JFlex can be easily integrated with Ant build tool. To use JFlex with Ant, simply copy JFlex.jar to $ANT_HOME/lib/ directory.
JFlex Ant Task invokes the JFlex lexical analyzer generator on a grammar file.
To use jflex task, the following line must be placed in the Ant build file:
<taskdef classname="JFlex.anttask.JFlexTask" name="jflex" />
JFlex task requires file attribute to be set to the source grammar file (*.flex). Generated class can be saved to the same directory where grammar file resides or to the directory specified with destdir option. JFlex task creates subdirectories in destdir according to the generated class package.
This task only invokes JFlex if the grammar file is newer than the generated files.
Attribute | Description | Required |
file | The grammar file to process. | Yes |
destdir | The directory to write the generated files to. If not set, the files are written to the directory containing the grammar file. Note that unlike JFlex's "-d" command line option, destdir causes to write generated file to {destdir}/{package name}. This behaviour is similar to javac -d dir. | No |
verbose | Display generation process messages. | No, default is "off" |
timeStatistics | Display generation time statistics. | No, default is "off" |
skipMinimization | Skip minimization step (alpha status, use with care). | No, default is "off" |
skeleton | Use external skeleton file. | No |
generateDot | Write graphviz .dot files for the generated automata (alpha). | No, default is "off" |
<jflex file="src/parser/Parser.flex" destdir="build/generated/" />
JFlex generates lexical analyzer for src/parser/Parser.flex and saves a result to build/generated/parser/.
<jflex file="src/parser/Parser.flex" destdir="build/generated/" /> <javac srcdir="build/generated/" destdir="build/classes/" />
The same as above plus compile generated classes to build/classes