[antlr-interest] static antlr c++ BitSets

Jim Idle jimi at temporal-wave.com
Tue Feb 26 12:05:19 PST 2008


If you don’t mind working with the beta for a week or so, then switching
to 3.1 C runtime allows you to use C++ directly in your grammar/actions.
The generated C can be compiled as C++ and so any embedded code can be
C++, not just C. If you are doing something new then you should really
put your efforts in to this version (I think). As much as is possible,
everything is pre-computed and allocated at compile time. Obviously
memory is allocated for tokens and so on, but this is done with
factories so it does chunks of them and does not thrash memory.

 

The 3.1 C runtime compares well with the Java version memory wise. The
java parser example (see the example downloads on the downloads page),
runs (on my system) through the JDK 1.6 source in about half the time
that the Java version does, and it is mostly waiting for IO that holds
it back. To perform the task, the Java version uses a working set
(Windows Vista 64) of 380,000K, whereas the C version hits a peaks of
11,700K. Of course working with C is commensurably a little more
involved. 

 

The C parser example in the 3.1 example downloads shows using C++
classes in the generated code, which is of course just a matter of
declaring them and newing them. The runtime itself is pure C, which
makes integration as a library, very simple.

 

Jim

 

 

From: Brian Meidell Andersen [mailto:brian at gameequation.com] 
Sent: Tuesday, February 26, 2008 11:33 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] static antlr c++ BitSets

 

 

On Tue, Feb 26 08, at 19:03 , Jim Idle wrote:





As of 3.1 the C runtime supports C++ integration, I dont know if this 
is of help to you, as you may be inextricably bound to 2.7.x of course, 
but the bitsets there are static C and perform no runtime allocations.

 

So changing to 3.1 would likely solve my problem? 

I am not sure how "c++ integration" does this, so I'm mostly referring
to "perform no runtime allocations".

 

Regards, Brian

 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080226/7ea2905d/attachment.html 


More information about the antlr-interest mailing list