GATE Computer ScienceVery hardGATE CS (PYQ pattern)

For S → A b | B c; A → a A | ε; B → a B | ε (augmented), in how many LR(0) states is there a conflict, how many ACTION cells of the LR(0) table are multiply defined (reductions written in every column, including $), and how many in the SLR(1) table?

  1. A. 2 states, 2 cells; SLR(1): 0
  2. B. 1 state, 4 cells; SLR(1): 1
  3. C. 2 states, 8 cells; SLR(1): 0
  4. D. 2 states, 8 cells; SLR(1): 2

Correct answer: C. 2 states, 8 cells; SLR(1): 0

I0 and the state after a both contain A → · and B → · (and a shift on a): LR(0) writes both reductions in all 4 columns a, b, c, $ — 4 clashes per state, 8 in all. SLR uses FOLLOW(A) = {b} and FOLLOW(B) = {c}, which are disjoint and do not contain a, so there is no clash. (The grammar is SLR(1) though it is not LL(k) for any k.)

More Compiler Design questions

Exams that ask this topic