Table of Contents

Compiler (Parser/Lexer) - Exception handling

About

exception handling in a parser.

By default, parser will stop matching on any failure.

But they may have a sort of recovery mode that allows to define an alternate rule or match .

Example

extendedPin mode

For idea, it's called the extendedPin mode that defines the pin position (ie the token position in the rule).

Everything after the pin position is collected:

The collected data will show up as:

For instance:

property ::= id '=' expr  {pin=2 recoverWhile=rule_recover}
private rule_recover ::= !(';' | id '=')

means:

Note that recovery rule is always a predicate (a NOT predicate usually) hence it doesn't consume anything from the input.

Note that:

Documentation / Reference