GATE Computer ScienceModerateGATE CS (PYQ pattern)

For the grammar S → C C; C → c C | d (augmented with S′), the canonical LR(1) automaton is built and then the states with identical LR(0) cores are merged to get LALR(1). The LALR state whose only item is the complete item C → d · is the merge of how many canonical LR(1) states?

  1. A. 3
  2. B. 5
  3. C. 2
  4. D. 4

Correct answer: C. 2

There are 2 LR(1) states with this core (they differ only in their lookahead sets), and LALR merges them into one.

More Compiler Design questions

Exams that ask this topic