Full name:

net.sourceforge.czt.dev:cup-maven-plugin:1.6-SNAPSHOT:generate

Description:

Goal which generates parser source files from the given CUP parser specifications (*.cup).

Can be configured using all standalone CUP parser generator options.

Attributes:

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

Optional Parameters

Name Type Since Description
className String - Generated parser class name.

Output parser and action code into a file (and class) with the given name. If not given, CUP file name will be used as the class name.


User property is: cup.className.
compactRed boolean - Including this option enables a table compaction optimization involving reductions. In particular, it allows the most common reduce entry in each row of the parse action table to be used as the default for that row. This typically saves considerable room in the tables, which can grow to be very large. This optimization has the effect of replacing all error entries in a row with the default reduce entry. While this may sound dangerous, if not down right incorrect, it turns out that this does not affect the correctness of the parser. In particular, some changes of this type are inherent in LALR parsers (when compared to canonical LR parsers), and the resulting parsers will still never read past the first token at which the error could be detected. The parser can, however, make extra erroneous reduces before detecting the error, so this can degrade the parser's ability to do error recovery. (Refer to reference [2] pp. 244-247 or reference [3] pp. 190-194 for a complete explanation of this compaction technique.)

This option is typically used to work-around the java bytecode limitations on table initialization code sizes. However, CUP 0.10h introduced a string-encoding for the parser tables which is not subject to the standard method-size limitations. Consequently, use of this option should no longer be required for large grammars.


Default value is: false.
User property is: cup.compactRed.
debug boolean - Output internal debugging information about the system as it runs.
Default value is: false.
User property is: cup.debug.
dumpGrammar boolean - Output a human readable dump of the grammar.
Default value is: false.
User property is: cup.dumpGrammar.
dumpStates boolean - Output a human readable dump of the constructed parse states (often needed to resolve parse conflicts).
Default value is: false.
User property is: cup.dumpStates.
dumpTables boolean - Output a human readable dump of the parse tables (rarely needed).
Default value is: false.
User property is: cup.dumpTables.
expectedConflicts int - During parser construction the system may detect that an ambiguous situation would occur at runtime. This is called a conflict. In general, the parser may be unable to decide whether to shift (read another symbol) or reduce (replace the recognized right hand side of a production with its left hand side). This is called a shift/reduce conflict. Similarly, the parser may not be able to decide between reduction with two different productions. This is called a reduce/reduce conflict. Normally, if one or more of these conflicts occur, parser generation is aborted. However, in certain carefully considered cases it may be advantageous to arbitrarily break such a conflict. In this case CUP uses YACC convention and resolves shift/reduce conflicts by shifting, and reduce/reduce conflicts using the "highest priority" production (the one declared first in the specification). In order to enable automatic breaking of conflicts the -expect option must be given indicating exactly how many conflicts are expected. Conflicts resolved by precedences and associativities are not reported.
Default value is: 0.
User property is: cup.expectedConflicts.
externalTables boolean - Output parser tables to external files.

The external parser tables are normally encoded in the generated parser file. This option allows outputting them to an external file, which is loaded by the generated parser during runtime. The files are named as the parser tables, e.g. "action_table.dat".

If the parser tables are too large, they are always written to an external file, despite this option here. This is to avoid "code too large" Java compilation errors, caused by the initialisation code (the parser table String) being too large. This option allows outputting all tables to external files, thus minimising parser class footprint.


Default value is: false.
User property is: cup.externalTables.
noPositions boolean - Do not generate code to propagate the left and right hand values of terminals to non-terminals, and then from non-terminals to other terminals. If the left and right values aren't going to be used by the parser, then it will save some runtime computation to not generate these position propagations. This option also keeps the left and right label variables from being generated, so any reference to these will cause an error.
Default value is: false.
User property is: cup.noPositions.
noScanner boolean - Suppress Scanner references.

CUP 0.10j introduced improved scanner integration and a new interface, Scanner. By default, the generated parser refers to this interface, which means you cannot use these parsers with CUP runtimes older than 0.10j. If your parser does not use the new scanner integration features, then you may suppress the Scanner references and allow compatibility with old runtimes. Not many people should have reason to do this.


Default value is: false.
User property is: cup.noScanner.
noSummary boolean - Suppress printing a summary listing such things as the number of terminals, non-terminals, parse states, etc. at the end of the generation.
Default value is: false.
User property is: cup.noSummary.
noWarn boolean - Suppress all warning messages (as opposed to error messages) produced by the system.
Default value is: false.
User property is: cup.noWarn.
nontermsToSymbols boolean - Place constants for non-terminals into the symbol constant class. The parser does not need these symbol constants, so they are not normally output. However, it can be very helpful to refer to these constants when debugging a generated parser.
Default value is: false.
User property is: cup.nontermsToSymbols.
outputDirectory File - The directory where CUP should generate parser and symbol files.
Default value is: ${project.build.directory}/generated-sources/cup.
User property is: cup.outputDirectory.
packageName String - Package name.

