javacc:jtb-javacc

Full name:

org.codehaus.mojo:javacc-maven-plugin:2.5:jtb-javacc

Description:

Preprocesses ordinary grammar files (*.jtb) with JTB and passes the output to JavaCC in order to finally generate a parser with parse tree actions.

Note:JTB requires Java 1.5 or higher. This goal will not work with earlier versions of the JRE.

Attributes:

  • Requires a Maven 2.0 project to be executed.
  • Since version: 2.4.
  • Binds by default to the lifecycle phase: generate-sources.

Optional Parameters

Name Type Since Description
buildParser Boolean 2.4 A flag that controls whether the parser file (*Parser.java) should be generated or not. If set to false, only the token manager is generated. Default value is true.
buildTokenManager Boolean 2.4 A flag that controls whether the token manager file (*TokenManager.java) should be generated or not. Setting this to false can speed up the generation process if only the parser part of the grammar changed. Default value is true.
cacheTokens Boolean 2.4 Setting this option to true causes the generated parser to lookahead for extra tokens ahead of time. Default value is false.
choiceAmbiguityCheck Integer 2.4 This is the number of tokens considered in checking choices of the form "A | B | ..." for ambiguity. Default value is 2.
commonTokenAction Boolean 2.4 When set to true, every call to the token manager's method getNextToken() (see the description of the Java Compiler Compiler API) will cause a call to a user-defined method CommonTokenAction() after the token has been scanned in by the token manager. Default value is false.
debugLookAhead Boolean 2.4 This is a boolean option whose default value is false. Setting this option to true causes the parser to generate all the tracing information it does when the option debugParser is true, and in addition, also causes it to generated a trace of actions performed during lookahead operation.
debugParser Boolean 2.4 This option is used to obtain debugging information from the generated parser. Setting this option to true causes the parser to generate a trace of its actions. Default value is false.
debugTokenManager Boolean 2.4 This option is used to obtain debugging information from the generated token manager. Default value is false.
descriptiveFieldNames Boolean 2.4 Setting this option to true causes JTB to generate field names that reflect the structure of the tree instead of generic names like f0, f1 etc. Default value is false.
errorReporting Boolean 2.4 Setting it to false causes errors due to parse errors to be reported in somewhat less detail. Default value is true.
excludes String[] 2.4 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.
forceLaCheck Boolean 2.4 This option setting controls lookahead ambiguity checking performed by JavaCC. Default value is false.
ignoreCase Boolean 2.4 Setting this option to true causes the generated token manager to ignore case in the token specifications and the input files. Default value is false.
includes String[] 2.4 A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, the patterns **/*.jj, **/*.JJ, **/*.jtb and **/*.JTB are used to select grammar files.
interimDirectory File 2.4 The 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. Default value is: ${project.build.directory}/generated-sources/jtb.
isStatic Boolean 2.4 If true, all methods and class variables are specified as static in the generated parser and token manager. This allows only one parser object to be present, but it improves the performance of the parser. Default value is true.
javaUnicodeEscape Boolean 2.4 When set to true, the generated parser uses an input stream object that processes Java Unicode escapes (\uxxxx) before sending characters to the token manager. Default value is false.
javadocFriendlyComments Boolean 2.4 If true, all generated comments will be wrapped in <pre> tags so that they are formatted correctly in API docs. Default value is false.
jdkVersion String 2.4 The Java version for which to generate source code. Default value is 1.4.
keepLineColumn Boolean 2.4 A flag whether to keep line and column information along with a token. Default value is true.
lookAhead Integer 2.4 The number of tokens to look ahead before making a decision at a choice point during parsing. The default value is 1.
nodePackageName String 2.4 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 is org.apache and this parameter is set to *.demo, the tree node classes will be located in the package org.apache.demo. Default value is *.syntaxtree.
nodeParentClass String 2.4 The qualified name of a user-defined class from which all AST nodes will inherit. By default, AST nodes will inherit from the generated class Node.
otherAmbiguityCheck Integer 2.4 This is the number of tokens considered in checking all other kinds of choices (i.e., of the forms "(A)*", "(A)+", and "(A)?") for ambiguity. Default value is 1.
outputDirectory File 2.4 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. Default value is: ${project.build.directory}/generated-sources/javacc.
packageName String 2.4 This option is short for nodePackageName = <packageName>.syntaxtree and visitorPackageName = <packageName>.visitor. Note that this option takes precedence over nodePackageName and visitorPackageName if specified.
parentPointers Boolean 2.4 If true, all nodes will contain fields for its parent node. Default value is false.
printer Boolean 2.4 If true, JTB will generate a syntax tree dumping visitor. Default value is false.
sanityCheck Boolean 2.4 Enables/disables many syntactic and semantic checks on the grammar file during parser generation. Default value is true.
scheme Boolean 2.4 If true, JTB will generate the following files to support the Schema programming language:
  • Scheme records representing the grammar.
  • A Scheme tree building visitor.
