Documentation:Using Gom

From Tom

Jump to: navigation, search
Doc : Tools

Installation  > Compiling from sources  > Using Tom  > Using Gom  > Configuring your environment  > Tom Server  > EMF Mapping Generator

Contents

Command line tool

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
--fresh <dir> | -f Enable Fresh Gom
--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
--nosharing | -ns Generate code without maximal sharing
--optimize | -O Optimize generated code
--optimize2 | -O2 Optimize generated code
--package <packageName> | -p Specify package name (optional)
--withCongruenceStrategies | -wcs Include the definition of congruence strategies in the generate *.tom file
--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

Ant task

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.

Gom Antlr adaptor

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). The example examples/parser shows how to combine Tom, Gom and Antlr.

Command line tool

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
--fresh | -f Extend the signature to deal with terms with binders
--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

Ant task

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
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
Tools

Installation  > Compiling from sources  > Using Tom  > Using Gom  > Configuring your environment  > Tom Server  > EMF Mapping Generator

Tom Documentation
Guided Tour :: Tutorial :: Language Reference :: Tools
Personal tools
Create a book