This post is about to run the LEX program in Windows Platform instead of wasteing your time in installing LINUX into your machine..
First of all download a files named "flex.exe" and "Bison.exe" from the following sites..
http://www.monmouth.com/~wstreett/lex-yacc/flex.exe
http://www.monmouth.com/~wstreett/lex-yacc/bison.exe
Now you can start from here:
1. Create a folder and place the flex and bison files in them.
2. Create the lex program and save in the folder(like 'program.l' or 'program.txt')
3. Open the command prompt and reach the directory.
4. Call the flex by the command "flex <filename.extension>" (like 'flex program.l')
5. If the program contain any error it will showed to you, otherwise it will generate the file named "lex.yy.c".I suggest you rename “lex.yy.c” to some other more sensible name like “lex.c”, because double extensions is not a good idea in windows environment. Move the file to the folder of your compiler.
6. Call the compiler and input lex.c to it (eg: “tcc lex.c”, where tcc is the Turbo C compiler; use any C/C++ compiler you have). If what you have is a more sophisticated environment like visual studio, you have to do the normal procedure to get a program to compile. If you use Turbo C, an object file “lex.obj’ and the executable “lex.exe” will be generated if there are no compilation problems
7. Thats it. Now just run lex.exe. Its your lexical analyser.
It is very similar to the way you do it in linux.
All the seven steps look like a complicated procedure. I created a batch file(.bat files similar to shell scrpits in linux) , to do the whole job from calling flex to get the lex.exe up and running. My batch file(rflex.bat) looks like below.
flex program.txt
ren lex.yy.c lex.c
copy lex.c c:\tc\bin\
c:
cd tc
cd bin
tcc lex.c
lex
c:
cd “Compiler Design”
del lex.yy.c
del lex.c
All the program can be carried out likewise.
First of all download a files named "flex.exe" and "Bison.exe" from the following sites..
http://www.monmouth.com/~wstreett/lex-yacc/flex.exe
http://www.monmouth.com/~wstreett/lex-yacc/bison.exe
Now you can start from here:
1. Create a folder and place the flex and bison files in them.
2. Create the lex program and save in the folder(like 'program.l' or 'program.txt')
3. Open the command prompt and reach the directory.
4. Call the flex by the command "flex <filename.extension>" (like 'flex program.l')
5. If the program contain any error it will showed to you, otherwise it will generate the file named "lex.yy.c".I suggest you rename “lex.yy.c” to some other more sensible name like “lex.c”, because double extensions is not a good idea in windows environment. Move the file to the folder of your compiler.
6. Call the compiler and input lex.c to it (eg: “tcc lex.c”, where tcc is the Turbo C compiler; use any C/C++ compiler you have). If what you have is a more sophisticated environment like visual studio, you have to do the normal procedure to get a program to compile. If you use Turbo C, an object file “lex.obj’ and the executable “lex.exe” will be generated if there are no compilation problems
7. Thats it. Now just run lex.exe. Its your lexical analyser.
It is very similar to the way you do it in linux.
All the seven steps look like a complicated procedure. I created a batch file(.bat files similar to shell scrpits in linux) , to do the whole job from calling flex to get the lex.exe up and running. My batch file(rflex.bat) looks like below.
flex program.txt
ren lex.yy.c lex.c
copy lex.c c:\tc\bin\
c:
cd tc
cd bin
tcc lex.c
lex
c:
cd “Compiler Design”
del lex.yy.c
del lex.c
All the program can be carried out likewise.
plz help me its not working
ReplyDeleteinternal external command not found type of error
ReplyDeleteCool and I have a nifty offer: Whole House Reno house renovation quotes
ReplyDelete