SLIDE 3 Bottom-Up PDA
(1) E E + T (2) E T (3) T T F (4) T F (5) F (E) (6) F id Reduce Transitions: (1) (p, , T + E), (p, E) (2) (p, , T), (p, E) (3) (p, , F T), (p, T) (4) (p, , F), (p, T) (5) (p, , )E( ), (p, F) (6) (p, , id), (p, F) Shift Transitions: (7) (p, id, ), (p, id) (8) (p, (, ), (p, () (9) (p, ), ), (p, )) (10) (p, +, ), (p, +) (11) (p, , ), (p, ) The idea: Let the stack keep track of what has been found. Discover a rightmost derivation in reverse order. Start with the string of terminals and attempt to "pull it back" (reduce) to S. When the right side of a production is
- n the top of the stack, we can replace
it by the left side of that production… …or not! That's where the nondeterminism comes in: choice between shift and reduce; choice between two reductions.
Example: id + id * id
Hidden during class, revealed later: Solution to bottom-up example
A bottom-up parser is sometimes called a shift-reduce parser. Show how it works on id + id * id State stack remaining input transition to use p id + id * id 7 p id + id * id 6 p F + id * id 4 p T + id * id 2 p E + id * id 10 p +E id * id 7 p id+E * id 6 p F+E * id 4 p T+E * id 11 p *T+E id 7 p id*T+E 6 p F*T+E 3 p T+E 1 p E q Note that the top of the stack is on the left. This is what I should have done in the class for sections 1 and 2 (and I did do it for section 3).