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.6 KiB

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