GOLDParser Object

 

Description

The GOLDParser object is the primary class in the parser engine. Unlike the Rule, Reduction, Symbol and Token objects, the GOLDParser object performs all the required logic and operations needed to analyze the source text. Like all DFA and LALR engines, the GOLDParser relies on tables to drive the tokenizer and parser.

The developer interacts with the GOLDParser object by first loading the Compiled Grammar Table file and then subsequently calling the "Parse" method within a control loop. The "Parse" method returns codes that inform developer of the action(s) performed by the system and if any lexical or syntax errors were found.

Each time a rule is reduced, the system will create a Reduction Object. This object, which is described in the following sections, contains a series of tokens and is directly associated with the reduced rule. The tokens can contain actual text for the source string as well as other Reduction Objects (or even customized ones). This mechanism allows the construction of a parse tree. Essentially the developer performs the following actions to initiate the GOLDParser object.

  1. Call LoadCompiledGrammar( ) method to load a previously developed Compiled Grammar Table file
  2. Call the appropriate method to open the source string to be parsed
  3. Continue to call the Parse( ) method until the string is either accepted or an error occurs.

This documentation contains examples on how to use the GOLDParser object using Visual Basic 6, Visual Basic NET, and C++.

 

Properties

Property Data Type Access Description
CurrentColumnNumber Integer (32-bit) Read only Returns the column line in the source string. This can be used to track when indentation changes or for highlighting a piece of information. This method was added in version 2.2.0 of the Engine.
CurrentComment String Read only Returns the text associated with a line or block comment. When the system reads a block or line comment, the text is temporarily stored. This property was add in version 2.4 of the Engine.
CurrentLineNumber Integer (32-bit) Read only Returns the current line in the source string.
CurrentReduction Object Read/Write Returns/sets the reduction made by the parsing engine. When a reduction takes place, this property will be set to a Reduction object which will store the reduced rule and its related tokens. This property may be reassigned a customized object if the developer so desires.

The value of this property is only valid when the Parse() method returns the gpMsgReduction message.

CurrentToken Token Read only Returns the token that is ready to be parsed by the engine. This property is only valid when when the gpMsgTokenRead message is returned from the Parse method.
RuleTableCount Integer (16-bit) Read only Returns the number of rules in the parser's internal Rule Table.
RuleTableEntry (Index) Rule Read only Returns rule in the parser's Rule Table at the specified Index. The Index will range from 0 to RuleTableCount - 1.
SymbolTableCount Integer (16-bit) Read only Returns the number of symbols in the parser's internal Symbol Table.
SymbolTableEntry (Index) Symbol Read only Returns the symbol specified by Index. The Index will range from 0 to SymbolTableCount - 1.
TrimReductions Boolean Read/Write Returns/sets the TrimReductions flag. When this property is set to True, the parser engine will automatically trim (i.e. remove) unneeded reductions from the parse tree. For more information please click here.
TokenCount Integer (16-bit) Read only Returns the number of tokens expected fokens when a syntax error occurs.
Tokens (Index) Token Read only Returns the token specified by Index.  The Index will range from 0 to TokenCount - 1.

 

Methods

Method Returns Details
Clear (None) The GOLDParser is reset and the internal tables are cleared.
CloseFile (None) The file opened with the OpenFile method is closed.
LoadCompiledGrammar (FileName) Boolean If the Compiled Grammar Table file is successfully loaded the method returns True; otherwise False. This method must be called before any Parse calls are made.
GetAboutText String This method is new in version 2.2 of the ActiveX Engine. The method returns a simple text string containing version information about the Engine.
OpenFile (FileName) Boolean Opens the FileName for parsing. If the file is successfully is open, the method returns True; otherwise False.
OpenTextString (String) Boolean Opens the SourceString for parsing. If successful the method returns True; otherwise False.
Parameter (Name) String Returns a string containing the value of the specified parameter. The ParameterName is the same as the parameters entered in the grammar's description. These include: Name, Version, Author, About, Case Sensitive and Start Symbol. If the name specified is invalid, this method will return an empty string.
Parse GPMessageConstants Executes a parse.  When this method is called, the parsing engine reads information from the source text (either a string or a file) and then reports what action was taken. This ranges from a token being read and recognized from the source, a parse reduction, or a type of error.
PopInputToken Token Removes the next token from the front of the parser's internal input queue.
PushInputToken (Token) (None) Pushes the token onto the front of the GOLDParser's internal input queue. It will be the next token analyzed by the parsing engine.
Reset (None) Resets the GOLDParser. The parser's internal tables are not affected.
ShowAboutWindow (None) Displays a simple window about the GOLDParser engine. This method was removed in version 2.2