






















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The differences between top-down and bottom-up parsing techniques, including the use of production rules, input matching, and internal state encoding. It also covers the concept of left recursion and its elimination in top-down parsing. Predictive parsing and the use of first sets are also discussed.
Typology: Slides
1 / 62
This page cannot be seen from the preview
Don't miss anything!























































2
Top-down parsers Start at the root of the parse tree and grow towards leaves. Pick a production and try to match the input
4
Top-down parsers Start at the root of the parse tree and grow towards leaves. Pick a production and try to match the input
5
Top-down parsers Bad “pick” ⇒ may need to backtrack Some grammars are backtrack-free.
7
Bottom-up parsers Start at the leaves and grow toward root As input is consumed, encode possibilities in an internal state.
8
Bottom-up parsers Start at the leaves and grow toward root As input is consumed, encode possibilities in an internal state.
11
Bottom-up parsers Start in a state valid for legal first tokens Bottom-up parsers handle a large class of grammars
12
Bottom-up parsers Start in a state valid for legal first tokens Bottom-up parsers handle a large class of grammars
14
A top-down parser starts with the root of the parse tree. The root node is labeled with the goal symbol of the grammar
15
Top-Down Parsing Algorithm
Construct the root node of the parse tree Repeat until the fringe of the parse tree matches input string
17
At a node labeled A , select a production with A on its lhs for each symbol on its rhs, construct the appropriate child
18
At a node labeled A , select a production with A on its lhs for each symbol on its rhs, construct the appropriate child
20
When a terminal symbol is added to the fringe and it does not match the fringe, backtrack Find the next node to be expanded
21
The key is picking right production in step 1.
That choice should be guided by the input string