Flex is a powerful tool for generating scanners: programs that recognize lexical patterns in text. Use this guide to quickly start running Flex programs on Windows.
First, you need to download the Flex tool for Windows:
- Download here: Flex Windows (Lex and Yacc)
Follow these steps to set up and run your Flex programs:
Once downloaded, open the Flex tool.
Create a new file by selecting the "lex" option.
Paste your Lex code into the new file and save it with the .l
extension. Ensure you select "All Files" as the file type.
Now, proceed with the following:
- Click on
1
(Lex File Compile) - Click on
2
(Lex Build) - Click on
6
(Open CMD)
When the command prompt opens, type in the file name you saved with the .exe
extension and enter your input to view the result.
Save the file "name: file2.star.txt" you want to scan example:
Now save the lex code in same folder as the scanner file, make sure the file name is same :
Follow above step 4 and step 5 to build and compile: output:
Create and compile lex file by clicking 1 (lex file compile) :
Create a new bison file with ".y" as extension
after entering bison code, click 3 (yacc compile) :
open cmd by clicking 6 (open cmd) and type in following commands :
Enter your query and it will display the output.
That's it! You are now ready to run and test your own Flex programs on Windows. Enjoy coding your scanner projects!
Feel free to reach out or contribute to this repository if you have any suggestions or improvements!