Default value is false.
sourceDirectory File 2.4 The directory where the JavaCC grammar files (*.jtb) are located. It will be recursively scanned for input files to pass to JTB. The parameters includes and excludes can be used to select a subset of files. Default value is: ${basedir}/src/main/jtb.
specialTokens Boolean 2.4 If true, JTB will include JavaCC "special tokens" in the AST. Default value is false.
staleMillis int 2.4 The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation. Default value is: 0.
supressErrorChecking Boolean 2.4 If true, JTB will suppress its semantic error checking. Default value is false.
tokenExtends String 2.5 The name of the base class for the generated Token class. Default value is java.lang.Object.
tokenFactory String 2.5 The name of a custom factory class used to create Token objects. This class must have a method with the signature public static Token newToken(int ofKind, String image). By default, tokens are created by calling Token.newToken().
tokenManagerUsesParser Boolean 2.4 When set to true, the generated token manager will include a field called parser that references the instantiating parser instance. Default value is false.
unicodeInput Boolean 2.4 When set to true, the generated parser uses uses an input stream object that reads Unicode files. By default, ASCII files are assumed. Default value is false.
userCharStream Boolean 2.4 This flag controls whether the token manager will read characters from a character stream reader as defined by the options javaUnicodeEscape and unicodeInput or whether the token manager reads from a user-supplied implementation of CharStream. Default value is false.
userTokenManager Boolean 2.4 The default action is to generate a token manager that works on the specified grammar tokens. If this option is set to true, then the parser is generated to accept tokens from any token manager of type TokenManager - this interface is generated into the generated parser directory. Default value is false.
visitorPackageName String 2.4 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 is org.apache and this parameter is set to *.demo, the visitor classes will be located in the package org.apache.demo. Default value is *.visitor.

Parameter Details

buildParser:

A flag that controls whether the parser file (*Parser.java) should be generated or not. If set to false, only the token manager is generated. Default value is true.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${buildParser}

buildTokenManager:

A flag that controls whether the token manager file (*TokenManager.java) should be generated or not. Setting this to false can speed up the generation process if only the parser part of the grammar changed. Default value is true.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${buildTokenManager}

cacheTokens:

Setting this option to true causes the generated parser to lookahead for extra tokens ahead of time. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${cacheTokens}

choiceAmbiguityCheck:

This is the number of tokens considered in checking choices of the form "A | B | ..." for ambiguity. Default value is 2.
  • Type: java.lang.Integer
  • Since: 2.4
  • Required: No
  • Expression: ${choiceAmbiguityCheck}

commonTokenAction:

When set to true, every call to the token manager's method getNextToken() (see the description of the Java Compiler Compiler API) will cause a call to a user-defined method CommonTokenAction() after the token has been scanned in by the token manager. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${commonTokenAction}

debugLookAhead:

This is a boolean option whose default value is false. Setting this option to true causes the parser to generate all the tracing information it does when the option debugParser is true, and in addition, also causes it to generated a trace of actions performed during lookahead operation.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${debugLookAhead}

debugParser:

This option is used to obtain debugging information from the generated parser. Setting this option to true causes the parser to generate a trace of its actions. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${debugParser}

debugTokenManager:

This option is used to obtain debugging information from the generated token manager. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${debugTokenManager}

descriptiveFieldNames:

Setting this option to true causes JTB to generate field names that reflect the structure of the tree instead of generic names like f0, f1 etc. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${descriptiveFieldNames}

errorReporting:

Setting it to false causes errors due to parse errors to be reported in somewhat less detail. Default value is true.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${errorReporting}

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.
  • Type: java.lang.String[]
  • Since: 2.4
  • Required: No

forceLaCheck:

This option setting controls lookahead ambiguity checking performed by JavaCC. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${forceLaCheck}

ignoreCase:

Setting this option to true causes the generated token manager to ignore case in the token specifications and the input files. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${ignoreCase}

includes:

A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, the patterns **/*.jj, **/*.JJ, **/*.jtb and **/*.JTB are used to select grammar files.
  • Type: java.lang.String[]
  • Since: 2.4
  • Required: No

interimDirectory:

The 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.
  • Type: java.io.File
  • Since: 2.4
  • Required: No
  • Expression: ${interimDirectory}
  • Default: ${project.build.directory}/generated-sources/jtb

isStatic:

If true, all methods and class variables are specified as static in the generated parser and token manager. This allows only one parser object to be present, but it improves the performance of the parser. Default value is true.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${isStatic}

javaUnicodeEscape:

When set to true, the generated parser uses an input stream object that processes Java Unicode escapes (\uxxxx) before sending characters to the token manager. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${javaUnicodeEscape}

