[antlr-interest] Build Question

Tiller, Michael (M.M.) mtiller at ford.com
Mon Mar 11 10:03:27 PST 2002


I am having a problem with creating a nice build structure for a project I'm working on and I'm hoping somebody can point out a way around this.
 
I have a grammar, call it "base.g".  Now, I'd like to preserve the ability to use "base.g" to generate either a C++ parser or a Java parser.  So, I've made "base.g" language neutral.  Now, I've created two more grammars called "base_cpp.g" and "base_java.g" that specify language and header file information.
 
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.
 
--
Mike
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20020311/f47ba3ef/attachment.html


More information about the antlr-interest mailing list