If the input given to the parser is valid, then the parser will not
need to produce any errors. Unfortunately this is not always the case,
so sid
provides a mechanism for handling errors.
When an error occurs, an exception is raised. This passes control to the nearest enclosing exception handler. If there is no exception handler at all, the entry point function will return with the current terminal set to the error value.
An exception handler is just an alternative that is executed when a
terminal or predicate fails. This should obviate the need to rely upon
language specific mechanisms (such as setjmp
and
longjmp
) for error recovery.