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 FIRST set of A includes 'a' because of the production A → aB, and ε because of the production A → ε.
Which of the following best describes the FOLLOW set of a non-terminal in a grammar?
Think about what symbols can follow a non-terminal in the grammar rules.
The FOLLOW set contains terminals that can appear immediately after the non-terminal in some derivation, helping in parsing decisions.
Consider the grammar:S → ABA → a | εB → b
What is the FIRST(S) set?
Remember that if FIRST(A) contains ε, then FIRST(S) includes FIRST(B) as well.
FIRST(A) = { 'a', ε } and FIRST(B) = { 'b' }. Since A can be empty, FIRST(S) = FIRST(A) without ε plus FIRST(B), so { 'a', 'b' }.
Which statement correctly contrasts the FIRST and FOLLOW sets?
Think about where each set is used in parsing and what they represent.
FIRST sets identify possible starting terminals of derivations; FOLLOW sets identify terminals that can come immediately after a non-terminal, aiding parser decisions.
Given the grammar:E → T E'E' → + T E' | εT → int
What is the FOLLOW(E') set?
Consider where E' appears and what can follow E in the grammar, including end of input.
E' appears after T in E → T E'. Since E is the start symbol, FOLLOW(E) includes end marker '$'. Because E' can be empty, FOLLOW(E') = FOLLOW(E) = { '$' }.
