%{
#include <stdio.h>
%}
/* ----- RÈGLES ----- */
%%
"if" { printf("KW_IF\n"); }
"else" { printf("KW_ELSE\n"); }
"while" { printf("KW_WHILE\n"); }
/* Operateurs de comparaison */
"==" { printf("EQ\n"); }
"!=" { printf("NEQ\n"); }
"<=" { printf("LE\n"); }
">=" { printf("GE\n"); }
"<" { printf("LT\n"); }
">" { printf("GT\n"); }
/* Operateurs arithmétiques */
"=" { printf("ASSIGN\n"); }
"+" { printf("PLUS\n"); }
"-" { printf("MINUS\n"); }
"*" { printf("MULT\n"); }
"/" { printf("DIV\n"); }
/* Délimiteurs */
"(" { printf("LPAREN\n"); }
")" { printf("RPAREN\n"); }
"{" { printf("LBRACE\n"); }
"}" { printf("RBRACE\n"); }
/* Identifiant */
[a-zA-Z_][a-zA-Z0-9_]* { printf("IDENT(%s)\n", yytext); }
/* Nombre entier */
[0-9]+ { printf("INT(%s)\n", yytext); }
/* Commentaires */
"//"[^\n]* ;
/* Espaces : ignorés */
[ \t\n]+ ;
/* Tout le reste = erreur */
. { printf("ERROR(%s)\n", yytext); }
%%
int main() {
yylex();
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiV9CgovKiAtLS0tLSBSw4hHTEVTIC0tLS0tICovCiUlCiJpZiIgICAgICAgIHsgcHJpbnRmKCJLV19JRlxuIik7IH0KImVsc2UiICAgICAgeyBwcmludGYoIktXX0VMU0VcbiIpOyB9CiJ3aGlsZSIgICAgIHsgcHJpbnRmKCJLV19XSElMRVxuIik7IH0KCi8qIE9wZXJhdGV1cnMgZGUgY29tcGFyYWlzb24gKi8KIj09IiAgICAgICAgeyBwcmludGYoIkVRXG4iKTsgfQoiIT0iICAgICAgICB7IHByaW50ZigiTkVRXG4iKTsgfQoiPD0iICAgICAgICB7IHByaW50ZigiTEVcbiIpOyB9CiI+PSIgICAgICAgIHsgcHJpbnRmKCJHRVxuIik7IH0KIjwiICAgICAgICAgeyBwcmludGYoIkxUXG4iKTsgfQoiPiIgICAgICAg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