GATE Computer ScienceHardGATE CS (PYQ pattern)

For S → a A | A b; A → c | ε (augmented), how many non-blank ACTION entries does the initial state I0 have in the SLR(1) table, and in the LALR(1) table?

  1. A. 4 in SLR(1), 3 in LALR(1)
  2. B. 3 in SLR(1), 3 in LALR(1)
  3. C. 4 in SLR(1), 4 in LALR(1)
  4. D. 2 in SLR(1), 2 in LALR(1)

Correct answer: A. 4 in SLR(1), 3 in LALR(1)

I0 holds S → ·a A, S → ·A b, A → ·c, A → ·. Shifts on a and c. SLR reduces A → ε on all of FOLLOW(A) = {b, $} ($ comes from S → a A), giving 4 entries. In I0 the A can only be the one in S → A b, so its LR(1) lookahead is just b: LALR(1) has 3 entries and an error on $.

More Compiler Design questions

Exams that ask this topic