Parsing PCD
Parsing PCD
Parsing PCD
Prepared By:
Mr.Roshan S. Bhanuse
Asst. Prof. IT
YCCE Nagpur
.
PARSING
■ It is the process of analyzing a continuous stream of input in order to
grammar
.
Parse tree:
tree. Each interior node of the parse tree is a non-terminal; the children of
2. Bottom up parsing
Parsing….
Ø Top-down parsing : A parser can start with the start symbol and try to
Ø Bottom-up parsing : A parser can start with input and attempt to rewrite
construct a parse tree for the input starting from the root to the leaves.
■ Example for :
Backtracking:
The parse tree can be constructed using the following top-down approach :
Step1:
Initially create a tree with single node labeled S. An input
pointer points to ‘c’, the first symbol of w. Expand the tree
with the production of S.
Step2:
The leftmost leaf ‘c’ matches the first symbol of w, so advance the input
pointer to the second symbol of w ‘a’ and consider the next leaf ‘A’.
second backtracking.
Step4: BACKTRACKING…..
construct a parse tree for an input string beginning at the leaves (the
bottom) and working up towards the root (the top).
BOTTOM-UP PARSING….
Example:
Consider the grammar:
E→E+E
E→E*E
E→(E)
E→id