Goldie Homepage

Documentation (v0.3)
Goldie -> Documentation (v0.3) -> Included Tools -> Parse

Parse

Parses any source according to any GOLD CGT file, and saves the resulting tokens and parse tree to JSON files. These JSON files can be inspected with the enhanced version of JsonViewer bundled with Goldie.

Example:

If the file extension of your source is the same as the name of a CGT file in the lang/ directory: For instance, the *.calc files (which just happen to also be in lang/, although they could be anywhere) are intended to be parsed with lang/calc.cgt.

>parse lang/valid_sample2.calc

If the file extension of your source is the same as the name of a CGT file in some other directory (the directory can be absolute or relative):

>parse -langdir:/home/me/myLanguages lang/valid_sample2.calc

To use a specific CGT file (in the lang/ directory), instead of inferring from the extension:

>parse -lang:calc lang/valid_sample2.calc

If the CGT file is not in the lang/ directory, you'll have to use both -lang and -langdir (This limitation will be fixed in a future version.):

>parse -lang:calc -langdir:/home/me/myLanguages lang/valid_sample2.calc

All of the examples above will create the following files in the same directory as valid_sample2.calc:

valid_sample2.calc.tk.json valid_sample2.calc.pt.json

The .tk.json file contains the tokenization (ie, the result of the Lexing phase) of valid_sample2.calc.

The .pt.json file contains the parse tree (ie, the result of the Parsing phase) of valid_sample2.calc.

Either of the .json files can be opened in JsonViewer and will be browsable using JsonViewer's Parse Tree Mode.

Command-line parameters:

Sample Usage: parse lang/valid_sample2.calc Switches: (Prefixes can be '/', '-' or '--') ('[]' means multiple switches are accepted) Basic: /help Displays a help summary and exits /detail Displays a detailed help message and exits <text> (Required) Input filename Advanced: /lang:<text> Language (will load '{lang}.cgt') /langdir:<text> Directory containing language files /npt Don't Save Parse Tree /ntk Don't Save Tokens /ptp Pretty Format Parse Tree File /tkp Pretty Format Token File /ptt:<text> Parse Tree File Type ("json" or "xml") (default: "json") /tkt:<text> Token File Type ("json" or "xml") (default: "json") /pto:<text> Parse Tree Output Filename /tko:<text> Token Output Filename /debug Display Debug Information