10 views

The following is an ambiguous grammar for expressions with $n$ binary, infix operators, at $n$ different levels of precedence:

• $E\rightarrow E\theta_{1}E\mid E\theta_{2}E\mid \cdot\cdot\cdot E\theta_{n}E\mid(E)\mid id$
1. As a function of $n$, what are the SLR sets of items?
2. How would you resolve the conflicts in the SLR items so that all operators are left associative, and $\theta_{1}$ takes precedence over $\theta_{2}$, which takes precedence over $\theta_{3}$, and so on?
3. Show the SLR parsing table that results from your decisions in part $(b)$.
4. Repeat parts $(a)$ and $(c)$ for the unambiguous grammar, which defines the same set of expressions, shown in Fig. $4.55$.
5. How do the counts of the number of sets of items and the sizes of the tables for the two (ambiguous and unambiguous) grammars compare? What does that comparison tell you about the use of ambiguous expression grammars?

| 10 views