[antlr-interest] More, Status of C++ backend?
Jim Idle
jimi at temporal-wave.com
Wed Jan 2 15:56:22 PST 2008
> -----Original Message-----
> From: Gavin Lambert [mailto:antlr at mirality.co.nz]
> Sent: Wednesday, January 02, 2008 2:49 PM
> To: Jim Idle; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] More, Status of C++ backend?
>
> At 05:22 3/01/2008, Jim Idle wrote:
> >Yeah - I see that argument too, however I think it will end up
> >being slower just for the sake of making it use "proper
> >classes", so I would not use it and just go with the C runtime.
>
> There's nothing inherently slow about C++ over C, it's just that
> you have to be aware that the compiler can inject extra code
> "behind your back" :)
Well, there is extra setup for exception handling and so on - hence all
the goings on with Embedded C++ specs. It never turns out as lean as C
and most programmers screw it up royally ;-P
>
> And I wasn't proposing going and using std::string as a member of
> the token or anything. You'd do it the same way as the Java
> runtime works -- normally store only indexes, but create a string
> on demand.
No, obviously not. In fact I am not sure that std:string is too terrible
when you are not allocating millions of them that won't even be used,
but it is probably high enough to look at alternatives.
>
> >I think doing this in phases makes a lot of sense.
>
> Definitely. The obvious first phase would be to get the C runtime
> C++-safe (which last time I checked it almost was, there was just
> one function somewhere that used a C++ keyword as an identifier, I
> think). The second phase would be to make C++ wrappers for the
> existing C runtime.
Yep - it is a few #ifdefs and a change in a couple of the sources.
>
> The thing is, I'm not convinced that making C++ wrapper classes
> would actually be faster or simpler than making full C++
> classes. Trying to take a C++ object (with polymorphic methods)
> and pass it across to the C runtime could get a little
> tricky. Doable, of course; I'm just not sure it's worth the
> effort.
Yep. Though in the first instance I am really only interested in neater
syntax for action code. I bet that is all that virtually everyone needs
to be honest.
Jim
More information about the antlr-interest
mailing list