int x = 12.3;
This topic provides an overview of the Syntax Parsing Engine.
This topic contains the following sections:
The Infragistics Syntax Parsing Engine is a set of classes capable of taking a definition for the grammatical structure of a type of document and producing analyzers to read and process those documents.
Main features:
Creating analyzers
Performing analysis
Other features:
Analyzing grammar
Identifying Errors and Ambiguities
Generating C# and Visual Basic language class files
The main part of the Syntax Parsing Engine is included in the following assembly:
In addition there are several predefined languages in external assemblies:
Lexical analysis breaks the text into meaningful chunks of text, called tokens. The tokens represent a type of textual element and the text which was read by the lexer to recognize that element.
Example of C# content:
In C#:
int x = 12.3;
After parsing the above C# content, the lexer will produce the following tokens (the text for insignificant tokens or tokens which always represent the same text has been omitted):
IdentifierToken (int)
WhitespaceToken
IdentifierToken (x)
WhitespaceToken
EqualsToken
WhitespaceToken
RealLiteralToken (12.3)
SemicolonToken
Tokens produced by the lexer are either identified as significant (keywords, identifiers, braces …) or insignificant (comments or whitespace).
Syntax analysis reads the significant tokens from left to right and creates a hierarchical grammatical structure as specified by the grammar definition. In the example above these are the significant tokens:
IdentifierToken (int)
IdentifierToken (x)
EqualsToken
RealLiteralToken (12.3)
SemicolonToken
The hierarchical grammatical structure holding the tokens is called a “Syntax Tree” and this is how it will look and where the tokens above are going to reside (highlighted with yellow background):
ClassKeyword
IdentifierToken
OpenBraceToken
MethodDeclaration
Modifiers **
…
Type **
IdentifierToken
IdentifierToken
ParametersList **
…
OpenBraceToken **
VariableDeclarationStatement *
Type
RealLiteralToken
SemicolonToken
CloseBraceToken
CloseBraceToken
The Syntax Parsing Engine does not perform semantic analysis, which determines the meaning of the code. Therefore, many errors will not be detected by the syntax analyzer because they are semantic errors. An example of a semantic error is the C# code snippet used above (int x = 12.3), which is grammatically correct. The “int” type however cannot accept the value 12.3, because it stores only integer values.
The following topics provide additional information related to this topic.