%{
#include <stdio.h>
#include <string.h>
int lineno = 1;
%}
%%
"int" { printf("Keyword: %s\n", yytext); }
"float" { printf("Keyword: %s\n", yytext); }
"if" { printf("Keyword: %s\n", yytext); }
"else" { printf("Keyword: %s\n", yytext); }
"return" { printf("Keyword: %s\n", yytext); }
[0-9]+ { printf("Constant: %s\n", yytext); }
[a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
"==" { printf("Operator: %s\n", yytext); }
"=" { printf("Operator: %s\n", yytext); }
"+" { printf("Operator: %s\n", yytext); }
"-" { printf("Operator: %s\n", yytext); }
"*" { printf("Operator: %s\n", yytext); }
"/" { printf("Operator: %s\n", yytext); }
";" { printf("Delimiter: %s\n", yytext); }
"," { printf("Delimiter: %s\n", yytext); }
"(" { printf("Delimiter: %s\n", yytext); }
")" { printf("Delimiter: %s\n", yytext); }
"{" { printf("Delimiter: %s\n", yytext); }
"}" { printf("Delimiter: %s\n", yytext); }
[\n] { lineno++; }
[ \t] { /* skip whitespace */ }
. { printf("Unknown token: %s\n", yytext); }
%%
int main() {
yylex();
return 0;
}
int yywrap() {
return 1;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBsaW5lbm8gPSAxOwolfQoKJSUKImludCIgICAgICAgeyBwcmludGYoIktleXdvcmQ6ICVzXG4iLCB5eXRleHQpOyB9CiJmbG9hdCIgICAgIHsgcHJpbnRmKCJLZXl3b3JkOiAlc1xuIiwgeXl0ZXh0KTsgfQoiaWYiICAgICAgICB7IHByaW50ZigiS2V5d29yZDogJXNcbiIsIHl5dGV4dCk7IH0KImVsc2UiICAgICAgeyBwcmludGYoIktleXdvcmQ6ICVzXG4iLCB5eXRleHQpOyB9CiJyZXR1cm4iICAgIHsgcHJpbnRmKCJLZXl3b3JkOiAlc1xuIiwgeXl0ZXh0KTsgfQoKWzAtOV0rICAgICAgeyBwcmludGYoIkNvbnN0YW50OiAlc1xuIiwgeXl0Z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