Parsing System (v0.5)
Goldie Home (v0.5) -> GoldieLib Reference -> Base

Base

These types store the information contained in a CGT file. For more information on what these actually mean, see GOLD's documentation on DFA Lexing, LALR(1) Parsing, and the CGT file format.

Most users of GoldieLib will only need to deal directly with Symbol.

module goldie.base

dstring chars
A dstring containing all the characters contained in this character set.
string toString()
The result of this is valid D code representing a struct literal. For example: auto charSet = CharSet("ABC123"d); assert(charSet.toString() == `CharSet("ABC123"d)`);

module goldie.base

module goldie.base

int symbolIndex
int[] subSymbolIndicies

The symbols that get reduced by this rule.

These are indicies into Language.symbolTable.

string toString()
The result of this is valid D code representing a struct literal. For example: auto rule = Rule(10, [2, 3, 4]); assert(rule.toString() == `Rule( 10, [2, 3, 4] )`);

module goldie.base

bool accept
Is this an "accept" state?
int acceptSymbolIndex
DFAStateEdge[] edges

The DFA edges leading away from this state.

For more information, see DFAStateEdge and GOLD's documentation on DFA Lexing and the CGT file format.

string toString()
The result of this is valid D code representing a struct literal. For example: auto dfaState = DFAState(true, 5, [ DFAStateEdge(3, 8) ]); assert(dfaState.toString() == `DFAState( true, 5, [DFAStateEdge(3,8)] )`);

module goldie.base

If the current character being scanned by the Lexer is in the character set referred to by charSetIndex, then the Lexer moves to the DFA state referred to by targetDFAStateIndex.

For more information, see GOLD's documentation on DFA Lexing and the CGT file format.

int charSetIndex
This is an index into Language.charSetTable.
int targetDFAStateIndex
This is an index into Language.dfaTable.
string toString()
The result of this is valid D code representing a struct literal. For example: auto dfaEdge = DFAStateEdge(3, 8); assert(dfaEdge.toString() == `DFAStateEdge(3,8)`);

module goldie.base

LALRAction[] actions

The possible LALR actions associated with this state.

For more information, see GOLD's documentation on LALR Parsing and the CGT file format.

string toString()
The result of this is valid D code representing a struct literal. For example: auto lalrState = LALRState([ LALRAction(7, LALRAction.Type.Shift, 10) ]); assert(lalrState.toString() == `LALRState( [LALRAction(7,LALRAction.Type.Shift,10)] )`);

module goldie.base

enum Type
The definition of LALRAction.Type is: enum Type { Shift = 1, // target: LALR State Index Reduce = 2, // target: Rule Index Goto = 3, // target: LALR State Index Accept = 4 // target: unused }
int symbolId

The symbol expected in order for the Parser to take this branch of the LALR graph.

This is an index into Language.symbolTable.

For more information, see the definition of enum Type above, as well as GOLD's documentation on LALR Parsing and the CGT file format.

Type type

The type of this state.

For more information, see the definition of enum Type above, as well as GOLD's documentation on LALR Parsing and the CGT file format.

int target

Extra information associated with this LALR state. The exact meaning of this depends on the value of type.

For more information, see the definition of enum Type above, as well as GOLD's documentation on LALR Parsing and the CGT file format.

string toString()
The result of this is valid D code representing a struct literal. For example: auto lalrAction = LALRAction(7, LALRAction.Type.Shift, 10); assert(lalrAction.toString() == `LALRAction(7,LALRAction.Type.Shift,10)`);
static string typeToString(Type type)
Example: string str = LALRAction.typeToString(LALRAction.Type.Reduce); assert(str == "Reduce");
static string fullTypeToString(Type type)
Example: string str = LALRAction.fullTypeToString(LALRAction.Type.Reduce); assert(str == "LALRAction.Type.Reduce");