Question: Using Flex and Bison|Compiler Construction|LAB PART WRITE FLEX AND BISON CODE : The following is a grammar for a very simple programming language. Program -->

Using Flex and Bison|Compiler Construction|LAB PART

WRITE FLEX AND BISON CODE :

The following is a grammar for a very simple programming language. Program --> Statements Statements --> Statement Statements | Statement Statement --> AsstStmt AsstStmt --> Identifier = Expression Expression --> Expression + Term | Expression - Term | Term Term --> Term * Factor | Term / Factor | Factor Factor --> ( Expression ) | Identifier | Literal

An Identifier is a variable that has to start with a letter but after that can have all upper and lower case letters or digits from 0-9. E.g., temp, temp25, etc are valid. 25temp, 6, $temp, index$ etc. are invalid. A Literal can be either an integer or a floating point number. 1. Write a program that would be valid for this language. The program should have 10 different kinds of statements, demonstrating the capability of the given CFG (e.g., it can handle nested brackets). Name this file yourname-input.txt. [10] 2. Create a parser for this language using Flex and Bison, and give the file created for the previous question (1) as input to it. Given that the file is correct as per the specification, your parser should be able to parse it successfully. Your parser should either say parsed or error upon completion. No further details are required. [10] 3. Create 3 erroneous versions of your input file (yourname-error1.txt, yourname-error2.txt, yourname-error3.txt) such that your parser gives an error. [5] Submission guideline Submit the following 1)You Flex file 2) Your Bison file 3) Your make file 4) Your correct input file and screenshot proving it parses correctly 5) Your incorrect input files (3) and screenshot(s) proving that your parser catches the error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!