/*** Definition Section ***/ %{ int v=0; int k=0; int t=0; %} /*** Rule Section ***/ %% ^if|else|while|int|switch|for|char t++ ; printf("Valid Keywords\n"); ^[_]*[a-zA-Z][a-zA-Z0-9]*[_]* v++ ; printf("Valid Identifier\n"); ^([//]*[/*]*)[0-9]*[A-Z]*([//]*[/*]*)+ v++; printf("Valid Identifier\n"); ^[/]+[a-zA-z]*[0-9]*[/]+ k++; printf("Valid Comments\n"); \n {return 0;} %% /*** Code Section ***/ int yywrap(){} int main(){ yylex(); if (v==0 && k==0 && t==0) printf("Invalid \n"); return 0; }