Goldie Homepage

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

StaticLang

Generates a language package from a GOLD CGT file that can be embedded directly into a D program and used in either static-style or dynamic-style.

Example:

Suppose this scenario:

  • Your program is called MyApp and is in a package named myapp.
  • MyApp's sources are in ./src.
  • You have a language mylang with a CGT ./langs/mylang.cgt (created by GOLD Parsr Builder).
  • You want to use mylang in static-style (or want to use it dynamic-style but have it built directly into MyApp instead of loading the CGT at runtime).
>staticlang langs/mylang.cgt -dir:src -pack:myapp.mylang

The above command will create the package myapp.mylang in directory ./src/myapp/mylang/. Then, to use the language (in either static-style or dynamic-style), include this line in the MyApp source:

import myapp.mylang.all;

Then, use the Language_{languageName} named language_mylang, like this:

module myapp; import myapp.mylang.all; void main() { auto source = "...source code in 'mylang' language here..."; // Static-style: auto rootTokenStatic = language_mylang.parseCode(src).parseTree; // Dynamic-style: auto rootTokenDynamic = language_mylang.parseCodeX(src).parseTreeX; // rootTokenStatic is of type: Token_mylang!("<mylang's start symbol>") // (Look up 'Token_{languageName}!({symbol})' in Goldie's API Reference) // rootTokenDynamic is of type: Token }

For an example of actually using the resulting parse tree, see the source code for the Included Sample Apps and the examples on the Static And Dynamic Styles page.

Command-line parameters:

Sample Usage: staticlang langs/lang.cgt Creates "goldie/staticlang/lang/*.d", each containing "module goldie.staticlang.lang.*;" staticlang langs/lang.cgt /dir:foo/src /pack:myapp.mylang Creates "foo/src/myapp/mylang/*.d", each containing "module myapp.mylang.*;" Switches: (Prefixes can be '/', '-' or '--') ('[]' means multiple switches are accepted) /help Displays a help summary and exits /detail Displays a detailed help message and exits <text> (Required) CGT language file to use /pack:<text> Name of output package (default: goldie.staticlang.{cgt}) /dir:<text> Directory of package root (default: current directory)

See Also: