The Gateway to Computer Science Excellence

0 votes

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$

- As a function of $n$, what are the SLR sets of items?
- 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?
- Show the SLR parsing table that results from your decisions in part $(b)$.
- Repeat parts $(a)$ and $(c)$ for the unambiguous grammar, which defines the same set of expressions, shown in Fig. $4.55$.
- 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?

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.3k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.5k
- Others 1.5k
- Admissions 595
- Exam Queries 576
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 17

50,648 questions

56,429 answers

195,208 comments

99,921 users