GATE Computer ScienceVery hardGATE CS (PYQ pattern)
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)?
- A. k = 2; G is LALR(1)
- B. k = 3; G is LALR(1)
- C. no such k; G is not LALR(1)
- D. k = 3; G is not LALR(1)
Correct answer: D. k = 3; G is not LALR(1)
a E c and a F d both begin a e, so 2 symbols are not enough; the third symbol (c or d) decides: LL(3). For LR, after a e the state reduces E on c and F on d, and after b e it reduces F on c and E on d. Same core, swapped lookaheads: canonical LR(1) is fine, but merging gives reduce-reduce conflicts on c and d.
More Compiler Design questions
- Live-variable analysis is used to find dead assignments (target not live immediately after the statement) in 1: x = a + b; 2: if c > 0…
- A DAG is built for the basic block x = a b; y = b a; z = x + y; a = z − x; w = a b; v = y + x (+ and commutative, a new leaf for each…
- In the LL(1) table of S → i E t S Z | a; Z → e S | ε; E → b the only multiply-defined cell is M[Z, e]. A parser generator resolves it by…
- Which of the following is/are true for the grammar S → a S | S b | c? I. It is ambiguous. II. It is LL(1). III. It is SLR(1). IV. It is…
- In the LL(1) table of S → A B C; A → a | ε; B → b | ε; C → c | ε, how many cells hold an ε-production, and how many cells of the column…
- Consider the grammar G with productions S → A B C; A → a | ε; B → b | ε; C → c | ε. Which of the following statements is/are true? I. G is…