Consider the following grammar:
S ® S + S | S * S
| S ^ S | ( S ) | num
This grammar is ambiguous; we would like the grammar to have parse trees
in which exponentiation (^) has higher precedence than multiplication (*),
and both have higher precedence than addition (+).
- Write an LL(1) grammar that accepts the same language as this grammar
and respects the desired operator precedence. (You need not ensure that
the operators are left-associative, however.)
- Write an LR(1) grammar that accepts the same language, but enforces
both the correct precedence and left-associativity of the operators.