Specify that the parser and sym classes are to be placed in the named package. By default, no package specification is put in the generated code (hence the classes default to the special "unnamed" package).


User property is: cup.packageName.
showProgress boolean - Print short messages indicating progress through various parts of the parser generation process.
Default value is: false.
User property is: cup.showProgress.
sourceDirectory File - The directory containing CUP specification files (*.cup).
Default value is: ${project.basedir}/src/main/cup.
User property is: cup.sourceDirectory.
suppressGeneratedJavaWarningsUnchecked boolean - Suppress Java warnings in parser generated code locally when needed.

CUP produces generic Java code, some of which doesn't get used. For instance, the left/right integer location information for every terminal in productions are always generated, even if they are never used. This creates a series of unused warnings that need removing. Another example is when some of the terminal symbols contain elements with generic types. This creates unchecked warnings at various places where such generic non-terminal types appear. At this stage it is needed to add an unchecked cast warning suppression.

By default this flag is false, and all warnings are added. If set to true, our specific warning suppression is added instead. Warning suppression is added locally, so as to not hide any dead code or unchecked warning from user code. This is a local warning suppression.


Default value is: false.
User property is: cup.suppressGeneratedJavaWarningsUnchecked.
suppressGeneratedJavaWarningsUnused boolean - Suppress Java warnings in parser generated code globally.

Suppress any unused code warnings from CUP action class globally. TODO: make it local to each left/right assignment eventually


Default value is: false.
User property is: cup.suppressGeneratedJavaWarningsUnused.
symbolsInterface boolean - Outputs the symbol constant code as an interface rather than as a class.
Default value is: false.
User property is: cup.symbolsInterface.
symbolsName String - Generated symbols class name.

Output the symbol constant code into a class with the given name instead of the default of "Sym".


Default value is: Sym.
User property is: cup.symbolsName.
timeSummary boolean - Add detailed timing statistics to the normal summary of results.
Default value is: false.
User property is: cup.timeSummary.
typeArgs String - Specify type arguments for parser class.
User property is: cup.typeArgs.

Parameter Details

className:

Generated parser class name.

Output parser and action code into a file (and class) with the given name. If not given, CUP file name will be used as the class name.

  • Type: java.lang.String
  • Required: No
  • User Property: cup.className

compactRed:

Including this option enables a table compaction optimization involving reductions. In particular, it allows the most common reduce entry in each row of the parse action table to be used as the default for that row. This typically saves considerable room in the tables, which can grow to be very large. This optimization has the effect of replacing all error entries in a row with the default reduce entry. While this may sound dangerous, if not down right incorrect, it turns out that this does not affect the correctness of the parser. In particular, some changes of this type are inherent in LALR parsers (when compared to canonical LR parsers), and the resulting parsers will still never read past the first token at which the error could be detected. The parser can, however, make extra erroneous reduces before detecting the error, so this can degrade the parser's ability to do error recovery. (Refer to reference [2] pp. 244-247 or reference [3] pp. 190-194 for a complete explanation of this compaction technique.)

This option is typically used to work-around the java bytecode limitations on table initialization code sizes. However, CUP 0.10h introduced a string-encoding for the parser tables which is not subject to the standard method-size limitations. Consequently, use of this option should no longer be required for large grammars.

  • Type: boolean
  • Required: No
  • User Property: cup.compactRed
  • Default: false

debug:

Output internal debugging information about the system as it runs.
  • Type: boolean
  • Required: No
  • User Property: cup.debug
  • Default: false

dumpGrammar:

Output a human readable dump of the grammar.
  • Type: boolean
  • Required: No
  • User Property: cup.dumpGrammar
  • Default: false

dumpStates:

Output a human readable dump of the constructed parse states (often needed to resolve parse conflicts).
  • Type: boolean
  • Required: No
  • User Property: cup.dumpStates
  • Default: false

dumpTables:

Output a human readable dump of the parse tables (rarely needed).
  • Type: boolean
  • Required: No
  • User Property: cup.dumpTables
  • Default: false

expectedConflicts:

During parser construction the system may detect that an ambiguous situation would occur at runtime. This is called a conflict. In general, the parser may be unable to decide whether to shift (read another symbol) or reduce (replace the recognized right hand side of a production with its left hand side). This is called a shift/reduce conflict. Similarly, the parser may not be able to decide between reduction with two different productions. This is called a reduce/reduce conflict. Normally, if one or more of these conflicts occur, parser generation is aborted. However, in certain carefully considered cases it may be advantageous to arbitrarily break such a conflict. In this case CUP uses YACC convention and resolves shift/reduce conflicts by shifting, and reduce/reduce conflicts using the "highest priority" production (the one declared first in the specification). In order to enable automatic breaking of conflicts the -expect option must be given indicating exactly how many conflicts are expected. Conflicts resolved by precedences and associativities are not reported.
  • Type: int
  • Required: No
  • User Property: cup.expectedConflicts
  • Default: 0

