GATE Computer ScienceVery hardGATE CS (PYQ pattern)

For the grammar S → A B, A → a A | a, B → b, the augmented canonical LR(0) collection has how many states, and what is the strongest class that the grammar belongs to?

  1. A. 7 states; LR(0)
  2. B. 6 states; SLR(1) but not LR(0)
  3. C. 7 states; SLR(1) but not LR(0)
  4. D. 8 states; not SLR(1)

Correct answer: C. 7 states; SLR(1) but not LR(0)

Building the item sets gives 7 states. The state containing A → a· and A → a· A has a shift/reduce conflict if reductions ignore lookahead, so it is not LR(0). FOLLOW(A) = {b} does not contain a, so SLR(1) resolves the conflict.

More Compiler Design questions

Exams that ask this topic