Sunday, 16 June 2019

Write a LEX program that reads a c program from input file and eliminates single line as well as multi-line comments from it and copies updates program to output file.


             

               Code :

%{
#include<stdio.h>
%}
%%
\/\/.* {fprintf(yyout,"");}
\/\*(.*\n)*.*\*\/ {fprintf(yyout,"");}
. ; {fprintf(yyout,"%s",yytext);}
%%
main()
{
yyin=fopen("input.txt","r");
yyout=fopen("output.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...