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?

  1. A. 6
  2. B. 8
  3. C. 10
  4. 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

Exams that ask this topic