source: release-kits/lirk3/resources/gs3-release-maker/apache-ant-1.6.5/docs/manual/OptionalTasks/jjtree.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 15.0 KB
Line 
1<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta http-equiv="Content-Language" content="en-us">
6 <title>JJTree Task</title>
7<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
8</head>
9<body>
10
11<h2>
12<a NAME="jjtree"></a>JJTree</h2>
13
14<h3>
15Description</h3>
16<p>Invokes the <a href="http://javacc.dev.java.net/">JJTree</a> preprocessor
17for the JavaCC compiler compiler. It inserts parse tree building actions
18at various places in the JavaCC source that it generates. The output of
19JJTree is run through JavaCC to create the parser.
20<p>To use the jjtree task, set the <i>target</i> attribute to the name
21of the JJTree grammar file to process. You also need to specify the directory
22containing the JavaCC installation using the <i>javacchome</i> attribute,
23so that ant can find the JavaCC classes. Optionally, you can also set the
24<i>outputdirectory</i>
25to write the generated JavaCC grammar and node files to a specific directory.
26Otherwise jjtree writes the generated JavaCC grammar and node files to the directory
27containing the JJTree grammar file. As an extra option, you can also set the
28<i>outputfile</i> to write the generated JavaCC grammar file to a specific (directory and) file.
29Otherwise jjtree writes the generated JavaCC grammar file as the JJTree
30grammar file with a suffix .jj.</p>
31<p>This task only invokes JJTree if the grammar file is newer than the
32generated JavaCC file.</p>
33
34<h3>Parameters</h3>
35
36<table BORDER CELLSPACING=0 CELLPADDING=2 >
37<tr>
38<td VALIGN=TOP><b>Attribute</b></td>
39
40<td VALIGN=TOP><b>Description</b></td>
41
42<td ALIGN=CENTER VALIGN=TOP><b>Required</b></td>
43</tr>
44
45<tr>
46<td VALIGN=TOP>target</td>
47
48<td VALIGN=TOP>The jjtree grammar file to process.</td>
49
50<td ALIGN=CENTER VALIGN=TOP>Yes</td>
51</tr>
52
53<tr>
54<td VALIGN=TOP>javacchome</td>
55
56<td VALIGN=TOP>The directory containing the JavaCC distribution.</td>
57
58<td ALIGN=CENTER VALIGN=TOP>Yes</td>
59</tr>
60
61<tr>
62<td VALIGN=TOP>outputdirectory</td>
63
64<td VALIGN=TOP>The directory to write the generated JavaCC grammar and node files to.
65If not set, the files are written to the directory containing the grammar file.&nbsp;</td>
66
67<td ALIGN=CENTER VALIGN=TOP>No</td>
68</tr>
69
70<tr>
71<td VALIGN=TOP>outputfile</td>
72
73<td VALIGN=TOP>The file to write the generated JavaCC grammar file
74to. If not set, the file is written with the same name as the JJTree
75grammar file but with a the suffix <code>.jj</code>. This is a
76filename relative to <em>outputdirectory</em> if specified, the
77project's basedir.</td>
78
79<td ALIGN=CENTER VALIGN=TOP>No</td>
80</tr>
81
82<tr>
83<td VALIGN=TOP>buildnodefiles</td>
84
85<td VALIGN=TOP>Sets the BUILD_NODE_FILES grammar option. This is a boolean
86option.</td>
87
88<td ALIGN=CENTER VALIGN=TOP>No</td>
89</tr>
90
91<tr>
92<td VALIGN=TOP>multi</td>
93
94<td VALIGN=TOP>Sets the MULTI grammar option. This is a boolean option.</td>
95
96<td ALIGN=CENTER VALIGN=TOP>No</td>
97</tr>
98
99<tr>
100<td VALIGN=TOP>nodedefaultvoid</td>
101
102<td VALIGN=TOP>Sets the NODE_DEFAULT_VOID grammar option. This is a boolean
103option.</td>
104
105<td ALIGN=CENTER VALIGN=TOP>No</td>
106</tr>
107
108<tr>
109<td VALIGN=TOP>nodefactory</td>
110
111<td VALIGN=TOP>Sets the NODE_FACTORY grammar option. This is boolean option.</td>
112
113<td ALIGN=CENTER VALIGN=TOP>No</td>
114</tr>
115
116<tr>
117<td VALIGN=TOP>nodescopehook</td>
118
119<td VALIGN=TOP>Sets the NODE_SCOPE_HOOK grammar option. This is a boolean
120option.</td>
121
122<td ALIGN=CENTER VALIGN=TOP>No</td>
123</tr>
124
125<tr>
126<td VALIGN=TOP>nodeusesparser</td>
127
128<td VALIGN=TOP>Sets the NODE_USES_PARSER grammar option. This is a boolean
129option.</td>
130
131<td ALIGN=CENTER VALIGN=TOP>No</td>
132</tr>
133
134<tr>
135<td VALIGN=TOP>static</td>
136
137<td VALIGN=TOP>Sets the STATIC grammar option. This is a boolean option.</td>
138
139<td ALIGN=CENTER VALIGN=TOP>No</td>
140</tr>
141
142<tr>
143<td VALIGN=TOP>visitor</td>
144
145<td VALIGN=TOP>Sets the VISITOR grammar option. This is a boolean option.</td>
146
147<td ALIGN=CENTER VALIGN=TOP>No</td>
148</tr>
149
150<tr>
151<td VALIGN=TOP>nodepackage</td>
152
153<td VALIGN=TOP>Sets the NODE_PACKAGE grammar option. This is a string option.</td>
154
155<td ALIGN=CENTER VALIGN=TOP>No</td>
156</tr>
157
158<tr>
159<td VALIGN=TOP>visitorexception</td>
160
161<td VALIGN=TOP>Sets the VISITOR_EXCEPTION grammar option. This is a string
162option.</td>
163
164<td ALIGN=CENTER VALIGN=TOP>No</td>
165</tr>
166
167<tr>
168<td VALIGN=TOP>nodeprefix</td>
169
170<td VALIGN=TOP>Sets the NODE_PREFIX grammar option. This is a string option.</td>
171
172<td ALIGN=CENTER VALIGN=TOP>No</td>
173</tr>
174</table>
175
176<h3>
177Example</h3>
178
179<blockquote>
180<pre>&lt;jjtree&nbsp;
181&nbsp;&nbsp;&nbsp; target="src/Parser.jjt"&nbsp;
182&nbsp;&nbsp;&nbsp; outputdirectory="build/src"
183&nbsp;&nbsp;&nbsp; javacchome="c:/program files/JavaCC"&nbsp;
184&nbsp;&nbsp;&nbsp; nodeusesparser="true"
185/&gt;</pre>
186</blockquote>
187This invokes JJTree on grammar file src/Parser.jjt, writing the generated
188grammar file, Parser.jj, file to build/src. The grammar option NODE_USES_PARSER
189is set to true when invoking JJTree.
190<br>
191
192<h3>Comparison output locations between command line JJTree and different Ant taskdef versions</h3>
193
194<table cellpadding="3" border="1">
195<tr>
196 <td><b>Command Line JJTree options</b>
197 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>and Generated Files</i> (working directory: <code>/tmp</code>)</td>
198 <td><b>Ant 1.5.3</b> versus command line</td>
199 <td><b>Ant 1.6</b> versus command line</td>
200</tr>
201<tr>
202 <td><pre><b>jjtree grammar.jjt</b>
203 /tmp/grammar.jj
204 /tmp/&lt;generated&gt;.java</pre>
205 </td>
206 <td>Same</td>
207 <td>Same</td>
208</tr>
209<tr>
210 <td><pre><b>jjtree relative/grammar.jjt</b>
211 /tmp/grammar.jj
212 /tmp/&lt;generated&gt;.java</pre>
213 </td>
214 <td><pre>
215/tmp/relative/grammar.jj
216/tmp/relative/&lt;generated&gt;.java</pre>
217 </td>
218 <td>Same</td>
219</tr>
220<tr>
221 <td><pre><b>jjtree /tmp/absolute/grammar.jjt</b>
222 /tmp/grammar.jj
223 /tmp/&lt;generated&gt;.java</pre>
224 </td>
225 <td><pre>
226/tmp/absolute/grammar.jj
227/tmp/absolute/&lt;generated&gt;.java</pre>
228 </td>
229 <td>Same</td>
230</tr>
231<tr>
232 <td><pre><b>jjtree -OUTPUT_DIRECTORY:relative grammar.jjt</b>
233 /tmp/relative/grammar.jj
234 /tmp/relative/&lt;generated&gt;.java</pre>
235 </td>
236 <td>Same</td>
237 <td>Same</td>
238</tr>
239<tr>
240 <td><pre><b>jjtree -OUTPUT_DIRECTORY:relative relative/grammar.jjt</b>
241 /tmp/relative/grammar.jj
242 /tmp/relative/&lt;generated&gt;.java</pre>
243 </td>
244 <td>Same</td>
245 <td>Same</td>
246</tr>
247<tr>
248 <td><pre><b>jjtree -OUTPUT_DIRECTORY:relative /tmp/absolute/grammar.jjt</b>
249 /tmp/relative/grammar.jj
250 /tmp/relative/&lt;generated&gt;.java</pre>
251 </td>
252 <td>Same</td>
253 <td>Same</td>
254</tr>
255<tr>
256 <td><pre><b>jjtree -OUTPUT_DIRECTORY:/tmp/absolute/ grammar.jjt</b>
257 /tmp/absolute/grammar.jj
258 /tmp/absolute/&lt;generated&gt;.java</pre>
259 </td>
260 <td>Same</td>
261 <td>Same</td>
262</tr>
263<tr>
264 <td><pre><b>jjtree -OUTPUT_DIRECTORY:/tmp/absolute/ relative/grammar.jjt</b>
265 /tmp/absolute/grammar.jj
266 /tmp/absolute/&lt;generated&gt;.java</pre>
267 </td>
268 <td>Same</td>
269 <td>Same</td>
270</tr>
271<tr>
272 <td><pre><b>jjtree -OUTPUT_DIRECTORY:/tmp/absolute/ /tmp/absolute/grammar.jjt</b>
273 /tmp/absolute/grammar.jj
274 /tmp/absolute/&lt;generated&gt;.java</pre>
275 </td>
276 <td>Same</td>
277 <td>Same</td>
278</tr>
279<tr>
280 <td><pre><b>jjtree -OUTPUT_FILE:output.jj grammar.jjt</b>
281 /tmp/output.jj
282 /tmp/&lt;generated&gt;.java</pre>
283 </td>
284 <td>Not Supported</td>
285 <td>Same</td>
286</tr>
287<tr>
288 <td><pre><b>jjtree -OUTPUT_FILE:output.jj relative/grammar.jjt</b>
289 /tmp/output.jj
290 /tmp/&lt;generated&gt;.java</pre>
291 </td>
292 <td>Not Supported</td>
293 <td>Same</td>
294</tr>
295<tr>
296 <td><pre><b>jjtree -OUTPUT_FILE:output.jj /tmp/absolute/grammar.jjt</b>
297 /tmp/output.jj
298 /tmp/&lt;generated&gt;.java</pre>
299 </td>
300 <td>Not Supported</td>
301 <td>Same</td>
302</tr>
303<tr>
304 <td><pre><b>jjtree -OUTPUT_FILE:output.jj -OUTPUT_DIRECTORY:relative grammar.jjt</b>
305 /tmp/relative/output.jj
306 /tmp/relative/&lt;generated&gt;.java</pre>
307 </td>
308 <td>Not Supported</td>
309 <td>Same</td>
310</tr>
311<tr>
312 <td><pre><b>jjtree -OUTPUT_FILE:output.jj -OUTPUT_DIRECTORY:relative relative/grammar.jjt</b>
313 /tmp/relative/output.jj
314 /tmp/relative/&lt;generated&gt;.java</pre>
315 </td>
316 <td>Not Supported</td>
317 <td>Same</td>
318</tr>
319<tr>
320 <td><pre><b>jjtree -OUTPUT_FILE:output.jj -OUTPUT_DIRECTORY:relative /tmp/absolute/grammar.jjt</b>
321 /tmp/relative/output.jj
322 /tmp/relative/&lt;generated&gt;.java</pre>
323 </td>
324 <td>Not Supported</td>
325 <td>Same</td>
326</tr>
327<tr>
328 <td><pre><b>jjtree -OUTPUT_FILE:output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ grammar.jjt</b>
329 /tmp/absolute/output.jj
330 /tmp/absolute/&lt;generated&gt;.java</pre>
331 </td>
332 <td>Not Supported</td>
333 <td>Same</td>
334</tr>
335<tr>
336 <td><pre><b>jjtree -OUTPUT_FILE:output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ relative/grammar.jjt</b>
337 /tmp/absolute/output.jj
338 /tmp/absolute/&lt;generated&gt;.java</pre>
339 </td>
340 <td>Not Supported</td>
341 <td>Same</td>
342</tr>
343<tr>
344 <td><pre><b>jjtree -OUTPUT_FILE:output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ /tmp/absolute/grammar.jjt</b>
345 /tmp/absolute/output.jj
346 /tmp/absolute/&lt;generated&gt;.java</pre>
347 </td>
348 <td>Not Supported</td>
349 <td>Same</td>
350</tr>
351<tr>
352 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj grammar.jjt</b>
353 /tmp/subdir/output.jj
354 /tmp/&lt;generated&gt;.java</pre>
355 </td>
356 <td>Not Supported</td>
357 <td>Same</td>
358</tr>
359<tr>
360 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj relative/grammar.jjt</b>
361 /tmp/subdir/output.jj
362 /tmp/&lt;generated&gt;.java</pre>
363 </td>
364 <td>Not Supported</td>
365 <td>Same</td>
366</tr>
367<tr>
368 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj /tmp/absolute/grammar.jjt</b>
369 /tmp/subdir/output.jj
370 /tmp/&lt;generated&gt;.java</pre>
371 </td>
372 <td>Not Supported</td>
373 <td>Same</td>
374</tr>
375<tr>
376 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj -OUTPUT_DIRECTORY:relative grammar.jjt</b>
377 /tmp/relative/subdir/output.jj
378 /tmp/relative/&lt;generated&gt;.java</pre>
379 </td>
380 <td>Not Supported</td>
381 <td>Same</td>
382</tr>
383<tr>
384 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj -OUTPUT_DIRECTORY:relative relative/grammar.jjt</b>
385 /tmp/relative/subdir/output.jj
386 /tmp/relative/&lt;generated&gt;.java</pre>
387 </td>
388 <td>Not Supported</td>
389 <td>Same</td>
390</tr>
391<tr>
392 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj -OUTPUT_DIRECTORY:relative /tmp/absolute/grammar.jjt</b>
393 /tmp/relative/subdir/output.jj
394 /tmp/relative/&lt;generated&gt;.java</pre>
395 </td>
396 <td>Not Supported</td>
397 <td>Same</td>
398</tr>
399<tr>
400 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ grammar.jjt</b>
401 /tmp/absolute/subdir/output.jj
402 /tmp/absolute/&lt;generated&gt;.java</pre>
403 </td>
404 <td>Not Supported</td>
405 <td>Same</td>
406</tr>
407<tr>
408 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ relative/grammar.jjt</b>
409 /tmp/absolute/subdir/output.jj
410 /tmp/absolute/&lt;generated&gt;.java</pre>
411 </td>
412 <td>Not Supported</td>
413 <td>Same</td>
414</tr>
415<tr>
416 <td><pre><b>jjtree -OUTPUT_FILE:subdir/output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ /tmp/absolute/grammar.jjt</b>
417 /tmp/absolute/subdir/output.jj
418 /tmp/absolute/&lt;generated&gt;.java</pre>
419 </td>
420 <td>Not Supported</td>
421 <td>Same</td>
422</tr>
423<tr>
424 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj grammar.jjt</b>
425 /tmp/subdir/output.jj
426 /tmp/&lt;generated&gt;.java</pre>
427 </td>
428 <td>Not Supported</td>
429 <td>Same</td>
430</tr>
431<tr>
432 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj relative/grammar.jjt</b>
433 /tmp/subdir/output.jj
434 /tmp/&lt;generated&gt;.java</pre>
435 </td>
436 <td>Not Supported</td>
437 <td>Same</td>
438</tr>
439<tr>
440 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj /tmp/absolute/grammar.jjt</b>
441 /tmp/subdir/output.jj
442 /tmp/&lt;generated&gt;.java</pre>
443 </td>
444 <td>Not Supported</td>
445 <td>Same</td>
446</tr>
447<tr>
448 <td><pre><b>jjtree -OUTPUT_FILE:<i><u>D:</u></i>/tmp/subdir/output.jj grammar.jjt</b>
449 /tmp/subdir/output.jj
450 /tmp/&lt;generated&gt;.java</pre>
451 </td>
452 <td>Not Supported</td>
453 <td>Not Supported *)</td>
454</tr>
455<tr>
456 <td><pre><b>jjtree -OUTPUT_FILE:<i><u>D:</u></i>/tmp/subdir/output.jj relative/grammar.jjt</b>
457 /tmp/subdir/output.jj
458 /tmp/&lt;generated&gt;.java</pre>
459 </td>
460 <td>Not Supported</td>
461 <td>Not Supported *)</td>
462</tr>
463<tr>
464 <td><pre><b>jjtree -OUTPUT_FILE:<i><u>D:</u></i>/tmp/subdir/output.jj /tmp/absolute/grammar.jjt</b>
465 /tmp/subdir/output.jj
466 /tmp/&lt;generated&gt;.java</pre>
467 </td>
468 <td>Not Supported</td>
469 <td>Not Supported *)</td>
470</tr>
471<tr>
472 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj -OUTPUT_DIRECTORY:relative grammar.jjt</b>
473 /tmp/relative/tmp/subdir/output.jj
474 /tmp/relative/&lt;generated&gt;.java</pre>
475 </td>
476 <td>Not Supported</td>
477 <td>Same</td>
478</tr>
479<tr>
480 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj -OUTPUT_DIRECTORY:relative relative/grammar.jjt</b>
481 /tmp/relative/tmp/subdir/output.jj
482 /tmp/relative/&lt;generated&gt;.java</pre>
483 </td>
484 <td>Not Supported</td>
485 <td>Same</td>
486</tr>
487<tr>
488 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj -OUTPUT_DIRECTORY:relative /tmp/absolute/grammar.jjt</b>
489 /tmp/relative/tmp/subdir/output.jj
490 /tmp/relative/&lt;generated&gt;.java</pre>
491 </td>
492 <td>Not Supported</td>
493 <td>Same</td>
494</tr>
495<tr>
496 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ grammar.jjt</b>
497 /tmp/absolute/tmp/subdir/output.jj
498 /tmp/absolute/&lt;generated&gt;.java</pre>
499 </td>
500 <td>Not Supported</td>
501 <td>Same</td>
502</tr>
503<tr>
504 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ relative/grammar.jjt</b>
505 /tmp/absolute/tmp/subdir/output.jj
506 /tmp/absolute/&lt;generated&gt;.java</pre>
507 </td>
508 <td>Not Supported</td>
509 <td>Same</td>
510</tr>
511<tr>
512 <td><pre><b>jjtree -OUTPUT_FILE:/tmp/subdir/output.jj -OUTPUT_DIRECTORY:/tmp/absolute/ /tmp/absolute/grammar.jjt</b>
513 /tmp/absolute/tmp/subdir/output.jj
514 /tmp/absolute/&lt;generated&gt;.java</pre>
515 </td>
516 <td>Not Supported</td>
517 <td>Same</td>
518</tr>
519</table>
520
521<p>*) <u>Footnote</u>: When running JJTree with the Ant taskdef <i>jjtree</i> the option <code>-OUTPUT_DIRECTORY</code> must always
522be set, because the project's basedir and the ant working directory might differ. So even if you don't specify the jjtree taskdef
523<i>outputdirectory</i> JJTree will be called with the <code>-OUTPUT_DIRECTORY</code> set to the project's basedirectory.
524But when the <code>-OUTPUT_DIRECTORY</code> is set, the <code>-OUTPUT_FILE</code> setting is handled as if relative to this
525<code>-OUTPUT_DIRECTORY</code>. Thus when the <code>-OUTPUT_FILE</code> is absolute or contains a drive letter we have a
526problem.
527Therefore absolute <i>outputfile</i>s (when the <i>outputdirectory</i> isn't specified) are made relative to the default directory.
528And for this reason <i>outputfile</i>s that contain a drive letter can't be supported.</p>
529
530<p>By the way: specifying a drive letter in the <code>-OUTPUT_FILE</code> when the <code>-OUTPUT_DIRECTORY</code> is set, also
531results in strange behavior when running JJTree from the command line.</p>
532
533<br>
534<hr>
535<p align="center">Copyright &copy; 2001-2004 The Apache Software Foundation. All rights
536Reserved.</p>
537
538
539
540</body>
541</html>
542
Note: See TracBrowser for help on using the repository browser.