[antlr-interest] More, Status of C++ backend?

Jim Idle jimi at temporal-wave.com
Wed Jan 2 08:20:16 PST 2008



> -----Original Message-----
> From: Ruslan Zasukhin [mailto:sunshine at public.kherson.ua]
> Sent: Wednesday, January 02, 2008 4:50 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] More, Status of C++ backend?
> 
> On 2/1/08 1:53 PM, "Mark Wright" <markwright at internode.on.net> wrote:
> 
> Hi Mark,
> 
> >>> Another idea is:  maybe it might be easier to find a way to
> >>> optionally plug in Andrei Alexandrescu's flex_string instead of
> >>> std::string. flex_string is used in the Boost Wave project,
> >>> presumably for the same reason.
> >>
> >> But does flex_string require allocation by new()?
> >> I assume that YES.
> >
> > Hello Ruslan,
> >
> > flex_string uses policy based design, so you can choose
> > whether you want it to use new() or your own allocator:
> >
> > http://www.ddj.com/cpp/184403784
> 
> Okay, although note that std::string also allow you specify own 
allocator.
> Right? Problem is in time we all need spend to find good mem pool, 
then
> plug
> them all together into our projects.
> 
> DREAM IS: that ANTLR C++ itself include some good mem-pool from the 
box
> for
> its AST nodes and allow us to use this mem pool for our own nodes 
also.

The C runtime already does this and if you want to make your own nodes, 
then you provide a similar mechanism for your node information (copy and 
past will work fine ;-). There is no inheritance in the C, so you are 
given a set of embedded structures. Create your own node, and embed the 
common node within it, it will act like a derived class. However, in C, 
you can just managed it with pointers anyway, and your memory pool is 
just taken from an array of your own nodes. Simple really (which is 
usually fastest ;-).

Jim




More information about the antlr-interest mailing list