Arrange these stages of a single reduce action in the order they occur.
1. the goto table is consulted for the exposed state and left side
2. the action table reports a reduction by a chosen production
3. the left side and its new state are pushed onto the stack
4. the right side symbols are popped from the parsing stack
Answer: A
Correct answer: 2 - 4 - 1 - 3
The order is fixed by what each step needs from the last. The action table, indexed by the state on top and the lookahead, says which production to reduce by; the right side symbols and their states are then popped, exposing the state beneath; the goto table is consulted with that exposed state and the left side; and the left side with its new state is pushed. The input pointer never moves.
Please log in or register to report this question.