Package org.codehaus.mojo.javacc
Class JTBJavaCCMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.javacc.AbstractJavaCCMojo
-
- org.codehaus.mojo.javacc.JTBJavaCCMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="jtb-javacc", defaultPhase=GENERATE_SOURCES) public class JTBJavaCCMojo extends AbstractJavaCCMojoPreprocesses ordinary grammar files (
Note: JTB requires Java 1.5 or higher. This goal will not work with earlier versions of the JRE.*.jtb) with JTB and passes the output to JavaCC in order to finally generate a parser with parse tree actions.- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.BooleandescriptiveFieldNamesSetting this option totruecauses JTB to generate field names that reflect the structure of the tree instead of generic names likef0,f1etc.private java.lang.String[]excludesA set of Ant-like exclusion patterns used to prevent certain files from being processing.private java.lang.String[]includesA set of Ant-like inclusion patterns used to select files from the source directory for processing.private java.io.FileinterimDirectoryThe directory where the visitor and AST node files generated by JTB will be stored.private java.lang.BooleanjavadocFriendlyCommentsIftrue, all generated comments will be wrapped in<pre>tags so that they are formatted correctly in API docs.private java.lang.StringnodePackageNameThis option specifies the package for the generated AST nodes.private java.lang.StringnodeParentClassThe qualified name of a user-defined class from which all AST nodes will inherit.private java.io.FileoutputDirectoryThe directory where the parser files generated by JavaCC will be stored.private java.lang.StringpackageNameThis option is short fornodePackageName=<packageName>.syntaxtreeandvisitorPackageName=<packageName>.visitor.private java.lang.BooleanparentPointersIftrue, all nodes will contain fields for its parent node.private java.lang.BooleanprinterIftrue, JTB will generate a syntax tree dumping visitor.private java.lang.BooleanschemeIftrue, JTB will generate the following files to support the Schema programming language: Scheme records representing the grammar. A Scheme tree building visitor. Default value isfalse.private java.io.FilesourceDirectoryThe directory where the JavaCC grammar files (*.jtb) are located.private java.lang.BooleanspecialTokensIftrue, JTB will include JavaCC "special tokens" in the AST.private intstaleMillisThe granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation.private java.lang.BooleansupressErrorCheckingIftrue, JTB will suppress its semantic error checking.private java.lang.StringvisitorPackageNameThis option specifies the package for the generated visitors.
-
Constructor Summary
Constructors Constructor Description JTBJavaCCMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.File[]getCompileSourceRoots()Gets all the output directories to register with the project for compilation.protected java.lang.String[]getExcludes()Gets a set of Ant-like exclusion patterns used to unselect files from the source directory for processing.protected java.lang.String[]getIncludes()Gets a set of Ant-like inclusion patterns used to select files from the source directory for processing.private java.io.FilegetInterimDirectory()Gets the absolute path to the directory where the interim output from JTB will be stored.private java.lang.StringgetNodePackageName()Gets the effective package name for the AST node files.protected java.io.FilegetOutputDirectory()Gets the absolute path to the directory where the generated Java files for the parser will be stored.protected java.io.FilegetSourceDirectory()Gets the absolute path to the directory where the grammar files are located.protected intgetStaleMillis()Gets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.private java.lang.StringgetVisitorPackageName()Gets the effective package name for the visitor files.private JTBnewJTB()Creates a new facade to invoke JTB.protected voidprocessGrammar(GrammarInfo grammarInfo)Passes the specified grammar file through the tool.-
Methods inherited from class org.codehaus.mojo.javacc.AbstractJavaCCMojo
copyGrammarOutput, deleteTempDirectory, execute, getGrammarEncoding, getIsStatic, getJdkVersion, getParserPackage, getTempDirectory, isSourceRoot, newJavaCC
-
-
-
-
Field Detail
-
packageName
@Parameter(property="javacc.packageName") private java.lang.String packageName
This option is short fornodePackageName=<packageName>.syntaxtreeandvisitorPackageName=<packageName>.visitor. Note that this option takes precedence overnodePackageNameandvisitorPackageNameif specified.
-
nodePackageName
@Parameter(property="javacc.nodePackageName") private java.lang.String nodePackageName
This option specifies the package for the generated AST nodes. This value may use a leading asterisk to reference the package of the corresponding parser. For example, if the parser package isorg.apacheand this parameter is set to*.demo, the tree node classes will be located in the packageorg.apache.demo. Default value is*.syntaxtree.
-
visitorPackageName
@Parameter(property="javacc.visitorPackageName") private java.lang.String visitorPackageName
This option specifies the package for the generated visitors. This value may use a leading asterisk to reference the package of the corresponding parser. For example, if the parser package isorg.apacheand this parameter is set to*.demo, the visitor classes will be located in the packageorg.apache.demo. Default value is*.visitor.
-
supressErrorChecking
@Parameter(property="javacc.supressErrorChecking") private java.lang.Boolean supressErrorChecking
Iftrue, JTB will suppress its semantic error checking. Default value isfalse.
-
javadocFriendlyComments
@Parameter(property="javacc.javadocFriendlyComments") private java.lang.Boolean javadocFriendlyComments
Iftrue, all generated comments will be wrapped in<pre>tags so that they are formatted correctly in API docs. Default value isfalse.
-
descriptiveFieldNames
@Parameter(property="javacc.descriptiveFieldNames") private java.lang.Boolean descriptiveFieldNames
Setting this option totruecauses JTB to generate field names that reflect the structure of the tree instead of generic names likef0,f1etc. Default value isfalse.
-
nodeParentClass
@Parameter(property="javacc.nodeParentClass") private java.lang.String nodeParentClass
The qualified name of a user-defined class from which all AST nodes will inherit. By default, AST nodes will inherit from the generated classNode.
-
parentPointers
@Parameter(property="javacc.parentPointers") private java.lang.Boolean parentPointers
Iftrue, all nodes will contain fields for its parent node. Default value isfalse.
-
specialTokens
@Parameter(property="javacc.specialTokens") private java.lang.Boolean specialTokens
Iftrue, JTB will include JavaCC "special tokens" in the AST. Default value isfalse.
-
scheme
@Parameter(property="javacc.scheme") private java.lang.Boolean scheme
Iftrue, JTB will generate the following files to support the Schema programming language:- Scheme records representing the grammar.
- A Scheme tree building visitor.
false.
-
printer
@Parameter(property="javacc.printer") private java.lang.Boolean printer
Iftrue, JTB will generate a syntax tree dumping visitor. Default value isfalse.
-
sourceDirectory
@Parameter(property="javacc.sourceDirectory", defaultValue="${basedir}/src/main/jtb") private java.io.File sourceDirectoryThe directory where the JavaCC grammar files (*.jtb) are located. It will be recursively scanned for input files to pass to JTB. The parametersincludesandexcludescan be used to select a subset of files.
-
interimDirectory
@Parameter(property="javacc.interimDirectory", defaultValue="${project.build.directory}/generated-sources/jtb") private java.io.File interimDirectoryThe directory where the visitor and AST node files generated by JTB will be stored. The directory will be registered as a compile source root of the project such that the generated files will participate in later build phases like compiling and packaging.
-
outputDirectory
@Parameter(property="javacc.outputDirectory", defaultValue="${project.build.directory}/generated-sources/javacc") private java.io.File outputDirectoryThe directory where the parser files generated by JavaCC will be stored. The directory will be registered as a compile source root of the project such that the generated files will participate in later build phases like compiling and packaging.
-
includes
@Parameter private java.lang.String[] includes
A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, the patterns**/*.jj,**/*.JJ,**/*.jtband**/*.JTBare used to select grammar files.
-
excludes
@Parameter private java.lang.String[] excludes
A set of Ant-like exclusion patterns used to prevent certain files from being processing. By default, this set is empty such that no files are excluded.
-
staleMillis
@Parameter(property="javacc.lastModGranularityMs", defaultValue="0") private int staleMillisThe granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation.
-
-
Method Detail
-
getSourceDirectory
protected java.io.File getSourceDirectory()
Gets the absolute path to the directory where the grammar files are located.- Specified by:
getSourceDirectoryin classAbstractJavaCCMojo- Returns:
- The absolute path to the directory where the grammar files are located, never
null.
-
getIncludes
protected java.lang.String[] getIncludes()
Gets a set of Ant-like inclusion patterns used to select files from the source directory for processing.- Specified by:
getIncludesin classAbstractJavaCCMojo- Returns:
- A set of Ant-like inclusion patterns used to select files from the source directory for processing, can
be
nullif all files should be included.
-
getExcludes
protected java.lang.String[] getExcludes()
Gets a set of Ant-like exclusion patterns used to unselect files from the source directory for processing.- Specified by:
getExcludesin classAbstractJavaCCMojo- Returns:
- A set of Ant-like inclusion patterns used to unselect files from the source directory for processing, can
be
nullif no files should be excluded.
-
getOutputDirectory
protected java.io.File getOutputDirectory()
Gets the absolute path to the directory where the generated Java files for the parser will be stored.- Specified by:
getOutputDirectoryin classAbstractJavaCCMojo- Returns:
- The absolute path to the directory where the generated Java files for the parser will be stored, never
null.
-
getStaleMillis
protected int getStaleMillis()
Gets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.- Specified by:
getStaleMillisin classAbstractJavaCCMojo- Returns:
- The granularity in milliseconds of the last modification date for testiintng whether a source needs recompilation.
-
getInterimDirectory
private java.io.File getInterimDirectory()
Gets the absolute path to the directory where the interim output from JTB will be stored.- Returns:
- The absolute path to the directory where the interim output from JTB will be stored.
-
getCompileSourceRoots
protected java.io.File[] getCompileSourceRoots()
Gets all the output directories to register with the project for compilation.- Specified by:
getCompileSourceRootsin classAbstractJavaCCMojo- Returns:
- The compile source roots to register with the project, never
null.
-
processGrammar
protected void processGrammar(GrammarInfo grammarInfo) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
Passes the specified grammar file through the tool.- Specified by:
processGrammarin classAbstractJavaCCMojo- Parameters:
grammarInfo- The grammar info describing the grammar file to process, must not benull.- Throws:
org.apache.maven.plugin.MojoExecutionException- If the invocation of the tool failed.org.apache.maven.plugin.MojoFailureException- If the tool reported a non-zero exit code.
-
getNodePackageName
private java.lang.String getNodePackageName()
Gets the effective package name for the AST node files.- Returns:
- The effective package name for the AST node files, never
null.
-
getVisitorPackageName
private java.lang.String getVisitorPackageName()
Gets the effective package name for the visitor files.- Returns:
- The effective package name for the visitor files, never
null.
-
newJTB
private JTB newJTB()
Creates a new facade to invoke JTB. Most options for the invocation are derived from the current values of the corresponding mojo parameters. The caller is responsible to set the input file, output directories and packages on the returned facade.- Returns:
- The facade for the tool invocation, never
null.
-
-