Version

Grammar Class

Represents a context-free grammar whose production rules are used to parse and validate textual input.
Syntax
'Declaration
 
Public Class Grammar 
public class Grammar 
Remarks

The syntax of a language is defined by its grammar. This formal definition provides a way to define what constitutes a legal sequence of characters in a concise, recursive manner.

The main components of a grammar definition are represented by the TerminalSymbol and NonTerminalSymbol instances stored in the grammar.

A TerminalSymbol represents the specific character pattern which must be matched in order for the corresponding rule to be satisfied. For example, a TerminalSymbol for the string "class" would evaluate the input string and signify success if it begins with "class", and signify failure if it does not. More complex evaluations are made possible through the use of regular expression patterns.

A NonTerminalSymbol represents a zero or more symbols, which can either be TerminalSymbols or NonTerminalSymbols. In addition, it can represent multiple sets of symbols. For example, let's say "class" is defined as a TerminalSymbol and a NonTerminalSymbol is defined in an EBNF file as "Classes = class | (Classes, class);" This indicates that. This means that for a "Classes" NonTerminalSymbol to be recognized in a parsed document, there must be either a "class" TerminalSymbol or a "Classes" NonTerminalSymbol followed by a "class" TerminalSymbol. In the latter, the nested "Classes" symbol could also either represent a "class" TerminalSymbol or a "Classes" NonTerminalSymbol followed by a "class" TerminalSymbol. Therefore, "Classes" represents one or more "class" TerminalSymbols.

The rules which define what can be represented by a NonTerminalSymbol are specified with the NonTerminalSymbol.Rule value or by defining the symbols in an EBNF file and using the LoadEbnf(Stream,Encoding) method.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also