Skip to content

Compiler Design experiments including c, flex, bison, scanner, java and other codes

Notifications You must be signed in to change notification settings

Ahad1317/CompilerDesign--18CSC304J

Repository files navigation

🚀 Running Flex Programs

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.

📥 Download Flex Tool

First, you need to download the Flex tool for Windows:

🛠️ Setup and Usage

Follow these steps to set up and run your Flex programs:

Step 1: Open Flex Tool

Once downloaded, open the Flex tool.

Step 2: Create a New File

Create a new file by selecting the "lex" option.

Create File

Step 3: Enter Your Lex Code

Paste your Lex code into the new file and save it with the .l extension. Ensure you select "All Files" as the file type.

Save File

Step 4: Compile and Build

Now, proceed with the following:

  1. Click on 1 (Lex File Compile)
  2. Click on 2 (Lex Build)
  3. Click on 6 (Open CMD)

Compile and Build

Step 5: Run Your Program

When the command prompt opens, type in the file name you saved with the .exe extension and enter your input to view the result.

Run Program


🚀 Running Scanner Programs

Save the file "name: file2.star.txt" you want to scan example:

image

Now save the lex code in same folder as the scanner file, make sure the file name is same :

image

Follow above step 4 and step 5 to build and compile: output:

image


🚀 Running Bison Programs

Create and compile lex file by clicking 1 (lex file compile) :

image

Create a new bison file with ".y" as extension

image

after entering bison code, click 3 (yacc compile) :

image

open cmd by clicking 6 (open cmd) and type in following commands :

image

Enter your query and it will display the output.

🌟 Conclusion

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!