GATE Computer ScienceHardGATE CS (PYQ pattern)

For S → S ( S ) | ε (augmented), count the reduce entries ($ column included, accept excluded) in the SLR(1) and in the LALR(1) ACTION tables.

  1. A. 9 and 9
  2. B. 9 and 7
  3. C. 7 and 7
  4. D. 6 and 7

Correct answer: B. 9 and 7

FOLLOW(S) = {$, (, )}. SLR puts S → ε in I0 and in the state after S ( on all three terminals and S → S(S)· on all three: 9. LALR uses true lookaheads: in I0 the S is top-level, so S → ε only on {$, (}; after S ( it is inside parentheses, so only on {(, )}; S → S(S)· keeps all three (it merges both contexts): 2 + 2 + 3 = 7.

More Compiler Design questions

Exams that ask this topic