[antlr-interest] c runtime with templates

Carter Cheng carter_cheng at yahoo.com
Sat Feb 14 01:00:37 PST 2009


Thanks Jim.


--- On Fri, 2/13/09, Jim Idle <jimi at temporal-wave.com> wrote:

> From: Jim Idle <jimi at temporal-wave.com>
> Subject: Re: [antlr-interest] c runtime with templates
> To: 
> Cc: antlr-interest at antlr.org
> Date: Friday, February 13, 2009, 9:32 AM
> Carter Cheng wrote:
> > Thanks for the reply.
> >
> > I did actually manage to find a semi workaround for
> this though it is a bit cumbersome (involves manually
> editing the extern "C" scopes in the tree grammar
> .h generated file). I am a bit of a C++ newbie and part of
> me is curious if this extern "C" stuff is really
> needed here since I am compiling everything with g++.
> >
> > Unfortunately given how the declarations look in the
> header it seems that since in certain cases I am returning
> stl types these show up in some of the generated structs in
> the header i suspect that #ifdefing them out of the header
> would mean the header would not compile.
> >
> >   
> In the latest source I think that the #ifdefs are more
> selective, but 
> you probably want to put your #includes inside @preincludes
> and not 
> @header. Chack the docs on the various sections.  Also
> don't put any of 
> your classes and things directly into the grammar, place
> them in .cpp 
> files and the include the headers the define the classes in
> the 
> preincludes sections. Then your classes won't be marked
> as extern "C". 
> There are comments about the approach you take to structure
> in the 
> examples - separate include that includes your headers and
> the 
> parser/lexer headers and so on. Keep as much of your own
> code as 
> possible out of the .g file and the generated headers
> basically.
> 
> Jim
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address


      


More information about the antlr-interest mailing list