tp-langages-formels/syntaxique/langlex.l

40 lines
703 B
Plaintext
Raw Normal View History

2020-05-15 23:51:08 +00:00
%option noyywrap
DIG [0-9]
%%
"bool" { return BOOL; }
2020-05-16 22:06:02 +00:00
"int" { return TYPE_INT; }
2020-05-15 23:51:08 +00:00
"while" { return WHILE; }
"do" { return DO; }
"od" { return OD; }
2020-05-16 00:59:03 +00:00
"if" { return IF; }
"then" { return THEN; }
"fi" { return FI; }
"else" { return ELSE; }
2020-05-15 23:51:08 +00:00
"print" { return PRINT; }
"true" { return TRUE; }
"false" { return FALSE; }
2020-05-16 22:06:02 +00:00
{DIG}+ { yylval.val = atoi(yytext); return INT; }
2020-05-15 23:51:08 +00:00
":=" { return ASSIGN; }
2020-05-16 00:49:34 +00:00
"^" { return XOR; }
2020-05-15 23:51:08 +00:00
"||" { return OR; }
"&&" { return AND; }
2020-05-16 00:49:34 +00:00
"!" { return NOT; }
"<=>" { return EQUIV; }
2020-05-16 22:06:02 +00:00
"+" { return PLUS; }
"*" { return TIMES; }
"==" { return EQUALS; }
"<" { return LT; }
2020-05-15 23:51:08 +00:00
[a-z_][a-z0-9_]* { yylval.i = strdup(yytext); return IDENT; }
[ \n] { /* ignore */ }
. { return *yytext; }
%%