%{
#include<stdio.h>
%}
DIGIT [0-9]
ID [_a-zA-Z][a-zA-z0-9]
KEYWORD [if/else/while/int]
OP "
>"
|"
<"
|"
="
|"
>="
|"
<="
|"
+"
|"
*"
|"
/"
|"
-"
SPECIALCHARACTER "'"|";"|":"|","|"("|")"
%%
{KEYWORD}+ {printf("%s is a keyword\n",yytext);}
[0-9]+ {printf("%s is an integer\n",yytext);}
{ID}+ {printf("%s is an identifier\n",yytext);}
{OP}+ {printf("%s is an operator\n",yytext);}
{SPECIALCHARACTER}+ {printf("%s is a special character\n",yytext);}
%%
int main()
{
extern FILE *yyin;
yyin = fopen("t1.txt","r");
yylex();
fclose(yyin);
return 0;
}
int yywrap()
{
return 1;
}
JXsKI2luY2x1ZGU8c3RkaW8uaD4KJX0KCkRJR0lUIFswLTldCklEIFtfYS16QS1aXVthLXpBLXowLTldCktFWVdPUkQgW2lmL2Vsc2Uvd2hpbGUvaW50XQpPUCAiPiJ8IjwifCI9InwiPj0ifCI8PSJ8IisifCIqInwiLyJ8Ii0iClNQRUNJQUxDSEFSQUNURVIgIicifCI7InwiOiJ8IiwifCIoInwiKSIKJSUKe0tFWVdPUkR9KyB7cHJpbnRmKCIlcyBpcyBhIGtleXdvcmRcbiIseXl0ZXh0KTt9ClswLTldKyB7cHJpbnRmKCIlcyBpcyBhbiBpbnRlZ2VyXG4iLHl5dGV4dCk7fQp7SUR9KyB7cHJpbnRmKCIlcyBpcyBhbiBpZGVudGlmaWVyXG4iLHl5dGV4dCk7fQp7T1B9KyB7cHJpbnRmKCIlcyBpcyBhbiBvcGVyYXRvclxuIix5eXRleHQpO30Ke1NQRUNJQUxDSEFSQUNURVJ9KyB7cHJpbnRmKCIlcyBpcyBhIHNwZWNpYWwgY2hhcmFjdGVyXG4iLHl5dGV4dCk7fQolJQppbnQgbWFpbigpCnsKCWV4dGVybiBGSUxFICp5eWluOwogICAgCXl5aW4gPSBmb3BlbigidDEudHh0IiwiciIpOwogICAJeXlsZXgoKTsKICAgCWZjbG9zZSh5eWluKTsKCiAgICByZXR1cm4gMDsKfQoKaW50IHl5d3JhcCgpCnsKCXJldHVybiAxOwp9