GATE Computer ScienceHardGATE CS (PYQ pattern)
For S → A a A b | B b B a; A → ε; B → ε (augmented), how many ACTION cells are multiply defined in the LR(0), SLR(1) and LALR(1) tables, respectively? (An LR(0) reduce is written in every terminal column including $.)
- A. 3, 2 and 2
- B. 2, 2 and 0
- C. 1, 1 and 0
- D. 3, 2 and 0
Correct answer: D. 3, 2 and 0
Only I0 holds two complete items, A → · and B → ·. LR(0) writes both reductions in the a, b and $ columns: 3 clashes. SLR uses FOLLOW(A) = FOLLOW(B) = {a, b}: 2 clashes. In I0, A must be followed by a and B by b, so LALR(1) reduces A on a and B on b: no clash (the grammar is even LL(1)).
More Compiler Design questions
- For G: S → a A c | a B d | B c; A → z; B → z, which statements are true? I. The canonical LR(1) automaton has the same number of states as…
- S → a S | b S | c is LR(0). In its LR(0) parsing table the reduce action for a complete item is written in every terminal column including…
- For the production A → B C D (A.i, B.i, C.i, D.i inherited; A.s, B.s, C.s, D.s synthesised), which rule set makes the SDD L-attributed?
- Productions are numbered (1) S → ( L ); (2) S → x; (3) L → S; (4) L → L , S. A shift-reduce parser parses "( x , ( x ) )". In which order…
- A table-driven LL(1) parser for S → A B C; A → a | ε; B → b | ε; C → c | ε parses "a c". Each pop of a non-terminal (expanding it) and…
- For G: S → a E c | a F d | b F c | b E d; E → e; F → e, what is the smallest k for which G is LL(k), and is G LALR(1)?