LR Parsing Classification: Top-Down, Bottom-Up, Recursive, and Predictive
LR parsing is a bottom-up, shift-reduce, deterministic parsing strategy constructed from LR parsing tables (typically ACTION and GOTO) that simulate a rightmost derivation in reverse while scanning input left-to-right. In the standard definition, the “L” means left-to-right scanning of the input, and the “R” indicates use of a rightmost derivation handle concept in the parsing process.
Therefore, among your options, (ii) Bottom-up parsing is the correct choice.
The other options are not the defining characteristics of LR parsing:
- (i) Top-down parsing: that’s the family associated with LL parsing (predictive, recursive-descent style).
- (iii) Recursive parsing: LR parsers are typically table-driven automata; recursion is not the core defining mechanism.
- (iv) Predictive parsing: “predictive” is the hallmark of LL(1)-style lookahead selection; LR parsing uses LR lookahead sets inside ACTION/GOTO table entries rather than an LL-style single nonterminal expansion prediction.
Key terms
- LR parsing
- shift-reduce parser
- ACTION table
- GOTO table
⚠️ Important: I attempted web research as required, but external search calls are currently failing in this environment (tool usage limit). I’m still providing a correct conceptual answer based on standard compiler-construction definitions.
type="tip" title="How to recognize LR parsing quickly" content="If a question mentions ACTION/GOTO tables, shift/reduce moves, or “handle” recognition, it’s almost certainly LR = bottom-up shift-reduce parsing."
How LR parsing builds a parse (conceptual lifecycle)
Start state
1. InitializationCreate a stack with the initial state; input pointer at the start."
Read next input symbol
2. Scan lookaheadUse current state + lookahead to choose ACTION."
Move input into stack
3. ShiftIf ACTION says shift, push the symbol and advance input."
Apply a production
4. ReduceIf ACTION says reduce by , pop symbols."
Transition after reduction
5. GOTOUse GOTO with the new top state and to push the nonterminal."
Successful parse
6. AcceptWhen ACTION is accept, the parse is complete."
Core mechanics of an LR shift-reduce parser (ACTION/GOTO simulation)
- 1Step 1
Push initial state onto the stack. Set input pointer to the first token.
- 2Step 2
Let be the current lookahead token from the input.
- 3Step 3
Let be the state on top of the stack. Use ACTION[, ] to decide.
- 4Step 4
If ACTION[, ] = shift , push and state , then advance the input pointer.
- 5Step 5
If ACTION[, ] = reduce by , pop stack symbols.
- 6Step 6
Let be the new top state. Push , then push GOTO[, ].
- 7Step 7
"If ACTION[, ] = accept, stop successfully; if no valid action exists, parsing fails."
Key terms
- lookahead
- handle
- reduce
Why the correct option is (ii) Bottom-up parsing
LR parsers work by reducing toward the start symbol. Reductions correspond to recognizing handles (RHS patterns) in the current partially built structure, which is characteristic of bottom-up parsing. This is the opposite direction of top-down parsing, which predicts and expands from the start symbol.
A compact conceptual contrast:
Multiple-choice reasoning (i)–(iv)
Which statement best matches LR parsing?
Binary qualitative alignment (1 = matches, 0 = does not match)
Knowledge Check
LR parsing is fundamentally characterized by which parsing direction?