Shift reduce parsing .
. Symbols on the left of "." are kept on a stack
- Top of the stack is at "."
- Shift pushes a terminal on the stack
- Reduce pops symbols (rhs of production) and pushes a non terminal (lhs of production) onto the stack
. The most important issue: when to shift and when to reduce
. Reduce action should be taken only if the result can be reduced to the start symbol
In actual implementation, a stack is used to hold the grammar symbols that are on the left of " . ". So, basically, the top of the stack is at " . ". The shift operation shifts the next input symbol onto the top of the stack. A reduce operation pops the symbols which are in the RHS of the identified production and pushes the non-terminal (LHS of the production) onto the top of the stack. During the whole procedure, we have to know when to use the shift operation and when to use the reduce operation. We must ensure that a reduce action is taken only if the result of the operation is further reducible to the start symbol. We must explain how choices of action are to be made so the shift reduce parser works correctly.