GATE Computer ScienceHardGATE CS (PYQ pattern)

Build the SLR(1) table of S → A a | b A c | d c | b d a; A → d (augmented). Which option describes all of its conflicts?

  1. A. One reduce-reduce conflict on c after d
  2. B. Two shift-reduce conflicts: on c after d, and on a after b d
  3. C. Two shift-reduce conflicts: on a after d, and on c after b d
  4. D. One shift-reduce conflict, on a after b d

Correct answer: B. Two shift-reduce conflicts: on c after d, and on a after b d

FOLLOW(A) = {a, c}. After d (from the start) the state is {S → d·c, A → d·}: shift c versus reduce A on c. After b d it is {A → d·, S → b d·a}: shift a versus reduce A on a. The true LR(1) lookaheads (A → d· on a after d, on c after b d) remove both clashes, so the grammar is LALR(1) but not SLR(1).

More Compiler Design questions

Exams that ask this topic