Lecture 3 Top Down Parsing Part 1
Lecture 3 Top Down Parsing Part 1
Parsing (Part-1)
Dr. Raheel Siddiqi
Compiler Construction
Parsing is the process of determining how a
string of terminals can be generated by a
grammar.
Most parsing methods fall into one of two
classes, called the top-down and bottom-up
methods.
These terms refer to the order in which nodes in
the parse tree are constructed.
In top-down parsers, construction starts at the
root and proceeds towards the leaves, while in
bottom-up parsers, construction starts at the leaves
and proceeds towards the root.
The popularity of top-down parsers is due
to the fact that efficient parsers can be
constructed more easily by hand using top-
down methods.
Bottom-up parsing, however, can handle a
larger class of grammars, so software tools
for generating parsers directly from
grammars often use bottom-up methods.
• A grammar (we call it “Grammar 1”) for some statements in C and
Java
Input String: for ( ; expr ; expr ) other