Hello readers,
Lets learn today how to Run the Lex/Flex program on Windows Operating System -
Follow the give steps one by one to do so
Step 1 -
We need to download Yacc-compitable parser generator i.e Bison for that go to -http://gnuwin32.sourceforge.net/packages.html and click on Bison
Step 2 -
We also need to download setup for Flex i.e fast lexical analyzer generator from http://gnuwin32.sourceforge.net/packages.html and click on Flex
Step 3 -
After Downloading all the requirements, we will run the setup of Bison and Flex
Step 4 -
After that we need to add binaries to path so that we can run this from cmd.exe To add path follow bellow steps
Step 5 -
Open the Folder GnuWin32 from the place where you have stored the Bison setup while running the setup from step no 3
Step 6 -
Then Go to bin folder and copy the location of bin folder for example i have stored Bison setup files in E: drive under folder 3_year\2_sem\CD so my bin folder path is E:\3_year\2_sem\CD\GnuWin32\bin
Step 7 -
Now search Edit the system environment variables in search bar on Desktop and open it
Step 8 -
Then click on Environment Variables in right corner
Step 9 -
Now in User variable section I.e., first box select Path and click on Edit button
Step 10 -
After this double click on empty section or empty line and paste the path of bin folder
Step 11 -
Then click on ok on each window open
Step 12 -
Now you are ready for running the lex program on your system
Step 13 -
Now you can download any IDE to write your code or u can use notepad and save file with .l extension
Step 14 -
To run the file run the cmd and type flex <filename.l> example flex token.l
Step 15 -
Then run gcc lex.yy.c -o <exe file name > example gcc lex.yy.c -o token you can give any name not necessary to give same name as file name
Step 16 -
Now run the .exe file example token.exe

