## JavaCC

### Description

Invokes the JavaCC compiler compiler on a grammar file.

To use the `javacc` task, set the target attribute to the name of the grammar file to process. You also need to specify the directory containing the JavaCC installation using the javacchome attribute, so that Apache Ant can find the JavaCC classes. Optionally, you can also set the outputdirectory to write the generated file to a specific directory. Otherwise JavaCC writes the generated files to the directory containing the grammar file.

This task only invokes JavaCC if the grammar file is newer than the generated `.java` files. JavaCC assumes that the Java class name of the generated parser is the same as the name of the grammar file, ignoring the `.jj`. If this is not the case, the `javacc` task will still work, but it will always generate the output files.

### Parameters

Attribute | Description | Required
--- | --- | ---
target | The grammar file to process. | Yes
javacchome | The directory containing the JavaCC distribution. | 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
buildparser | Sets the BUILD_PARSER grammar option. This is a boolean option. | No
buildtokenmanager | Sets the BUILD_TOKEN_MANAGER grammar option. This is a boolean option. | No
cachetokens | Sets the CACHE_TOKENS grammar option. This is a boolean option. | No
choiceambiguitycheck | Sets the CHOICE_AMBIGUITY_CHECK grammar option. This is an integer option. | No
commontokenaction | Sets the COMMON_TOKEN_ACTION grammar option. This is a boolean option. | No
debuglookahead | Sets the DEBUG_LOOKAHEAD grammar option. This is a boolean option. | No
debugparser | Sets the DEBUG_PARSER grammar option. This is a boolean option. | No
debugtokenmanager | Sets the DEBUG_TOKEN_MANAGER grammar option. This is a boolean option. | No
errorreporting | Sets the ERROR_REPORTING grammar option. This is a boolean option. | No
forcelacheck | Sets the FORCE_LA_CHECK grammar option. This is a boolean option. | No
ignorecase | Sets the IGNORE_CASE grammar option. This is a boolean option. | No
javaunicodeescape | Sets the JAVA_UNICODE_ESCAPE grammar option. This is a boolean option. | No
jdkversion | Sets the JDK_VERSION option. This is a string option. | No
keeplinecolumn | Sets the KEEP_LINE_COLUMN grammar option. This is a boolean option. | No
lookahead | Sets the LOOKAHEAD grammar option. This is an integer option. | No
optimizetokenmanager | Sets the OPTIMIZE_TOKEN_MANAGER grammar option. This is a boolean option. | No
otherambiguitycheck | Sets the OTHER_AMBIGUITY_CHECK grammar option. This is an integer option. | No
sanitycheck | Sets the SANITY_CHECK grammar option. This is a boolean option. | No
static | Sets the STATIC grammar option. This is a boolean option. | No
unicodeinput | Sets the UNICODE_INPUT grammar option. This is a boolean option. | No
usercharstream | Sets the USER_CHAR_STREAM grammar option. This is a boolean option. | No
usertokenmanager | Sets the USER_TOKEN_MANAGER grammar option. This is a boolean option. | No
maxmemory | Max amount of memory to allocate to the forked JVM. since Ant 1.8.3 | No

### Example

Invoke JavaCC on grammar file `src/Parser.jj`, writing the generated files to `build/src`. The grammar option STATIC is set to true when invoking JavaCC.

    <javacc target="src/Parser.jj"
            outputdirectory="build/src"
            javacchome="c:/program files/JavaCC"
            static="true"/>