GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 17

SLR and LALR state counts

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2003 paper

GATE 2003, Q17 1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 17, GATE 2003: The SLR parser for grammar G has n₁ states and its LALR parser has n₂ states. Which relationship is necessary in the standard constructions? A. n₁<n₂; B. n₁=n₂; C. n₁>n₂; D. None of these.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. SLR states are sets of LR(0) items. Start with canonical LR(1) states for LALR and discard lookaheads to identify equal cores; merging those states leaves the reachable LR(0) cores. Different reduction entries in the tables do not create extra automaton cores.

2. SLR uses the canonical LR(0) item-state cores. LALR merges canonical LR(1) states that share an LR(0) core, leaving one state per such core. Thus their automata have the same number of states, n 1=n 2, B, under the conventional constructions, even though their reduction lookaheads and conflict behavior differ.

Original paper, page 2