Package org.codehaus.mojo.javacc
Class JJTreeJavaCCMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.javacc.AbstractJavaCCMojo
org.codehaus.mojo.javacc.JJTreeJavaCCMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="jjtree-javacc",
defaultPhase=GENERATE_SOURCES,
threadSafe=true)
public class JJTreeJavaCCMojo
extends AbstractJavaCCMojo
Preprocesses decorated grammar files (
*.jjt
) with JJTree and passes the output to JavaCC in order to
finally generate a parser with parse tree actions.- Since:
- 2.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Boolean
A flag whether to generate sample implementations forSimpleNode
and any other nodes used in the grammar.private String[]
A set of Ant-like exclusion patterns used to prevent certain files from being processed.private String[]
A set of Ant-like inclusion patterns used to select files from the source directory for processing.private File
The directory where the AST node files generated by JJTree will be stored.private Boolean
A flag whether to generate a multi mode parse tree or a single mode parse tree.private String
The name of a custom class that extendsSimpleNode
and will be used as the super class for the generated tree node classes.private Boolean
A flag whether to make each non-decorated production void instead of an indefinite node.private String
The name of a custom factory class used to createNode
objects.private String
The package to generate the AST node classes into.private String
The prefix used to construct node class names from node identifiers in multi mode.private Boolean
A flag whether user-defined parser methods should be called on entry and exit of every node scope.private Boolean
A flag whether the node construction routines need an additional method parameter to receive the parser object.private File
The directory where the parser files generated by JavaCC will be stored.private File
The directory where the decorated JavaCC grammar files (*.jjt
) are located.private int
The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation.private Boolean
A flag whether to insert the methodsjjtGetFirstToken()
,jjtSetFirstToken()
,getLastToken()
andjjtSetLastToken()
into the classSimpleNode
.private Boolean
A flag whether to insert ajjtAccept()
method in the node classes and to generate a visitor implementation with an entry for every node type used in the grammar.private String
The name of a class to use for the data argument of thejjtAccept()
andvisit()
methods.private String
The name of an exception class to include in the signature of the generatedjjtAccept()
andvisit()
methods.private String
The name of a class to use as the return type of thejjtAccept()
andvisit()
methods.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected File[]
Gets all the output directories to register with the project for compilation.protected String[]
Gets a set of Ant-like exclusion patterns used to unselect files from the source directory for processing.protected String[]
Gets a set of Ant-like inclusion patterns used to select files from the source directory for processing.private File
Gets the absolute path to the directory where the interim output from JJTree will be stored.protected File
Gets the absolute path to the directory where the generated Java files for the parser will be stored.protected File
Gets the absolute path to the directory where the grammar files are located.protected int
Gets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.protected JJTree
Creates a new facade to invoke JJTree.protected void
processGrammar
(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
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
buildNodeFiles
A flag whether to generate sample implementations forSimpleNode
and any other nodes used in the grammar. Default value istrue
. -
multi
A flag whether to generate a multi mode parse tree or a single mode parse tree. Default value isfalse
. -
nodeDefaultVoid
A flag whether to make each non-decorated production void instead of an indefinite node. Default value isfalse
. -
nodeClass
The name of a custom class that extendsSimpleNode
and will be used as the super class for the generated tree node classes. By default, the tree node classes will directly extend the classSimpleNode
.- Since:
- 2.5
-
nodeFactory
The name of a custom factory class used to createNode
objects. This class must have a method with the signaturepublic static Node jjtCreate(int id)
. By default, the classSimpleNode
will be used as the factory class. -
nodePackage
The package to generate the AST node classes into. This value may use a leading asterisk to reference the package of the corresponding parser. For example, if the parser package isorg.apache
and this parameter is set to*.node
, the tree node classes will be located in the packageorg.apache.node
. By default, the package of the corresponding parser is used. -
nodePrefix
The prefix used to construct node class names from node identifiers in multi mode. Default value isAST
. -
nodeScopeHook
A flag whether user-defined parser methods should be called on entry and exit of every node scope. Default value isfalse
. -
nodeUsesParser
A flag whether the node construction routines need an additional method parameter to receive the parser object. Default value isfalse
. -
trackTokens
A flag whether to insert the methodsjjtGetFirstToken()
,jjtSetFirstToken()
,getLastToken()
andjjtSetLastToken()
into the classSimpleNode
. Default value isfalse
.- Since:
- 2.5
-
visitor
A flag whether to insert ajjtAccept()
method in the node classes and to generate a visitor implementation with an entry for every node type used in the grammar. Default value isfalse
. -
visitorDataType
The name of a class to use for the data argument of thejjtAccept()
andvisit()
methods. Default value isjava.lang.Object
.- Since:
- 2.5
-
visitorReturnType
The name of a class to use as the return type of thejjtAccept()
andvisit()
methods. Default value isjava.lang.Object
.- Since:
- 2.5
-
visitorException
The name of an exception class to include in the signature of the generatedjjtAccept()
andvisit()
methods. By default, thethrows
clause of the generated methods is empty such that only unchecked exceptions can be thrown. -
sourceDirectory
@Parameter(property="javacc.sourceDirectory", defaultValue="${basedir}/src/main/jjtree") private File sourceDirectoryThe directory where the decorated JavaCC grammar files (*.jjt
) are located. It will be recursively scanned for input files to pass to JJTree. The parametersincludes
andexcludes
can be used to select a subset of files. -
interimDirectory
@Parameter(property="javacc.interimDirectory", defaultValue="${project.build.directory}/generated-sources/jjtree") private File interimDirectoryThe directory where the AST node files generated by JJTree 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 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
A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, the patterns**/*.jj
,**/*.JJ
,**/*.jjt
and**/*.JJT
are used to select grammar files. -
excludes
A set of Ant-like exclusion patterns used to prevent certain files from being processed. 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.
-
-
Constructor Details
-
JJTreeJavaCCMojo
public JJTreeJavaCCMojo()
-
-
Method Details
-
getSourceDirectory
Gets the absolute path to the directory where the grammar files are located.- Specified by:
getSourceDirectory
in classAbstractJavaCCMojo
- Returns:
- The absolute path to the directory where the grammar files are located, never
null
.
-
getIncludes
Gets a set of Ant-like inclusion patterns used to select files from the source directory for processing.- Specified by:
getIncludes
in classAbstractJavaCCMojo
- Returns:
- A set of Ant-like inclusion patterns used to select files from the source directory for processing, can
be
null
if all files should be included.
-
getExcludes
Gets a set of Ant-like exclusion patterns used to unselect files from the source directory for processing.- Specified by:
getExcludes
in classAbstractJavaCCMojo
- Returns:
- A set of Ant-like inclusion patterns used to unselect files from the source directory for processing, can
be
null
if no files should be excluded.
-
getOutputDirectory
Gets the absolute path to the directory where the generated Java files for the parser will be stored.- Specified by:
getOutputDirectory
in 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:
getStaleMillis
in classAbstractJavaCCMojo
- Returns:
- The granularity in milliseconds of the last modification date for testiintng whether a source needs recompilation.
-
getInterimDirectory
Gets the absolute path to the directory where the interim output from JJTree will be stored.- Returns:
- The absolute path to the directory where the interim output from JJTree will be stored.
-
getCompileSourceRoots
Gets all the output directories to register with the project for compilation.- Specified by:
getCompileSourceRoots
in 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:
processGrammar
in 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.
-
newJJTree
Creates a new facade to invoke JJTree. 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 directory and package on the returned facade.- Returns:
- The facade for the tool invocation, never
null
.
-