"Untitled Post" - Views: 45 · Hits: 45 - Type: Unlisted

#include<fstream>
#include<string>
#include<iostream>
#include<cstdlib>
using namespace std;

int main(int argc, char *argv[])
{
string s1;
if(argc<=1)
{
cout<<"Please enter two names"<<endl;
perror(argv[1]);
exit(1);
}
cout<<"This program searches for regular expressions\nInput the expression"<<endl;
cin>>s1;
ofstream out("q5.l",ios::out);
out<<"%{\n#include <stdio.h>\nchar *filep;\n%}\n%%\n";
out<<s1<<"\tprintf(\"%s \",yytext);\n%%\n";
out<<"int main()\n{filep ="<<argv[1]<<";\nyyin=fopen(filep,\"r\");\nfilep ="<<argv[2]<<";\nyyout=fopen(filep,\"w+\");\nyylex();\nreturn 0;\n}\n";

system("/usr/bin/lex q5.l");
system("g++ lex.yy.c -lfl -o q5");
return 0;
}