[antlr-interest] [antlr3c] Need help working with ANTLR3_STRING...

Adamic Tomislav tomislav.adamic at gmail.com
Mon Aug 3 00:58:35 PDT 2009


Hi

I'm a bit puzzled with ANTLR API for ANTLR3_STRING... I need few
operations on strings and I could do it either by converting
ANTLR3_STRING into std::string (or std::wstring) or do it directly.
Well, I can't figure out either. So, let's say I want to create a copy
of some already existing ANTLR3_STRING. Is this the proper way of
doing it, so it doesn't leak memory:

pANTLR3_STRING_FACTORY sFact = antlr3StringFactoryNew();
pANTLR3_STRING str = sFact->newRaw(sFact);
// ... do some work with str
sFact->close();

The more important thing I'm puzzled about is hoe to make whole string
lowercase... I see that I can iterate over it, but what to do with
each ANTLR3_UCHAR? How do I make it lowercase?

Well, I was thinking of using suplied toUTF8 function, then converting
resulting UTF8 string to some string class that has more complete
implementation and then use this class to lowercase the string and
work with it... This seems like overkill, so is there a better way?

Oh, yes, I haven't mentioned it, I'm using anlr3c from C++ program...


More information about the antlr-interest mailing list