GATE Computer ScienceVery hardGATE CS (PYQ pattern)
For S → A b B | c; A → a | ε; B → c B | ε (augmented), in how many LR(0) states is there a conflict, and how many reduce entries does the SLR(1) table have ($ column included, accept excluded)?
- A. 2 states; 7 entries
- B. 3 states; 9 entries
- C. 3 states; 7 entries
- D. 1 state; 5 entries
Correct answer: C. 3 states; 7 entries
Conflicting LR(0) states: I0 (A → · beside shifts on a and c), the state after A b (B → · beside shift c), and the state after c inside B (B → c·B, B → · beside shift c). SLR reduce entries: A → ε and A → a on FOLLOW(A) = {b}: 2; S → c· on $; B → ε in two states on $; B → c B· on $; S → A b B· on $: 2 + 1 + 2 + 1 + 1 = 7.
More Compiler Design questions
- For S → A B | B C; A → a A | ε; B → b B | ε; C → c C | d, which statement is FALSE?
- In S → A B; A → a | ε; B → A b | c, FOLLOW(A) does not contain . Which of these productions, each added to the grammar on its own, put…
- For S → X Y Z; X → a X | ε; Y → b Y | X; Z → c | ε (augmented), in how many states is there a conflict in the SLR(1) table, and in how…
- In 1: i = 0; 2: c = 2; 3: L1: if i >= n goto L3; 4: d = c 3; 5: if i > k goto L2; 6: c = 2; 7: L2: e = d + 1; 8: f = a b; 9: i = i + 1…
- L1 is the set of strings over {a, b} whose third symbol from the right is a; its minimal DFA has 8 states. L2 = L1 ∩ {strings of even…
- For the augmented grammar S′ → S; S → ( L ) | x; L → S | L , S, how many states does the canonical LR(1) automaton have, and in how many…