%{
#include <stdio.h>
%}
%%
int
|float|char
|double
{ printf
("Data Type
: %s\n", yytext); }if|else|for|while { printf("Keyword: %s\n", yytext); }
[0-9]+ { printf
("
Number: %s\n", yytext); } [a-zA-Z_][a-zA-Z0-9_]* { printf("Identifier: %s\n", yytext); }
[(),;{}] { printf("Punctuation: %s\n", yytext); }
[ \t\n] ; // Ignore whitespace and newline characters
. { printf("Unknown: %s\n", yytext); }
%%
int yywrap() {
return 1;
}
int main(int argc, char *argv[]) {
++argv, --argc;
if (argc > 0)
yyin = fopen(argv[0], "r");
else
yyin = stdin;
yylex();
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiV9CgolJQoKaW50fGZsb2F0fGNoYXJ8ZG91YmxlICAgeyBwcmludGYoIkRhdGEgVHlwZTogJXNcbiIsIHl5dGV4dCk7IH0KaWZ8ZWxzZXxmb3J8d2hpbGUgICAgICAgeyBwcmludGYoIktleXdvcmQ6ICVzXG4iLCB5eXRleHQpOyB9ClswLTldKyAgICAgICAgICAgICAgICAgIHsgcHJpbnRmKCJOdW1iZXI6ICVzXG4iLCB5eXRleHQpOyB9ClthLXpBLVpfXVthLXpBLVowLTlfXSogIHsgcHJpbnRmKCJJZGVudGlmaWVyOiAlc1xuIiwgeXl0ZXh0KTsgfQpbKCksO3t9XSAgICAgICAgICAgICAgICB7IHByaW50ZigiUHVuY3R1YXRpb246ICVzXG4iLCB5eXRleHQpOyB9ClsgXHRcbl0gICAgICAgICAgICAgICAgIDsgLy8gSWdub3JlIHdoaXRlc3BhY2UgYW5kIG5ld2xpbmUgY2hhcmFjdGVycwouICAgICAgICAgICAgICAgICAgICAgICB7IHByaW50ZigiVW5rbm93bjogJXNcbiIsIHl5dGV4dCk7IH0KCiUlCgppbnQgeXl3cmFwKCkgewogICAgcmV0dXJuIDE7Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pIHsKICAgICsrYXJndiwgLS1hcmdjOwogICAgaWYgKGFyZ2MgPiAwKQogICAgICAgIHl5aW4gPSBmb3Blbihhcmd2WzBdLCAiciIpOwogICAgZWxzZQogICAgICAgIHl5aW4gPSBzdGRpbjsKICAgIHl5bGV4KCk7CiAgICByZXR1cm4gMDsKfQo=