Class Parser

Extends: System.Object

This is the main class in the GoldParser Engine and is used to perform all duties required to the parsing of a source text string. This class contains the LALR(1) State Machine code, the DFA State Machine code, character table (used by the DFA algorithm) and all other structures and methods needed to interact with the developer.

Public Constructors
Parser
Creates a new Parser object for the specified CGT file. 

Public Properties
CurrentLineNumber
Gets the line number that is currently being processed. 
CurrentReduction
Gets the Reduction made by the parsing engine. 
CurrentToken
Gets the current token. 
TrimReductions
Gets or sets whether or not to trim reductions which contain only one non-terminal. 

Public Methods
CloseFile
Closes the file opened with OpenFile
GetParameter
Returns a string containing the value of the specified parameter. 
GetTokens
Returns a TokenStack containing the tokens for the reduced rule or the tokens that where expected when a syntax error occures. 
OpenFile
Opens the file with the specified name for parsing. 
Parse
Executes a parse-action. 
PopInputToken
Pops the next token from the internal input queue. 
PushInputToken
Pushes the specified token onto the internal input queue. It will be the next token analyzed by the parsing engine. 

Constructor Detail

Parser

public Parser(string p_filename)
Creates a new Parser object for the specified CGT file.
Parameters
p_filename
The name of the CGT file.
Property Detail

CurrentLineNumber

public int CurrentLineNumber { get; }
Gets the line number that is currently being processed.

CurrentReduction

public GoldParser.Reduction CurrentReduction { get; }
Gets the Reduction made by the parsing engine.
Remarks
The value of this property is only valid when the Parse-method returns ParseMessage.Reduction.

CurrentToken

public GoldParser.Token CurrentToken { get; }
Gets the current token.

TrimReductions

public bool TrimReductions { get; set; }
Gets or sets whether or not to trim reductions which contain only one non-terminal.
Method Detail

CloseFile

public void CloseFile()
Closes the file opened with OpenFile.

GetParameter

public string GetParameter(string p_name)
Returns a string containing the value of the specified parameter.
Remarks
These parameters include: Name, Version, Author, About, Case Sensitive and Start Symbol. If the name specified is invalid, this method will return an empty string.

GetTokens

public GoldParser.TokenStack GetTokens()
Returns a TokenStack containing the tokens for the reduced rule or the tokens that where expected when a syntax error occures.

OpenFile

public void OpenFile(string p_filename)
Opens the file with the specified name for parsing.

Parse

public GoldParser.ParseMessage Parse()
Executes a parse-action.
Remarks
When this method is called, the parsing engine reads information from the source text and then reports what action was taken. This ranges from a token being read and recognized from the source, a parse reduction, or some type of error.

PopInputToken

public GoldParser.Token PopInputToken()
Pops the next token from the internal input queue.

PushInputToken

public void PushInputToken(GoldParser.Token p_token)
Pushes the specified token onto the internal input queue. It will be the next token analyzed by the parsing engine.