LL parsers (recursive descent) parse from the
Aright to left, building a rightmost derivation
Bleft to right, building a leftmost derivation
Cmiddle outward
Dleaves up to the root
Answer & Solution
Correct answer: B. left to right, building a leftmost derivation
1. LL parsers:
- L: left-to-right input scan (consume tokens in the order produced)
- L: leftmost derivation produced
2. They TOP-DOWN expand non-terminals starting from the root (the grammar start symbol).
3. CONTRAST with LR parsers:
- L: left-to-right scan
- R: rightmost derivation in REVERSE
- Build trees BOTTOM-UP from leaves
4. LL is the parsing style of recursive descent, ANTLR, javacc. LR is the style of yacc, bison.
5. Options A, C, D describe other strategies.
_Source: Bob Nystrom, "Crafting Interpreters", Ch 6.2 + 6.1 (LL vs LR parsing)._
Related questions
The FOLLOW(A) set in LL parsing isThe FIRST(α) set of a string α in LL parsing isAfter the parser produces an AST, the next compiler phase is typicallyA SHIFT/REDUCE CONFLICT in an LR parser occurs whenWhich of these is a BOTTOM-UP (LR) parser feature?An LL(1) grammar requires that, given the leftmost non-terminal and ONE token of lookaheadPANIC MODE error recovery in a parser works byWhat is a SYNTAX ERROR?