2021-03-22 12:45:21 +01:00
|
|
|
%{
|
|
|
|
#include "analyse_syntaxique.tab.h"
|
|
|
|
int yywrap(void){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-18 12:18:42 +01:00
|
|
|
ADD "+"
|
|
|
|
SUB "-"
|
|
|
|
MUL "*"
|
|
|
|
DIV "/"
|
|
|
|
tPO "("
|
|
|
|
tPF ")"
|
|
|
|
tAO "{"
|
|
|
|
tAF "}"
|
|
|
|
EOL "\n"
|
|
|
|
EOI ";"
|
|
|
|
SPACE " "
|
|
|
|
TAB "\t"
|
|
|
|
VIRGULE ","
|
|
|
|
AFFECTATION "="
|
|
|
|
EQUAL "=="
|
|
|
|
LT "<"
|
|
|
|
GT ">"
|
|
|
|
LTE "<="
|
|
|
|
GTE ">="
|
|
|
|
tINT "int"
|
|
|
|
tMAIN "main"
|
|
|
|
tPRINT "printf"
|
|
|
|
tRETURN "return"
|
|
|
|
tIF "if"
|
|
|
|
tELSE "else"
|
|
|
|
tWHILE "while"
|
|
|
|
tNOT "!"
|
|
|
|
tAND "&&"
|
|
|
|
tOR "||"
|
|
|
|
tDIFF "!="
|
2021-04-30 17:08:29 +02:00
|
|
|
tAPPERSAND "&"
|
2021-03-18 12:18:42 +01:00
|
|
|
DIGIT [0-9]
|
|
|
|
VARIABLE [A-Za-z0-9_]+
|
|
|
|
CONST "const"
|
|
|
|
DECIMAL {DIGIT}+
|
2021-03-22 12:45:21 +01:00
|
|
|
EXPONENTIEL {DIGIT}+"e"{DIGIT}+
|
|
|
|
ENTIER {DECIMAL}
|
|
|
|
ENTIEREXP {EXPONENTIEL}
|
2021-03-18 12:18:42 +01:00
|
|
|
OPERATION {ADD}|{SUB}|{MUL}|{DIV}
|
|
|
|
COMPARATEUR {EGAL}|{LT}|{GT}
|
|
|
|
SEPARATOR {SPACE}|{TAB}
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
{ADD} {return tADD ;}
|
|
|
|
{SUB} {return tSUB ;}
|
|
|
|
{MUL} {return tMUL ;}
|
|
|
|
{DIV} {return tDIV ;}
|
|
|
|
|
|
|
|
{tPO} {return tPO ;}
|
|
|
|
{tPF} {return tPF ;}
|
|
|
|
{tAO} {return tAO ;}
|
|
|
|
{tAF} {return tAF ;}
|
|
|
|
|
|
|
|
{EOI} {return tPV ;}
|
|
|
|
{SEPARATOR} {}
|
|
|
|
{EOL} {}
|
|
|
|
{VIRGULE} {return tVIRGULE ;}
|
|
|
|
|
|
|
|
{AFFECTATION} {return tAFFECTATION ;}
|
|
|
|
|
|
|
|
{EQUAL} {return tEGAL ;}
|
|
|
|
{tDIFF} {return tDIFF ;}
|
|
|
|
{LT} {return tLT ;}
|
|
|
|
{GT} {return tGT ;}
|
|
|
|
{LTE} {return tLTE ;}
|
|
|
|
{GTE} {return tGTE ;}
|
|
|
|
{tNOT} {return tNOT ;}
|
|
|
|
|
|
|
|
|
|
|
|
{tMAIN} {return tMAIN ;}
|
|
|
|
{tINT} {return tINT ;}
|
|
|
|
{tPRINT} {return tPRINT ;}
|
|
|
|
{tRETURN} {return tRETURN ;}
|
|
|
|
|
|
|
|
{tOR} {return tOR ;}
|
|
|
|
{tAND} {return tAND ;}
|
|
|
|
|
|
|
|
{tIF} {return tIF ;}
|
|
|
|
{tELSE} {return tELSE ;}
|
|
|
|
{tWHILE} {return tWHILE ;}
|
|
|
|
|
2021-04-30 17:08:29 +02:00
|
|
|
{tAPPERSAND} {return tAPPERSAND;}
|
2021-03-18 12:18:42 +01:00
|
|
|
{CONST} {return tCONST ;}
|
2021-03-22 12:45:21 +01:00
|
|
|
{ENTIER} {yylval.nombre = atoi(yytext); return tENTIER ;}
|
|
|
|
{ENTIEREXP} {yylval.nombre = -1; return tENTIEREXP;}
|
|
|
|
{VARIABLE} {strcpy(yylval.id, yytext); return tVAR ;}
|
2021-03-18 12:18:42 +01:00
|
|
|
|
|
|
|
%%
|
2021-03-22 12:45:21 +01:00
|
|
|
|
2021-03-18 12:18:42 +01:00
|
|
|
//int main(void){
|
|
|
|
// yylex();
|
|
|
|
//}
|
|
|
|
|
|
|
|
|