What is the primary purpose of the FIRST set in predictive parsing?
Think about how the parser decides which rule to apply when it sees a symbol.
The FIRST set contains terminals that can appear at the beginning of strings derived from a non-terminal. It helps the parser decide which production to use by looking at the next input symbol.
Which condition must a grammar satisfy to be considered LL(1)?
Consider how the parser decides uniquely which production to pick with one lookahead symbol.
LL(1) grammars require that for each non-terminal, the FIRST sets of its productions do not overlap. If the non-terminal can derive epsilon, the FOLLOW set must be disjoint from the FIRST sets of the non-epsilon productions to avoid ambiguity.
Given the grammar:S → Aa | bA → c | ε
What entry should be placed in the parsing table cell for non-terminal A and terminal a?
Check if A can produce epsilon and if a is in FOLLOW(A).
Since A can produce epsilon and a follows A in S → Aa, the parsing table entry for A, a is A → ε.
Which statement correctly distinguishes predictive parsing from general recursive descent parsing?
Think about how each parser decides which production to use.
Predictive parsing is a form of recursive descent parsing that uses a parsing table to decide productions without backtracking. General recursive descent parsers may backtrack if the grammar is not LL(1).
Consider a grammar with the productions:E → E + T | TT → int
Why will a predictive parser fail to parse this grammar?
Consider what happens when the parser tries to expand E.
The grammar is left-recursive since E appears on the left side of its own production. Predictive parsers cannot handle left recursion because it leads to infinite recursion during parsing.
