GATE Computer ScienceHardGATE CSE · NIELIT

How many states does the canonical LR(0) automaton have for the augmented grammar S' → S, S → a S b | a b?

  1. A. 5
  2. B. 6
  3. C. 7
  4. D. 10

Correct answer: B. 6

States: I0; goto on S (S′→S·); goto on a (S→a·Sb, S→a·b plus closure); goto on S from there (S→aS·b); goto on b (S→ab·); goto on b from aS (S→aSb·). That is 6 distinct item sets (a on the a-state loops back to itself).

More Compiler Design questions

Exams that ask this topic