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 is newer than the generated files.
To successfully run ANTLR, your best option is probably to build the whole jar with the provided script mkalljar and drop the resulting jar (about 300KB) into ${ant.home}/lib. Dropping the default jar (70KB) is probably not enough for most needs and your only option will be to add ANTLR home directory to your classpath as described in ANTLR install.html document.
Attribute | Description | Required |
target | The grammar file to process. | Yes |
outputdirectory | The directory to write the generated files to. If not set, the files are written to the directory containing the grammar file. | No |
dir | The directory to invoke the VM in. | No |
ANTLR
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.
Additional parameters may be passed to the new
VM via nested <jvmarg>
attributes, for example:
<antlr target=...> <jvmarg value="-Djava.compiler=NONE"/> ... </antlr>
would run ANTLR in a VM without JIT.
<jvmarg>
allows all attributes described in Command line arguments.
<antlr target="etc/java.g" outputdirectory="build/src" />
This invokes ANTLR on grammar file etc/java.g, writing the generated files to build/src.
Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.