externalTables:

Output parser tables to external files.

The external parser tables are normally encoded in the generated parser file. This option allows outputting them to an external file, which is loaded by the generated parser during runtime. The files are named as the parser tables, e.g. "action_table.dat".

If the parser tables are too large, they are always written to an external file, despite this option here. This is to avoid "code too large" Java compilation errors, caused by the initialisation code (the parser table String) being too large. This option allows outputting all tables to external files, thus minimising parser class footprint.

  • Type: boolean
  • Required: No
  • User Property: cup.externalTables
  • Default: false

noPositions:

Do not generate code to propagate the left and right hand values of terminals to non-terminals, and then from non-terminals to other terminals. If the left and right values aren't going to be used by the parser, then it will save some runtime computation to not generate these position propagations. This option also keeps the left and right label variables from being generated, so any reference to these will cause an error.
  • Type: boolean
  • Required: No
  • User Property: cup.noPositions
  • Default: false

noScanner:

Suppress Scanner references.

CUP 0.10j introduced improved scanner integration and a new interface, Scanner. By default, the generated parser refers to this interface, which means you cannot use these parsers with CUP runtimes older than 0.10j. If your parser does not use the new scanner integration features, then you may suppress the Scanner references and allow compatibility with old runtimes. Not many people should have reason to do this.

  • Type: boolean
  • Required: No
  • User Property: cup.noScanner
  • Default: false

noSummary:

Suppress printing a summary listing such things as the number of terminals, non-terminals, parse states, etc. at the end of the generation.
  • Type: boolean
  • Required: No
  • User Property: cup.noSummary
  • Default: false

noWarn:

Suppress all warning messages (as opposed to error messages) produced by the system.
  • Type: boolean
  • Required: No
  • User Property: cup.noWarn
  • Default: false

nontermsToSymbols:

Place constants for non-terminals into the symbol constant class. The parser does not need these symbol constants, so they are not normally output. However, it can be very helpful to refer to these constants when debugging a generated parser.
  • Type: boolean
  • Required: No
  • User Property: cup.nontermsToSymbols
  • Default: false

outputDirectory:

The directory where CUP should generate parser and symbol files.
  • Type: java.io.File
  • Required: No
  • User Property: cup.outputDirectory
  • Default: ${project.build.directory}/generated-sources/cup

packageName:

Package name.

Specify that the parser and sym classes are to be placed in the named package. By default, no package specification is put in the generated code (hence the classes default to the special "unnamed" package).

  • Type: java.lang.String
  • Required: No
  • User Property: cup.packageName

showProgress:

Print short messages indicating progress through various parts of the parser generation process.
  • Type: boolean
  • Required: No
  • User Property: cup.showProgress
  • Default: false

sourceDirectory:

The directory containing CUP specification files (*.cup).
  • Type: java.io.File
  • Required: No
  • User Property: cup.sourceDirectory
  • Default: ${project.basedir}/src/main/cup

suppressGeneratedJavaWarningsUnchecked:

Suppress Java warnings in parser generated code locally when needed.

CUP produces generic Java code, some of which doesn't get used. For instance, the left/right integer location information for every terminal in productions are always generated, even if they are never used. This creates a series of unused warnings that need removing. Another example is when some of the terminal symbols contain elements with generic types. This creates unchecked warnings at various places where such generic non-terminal types appear. At this stage it is needed to add an unchecked cast warning suppression.

By default this flag is false, and all warnings are added. If set to true, our specific warning suppression is added instead. Warning suppression is added locally, so as to not hide any dead code or unchecked warning from user code. This is a local warning suppression.

  • Type: boolean
  • Required: No
  • User Property: cup.suppressGeneratedJavaWarningsUnchecked
  • Default: false

suppressGeneratedJavaWarningsUnused:

Suppress Java warnings in parser generated code globally.

Suppress any unused code warnings from CUP action class globally. TODO: make it local to each left/right assignment eventually

  • Type: boolean
  • Required: No
  • User Property: cup.suppressGeneratedJavaWarningsUnused
  • Default: false

symbolsInterface:

Outputs the symbol constant code as an interface rather than as a class.
  • Type: boolean
  • Required: No
  • User Property: cup.symbolsInterface
  • Default: false

symbolsName:

Generated symbols class name.

Output the symbol constant code into a class with the given name instead of the default of "Sym".

  • Type: java.lang.String
  • Required: No
  • User Property: cup.symbolsName
  • Default: Sym

timeSummary:

Add detailed timing statistics to the normal summary of results.
  • Type: boolean
  • Required: No
  • User Property: cup.timeSummary
  • Default: false

typeArgs:

Specify type arguments for parser class.
  • Type: java.lang.String
  • Required: No
  • User Property: cup.typeArgs

Back to top

Version: 1.6-SNAPSHOT. Last Published: 2016-04-09.

Reflow Maven skin by Andrius Velykis.