Skip to content
Official PYQ · 2017

GATE CS 2017 Set 2 Q6 — Parsing (LL, LR)

Explain with AI

Which of the following statements about parser is/are CORRECT?

  1. Canonical LR\text{Canonical LR} is more powerful than SLR\text{SLR}
  2. SLR\text{SLR} is more powerful than LALR\text{LALR}
  3. SLR\text{SLR} is more powerful than Canonical LR\text{Canonical LR}
Choose one option
View worked solution

Answer: A

The "power" of a parser refers to the class of grammars it can successfully parse without any conflicts (shift-reduce or reduce-reduce).

The hierarchy of bottom-up parsers in terms of their parsing power is as follows:

LR(0)⊂SLR(1)⊂LALR(1)⊂LR(1) (Canonical LR)\text{LR}(0) \subset \text{SLR}(1) \subset \text{LALR}(1) \subset \text{LR}(1) \text{ (Canonical LR)}
  • Statement I: "Canonical LR is more powerful than SLR" is CORRECT because any grammar that is SLR(1)\text{SLR}(1) is also LR(1)\text{LR}(1), but the reverse is not always true.
  • Statement II: "SLR is more powerful than LALR" is INCORRECT because LALR(1)\text{LALR}(1) is strictly more powerful than SLR(1)\text{SLR}(1).
  • Statement III: "SLR is more powerful than Canonical LR" is INCORRECT because Canonical LR is the most powerful LR parser.

Thus, only statement I is correct.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions