Class JJTreeJavaCCMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    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
    Version:
    $Id: JJTreeJavaCCMojo.java 10603 2009-09-06 15:05:08Z bentmann $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Boolean buildNodeFiles
      A flag whether to generate sample implementations for SimpleNode and any other nodes used in the grammar.
      private java.lang.String[] excludes
      A set of Ant-like exclusion patterns used to prevent certain files from being processed.
      private java.lang.String[] includes
      A set of Ant-like inclusion patterns used to select files from the source directory for processing.
      private java.io.File interimDirectory
      The directory where the AST node files generated by JJTree will be stored.
      private java.lang.Boolean multi
      A flag whether to generate a multi mode parse tree or a single mode parse tree.
      private java.lang.String nodeClass
      The name of a custom class that extends SimpleNode and will be used as the super class for the generated tree node classes.
      private java.lang.Boolean nodeDefaultVoid
      A flag whether to make each non-decorated production void instead of an indefinite node.
      private java.lang.String nodeFactory
      The name of a custom factory class used to create Node objects.
      private java.lang.String nodePackage
      The package to generate the AST node classes into.
      private java.lang.String nodePrefix
      The prefix used to construct node class names from node identifiers in multi mode.
      private java.lang.Boolean nodeScopeHook
      A flag whether user-defined parser methods should be called on entry and exit of every node scope.
      private java.lang.Boolean nodeUsesParser
      A flag whether the node construction routines need an additional method parameter to receive the parser object.
      private java.io.File outputDirectory
      The directory where the parser files generated by JavaCC will be stored.
      private java.io.File sourceDirectory
      The directory where the decorated JavaCC grammar files (*.jjt) are located.
      private int staleMillis
      The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation.
      private java.lang.Boolean trackTokens
      A flag whether to insert the methods jjtGetFirstToken(), jjtSetFirstToken(), getLastToken() and jjtSetLastToken() into the class SimpleNode.
      private java.lang.Boolean visitor
      A flag whether to insert a jjtAccept() method in the node classes and to generate a visitor implementation with an entry for every node type used in the grammar.
      private java.lang.String visitorDataType
      The name of a class to use for the data argument of the jjtAccept() and visit() methods.
      private java.lang.String visitorException
      The name of an exception class to include in the signature of the generated jjtAccept() and visit() methods.
      private java.lang.String visitorReturnType
      The name of a class to use as the return type of the jjtAccept() and visit() methods.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • 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.File getInterimDirectory()
      Gets the absolute path to the directory where the interim output from JJTree will be stored.
      protected java.io.File getOutputDirectory()
      Gets the absolute path to the directory where the generated Java files for the parser will be stored.
      protected java.io.File getSourceDirectory()
      Gets the absolute path to the directory where the grammar files are located.
      protected int getStaleMillis()
      Gets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.
      protected JJTree newJJTree()
      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.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buildNodeFiles

        private java.lang.Boolean buildNodeFiles
        A flag whether to generate sample implementations for SimpleNode and any other nodes used in the grammar. Default value is true.
      • multi

        private java.lang.Boolean multi
        A flag whether to generate a multi mode parse tree or a single mode parse tree. Default value is false.
      • nodeDefaultVoid

        private java.lang.Boolean nodeDefaultVoid
        A flag whether to make each non-decorated production void instead of an indefinite node. Default value is false.
      • nodeClass

        private java.lang.String nodeClass
        The name of a custom class that extends SimpleNode and will be used as the super class for the generated tree node classes. By default, the tree node classes will directly extend the class SimpleNode.
        Since:
        2.5
      • nodeFactory

        private java.lang.String nodeFactory
        The name of a custom factory class used to create Node objects. This class must have a method with the signature public static Node jjtCreate(int id). By default, the class SimpleNode will be used as the factory class.
      • nodePackage

        private java.lang.String 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 is org.apache and this parameter is set to *.node, the tree node classes will be located in the package org.apache.node. By default, the package of the corresponding parser is used.
      • nodePrefix

        private java.lang.String nodePrefix
        The prefix used to construct node class names from node identifiers in multi mode. Default value is AST.
      • nodeScopeHook

        private java.lang.Boolean nodeScopeHook
        A flag whether user-defined parser methods should be called on entry and exit of every node scope. Default value is false.
      • nodeUsesParser

        private java.lang.Boolean nodeUsesParser
        A flag whether the node construction routines need an additional method parameter to receive the parser object. Default value is false.
      • trackTokens

        private java.lang.Boolean trackTokens
        A flag whether to insert the methods jjtGetFirstToken(), jjtSetFirstToken(), getLastToken() and jjtSetLastToken() into the class SimpleNode. Default value is false.
        Since:
        2.5
      • visitor

        private java.lang.Boolean visitor
        A flag whether to insert a jjtAccept() method in the node classes and to generate a visitor implementation with an entry for every node type used in the grammar. Default value is false.
      • visitorDataType

        private java.lang.String visitorDataType
        The name of a class to use for the data argument of the jjtAccept() and visit() methods. Default value is java.lang.Object.
        Since:
        2.5
      • visitorReturnType

        private java.lang.String visitorReturnType
        The name of a class to use as the return type of the jjtAccept() and visit() methods. Default value is java.lang.Object.
        Since:
        2.5
      • visitorException

        private java.lang.String visitorException
        The name of an exception class to include in the signature of the generated jjtAccept() and visit() methods. By default, the throws clause of the generated methods is empty such that only unchecked exceptions can be thrown.
      • sourceDirectory

        private java.io.File sourceDirectory
        The directory where the decorated JavaCC grammar files (*.jjt) are located. It will be recursively scanned for input files to pass to JJTree. The parameters includes and excludes can be used to select a subset of files.
      • interimDirectory

        private java.io.File interimDirectory
        The 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

        private java.io.File outputDirectory
        The 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

        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, **/*.jjt and **/*.JJT are used to select grammar files.
      • excludes

        private java.lang.String[] 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

        private int staleMillis
        The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation.
    • Constructor Detail

      • JJTreeJavaCCMojo

        public JJTreeJavaCCMojo()
    • Method Detail

      • getSourceDirectory

        protected java.io.File getSourceDirectory()
        Gets the absolute path to the directory where the grammar files are located.
        Specified by:
        getSourceDirectory in class AbstractJavaCCMojo
        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:
        getIncludes in class AbstractJavaCCMojo
        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

        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:
        getExcludes in class AbstractJavaCCMojo
        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

        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:
        getOutputDirectory in class AbstractJavaCCMojo
        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 class AbstractJavaCCMojo
        Returns:
        The granularity in milliseconds of the last modification date for testing whether a source needs recompilation.
      • getInterimDirectory

        private java.io.File 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

        protected java.io.File[] getCompileSourceRoots()
        Gets all the output directories to register with the project for compilation.
        Specified by:
        getCompileSourceRoots in class AbstractJavaCCMojo
        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 class AbstractJavaCCMojo
        Parameters:
        grammarInfo - The grammar info describing the grammar file to process, must not be null.
        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

        protected JJTree 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.