[antlr-interest] Fragments and setText appear to not work at all - not even with code from the book
Kay Röpke
kroepke at classdump.org
Thu Nov 22 06:55:16 PST 2007
Hi!
On Nov 22, 2007, at 1:37 PM, Harald Mueller wrote:
> I tried to track discussions of this issue in all of 2007. What I
> came up with after about 2 hours search (for "fragment", "setText",
> "!"(!)) in all text is only the following:
I'm sure there's more, because I vividly remember those dicussions.
sorry I have no links right now. Maybe it was back 2006, dunno. The
first beta release wasn't the beginning of development on v3. I've
been involved since late 2005 and at the time Ter had been working on
it for quite some time, already.
> --------------
> On Apr 20, 2007, at 4:36 AM, Wincent Colaiuta wrote:
>
>> Replying to my own post with a more fleshed-out example grammar. My
>> question is, does the ! operator no longer have any effect in lexer
>> rules in ANTLR 3?
>
> At the moment, it does not work in version 3.
> Ter
> --------------
>
> Is this to mean that it will work one day?
The ! operator is pretty ugly to implement when all you have is
indices. If you are copying text like v2 does, it's trivial, because
then you just don't copy the text for a token/char if there's the !
operator tacked on.
With indices there can be holes in your character index ranges which
makes it non-trivial to assemble the text later on, aside from the
complexity of storing these non-contiguous ranges.
It is possible, but there are workarounds for most of the cases where
you might want it. If everything else fails, it is possible to
implement (and I think the ! is properly lexed and parsed by ANTLR).
So in theory you could write it yourself ;)
IIRC Ter was against implementing it for ANTLR v3 because it is hard
to get it right *and* efficient.
cheers,
-k
--
Kay Röpke
http://classdump.org/
More information about the antlr-interest
mailing list