Browse Source

Fin Analyse Lex

Foussats Morgane 3 years ago
parent
commit
1fde03c4c1
4 changed files with 1977 additions and 0 deletions
  1. 0
    0
      Lex/Makefile
  2. BIN
      Lex/a.out
  3. 80
    0
      Lex/analyse_lexicale.lex
  4. 1897
    0
      Lex/lex.yy.c

+ 0
- 0
Lex/Makefile View File


BIN
Lex/a.out View File


+ 80
- 0
Lex/analyse_lexicale.lex View File

@@ -0,0 +1,80 @@
1
+ADD         "+"
2
+SUB         "-"
3
+MUL         "*"
4
+DIV         "/"
5
+tPO         "("
6
+tPF         ")"
7
+tAO         "{"
8
+tAF         "}"
9
+EOL         "\n"
10
+EOI         ";"
11
+SPACE       " "
12
+TAB         "\t"
13
+VIRGULE     ","
14
+EGAL        "="
15
+LT          "<"
16
+GT          ">"
17
+tINT        "int"
18
+tMAIN       "main"  
19
+tPRINT      "printf"
20
+tRETURN     "return"
21
+tIF         "if"
22
+tELSE       "else"
23
+tWHILE      "while"
24
+tNOT        "!"
25
+tAND        "&&"
26
+tOR         "||"
27
+DIGIT       [0-9]
28
+VARIABLE    [A-Za-z0-9_]+
29
+DECIMAL     {DIGIT}+
30
+EXPONENTIEL {DIGIT}+"^"{DIGIT}+
31
+ENTIER      {DECIMAL}|{EXPONENTIEL}
32
+OPERATION   {ADD}|{SUB}|{MUL}|{DIV}
33
+COMPARATEUR {EGAL}|{LT}|{GT}
34
+SEPARATOR   {SPACE}|{TAB}
35
+
36
+%%
37
+
38
+{ADD}           {printf("tADD ");}
39
+{SUB}           {printf("tSUB ");}
40
+{MUL}           {printf("tMUL ");}
41
+{DIV}           {printf("tDIV ");}
42
+
43
+{tPO}           {printf("tPO ");}
44
+{tPF}           {printf("tPF ");}
45
+{tAO}           {printf("tAO ");}
46
+{tAF}           {printf("tAF ");}
47
+
48
+{EOI}           {printf("tPV ");}
49
+{SEPARATOR}     {}
50
+{EOL}           {}
51
+{VIRGULE}       {printf("tVIRGULE ");}
52
+
53
+{EGAL}          {printf("tEGAL ");}
54
+{LT}            {printf("tLT ");}
55
+{GT}            {printf("tGT ");}
56
+
57
+{tMAIN}         {printf("tMAIN ");}
58
+{tINT}          {printf("tINT ");}
59
+{tPRINT}        {printf("tPRINT ");}
60
+{tRETURN}       {printf("tRETURN ");}
61
+
62
+{tOR}           {printf("tOR ");}
63
+{tAND}          {printf("tAND ");}
64
+
65
+{tIF}           {printf("tIF ");}
66
+{tELSE}         {printf("tELSE ");}
67
+{tWHILE}        {printf("tWHILE ");}
68
+
69
+{ENTIER}        {printf("tENTIER ");}
70
+{VARIABLE}      {printf("tVAR ");}
71
+
72
+%%
73
+int yywrap(void){
74
+    return 1;
75
+}
76
+int main(void){
77
+    yylex();
78
+}
79
+
80
+

+ 1897
- 0
Lex/lex.yy.c
File diff suppressed because it is too large
View File


Loading…
Cancel
Save