Question
Using Flex and Bison|Compiler Construction|LAB PART|please make the code error free WRITE FLEX AND BISON CODE : The following is a grammar for a very
Using Flex and Bison|Compiler Construction|LAB PART|please make the code error free
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started