Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Lex and Yacc to construct a translator from modified tiny BASIC ; the translator will parse input code according to the given grammar and
Use Lex and Yacc to construct a translator from modified tiny BASIC ; the translator will parse input code according to the given grammar and generate C/C++ code which you be able to compile and test. Note that the link describes a tiny BASIC compiler. This is a front end for a compiler, using C/C++ as intermediate code.
Modified tiny BASIC:
/* modified tiny basic - terminals in CAPS */ program ::= block block ::= block line | line line ::= INTEGER statement CR | statement CR statement ::= PRINT expr-list | IF expression relop expression THEN statement | GOTO expression | INPUT var-list | LET var = expression | GOTO expression | END expr-list ::= expr-list , expression | expression var-list ::= var-list , var | var expression ::= expression + term | expression - term | term term ::= term * factor | term / factor | factor factor ::= var | number | (expression) number ::= INTEGER | DECIMAL var ::= A | B | C .... | Y | Z relop ::= < | <= | > | >= | == | !=
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