Ambiguous-and-Unambiguous-Grammar
Question 1 |
Consider the following grammar for arithmetic expression using binary operators – and/which are not associative:
E → E−T|T T → T/F|F F → (E)id(E is the start symbol)
(a) Is this grammar unambiguous? If so, what is the relative precedence between – and/if not, give an unambiguous grammar that gives/precedence over -
(b) Does the grammar allow expressions with redundant parentheses as in (id/id) or in id-(id/id)? If so, convert the grammar into one which does not generate expressions with redundant parentheses. Do this with minimum number of changes to the given production rules and adding at most one more production rule.
Theory Explanation. |