Browse Source

ajout post-parser Flex pour transformer les fichier UNIX en Win \n --> \r\n
modifié le Makefile général en conséquance
ajout Makefile pour n2rn.l

Citnop 3 years ago
parent
commit
f7c7b19863
3 changed files with 94 additions and 1 deletions
  1. 5 1
      Makefile
  2. 27 0
      unix2win/Makefile
  3. 62 0
      unix2win/n2rn.l

+ 5 - 1
Makefile

@@ -16,10 +16,14 @@ cleanram: cpp
16 16
 	#make -C ./cleanRAM/
17 17
 	cd cleanRAM && make all
18 18
 
19
-cpp: doc
19
+cpp: n2rn
20 20
 	#make -C ./cpp/
21 21
 	cd cpp && make 
22 22
 
23
+n2rn: doc
24
+	#make -C ./unix2win/
25
+	cd unix2win && make all
26
+
23 27
 doc: h
24 28
 	#make -C ./cpp/
25 29
 	cd doc && make

+ 27 - 0
unix2win/Makefile

@@ -0,0 +1,27 @@
1
+CC=/usr/bin/gcc
2
+CFLAGS=-O3 -Wall 
3
+FLEX=/usr/bin/flex
4
+RM=/bin/rm
5
+
6
+
7
+# target
8
+help: h
9
+all: n2rn.out
10
+
11
+
12
+# rules
13
+h:
14
+	: "make all pour construire"
15
+	: "make clean pour nettoyer l'environnement"
16
+
17
+n2rn.out: lex.yy.c
18
+	${CC} ${CFLAGS} lex.yy.c -o n2rn.out
19
+	${RM} -f lex.yy.c 
20
+
21
+lex.yy.c: n2rn.l
22
+	${FLEX} n2rn.l
23
+
24
+# nettoyer
25
+clean: 
26
+	${RM} -f lex.yy.c *.out 
27
+

+ 62 - 0
unix2win/n2rn.l

@@ -0,0 +1,62 @@
1
+%option nounput noinput
2
+%option noyywrap
3
+
4
+%{
5
+/*
6
+#include <stdio.h>
7
+#include <stdlib.h>
8
+
9
+#define RED(str)   "\e[31m" str "\e[0m"
10
+#define GREEN(str) "\e[32m" str "\e[0m"
11
+
12
+#define YLW(str)  "\e[33m" str "\e[0m"
13
+#define BLUE(str)  "\e[34m" str "\e[0m"
14
+
15
+#define VLT(str)  "\e[35m" str "\e[0m"
16
+#define BLCL(str)  "\e[36m" str "\e[0m"
17
+
18
+
19
+void echog(char *lex_cat) {
20
+    fprintf(stdout,GREEN("[%s:%s]"), lex_cat, yytext); 
21
+}
22
+void echob(char *lex_cat) {
23
+    fprintf(stdout,BLUE("[%s:%s]"), lex_cat, yytext); 
24
+}
25
+void echor(char *lex_cat) {
26
+    fprintf(stdout,RED("[%s:%s]"), lex_cat, yytext); 
27
+}
28
+void echoy(char *lex_cat) {
29
+    fprintf(stdout,YLW("[%s:%s]"), lex_cat, yytext); 
30
+}
31
+void echov(char *lex_cat) {
32
+    fprintf(stdout,"%s", yytext); 
33
+}
34
+*/
35
+void echo() {
36
+    fprintf(stdout,"%s", yytext); 
37
+}
38
+void winNL(){
39
+    fprintf(stdout, "\r\n");
40
+}
41
+%}
42
+
43
+
44
+UNIXNL              [\n]
45
+
46
+
47
+%%
48
+
49
+
50
+{UNIXNL}            { winNL(); }
51
+.                   { echo(); } ; /* { std::cout << std::endl; } // */
52
+
53
+
54
+%%
55
+
56
+
57
+int main(int argc, char** argv) 
58
+{
59
+    // lex through the input:
60
+    yylex();
61
+    return 0;
62
+}