Fin Analyse Lex

This commit is contained in:
Foussats Morgane 2021-03-12 10:49:22 +01:00
parent 3377294eea
commit 1fde03c4c1
4 changed files with 1977 additions and 0 deletions

0
Lex/Makefile Normal file
View file

BIN
Lex/a.out Executable file

Binary file not shown.

80
Lex/analyse_lexicale.lex Normal file
View file

@ -0,0 +1,80 @@
ADD "+"
SUB "-"
MUL "*"
DIV "/"
tPO "("
tPF ")"
tAO "{"
tAF "}"
EOL "\n"
EOI ";"
SPACE " "
TAB "\t"
VIRGULE ","
EGAL "="
LT "<"
GT ">"
tINT "int"
tMAIN "main"
tPRINT "printf"
tRETURN "return"
tIF "if"
tELSE "else"
tWHILE "while"
tNOT "!"
tAND "&&"
tOR "||"
DIGIT [0-9]
VARIABLE [A-Za-z0-9_]+
DECIMAL {DIGIT}+
EXPONENTIEL {DIGIT}+"^"{DIGIT}+
ENTIER {DECIMAL}|{EXPONENTIEL}
OPERATION {ADD}|{SUB}|{MUL}|{DIV}
COMPARATEUR {EGAL}|{LT}|{GT}
SEPARATOR {SPACE}|{TAB}
%%
{ADD} {printf("tADD ");}
{SUB} {printf("tSUB ");}
{MUL} {printf("tMUL ");}
{DIV} {printf("tDIV ");}
{tPO} {printf("tPO ");}
{tPF} {printf("tPF ");}
{tAO} {printf("tAO ");}
{tAF} {printf("tAF ");}
{EOI} {printf("tPV ");}
{SEPARATOR} {}
{EOL} {}
{VIRGULE} {printf("tVIRGULE ");}
{EGAL} {printf("tEGAL ");}
{LT} {printf("tLT ");}
{GT} {printf("tGT ");}
{tMAIN} {printf("tMAIN ");}
{tINT} {printf("tINT ");}
{tPRINT} {printf("tPRINT ");}
{tRETURN} {printf("tRETURN ");}
{tOR} {printf("tOR ");}
{tAND} {printf("tAND ");}
{tIF} {printf("tIF ");}
{tELSE} {printf("tELSE ");}
{tWHILE} {printf("tWHILE ");}
{ENTIER} {printf("tENTIER ");}
{VARIABLE} {printf("tVAR ");}
%%
int yywrap(void){
return 1;
}
int main(void){
yylex();
}

1897
Lex/lex.yy.c Normal file

File diff suppressed because it is too large Load diff