javadocFriendlyComments:

If true, all generated comments will be wrapped in <pre> tags so that they are formatted correctly in API docs. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${javadocFriendlyComments}

jdkVersion:

The Java version for which to generate source code. Default value is 1.4.
  • Type: java.lang.String
  • Since: 2.4
  • Required: No
  • Expression: ${jdkVersion}

keepLineColumn:

A flag whether to keep line and column information along with a token. Default value is true.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${keepLineColumn}

lookAhead:

The number of tokens to look ahead before making a decision at a choice point during parsing. The default value is 1.
  • Type: java.lang.Integer
  • Since: 2.4
  • Required: No
  • Expression: ${lookAhead}

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 is org.apache and this parameter is set to *.demo, the tree node classes will be located in the package org.apache.demo. Default value is *.syntaxtree.
  • Type: java.lang.String
  • Since: 2.4
  • Required: No
  • Expression: ${nodePackageName}

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 class Node.
  • Type: java.lang.String
  • Since: 2.4
  • Required: No
  • Expression: ${nodeParentClass}

otherAmbiguityCheck:

This is the number of tokens considered in checking all other kinds of choices (i.e., of the forms "(A)*", "(A)+", and "(A)?") for ambiguity. Default value is 1.
  • Type: java.lang.Integer
  • Since: 2.4
  • Required: No
  • Expression: ${otherAmbiguityCheck}

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.
  • Type: java.io.File
  • Since: 2.4
  • Required: No
  • Expression: ${outputDirectory}
  • Default: ${project.build.directory}/generated-sources/javacc

packageName:

This option is short for nodePackageName = <packageName>.syntaxtree and visitorPackageName = <packageName>.visitor. Note that this option takes precedence over nodePackageName and visitorPackageName if specified.
  • Type: java.lang.String
  • Since: 2.4
  • Required: No
  • Expression: ${package}

parentPointers:

If true, all nodes will contain fields for its parent node. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${parentPointers}

printer:

If true, JTB will generate a syntax tree dumping visitor. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${printer}

sanityCheck:

Enables/disables many syntactic and semantic checks on the grammar file during parser generation. Default value is true.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${sanityCheck}

scheme:

If true, JTB will generate the following files to support the Schema programming language:
  • Scheme records representing the grammar.
  • A Scheme tree building visitor.
Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${scheme}

sourceDirectory:

The directory where the JavaCC grammar files (*.jtb) are located. It will be recursively scanned for input files to pass to JTB. The parameters includes and excludes can be used to select a subset of files.
  • Type: java.io.File
  • Since: 2.4
  • Required: No
  • Expression: ${sourceDirectory}
  • Default: ${basedir}/src/main/jtb

specialTokens:

If true, JTB will include JavaCC "special tokens" in the AST. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${specialTokens}

staleMillis:

The granularity in milliseconds of the last modification date for testing whether a grammar file needs recompilation.
  • Type: int
  • Since: 2.4
  • Required: No
  • Expression: ${lastModGranularityMs}
  • Default: 0

supressErrorChecking:

If true, JTB will suppress its semantic error checking. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${supressErrorChecking}

tokenExtends:

The name of the base class for the generated Token class. Default value is java.lang.Object.
  • Type: java.lang.String
  • Since: 2.5
  • Required: No
  • Expression: ${tokenExtends}

tokenFactory:

The name of a custom factory class used to create Token objects. This class must have a method with the signature public static Token newToken(int ofKind, String image). By default, tokens are created by calling Token.newToken().
  • Type: java.lang.String
  • Since: 2.5
  • Required: No
  • Expression: ${tokenFactory}

tokenManagerUsesParser:

When set to true, the generated token manager will include a field called parser that references the instantiating parser instance. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${tokenManagerUsesParser}

unicodeInput:

When set to true, the generated parser uses uses an input stream object that reads Unicode files. By default, ASCII files are assumed. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${unicodeInput}

userCharStream:

This flag controls whether the token manager will read characters from a character stream reader as defined by the options javaUnicodeEscape and unicodeInput or whether the token manager reads from a user-supplied implementation of CharStream. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${userCharStream}

userTokenManager:

The default action is to generate a token manager that works on the specified grammar tokens. If this option is set to true, then the parser is generated to accept tokens from any token manager of type TokenManager - this interface is generated into the generated parser directory. Default value is false.
  • Type: java.lang.Boolean
  • Since: 2.4
  • Required: No
  • Expression: ${userTokenManager}

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 is org.apache and this parameter is set to *.demo, the visitor classes will be located in the package org.apache.demo. Default value is *.visitor.
  • Type: java.lang.String
  • Since: 2.4
  • Required: No
  • Expression: ${visitorPackageName}