Overview
FIRST sets describe tokens that can begin a symbol, while FOLLOW sets describe tokens that may appear after a nonterminal.
Computes grammar symbol sets used to predict valid parser choices.
Compact metadata for implementation and discovery.
FIRST sets describe tokens that can begin a symbol, while FOLLOW sets describe tokens that may appear after a nonterminal.
Quick facts
Runtime and memory behavior at a glance.
Best
O(grammar size)
Average
O(iterations * grammar size)
Worst
O(iterations * grammar size)
Space
O(grammar size)
FIRST(A) includes FIRST(symbol) for productions A -> symbol ...Adds possible leading tokens from productions until sets stop changing.
Show grammar items, parser states, and consumed input as parsing progresses.
FIRST/FOLLOW Set Computation should be used with the assumptions and tradeoffs of grammar Analysis in mind.
What each reference supports for this entry.
Compiler textbook support for FIRST/FOLLOW Set Computation's grammar analysis, parser construction, and implementation constraints.
Good next jumps from the relationship graph, ranked for useful discovery.
LL(1) parse table construction uses FIRST and FOLLOW sets to choose productions.