GATE Computer ScienceVery hardGATE CSE · UGC NET

Grammar: S → a A d | b B d | a B e | b A e; A → c; B → c. How many states does the canonical LR(1) collection contain, how many does LALR(1) contain, and how many conflicting (state, lookahead) entries does the LALR(1) table have?

  1. A. 12, 11 and 2 (reduce/reduce)
  2. B. 12, 11 and 0
  3. C. 12, 12 and 2 (reduce/reduce)
  4. D. 12, 11 and 2 (shift/reduce)

Correct answer: A. 12, 11 and 2 (reduce/reduce)

After "ac" and "bc" the LR(1) states differ only in lookaheads ({d} vs {e}); merging them gives A→c., B→c. with lookaheads {d,e} for both: 2 reduce/reduce entries. LR(1) has 12 states, LALR 11.

More Compiler Design questions

Exams that ask this topic