Which of the following best describes the purpose of the LL(1) parsing table in the parsing process?
Think about how the parser decides which production to use based on the current input symbol.
The LL(1) parsing table maps each non-terminal and lookahead terminal pair to a specific production rule. This guides the parser on which rule to apply next.
What is the main difference between the First set and the Follow set of a non-terminal in LL(1) parsing?
Consider what symbols can appear at the start of a derivation versus what can appear after a non-terminal.
The First set of a non-terminal includes terminals that can appear at the beginning of strings derived from it. The Follow set includes terminals that can appear immediately to the right of that non-terminal in some sentential form.
Given the following grammar productions:
S → Aa | b
A → a | ε
Which problem will occur when constructing the LL(1) parsing table for this grammar?
Check how ε-productions affect the Follow set and table entries.
The ε-production in A means that when A derives empty, the parser must look at Follow(A) to decide. If First(A) and Follow(A) overlap, the parsing table will have multiple entries for the same cell, causing a conflict.
Which statement correctly compares LL(1) parsing and recursive descent parsing?
Think about the implementation style and grammar restrictions of both parsing methods.
LL(1) parsing uses a table-driven approach with a stack, while recursive descent parsing uses functions calling each other. Both require the grammar to be LL(1) compliant to avoid backtracking.
Consider the grammar:
E → E + T | T
T → int
Why is this grammar not LL(1), and what modification can make it LL(1)?
Check for left recursion and how it affects LL(1) parsing.
The grammar has immediate left recursion in E → E + T, which LL(1) parsers cannot handle. Removing left recursion by rewriting the grammar into right-recursive or iterative form makes it LL(1) compatible.
