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 3.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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">fork</td>
  55. <td valign="top">Run ANTLR in a separate VM.</td>
  56. <td align="center" valign="top">No, default is &quot;off&quot;</td>
  57. </tr-->
  58. <tr>
  59. <td valign="top">dir</td>
  60. <td valign="top">The directory to invoke the VM in. <!--(ignored if
  61. fork is disabled)--></td>
  62. <td align="center" valign="top">No</td>
  63. </tr>
  64. </table>
  65. <h3><a name="nested">Nested Elements</a></h3>
  66. <p><code>ANTLR</code> supports a nested <code>&lt;classpath&gt;</code>
  67. element, that represents a <a href="../using.html#path">PATH like
  68. structure</a>. It is given as a convenience if you have to specify
  69. the original ANTLR directory. In most cases, dropping the appropriate
  70. ANTLR jar in the normal Ant lib repository will be enough.</p>
  71. <h4>jvmarg</h4>
  72. <p><!--If fork is enabled, -->Additional parameters may be passed to the new
  73. VM via nested <code>&lt;jvmarg&gt;</code> attributes, for example:</p>
  74. <pre>
  75. &lt;antlr target=...&gt;
  76. &lt;jvmarg value=&quot;-Djava.compiler=NONE&quot;/&gt;
  77. ...
  78. &lt;/antlr&gt;
  79. </pre>
  80. <p>would run ANTLR in a VM without JIT.</p>
  81. <p><code>&lt;jvmarg&gt;</code> allows all attributes described in <a
  82. href="../using.html#arg">Command line arguments</a>.</p>
  83. <h3>Example</h3>
  84. <blockquote><pre>
  85. &lt;antlr
  86. target=&quot;etc/java.g&quot;
  87. outputdirectory=&quot;build/src&quot;
  88. /&gt;
  89. </pre></blockquote>
  90. <p>
  91. This invokes ANTLR on grammar file etc/java.g, writing the generated
  92. files to build/src.
  93. </p>
  94. <hr>
  95. <p align="center">Copyright &copy; 2001 Apache Software Foundation. All rights
  96. Reserved.</p>
  97. </body>
  98. </html>