Version

Use SymbolNames Constants Instead of Strings (Syntax Parsing Engine)

Topic Overview

Purpose

This topic explains the benefits of using the SymbolNames constants.

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 explains a grammar’s non-terminal symbols.

This topic explains how to create productions for a non-terminal symbol.

Introduction

Overview

The internal grammatical structure of these the supported languages, including the structure of the syntax tree created for documents parsed with them is subject to change. Moreover, if you are writing code to inspect or traverse a syntax tree you should use the nested SymbolNames class constants in each language definition to identify the name of each node’s symbol (rather than the symbol name as a string literal) so that future changes to these symbol names will be highlighted via compilation errors.

Additionally, it is a good practice to write test logic using the Debug.Assert method and test for the number and type of the child nodes on a particular node so changes to a node’s child structure in the future will be detected and handled gracefully.

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic describes how to improve EBNF file readability.

This topic explains how to optimize your non-terminal symbol definitions in order to minimize the number of productions.

This topic explains how to write operator precedence rules correctly.

This topic explains the process of creating a grammar from EBNF content.