Home › GATE CSE › computerscience › Compiler Design › An LL(1) grammar requires that, given the leftmo…
An LL(1) grammar requires that, given the leftmost non-terminal and ONE token of lookahead, the parser can
Adeterministically choose which production to apply
Bnon-deterministically try all productions
Cignore the grammar entirely
Dalways accept the input
Answer & Solution
Correct answer: A. deterministically choose which production to apply
1. LL(1) = LL with 1 token of LOOKAHEAD.
2. PROPERTY: at each step, the current non-terminal + the next input token uniquely determines which production to use. This is DETERMINISTIC parsing.
3. Implementation: FIRST and FOLLOW sets are computed; a PARSING TABLE maps (non-terminal, lookahead token) → production.
4. NOT EVERY CFG is LL(1). Some require rewriting (e.g. to eliminate left recursion or factor common prefixes).
5. Higher $k$ (LL(2), LL(*)) allows more grammars but is more complex.
6. Options B, C, D describe non-LL(1) behaviour.
_Source: Bob Nystrom, "Crafting Interpreters", Ch 6.2 (LL(1) 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?LL parsers (recursive descent) parse from thePANIC MODE error recovery in a parser works byWhat is a SYNTAX ERROR?