GATE Computer ScienceVery hardGATE CSE · UGC NET

Grammar: S → A a | b A c | d c | b d a; A → d. How many conflicting (state, terminal) entries are there in its SLR(1) table, and how many in its LALR(1) table?

  1. A. 0 and 2
  2. B. 2 and 2
  3. C. 3 and 0
  4. D. 2 and 0

Correct answer: D. 2 and 0

FOLLOW(A) = {a, c}; in the state after "d" and the state after "bd" the reduce A→d on a or c clashes with a shift, giving 2 shift/reduce entries under SLR. The LR(1) lookaheads are exact ({a} resp. {c}), so LALR has 0.

More Compiler Design questions

Exams that ask this topic