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

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