GATE Computer ScienceVery hardGATE CSE · UGC NET
Grammar: S → A a | b A c | d c | b d a; A → d. How many conflicting (state, terminal) entries are there in its SLR(1) table, and how many in its LALR(1) table?
- A. 0 and 2
- B. 2 and 2
- C. 3 and 0
- D. 2 and 0
Correct answer: D. 2 and 0
FOLLOW(A) = {a, c}; in the state after "d" and the state after "bd" the reduce A→d on a or c clashes with a shift, giving 2 shift/reduce entries under SLR. The LR(1) lookaheads are exact ({a} resp. {c}), so LALR has 0.
More Compiler Design questions
- Consider the grammar S → a S | a S b S | ε. How many distinct parse trees does the string aaabb have?
- Procedure swap(x, y) { t = x; x = y; y = t; } is called as swap(i, a[i]) with i = 1 and a[1], a[2], a[3] = 2, 5, 9. Under call-by-name…
- A DFA reads binary strings most-significant bit first and accepts those whose numeric value is divisible by 12 (the empty string counts as…
- Let L = { w ∈ {a,b} : w contains the substring "aba" and |w| is even }. How many states does the minimal DFA for L have?
- A straight-line CFG B1→B2→B3→B4→B5 has: B1 defines x; B2 defines y; B3 uses y and defines z; B4 defines y; B5 uses x and z. Live-variable…
- A flow graph has blocks (definitions d1…d7): B1: d1: i=0; d2: j=0. B2: d3: i=i+1. B3: d4: j=j+i. B4: d5: i=j; d6: k=i. B5: d7: j=k. Edges…