[antlr-interest] Re: ANTLR 3.0 and code generation for C++

iank at bearcave.com iank at bearcave.com
Mon Oct 27 12:26:51 PST 2003


  Since Ter is a Java kind of guy (I hate to say it but I'm becoming a
  Java kind of guy too), I don't know if the new version will include
  work on the C++ code generator.  Its been a while since I looked at
  the C++ generated source but as I recall it uses reference counted
  strings and other reference counted objects to mirror garbage
  collection in Java.

  I have implemented a reference counting framework that includes a
  reference counted String class.  As with ANTLR there are no
  limitations on the use of this code.  So I'd like to offer it for
  the ANTLR C++ code generator if it would be useful.

  The reference counted String class is losely modeled after the Rogue
  Wave RWCString.  I originally thought that this class would be a
  couple of weekends of work, at most.  I don't think that I've ever
  underestimated development effort as badly.  I've been working on
  this software off and on for about three years.  It has been much
  more work and more complex than I realized.

  The current version is version 3.0.  It may be a bit of overkill for
  ANTLR.  Like RWCString it supports string sections.  The class
  properly implements copy-on-write, which is more complicated that I
  realized (version 2.0 implemented copy-on-read much to my
  surprise).

  The reference counting classes are based on Scott Meyers' reference
  counted classes from "More Effective C++" and include all the
  updates he made in the various editions, plus my changes.  The
  reference counted String is based on a reference counted array
  template.  I include an example of a DoubleVec class (a reference
  counted, copy on write array of doubles).  I try to comment my code
  extensively, but reference to Meyers book might be useful.

  More compilers, including GNU seem to implement "the standard"
  fairly completely.  This code includes regression tests which pass
  on VC++ and GNU.  I've also used Valgrind in an attempt to verify
  memory use.

  The code can be found at

    http://www.bearcave.com/software/string/index.html

  For those who would like to beat up on C++ (sort of like shooting
  fish in a barrel) the complexity of this code is probably a good
  target.  And then there is the fact that I had to use Valgrind...  I
  guess that this is one reason that I'm using Java more for
  applications where performance is not critical.  It's a hard thing
  for an aging C hacker to admit.

  Ian

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list