GATE Computer ScienceVery hardGATE CS (PYQ pattern)
For the grammar E → E + T | T; T → T * F | F; F → ( E ) | id, the LALR(1) parser is obtained by merging LR(1) states with identical cores. How many more states does the canonical LR(1) automaton have than the LALR(1) automaton?
- A. 13
- B. 11
- C. 9
- D. 10
Correct answer: D. 10
LR(1) has 22 states; merging equal-core states leaves 12 (equal to the LR(0) count 12), so the difference is 10.
More Compiler Design questions
- How many distinct LR(0) items does the grammar S → X Y Z; X → a X | ε; Y → b Y | X; Z → c | ε have (do not augment it; an ε-production…
- Which of the following is/are true? I. Every S-attributed definition is L-attributed. II. Every L-attributed definition can be evaluated…
- For S → S ( S ) | ε (augmented), count the reduce entries ( column included, accept excluded) in the SLR(1) and in the LALR(1) ACTION…
- A table-driven LL(1) parser for S → ( S ) S | ε parses "( ) ( )". Each pop of a non-terminal (expanding it) and each match of a terminal…
- An array A[1..4], [0..5], [1..6] of 8-byte elements is stored in row-major order starting at address 500. What is the address of A[3][2][5]?
- For G: S → A b | a A c | B c | a B b; A → a; B → a, which statements are true? I. G is LL(2). II. G is SLR(1). III. G is LALR(1). IV. The…