GATE Computer ScienceVery hardGATE CS (PYQ pattern)

For S → A | x b; A → a A b | B; B → x (augmented), how many states does the canonical LR(1) automaton have, and in how many states of the SLR(1) table is there a conflict?

  1. A. 10 states; 1 conflicting state
  2. B. 14 states; 1 conflicting state
  3. C. 14 states; no conflict
  4. D. 12 states; 2 conflicting states

Correct answer: B. 14 states; 1 conflicting state

LR(0) has 10 states. The cores reached inside a…b (after a, a A, a A b, and x / B there) recur with lookahead b in addition to the top-level copies with $, adding 4 states: 14. SLR: after x at the top, S → x·b and B → x· clash on b because FOLLOW(B) = {b, $}; the LR(1) lookahead there is only $, so the grammar is LALR(1) but not SLR(1).

More Compiler Design questions

Exams that ask this topic