ANTLR

Description

Invokes the ANTLR Translator generator on a grammar file.

To use the ANTLR task, set the target attribute to the name of the grammar file to process. Optionally, you can also set the outputdirectory to write the generated file to a specific directory. Otherwise ANTLR writes the generated files to the directory containing the grammar file.

This task only invokes ANTLR if the grammar file (or the supergrammar specified by the glib attribute) is newer than the generated files.

Note: This task depends on external libraries not included in the Apache Ant distribution. See Library Dependencies for more information.

Antlr 2.7.2 Note: You will need antlrall.jar that can be created by the antlr-all.jar target of the Makefile provided with the download.

Parameters

Attribute Description Required
target The grammar file to process. Yes
outputdirectory The directory to write the generated files to. No; defaults to the directory containing the grammar file
glib An optional super grammar file that the target grammar overrides. This feature is only needed for advanced vocabularies. No
debug When set to yes, this flag adds code to the generated parser that will launch the ParseView debugger upon invocation.
Note: ParseView is a separate component that needs to be installed or your grammar will have compilation errors.
No; default is no
html Emit an HTML version of the grammar with hyperlinked actions if set to yes. No; default is no
diagnostic Generate a text file with debugging information based on the target grammar if set to yes. No; default is no
trace Force all rules to call traceIn/traceOut if set to yes. No; default is no
traceParser Only force parser rules to call traceIn/traceOut if set to yes. No; default is no
traceLexer Only force lexer rules to call traceIn/traceOut if set to yes. No; default is no
traceTreeWalker Only force tree walker rules to call traceIn/traceOut if set to yes. No; default is no
dir The directory to invoke JVM in. No

Parameters specified as nested elements

The task supports a nested <classpath> element, that represents a path-like structure. It is given as a convenience if you have to specify the original ANTLR directory. In most cases, dropping the appropriate ANTLR jar in the normal Ant lib repository will be enough.

jvmarg

Additional parameters may be passed to the new JVM via nested <jvmarg> attributes, for example:

<antlr target="...">
  <jvmarg value="-Djava.compiler=NONE"/>
  ...
</antlr>

would run ANTLR in a JVM without JIT.

<jvmarg> allows all attributes described in Command line arguments.

Example

<antlr
    target="etc/java.g"
    outputdirectory="build/src"/>

This invokes ANTLR on grammar file etc/java.g, writing the generated files to build/src.