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