Which Parser Uses Leftmost Derivation?
In context-free grammar parsing, leftmost derivation means that at each step you replace the leftmost non-terminal in the sentential form. For deterministic top-down parsing, this naturally matches the way LL parsers expand non-terminals from left to right, producing the leftmost derivation for a successful parse. By contrast, LR parsers are bottom-up and are characterized as producing a rightmost derivation in reverse rather than a leftmost derivation. Operator-precedence parsers are also bottom-up (shift/reduce) and therefore are not associated with producing leftmost derivations in the standard theoretical description.
Key takeaway for the multiple-choice question: (i) LL parser uses leftmost derivation.
Evidence: LL parsers are described as left-to-right predictive parsers where the second “L” indicates leftmost derivation.2 LR parsers are described as left-to-right and producing rightmost derivation in reverse.2 Wikipedia’s bottom-up parsing overview lists operator-precedence parser and LR parser among bottom-up parsers, consistent with bottom-up (not leftmost-derivation) behavior.
Footnotes
-
LL and LR Parsing Demystified - States: “LL parsers produce a leftmost derivation, while LR parsers produce a reversed rightmost derivation.” ↩
-
Build LL(1) Parse Table (JFLAP) - Explains LL(1) and notes the second “L” means leftmost derivation. ↩
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩
-
LR Parsers (CS notes) - Notes LR corresponds to a rightmost derivation in reverse (bottom-up). ↩
-
Bottom-up parsing - Wikipedia - Lists operator-precedence parser and LR parser among bottom-up parsers. ↩
Leftmost vs Rightmost Derivation (CFG)
keywordLeftmost derivation
A derivation sequence where the parser/derivation always replaces the leftmost non-terminal at each step.
keywordLL parser
Top-down predictive parser where L L means left-to-right input and leftmost derivation.
keywordLR parser
Bottom-up parser where L means left-to-right input and R means rightmost derivation in reverse.
keywordOperator precedence parser
A bottom-up shift/reduce parsing method specialized for operator expressions using precedence relations.
Direct answer (with justification)
| Option | Parser type | Leftmost derivation? | Why |
|---|---|---|---|
| (i) | LL parser | Yes | LL parsing expands the leftmost non-terminal; sources explicitly state “LL parsers produce a leftmost derivation.”2 |
| (ii) | Bottom-up parser (general category) | Not inherently | Bottom-up parsing includes LR and operator-precedence; LR specifically yields rightmost derivation in reverse, not leftmost.2 |
| (iii) | LR parser | No | LR parsers produce rightmost derivation in reverse (bottom-up).2 |
| (iv) | Operator precedence parser | No (standard characterization) | It is bottom-up/precedence-based and is not characterized as producing leftmost derivations; bottom-up groupings include it. |
Therefore, the correct choice is: (i) LL parser.
LL(1) terminology: the second L in LL(1) indicates leftmost derivation.
Footnotes
-
LL and LR Parsing Demystified - States: “LL parsers produce a leftmost derivation, while LR parsers produce a reversed rightmost derivation.” ↩
-
Build LL(1) Parse Table (JFLAP) - Explains LL(1) and notes the second “L” means leftmost derivation. ↩ ↩2
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩ ↩2
-
Bottom-up parsing - Wikipedia - Lists operator-precedence parser and LR parser among bottom-up parsers. ↩ ↩2
-
LR Parsers (CS notes) - Notes LR corresponds to a rightmost derivation in reverse (bottom-up). ↩
How derivation order connects to parser direction
Predict and expand
Top-down (LL family)Expand non-terminals as you read input left-to-right; expand the leftmost non-terminal first ⇒ leftmost derivation.2"
Footnotes
-
LL and LR Parsing Demystified - States: “LL parsers produce a leftmost derivation, while LR parsers produce a reversed rightmost derivation.” ↩
-
Build LL(1) Parse Table (JFLAP) - Explains LL(1) and notes the second “L” means leftmost derivation. ↩
Shift and reduce
Bottom-up (LR family)Build the parse from leaves upward; applying productions in reverse yields rightmost derivation in reverse.2"
Footnotes
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩
-
LR Parsers (CS notes) - Notes LR corresponds to a rightmost derivation in reverse (bottom-up). ↩
Precedence-guided reductions
Bottom-up precedence parsingA specialized shift/reduce strategy under the bottom-up umbrella (not leftmost-derivation characterized)."
Footnotes
-
Bottom-up parsing - Wikipedia - Lists operator-precedence parser and LR parser among bottom-up parsers. ↩
How to reason: connect derivation order to parser strategy
- 1Step 1
Leftmost derivation replaces the leftmost non-terminal at each step; rightmost derivation replaces the rightmost non-terminal.
- 2Step 2
LL parsers are described as predictive/top-down and producing a leftmost derivation.2
Footnotes
-
LL and LR Parsing Demystified - States: “LL parsers produce a leftmost derivation, while LR parsers produce a reversed rightmost derivation.” ↩
-
Build LL(1) Parse Table (JFLAP) - Explains LL(1) and notes the second “L” means leftmost derivation. ↩
-
- 3Step 3
LR parsers are described as producing a rightmost derivation in reverse due to bottom-up reducing.2
Footnotes
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩
-
LR Parsers (CS notes) - Notes LR corresponds to a rightmost derivation in reverse (bottom-up). ↩
-
- 4Step 4
Both fall under bottom-up parsing; standard references pair bottom-up parsers with rightmost-in-reverse (for LR) and do not claim leftmost derivations for operator precedence.2
Footnotes
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩
-
Bottom-up parsing - Wikipedia - Lists operator-precedence parser and LR parser among bottom-up parsers. ↩
-
Pro Tip
When a question says “uses leftmost derivation?”, focus on LL because LL explicitly encodes “leftmost derivation” in its naming/definition, while LR encodes “rightmost derivation in reverse.”3
Footnotes
-
LL and LR Parsing Demystified - States: “LL parsers produce a leftmost derivation, while LR parsers produce a reversed rightmost derivation.” ↩
-
Build LL(1) Parse Table (JFLAP) - Explains LL(1) and notes the second “L” means leftmost derivation. ↩
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩
Common confusion
“Bottom-up parsing” does not automatically mean “leftmost derivation.” In fact, standard descriptions of LR parsing state it corresponds to rightmost derivation in reverse, not leftmost derivation.2
Footnotes
-
LR parser - Wikipedia - Defines LR as left-to-right scanning and producing a rightmost derivation in reverse; describes the bottom-up reduce process. ↩
-
LR Parsers (CS notes) - Notes LR corresponds to a rightmost derivation in reverse (bottom-up). ↩
FAQs
Knowledge Check
Which parser uses leftmost derivation?