Question: The question is based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr +
The question is based on the grammar given as the following:
prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3
(a)What is the associativity of the * operator?
(b) What is the associativity of the + operator?
(c) For the * and + operators, do they have the same precedence, does the * operator have greater precedence than +, or does + have greater precedence than * ?
(d) Modify the grammar to add a new operator as it follows. A unary minus operator (-) that has precedence higher than any of *, +, or binary minus.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
