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 | Creates a new Parser object for the specified
CGT file.
|
Public Properties | Gets the line number that is currently being processed.
|
| Gets the Reduction made by the parsing engine.
|
| Gets the current token.
|
| Gets or sets whether or not to trim reductions which contain
only one non-terminal.
|
Public Methods | Closes the file opened with OpenFile.
|
| Returns a string containing the value of the specified parameter.
|
| Returns a TokenStack containing the tokens for the reduced rule or
the tokens that where expected when a syntax error occures.
|
| Opens the file with the specified name for parsing.
|
| Executes a parse-action.
|
| Pops the next token from the internal input queue.
|
| 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.
Parametersp_filenameThe 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.
RemarksThe 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.
RemarksThese 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.
RemarksWhen 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.