Parsing System (v0.9)
Goldie Home (v0.9) -> Goldie's Tools -> GRMC: Grammar Compiler

GRMC: Grammar Compiler

Compiles a grammar definition file to a CGT file (Compiled Grammar Table). This tool can be used instead of GOLD Parser Builder. The resulting .cgt files can be used with either Goldie or any other GOLD Engine.

Note that there are a few GOLD Parser Builder features that Goldie Grammar Compiler does not yet support:

Be aware that although some grammars can be compiled in under a second, others can take several minutes to be compiled into a CGT. In particular, grammars that use large sets of Unicode characters or require many parsing states tend to take significantly longer than simpler grammars.

Note: GRMC cannot be compiled with DMD 2.057 due to DMD Issue #7375.

Command-line parameters:

Usage: goldie-grmc [options] [grammar file] [options] Example: goldie-grmc grammar.grm goldie-grmc grammar.grm -o=output.cgt Options: --help, /? Displays this help screen -o, --out <filename> Output filename -v, --verbose Verbose, displays progress and timings for each step --gold Imitate GOLD's output as closely as possible --dot Output lexer's NFA and DFA to Graphviz DOT format

The --dot parameter is interesting because it allows you to use Graphviz (or any other DOT-compatible visualization software) to create visual graphs of the lexer's original NFA and its resulting DFA.

The --gold parameter needs a little clarification:

The CGTs Goldie generates are always valid GOLD-compatible files that are functionally equivalent to the CGTs GOLD Parser Builder would generate. But there can still be some inconsequential differences, even though the CGTs behave exactly the same.

In theory, it's possible that another GOLD engine besides GoldieLib might mistakenly rely on some subtle detail of GOLD Parser Builder's output. Such an engine might accidentally handle Goldie's CGT slightly differently even though the CGTs normally would be functionally equivalent.

If this happens, you can use the --gold parameter: Goldie will jump through some extra hoops trying to emulate the normally-irrelevant details of GOLD Parser Builder as closely as possible. It still might not be exactly the same as GOLD Parser Builder's output, but it may at least be close enough. If not, you may be able to adjust your CGT file as needed with AlterCGT.

See Also: