[antlr-interest] Build Question

Ric Klaren klaren at cs.utwente.nl
Tue Mar 12 00:50:39 PST 2002


On Mon, Mar 11, 2002 at 01:03:27PM -0500, Tiller, Michael (M.M.) wrote:
> So far so good I imagine (although I haven't gotten far enough to figure
> out if this is a good idea yet).  The problem I'm running into is that I
> imagine these grammars may be shared among several distinct applications.
> For that reason, I keep the ".g" files away from everything else.  So when
> I run ANTLR, the Makefile rule looks like this:
>  
>  $(ANTLR) -glib $(ROOTDIR)/base.g -o $(GENDIR) $(ROOTDIR)/base_java.g
>  
> where GENDIR is the location for the generated code and ROOTDIR is where I
> keep the .g files.  This way, I can generate the set of source files for
> each project based on the grammars.
>  
> The problem is that when you use grammar inheritance, ANTLR expands the
> complete grammar into "expandedbase_java.g".  Except that it actually names
> it "expanded$(ROOTDIR)/base_java.g" (where ROOTDIR is actually expanded).
> In other words, it assumes that the ".g" is in the current directory.
>  
> Any suggestions about how to avoid this problem?  I'm surprised that I
> can't explicitly specify the name of the expanded grammar.  That would have
> been a nice option.

Been there done that. Doesn't work. It needs some serious fixing in antlr
to make this behave well. I already looked at it when I ran into it, it's
not completely easy to fix in antlr. I currently copy .g files around with
Make rules to get the right behaviour.

I personally must say that I found antlr's grammar inheritance pretty
useless (gives to little control over what you want to override, in the end
you end up copying action code in a complicated way so I figured I'd better
copy stuff around in an easy way). YMMV though I suspect some ppl on the
list may have gotten nice results with it.

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 Time what is time - I wish I knew how to tell You why - It hurts to know -
          Aren't we machines - Time what is time - Unlock the door
               - And see the truth - Then time is time again
                From: 'Time what is Time' by Blind Guardian


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list