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?
- A. One reduce-reduce conflict on c after d
- B. Two shift-reduce conflicts: on c after d, and on a after b d
- C. Two shift-reduce conflicts: on a after d, and on c after b d
- 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
- Compute FIRST of every non-terminal of S → A B | B C; A → a A | ε; B → b B | ε; C → c C | c, treating ε as a member of FIRST when the…
- With int i = 2 and the array A = [0, 3, 5, 7, 9, 11, 13] (indices from 0), the call f(A[i], i) is made to void f(p, q) { i = i + 1; p = p…
- How many states does the minimal complete DFA (dead state included) for the regular expression (ab | aba) over {a, b} have?
- For E → T R; R → + T R | − T R | ε; T → F P; P → ^ T | ε; F → ( E ) | id, compute FOLLOW of every non-terminal ( counts as a member). What…
- A basic block is converted to a DAG using value numbering, treating + and as commutative, reusing an existing node when the same operator…
- Minimal SSA form is built for 1: if p > 0 goto L2; 2: L1: x = x + 1; 3: if x > n goto L3; 4: L2: y = y + x; 5: if y < m goto L1; 6: L3…