Error Handling[slide by John Werth.]
During the parse, if an error is encountered (access to a blank entry in
the LALR table) the following happens:
- the stack is popped until a state is on top whose items match the
right-hand side of an error production.
- a token error is shifted onto the stack
- if α is empty, then a reduction takes place and the semantic
action is performed.
- if α is non-empty, the parser tries to identify α
in the input. It then pushes α on the stack and does a
reduction as usual.
For example, stmt : error ';' will have the effect of
causing the parser to skip ahead to the next ; and assume that
a statement has been found.