[antlr-interest] C++ Target updates

Gokulakannan Somasundaram gokul007 at gmail.com
Thu Feb 23 02:19:22 PST 2012


Hi,
  I have uploaded the latest version of C++ Target with some enhancements
into the wiki. There are no changes to the existing behavior.
http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826

a) I have made the default structure of the return value as a trait. I have
also merged this structure into the structure, i created before to get
created and destroyed in every rule. Usually it includes the
CommonToken* start;
CommonToken* stop;

start gets assigned at a point and stop gets assigned at a point. I have
made those points to call a function and made sure everything by default
works in the same behavior. The memory savings i have implemented before
has a limitation. It doesn't delete the first and last token after tokens
are condensed into a rule. So, say we have two rules like this
rule2: rule1*;
rule1: TOKEN1 TOKEN2;

Now the the memory occupied by rule1 will not get freed, till rule2 is
completed. The default return value( especially the stop token assignment)
was an impediment to implement the memory behaviour wherein everything
including the start and stop tokens are destroyed( even if we are not using
rule attributes ).
So if a user doesn't use the rule attributes outside the rule, his memory
usage will be very optimal. I am posting an example of how to achieve this
in the attachment.

b) @rulecatch is implemented similar to Java.


Thanks,
Gokul.


More information about the antlr-interest mailing list