Question: Part I) Give two parse trees that demonstrate the following grammar is ambiguous. expression literal | expression + expression | expression - expression tertiary secondary
Part I) Give two parse trees that demonstrate the following grammar is ambiguous.
expression literal | expression + expression | expression - expression tertiary secondary | expression + secondary secondary primary | secondary * primary primary literal | variable | ( expression ) literal 1, 2, 3, variable a, b, c,
Part II) Consider a program: int main() { int x; bool y; int z; z = x + y; }
Using the CLite Grammar from Topic 2, but assuming bool is a Java-like boolean type. Part I: Create a parse tree for the previous program Part II: Annotate your parse tree with attributes (as in an attribute grammar) that allows detection of the error in the assignment statement, which adds a bool and int value.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
