Contents    Page-10    Prev    Next    Page+10    Index   

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:

  1. the stack is popped until a state is on top whose items match the right-hand side of an error production.

  2. a token error is shifted onto the stack

  3. if α is empty, then a reduction takes place and the semantic action is performed.

  4. 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.