Practice free →
HomeGATE CSEcomputerscienceCompiler 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)._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions