Top Down Parsing
Top Down Parsing
…
Another example
// and so on
…
The LL(1) Algorithm
Repeat for no terminals until no
changes in the first sets
Next wo deal with
grammars that has epsilon
production(s)
Expanding our grammar so that if and while
statements can have block statements inside.
FIRST Sets with ε
Final Result
The Strengths of LL(1)
• LL(1) is Straightforward
• Can be implemented quickly with a table-driven design
• Can be implemented by recursive descent
• Define a function for each nonterminal
• Have these functions call each other based on the lookahead
token.
• LL(1) is Fast
• Both table-driven LL(1) and recursive-descent-powered LL(1) are
fast.
• Can parse in O(n |G|) time, where n is the length of the string and |
G| is the size of the grammar.