Subtopic 1 of 6
5.1Shift-reduce parsing and handles
Keep a stack of symbols. Shift the next token or reduce a handle (right side of a production that matches the top) to its left side. The sequence of reductions is a rightmost derivation in reverse.
| # | Stack | Input | Action |
|---|---|---|---|
| 1 | 0 | id + id * id $ | shift → state 5 |
Stack alternates state, symbol, state. Shift pushes the token and a state. Reduce pops 2 × |RHS| entries, then pushes the LHS and the goto state.
Previous year questions: Bottom-up Parsing (LR family) (12)
PYQs are grouped by topic, so this is the full set for Bottom-up Parsing (LR family); try the ones that match this subtopic. Open all 12 on the topic page.