Package jflex.maven.plugin.jflex
Class JFlexMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- jflex.maven.plugin.jflex.JFlexMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="generate", defaultPhase=GENERATE_SOURCES, threadSafe=false) public class JFlexMojo extends org.apache.maven.plugin.AbstractMojoGenerates lexical scanners from one or more JFlex grammar files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classJFlexMojo.ExtensionPredicate
-
Field Summary
Fields Modifier and Type Field Description private booleanbackupA flag whether to enable the generation of a backup copy if the generated source file already exists.private booleandotWhether to produce graphviz .dot files for the generated automata.private booleandumpWhether to dump full debug information.private java.lang.StringencodingNameThe name of the character encoding for reading lexer specifications.private java.lang.StringgenerationMethodThe generation method to use for the scanner.private booleanjlexStrict JLex compatibility.private booleanlegacyDotIf true, the dot (.) metachar matches [^\n] instead of [^\n\r ].private java.io.File[]lexDefinitionsList of grammar definitions to run the JFlex parser generator on.private booleanminimizeA flag whether to perform the DFA minimization step during scanner generation.private java.io.FileoutputDirectoryName of the directory into which JFlex should generate the parser.private org.apache.maven.project.MavenProjectprojectprivate java.io.FileskeletonUse external skeleton file.private static java.lang.StringSRC_MAIN_JFLEXName of the directory where to look for jflex files by default.private intstaleMillisThe granularity in milliseconds of the last modification date for testing whether a source needs regeneration.private booleanunusedWarningWhether a warning will be logged when there are unused macros.private booleanverboseWhether source code generation should be verbose.
-
Constructor Summary
Constructors Constructor Description JFlexMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckParameters(java.io.File lexFile)Check parameter lexFile.voidexecute()Generate java parsers from lexer definition files.private SpecInfofindSpecInfo(java.io.File lexFile)private java.io.FilegetAbsolutePath(java.io.File path)Converts the specified path argument into an absolute path.private static longlatestModified(java.util.Set<java.io.File> includedFiles)Determines the highestFile.lastModified()value among the specifiedincludedFiles, which are resolved relative to the specifiedparentdirectory.private voidparseLexDefinition(java.io.File lexDefinition)Generates java code of a parser from a lexer file.private voidparseLexFile(java.io.File lexFile)
-
-
-
Field Detail
-
SRC_MAIN_JFLEX
private static final java.lang.String SRC_MAIN_JFLEX
Name of the directory where to look for jflex files by default.- See Also:
- Constant Field Values
-
project
@Parameter(property="project", required=true, readonly=true) private org.apache.maven.project.MavenProject project
-
lexDefinitions
@Parameter private java.io.File[] lexDefinitions
List of grammar definitions to run the JFlex parser generator on. Each path may either specify a single grammar file or a directory. Directories will be recursively scanned for files with one of the following extensions: ".jflex", ".flex", ".jlex" or ".lex". By default, all files insrc/main/jflexwill be processed.- See Also:
SRC_MAIN_JFLEX
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/jflex") private java.io.File outputDirectoryName of the directory into which JFlex should generate the parser.
-
staleMillis
@Parameter(property="lastModGranularityMs", defaultValue="0") private int staleMillisThe granularity in milliseconds of the last modification date for testing whether a source needs regeneration.
-
verbose
@Parameter(defaultValue="false") private boolean verbose
Whether source code generation should be verbose.
-
unusedWarning
@Parameter(defaultValue="true") private boolean unusedWarning
Whether a warning will be logged when there are unused macros.
-
dump
@Parameter(defaultValue="false") private boolean dump
Whether to dump full debug information.
-
dot
@Parameter(defaultValue="false") private boolean dot
Whether to produce graphviz .dot files for the generated automata. This feature is EXPERIMENTAL.
-
skeleton
@Parameter private java.io.File skeleton
Use external skeleton file.
-
jlex
@Parameter(defaultValue="false") private boolean jlex
Strict JLex compatibility.
-
generationMethod
@Parameter(defaultValue="pack") private java.lang.String generationMethod
The generation method to use for the scanner. The only valid value ispack.
-
minimize
@Parameter(defaultValue="true") private boolean minimize
A flag whether to perform the DFA minimization step during scanner generation.
-
backup
@Parameter(defaultValue="true") private boolean backup
A flag whether to enable the generation of a backup copy if the generated source file already exists.
-
legacyDot
@Parameter(defaultValue="false") private boolean legacyDot
If true, the dot (.) metachar matches [^\n] instead of [^\n\r ].
-
encodingName
@Parameter(defaultValue="") private java.lang.String encodingName
The name of the character encoding for reading lexer specifications. Uses JVM default encoding if unset.
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionGenerate java parsers from lexer definition files.This methods is checks parameters, sets options and calls JFlex.Main.generate()
- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
parseLexDefinition
private void parseLexDefinition(java.io.File lexDefinition) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionExceptionGenerates java code of a parser from a lexer file.If the
lexDefinitionis a directory, process all lexer files contained within.- Parameters:
lexDefinition- Lexer definiton file or directory to process.- Throws:
org.apache.maven.plugin.MojoFailureException- if the file is not found.org.apache.maven.plugin.MojoExecutionException- if file could not be parsed
-
parseLexFile
private void parseLexFile(java.io.File lexFile) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-
findSpecInfo
private SpecInfo findSpecInfo(java.io.File lexFile) throws org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoFailureException
-
checkParameters
private void checkParameters(java.io.File lexFile) throws org.apache.maven.plugin.MojoExecutionExceptionCheck parameter lexFile.Must not be
nulland file must exist.- Parameters:
lexFile- input file to check.- Throws:
org.apache.maven.plugin.MojoExecutionException- in case of error
-
getAbsolutePath
private java.io.File getAbsolutePath(java.io.File path)
Converts the specified path argument into an absolute path. If the path is relative like "src/main/jflex", it is resolved against the base directory of the project (in constrast, File.getAbsoluteFile() would resolve against the current directory which may be different, especially during a reactor build).- Parameters:
path- The path argument to convert, may benull.- Returns:
- The absolute path corresponding to the input argument.
-
latestModified
private static long latestModified(java.util.Set<java.io.File> includedFiles)
Determines the highestFile.lastModified()value among the specifiedincludedFiles, which are resolved relative to the specifiedparentdirectory.- Returns:
- the latest value -- or 0 if the list is empty, if no files exist, or if I/O exceptions prevent getting any values
-
-