%{
#include <stdio.h>
%}
// Regular expressions for different token types
%%
"int"|"float"|"char"|"if"|"else"|"for"|"while" { printf("KEYWORD: %s\n", yytext); }
[a-zA-Z_][a-zA-Z0-9_]* { printf("IDENTIFIER: %s\n", yytext); }
[0-9]+ { printf
("
INTEGER: %s\n", yytext); } [0-9]+"
."
[0-9]+ { printf
("
FLOAT: %s\n", yytext); } "=="|"<="|">="|"!="|"<"|">" { printf("RELATIONAL OPERATOR: %s\n", yytext); }
"=" { printf("ASSIGNMENT OPERATOR: %s\n", yytext); }
"(" { printf("LEFT PARENTHESIS: %s\n", yytext); }
")" { printf("RIGHT PARENTHESIS: %s\n", yytext); }
"{" { printf("LEFT BRACE: %s\n", yytext); }
"}" { printf("RIGHT BRACE: %s\n", yytext); }
"+"|"-"|"*"|"/" { printf("ARITHMETIC OPERATOR: %s\n", yytext); }
";" { printf("SEMICOLON: %s\n", yytext); }
[ \t\n]+ { /* Ignore whitespace */ }
. { printf("UNKNOWN: %s\n", yytext); }
%%
int main() {
// Start lexical analysis
yylex();
return 0;
}
int yywrap() {
return 1;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiV9CgovLyBSZWd1bGFyIGV4cHJlc3Npb25zIGZvciBkaWZmZXJlbnQgdG9rZW4gdHlwZXMKJSUKImludCJ8ImZsb2F0InwiY2hhciJ8ImlmInwiZWxzZSJ8ImZvciJ8IndoaWxlIiAgICAgICB7IHByaW50ZigiS0VZV09SRDogJXNcbiIsIHl5dGV4dCk7IH0KW2EtekEtWl9dW2EtekEtWjAtOV9dKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHByaW50ZigiSURFTlRJRklFUjogJXNcbiIsIHl5dGV4dCk7IH0KWzAtOV0rICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHByaW50ZigiSU5URUdFUjogJXNcbiIsIHl5dGV4dCk7IH0KWzAtOV0rIi4iWzAtOV0rICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHByaW50ZigiRkxPQVQ6ICVzXG4iLCB5eXRleHQpOyB9CiI9PSJ8Ijw9InwiPj0ifCIhPSJ8IjwifCI+IiAgICAgICAgICAgICAgICAgICAgICAgICAgeyBwcmludGYoIlJFTEFUSU9OQUwgT1BFUkFUT1I6ICVzXG4iLCB5eXRleHQpOyB9CiI9IiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBwcmludGYoIkFTU0lHTk1FTlQgT1BFUkFUT1I6ICVzXG4iLCB5eXRleHQpOyB9CiIoIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBwcmludGYoIkxFRlQgUEFSRU5USEVTSVM6ICVzXG4iLCB5eXRleHQpOyB9CiIpIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBwcmludGYoIlJJR0hUIFBBUkVOVEhFU0lTOiAlc1xuIiwgeXl0ZXh0KTsgfQoieyIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgcHJpbnRmKCJMRUZUIEJSQUNFOiAlc1xuIiwgeXl0ZXh0KTsgfQoifSIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgcHJpbnRmKCJSSUdIVCBCUkFDRTogJXNcbiIsIHl5dGV4dCk7IH0KIisifCItInwiKiJ8Ii8iICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHByaW50ZigiQVJJVEhNRVRJQyBPUEVSQVRPUjogJXNcbiIsIHl5dGV4dCk7IH0KIjsiICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHByaW50ZigiU0VNSUNPTE9OOiAlc1xuIiwgeXl0ZXh0KTsgfQpbIFx0XG5dKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgLyogSWdub3JlIHdoaXRlc3BhY2UgKi8gfQouICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgcHJpbnRmKCJVTktOT1dOOiAlc1xuIiwgeXl0ZXh0KTsgfQolJQoKaW50IG1haW4oKSB7CiAgICAvLyBTdGFydCBsZXhpY2FsIGFuYWx5c2lzCiAgICB5eWxleCgpOwogICAgcmV0dXJuIDA7Cn0KCmludCB5eXdyYXAoKSB7CiAgICByZXR1cm4gMTsKfQo=