1 | <!--
|
---|
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
|
---|
8 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
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.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
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>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2><a name="antlr">ANTLR</a></h2>
|
---|
28 | <h3>Description</h3>
|
---|
29 | <p>
|
---|
30 | Invokes the <a HREF="http://www.antlr.org/" target="_top">ANTLR</a> Translator generator
|
---|
31 | on a grammar file.
|
---|
32 | </p>
|
---|
33 | <p>
|
---|
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
|
---|
38 | the grammar file.
|
---|
39 | </p>
|
---|
40 | <p>
|
---|
41 | This task only invokes ANTLR if the grammar file (or the
|
---|
42 | supergrammar specified by the glib attribute) is newer than the
|
---|
43 | generated files.
|
---|
44 | </p>
|
---|
45 | <p>Antlr 2.7.1 Note:
|
---|
46 | <i>
|
---|
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.
|
---|
52 | </i>
|
---|
53 | </p>
|
---|
54 | <p>Antlr 2.7.2 Note:
|
---|
55 | <i>
|
---|
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
|
---|
58 | download.
|
---|
59 | </i>
|
---|
60 | </p>
|
---|
61 |
|
---|
62 | <h3>Parameters</h3>
|
---|
63 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
64 | <tr>
|
---|
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>
|
---|
68 | </tr>
|
---|
69 | <tr>
|
---|
70 | <td valign="top">target</td>
|
---|
71 | <td valign="top">The grammar file to process.</td>
|
---|
72 | <td valign="top" align="center">Yes</td>
|
---|
73 | </tr>
|
---|
74 | <tr>
|
---|
75 | <td valign="top">outputdirectory</td>
|
---|
76 | <td valign="top">
|
---|
77 | The directory to write the generated files to. If not set, the files
|
---|
78 | are written to the directory containing the grammar file.
|
---|
79 | </td>
|
---|
80 | <td valign="top" align="center">No</td>
|
---|
81 | </tr>
|
---|
82 | <tr>
|
---|
83 | <td valign="top">glib</td>
|
---|
84 | <td valign="top">
|
---|
85 | An optional super grammar file that the target grammar overrides. This
|
---|
86 | feature is only needed for advanced vocabularies.
|
---|
87 | </td>
|
---|
88 | <td valign="top" align="center">No</td>
|
---|
89 | </tr>
|
---|
90 | <tr>
|
---|
91 | <td valign="top">debug</td>
|
---|
92 | <td valign="top">
|
---|
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".
|
---|
95 | <br>
|
---|
96 | Note: ParseView is a separate component that needs to be installed or your
|
---|
97 | grammar will have compilation errors.
|
---|
98 | </td>
|
---|
99 | <td valign="top" align="center">No</td>
|
---|
100 | </tr>
|
---|
101 | <tr>
|
---|
102 | <td valign="top">html</td>
|
---|
103 | <td valign="top">
|
---|
104 | Emit an html version of the grammar with hyperlinked actions.
|
---|
105 | </td>
|
---|
106 | <td valign="top" align="center">No</td>
|
---|
107 | </tr>
|
---|
108 | <tr>
|
---|
109 | <td valign="top">diagnostic</td>
|
---|
110 | <td valign="top">
|
---|
111 | Generates a text file with debugging information based on the target grammar.
|
---|
112 | </td>
|
---|
113 | <td valign="top" align="center">No</td>
|
---|
114 | </tr>
|
---|
115 | <tr>
|
---|
116 | <td valign="top">trace</td>
|
---|
117 | <td valign="top">
|
---|
118 | Forces <b>all</b> rules to call traceIn/traceOut if set to "yes".
|
---|
119 | The default is "no".
|
---|
120 | </td>
|
---|
121 | <td valign="top" align="center">No</td>
|
---|
122 | </tr>
|
---|
123 | <tr>
|
---|
124 | <td valign="top">traceParser</td>
|
---|
125 | <td valign="top">
|
---|
126 | Only forces parser rules to call traceIn/traceOut if set to "yes".
|
---|
127 | The default is "no".
|
---|
128 | </td>
|
---|
129 | <td valign="top" align="center">No</td>
|
---|
130 | </tr>
|
---|
131 | <tr>
|
---|
132 | <td valign="top">traceLexer</td>
|
---|
133 | <td valign="top">
|
---|
134 | Only forces lexer rules to call traceIn/traceOut if set to "yes".
|
---|
135 | The default is "no".
|
---|
136 | </td>
|
---|
137 | <td valign="top" align="center">No</td>
|
---|
138 | </tr>
|
---|
139 | <tr>
|
---|
140 | <td valign="top">traceTreeWalker</td>
|
---|
141 | <td valign="top">
|
---|
142 | Only forces tree walker rules to call traceIn/traceOut if set to
|
---|
143 | "yes". The default is "no".
|
---|
144 | </td>
|
---|
145 | <td valign="top" align="center">No</td>
|
---|
146 | </tr>
|
---|
147 | <!--tr>
|
---|
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>
|
---|
151 | </tr-->
|
---|
152 | <tr>
|
---|
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>
|
---|
157 | </tr>
|
---|
158 | </table>
|
---|
159 |
|
---|
160 | <h3><a name="nested">Nested Elements</a></h3>
|
---|
161 |
|
---|
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>
|
---|
167 |
|
---|
168 | <h4>jvmarg</h4>
|
---|
169 |
|
---|
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>
|
---|
172 |
|
---|
173 | <pre>
|
---|
174 | <antlr target="...">
|
---|
175 | <jvmarg value="-Djava.compiler=NONE"/>
|
---|
176 | ...
|
---|
177 | </antlr>
|
---|
178 | </pre>
|
---|
179 |
|
---|
180 | <p>would run ANTLR in a VM without JIT.</p>
|
---|
181 |
|
---|
182 | <p><code><jvmarg></code> allows all attributes described in <a
|
---|
183 | href="../using.html#arg">Command line arguments</a>.</p>
|
---|
184 |
|
---|
185 | <h3>Example</h3>
|
---|
186 | <blockquote><pre>
|
---|
187 | <antlr
|
---|
188 | target="etc/java.g"
|
---|
189 | outputdirectory="build/src"
|
---|
190 | />
|
---|
191 | </pre></blockquote>
|
---|
192 | <p>
|
---|
193 | This invokes ANTLR on grammar file etc/java.g, writing the generated
|
---|
194 | files to build/src.
|
---|
195 | </p>
|
---|
196 |
|
---|
197 |
|
---|
198 | </body>
|
---|
199 | </html>
|
---|
200 |
|
---|