16.2 LL(1) PARSE TABLE
To simplify the parsing process, information from the npda combined with lookaheads can be stored in a table called the LL(k) Parse Table. For now we focus on k = 1, and show how to build an LL(1) Parse Table.
LL(1) Parse Table
For a context-free grammar G = (V, T, S, P), the rows of the table are labeled with A ∈ V and the columns of the table are labeled with a ∈ T∪{$}, the symbols that could be a lookahead.
To construct the LL(1) Parse Table. Let A ∈ V, and w ∈ (V ∪ T)*.
- For each production A → w.
- For each a in FIRST(w), add w to LL[A, a].
- If λ ∈ FIRST(w), add w to LL[A, b] for each b in FOLLOW(A).
- Each undefined entry is error.
Get An Introduction to Formal Languages and Automata, 7th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.