You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

antlr.html 5.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>ANTLR Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="antlr">ANTLR</a></h2>
  8. <h3>Description</h3>
  9. <p>
  10. Invokes the <a HREF="http://www.antlr.org/" target="_top">ANTLR</a> Translator generator
  11. on a grammar file.
  12. </p>
  13. <p>
  14. To use the ANTLR task, set the <i>target</i> attribute to the name of the
  15. grammar file to process. Optionally, you can also set the
  16. <i>outputdirectory</i> to write the generated file to a specific directory.
  17. Otherwise ANTLR writes the generated files to the directory containing
  18. the grammar file.
  19. </p>
  20. <p>
  21. This task only invokes ANTLR if the grammar file (or the
  22. supergrammar specified by the glib attribute) is newer than the
  23. generated files.
  24. </p>
  25. <p>Antlr 2.7.1 Note:
  26. <i>
  27. To successfully run ANTLR, your best option is probably to build the whole
  28. jar with the provided script <b>mkalljar</b> and drop the resulting jar (about 300KB)
  29. into ${ant.home}/lib. Dropping the default jar (70KB) is probably not enough
  30. for most needs and your only option will be to add ANTLR home directory
  31. to your classpath as described in ANTLR <tt>install.html</tt> document.
  32. </i>
  33. </p>
  34. <p>Antlr 2.7.2 Note:
  35. <i>
  36. Instead of the above, you will need antlrall.jar that can be created
  37. by the <b>antlr-all.jar</b> target of the Makefile provided with the
  38. download.
  39. </i>
  40. </p>
  41. <h3>Parameters</h3>
  42. <table border="1" cellpadding="2" cellspacing="0">
  43. <tr>
  44. <td valign="top"><b>Attribute</b></td>
  45. <td valign="top"><b>Description</b></td>
  46. <td align="center" valign="top"><b>Required</b></td>
  47. </tr>
  48. <tr>
  49. <td valign="top">target</td>
  50. <td valign="top">The grammar file to process.</td>
  51. <td valign="top" align="center">Yes</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">outputdirectory</td>
  55. <td valign="top">
  56. The directory to write the generated files to. If not set, the files
  57. are written to the directory containing the grammar file.
  58. </td>
  59. <td valign="top" align="center">No</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">glib</td>
  63. <td valign="top">
  64. An optional super grammar file that the target grammar overrides. This
  65. feature is only needed for advanced vocabularies.
  66. </td>
  67. <td valign="top" align="center">No</td>
  68. </tr>
  69. <tr>
  70. <td valign="top">debug</td>
  71. <td valign="top">
  72. When set to "yes", this flag adds code to the generated parser that will
  73. launch the ParseView debugger upon invocation. The default is "no".
  74. <br>
  75. Note: ParseView is a separate component that needs to be installed or your
  76. grammar will have compilation errors.
  77. </td>
  78. <td valign="top" align="center">No</td>
  79. </tr>
  80. <tr>
  81. <td valign="top">html</td>
  82. <td valign="top">
  83. Emit an html version of the grammar with hyperlinked actions.
  84. </td>
  85. <td valign="top" align="center">No</td>
  86. </tr>
  87. <tr>
  88. <td valign="top">diagnostic</td>
  89. <td valign="top">
  90. Generates a text file with debugging information based on the target grammar.
  91. </td>
  92. <td valign="top" align="center">No</td>
  93. </tr>
  94. <tr>
  95. <td valign="top">trace</td>
  96. <td valign="top">
  97. Forces <b>all</b> rules to call traceIn/traceOut if set to "yes".
  98. The default is "no".
  99. </td>
  100. <td valign="top" align="center">No</td>
  101. </tr>
  102. <tr>
  103. <td valign="top">traceParser</td>
  104. <td valign="top">
  105. Only forces parser rules to call traceIn/traceOut if set to "yes".
  106. The default is "no".
  107. </td>
  108. <td valign="top" align="center">No</td>
  109. </tr>
  110. <tr>
  111. <td valign="top">traceLexer</td>
  112. <td valign="top">
  113. Only forces lexer rules to call traceIn/traceOut if set to "yes".
  114. The default is "no".
  115. </td>
  116. <td valign="top" align="center">No</td>
  117. </tr>
  118. <tr>
  119. <td valign="top">traceTreeWalker</td>
  120. <td valign="top">
  121. Only forces tree walker rules to call traceIn/traceOut if set to
  122. "yes". The default is "no".
  123. </td>
  124. <td valign="top" align="center">No</td>
  125. </tr>
  126. <!--tr>
  127. <td valign="top">fork</td>
  128. <td valign="top">Run ANTLR in a separate VM.</td>
  129. <td align="center" valign="top">No, default is &quot;off&quot;</td>
  130. </tr-->
  131. <tr>
  132. <td valign="top">dir</td>
  133. <td valign="top">The directory to invoke the VM in. <!--(ignored if
  134. fork is disabled)--></td>
  135. <td align="center" valign="top">No</td>
  136. </tr>
  137. </table>
  138. <h3><a name="nested">Nested Elements</a></h3>
  139. <p><code>ANTLR</code> supports a nested <code>&lt;classpath&gt;</code>
  140. element, that represents a <a href="../using.html#path">PATH like
  141. structure</a>. It is given as a convenience if you have to specify
  142. the original ANTLR directory. In most cases, dropping the appropriate
  143. ANTLR jar in the normal Ant lib repository will be enough.</p>
  144. <h4>jvmarg</h4>
  145. <p><!--If fork is enabled, -->Additional parameters may be passed to the new
  146. VM via nested <code>&lt;jvmarg&gt;</code> attributes, for example:</p>
  147. <pre>
  148. &lt;antlr target="..."&gt;
  149. &lt;jvmarg value=&quot;-Djava.compiler=NONE&quot;/&gt;
  150. ...
  151. &lt;/antlr&gt;
  152. </pre>
  153. <p>would run ANTLR in a VM without JIT.</p>
  154. <p><code>&lt;jvmarg&gt;</code> allows all attributes described in <a
  155. href="../using.html#arg">Command line arguments</a>.</p>
  156. <h3>Example</h3>
  157. <blockquote><pre>
  158. &lt;antlr
  159. target=&quot;etc/java.g&quot;
  160. outputdirectory=&quot;build/src&quot;
  161. /&gt;
  162. </pre></blockquote>
  163. <p>
  164. This invokes ANTLR on grammar file etc/java.g, writing the generated
  165. files to build/src.
  166. </p>
  167. <hr>
  168. <p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
  169. Reserved.</p>
  170. </body>
  171. </html>