Lex programm to recgnize static words from english
/*
Aim : Write a programm to recgnize static words from english
*/
%{
#include<stdio.h>
%}
verb is|are|was|were
adjective good|bad|big|small
preposition this|under|below
adverb happely|gracefully
space [ \n]+
noune [a-zA-Z]+
%%
{verb} {fprintf(yyout,"\n%s\t\tVERB",yytext);}
{adverb} {fprintf(yyout,"\n%s\t\tADVERB",yytext);}
{adjective} {fprintf(yyout,"\n%s\t\tADJECTIVE",yytext);}
{noune} {fprintf(yyout,"\n%s\t\tNOUNE",yytext);}
. {;}
%%
int main()
{
yyout=fopen("out.txt","w");
yylex();
fclose(yyout);
}
Aim : Write a programm to recgnize static words from english
*/
%{
#include<stdio.h>
%}
verb is|are|was|were
adjective good|bad|big|small
preposition this|under|below
adverb happely|gracefully
space [ \n]+
noune [a-zA-Z]+
%%
{verb} {fprintf(yyout,"\n%s\t\tVERB",yytext);}
{adverb} {fprintf(yyout,"\n%s\t\tADVERB",yytext);}
{adjective} {fprintf(yyout,"\n%s\t\tADJECTIVE",yytext);}
{noune} {fprintf(yyout,"\n%s\t\tNOUNE",yytext);}
. {;}
%%
int main()
{
yyout=fopen("out.txt","w");
yylex();
fclose(yyout);
}
0 comments:
Post a Comment