GATE Computer ScienceVery hardGATE CSE · UGC NET
Grammar: S → L = R | R; L → * R | id; R → L, augmented with S' → S. How many distinct LR(1) items (production, dot position, lookahead) does the initial state I0 = closure({S' → ·S, $}) contain?
- A. 6
- B. 8
- C. 10
- D. 12
Correct answer: B. 8
Items: S'→·S,$; S→·L=R,$; S→·R,$; R→·L,$; L→·*R and L→·id each with lookaheads {=, $}; that gives 8 items in total.
More Compiler Design questions
- Grammar: S → a S b | S S | ε. How many distinct strings of length exactly 10 belong to the language it generates?
- Backpatching with no fall-through optimisation, numbering from 100, translates while (a < b && c < d || e < f) { if (x < y) p = 1; else q…
- For the augmented grammar S′ → S; S → a S a | b S b | c, how many states does the canonical LR(1) automaton have, and how many does the…
- For the grammar G: S → A b | B c; A → a A | ε; B → a B | ε, the LL(1) predictive table is built. Which statement is correct?
- For G: S → a A | b B; A → c A d | ε; B → c B d d | ε, which statements are true? I. G is LL(1). II. G is LR(0). III. The canonical LR(1)…
- A scanner has two token rules, R1 = a b and R2 = b c. It always takes the longest prefix matching some rule and never backtracks over a…