Given the grammar rule A → aB | ε, what is the FIRST(A) set?
Recall that FIRST set includes terminals that begin strings derived from the non-terminal, including ε if it can produce empty.
The rule A → aB | ε means A can start with terminal 'a' or be empty. So FIRST(A) = {a, ε}.
For the grammar with start symbol S and rule S → AB, if FOLLOW(S) = { $ }, and FIRST(B) = {b, ε}, what is FOLLOW(A)?
FOLLOW(A) includes FIRST(B) except ε, and if B can be ε, then FOLLOW(S) is also included.
Since B can be ε, FOLLOW(A) includes FIRST(B) without ε plus FOLLOW(S). So FOLLOW(A) = {b, $}.
Consider the grammar rules:E → TE'E' → +TE' | εT → int
Assuming FOLLOW(E') = {$}, which input symbol has the ε-production in the LL(1) parsing table for E'?
The ε-production is placed in the table for symbols in the FOLLOW set of the non-terminal.
FIRST(E' → +TE') = {+}, so table[E', +] = E' → +TE'.
FIRST(E' → ε) includes ε, so table[E', $] = E' → ε (since $ ∈ FOLLOW(E')).
No conflict because {+} ∩ {$} = ∅.
Which of the following grammars is NOT LL(1) due to ambiguity in the parsing table?
1. S → aSb | ε
2. S → Aa | Ab
3. S → aA | bA
4. S → aS | a
Look for productions with common prefixes causing FIRST set overlaps.
Grammar 2 has productions S → Aa and S → Ab starting with the same non-terminal 'A', causing FIRST sets overlap and ambiguity in the parsing table, so it is not LL(1).
Given the grammar:S → ABA → a | εB → b
and FIRST and FOLLOW sets:
FIRST(A) = {a, ε}
FIRST(B) = {b}
FOLLOW(A) = {b}
FOLLOW(S) = {$}
Which entries should be added to the LL(1) parsing table for non-terminal A?
Use the rule: For each production A → α, add to table[A, t] for each t in FIRST(α). If ε in FIRST(α), add to table[A, t] for each t in FOLLOW(A).
For A → a, FIRST(a) = {a}, so table[A, a] = A → a.
For A → ε, ε in FIRST(A), so add table[A, t] for t in FOLLOW(A) = {b}, so table[A, b] = A → ε.
