Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( python code required ) 2 . Consider the grammar above which is an extension to what we had in class. PROGRAM - > STMTS

(python code required)2. Consider the grammar above which is an extension to what we had in class.
PROGRAM -> STMTS
STMTS -> STMT| STMT ; STMTS
STMT -> id = EXPR
EXPR -> EXPR + TERM | EXPR - TERM | TERM
TERM -> TERM * FACTOR | TERM / FACTOR | FACTOR
FACTOR ->( EXPR )| id | integer
Where{PROGRAM, STMTS, STMT, EXPR, TERM, FACTOR} are non-terminals and { ; ,=,+,-,*,/,(,), id, integer} are terminals. PROGRAM is the start non-terminal, and the terminal id is defined using the regular expression: letter(letter | digit)*.
a) Modify the grammar to add the power operator (^) and unary sign operators +and -.
b) Re-write the grammar such that it can be parsed by an LL(1)parser.
c) Use the written grammar as a base to implement LL(1)parser.
d) Test your code with a correct and incorrect input code.
e) Report (Code of the parser, parsing table, testing the codes, a screenshot of the outputs or GUI if any).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago