Class ShiftReduceParser<TValue, TSpan>
Abstract class for GPPG shift-reduce parsers. Parsers generated by GPPG derive from this base class, overriding the abstract Initialize() and DoAction() methods.
Inherited Members
Namespace: QUT.Gppg
Assembly: Xbim.Common.dll
Syntax
public abstract class ShiftReduceParser<TValue, TSpan>
    where TSpan : IMerge<TSpan>, new()Type Parameters
| Name | Description | 
|---|---|
| TValue | Semantic value type | 
| TSpan | Location type | 
Constructors
| Improve this Doc View SourceShiftReduceParser(AbstractScanner<TValue, TSpan>)
Constructor for base class
Declaration
protected ShiftReduceParser(AbstractScanner<TValue, TSpan> scanner)Parameters
| Type | Name | Description | 
|---|---|---|
| AbstractScanner<TValue, TSpan> | scanner | Scanner instance for this parser | 
Fields
| Improve this Doc View SourceCurrentLocationSpan
The current value of the "@$" symbolic variable in the parser
Declaration
protected TSpan CurrentLocationSpanField Value
| Type | Description | 
|---|---|
| TSpan | 
CurrentSemanticValue
The current value of the "$$" symbolic variable in the parser
Declaration
protected TValue CurrentSemanticValueField Value
| Type | Description | 
|---|---|
| TValue | 
NextToken
Declaration
protected int NextTokenField Value
| Type | Description | 
|---|---|
| System.Int32 | 
Properties
| Improve this Doc View SourceLocationStack
The stack of location value (YYLTYPE) values.
Declaration
protected PushdownPrefixState<TSpan> LocationStack { get; }Property Value
| Type | Description | 
|---|---|
| PushdownPrefixState<TSpan> | 
Scanner
The abstract scanner for this parser.
Declaration
protected AbstractScanner<TValue, TSpan> Scanner { get; set; }Property Value
| Type | Description | 
|---|---|
| AbstractScanner<TValue, TSpan> | 
ValueStack
The stack of semantic value (YYSTYPE) values.
Declaration
protected PushdownPrefixState<TValue> ValueStack { get; }Property Value
| Type | Description | 
|---|---|
| PushdownPrefixState<TValue> | 
YYRecovering
Check if parser in error recovery state.
Declaration
protected bool YYRecovering { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
Methods
| Improve this Doc View SourceAddState(Int32, State)
OBSOLETE FOR VERSION 1.4.0 Method used by derived types to insert new state instances in the "states" array.
Declaration
protected void AddState(int stateNumber, State state)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | stateNumber | index of the state | 
| State | state | data for the state | 
CharToString(Char)
Return text representation of argument character
Declaration
protected static string CharToString(char input)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Char | input | The character to convert | 
Returns
| Type | Description | 
|---|---|
| System.String | String representation of the character | 
DoAction(Int32)
Execute the selected action from array. Must be overriden in derived classes.
Declaration
protected abstract void DoAction(int actionNumber)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | actionNumber | Index of the action to perform | 
Initialize()
Abstract base method. ShiftReduceParser calls this to initialize the base class data structures. Concrete parser classes must override this method.
Declaration
protected abstract void Initialize()InitNonTerminals(String[])
Initialization method to allow derived classes to insert the non-terminal symbol names into this base class.
Declaration
protected void InitNonTerminals(string[] names)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | names | Non-terminal symbol names | 
InitRules(Rule[])
Initialization method to allow derived classes to insert the rule list into this base class.
Declaration
protected void InitRules(Rule[] rules)Parameters
| Type | Name | Description | 
|---|---|---|
| Rule[] | rules | The array of Rule objects | 
InitSpecialTokens(Int32, Int32)
Initialization method to allow derived classes to insert the special value for the error and EOF tokens.
Declaration
protected void InitSpecialTokens(int err, int end)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | err | The error state ordinal | 
| System.Int32 | end | The EOF stat ordinal | 
InitStates(State[])
Initialization method to allow derived classes to insert the states table into this base class.
Declaration
protected void InitStates(State[] states)Parameters
| Type | Name | Description | 
|---|---|---|
| State[] | states | The pre-initialized states table | 
InitStateTable(Int32)
OBSOLETE FOR VERSION 1.4.0
Declaration
protected void InitStateTable(int size)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | size | 
Parse()
Main entry point of the Shift-Reduce Parser.
Declaration
public bool Parse()Returns
| Type | Description | 
|---|---|
| System.Boolean | True if parse succeeds, else false for unrecoverable errors | 
TerminalToString(Int32)
Abstract state class naming terminal symbols. This is overridden by derived classes with the name (or alias) to be used in error messages.
Declaration
protected abstract string TerminalToString(int terminal)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | terminal | The terminal ordinal | 
Returns
| Type | Description | 
|---|---|
| System.String | 
YYAbort()
Force parser to terminate, returning "false"
Declaration
protected static void YYAbort()YYAccept()
Force parser to terminate, returning "true"
Declaration
protected static void YYAccept()yyclearin()
Traditional YACC method. Discards the next input token.
Declaration
protected void yyclearin()yyerrok()
Tradional YACC method. Clear the "recovering" flag.
Declaration
protected void yyerrok()YYError()
Force parser to terminate, returning "false" if error recovery fails.
Declaration
protected static void YYError()