Saturday, 8 September 2018

Write a LEX program that reads input file and copies only words starting with vowels to output file.


               Code :

%{
#include<stdio.h>
#include<string.h>
%}
alpha [a-zA-Z]
digit [0-9]
space [ \n\t]
start ^(a|e|i|o|u|A|E|I|O|U)
%%
{start}({alpha}|{digit})* {fprintf(yyout,"%s",yytext);}
{space}(a|e|i|o|u|A|E|I|O|U)({alpha}|{digit})*  {fprintf(yyout,"%s",yytext);}
. ;
%%
main()
{
yyin=fopen("in.txt","r");
yyout=fopen("out.txt","w");
yylex();
}
int yywrap()
{
return 1;
}

No comments:

Post a Comment

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...