1 | <html>
|
---|
2 |
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Language" content="en-us">
|
---|
5 | <title>JFlex Ant Task</title>
|
---|
6 | </head>
|
---|
7 |
|
---|
8 | <body>
|
---|
9 |
|
---|
10 | <h2><a name="JFlex">JFlex Ant Task</a></h2>
|
---|
11 | <p>
|
---|
12 | JFlex can be easily integrated with <a HREF="http://ant.apache.org/"
|
---|
13 | target="_top">Ant</a> build tool.
|
---|
14 | To use JFlex with Ant, simply copy JFlex.jar to <i>$ANT_HOME/lib/</i> directory.
|
---|
15 | </p>
|
---|
16 | <h3>Description</h3>
|
---|
17 | <p>
|
---|
18 | The JFlex Ant Task invokes the <a HREF="http://jflex.de/" target="_top">JFlex</a> lexical
|
---|
19 | analyzer generator on a grammar file.
|
---|
20 | </p>
|
---|
21 | <p>
|
---|
22 | To use the JFlex task, the following line must be placed in the Ant build file:
|
---|
23 | </p>
|
---|
24 | <pre><taskdef classname="JFlex.anttask.JFlexTask" name="jflex" /></pre>
|
---|
25 |
|
---|
26 | <p>
|
---|
27 | The JFlex task requires the <i>file</i> attribute to be set to the source grammar file (*.flex).
|
---|
28 | Unless the target directory is specified with the <i>destdir</i> option,
|
---|
29 | the generated class will be saved to the same directory where grammar file resides.
|
---|
30 | Like javac, the JFlex task creates subdirectories in <i>destdir</i> according to the
|
---|
31 | generated class package.
|
---|
32 | </p>
|
---|
33 | <p>
|
---|
34 | This task only invokes JFlex if the grammar file is newer than the generated
|
---|
35 | files.
|
---|
36 | </p>
|
---|
37 |
|
---|
38 | <h3>Parameters</h3>
|
---|
39 | <table border="1" cellpadding="2" cellspacing="0" width="80%">
|
---|
40 | <tr>
|
---|
41 | <td valign="top"><b>Attribute</b></td>
|
---|
42 | <td valign="top"><b>Description</b></td>
|
---|
43 | <td align="center" valign="top"><b>Required</b></td>
|
---|
44 | <td align="center" valign="top"><b>Default</b></td>
|
---|
45 | </tr>
|
---|
46 | <tr>
|
---|
47 | <td valign="top">file="file"</td>
|
---|
48 | <td valign="top">The grammar file to process.</td>
|
---|
49 | <td valign="top" align="center">Yes</td>
|
---|
50 | <td></td>
|
---|
51 | </tr>
|
---|
52 | <tr>
|
---|
53 | <td valign="top">destdir="dir"</td>
|
---|
54 | <td valign="top">
|
---|
55 | The directory to write the generated files to. If not set, the files
|
---|
56 | are written to the directory containing the grammar file. Note that unlike
|
---|
57 | JFlex's "-d" command line option, <i>destdir</i> causes the generated file to be written to
|
---|
58 | {destdir}/<b>{package name}</b>. This behaviour is similar to <i>javac -d dir</i>.
|
---|
59 | </td>
|
---|
60 | <td valign="top" align="center">No</td>
|
---|
61 | <td></td>
|
---|
62 | </tr>
|
---|
63 | <tr>
|
---|
64 | <td valign="top">outdir="dir"</td>
|
---|
65 | <td valign="top">
|
---|
66 | The directory to write the generated files to. If not set, the files
|
---|
67 | are written to the directory containing the grammar file. This options works
|
---|
68 | exactly like JFlex's "-d" command line option, it causes the output file to
|
---|
69 | be written to <i>dir</i> regardless of the package name.
|
---|
70 | </td>
|
---|
71 | <td valign="top" align="center">No</td>
|
---|
72 | <td></td>
|
---|
73 | </tr>
|
---|
74 | <tr>
|
---|
75 | <td valign="top">verbose</td>
|
---|
76 | <td valign="top">Display generation process messages.</td>
|
---|
77 | <td align="center" valign="top">No</td>
|
---|
78 | <td align="center" valign="top">"off"</td>
|
---|
79 | </tr>
|
---|
80 | <tr>
|
---|
81 | <td valign="top">dump</td>
|
---|
82 | <td valign="top">Dump character classes, NFA and DFA tables.</td>
|
---|
83 | <td align="center" valign="top">No</td>
|
---|
84 | <td align="center" valign="top">"off"</td>
|
---|
85 | </tr>
|
---|
86 | <tr>
|
---|
87 | <td valign="top">time or<p>timeStatistics</td>
|
---|
88 | <td valign="top">Display generation time statistics.</td>
|
---|
89 | <td align="center" valign="top">No</td>
|
---|
90 | <td align="center" valign="top">"off"</td>
|
---|
91 | </tr>
|
---|
92 | <tr>
|
---|
93 | <td valign="top">nomin or<p>skipMinimization</td>
|
---|
94 | <td valign="top">Skip minimization step.</td>
|
---|
95 | <td align="center" valign="top">No</td>
|
---|
96 | <td align="center" valign="top">"off"</td>
|
---|
97 | </tr>
|
---|
98 | <tr>
|
---|
99 | <td valign="top">skel="file" or<p>skeleton="file"</td>
|
---|
100 | <td valign="top">Use external skeleton file.</td>
|
---|
101 | <td align="center" valign="top">No</td>
|
---|
102 | <td align="center" valign="top">"off"</td>
|
---|
103 | </tr>
|
---|
104 | <tr>
|
---|
105 | <td valign="top">dot or<p>generateDot</td>
|
---|
106 | <td valign="top">Write graphviz .dot files for the generated automata (alpha).</td>
|
---|
107 | <td align="center" valign="top">No</td>
|
---|
108 | <td align="center" valign="top">"off"</td>
|
---|
109 | </tr>
|
---|
110 | <tr>
|
---|
111 | <td valign="top">nobak</td>
|
---|
112 | <td valign="top">Do not make a backup if the generated file exists.</td>
|
---|
113 | <td align="center" valign="top">No</td>
|
---|
114 | <td align="center" valign="top">"off"</td>
|
---|
115 | </tr>
|
---|
116 | <tr>
|
---|
117 | <td valign="top">switch</td>
|
---|
118 | <td valign="top">Use code generation method <i>switch</t>.</td>
|
---|
119 | <td align="center" valign="top">No</td>
|
---|
120 | <td align="center" valign="top">"off"</td>
|
---|
121 | </tr>
|
---|
122 | <tr>
|
---|
123 | <td valign="top">table</td>
|
---|
124 | <td valign="top">Use code generation method <i>table</t>.</td>
|
---|
125 | <td align="center" valign="top">No</td>
|
---|
126 | <td align="center" valign="top">"off"</td>
|
---|
127 | </tr>
|
---|
128 | <tr>
|
---|
129 | <td valign="top">pack</td>
|
---|
130 | <td valign="top">Use code generation method <i>pack</t>.</td>
|
---|
131 | <td align="center" valign="top">No</td>
|
---|
132 | <td align="center" valign="top">"on"</td>
|
---|
133 | </tr>
|
---|
134 |
|
---|
135 | </table>
|
---|
136 | <h3>Example</h3>
|
---|
137 | <blockquote><pre>
|
---|
138 | <jflex
|
---|
139 | file="src/parser/Parser.flex"
|
---|
140 | destdir="build/generated/"
|
---|
141 | />
|
---|
142 | </pre></blockquote>
|
---|
143 | <p>
|
---|
144 | JFlex generates the lexical analyzer for <tt>src/parser/Parser.flex</tt> and saves the result
|
---|
145 | to <tt>build/generated/parser/</tt>, providing <tt>Parser.flex</tt> declares to be in package <tt>parser</tt>.
|
---|
146 | </p>
|
---|
147 |
|
---|
148 | <blockquote><pre>
|
---|
149 | <jflex
|
---|
150 | file="src/parser/Parser.flex"
|
---|
151 | destdir="build/generated/"
|
---|
152 | />
|
---|
153 | <javac
|
---|
154 | srcdir="build/generated/"
|
---|
155 | destdir="build/classes/"
|
---|
156 | />
|
---|
157 | </pre></blockquote>
|
---|
158 | <p>
|
---|
159 | The same as above plus compile generated classes to <i>build/classes</i>
|
---|
160 | </p>
|
---|
161 | <hr>
|
---|
162 |
|
---|
163 | </body>
|
---|
164 | </html>
|
---|
165 |
|
---|