[antlr-interest] advocacy of C++ support in ANTLR 3.x
Ruslan Zasukhin
sunshine at public.kherson.ua
Fri Mar 28 04:19:35 PDT 2008
On 3/28/08 11:52 AM, "Jim Idle" <jimi at temporal-wave.com> wrote:
Hi Jim,
> Tomas Potrusil wrote:
>
> I should add that if you really need to build C++ strings from the token, then
> you should probably not use the .text attribute of the token. That is really
> just a convenience method. Write yourself a class with a constructor that
> accepts a token as input and constructs the C++ string directly. That is all
> that the C runtime does internally and there is no need to incur the overhead
> of getting the C runtime to produce the token text, when you can take it
> directly from the input stream.
Why not add such C++ class into ANTLR 3.1 = 3.1for C target ?
So each C++ user will not reinvent a bike.
> If you have your own tree constructor then you could just implement an
> interface to it by implementing your own tree adapter and tree nodes that
> encapsulate your own tree.
>> From what you say here, a pure C++ runtime would give you no advantage at all
>> over what you have. The first thing to do is to back away from putting much
>> of ANY action code in to the grammar.
>
> Just use helper classes to build the tree and pass in $NUMBER directly. Then
> you can use the properties in the structure you get to build your string in an
> external method. The parser should then have MyHelperClass in @members.
--
Best regards,
Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc
Valentina - Joining Worlds of Information
http://www.paradigmasoft.com
[I feel the need: the need for speed]
More information about the antlr-interest
mailing list