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.
- A. 9 and 9
- B. 9 and 7
- C. 7 and 7
- 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
- A table-driven LL(1) parser for S → ( S ) S | ε parses "( ) ( )". Each pop of a non-terminal (expanding it) and each match of a terminal…
- An array A[1..4], [0..5], [1..6] of 8-byte elements is stored in row-major order starting at address 500. What is the address of A[3][2][5]?
- For G: S → A b | a A c | B c | a B b; A → a; B → a, which statements are true? I. G is LL(2). II. G is SLR(1). III. G is LALR(1). IV. The…
- For E → id | E [ E ] | ( E ) (augmented), how many states does the LR(0) automaton have, and which is the strongest of LR(0) / SLR(1) /…
- S → A B; A → a | ε; B → A b | c generates exactly five strings, and its LL(1) table has one multiply-defined cell. If that cell is…
- Consider an SDD where for A → B C the rules are: B.i = A.i + 1, C.i = B.s, A.s = C.s. Which statement is correct?