| 1 |
<!DOCTYPE html> |
| 2 |
<!-- |
| 3 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 |
contributor license agreements. See the NOTICE file distributed with |
| 5 |
this work for additional information regarding copyright ownership. |
| 6 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 |
(the "License"); you may not use this file except in compliance with |
| 8 |
the License. You may obtain a copy of the License at |
| 9 |
|
| 10 |
https://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 12 |
Unless required by applicable law or agreed to in writing, software |
| 13 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
See the License for the specific language governing permissions and |
| 16 |
limitations under the License. |
| 17 |
--> |
| 18 |
<html lang="en"> |
| 19 |
|
| 20 |
<head> |
| 21 |
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css"> |
| 22 |
<title>JavaCC Task</title> |
| 23 |
</head> |
| 24 |
|
| 25 |
<body> |
| 26 |
|
| 27 |
<h2 id="javacc">JavaCC</h2> |
| 28 |
<h3>Description</h3> |
| 29 |
<p>Invokes the <a href="https://javacc.org/" target="_top">JavaCC</a> compiler compiler on a grammar |
| 30 |
file.</p> |
| 31 |
<p>To use the <code>javacc</code> task, set the <var>target</var> attribute to the name of the |
| 32 |
grammar file to process. You also need to specify the directory containing the JavaCC installation |
| 33 |
using the <var>javacchome</var> attribute, so that Apache Ant can find the JavaCC classes. |
| 34 |
Optionally, you can also set the <var>outputdirectory</var> to write the generated file to a |
| 35 |
specific directory. Otherwise JavaCC writes the generated files to the directory containing the |
| 36 |
grammar file.</p> |
| 37 |
<p>This task only invokes JavaCC if the grammar file is newer than the generated <samp>.java</samp> |
| 38 |
files. JavaCC assumes that the Java class name of the generated parser is the same as the name of |
| 39 |
the grammar file, ignoring the <samp>.jj</samp>. If this is not the case, the <code>javacc</code> |
| 40 |
task will still work, but it will always generate the output files.</p> |
| 41 |
|
| 42 |
<h3>Parameters</h3> |
| 43 |
<table class="attr"> |
| 44 |
<tr> |
| 45 |
<th scope="col">Attribute</th> |
| 46 |
<th scope="col">Description</th> |
| 47 |
<th scope="col">Required</th> |
| 48 |
</tr> |
| 49 |
<tr> |
| 50 |
<td>target</td> |
| 51 |
<td>The grammar file to process.</td> |
| 52 |
<td>Yes</td> |
| 53 |
</tr> |
| 54 |
<tr> |
| 55 |
<td>javacchome</td> |
| 56 |
<td>The directory containing the JavaCC distribution.</td> |
| 57 |
<td>Yes</td> |
| 58 |
</tr> |
| 59 |
<tr> |
| 60 |
<td>outputdirectory</td> |
| 61 |
<td>The directory to write the generated files to. If not set, the files are written to the |
| 62 |
directory containing the grammar file.</td> |
| 63 |
<td>No</td> |
| 64 |
</tr> |
| 65 |
<tr> |
| 66 |
<td>buildparser</td> |
| 67 |
<td>Sets the BUILD_PARSER grammar option. This is a boolean option.</td> |
| 68 |
<td>No</td> |
| 69 |
</tr> |
| 70 |
<tr> |
| 71 |
<td>buildtokenmanager</td> |
| 72 |
<td>Sets the BUILD_TOKEN_MANAGER grammar option. This is a boolean option.</td> |
| 73 |
<td>No</td> |
| 74 |
</tr> |
| 75 |
<tr> |
| 76 |
<td>cachetokens</td> |
| 77 |
<td>Sets the CACHE_TOKENS grammar option. This is a boolean option.</td> |
| 78 |
<td>No</td> |
| 79 |
</tr> |
| 80 |
<tr> |
| 81 |
<td>choiceambiguitycheck</td> |
| 82 |
<td>Sets the CHOICE_AMBIGUITY_CHECK grammar option. This is an integer option.</td> |
| 83 |
<td>No</td> |
| 84 |
</tr> |
| 85 |
<tr> |
| 86 |
<td>commontokenaction</td> |
| 87 |
<td>Sets the COMMON_TOKEN_ACTION grammar option. This is a boolean option.</td> |
| 88 |
<td>No</td> |
| 89 |
</tr> |
| 90 |
<tr> |
| 91 |
<td>debuglookahead</td> |
| 92 |
<td>Sets the DEBUG_LOOKAHEAD grammar option. This is a boolean option.</td> |
| 93 |
<td>No</td> |
| 94 |
</tr> |
| 95 |
<tr> |
| 96 |
<td>debugparser</td> |
| 97 |
<td>Sets the DEBUG_PARSER grammar option. This is a boolean option.</td> |
| 98 |
<td>No</td> |
| 99 |
</tr> |
| 100 |
<tr> |
| 101 |
<td>debugtokenmanager</td> |
| 102 |
<td>Sets the DEBUG_TOKEN_MANAGER grammar option. This is a boolean option.</td> |
| 103 |
<td>No</td> |
| 104 |
</tr> |
| 105 |
<tr> |
| 106 |
<td>errorreporting</td> |
| 107 |
<td>Sets the ERROR_REPORTING grammar option. This is a boolean option.</td> |
| 108 |
<td>No</td> |
| 109 |
</tr> |
| 110 |
<tr> |
| 111 |
<td>forcelacheck</td> |
| 112 |
<td>Sets the FORCE_LA_CHECK grammar option. This is a boolean option.</td> |
| 113 |
<td>No</td> |
| 114 |
</tr> |
| 115 |
<tr> |
| 116 |
<td>ignorecase</td> |
| 117 |
<td>Sets the IGNORE_CASE grammar option. This is a boolean option.</td> |
| 118 |
<td>No</td> |
| 119 |
</tr> |
| 120 |
<tr> |
| 121 |
<td>javaunicodeescape</td> |
| 122 |
<td>Sets the JAVA_UNICODE_ESCAPE grammar option. This is a boolean option.</td> |
| 123 |
<td>No</td> |
| 124 |
</tr> |
| 125 |
<tr> |
| 126 |
<td>jdkversion</td> |
| 127 |
<td>Sets the JDK_VERSION option. This is a string option.</td> |
| 128 |
<td>No</td> |
| 129 |
</tr> |
| 130 |
<tr> |
| 131 |
<td>keeplinecolumn</td> |
| 132 |
<td>Sets the KEEP_LINE_COLUMN grammar option. This is a boolean option.</td> |
| 133 |
<td>No</td> |
| 134 |
</tr> |
| 135 |
<tr> |
| 136 |
<td>lookahead</td> |
| 137 |
<td>Sets the LOOKAHEAD grammar option. This is an integer option.</td> |
| 138 |
<td>No</td> |
| 139 |
</tr> |
| 140 |
<tr> |
| 141 |
<td>optimizetokenmanager</td> |
| 142 |
<td>Sets the OPTIMIZE_TOKEN_MANAGER grammar option. This is a boolean option.</td> |
| 143 |
<td>No</td> |
| 144 |
</tr> |
| 145 |
<tr> |
| 146 |
<td>otherambiguitycheck</td> |
| 147 |
<td>Sets the OTHER_AMBIGUITY_CHECK grammar option. This is an integer option.</td> |
| 148 |
<td>No</td> |
| 149 |
</tr> |
| 150 |
<tr> |
| 151 |
<td>sanitycheck</td> |
| 152 |
<td>Sets the SANITY_CHECK grammar option. This is a boolean option.</td> |
| 153 |
<td>No</td> |
| 154 |
</tr> |
| 155 |
<tr> |
| 156 |
<td>static</td> |
| 157 |
<td>Sets the STATIC grammar option. This is a boolean option.</td> |
| 158 |
<td>No</td> |
| 159 |
</tr> |
| 160 |
<tr> |
| 161 |
<td>unicodeinput</td> |
| 162 |
<td>Sets the UNICODE_INPUT grammar option. This is a boolean option.</td> |
| 163 |
<td>No</td> |
| 164 |
</tr> |
| 165 |
<tr> |
| 166 |
<td>usercharstream</td> |
| 167 |
<td>Sets the USER_CHAR_STREAM grammar option. This is a boolean option.</td> |
| 168 |
<td>No</td> |
| 169 |
</tr> |
| 170 |
<tr> |
| 171 |
<td>usertokenmanager</td> |
| 172 |
<td>Sets the USER_TOKEN_MANAGER grammar option. This is a boolean option.</td> |
| 173 |
<td>No</td> |
| 174 |
</tr> |
| 175 |
<tr> |
| 176 |
<td>maxmemory</td> |
| 177 |
<td>Max amount of memory to allocate to the forked JVM. <em>since Ant 1.8.3</em></td> |
| 178 |
<td>No</td> |
| 179 |
</tr> |
| 180 |
</table> |
| 181 |
<h3>Example</h3> |
| 182 |
|
| 183 |
<p>Invoke JavaCC on grammar file <samp>src/Parser.jj</samp>, writing the generated files |
| 184 |
to <samp>build/src</samp>. The grammar option STATIC is set to <q>true</q> when invoking JavaCC.</p> |
| 185 |
<pre> |
| 186 |
<javacc target="src/Parser.jj" |
| 187 |
outputdirectory="build/src" |
| 188 |
javacchome="c:/program files/JavaCC" |
| 189 |
static="true"/></pre> |
| 190 |
|
| 191 |
</body> |
| 192 |
</html> |