This topic explains the synchronizer symbol error handling strategy.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
The main type of error handling used by the Syntax Parsing Engine is called the “synchronizer symbol” strategy, because it is used to synchronize the parser’s place in the grammar rules back up with the tokens from the lexer. They become out of sync when the tokens provided do not conform to the grammar rules. The synchronizer symbols used are taken from the remainders of all productions which are currently being constructed when the error occurs. If the unexpected token is associated with one of the synchronizer symbols, the missing structures that should have been before it will be filled in so that the parser can continue parsing with the token that is now expected. Otherwise, tokens are skipped and marked as errors until a token is found that is associated with a synchronizer symbol. Here are some things to note about this error handling strategy:
If certain symbols should not be used as synchronizers for a non-terminal symbol’s productions, they can be suppressed by calling the NonTerminalSymbol.SuppressErrorRecoveryForSymbol method and passing it a symbol directly used in the non-terminal symbol’s production bodies. When taking synchronizer symbols from the remainder of a production body, they will not be taken from these symbols.
The synchronizer symbol error handling strategy is a “catch all” strategy which is attempted after all other error handling strategies fail. In addition, it will always succeed in recovering from errors, even if that means skipping all remaining tokens from the lexer. It will never fail to move the parser along in the token stream from the lexer.
The following topics provide additional information related to this topic.