JavaCC Maven Plugin

This plugin uses the JavaCC parser generator to process JavaCC grammar files and generate the appropriate Java source files. For general information about JavaCC, see the JavaCC web site.

JavaCC grammar files use the extension .jj . This plugin can be used to locate and process all grammar files within a specified directory. Java source files will be written to a common generated-sources output directory, typically located in the build output directory. By default, the plugin will run during the generate-sources phase, but it can be configured to run in other phases as well.

The plugin can also be be used to call the JJTree and JTB tools. JJTree is a preprocessor for JavaCC that inserts parse tree building actions at various places in the JavaCC source. More information about JJTree can be found on the JJTree site.

JTB (Java Tree Builder) is another syntax tree builder. Just like JJTree, it works as a preprocessor for JavaCC grammar files and inserts code to build syntax trees from a parsed input stream. More information about JTB in general and a feature comparison with JJTree can be found on the JTB web site.

Finally, this plugin contains a goal for running JJDoc. JJDoc is a simple tool that generates BNF documentation for the JavaCC grammar files. This can be used to generate a report for your project site using the Maven reporting tools.

Goals Overview

The following goals are meant to participate in the default build lifecycle:

  • javacc:javacc
    Runs JavaCC on grammar files (*.jj ) to generate a Java parser.
  • javacc:jjtree-javacc
    Runs JJTree and JavaCC in a pipeline to process annotated grammar files (*.jjt ).
  • javacc:jjtree
    Deprecated. Preprocesses annotated grammar files (*.jjt ) with JJTree.
  • javacc:jtb-javacc
    Runs JTB and JavaCC in a pipeline to process ordinary grammar files (*.jtb ).
  • javacc:jtb
    Deprecated. Preprocesses ordinary grammar files (*.jtb ) with JTB.

This last goal is intended for usage with the site lifecycle:

  • javacc:jjdoc
    Generates BNF documentation from the grammar files for usage as a site report.

Usage

This plugin is normally used before Java compilation, during the generate-sources phase of a build. Detailed instructions on how to use the JavaCC Maven Plugin can be found on the usage page .

Examples

To provide you with better understanding of some usages of the JavaCC Plugin, you can take a look into the following examples: