LR Parsing Power: SLR(1), CLR(1), and LALR(1) (Low → High)
In the LR parsing family, the “power” of a parser class is commonly understood as how many grammars it can parse using the class’s lookahead construction. For the standard hierarchy among SLR(1), LALR(1), and CLR(1), the containment is:
[ \text{SLR(1)} \subset \text{LALR(1)} \subset \text{CLR(1)} ]
So, from low to high power, the correct order is:
[ \boxed{\text{SLR, LALR, CLR}} ]
Thus the correct multiple-choice option is (ii) LALR, SLR, CLR? Not quite—option (ii) is LALR, SLR, CLR, which is not consistent with the correct low→high ordering. The option that matches SLR, LALR, CLR is:
- Correct ordering (low → high): SLR, LALR, CLR
Therefore, none of the listed options matches exactly the standard containment order.
(If forced to choose among the provided permutations, the closest consistent relative placement would be keeping CLR last, but SLR and LALR are swapped in every offered choice relative to the correct hierarchy.)
Key terms: LR(1) SLR(1) LALR(1) CLR(1).
Footnotes
-
SLR(1) parser - Wikipedia - Defines SLR(1) lookahead via FOLLOW sets and describes conflicts relative to more precise methods. ↩
-
LALR parser - Wikipedia - Explains LALR(1) as merging LR(1) states and positioning between SLR and canonical LR(1). ↩
-
LR parser - Wikipedia - Covers canonical LR(1) (CLR(1)) and overall LR parsing family relationships and lookahead precision. ↩
SLR vs LALR vs CLR (LR Parsing) — explanation
Why the hierarchy holds (intuition)
SLR(1) uses relatively coarse lookahead: for a reduction by , SLR(1) reduces on terminals in , which may include strings where reduction is invalid—so SLR(1) can introduce conflicts earlier. CLR(1) uses full canonical LR(1) lookahead, yielding the most precise reduce/shift decisions. LALR(1) sits between: it refines lookahead compared to SLR by starting from LR(1)-style information, but merges states to reduce size, yielding fewer conflicts than SLR but (in general) no more than CLR.
Key terms: lookahead FOLLOW set canonical LR(1) items state merging.
Footnotes
-
SLR(1) parser - Wikipedia - Defines SLR(1) lookahead via FOLLOW sets and describes conflicts relative to more precise methods. ↩
-
LALR parser - Wikipedia - Explains LALR(1) as merging LR(1) states and positioning between SLR and canonical LR(1). ↩
-
LR parser - Wikipedia - Covers canonical LR(1) (CLR(1)) and overall LR parsing family relationships and lookahead precision. ↩
How to decide the ‘power’ order among SLR, LALR, CLR
- 1Step 1
Recall that CLR(1) uses canonical LR(1) items, so its lookahead information is the most precise.
- 2Step 2
SLR(1) approximates CLR by using FOLLOW sets, which can be too coarse—so it admits a subset of the grammars CLR can handle.
- 3Step 3
LALR(1) merges compatible LR(1) states (same LR(0) core) rather than using FOLLOW-only approximation, so it’s strictly more powerful than SLR but still not more powerful than canonical CLR in the containment sense.
- 4Step 4
Conclude: SLR(1) ⊂ LALR(1) ⊂ CLR(1), hence low→high is SLR, then LALR, then CLR.
Exam shortcut
Memorize the containment chain: SLR(1) < LALR(1) < CLR(1) (low → high). Then match the permutation to the answer choices.
About the given options
Your listed options are: (i) LALR, CLR, SLR (ii) LALR, SLR, CLR (iii) CLR, LALR, SLR (iv) CLR, SLR, LALR. None equals the standard low→high order SLR, LALR, CLR.
Positioning the three parser classes by lookahead precision
SLR(1)
Low precisionLookahead is derived from FOLLOW sets."
LALR(1)
Balanced precisionLookahead is derived from LR(1) but obtained via state merging."
CLR(1)
High precisionCanonical LR(1) items retain explicit lookahead terminals per item."
Relative Parsing Power (low → high)
Standard containment: SLR(1) ⊂ LALR(1) ⊂ CLR(1)
Quick reference: what changes from SLR to LALR to CLR?
LR parsing power & definitions
Knowledge Check
Arrange SLR(1), LALR(1), CLR(1) from low to high parsing power.
Explore Related Topics
Relationship Between SLR and LALR Parser State Counts ($n_1$ vs $n_2$)
Hierarchy and Power of Bottom-Up Parsers: SLR, LALR, and CLR
Bottom‑up LR parsers form a strict hierarchy of power: LR(0) < SLR < LALR < CLR, with each level able to handle all grammars of the lower levels.
- SLR uses LR(0) items and resolves conflicts with FOLLOW sets; it is the weakest but simplest LR parser.
- LALR builds full LR(1) items then merges states that share the same core, keeping the same number of states as SLR while adding look‑ahead precision.
- CLR (canonical LR) retains all LR(1) states and look‑aheads, giving it the highest grammar coverage at the cost of many more states.
- Merging CLR states to form LALR can introduce reduce‑reduce conflicts (never shift‑reduce), making LALR strictly less powerful than CLR.
- In practice, tools like Yacc/Bison prefer LALR because it balances power with manageable memory usage.
Parsers and Ambiguous Grammars: Choosing the Correct Option