Which of the following statements about parsers is/are CORRECT? I. Canonical…

2017

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

I. Canonical LR (CLR) is more powerful than SLR.

II. SLR is more powerful than LALR.

III. SLR is more powerful than Canonical LR (CLR).

  1. A.

    I only

  2. B.

    II only

  3. C.

    III only

  4. D.

    II and III only

Attempted by 139 students.

Show answer & explanation

Correct answer: A

Concept: The four common bottom-up LR parsers differ in the item sets they build and in how much lookahead they attach to a reduce action. LR(0) and SLR work from LR(0) item sets; SLR adds FOLLOW-set lookahead on top. Canonical LR (CLR / LR(1)) builds full LR(1) item sets, each item carrying its own lookahead. LALR(1) starts from those LR(1) states and merges states that share the same LR(0) core, so it keeps most—but not all—of CLR's precision. More lookahead precision means fewer reduce conflicts, giving a strict power hierarchy: SLR(1) < LALR(1) < Canonical LR (LR(1)). A parser X is "more powerful" than Y when the set of grammars X can parse strictly contains the set Y can parse.

Power hierarchy (weakest to strongest):

  1. LR(0) — uses no lookahead; reduces on every terminal.

  2. SLR(1) — reduces only when the next token is in FOLLOW(A) (a coarse, grammar-wide set).

  3. LALR(1) — uses lookahead computed from merged LR(1) states; finer than FOLLOW sets.

  4. Canonical LR / CLR (LR(1)) — keeps full per-state LR(1) lookahead; never merges, so it is the most precise.

Applying it to each statement:

  • Statement I — "Canonical LR is more powerful than SLR": TRUE. CLR sits above SLR in the hierarchy, so it parses a strict superset of SLR-parsable grammars.

  • Statement II — "SLR is more powerful than LALR": FALSE. LALR is above SLR; LALR's per-state merged lookahead handles grammars on which SLR's FOLLOW-set rule causes reduce conflicts. The relation is the reverse of what is stated.

  • Statement III — "SLR is more powerful than Canonical LR": FALSE. CLR is the strongest of the four, so SLR cannot be more powerful than it; again the stated relation is reversed.

Cross-check (comparison): Reading the hierarchy table, the only relation that points from a weaker parser to a stronger one in the direction the statement claims is Statement I; both other statements claim a weaker parser dominates a stronger one, which the strict ordering forbids. Hence exactly one statement holds, matching the choice that selects statement I alone.

Statement

Claim

Verdict

I

CLR > SLR

True

II

SLR > LALR

False (LALR > SLR)

III

SLR > CLR

False (CLR > SLR)

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir