Definition

FIRST and FOLLOW are sets of terminals computed from a grammar, used to build predictive (LL) parsing tables and to construct parsers without backtracking.

Key Points

Example

Grammar: E → T E', E' → + T E' | ε, T → id

📌 CSS Frequency: High — "compute FIRST and FOLLOW for the given grammar" is a classic numeric question.

Model Answer (short)

"FIRST(α) is the set of terminals that can start a string derived from α, while FOLLOW(A) is the set of terminals that can immediately follow A in some sentential form. Both are computed by systematically applying the grammar's production rules, and together they are used to build the LL(1) parsing table, which decides which production to apply for a given non-terminal and lookahead symbol."