Goldie: Base

Goldie
Parsing System (v0.4)
Goldie Home (v0.4)
Getting Started

- Requirements
- Download / Install
- Never Used a Parsing Tool?
- How To Use Goldie
- Grammar Definition Language
- Message Board
- Ticket System

Goldie's Tools

- DumpCGT
- GenDocs
  - Template Format
- GRMC: Grammar Compiler
- JsonViewer
  - Parse Tree Mode
- Parse
- StaticLang
- Other Tools

GoldieLib Overview

- Static And Dynamic Styles
- Ambiguous Symbols

GoldieLib Reference

- Base
- Exception
- class Language
- class Lexer
- class Parser
- struct Symbol
- class Token
- Ver

GoldieLib Sample Apps

- Calculator Dynamic
- Calculator Static
- Parse Anything

CGT File Format
FAQ
Change Log
If You Use Trunk
Future Work
Developers

- Library Source and StaticLang

Goldie Home (v0.4) -> GoldieLib Reference -> Base

# Base

- struct CharSet
- struct Symbol
- struct Rule
- struct DFAState
- struct DFAStateEdge
- struct LALRState
- struct LALRAction

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

struct CharSet
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

struct Symbol
See the struct Symbol page.

module goldie.base

struct Rule
int symbolIndex

The nonterminal symbol this rule reduces to.

This is an index into Language.symbolTable.

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

struct DFAState
bool accept
Is this an "accept" state?
int acceptSymbolIndex

If this is an accept state, acceptSymbolIndex refers to the symbol that has been found.

This is an index into Language.symbolTable.

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

struct DFAStateEdge

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

struct LALRState
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

struct LALRAction
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");