GATE Computer ScienceEasyGATE CS (PYQ pattern)
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 is one move. How many moves does it make before reaching $ on both stack and input?
- A. 5
- B. 10
- C. 9
- D. 11
Correct answer: C. 9
5 expansions and 4 terminal matches (including expansions to ε) give 9 moves.
More Compiler Design questions
- 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…
- For E → id | E [ E ] | ( E ) (augmented), how many states does the LR(0) automaton have, and which is the strongest of LR(0) / SLR(1) /…
- S → A B; A → a | ε; B → A b | c generates exactly five strings, and its LL(1) table has one multiply-defined cell. If that cell is…
- Consider an SDD where for A → B C the rules are: B.i = A.i + 1, C.i = B.s, A.s = C.s. Which statement is correct?
- Consider these claims about LR parsers. I. Merging LR(1) states with the same core can create a shift-reduce conflict that the canonical…