Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
shift and reduce.ppt
1. 1
Bottom-up parsing
Goal of parser : build a derivation
Top-down parser : build a derivation by working from the
start symbol towards the input.
Builds parse tree from root to leaves
Builds leftmost derivation
Bottom-up parser : build a derivation by working from the
input back toward the start symbol
Builds parse tree from leaves to root
Builds reverse rightmost derivation
2. 2
Example: Shift-reduce parsing
1. S E
2. E E + E
3. E E * E
4. E num
5. E id
Input to parse:
id1 + num * id2
Accept
$ S
Reduce (rule 1)
$ E
Reduce (rule 2)
$ E + E
Reduce (rule 3)
$ E + E * E
Reduce (rule 5)
$ E + E * id2
Shift
$ E + E *
Shift
$ E + E
Reduce (rule 4)
$ E + num
Shift
$ E +
Shift
$ E
Reduce (rule 5)
$ id1
Shift
$
ACTION
Grammar:
Handles:
underlined
STACK