Parsing System (v0.8)
|
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 dchar start
dchar end
The start and end points of a range of UTF-32 code points.
Both start and end are inclusive.
Comparison operator.
string toString()
The result of this is valid D code representing a struct literal.
For example:
auto charPair = CharPair('A', 'Z');
assert(charPair.toString() == `CharPair('\U00000041','\U0000005A')`);
module goldie.base
This array defines all the UTF-32 code points
contained in this character set.
this(dstring str)
Constructor. Automatically converts an unsorted array of UTF-32 code points (with possible duplicates) to the internal, sorted and canonical, CharPair[] representation. Constructor. This should be sorted and canonical. For instance, a set containing "ABC123" should be laid out exactly like this: CharSet([ CharPair('1','3'), CharPair('A','C') ]);
Any other equivalent set might not be properly handled by when comparing with another CharSet. See opEquals below for specifics. If you're not passing the CharSet into Goldie, and you don't need comparisons to be properly set-based, then this isn't required to be sorted or canonical. Comparison operator. Only checks that the pairs arrays are equal. Doesn't check for set equivalence: auto a = CharSet([ CharPair('A','D') ]);
auto b = CharSet([ CharPair('A','B'), CharPair('C','D') ]);
auto c = CharSet([ CharPair('C','D'), CharPair('A','B') ]);
auto d = CharSet([ CharPair('A','C'), CharPair('B','D') ]);
assert(a == b); // Fails!
assert(a == c); // Fails!
assert(a == d); // Fails!
assert(b == c); // Fails!
assert(b == d); // Fails!
assert(c == d); // Fails!
string toString()
The result of this is valid D code representing a struct literal.
For example:
auto charSet = CharSet("123ABC"d);
assert(
charSet.toString() ==
`CharSet(CharPair('\U00000031','\U00000033'),CharPair('\U00000041','\U00000043'))`
);
dstring toRawChars()
Returns an array of all the UTF-32 code points in this set. Not guaranteed to be sorted or to lack duplicates unless the internal pairs array is sorted and canonical.
Returns a deep (not shallow) duplicate of this CharSet.
bool matches(dchar ch)
Checks whether a UTF-32 code point is included in this set.
auto charSet = CharSet([ CharPair('1','3'), CharPair('A','C') ]);
assert(charSet.matches('B'));
module goldie.base
See the struct Symbol page.
module goldie.base 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] )`);
Returns a deep (not shallow) duplicate of this Rule.
module goldie.base 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. The DFA edges leading away from this state. For more information, see DFAStateEdge and GOLD's documentation on both 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)] )`);
Returns a deep (not shallow) duplicate of this DFAState.
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 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)] )`);
Returns a deep (not shallow) duplicate of this LALRState.
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");
module goldie.base T[] goldieBaseDup(T)(const(T[]) arr)
Duplicates the given array, calling xxxx.dup() on each member. Intended specifically for arrays of the types defined in this goldie.base module. |