Which of the following is a requirement for an LL(1) parser?
Practice Questions
Q1
Which of the following is a requirement for an LL(1) parser?
The grammar must be left recursive.
The grammar must be ambiguous.
The grammar must be free of left recursion.
The grammar must have multiple left factors.
Questions & Step-by-Step Solutions
Which of the following is a requirement for an LL(1) parser?
Step 1: Understand what an LL(1) parser is. It is a type of parser that reads input from left to right and constructs a leftmost derivation of the sentence using one lookahead token.
Step 2: Know that '1' in LL(1) means the parser looks at one token ahead to make parsing decisions.
Step 3: Recognize that left recursion in a grammar can cause the parser to enter an infinite loop because it keeps trying to expand the same non-terminal.
Step 4: Conclude that to avoid this problem, the grammar must be free of left recursion, allowing the parser to make decisions based on the single lookahead token.