%option noyywrap %{ #include %} digit [0-9] letter [A-Za-z] key "int"|"main"|"for"|"return"|"printf"|"while"|"scanf"|"if" %% {key} {printf("%s is a keyword and length is: %d\n", yytext, yyleng);} {letter}({letter}|{digit})* {printf("%s is an identifier and length is: %d\n", yytext, yyleng);} {digit}+ {printf("%s is an int value: %d\n", yytext, atoi(yytext));} {digit}+"."{digit}+ {printf("%s is a floating-point number and value is: %f\n", yytext, atof(yytext));} %% int main() { yylex(); return 0; }