Top-down Parsing

San Skulrattanakulchai

February 26, 2019

Top-down parsing

Recursive-descent parsing

Nullability

The nullable set of nonterminals

The FIRST sets

Computing the FIRST sets

The first sets of all nonterminals

Example computation of the FIRST sets

The FOLLOW sets

The FOLLOW sets of all nonterminals

Example computation of the FOLLOW sets

LL(1) grammars

Constructing the \(M[\cdot,\cdot]\) table

An example LL(1) grammar

An example non-LL(1) grammar

Non-recursive predictive parsing

Sample run