[antlr-interest] Error on line 499 of TokenRewriteStream?

Geoff hendrey geoff_hendrey at yahoo.com
Sat Nov 29 17:52:03 PST 2008


Hi,

On line 499 of TokenRewriteStream, I find this line, which is consolidating adjacent InsertBeforeOp objects.

iop.text = catOpText(iop.text,prevIop.text);

The problem (at least it seems to be) is that it consolidates them in the opposite of the expected order. Let me give you an example. 
Suppose I have a token whose text "A", and suppose I perform a first insertAfter operation to insert the text "B".
Later on I perform a second insertAfter operation with the text "C". 

My expectation is that calling toString on the TokenRewriteStream produces "ABC". But this
is not the case due to the parameter order of catOpTest. Instead, I get "ACB". And as far as
I can tell there is no way around this.Can anyone tell me a solution? I tried inserting "B" and "C" before the token *after* "A". But when I look in the antlr code, all insertAfter calls internally convert to insertBefore, so this of course produced exactly the same result ..."ACB".


-geoff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081129/a0f424b6/attachment.html 


More information about the antlr-interest mailing list