Version

Synchronizer Symbol Strategy

Topic Overview

Purpose

This topic explains the synchronizer symbol error handling strategy.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic provides an overview of the Syntax Parsing Engine.

This topic provides an overview of the Syntax Parsing Engine’s Grammar.

The topics in this group explain the lexical analysis performed by the Syntax Parsing Engine.

This topic explains the syntax analysis performed by the Syntax Parsing Engine.

This topic explains the syntax errors found by the Syntax Parsing Engine.

In this topic

This topic contains the following sections:

Synchronizer Symbol Strategy

Overview

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.

Related Content

Topics

The following topics provide additional information related to this topic.

This topic explains the error production error handling strategy.

This topic explains the synchronizer pair error handling strategy.

This topic explains the backtracking error handling strategy.