[antlr-interest] added new -depend option

Terence Parr parrt at cs.usfca.edu
Sun Feb 11 14:19:51 PST 2007


Hi,

We've been arguing about file extensions on antlr-dev.  I've decided  
that the file extensions can't say enough due to dependencies on  
token files etc... so only .g will be used.  To help build tools, I  
built a -depend option at Ric Klaren's suggestion.  It just lists the  
make-compatible dependencies to stdout.  You can change the template  
to gen what you want though.  Also available as an API. :)

Note this ain't exactly cheap to execute as it has to do a lot of  
normal ANTLR processing to answer these dependency questions.

Here are my notes from the readme:

* Added -depend command-line option that, instead of processing files,
   it shows you what files the input grammar(s) depend on and what files
   they generate. For combined grammar T.g:

   $ java org.antlr.Tool -depend T.g

   You get:

   TParser.java : T.g
   T.tokens : T.g
   T__.g : T.g

   Now, assuming U.g is a tree grammar ref'd T's tokens:

   $ java org.antlr.Tool -depend T.g U.g

   TParser.java : T.g
   T.tokens : T.g
   T__.g : T.g
   U.g: T.tokens
   U.java : U.g
   U.tokens : U.g

   Handles spaces by escaping them.  Pays attention to -o, -fo and -lib.
   Dir 'x y' is a valid dir in current dir.

   $ java org.antlr.Tool -depend -lib /usr/local/lib -o 'x y' T.g U.g
   x\ y/TParser.java : T.g
   x\ y/T.tokens : T.g
   x\ y/T__.g : T.g
   U.g: /usr/local/lib/T.tokens
   x\ y/U.java : U.g
   x\ y/U.tokens : U.g

   You have API access via org.antlr.tool.BuildDependencyGenerator  
class:
   getGeneratedFileList(), getDependenciesFileList().  You can also  
access
   the output template: getDependencies().  The file
   org/antlr/tool/templates/depend.stg contains the template.  You can
   modify as you want.  File objects go in so you can play with path  
etc...

Ter


More information about the antlr-interest mailing list