GATE Computer ScienceHardGATE CS (PYQ pattern)

Build the SLR(1) table for S → ( L ) | x; L → S | L , S (augmented with S′ → S). The ACTION part has a column for each of (, ), x, , and $. How many ACTION cells are blank (error entries)?

  1. A. 21
  2. B. 30
  3. C. 24
  4. D. 26

Correct answer: D. 26

9 states × 5 columns = 45 cells. Shifts: I0 and the two states before an S (after ( and after ,) each shift ( and x (6), plus ) and , in the state S → (L·)/L → L·,S (2) = 8. Reduces with FOLLOW(S) = {), ,, $} and FOLLOW(L) = {), ,}: S → x· 3, S → (L)· 3, L → S· 2, L → L,S· 2 = 10. Accept 1. Blank = 45 − 8 − 10 − 1 = 26.

More Compiler Design questions

Exams that ask this topic