{
	"0: data": {
		"srcIndexStart": "0", 
		"file": "docssrc/docs.Start.Overview.tmpl", 
		"parseTreeMode": "true", 
		"srcLength": "5255", 
		"source": "[$name|Overview$]
[$title|Goldie Overview$]
[$frame|HTMLPage.tmpl$]

<p>
The process for using Goldie is just like
[$link| http://goldparser.org/about/how-it-works.htm | the process for GOLD Parser Builder $]:
</p>

<a name=\"Grammar\" />
<h2>1. Write a grammar in the .grm language</h2>
<div class=\"api-def\">
<p>
Here is a simple example of a grammar definition:
</p>
[$code|plain|
[:! This grammar defines a simple language consisting of
! positive integers separated by a plus sign.

\"Start Symbol\" = <List>

Number = {Digit}+

<List> ::= <List> '+' Number
         | Number:]
$]
<p>
One of the nice things about the GOLD/Goldie systems, unlike most other parsing systems,
is that there's no code embedded in the grammars, so grammars are write-once-and-reuse.
In other words, if you write a grammar to use in one tool, you can reuse the exact same
grammar for any other tool - even if the two tools are written in completely
different languages!
</p>
<p>
More information about the grammar description language used by GOLD and Goldie,
including links to premade grammars, can be found on this page:
[$pageTitle|Grammar$]
</p>
</div>

<a name=\"Compile\" />
<h2>2. Compile the grammar to .cgt format</h2>
<div class=\"api-def\">
<p>
Goldie uses the
[$link|http://goldparser.org/articles/lalr.htm| LALR(1) $]
and
[$link|http://goldparser.org/articles/dfa.htm| DFA $]
algorithms to parse source. Both of these algorithms can be driven completely
by tables of raw data, so Goldie requires grammars be compiled into
these tables before they can be used. This provides certain benefits:
</p>
<ul>
<li>
	The grammar definition itself can be parsed ahead of time, instead of on-the-fly.
	(Although, this is typical of just about any parsing system.)
</li>
<li>
	Grammars can be checked for errors before they're used.
	(This is also typical.)
</li>
<li>
	The code to parse a source can be written once and reused for any grammar,
	even without automatically-generating any code.
	This is very rare among parsing systems.
	<!-- Goldie already provides this (and other features) to D2 users via the included
	[$pageLink|APIOver|GoldieLib$]. -->
</li>
</ul>
<p>
That last benefit is very powerful as it allows programs to be written that operate
on user-created grammars without compiling any software or using DLL-based plug-in systems.
Goldie's [$pageTitle|Parse$] tool and [$pageTitle|SampleGenericParse$] sample make
use of this ability.
</p>
<p>
Of course, this doesn't prevent automatically generating source code for a
parser as other tools such as ANTLR do. In fact, GOLD has a full
template system that does exactly that. Goldie doesn't actually make any use of
it, but GoldieLib does offer a [$pageLink|StatVsDyn|static-style$]
which fills a similar role for
[$link| http://www.d-programming-language.org/ | D v2.x $] users.
</p>
<h3>How to compile a grammar</h3>
<p>Grammar files can be compiled in a number of ways:</p>
<ul class=\"info-list\">
<li>
	<h4>Goldie's [$pageTitle|GRMC$]</h4>
	<div class=\"info-list-info\">
	A cross-platform command-line tool.<br />
	<br />
<div class=\"code-plain\" style=\"padding-left: 5px\">&gt;[$code|user|goldie-grmc grammar.grm$]
Or:
&gt;[$code|user|goldie-grmc grammar.grm -o:output.cgt$]</div>
	</div>
</li>
<li>
	<h4>[$pageLink|OtherTools#GOLD|GOLD Parser Builder$]</h4>
	<div class=\"info-list-info\">
	A .NET-based tool in GUI and command-line versions.
	</div>
</li>
<li>
	<h4>GoldieLib's [$typeName|Language$][$ident|.compileGrammar*$] functions</h4>
	<div class=\"info-list-info\">
	A [$link| http://www.d-programming-language.org/ | D v2.x $]
	API interface.
	This can be useful for building general language-processing tools.
	In fact, this is what [$pageTitle|GRMC$] uses.<br />
	<br />
[$code|highlight|
[:string grammar1 = \"!* grammar definition here *!\";
Language lang1 = Language.compileGrammar(grammar1);

// Or:
Language lang2 = Language.compileGrammarFile(\"grammar2.grm\");

// Optionally save:
lang1.save(\"grammar1.cgt\");
lang2.save(\"grammar2.cgt\");:]
$]
	</div>
</li>
</ul>
</div>

<a name=\"Engine\" />
<h2>3. Use a GOLD engine to load the compiled grammar and parse a source</h2>
<div class=\"api-def\">
<p>
Any [$pageLink|OtherTools#GOLD|GOLD$]-compatible engine can be used to load the
compiled grammar and parse a source. Such engines are
[$pageLink|OtherTools#EngineLinks| available for a wide variety of languages $],
since they're
[$link|http://goldparser.org/doc/engine-pseudo/index.htm| fairly easy to make $].
Goldie includes [$pageLink|APIOver|GoldieLib$] which serves as just such
an engine for [$link| http://www.d-programming-language.org/ | D v2.x $].
</p>
<p>
Each engine is used differently, and their features and APIs can vary greatly.
To start learning how to use the GoldieLib engine, see the following:
</p>
<ul>
<li>[$pageTitle|Tutorial$]</li>
<li>[$pageTitle|SampleApps$]</li>
<li>[$pageTitle|StatVsDyn$]</li>
<li>[$pageTitle|APIOver$]</li>
<li>[$pageTitle|APIRef$]</li>
</ul>
<p>
Additionally, see the [$pageTitle|Tools$] page for various
tools that may be helpful when using Goldie.
</p>
<em>Next:</em> [$pageTitle|Tutorial$]
</div>
", 
		"0: name": {
			"srcIndexStart": "0", 
			"data": "Overview", 
			"srcLength": "17", 
			"0: data": {
				"srcIndexStart": "7", 
				"data": "Overview", 
				"srcLength": "8"
			}
		}, 
		"1: data": {
			"srcIndexStart": "17", 
			"data": "
", 
			"srcLength": "2"
		}, 
		"2: title": {
			"srcIndexStart": "19", 
			"data": "Goldie Overview", 
			"srcLength": "25", 
			"0: data": {
				"srcIndexStart": "27", 
				"data": "Goldie Overview", 
				"srcLength": "15"
			}
		}, 
		"3: data": {
			"srcIndexStart": "44", 
			"data": "
", 
			"srcLength": "2"
		}, 
		"4: frame": {
			"srcIndexStart": "46", 
			"data": "HTMLPage.tmpl", 
			"srcLength": "23", 
			"0: data": {
				"srcIndexStart": "54", 
				"data": "HTMLPage.tmpl", 
				"srcLength": "13"
			}
		}, 
		"5: data": {
			"srcIndexStart": "69", 
			"data": "

<p>
The process for using Goldie is just like
", 
			"srcLength": "52"
		}, 
		"6: link": {
			"srcIndexStart": "121", 
			"param 0": "http://goldparser.org/about/how-it-works.htm", 
			"data": "the process for GOLD Parser Builder", 
			"srcLength": "93", 
			"0: data": {
				"srcIndexStart": "175", 
				"data": "the process for GOLD Parser Builder", 
				"srcLength": "37"
			}
		}, 
		"7: data": {
			"srcIndexStart": "214", 
			"data": ":
</p>

<a name=\"Grammar\" />
<h2>1. Write a grammar in the .grm language</h2>
<div class=\"api-def\">
<p>
Here is a simple example of a grammar definition:
</p>
", 
			"srcLength": "168"
		}, 
		"8: code": {
			"srcIndexStart": "382", 
			"param 0": "plain", 
			"data": "! This grammar defines a simple language consisting of
! positive integers separated by a plus sign.

\"Start Symbol\" = &lt;List&gt;

Number = {Digit}+

&lt;List&gt; ::= &lt;List&gt; '+' Number
         | Number", 
			"srcLength": "223", 
			"0: data": {
				"srcIndexStart": "395", 
				"data": "", 
				"srcLength": "2"
			}, 
			"1: data": {
				"srcIndexStart": "397", 
				"data": "! This grammar defines a simple language consisting of
! positive integers separated by a plus sign.

\"Start Symbol\" = <List>

Number = {Digit}+

<List> ::= <List> '+' Number
         | Number", 
				"srcLength": "204"
			}, 
			"2: data": {
				"srcIndexStart": "601", 
				"data": "", 
				"srcLength": "2"
			}
		}, 
		"9: data": {
			"srcIndexStart": "605", 
			"data": "
<p>
One of the nice things about the GOLD/Goldie systems, unlike most other parsing systems,
is that there's no code embedded in the grammars, so grammars are write-once-and-reuse.
In other words, if you write a grammar to use in one tool, you can reuse the exact same
grammar for any other tool - even if the two tools are written in completely
different languages!
</p>
<p>
More information about the grammar description language used by GOLD and Goldie,
including links to premade grammars, can be found on this page:
", 
			"srcLength": "533"
		}, 
		"10: pageTitle": {
			"srcIndexStart": "1138", 
			"data": "Grammar", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "1150", 
				"data": "Grammar", 
				"srcLength": "7"
			}
		}, 
		"11: data": {
			"srcIndexStart": "1159", 
			"data": "
</p>
</div>

<a name=\"Compile\" />
<h2>2. Compile the grammar to .cgt format</h2>
<div class=\"api-def\">
<p>
Goldie uses the
", 
			"srcLength": "133"
		}, 
		"12: link": {
			"srcIndexStart": "1292", 
			"param 0": "http://goldparser.org/articles/lalr.htm", 
			"data": "LALR(1)", 
			"srcLength": "58", 
			"0: data": {
				"srcIndexStart": "1339", 
				"data": "LALR(1)", 
				"srcLength": "9"
			}
		}, 
		"13: data": {
			"srcIndexStart": "1350", 
			"data": "
and
", 
			"srcLength": "7"
		}, 
		"14: link": {
			"srcIndexStart": "1357", 
			"param 0": "http://goldparser.org/articles/dfa.htm", 
			"data": "DFA", 
			"srcLength": "53", 
			"0: data": {
				"srcIndexStart": "1403", 
				"data": "DFA", 
				"srcLength": "5"
			}
		}, 
		"15: data": {
			"srcIndexStart": "1410", 
			"data": "
algorithms to parse source. Both of these algorithms can be driven completely
by tables of raw data, so Goldie requires grammars be compiled into
these tables before they can be used. This provides certain benefits:
</p>
<ul>
<li>
	The grammar definition itself can be parsed ahead of time, instead of on-the-fly.
	(Although, this is typical of just about any parsing system.)
</li>
<li>
	Grammars can be checked for errors before they're used.
	(This is also typical.)
</li>
<li>
	The code to parse a source can be written once and reused for any grammar,
	even without automatically-generating any code.
	This is very rare among parsing systems.
	<!-- Goldie already provides this (and other features) to D2 users via the included
	", 
			"srcLength": "754"
		}, 
		"16: pageLink": {
			"srcIndexStart": "2164", 
			"param 0": "APIOver", 
			"data": "GoldieLib", 
			"srcLength": "30", 
			"0: data": {
				"srcIndexStart": "2183", 
				"data": "GoldieLib", 
				"srcLength": "9"
			}
		}, 
		"17: data": {
			"srcIndexStart": "2194", 
			"data": ". -->
</li>
</ul>
<p>
That last benefit is very powerful as it allows programs to be written that operate
on user-created grammars without compiling any software or using DLL-based plug-in systems.
Goldie's ", 
			"srcLength": "213"
		}, 
		"18: pageTitle": {
			"srcIndexStart": "2407", 
			"data": "Parse", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "2419", 
				"data": "Parse", 
				"srcLength": "5"
			}
		}, 
		"19: data": {
			"srcIndexStart": "2426", 
			"data": " tool and ", 
			"srcLength": "10"
		}, 
		"20: pageTitle": {
			"srcIndexStart": "2436", 
			"data": "SampleGenericParse", 
			"srcLength": "32", 
			"0: data": {
				"srcIndexStart": "2448", 
				"data": "SampleGenericParse", 
				"srcLength": "18"
			}
		}, 
		"21: data": {
			"srcIndexStart": "2468", 
			"data": " sample make
use of this ability.
</p>
<p>
Of course, this doesn't prevent automatically generating source code for a
parser as other tools such as ANTLR do. In fact, GOLD has a full
template system that does exactly that. Goldie doesn't actually make any use of
it, but GoldieLib does offer a ", 
			"srcLength": "301"
		}, 
		"22: pageLink": {
			"srcIndexStart": "2769", 
			"param 0": "StatVsDyn", 
			"data": "static-style", 
			"srcLength": "35", 
			"0: data": {
				"srcIndexStart": "2790", 
				"data": "static-style", 
				"srcLength": "12"
			}
		}, 
		"23: data": {
			"srcIndexStart": "2804", 
			"data": "
which fills a similar role for
", 
			"srcLength": "34"
		}, 
		"24: link": {
			"srcIndexStart": "2838", 
			"param 0": "http://www.d-programming-language.org/", 
			"data": "D v2.x", 
			"srcLength": "58", 
			"0: data": {
				"srcIndexStart": "2886", 
				"data": "D v2.x", 
				"srcLength": "8"
			}
		}, 
		"25: data": {
			"srcIndexStart": "2896", 
			"data": " users.
</p>
<h3>How to compile a grammar</h3>
<p>Grammar files can be compiled in a number of ways:</p>
<ul class=\"info-list\">
<li>
	<h4>Goldie's ", 
			"srcLength": "153"
		}, 
		"26: pageTitle": {
			"srcIndexStart": "3049", 
			"data": "GRMC", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "3061", 
				"data": "GRMC", 
				"srcLength": "4"
			}
		}, 
		"27: data": {
			"srcIndexStart": "3067", 
			"data": "</h4>
	<div class=\"info-list-info\">
	A cross-platform command-line tool.<br />
	<br />
<div class=\"code-plain\" style=\"padding-left: 5px\">&gt;", 
			"srcLength": "145"
		}, 
		"28: code": {
			"srcIndexStart": "3212", 
			"param 0": "user", 
			"data": "goldie-grmc grammar.grm", 
			"srcLength": "37", 
			"0: data": {
				"srcIndexStart": "3224", 
				"data": "goldie-grmc grammar.grm", 
				"srcLength": "23"
			}
		}, 
		"29: data": {
			"srcIndexStart": "3249", 
			"data": "
Or:
&gt;", 
			"srcLength": "11"
		}, 
		"30: code": {
			"srcIndexStart": "3260", 
			"param 0": "user", 
			"data": "goldie-grmc grammar.grm -o:output.cgt", 
			"srcLength": "51", 
			"0: data": {
				"srcIndexStart": "3272", 
				"data": "goldie-grmc grammar.grm -o:output.cgt", 
				"srcLength": "37"
			}
		}, 
		"31: data": {
			"srcIndexStart": "3311", 
			"data": "</div>
	</div>
</li>
<li>
	<h4>", 
			"srcLength": "35"
		}, 
		"32: pageLink": {
			"srcIndexStart": "3346", 
			"param 0": "OtherTools#GOLD", 
			"data": "GOLD Parser Builder", 
			"srcLength": "48", 
			"0: data": {
				"srcIndexStart": "3373", 
				"data": "GOLD Parser Builder", 
				"srcLength": "19"
			}
		}, 
		"33: data": {
			"srcIndexStart": "3394", 
			"data": "</h4>
	<div class=\"info-list-info\">
	A .NET-based tool in GUI and command-line versions.
	</div>
</li>
<li>
	<h4>GoldieLib's ", 
			"srcLength": "131"
		}, 
		"34: typeName": {
			"srcIndexStart": "3525", 
			"data": "Language", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "3536", 
				"data": "Language", 
				"srcLength": "8"
			}
		}, 
		"35: ident": {
			"srcIndexStart": "3546", 
			"data": ".compileGrammar*", 
			"srcLength": "26", 
			"0: data": {
				"srcIndexStart": "3554", 
				"data": ".compileGrammar*", 
				"srcLength": "16"
			}
		}, 
		"36: data": {
			"srcIndexStart": "3572", 
			"data": " functions</h4>
	<div class=\"info-list-info\">
	A ", 
			"srcLength": "51"
		}, 
		"37: link": {
			"srcIndexStart": "3623", 
			"param 0": "http://www.d-programming-language.org/", 
			"data": "D v2.x", 
			"srcLength": "58", 
			"0: data": {
				"srcIndexStart": "3671", 
				"data": "D v2.x", 
				"srcLength": "8"
			}
		}, 
		"38: data": {
			"srcIndexStart": "3681", 
			"data": "
	API interface.
	This can be useful for building general language-processing tools.
	In fact, this is what ", 
			"srcLength": "111"
		}, 
		"39: pageTitle": {
			"srcIndexStart": "3792", 
			"data": "GRMC", 
			"srcLength": "18", 
			"0: data": {
				"srcIndexStart": "3804", 
				"data": "GRMC", 
				"srcLength": "4"
			}
		}, 
		"40: data": {
			"srcIndexStart": "3810", 
			"data": " uses.<br />
	<br />
", 
			"srcLength": "23"
		}, 
		"41: code": {
			"srcIndexStart": "3833", 
			"param 0": "highlight", 
			"data": "string grammar1 = \"!* grammar definition here *!\";
Language lang1 = Language.compileGrammar(grammar1);

<span class=\"code-comment\">// Or:</span>
Language lang2 = Language.compileGrammarFile(\"grammar2.grm\");

<span class=\"code-comment\">// Optionally save:</span>
lang1.save(\"grammar1.cgt\");
lang2.save(\"grammar2.cgt\");", 
			"srcLength": "284", 
			"0: data": {
				"srcIndexStart": "3850", 
				"data": "", 
				"srcLength": "2"
			}, 
			"1: data": {
				"srcIndexStart": "3852", 
				"data": "string grammar1 = \"!* grammar definition here *!\";
Language lang1 = Language.compileGrammar(grammar1);

// Or:
Language lang2 = Language.compileGrammarFile(\"grammar2.grm\");

// Optionally save:
lang1.save(\"grammar1.cgt\");
lang2.save(\"grammar2.cgt\");", 
				"srcLength": "261"
			}, 
			"2: data": {
				"srcIndexStart": "4113", 
				"data": "", 
				"srcLength": "2"
			}
		}, 
		"42: data": {
			"srcIndexStart": "4117", 
			"data": "
	</div>
</li>
</ul>
</div>

<a name=\"Engine\" />
<h2>3. Use a GOLD engine to load the compiled grammar and parse a source</h2>
<div class=\"api-def\">
<p>
Any ", 
			"srcLength": "167"
		}, 
		"43: pageLink": {
			"srcIndexStart": "4284", 
			"param 0": "OtherTools#GOLD", 
			"data": "GOLD", 
			"srcLength": "33", 
			"0: data": {
				"srcIndexStart": "4311", 
				"data": "GOLD", 
				"srcLength": "4"
			}
		}, 
		"44: data": {
			"srcIndexStart": "4317", 
			"data": "-compatible engine can be used to load the
compiled grammar and parse a source. Such engines are
", 
			"srcLength": "99"
		}, 
		"45: pageLink": {
			"srcIndexStart": "4416", 
			"param 0": "OtherTools#EngineLinks", 
			"data": "available for a wide variety of languages", 
			"srcLength": "79", 
			"0: data": {
				"srcIndexStart": "4450", 
				"data": "available for a wide variety of languages", 
				"srcLength": "43"
			}
		}, 
		"46: data": {
			"srcIndexStart": "4495", 
			"data": ",
since they're
", 
			"srcLength": "18"
		}, 
		"47: link": {
			"srcIndexStart": "4513", 
			"param 0": "http://goldparser.org/doc/engine-pseudo/index.htm", 
			"data": "fairly easy to make", 
			"srcLength": "80", 
			"0: data": {
				"srcIndexStart": "4570", 
				"data": "fairly easy to make", 
				"srcLength": "21"
			}
		}, 
		"48: data": {
			"srcIndexStart": "4593", 
			"data": ".
Goldie includes ", 
			"srcLength": "19"
		}, 
		"49: pageLink": {
			"srcIndexStart": "4612", 
			"param 0": "APIOver", 
			"data": "GoldieLib", 
			"srcLength": "30", 
			"0: data": {
				"srcIndexStart": "4631", 
				"data": "GoldieLib", 
				"srcLength": "9"
			}
		}, 
		"50: data": {
			"srcIndexStart": "4642", 
			"data": " which serves as just such
an engine for ", 
			"srcLength": "42"
		}, 
		"51: link": {
			"srcIndexStart": "4684", 
			"param 0": "http://www.d-programming-language.org/", 
			"data": "D v2.x", 
			"srcLength": "58", 
			"0: data": {
				"srcIndexStart": "4732", 
				"data": "D v2.x", 
				"srcLength": "8"
			}
		}, 
		"52: data": {
			"srcIndexStart": "4742", 
			"data": ".
</p>
<p>
Each engine is used differently, and their features and APIs can vary greatly.
To start learning how to use the GoldieLib engine, see the following:
</p>
<ul>
<li>", 
			"srcLength": "181"
		}, 
		"53: pageTitle": {
			"srcIndexStart": "4923", 
			"data": "Tutorial", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "4935", 
				"data": "Tutorial", 
				"srcLength": "8"
			}
		}, 
		"54: data": {
			"srcIndexStart": "4945", 
			"data": "</li>
<li>", 
			"srcLength": "11"
		}, 
		"55: pageTitle": {
			"srcIndexStart": "4956", 
			"data": "SampleApps", 
			"srcLength": "24", 
			"0: data": {
				"srcIndexStart": "4968", 
				"data": "SampleApps", 
				"srcLength": "10"
			}
		}, 
		"56: data": {
			"srcIndexStart": "4980", 
			"data": "</li>
<li>", 
			"srcLength": "11"
		}, 
		"57: pageTitle": {
			"srcIndexStart": "4991", 
			"data": "StatVsDyn", 
			"srcLength": "23", 
			"0: data": {
				"srcIndexStart": "5003", 
				"data": "StatVsDyn", 
				"srcLength": "9"
			}
		}, 
		"58: data": {
			"srcIndexStart": "5014", 
			"data": "</li>
<li>", 
			"srcLength": "11"
		}, 
		"59: pageTitle": {
			"srcIndexStart": "5025", 
			"data": "APIOver", 
			"srcLength": "21", 
			"0: data": {
				"srcIndexStart": "5037", 
				"data": "APIOver", 
				"srcLength": "7"
			}
		}, 
		"60: data": {
			"srcIndexStart": "5046", 
			"data": "</li>
<li>", 
			"srcLength": "11"
		}, 
		"61: pageTitle": {
			"srcIndexStart": "5057", 
			"data": "APIRef", 
			"srcLength": "20", 
			"0: data": {
				"srcIndexStart": "5069", 
				"data": "APIRef", 
				"srcLength": "6"
			}
		}, 
		"62: data": {
			"srcIndexStart": "5077", 
			"data": "</li>
</ul>
<p>
Additionally, see the ", 
			"srcLength": "41"
		}, 
		"63: pageTitle": {
			"srcIndexStart": "5118", 
			"data": "Tools", 
			"srcLength": "19", 
			"0: data": {
				"srcIndexStart": "5130", 
				"data": "Tools", 
				"srcLength": "5"
			}
		}, 
		"64: data": {
			"srcIndexStart": "5137", 
			"data": " page for various
tools that may be helpful when using Goldie.
</p>
<em>Next:</em> ", 
			"srcLength": "86"
		}, 
		"65: pageTitle": {
			"srcIndexStart": "5223", 
			"data": "Tutorial", 
			"srcLength": "22", 
			"0: data": {
				"srcIndexStart": "5235", 
				"data": "Tutorial", 
				"srcLength": "8"
			}
		}, 
		"66: data": {
			"srcIndexStart": "5245", 
			"data": "
</div>", 
			"srcLength": "10"
		}
	}
}