40 lines
703 B
Plaintext
40 lines
703 B
Plaintext
%option noyywrap
|
|
|
|
DIG [0-9]
|
|
|
|
%%
|
|
|
|
"bool" { return BOOL; }
|
|
"int" { return TYPE_INT; }
|
|
"while" { return WHILE; }
|
|
"do" { return DO; }
|
|
"od" { return OD; }
|
|
"if" { return IF; }
|
|
"then" { return THEN; }
|
|
"fi" { return FI; }
|
|
"else" { return ELSE; }
|
|
"print" { return PRINT; }
|
|
"true" { return TRUE; }
|
|
"false" { return FALSE; }
|
|
{DIG}+ { yylval.val = atoi(yytext); return INT; }
|
|
|
|
":=" { return ASSIGN; }
|
|
"^" { return XOR; }
|
|
"||" { return OR; }
|
|
"&&" { return AND; }
|
|
"!" { return NOT; }
|
|
"<=>" { return EQUIV; }
|
|
"+" { return PLUS; }
|
|
"*" { return TIMES; }
|
|
"==" { return EQUALS; }
|
|
"<" { return LT; }
|
|
|
|
[a-z_][a-z0-9_]* { yylval.i = strdup(yytext); return IDENT; }
|
|
|
|
[ \n] { /* ignore */ }
|
|
|
|
. { return *yytext; }
|
|
|
|
%%
|
|
|