%{ 
%}
identifier [a-zA-Z]*
digit [0-9]
letter [a-zA-Z]
 int com = 0,com1 = 0;
%%
#.* { printf("\n%s is PRE PROCESSOR DIRECTIVE",yytext); }
int|float|if { if(!com) printf("\n keyword %s ",yytext); }
"/*" { com=1; printf("\n Comments"); }
"*/" { com=0; }
[a-z]+ { if(!com) printf("\n varibles %s ",yytext); }
{identifier}\( { if(!com) printf("\n function %s",yytext); }
\{ { if(!com) printf("\n block begines "); }
\} { if(!com) printf("\n block ends "); }
\".*\" { if(!com) printf("\n string is %s ",yytext); }
[0-9]+ { if(!com) printf("\n number is %s ",yytext); }
\\ { if(!com) printf("\n\t"); }
= { if(!com) printf("\n assigment %s ",yytext); }
\<=|\>=|\>|\<|\== { if(!com) printf("\n relational operators %s 
",yytext); }
%%
main(argc,argv)
int argc;
char **argv;
{
if(argc>1)
{
FILE *file;
file=fopen(argv[1],"r");
if(!file)
{
printf("couldnot open %s",argv[1]);
exit(0);
}
yyin=file;
}
yylex();
}
int yywrap()
{
return(0);
}
 