EControl Syntax Editor SDK
TGrammaAnalyzer Class

Implements grammar analyzer engine.

TGrammaAnalyzer = class(TPersistent);


Grammar rules allows testing complex sequences of tokens. 

Grammar is defined in Gramma property. Grammar rules are separated by the semicolon. 


Syntax of grammar definitions:

Rule ::= RuleName '=' Branch_list ';'

Branch_list ::= Item_list
              | Branch_list '|' Item_list

Item_list ::= Element
            | Item_list Element

Element ::= Item
          | Item '*'
          | Item '+'
          | Item '?'

Item ::= RuleName
       | '"' Term '"'
       | ''' Term '''
       | '<' TokenType '>'
       | '(' Item_list ')'


"Term" - case insensitive terminal, 

'Term' - case sensitive terminal, 

TokenType - name of token type, 

RuleName - name of grammar rule. 



'*' - any number of entries including none 

'+' - at least one entry 

'?' - one entry or none 


There are special grammar rule "Skip". It is used after each match operation to skip unused tokens (for example, comments). 


There is reserved rule name "Skip", that is used to specify skipping sequence. This rule is executed after each item processing. 

For example, see Pascal lexer in default lexer library, rules "class declaration", "Empty class", "Interface declaration".

The methods of the TGrammaAnalyzer class are listed here. 
The properties of the TGrammaAnalyzer class are listed here. 
The events of the TGrammaAnalyzer class are listed here. 
read only 
TGrammaAnalyzer Events 
Occurs when grammar definition has been changed. 
TGrammaAnalyzer Methods 
Clears grammar definition and grammar rules (results of grammar compilation). 
Compiles grammar definition. 
Creates and initializes a TGrammaAnalyzer instance. 
Destroys an instance of TGrammaAnalyzer. 
Returns index of the rule in rules list. 
Returns grammar ruler with name AName. 
Analyzes text represented by Tags (TClientSyntAnalyze) starting from FromIndex to back direction using Rule. If parsing is successful result is not nil
Tests sequence of tokens from position FromIndex to satisfy grammar rule Rule 
TGrammaAnalyzer Properties 
Specifies grammar definition. 
Indicates number of grammar rules. 
Lists grammar rules references. 
Copyright (c) 2004-2011. All rights reserved.
What do you think about this topic? Send feedback!