GATE Computer ScienceVery hardGATE CS (PYQ pattern)

G: S → T | S ; T; T → a | ( S ). Removing the left recursion gives G′: S → T R; R → ; T R | ε; T → a | ( S ). Which statements are true? I. G is LR(0). II. G′ is LL(1). III. G′ is LR(0).

  1. A. II only
  2. B. I, II and III
  3. C. I and II only
  4. D. II and III only

Correct answer: C. I and II only

I: every complete item of G (T → a·, T → (S)·, S → T·, S → S;T·) is alone in its state, and the accept item S′ → S· shares its state only with the shift of ; (accept acts on $ alone): G is LR(0). II: R → ; T R and R → ε are told apart by ; versus FOLLOW(R) = {$, )}. III: the state after T in G′ contains R → · together with R → ·; T R, a shift-reduce clash without lookahead.

More Compiler Design questions

Exams that ask this topic