People interested in using Gom as a standalone tool can use the Gom command line interface.
gom [options] filename [... filename]
Options:
--config <file> | -X | Defines an alternate XML configuration file |
--debug | -vv | Display debugging info |
--destdir <dir> | -d | Specify where to place generated files |
--generator <type> | -g | Select Generator. Possible value: "shared" |
--help | -h | Show this help |
--import <path> | -I | Path for include |
--inlineplus | Make inlining active |
--intermediate | -i | Generate intermediate files |
--intermediateName <intermediateName> | -iname | specify the prefix of intermediate files |
--multithread | -mt | Generate code compatible with multi-threading |
--optimize | -O | Optimize generated code |
--optimize2 | -O2 | Optimize generated code |
--package <packageName> | -p | Specify package name (optional) |
--strategies-mapping | -sm | Generate tom mapping for strategies |
--termgraph | -tg | Extend the signature for term-graphs |
--termpointer | -tp | Extend the signature for term pointers |
--verbose | -v | Display compilation information |
--verbosedebug | -vvv | Display even more debugging info |
--version | -V | Print version |
--wall | -W | Print warning |
Gom can also be used within ant, and has its own ant tasks.
To use the Gom ant task, you have to first declare it the same way as the Tom ant task.
<taskdef name="gom" classname="tom.gom.tools.ant.GomTask" classpathref="tom.classpath"/>
Once the task is defined, you can use them to compile a Gom file.
The Gom ant task has to be able to find a configuration file for Gom.
It can either use the tom.home
property to find its configuration file,
or use the value of the config
attribute.
Since the tom.home
property is also used when Gom has to process
hooks, it is a good practice to always define the tom.home
property to
the installation path of the Tom system.
The default configuration file for
Gom is included in the Tom distribution as Gom.xml
.
<gom config="${gom.configfile}" srcdir="${src.dir}" package="example" destdir="${gen.dir}"> <include name="**/*.gom"/> </gom>
Like in Tom example, in this Gom ant task we want to compile all Gom source files in {src.dir}
and to configure the compiler to create a package called example
in {gen.dir}
for the generated code, just as we do for Gom in command line.
The Gom task takes the following arguments:
Attribute | Description | Required |
config | Location of the Gom configuration file. | No |
destdir | Location of the generated files. | No |
options | Custom options to pass to the Gom compiler. | No |
package | Package for the generated Java files. | No |
srcdir | Location of the Gom files | Yes, unless nested
<src> elements are present |
The set of .gom
files to compile is specified with a nested
include
element.
GomAntlrAdaptor is a tool that takes a Gom signature and generates an adaptor for a given Antlr grammar file. This way, Gom constructors can be directly used in the rewrite rule mechanism offered by Antlr (version 3). See examples/parser the see an example that shows how to combine Tom, Gom and Antlr.
gomantlradaptor [options] filename [... filename]
Options:
--config <file> | -X | Defines an alternate XML configuration file |
--debug | -vv | Display debugging info |
--destdir <dir> | -d | Specify where to place generated files |
--grammar <grammarName> | -g | Antlr grammar name |
--help | -h | Show this help |
--import <path> | -I | Path for include |
--intermediate | -i | Generate intermediate files |
--intermediateName <intermediateName> | -iname | specify the prefix of intermediate files |
--package <packageName> | -p | Specify package name (optional) |
--termgraph | -tg | Extend the signature for term-graphs |
--termpointer | -tp | Extend the signature for term pointers |
--verbose | -v | Display compilation information |
--verbosedebug | -vvv | Display even more debugging info |
--version | -V | Print version |
--wall | -W | Print warning |
The GomAntlrAdaptor task takes the following arguments:
Attribute | Description | Required |
config | Location of the GomAntlrAdaptor configuration file. | No |
destdir | Location of the generated files. | No |
grammar | Name of the grammar. | Yes |
options | Custom options to pass to the Gom compiler. | No |
package | Package for the generated Java files. | No |
srcdir | Location of the GomAntlrAdaptor files | Yes, unless nested
<src> elements are present |