GATE Computer ScienceVery hardGATE CSE · UGC NET
Grammar: S → a A d | b B d | a B e | b A e; A → c; B → c. How many states does the canonical LR(1) collection contain, how many does LALR(1) contain, and how many conflicting (state, lookahead) entries does the LALR(1) table have?
- A. 12, 11 and 2 (reduce/reduce)
- B. 12, 11 and 0
- C. 12, 12 and 2 (reduce/reduce)
- D. 12, 11 and 2 (shift/reduce)
Correct answer: A. 12, 11 and 2 (reduce/reduce)
After "ac" and "bc" the LR(1) states differ only in lookaheads ({d} vs {e}); merging them gives A→c., B→c. with lookaheads {d,e} for both: 2 reduce/reduce entries. LR(1) has 12 states, LALR 11.
More Compiler Design questions
- For the standard expression grammar E → E + T | T; T → T F | F; F → ( E ) | id (augmented), how many states does the canonical LR(1)…
- For S → C C; C → c C | d (augmented), the canonical LR(1) collection has some states that share an LR(0) core. By how many states does…
- 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…
- 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…