{
	"0: data": {
		"srcIndexStart": "0", 
		"file": "docssrc/docs.APIOver.StatVsDyn.tmpl", 
		"parseTreeMode": "true", 
		"srcLength": "12255", 
		"source": "[$name|StatVsDyn$]
[$title|Static And Dynamic Styles$]
[$frame|HTMLPage.tmpl$]

<p>
Goldie supports two different styles of interfaces: a static-style and
a dynamic-style. Both styles have pros and cons, and are suitable for
different purposes. The differences are explained in the comparison chart
and examples below.
</p>

<p>
Note that if you use [$pageTitle|StaticLang$] to embed a language directly into your program,
you can switch back and forth between static and dynamic styles however you wish.
</p>

<h2>Which Style Should I Use?</h2>
<p>
You can use whichever you want. In fact, you can mix and match both in
the same code.
</p>
<p>
When in doubt, the recommended rule of thumb is:
</p>
<p>
	<em>
		Use static-style unless what you're trying to do requires dynamic-style
		(such as [$pageTitle|Parse$] or [$pageTitle|SampleGenericParse$]).
	</em>
</p>

<p>
Note: Static-style doesn't work on DMD 2.057 due to DMD Issue
[$link| http://d.puremagic.com/issues/show_bug.cgi?id=7375 | #7375 $].
</p>

<h2>Comparison Chart</h2>
<table class=\"grid-table\" style=\"margin-bottom: 1em\">
<tr>
	<td>&nbsp;</td>
	<td style=\"width: 40%\"><h3>Static-style</h3></td>
	<td style=\"width: 40%\"><h3>Dynamic-style</h3></td>
</tr>
<tr>
	<td><h3>Primary Benefits</h3></td>
	<td>Better compile-time type-safety</td>
	<td>More run-time flexibility and slightly simpler API</td>
</tr>
<tr>
	<td><h3>Ideal Uses</h3></td>
	<td>
		<ul>
			<li>You're processing a single specific language.</li>
			<li>You need high reliability.</li>
		</ul>
	</td>
	<td>
		<ul>
			<li>
				You're creating a general language processing tool,
				like [$pageTitle|Parse$] or [$pageTitle|SampleGenericParse$].
			</li>
			<li>You need to support user-created languages.</li>
			<li>You're just working on a quick-and-dirty project.</li>
		</ul>
	</td>
</tr>
<tr>
	<td><h3>Advance Knowledge of Language</h3></td>
	<td>
		Languages must be known ahead-of-time by the developer.
		(This is usually the case.)
	</td>
	<td>
		Can use any user-supplied language, not just ones known by the developer at development-time.
		This enables programs like [$pageTitle|Parse$] and [$pageTitle|SampleGenericParse$] to be possible.
		<br /><br />
		Note: Using a language not known at development-time naturally limits what you
		can do with the language, unless you have a way to programmatically infer
		semantic meaning from a grammar.
	</td>
</tr>
<tr>
	<td><h3>Loading a Language</h3></td>
	<td>
		Use [$pageTitle|StaticLang$] to embed the language directly into your program at compile-time.
	</td>
	<td>
		<ul>
			<li>Use [$pageTitle|StaticLang$] to embed the language directly into your program at compile-time.</li>
			<li><em>OR</em> Load a [$code|inline|.cgt$] file at run-time.</li>
			<li><em>OR</em> Compile a grammar definition at run-time.</li>
		</ul>
	</td>
</tr>
<tr>
	<td><h3>Token Types</h3></td>
	<td>
		All tokens are subclassed from [$typeName|Token$] with a different
		type for each symbol or rule (rule-tokens are subclassed from
		nonterminal symbol-tokens).
	</td>
	<td>All tokens are of the type [$typeName|Token$].</td>
</tr>
<tr>
	<td><h3>Use of Non-Existent Symbol/Rule</h3></td>
	<td>Can be caught at compile-time.</td>
	<td>Only detectable at run-time.</td>
</tr>
<tr>
	<td><h3>Use of a Different Symbol/Rule Than Expected</h3></td>
	<td>Can be caught at compile-time.</td>
	<td>Only detectable at run-time.</td>
</tr>
<tr>
	<td><h3>Unhandled Symbols</h3></td>
	<td>Can be caught at compile-time.</td>
	<td>Only detectable at run-time.</td>
</tr>
<tr>
	<td><h3>Unhandled Rules</h3></td>
	<td>
		Effectively caught at run-time.
		<br /><br />
		(It's possible to catch this at compile-time, but at some point
		you still have to do a run-time check to see what rule a nonterminal
		was created from. And that check currently can't detect an unhandled rule at compile-time.)
	</td>
	<td>
		Only detectable at run-time.
	</td>
</tr>
</table>

<a name=\"Types\" />
<h2>Types and Inheritance</h2>
<p>
Consider this grammar:
</p>
[$code|plain|
[:! This is grammar \"numberList.grm\"
\"Start Symbol\" = <List>

Number = {Digit}+

<List> ::= <List> '+' Number
         | Number
		 | :]
$]
<p>
In both dynamic-style and static-style, there are the types
[$typeName|Language$], [$typeName|Lexer$] and [$typeName|Parser$].
These classes work for any grammar.
</p>
<p>
Static-style additionally subclasses those with the following types, which can *only*
be used with the \"numberList\" grammar: 
[$typeLink|Language_{languageName}| Language_numberList$],
[$typeLink|Lexer_{languageName}| Lexer_numberList$] and
[$typeLink|Parser_{languageName}| Parser_numberList$].
These contain additional/modified functionality that provides better type-safety.
</p>
<p>
The [$typeName|Token$] type works similarly, but with some extra subclasses:
</p>
<p>
In dynamic-style, all of the language's [$pageLink|APIOver#TokenSymbol| symbols $]
(ie, [$code|inline|Number$], [$code|inline|<List>$] and
the implicitly-defined [$code|inline|Whitespace$], [$code|inline|Error$] and [$code|inline|EOF$])
are represented by type [$typeName|Token$].
</p>
<p>
That is still true in static-style, but static-style also defines the following types:
</p>

<div class=\"api-def\">
	<h4 style=\"margin-bottom: 0px\">Subclass of Token:</h4>
	<ul>
	<li>[$typeLink|Token_{languageName}| Token_numberList $]: All tokens in the language \"numberList\".</li>
	</ul>

	<h4 style=\"margin-bottom: 0px\">Subclasses of Token_numberList:</h4>
	<ul>
	<li>[$typeLink|Token_{languageName}!{symbol}| Token_numberList!\"Number\" $]: All [$ident|Number$] terminals.</li>
	<li>[$typeLink|Token_{languageName}!{symbol}| Token_numberList!\"&lt;List&gt;\" $]: All [$ident|&lt;List&gt;$] nonterminals.</li>
	<li>[$typeLink|Token_{languageName}!{symbol}| Token_numberList!\"Whitespace\" $]: A special terminal built into all grammars.</li>
	<li>[$typeLink|Token_{languageName}!{symbol}| Token_numberList!\"Error\" $]: A special terminal built into all grammars.</li>
	<li>[$typeLink|Token_{languageName}!{symbol}| Token_numberList!\"EOF\" $]: A special terminal built into all grammars.</li>
	<!-- <li>Plus similar types for the implicitly-defined [$typeLink|SymbolType| Whitespace, Error and EOF symbols $].</li> -->
	</ul>

	<h4 style=\"margin-bottom: 0px\">Subclasses of Token_numberList!\"Number\":</h4>
	<ul>
	<li>
		None, because [$ident|Number$] is a terminal.
	</li>
	</ul>

	<h4 style=\"margin-bottom: 0px\">Subclasses of Token_numberList!\"&lt;List&gt;\":</h4>
	<ul>
	<li>
		[$typeLink|Token_{languageName}!{rule}| Token_numberList!(\"&lt;List&gt;\", \"&lt;List&gt;\", \"+\", \"Number\") $]:<br />
		All [$ident|&lt;List&gt;$] nonterminals matching the rule: [$code|inline| <List> ::= <List> '+' Number $]
	</li>
	<li>
		[$typeLink|Token_{languageName}!{rule}| Token_numberList!(\"&lt;List&gt;\", \"Number\") $]:<br />
		All [$ident|&lt;List&gt;$] nonterminals matching the rule: [$code|inline| <List> ::= Number $]
	</li>
	<li>
		[$typeLink|Token_{languageName}!{rule}| Token_numberList!(\"&lt;List&gt;\", null) $]:<br />
		All [$ident|&lt;List&gt;$] nonterminals matching the empty rule: [$code|inline|[:<List> ::= :]$]
	</li>
	</ul>
	<p>
	(Note: A future version of Goldie might be made to accept the actual rule,
	such as [$code|inline| Token_numberList!\"<List> ::= <List> '+' Number\" $],
	instead of a list of separate strings.)
	</p>
</div>

<p>
See also [$pageTitle|AmbiguousSym$].
</p>

<a name=\"ExLoading\" />
<h2>Examples</h2>
<p>
The following examples use the
[$link| https://bitbucket.org/Abscissa/goldie/src/v0.8/lang/calc.grm | calc $]
grammar.
</p>

<h2>Example: Loading a Language</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:// Run \"goldie-staticlang calc.cgt --pack:myapp.mylangs\" at the command-line
import goldie.all;
import myapp.mylangs.calc.all;
// Use 'language_calc':]
$]
</div>


<h3>Dynamic-style</h3>
<div class=\"api-def\">
<p>Do the same as static-style, or:</p>
[$code|highlight|
[:import goldie.all;
Language language_calc = Language.loadCGT(\"calc.cgt\");
// Use 'language_calc':]
$]
<p>Or (slower) compile a grammar at runtime:</p>
[$code|highlight|
[:import goldie.all;
Language language_calcA = Language.compileGrammar(`...actual grammar here...`);
// -or-
Language language_calcB = Language.compileGrammarFile(\"calc.grm\");
// Use 'language_calcA' or 'language_calcB':]
$]
</div>


<h2>Example: Parsing a source</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:string src = ...;
Token_calc!\"<Add Exp>\" rootToken = language_calc.parseCode(src).parseTree;:]
$]
<p>
See [$typeName|Token_{languageName}!{symbol}$] for details.
</p>
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:string src = ...;
Token rootToken = language_calc.parseCodeX(src).parseTreeX;:]
$]
</div>
<h4 style=\"margin-bottom: 0px;\">See also:</h4>
<ul>
	<li>[$typeName|Language_{languageName}$].[$pageLink|Language#Language_parseCode |parseCode $]</li>
	<li>[$typeName|Language_{languageName}$].[$pageLink|Language#Language_parseFile |parseFile $]</li>
	<li>[$typeName|Language$].[$pageLink|Language#Language_parseCodeX |parseCodeX $]</li>
	<li>[$typeName|Language$].[$pageLink|Language#Language_parseFileX |parseFileX $]</li>
</ul>


<a name=\"ExCheckSymbol\" />
<h2>Example: Checking a token's symbol</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:// Check static/compile-time type (ie, not polymorphic)
bool isAddExp(Token_calc!\"<Add Exp>\" tok)
{
	return true;
}
bool isAddExp(Token tok)
{
	return false;
}

// Check run-time type (ie, polymorphic)
bool isAddExp(Token_calc tok)
{
	return cast(Token_calc!\"<Add Exp>\")tok is null;
	
	// Or to disambiguate (See the \"Ambiguous Symbols\" page):
	return cast(Token_calc!(SymbolType.NonTerminal, \"<Add Exp>\"))tok is null;
}:]
$]
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:bool isAddExp(Token tok)
{
	return tok.name == \"<Add Exp>\";
	
	// Or to disambiguate (See the \"Ambiguous Symbols\" page):
	return tok.name == \"<Add Exp>\" && tok.type == SymbolType.NonTerminal;
}:]
$]
</div>


<a name=\"ExCheckRule\" />
<h2>Example: Checking a token's rule and retrieving a sub-token</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:Token_calc!\"<Mult Exp>\" getMultExp(Token_calc!\"<Add Exp>\" tok)
{
	// This represents the rule: <Add Exp> ::= <Add Exp> '+' <Mult Exp>
	if( auto t = cast(Token_calc!(\"<Add Exp>\", \"<Add Exp>\", \"+\", \"<Mult Exp>\"))tok )
	{
		return t.sub!2;
	}
}:]
$]
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:Token getMultExp(Token tok)
{
	// This represents the rule: <Add Exp> ::= <Add Exp> '+' <Mult Exp>
	if( tok.matches(\"<Add Exp>\", \"<Add Exp>\", \"+\", \"<Mult Exp>\") )
	{
		return tok[2];
	}
}:]
$]
</div>


<a name=\"ExDescendant\" />
<h2>Example: Finding a descendant token</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:alias Token_calc Tok; // For convenience

// Returns:
//   this
//     .sub!(/+ the first <Mult Exp> +/)
//     .sub!(/+ the first <Negate Exp> +/)
//     .sub!(/+ the first <Value> that was created from <Value> ::= Number +/);
// 
// If not found, returns null
Tok!(\"<Value>\",\"Number\") foo(Token tok)
{
	return tok.get!( Tok!\"<Mult Exp>\", Tok!\"<Negate Exp>\", Tok!(\"<Value>\",\"Number\") )();
}:]
$]
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
[$code|highlight|
[:// Returns:
//   this
//     [/+ the first <Mult Exp> +/]
//     [/+ the first <Negate Exp> +/]
//     [/+ the first <Value> that was created from <Value> ::= Number +/];
// 
// If not found, returns null

Token foo(Token tok)
{
	auto t = tok.get( [\"<Mult Exp>\", \"<Negate Exp>\", \"<Value>\"] );

	if(t && t.matches(\"<Value>\", \"Number\"))
		return t;

	return null;
}:]
$]
</div>
<h4 style=\"margin-bottom: 0px;\">See also:</h4>
<ul>
	<li>[$typeName|Token$].[$pageLink|Token#Token_get|get$]</li>
	<li>[$typeName|Token$].[$pageLink|Token#Token_getRequired|getRequired$]</li>
</ul>

<a name=\"ExTraverse\" />
<h2>Example: Traverse each node in a parse tree, with optional filtering</h2>
<div class=\"api-def\">
	See documentation of [$pageLink|Token#traverse|traverse$] for examples.
</div>

<h2>More Examples</h2>
<p>
For a full-program example of static-style versus dynamic-style, see
[$pageTitle|CalculatorStatic$] and [$pageTitle|CalculatorDynamic$].
</p>
", 
		"0: name": {
			"srcIndexStart": "0", 
			"data": "StatVsDyn", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "7", 
				"data": "StatVsDyn", 
				"srcLength": "9"
			}
		}, 
		"1: data": {
			"srcIndexStart": "18", 
			"data": "
", 
			"srcLength": "1"
		}, 
		"2: title": {
			"srcIndexStart": "19", 
			"data": "Static And Dynamic Styles", 
			"srcLength": "35", 
			"0: data": {
				"srcIndexStart": "27", 
				"data": "Static And Dynamic Styles", 
				"srcLength": "25"
			}
		}, 
		"3: data": {
			"srcIndexStart": "54", 
			"data": "
", 
			"srcLength": "1"
		}, 
		"4: frame": {
			"srcIndexStart": "55", 
			"data": "HTMLPage.tmpl", 
			"srcLength": "23", 
			"0: data": {
				"srcIndexStart": "63", 
				"data": "HTMLPage.tmpl", 
				"srcLength": "13"
			}
		}, 
		"5: data": {
			"srcIndexStart": "78", 
			"data": "

<p>
Goldie supports two different styles of interfaces: a static-style and
a dynamic-style. Both styles have pros and cons, and are suitable for
different purposes. The differences are explained in the comparison chart
and examples below.
</p>

<p>
Note that if you use ", 
			"srcLength": "272"
		}, 
		"6: pageTitle": {
			"srcIndexStart": "350", 
			"data": "StaticLang", 
			"srcLength": "24", 
			"0: data": {
				"srcIndexStart": "362", 
				"data": "StaticLang", 
				"srcLength": "10"
			}
		}, 
		"7: data": {
			"srcIndexStart": "374", 
			"data": " to embed a language directly into your program,
you can switch back and forth between static and dynamic styles however you wish.
</p>

<h2>Which Style Should I Use?</h2>
<p>
You can use whichever you want. In fact, you can mix and match both in
the same code.
</p>
<p>
When in doubt, the recommended rule of thumb is:
</p>
<p>
	<em>
		Use static-style unless what you're trying to do requires dynamic-style
		(such as ", 
			"srcLength": "420"
		}, 
		"8: pageTitle": {
			"srcIndexStart": "794", 
			"data": "Parse", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "806", 
				"data": "Parse", 
				"srcLength": "5"
			}
		}, 
		"9: data": {
			"srcIndexStart": "813", 
			"data": " or ", 
			"srcLength": "4"
		}, 
		"10: pageTitle": {
			"srcIndexStart": "817", 
			"data": "SampleGenericParse", 
			"srcLength": "32", 
			"0: data": {
				"srcIndexStart": "829", 
				"data": "SampleGenericParse", 
				"srcLength": "18"
			}
		}, 
		"11: data": {
			"srcIndexStart": "849", 
			"data": ").
	</em>
</p>

<p>
Note: Static-style doesn't work on DMD 2.057 due to DMD Issue
", 
			"srcLength": "82"
		}, 
		"12: link": {
			"srcIndexStart": "931", 
			"param 0": "http://d.puremagic.com/issues/show_bug.cgi?id=7375", 
			"data": "#7375", 
			"srcLength": "69", 
			"0: data": {
				"srcIndexStart": "991", 
				"data": "#7375", 
				"srcLength": "7"
			}
		}, 
		"13: data": {
			"srcIndexStart": "1000", 
			"data": ".
</p>

<h2>Comparison Chart</h2>
<table class=\"grid-table\" style=\"margin-bottom: 1em\">
<tr>
	<td>&nbsp;</td>
	<td style=\"width: 40%\"><h3>Static-style</h3></td>
	<td style=\"width: 40%\"><h3>Dynamic-style</h3></td>
</tr>
<tr>
	<td><h3>Primary Benefits</h3></td>
	<td>Better compile-time type-safety</td>
	<td>More run-time flexibility and slightly simpler API</td>
</tr>
<tr>
	<td><h3>Ideal Uses</h3></td>
	<td>
		<ul>
			<li>You're processing a single specific language.</li>
			<li>You need high reliability.</li>
		</ul>
	</td>
	<td>
		<ul>
			<li>
				You're creating a general language processing tool,
				like ", 
			"srcLength": "615"
		}, 
		"14: pageTitle": {
			"srcIndexStart": "1615", 
			"data": "Parse", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "1627", 
				"data": "Parse", 
				"srcLength": "5"
			}
		}, 
		"15: data": {
			"srcIndexStart": "1634", 
			"data": " or ", 
			"srcLength": "4"
		}, 
		"16: pageTitle": {
			"srcIndexStart": "1638", 
			"data": "SampleGenericParse", 
			"srcLength": "32", 
			"0: data": {
				"srcIndexStart": "1650", 
				"data": "SampleGenericParse", 
				"srcLength": "18"
			}
		}, 
		"17: data": {
			"srcIndexStart": "1670", 
			"data": ".
			</li>
			<li>You need to support user-created languages.</li>
			<li>You're just working on a quick-and-dirty project.</li>
		</ul>
	</td>
</tr>
<tr>
	<td><h3>Advance Knowledge of Language</h3></td>
	<td>
		Languages must be known ahead-of-time by the developer.
		(This is usually the case.)
	</td>
	<td>
		Can use any user-supplied language, not just ones known by the developer at development-time.
		This enables programs like ", 
			"srcLength": "436"
		}, 
		"18: pageTitle": {
			"srcIndexStart": "2106", 
			"data": "Parse", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "2118", 
				"data": "Parse", 
				"srcLength": "5"
			}
		}, 
		"19: data": {
			"srcIndexStart": "2125", 
			"data": " and ", 
			"srcLength": "5"
		}, 
		"20: pageTitle": {
			"srcIndexStart": "2130", 
			"data": "SampleGenericParse", 
			"srcLength": "32", 
			"0: data": {
				"srcIndexStart": "2142", 
				"data": "SampleGenericParse", 
				"srcLength": "18"
			}
		}, 
		"21: data": {
			"srcIndexStart": "2162", 
			"data": " to be possible.
		<br /><br />
		Note: Using a language not known at development-time naturally limits what you
		can do with the language, unless you have a way to programmatically infer
		semantic meaning from a grammar.
	</td>
</tr>
<tr>
	<td><h3>Loading a Language</h3></td>
	<td>
		Use ", 
			"srcLength": "292"
		}, 
		"22: pageTitle": {
			"srcIndexStart": "2454", 
			"data": "StaticLang", 
			"srcLength": "24", 
			"0: data": {
				"srcIndexStart": "2466", 
				"data": "StaticLang", 
				"srcLength": "10"
			}
		}, 
		"23: data": {
			"srcIndexStart": "2478", 
			"data": " to embed the language directly into your program at compile-time.
	</td>
	<td>
		<ul>
			<li>Use ", 
			"srcLength": "98"
		}, 
		"24: pageTitle": {
			"srcIndexStart": "2576", 
			"data": "StaticLang", 
			"srcLength": "24", 
			"0: data": {
				"srcIndexStart": "2588", 
				"data": "StaticLang", 
				"srcLength": "10"
			}
		}, 
		"25: data": {
			"srcIndexStart": "2600", 
			"data": " to embed the language directly into your program at compile-time.</li>
			<li><em>OR</em> Load a ", 
			"srcLength": "98"
		}, 
		"26: code": {
			"srcIndexStart": "2698", 
			"param 0": "inline", 
			"data": ".cgt", 
			"srcLength": "20", 
			"0: data": {
				"srcIndexStart": "2712", 
				"data": ".cgt", 
				"srcLength": "4"
			}
		}, 
		"27: data": {
			"srcIndexStart": "2718", 
			"data": " file at run-time.</li>
			<li><em>OR</em> Compile a grammar definition at run-time.</li>
		</ul>
	</td>
</tr>
<tr>
	<td><h3>Token Types</h3></td>
	<td>
		All tokens are subclassed from ", 
			"srcLength": "186"
		}, 
		"28: typeName": {
			"srcIndexStart": "2904", 
			"data": "Token", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "2915", 
				"data": "Token", 
				"srcLength": "5"
			}
		}, 
		"29: data": {
			"srcIndexStart": "2922", 
			"data": " with a different
		type for each symbol or rule (rule-tokens are subclassed from
		nonterminal symbol-tokens).
	</td>
	<td>All tokens are of the type ", 
			"srcLength": "151"
		}, 
		"30: typeName": {
			"srcIndexStart": "3073", 
			"data": "Token", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "3084", 
				"data": "Token", 
				"srcLength": "5"
			}
		}, 
		"31: data": {
			"srcIndexStart": "3091", 
			"data": ".</td>
</tr>
<tr>
	<td><h3>Use of Non-Existent Symbol/Rule</h3></td>
	<td>Can be caught at compile-time.</td>
	<td>Only detectable at run-time.</td>
</tr>
<tr>
	<td><h3>Use of a Different Symbol/Rule Than Expected</h3></td>
	<td>Can be caught at compile-time.</td>
	<td>Only detectable at run-time.</td>
</tr>
<tr>
	<td><h3>Unhandled Symbols</h3></td>
	<td>Can be caught at compile-time.</td>
	<td>Only detectable at run-time.</td>
</tr>
<tr>
	<td><h3>Unhandled Rules</h3></td>
	<td>
		Effectively caught at run-time.
		<br /><br />
		(It's possible to catch this at compile-time, but at some point
		you still have to do a run-time check to see what rule a nonterminal
		was created from. And that check currently can't detect an unhandled rule at compile-time.)
	</td>
	<td>
		Only detectable at run-time.
	</td>
</tr>
</table>

<a name=\"Types\" />
<h2>Types and Inheritance</h2>
<p>
Consider this grammar:
</p>
", 
			"srcLength": "913"
		}, 
		"32: code": {
			"srcIndexStart": "4004", 
			"param 0": "plain", 
			"data": "! This is grammar \"numberList.grm\"
\"Start Symbol\" = &lt;List&gt;

Number = {Digit}+

&lt;List&gt; ::= &lt;List&gt; '+' Number
         | Number
         | ", 
			"srcLength": "152", 
			"0: data": {
				"srcIndexStart": "4017", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "4018", 
				"data": "! This is grammar \"numberList.grm\"
\"Start Symbol\" = <List>

Number = {Digit}+

<List> ::= <List> '+' Number
         | Number
		 | ", 
				"srcLength": "135"
			}, 
			"2: data": {
				"srcIndexStart": "4153", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"33: data": {
			"srcIndexStart": "4156", 
			"data": "
<p>
In both dynamic-style and static-style, there are the types
", 
			"srcLength": "65"
		}, 
		"34: typeName": {
			"srcIndexStart": "4221", 
			"data": "Language", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "4232", 
				"data": "Language", 
				"srcLength": "8"
			}
		}, 
		"35: data": {
			"srcIndexStart": "4242", 
			"data": ", ", 
			"srcLength": "2"
		}, 
		"36: typeName": {
			"srcIndexStart": "4244", 
			"data": "Lexer", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "4255", 
				"data": "Lexer", 
				"srcLength": "5"
			}
		}, 
		"37: data": {
			"srcIndexStart": "4262", 
			"data": " and ", 
			"srcLength": "5"
		}, 
		"38: typeName": {
			"srcIndexStart": "4267", 
			"data": "Parser", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "4278", 
				"data": "Parser", 
				"srcLength": "6"
			}
		}, 
		"39: data": {
			"srcIndexStart": "4286", 
			"data": ".
These classes work for any grammar.
</p>
<p>
Static-style additionally subclasses those with the following types, which can *only*
be used with the \"numberList\" grammar: 
", 
			"srcLength": "173"
		}, 
		"40: typeLink": {
			"srcIndexStart": "4459", 
			"param 0": "Language_{languageName}", 
			"data": "Language_numberList", 
			"srcLength": "57", 
			"0: data": {
				"srcIndexStart": "4494", 
				"data": "Language_numberList", 
				"srcLength": "20"
			}
		}, 
		"41: data": {
			"srcIndexStart": "4516", 
			"data": ",
", 
			"srcLength": "2"
		}, 
		"42: typeLink": {
			"srcIndexStart": "4518", 
			"param 0": "Lexer_{languageName}", 
			"data": "Lexer_numberList", 
			"srcLength": "51", 
			"0: data": {
				"srcIndexStart": "4550", 
				"data": "Lexer_numberList", 
				"srcLength": "17"
			}
		}, 
		"43: data": {
			"srcIndexStart": "4569", 
			"data": " and
", 
			"srcLength": "5"
		}, 
		"44: typeLink": {
			"srcIndexStart": "4574", 
			"param 0": "Parser_{languageName}", 
			"data": "Parser_numberList", 
			"srcLength": "53", 
			"0: data": {
				"srcIndexStart": "4607", 
				"data": "Parser_numberList", 
				"srcLength": "18"
			}
		}, 
		"45: data": {
			"srcIndexStart": "4627", 
			"data": ".
These contain additional/modified functionality that provides better type-safety.
</p>
<p>
The ", 
			"srcLength": "97"
		}, 
		"46: typeName": {
			"srcIndexStart": "4724", 
			"data": "Token", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "4735", 
				"data": "Token", 
				"srcLength": "5"
			}
		}, 
		"47: data": {
			"srcIndexStart": "4742", 
			"data": " type works similarly, but with some extra subclasses:
</p>
<p>
In dynamic-style, all of the language's ", 
			"srcLength": "104"
		}, 
		"48: pageLink": {
			"srcIndexStart": "4846", 
			"param 0": "APIOver#TokenSymbol", 
			"data": "symbols", 
			"srcLength": "42", 
			"0: data": {
				"srcIndexStart": "4877", 
				"data": "symbols", 
				"srcLength": "9"
			}
		}, 
		"49: data": {
			"srcIndexStart": "4888", 
			"data": "
(ie, ", 
			"srcLength": "6"
		}, 
		"50: code": {
			"srcIndexStart": "4894", 
			"param 0": "inline", 
			"data": "Number", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "4908", 
				"data": "Number", 
				"srcLength": "6"
			}
		}, 
		"51: data": {
			"srcIndexStart": "4916", 
			"data": ", ", 
			"srcLength": "2"
		}, 
		"52: code": {
			"srcIndexStart": "4918", 
			"param 0": "inline", 
			"data": "&lt;List&gt;", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "4932", 
				"data": "<List>", 
				"srcLength": "6"
			}
		}, 
		"53: data": {
			"srcIndexStart": "4940", 
			"data": " and
the implicitly-defined ", 
			"srcLength": "28"
		}, 
		"54: code": {
			"srcIndexStart": "4968", 
			"param 0": "inline", 
			"data": "Whitespace", 
			"srcLength": "26", 
			"0: data": {
				"srcIndexStart": "4982", 
				"data": "Whitespace", 
				"srcLength": "10"
			}
		}, 
		"55: data": {
			"srcIndexStart": "4994", 
			"data": ", ", 
			"srcLength": "2"
		}, 
		"56: code": {
			"srcIndexStart": "4996", 
			"param 0": "inline", 
			"data": "Error", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "5010", 
				"data": "Error", 
				"srcLength": "5"
			}
		}, 
		"57: data": {
			"srcIndexStart": "5017", 
			"data": " and ", 
			"srcLength": "5"
		}, 
		"58: code": {
			"srcIndexStart": "5022", 
			"param 0": "inline", 
			"data": "EOF", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "5036", 
				"data": "EOF", 
				"srcLength": "3"
			}
		}, 
		"59: data": {
			"srcIndexStart": "5041", 
			"data": ")
are represented by type ", 
			"srcLength": "26"
		}, 
		"60: typeName": {
			"srcIndexStart": "5067", 
			"data": "Token", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "5078", 
				"data": "Token", 
				"srcLength": "5"
			}
		}, 
		"61: data": {
			"srcIndexStart": "5085", 
			"data": ".
</p>
<p>
That is still true in static-style, but static-style also defines the following types:
</p>

<div class=\"api-def\">
	<h4 style=\"margin-bottom: 0px\">Subclass of Token:</h4>
	<ul>
	<li>", 
			"srcLength": "193"
		}, 
		"62: typeLink": {
			"srcIndexStart": "5278", 
			"param 0": "Token_{languageName}", 
			"data": "Token_numberList", 
			"srcLength": "52", 
			"0: data": {
				"srcIndexStart": "5310", 
				"data": "Token_numberList", 
				"srcLength": "18"
			}
		}, 
		"63: data": {
			"srcIndexStart": "5330", 
			"data": ": All tokens in the language \"numberList\".</li>
	</ul>

	<h4 style=\"margin-bottom: 0px\">Subclasses of Token_numberList:</h4>
	<ul>
	<li>", 
			"srcLength": "136"
		}, 
		"64: typeLink": {
			"srcIndexStart": "5466", 
			"param 0": "Token_{languageName}!{symbol}", 
			"data": "Token_numberList!\"Number\"", 
			"srcLength": "70", 
			"0: data": {
				"srcIndexStart": "5507", 
				"data": "Token_numberList!\"Number\"", 
				"srcLength": "27"
			}
		}, 
		"65: data": {
			"srcIndexStart": "5536", 
			"data": ": All ", 
			"srcLength": "6"
		}, 
		"66: ident": {
			"srcIndexStart": "5542", 
			"data": "Number", 
			"srcLength": "16", 
			"0: data": {
				"srcIndexStart": "5550", 
				"data": "Number", 
				"srcLength": "6"
			}
		}, 
		"67: data": {
			"srcIndexStart": "5558", 
			"data": " terminals.</li>
	<li>", 
			"srcLength": "22"
		}, 
		"68: typeLink": {
			"srcIndexStart": "5580", 
			"param 0": "Token_{languageName}!{symbol}", 
			"data": "Token_numberList!\"&lt;List&gt;\"", 
			"srcLength": "76", 
			"0: data": {
				"srcIndexStart": "5621", 
				"data": "Token_numberList!\"&lt;List&gt;\"", 
				"srcLength": "33"
			}
		}, 
		"69: data": {
			"srcIndexStart": "5656", 
			"data": ": All ", 
			"srcLength": "6"
		}, 
		"70: ident": {
			"srcIndexStart": "5662", 
			"data": "&lt;List&gt;", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "5670", 
				"data": "&lt;List&gt;", 
				"srcLength": "12"
			}
		}, 
		"71: data": {
			"srcIndexStart": "5684", 
			"data": " nonterminals.</li>
	<li>", 
			"srcLength": "25"
		}, 
		"72: typeLink": {
			"srcIndexStart": "5709", 
			"param 0": "Token_{languageName}!{symbol}", 
			"data": "Token_numberList!\"Whitespace\"", 
			"srcLength": "74", 
			"0: data": {
				"srcIndexStart": "5750", 
				"data": "Token_numberList!\"Whitespace\"", 
				"srcLength": "31"
			}
		}, 
		"73: data": {
			"srcIndexStart": "5783", 
			"data": ": A special terminal built into all grammars.</li>
	<li>", 
			"srcLength": "56"
		}, 
		"74: typeLink": {
			"srcIndexStart": "5839", 
			"param 0": "Token_{languageName}!{symbol}", 
			"data": "Token_numberList!\"Error\"", 
			"srcLength": "69", 
			"0: data": {
				"srcIndexStart": "5880", 
				"data": "Token_numberList!\"Error\"", 
				"srcLength": "26"
			}
		}, 
		"75: data": {
			"srcIndexStart": "5908", 
			"data": ": A special terminal built into all grammars.</li>
	<li>", 
			"srcLength": "56"
		}, 
		"76: typeLink": {
			"srcIndexStart": "5964", 
			"param 0": "Token_{languageName}!{symbol}", 
			"data": "Token_numberList!\"EOF\"", 
			"srcLength": "67", 
			"0: data": {
				"srcIndexStart": "6005", 
				"data": "Token_numberList!\"EOF\"", 
				"srcLength": "24"
			}
		}, 
		"77: data": {
			"srcIndexStart": "6031", 
			"data": ": A special terminal built into all grammars.</li>
	<!-- <li>Plus similar types for the implicitly-defined ", 
			"srcLength": "107"
		}, 
		"78: typeLink": {
			"srcIndexStart": "6138", 
			"param 0": "SymbolType", 
			"data": "Whitespace, Error and EOF symbols", 
			"srcLength": "59", 
			"0: data": {
				"srcIndexStart": "6160", 
				"data": "Whitespace, Error and EOF symbols", 
				"srcLength": "35"
			}
		}, 
		"79: data": {
			"srcIndexStart": "6197", 
			"data": ".</li> -->
	</ul>

	<h4 style=\"margin-bottom: 0px\">Subclasses of Token_numberList!\"Number\":</h4>
	<ul>
	<li>
		None, because ", 
			"srcLength": "125"
		}, 
		"80: ident": {
			"srcIndexStart": "6322", 
			"data": "Number", 
			"srcLength": "16", 
			"0: data": {
				"srcIndexStart": "6330", 
				"data": "Number", 
				"srcLength": "6"
			}
		}, 
		"81: data": {
			"srcIndexStart": "6338", 
			"data": " is a terminal.
	</li>
	</ul>

	<h4 style=\"margin-bottom: 0px\">Subclasses of Token_numberList!\"&lt;List&gt;\":</h4>
	<ul>
	<li>
		", 
			"srcLength": "129"
		}, 
		"82: typeLink": {
			"srcIndexStart": "6467", 
			"param 0": "Token_{languageName}!{rule}", 
			"data": "Token_numberList!(\"&lt;List&gt;\", \"&lt;List&gt;\", \"+\", \"Number\")", 
			"srcLength": "107", 
			"0: data": {
				"srcIndexStart": "6506", 
				"data": "Token_numberList!(\"&lt;List&gt;\", \"&lt;List&gt;\", \"+\", \"Number\")", 
				"srcLength": "66"
			}
		}, 
		"83: data": {
			"srcIndexStart": "6574", 
			"data": ":<br />
		All ", 
			"srcLength": "14"
		}, 
		"84: ident": {
			"srcIndexStart": "6588", 
			"data": "&lt;List&gt;", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "6596", 
				"data": "&lt;List&gt;", 
				"srcLength": "12"
			}
		}, 
		"85: data": {
			"srcIndexStart": "6610", 
			"data": " nonterminals matching the rule: ", 
			"srcLength": "33"
		}, 
		"86: code": {
			"srcIndexStart": "6643", 
			"param 0": "inline", 
			"data": "&lt;List&gt; ::= &lt;List&gt; '+' Number", 
			"srcLength": "46", 
			"0: data": {
				"srcIndexStart": "6657", 
				"data": "<List> ::= <List> '+' Number", 
				"srcLength": "30"
			}
		}, 
		"87: data": {
			"srcIndexStart": "6689", 
			"data": "
	</li>
	<li>
		", 
			"srcLength": "16"
		}, 
		"88: typeLink": {
			"srcIndexStart": "6705", 
			"param 0": "Token_{languageName}!{rule}", 
			"data": "Token_numberList!(\"&lt;List&gt;\", \"Number\")", 
			"srcLength": "86", 
			"0: data": {
				"srcIndexStart": "6744", 
				"data": "Token_numberList!(\"&lt;List&gt;\", \"Number\")", 
				"srcLength": "45"
			}
		}, 
		"89: data": {
			"srcIndexStart": "6791", 
			"data": ":<br />
		All ", 
			"srcLength": "14"
		}, 
		"90: ident": {
			"srcIndexStart": "6805", 
			"data": "&lt;List&gt;", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "6813", 
				"data": "&lt;List&gt;", 
				"srcLength": "12"
			}
		}, 
		"91: data": {
			"srcIndexStart": "6827", 
			"data": " nonterminals matching the rule: ", 
			"srcLength": "33"
		}, 
		"92: code": {
			"srcIndexStart": "6860", 
			"param 0": "inline", 
			"data": "&lt;List&gt; ::= Number", 
			"srcLength": "35", 
			"0: data": {
				"srcIndexStart": "6874", 
				"data": "<List> ::= Number", 
				"srcLength": "19"
			}
		}, 
		"93: data": {
			"srcIndexStart": "6895", 
			"data": "
	</li>
	<li>
		", 
			"srcLength": "16"
		}, 
		"94: typeLink": {
			"srcIndexStart": "6911", 
			"param 0": "Token_{languageName}!{rule}", 
			"data": "Token_numberList!(\"&lt;List&gt;\", null)", 
			"srcLength": "82", 
			"0: data": {
				"srcIndexStart": "6950", 
				"data": "Token_numberList!(\"&lt;List&gt;\", null)", 
				"srcLength": "41"
			}
		}, 
		"95: data": {
			"srcIndexStart": "6993", 
			"data": ":<br />
		All ", 
			"srcLength": "14"
		}, 
		"96: ident": {
			"srcIndexStart": "7007", 
			"data": "&lt;List&gt;", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "7015", 
				"data": "&lt;List&gt;", 
				"srcLength": "12"
			}
		}, 
		"97: data": {
			"srcIndexStart": "7029", 
			"data": " nonterminals matching the empty rule: ", 
			"srcLength": "39"
		}, 
		"98: code": {
			"srcIndexStart": "7068", 
			"param 0": "inline", 
			"data": "&lt;List&gt; ::= ", 
			"srcLength": "31", 
			"0: data": {
				"srcIndexStart": "7082", 
				"data": "<List> ::= ", 
				"srcLength": "15"
			}
		}, 
		"99: data": {
			"srcIndexStart": "7099", 
			"data": "
	</li>
	</ul>
	<p>
	(Note: A future version of Goldie might be made to accept the actual rule,
	such as ", 
			"srcLength": "105"
		}, 
		"100: code": {
			"srcIndexStart": "7204", 
			"param 0": "inline", 
			"data": "Token_numberList!\"&lt;List&gt; ::= &lt;List&gt; '+' Number\"", 
			"srcLength": "65", 
			"0: data": {
				"srcIndexStart": "7218", 
				"data": "Token_numberList!\"<List> ::= <List> '+' Number\"", 
				"srcLength": "49"
			}
		}, 
		"101: data": {
			"srcIndexStart": "7269", 
			"data": ",
	instead of a list of separate strings.)
	</p>
</div>

<p>
See also ", 
			"srcLength": "70"
		}, 
		"102: pageTitle": {
			"srcIndexStart": "7339", 
			"data": "AmbiguousSym", 
			"srcLength": "26", 
			"0: data": {
				"srcIndexStart": "7351", 
				"data": "AmbiguousSym", 
				"srcLength": "12"
			}
		}, 
		"103: data": {
			"srcIndexStart": "7365", 
			"data": ".
</p>

<a name=\"ExLoading\" />
<h2>Examples</h2>
<p>
The following examples use the
", 
			"srcLength": "84"
		}, 
		"104: link": {
			"srcIndexStart": "7449", 
			"param 0": "https://bitbucket.org/Abscissa/goldie/src/v0.8/lang/calc.grm", 
			"data": "calc", 
			"srcLength": "78", 
			"0: data": {
				"srcIndexStart": "7519", 
				"data": "calc", 
				"srcLength": "6"
			}
		}, 
		"105: data": {
			"srcIndexStart": "7527", 
			"data": "
grammar.
</p>

<h2>Example: Loading a Language</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "97"
		}, 
		"106: code": {
			"srcIndexStart": "7624", 
			"param 0": "highlight", 
			"data": "<span class=\"code-comment\">// Run \"goldie-staticlang calc.cgt --pack:myapp.mylangs\" at the command-line</span>
import goldie.all;
import myapp.mylangs.calc.all;
<span class=\"code-comment\">// Use 'language_calc'</span>", 
			"srcLength": "174", 
			"0: data": {
				"srcIndexStart": "7641", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "7642", 
				"data": "// Run \"goldie-staticlang calc.cgt --pack:myapp.mylangs\" at the command-line
import goldie.all;
import myapp.mylangs.calc.all;
// Use 'language_calc'", 
				"srcLength": "153"
			}, 
			"2: data": {
				"srcIndexStart": "7795", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"107: data": {
			"srcIndexStart": "7798", 
			"data": "
</div>


<h3>Dynamic-style</h3>
<div class=\"api-def\">
<p>Do the same as static-style, or:</p>
", 
			"srcLength": "95"
		}, 
		"108: code": {
			"srcIndexStart": "7893", 
			"param 0": "highlight", 
			"data": "import goldie.all;
Language language_calc = Language.loadCGT(\"calc.cgt\");
<span class=\"code-comment\">// Use 'language_calc'</span>", 
			"srcLength": "121", 
			"0: data": {
				"srcIndexStart": "7910", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "7911", 
				"data": "import goldie.all;
Language language_calc = Language.loadCGT(\"calc.cgt\");
// Use 'language_calc'", 
				"srcLength": "100"
			}, 
			"2: data": {
				"srcIndexStart": "8011", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"109: data": {
			"srcIndexStart": "8014", 
			"data": "
<p>Or (slower) compile a grammar at runtime:</p>
", 
			"srcLength": "50"
		}, 
		"110: code": {
			"srcIndexStart": "8064", 
			"param 0": "highlight", 
			"data": "import goldie.all;
Language language_calcA = Language.compileGrammar(`...actual grammar here...`);
<span class=\"code-comment\">// -or-</span>
Language language_calcB = Language.compileGrammarFile(\"calc.grm\");
<span class=\"code-comment\">// Use 'language_calcA' or 'language_calcB'</span>", 
			"srcLength": "242", 
			"0: data": {
				"srcIndexStart": "8081", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "8082", 
				"data": "import goldie.all;
Language language_calcA = Language.compileGrammar(`...actual grammar here...`);
// -or-
Language language_calcB = Language.compileGrammarFile(\"calc.grm\");
// Use 'language_calcA' or 'language_calcB'", 
				"srcLength": "221"
			}, 
			"2: data": {
				"srcIndexStart": "8303", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"111: data": {
			"srcIndexStart": "8306", 
			"data": "
</div>


<h2>Example: Parsing a source</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "89"
		}, 
		"112: code": {
			"srcIndexStart": "8395", 
			"param 0": "highlight", 
			"data": "string src = ...;
Token_calc!\"&lt;Add Exp&gt;\" rootToken = language_calc.parseCode(src).parseTree;", 
			"srcLength": "117", 
			"0: data": {
				"srcIndexStart": "8412", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "8413", 
				"data": "string src = ...;
Token_calc!\"<Add Exp>\" rootToken = language_calc.parseCode(src).parseTree;", 
				"srcLength": "96"
			}, 
			"2: data": {
				"srcIndexStart": "8509", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"113: data": {
			"srcIndexStart": "8512", 
			"data": "
<p>
See ", 
			"srcLength": "9"
		}, 
		"114: typeName": {
			"srcIndexStart": "8521", 
			"data": "Token_{languageName}!{symbol}", 
			"srcLength": "42", 
			"0: data": {
				"srcIndexStart": "8532", 
				"data": "Token_{languageName}!{symbol}", 
				"srcLength": "29"
			}
		}, 
		"115: data": {
			"srcIndexStart": "8563", 
			"data": " for details.
</p>
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "72"
		}, 
		"116: code": {
			"srcIndexStart": "8635", 
			"param 0": "highlight", 
			"data": "string src = ...;
Token rootToken = language_calc.parseCodeX(src).parseTreeX;", 
			"srcLength": "102", 
			"0: data": {
				"srcIndexStart": "8652", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "8653", 
				"data": "string src = ...;
Token rootToken = language_calc.parseCodeX(src).parseTreeX;", 
				"srcLength": "81"
			}, 
			"2: data": {
				"srcIndexStart": "8734", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"117: data": {
			"srcIndexStart": "8737", 
			"data": "
</div>
<h4 style=\"margin-bottom: 0px;\">See also:</h4>
<ul>
	<li>", 
			"srcLength": "65"
		}, 
		"118: typeName": {
			"srcIndexStart": "8802", 
			"data": "Language_{languageName}", 
			"srcLength": "36", 
			"0: data": {
				"srcIndexStart": "8813", 
				"data": "Language_{languageName}", 
				"srcLength": "23"
			}
		}, 
		"119: data": {
			"srcIndexStart": "8838", 
			"data": ".", 
			"srcLength": "1"
		}, 
		"120: pageLink": {
			"srcIndexStart": "8839", 
			"param 0": "Language#Language_parseCode", 
			"data": "parseCode", 
			"srcLength": "52", 
			"0: data": {
				"srcIndexStart": "8879", 
				"data": "parseCode", 
				"srcLength": "10"
			}
		}, 
		"121: data": {
			"srcIndexStart": "8891", 
			"data": "</li>
	<li>", 
			"srcLength": "11"
		}, 
		"122: typeName": {
			"srcIndexStart": "8902", 
			"data": "Language_{languageName}", 
			"srcLength": "36", 
			"0: data": {
				"srcIndexStart": "8913", 
				"data": "Language_{languageName}", 
				"srcLength": "23"
			}
		}, 
		"123: data": {
			"srcIndexStart": "8938", 
			"data": ".", 
			"srcLength": "1"
		}, 
		"124: pageLink": {
			"srcIndexStart": "8939", 
			"param 0": "Language#Language_parseFile", 
			"data": "parseFile", 
			"srcLength": "52", 
			"0: data": {
				"srcIndexStart": "8979", 
				"data": "parseFile", 
				"srcLength": "10"
			}
		}, 
		"125: data": {
			"srcIndexStart": "8991", 
			"data": "</li>
	<li>", 
			"srcLength": "11"
		}, 
		"126: typeName": {
			"srcIndexStart": "9002", 
			"data": "Language", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "9013", 
				"data": "Language", 
				"srcLength": "8"
			}
		}, 
		"127: data": {
			"srcIndexStart": "9023", 
			"data": ".", 
			"srcLength": "1"
		}, 
		"128: pageLink": {
			"srcIndexStart": "9024", 
			"param 0": "Language#Language_parseCodeX", 
			"data": "parseCodeX", 
			"srcLength": "54", 
			"0: data": {
				"srcIndexStart": "9065", 
				"data": "parseCodeX", 
				"srcLength": "11"
			}
		}, 
		"129: data": {
			"srcIndexStart": "9078", 
			"data": "</li>
	<li>", 
			"srcLength": "11"
		}, 
		"130: typeName": {
			"srcIndexStart": "9089", 
			"data": "Language", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "9100", 
				"data": "Language", 
				"srcLength": "8"
			}
		}, 
		"131: data": {
			"srcIndexStart": "9110", 
			"data": ".", 
			"srcLength": "1"
		}, 
		"132: pageLink": {
			"srcIndexStart": "9111", 
			"param 0": "Language#Language_parseFileX", 
			"data": "parseFileX", 
			"srcLength": "54", 
			"0: data": {
				"srcIndexStart": "9152", 
				"data": "parseFileX", 
				"srcLength": "11"
			}
		}, 
		"133: data": {
			"srcIndexStart": "9165", 
			"data": "</li>
</ul>


<a name=\"ExCheckSymbol\" />
<h2>Example: Checking a token's symbol</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "129"
		}, 
		"134: code": {
			"srcIndexStart": "9294", 
			"param 0": "highlight", 
			"data": "<span class=\"code-comment\">// Check static/compile-time type (ie, not polymorphic)</span>
bool isAddExp(Token_calc!\"&lt;Add Exp&gt;\" tok)
{
    return true;
}
bool isAddExp(Token tok)
{
    return false;
}

<span class=\"code-comment\">// Check run-time type (ie, polymorphic)</span>
bool isAddExp(Token_calc tok)
{
    return cast(Token_calc!\"&lt;Add Exp&gt;\")tok is null;
    
    <span class=\"code-comment\">// Or to disambiguate (See the \"Ambiguous Symbols\" page):</span>
    return cast(Token_calc!(SymbolType.NonTerminal, \"&lt;Add Exp&gt;\"))tok is null;
}", 
			"srcLength": "445", 
			"0: data": {
				"srcIndexStart": "9311", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "9312", 
				"data": "// Check static/compile-time type (ie, not polymorphic)
bool isAddExp(Token_calc!\"<Add Exp>\" tok)
{
	return true;
}
bool isAddExp(Token tok)
{
	return false;
}

// Check run-time type (ie, polymorphic)
bool isAddExp(Token_calc tok)
{
	return cast(Token_calc!\"<Add Exp>\")tok is null;
	
	// Or to disambiguate (See the \"Ambiguous Symbols\" page):
	return cast(Token_calc!(SymbolType.NonTerminal, \"<Add Exp>\"))tok is null;
}", 
				"srcLength": "424"
			}, 
			"2: data": {
				"srcIndexStart": "9736", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"135: data": {
			"srcIndexStart": "9739", 
			"data": "
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "54"
		}, 
		"136: code": {
			"srcIndexStart": "9793", 
			"param 0": "highlight", 
			"data": "bool isAddExp(Token tok)
{
    return tok.name == \"&lt;Add Exp&gt;\";
    
    <span class=\"code-comment\">// Or to disambiguate (See the \"Ambiguous Symbols\" page):</span>
    return tok.name == \"&lt;Add Exp&gt;\" &amp;&amp; tok.type == SymbolType.NonTerminal;
}", 
			"srcLength": "218", 
			"0: data": {
				"srcIndexStart": "9810", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "9811", 
				"data": "bool isAddExp(Token tok)
{
	return tok.name == \"<Add Exp>\";
	
	// Or to disambiguate (See the \"Ambiguous Symbols\" page):
	return tok.name == \"<Add Exp>\" && tok.type == SymbolType.NonTerminal;
}", 
				"srcLength": "197"
			}, 
			"2: data": {
				"srcIndexStart": "10008", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"137: data": {
			"srcIndexStart": "10011", 
			"data": "
</div>


<a name=\"ExCheckRule\" />
<h2>Example: Checking a token's rule and retrieving a sub-token</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "148"
		}, 
		"138: code": {
			"srcIndexStart": "10159", 
			"param 0": "highlight", 
			"data": "Token_calc!\"&lt;Mult Exp&gt;\" getMultExp(Token_calc!\"&lt;Add Exp&gt;\" tok)
{
    <span class=\"code-comment\">// This represents the rule: &lt;Add Exp&gt; ::= &lt;Add Exp&gt; '+' &lt;Mult Exp&gt;</span>
    if( auto t = cast(Token_calc!(\"&lt;Add Exp&gt;\", \"&lt;Add Exp&gt;\", \"+\", \"&lt;Mult Exp&gt;\"))tok )
    {
        return t.sub!2;
    }
}", 
			"srcLength": "266", 
			"0: data": {
				"srcIndexStart": "10176", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "10177", 
				"data": "Token_calc!\"<Mult Exp>\" getMultExp(Token_calc!\"<Add Exp>\" tok)
{
	// This represents the rule: <Add Exp> ::= <Add Exp> '+' <Mult Exp>
	if( auto t = cast(Token_calc!(\"<Add Exp>\", \"<Add Exp>\", \"+\", \"<Mult Exp>\"))tok )
	{
		return t.sub!2;
	}
}", 
				"srcLength": "245"
			}, 
			"2: data": {
				"srcIndexStart": "10422", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"139: data": {
			"srcIndexStart": "10425", 
			"data": "
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "54"
		}, 
		"140: code": {
			"srcIndexStart": "10479", 
			"param 0": "highlight", 
			"data": "Token getMultExp(Token tok)
{
    <span class=\"code-comment\">// This represents the rule: &lt;Add Exp&gt; ::= &lt;Add Exp&gt; '+' &lt;Mult Exp&gt;</span>
    if( tok.matches(\"&lt;Add Exp&gt;\", \"&lt;Add Exp&gt;\", \"+\", \"&lt;Mult Exp&gt;\") )
    {
        return tok[2];
    }
}", 
			"srcLength": "212", 
			"0: data": {
				"srcIndexStart": "10496", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "10497", 
				"data": "Token getMultExp(Token tok)
{
	// This represents the rule: <Add Exp> ::= <Add Exp> '+' <Mult Exp>
	if( tok.matches(\"<Add Exp>\", \"<Add Exp>\", \"+\", \"<Mult Exp>\") )
	{
		return tok[2];
	}
}", 
				"srcLength": "191"
			}, 
			"2: data": {
				"srcIndexStart": "10688", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"141: data": {
			"srcIndexStart": "10691", 
			"data": "
</div>


<a name=\"ExDescendant\" />
<h2>Example: Finding a descendant token</h2>
<h3>Static-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "125"
		}, 
		"142: code": {
			"srcIndexStart": "10816", 
			"param 0": "highlight", 
			"data": "alias Token_calc Tok; <span class=\"code-comment\">// For convenience</span>

<span class=\"code-comment\">// Returns:</span>
<span class=\"code-comment\">//   this</span>
<span class=\"code-comment\">//     .sub!(/+ the first &lt;Mult Exp&gt; +/)</span>
<span class=\"code-comment\">//     .sub!(/+ the first &lt;Negate Exp&gt; +/)</span>
<span class=\"code-comment\">//     .sub!(/+ the first &lt;Value&gt; that was created from &lt;Value&gt; ::= Number +/);</span>
<span class=\"code-comment\">//</span> 
<span class=\"code-comment\">// If not found, returns null</span>
Tok!(\"&lt;Value&gt;\",\"Number\") foo(Token tok)
{
    return tok.get!( Tok!\"&lt;Mult Exp&gt;\", Tok!\"&lt;Negate Exp&gt;\", Tok!(\"&lt;Value&gt;\",\"Number\") )();
}", 
			"srcLength": "416", 
			"0: data": {
				"srcIndexStart": "10833", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "10834", 
				"data": "alias Token_calc Tok; // For convenience

// Returns:
//   this
//     .sub!(/+ the first <Mult Exp> +/)
//     .sub!(/+ the first <Negate Exp> +/)
//     .sub!(/+ the first <Value> that was created from <Value> ::= Number +/);
// 
// If not found, returns null
Tok!(\"<Value>\",\"Number\") foo(Token tok)
{
	return tok.get!( Tok!\"<Mult Exp>\", Tok!\"<Negate Exp>\", Tok!(\"<Value>\",\"Number\") )();
}", 
				"srcLength": "395"
			}, 
			"2: data": {
				"srcIndexStart": "11229", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"143: data": {
			"srcIndexStart": "11232", 
			"data": "
</div>

<h3>Dynamic-style</h3>
<div class=\"api-def\">
", 
			"srcLength": "54"
		}, 
		"144: code": {
			"srcIndexStart": "11286", 
			"param 0": "highlight", 
			"data": "<span class=\"code-comment\">// Returns:</span>
<span class=\"code-comment\">//   this</span>
<span class=\"code-comment\">//     [/+ the first &lt;Mult Exp&gt; +/]</span>
<span class=\"code-comment\">//     [/+ the first &lt;Negate Exp&gt; +/]</span>
<span class=\"code-comment\">//     [/+ the first &lt;Value&gt; that was created from &lt;Value&gt; ::= Number +/];</span>
<span class=\"code-comment\">//</span> 
<span class=\"code-comment\">// If not found, returns null</span>

Token foo(Token tok)
{
    auto t = tok.get( [\"&lt;Mult Exp&gt;\", \"&lt;Negate Exp&gt;\", \"&lt;Value&gt;\"] );

    if(t &amp;&amp; t.matches(\"&lt;Value&gt;\", \"Number\"))
        return t;

    return null;
}", 
			"srcLength": "388", 
			"0: data": {
				"srcIndexStart": "11303", 
				"data": "", 
				"srcLength": "1"
			}, 
			"1: data": {
				"srcIndexStart": "11304", 
				"data": "// Returns:
//   this
//     [/+ the first <Mult Exp> +/]
//     [/+ the first <Negate Exp> +/]
//     [/+ the first <Value> that was created from <Value> ::= Number +/];
// 
// If not found, returns null

Token foo(Token tok)
{
	auto t = tok.get( [\"<Mult Exp>\", \"<Negate Exp>\", \"<Value>\"] );

	if(t && t.matches(\"<Value>\", \"Number\"))
		return t;

	return null;
}", 
				"srcLength": "367"
			}, 
			"2: data": {
				"srcIndexStart": "11671", 
				"data": "", 
				"srcLength": "1"
			}
		}, 
		"145: data": {
			"srcIndexStart": "11674", 
			"data": "
</div>
<h4 style=\"margin-bottom: 0px;\">See also:</h4>
<ul>
	<li>", 
			"srcLength": "65"
		}, 
		"146: typeName": {
			"srcIndexStart": "11739", 
			"data": "Token", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "11750", 
				"data": "Token", 
				"srcLength": "5"
			}
		}, 
		"147: data": {
			"srcIndexStart": "11757", 
			"data": ".", 
			"srcLength": "1"
		}, 
		"148: pageLink": {
			"srcIndexStart": "11758", 
			"param 0": "Token#Token_get", 
			"data": "get", 
			"srcLength": "32", 
			"0: data": {
				"srcIndexStart": "11785", 
				"data": "get", 
				"srcLength": "3"
			}
		}, 
		"149: data": {
			"srcIndexStart": "11790", 
			"data": "</li>
	<li>", 
			"srcLength": "11"
		}, 
		"150: typeName": {
			"srcIndexStart": "11801", 
			"data": "Token", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "11812", 
				"data": "Token", 
				"srcLength": "5"
			}
		}, 
		"151: data": {
			"srcIndexStart": "11819", 
			"data": ".", 
			"srcLength": "1"
		}, 
		"152: pageLink": {
			"srcIndexStart": "11820", 
			"param 0": "Token#Token_getRequired", 
			"data": "getRequired", 
			"srcLength": "48", 
			"0: data": {
				"srcIndexStart": "11855", 
				"data": "getRequired", 
				"srcLength": "11"
			}
		}, 
		"153: data": {
			"srcIndexStart": "11868", 
			"data": "</li>
</ul>

<a name=\"ExTraverse\" />
<h2>Example: Traverse each node in a parse tree, with optional filtering</h2>
<div class=\"api-def\">
	See documentation of ", 
			"srcLength": "159"
		}, 
		"154: pageLink": {
			"srcIndexStart": "12027", 
			"param 0": "Token#traverse", 
			"data": "traverse", 
			"srcLength": "36", 
			"0: data": {
				"srcIndexStart": "12053", 
				"data": "traverse", 
				"srcLength": "8"
			}
		}, 
		"155: data": {
			"srcIndexStart": "12063", 
			"data": " for examples.
</div>

<h2>More Examples</h2>
<p>
For a full-program example of static-style versus dynamic-style, see
", 
			"srcLength": "119"
		}, 
		"156: pageTitle": {
			"srcIndexStart": "12182", 
			"data": "CalculatorStatic", 
			"srcLength": "30", 
			"0: data": {
				"srcIndexStart": "12194", 
				"data": "CalculatorStatic", 
				"srcLength": "16"
			}
		}, 
		"157: data": {
			"srcIndexStart": "12212", 
			"data": " and ", 
			"srcLength": "5"
		}, 
		"158: pageTitle": {
			"srcIndexStart": "12217", 
			"data": "CalculatorDynamic", 
			"srcLength": "31", 
			"0: data": {
				"srcIndexStart": "12229", 
				"data": "CalculatorDynamic", 
				"srcLength": "17"
			}
		}, 
		"159: data": {
			"srcIndexStart": "12248", 
			"data": ".
</p>", 
			"srcLength": "7"
		}
	}
}