3 parser-Intro-L5
3 parser-Intro-L5
Lexical Analysis
Syntactic Analysis
Abstract Syntax Tree
if
(AST)
Semantic Analysis
== = ;
b 0 a “Hi”
Do tokens conform to the language syntax?
BITS Pilani, Hyderabad Campus
Functions of Syntax Analysis
• Additional functionalities
• {(i)i|i=0}
• Consider grammar
string -> string + string | string - string | 0 | 1 | . | 9
• Construction of the parse tree starts at the root (from the start symbol) and
proceeds towards leaves (token or terminals)
– Bottom-up parsing:
• Constructions of the parse tree starts from the leaf nodes (tokens or terminals of
the grammar) and proceeds towards root (start symbol) 1.
S –> AB
A –> aA | ε S
B –> b | bB
A B