Which of the following correctly describes a feature of Simple LR (SLR) parsing?

2025

Which of the following correctly describes a feature of Simple LR (SLR) parsing?

  1. A.

    Parsing tables are not used in the SLR technique.

  2. B.

    SLR parsing constructs a leftmost derivation of the input string.

  3. C.

    FOLLOW sets are used in constructing SLR parsing tables.

  4. D.

    SLR parsers rely on backtracking to analyse input strings.

Attempted by 58 students.

Show answer & explanation

Correct answer: C

SLR(1) parsing is a bottom-up (shift-reduce) LR technique: it builds an LR(0) automaton from the grammar's items and then places its reduce actions using FOLLOW sets computed from the grammar -- a reduce-by-A entry is added only under the terminals in FOLLOW(A) for a completed item A → α•. (If a shift-reduce or reduce-reduce conflict still remains after this, the grammar is not SLR(1).) This FOLLOW-set step is exactly what separates SLR from a plain LR(0) parser and from the stronger canonical-LR(1)/LALR(1) parsers, which instead compute per-state, context-sensitive lookaheads.

Building the SLR parsing table therefore means: for every LR(0) state containing a completed item A → α•, a reduce-by-that-production action is added in every ACTION-table column headed by a terminal in FOLLOW(A). This is precisely the feature that correctly describes SLR parsing among the options given.

Each of the other statements fails for a specific reason:

  • Claiming parsing tables are not used contradicts the core SLR mechanism -- SLR is entirely table-driven, using ACTION and GOTO tables built from the LR(0) automaton.

  • Claiming a leftmost derivation is constructed describes top-down (LL) parsing, not SLR -- every bottom-up/LR-family parser, SLR included, instead produces a rightmost derivation of the input in reverse.

  • Claiming SLR relies on backtracking is false -- its table-driven shift/reduce decisions are fully deterministic, so no backtracking over the input is ever needed.

So the FOLLOW-set-based reduce-action rule is the feature that correctly describes SLR parsing.

Explore the full course: Niacl Ao It Specialist

Loading lesson…