Code:
%{
%}
%%
#.*>
{fprintf(yyout,"Valid Header File: %s\n",yytext);}
(printf|scanf|if|else|while|do|break|continue|int|double|float|return|char|case|char|sizeof|
long|short|typedef|switch|unsigned|void|static|struct|goto)
{fprintf(yyout,"Valid
Keyword:
%s\n",yytext);}
(\+|\-|\*|\/|\=|\%|\>|\<)
{fprintf(yyout,"Valid Operator: %s\n",yytext);}
[0-9]+\.?[0-9]+
{ fprintf(yyout,"Valid Constant: %s\n",yytext);}
[a-zA-Z]+[0-9]*
{ fprintf(yyout,"Valid Identifier: %s\n",yytext);}
[\"].*[\"]
{ fprintf(yyout,"Valid Literal: %s\n",yytext);}
(\(|\)|\{|\}|\;|\,|\&)
{ fprintf(yyout,"Valid Special Symbols: %s\n",yytext);}
%%
main()
{
yyin=fopen("input.c","r");
yyout=fopen("output.txt","w");
yylex();
}
int
yywrap()
{
return
1;
No comments:
Post a Comment