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)?
- A. 21
- B. 30
- C. 24
- 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
- int x = 1; void p() { x = x + 10; } void r() { print(x); } void q() { int x = 5; p(); r(); } main() { q(); r(); print(x); } What is…
- Each assignment is a definition named by its statement number. In 1: s = 0; 2: i = 0; 3: L1: if i >= n goto L4; 4: if a > 0 goto L2; 5: s…
- A basic block is converted to a DAG using value numbering, treating + and as commutative, reusing an existing node when the same operator…
- A web of a variable is a maximal union of def-use chains that share a definition or a use; a register allocator gives each web its own…
- In 1: x = 1; 2: y = 0; 3: L1: if y > n goto L3; 4: if x > 5 goto L2; 5: x = x 2; 6: L2: y = y + x; 7: x = y - 1; 8: if y < m goto L1; 9: x…
- Using the standard backpatching scheme (each relational test yields 'if a<b goto ' followed by 'goto ', with no fall-through optimisation…