Question
Compiler Design Project 1: Implement a predictive parser for the example expression grammar 1. Introduction Implement a predictive parser for the example expression grammar. You
Compiler Design Project 1: Implement a predictive parser for the example expression grammar
1. Introduction Implement a predictive parser for the example expression grammar. You need to construct an abstract syntax tree for input expressions. Emit the abstract syntax tree for an input expression in preorder.
2. Input-Output specification Input : "input.txt" file that contains expressions - Input expressions only contain variables with a single character alphabet (like a, b, c, x, y, not like var1, length) - Input expressions may contain multiple digit number (like 150, 20, 293...) - Input expression may contains empty spaces within an expression (like 5 +10-x...) - Input expression does not contain brackets - Each expression is separated with a new line character (' ') Output : "output.txt" file that should contain results for each expression in the input file - For a syntactically incorrect expression, print "incorrect syntax" - For a syntactically correct expression, print the syntax tree for the expression in preorder (ex. *+234)
Input, output file example [input.txt] x-2*y a + 35 - b 10+*5 [output.txt] -x*2y -+a35b incorrect syntax
Please help!!!
Thanks a lot!!!
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