GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Which of the following are true? I. Every LL(1) grammar is LR(1). II. Every LL(1) grammar is LALR(1). III. Every LALR(1) grammar is LR(1). IV. Every LR(0) grammar is SLR(1).

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

Correct answer: A. I, III and IV only

I, III and IV are standard inclusions. II fails: S → a A | b B; A → C a | D b; B → C b | D a; C → E; D → E; E → ε is LL(1) (the alternatives of A and of B are told apart by a/b after the empty C or D), but the LR(1) states {C → E·, D → E·} reached after a (C on a, D on b) and after b (C on b, D on a) share a core with the lookaheads swapped; merging them gives reduce-reduce conflicts on a and b in the LALR(1) table.

More Compiler Design questions

Exams that ask this topic