java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4086
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use ANTLR task E-mail
User Rating: / 5
PoorBest 

ANTLR

Description

Invokes the ANTLR Translator generator on a grammar file.

To use the ANTLR task, set the target attribute to the name of the grammar file to process. Optionally, you can also set the outputdirectory to write the generated file to a specific directory. Otherwise ANTLR writes the generated files to the directory containing the grammar file.

This task only invokes ANTLR if the grammar file (or the supergrammar specified by the glib attribute) is newer than the generated files.

Antlr 2.7.1 Note: To successfully run ANTLR, your best option is probably to build the whole jar with the provided script mkalljar and drop the resulting jar (about 300KB) into ${ant.home}/lib. Dropping the default jar (70KB) is probably not enough for most needs and your only option will be to add ANTLR home directory to your classpath as described in ANTLR install.html document.

Antlr 2.7.2 Note: Instead of the above, you will need antlrall.jar that can be created by the antlr-all.jar target of the Makefile provided with the download.

Parameters

Attribute Description Required
target The grammar file to process. Yes
outputdirectory The directory to write the generated files to. If not set, the files are written to the directory containing the grammar file. No
glib An optional super grammar file that the target grammar overrides. This feature is only needed for advanced vocabularies. No
debug When set to "yes", this flag adds code to the generated parser that will launch the ParseView debugger upon invocation. The default is "no".
Note: ParseView is a separate component that needs to be installed or your grammar will have compilation errors.
No
html Emit an html version of the grammar with hyperlinked actions. No
diagnostic Generates a text file with debugging information based on the target grammar. No
trace Forces all rules to call traceIn/traceOut if set to "yes". The default is "no". No
traceParser Only forces parser rules to call traceIn/traceOut if set to "yes". The default is "no". No
traceLexer Only forces lexer rules to call traceIn/traceOut if set to "yes". The default is "no". No
traceTreeWalker Only forces tree walker rules to call traceIn/traceOut if set to "yes". The default is "no". No
dir The directory to invoke the VM in. No

Nested Elements

ANTLR supports a nested <classpath> element, that represents a PATH like structure. It is given as a convenience if you have to specify the original ANTLR directory. In most cases, dropping the appropriate ANTLR jar in the normal Ant lib repository will be enough.

jvmarg

Additional parameters may be passed to the new VM via nested <jvmarg> attributes, for example:

<antlr target="...">
  <jvmarg value="-Djava.compiler=NONE"/>
  ...
</antlr>

would run ANTLR in a VM without JIT.

<jvmarg> allows all attributes described in Command line arguments.

Example

<antlr
    target="etc/java.g"
    outputdirectory="build/src"

/>

This invokes ANTLR on grammar file etc/java.g, writing the generated files to build/src.

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.