[antlr-interest] My Progress on C++ Target

Gokulakannan Somasundaram gokul007 at gmail.com
Sat Feb 4 23:50:52 PST 2012


Hi,
   I have completed the C++ Runtime, and right now i am working on the
String Template Cpp.stg. I have attached the entire runtime, but right now
i have just made sure things are compiling for a simple parser( not yet for
the tree parser ) in Windows. After i complete the Cpp.stg, i will check
out a simple run. Some logic behind some of the changes

a) As i have already said, there are no function pointers/ virtual
functions. This is completely written making use of the power of C++
templates. At the same time, i have kept a check on the compile times.
b) I have put the functional logic into the .inl file.
c) Right now i have made a GenericStreamTraits inside antlr3.h, to provide
a default implementation of all the templated parameters
d) I have changed all the types with ANTLR3_ into ANTLR_, as i have pulled
in everything inside antlr3 namespace.
e) I have removed the StringFactory and TokenFactory, as i feel they are
related to memory allocation optimization and can be easily solved with
providing a memory pool implementation. There are a lot of Pool
implementations available( Boost, Intel TBB, POCO etc). There are even
object specific pools available to be made use of.
f) I have tried to change all the void* members with some type, but still
not complete with it. Similarly, i feel i won't be able to get away with
all the C Style casts.
g) Regarding the Unicode stuff, i feel that we should make use of ICU
library(why replicate the effort?). But i have went ahead and converted all
that was in C Target, except the unicode conversion functions.
h) Tried to remove all the #defines and converted into enum and static
const variables
i) Memory allocation failures and file errors are handled with exceptions
in the default implementation(even std::vector and std::deque use
exceptions inside). So even if some overrides are provided for these, they
should throw exception and should not assume return value handling.
j) The Exception related to parsing and scanning are not using C++
exceptions. This is because there is try .. catch block setup for every
token being read in Java Target, which would be a performance problem in
C++.
k) A Keen observer can also find that some of the runtime errors have
become compile time errors in the C++ implementation.

For the files generated using Cpp.stg, i am trying to remove the macros and
the function pointers.

Any thoughts/suggestions?

Thanks,
Gokul.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cpp.7z
Type: application/octet-stream
Size: 86003 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120205/a78acc8f/attachment.obj 


More information about the antlr-interest mailing list