2
Licensed to the Apache Software Foundation (ASF) under one or more
3
contributor license agreements. See the NOTICE file distributed with
4
this work for additional information regarding copyright ownership.
5
The ASF licenses this file to You under the Apache License, Version 2.0
6
(the "License"); you may not use this file except in compliance with
7
the License. You may obtain a copy of the License at
9
http://www.apache.org/licenses/LICENSE-2.0
11
Unless required by applicable law or agreed to in writing, software
12
distributed under the License is distributed on an "AS IS" BASIS,
13
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
See the License for the specific language governing permissions and
15
limitations under the License.
20
<meta http-equiv="Content-Language" content="en-us">
21
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22
<title>ANTLR Task</title>
27
<h2><a name="antlr">ANTLR</a></h2>
30
Invokes the <a HREF="http://www.antlr.org/" target="_top">ANTLR</a> Translator generator
34
To use the ANTLR task, set the <i>target</i> attribute to the name of the
35
grammar file to process. Optionally, you can also set the
36
<i>outputdirectory</i> to write the generated file to a specific directory.
37
Otherwise ANTLR writes the generated files to the directory containing
41
This task only invokes ANTLR if the grammar file (or the
42
supergrammar specified by the glib attribute) is newer than the
47
To successfully run ANTLR, your best option is probably to build the whole
48
jar with the provided script <b>mkalljar</b> and drop the resulting jar (about 300KB)
49
into ${ant.home}/lib. Dropping the default jar (70KB) is probably not enough
50
for most needs and your only option will be to add ANTLR home directory
51
to your classpath as described in ANTLR <tt>install.html</tt> document.
56
Instead of the above, you will need antlrall.jar that can be created
57
by the <b>antlr-all.jar</b> target of the Makefile provided with the
63
<table border="1" cellpadding="2" cellspacing="0">
65
<td valign="top"><b>Attribute</b></td>
66
<td valign="top"><b>Description</b></td>
67
<td align="center" valign="top"><b>Required</b></td>
70
<td valign="top">target</td>
71
<td valign="top">The grammar file to process.</td>
72
<td valign="top" align="center">Yes</td>
75
<td valign="top">outputdirectory</td>
77
The directory to write the generated files to. If not set, the files
78
are written to the directory containing the grammar file.
80
<td valign="top" align="center">No</td>
83
<td valign="top">glib</td>
85
An optional super grammar file that the target grammar overrides. This
86
feature is only needed for advanced vocabularies.
88
<td valign="top" align="center">No</td>
91
<td valign="top">debug</td>
93
When set to "yes", this flag adds code to the generated parser that will
94
launch the ParseView debugger upon invocation. The default is "no".
96
Note: ParseView is a separate component that needs to be installed or your
97
grammar will have compilation errors.
99
<td valign="top" align="center">No</td>
102
<td valign="top">html</td>
104
Emit an html version of the grammar with hyperlinked actions.
106
<td valign="top" align="center">No</td>
109
<td valign="top">diagnostic</td>
111
Generates a text file with debugging information based on the target grammar.
113
<td valign="top" align="center">No</td>
116
<td valign="top">trace</td>
118
Forces <b>all</b> rules to call traceIn/traceOut if set to "yes".
121
<td valign="top" align="center">No</td>
124
<td valign="top">traceParser</td>
126
Only forces parser rules to call traceIn/traceOut if set to "yes".
129
<td valign="top" align="center">No</td>
132
<td valign="top">traceLexer</td>
134
Only forces lexer rules to call traceIn/traceOut if set to "yes".
137
<td valign="top" align="center">No</td>
140
<td valign="top">traceTreeWalker</td>
142
Only forces tree walker rules to call traceIn/traceOut if set to
143
"yes". The default is "no".
145
<td valign="top" align="center">No</td>
148
<td valign="top">fork</td>
149
<td valign="top">Run ANTLR in a separate VM.</td>
150
<td align="center" valign="top">No, default is "off"</td>
153
<td valign="top">dir</td>
154
<td valign="top">The directory to invoke the VM in. <!--(ignored if
155
fork is disabled)--></td>
156
<td align="center" valign="top">No</td>
160
<h3><a name="nested">Nested Elements</a></h3>
162
<p><code>ANTLR</code> supports a nested <code><classpath></code>
163
element, that represents a <a href="../using.html#path">PATH like
164
structure</a>. It is given as a convenience if you have to specify
165
the original ANTLR directory. In most cases, dropping the appropriate
166
ANTLR jar in the normal Ant lib repository will be enough.</p>
170
<p><!--If fork is enabled, -->Additional parameters may be passed to the new
171
VM via nested <code><jvmarg></code> attributes, for example:</p>
174
<antlr target="...">
175
<jvmarg value="-Djava.compiler=NONE"/>
180
<p>would run ANTLR in a VM without JIT.</p>
182
<p><code><jvmarg></code> allows all attributes described in <a
183
href="../using.html#arg">Command line arguments</a>.</p>
188
target="etc/java.g"
189
outputdirectory="build/src"
193
This invokes ANTLR on grammar file etc/java.g, writing the generated