[antlr-interest] insert after tree?
Gavin Lambert
antlr at mirality.co.nz
Sun Jan 6 13:37:59 PST 2008
At 07:56 7/01/2008, Geoff hendrey wrote:
>likeExpression
> :(concatenationExpression 'LIKE' concatenationExpression)
> ->^('LIKE' concatenationExpression+ ESCAPE) ;
>
>I added the imaginary ESCAPE token, but I have not had any luck
>in my Java trying to replace the imaginary escape token with the
>real text "ESCAPE '~'". If only I could add a *real* token
>through my rewrite rule above , I would be in business.
The tree is a tree of tokens, not a tree of characters. So you
can't add an arbitrary '~' to it; you can only add a token
representing a '~'. Any tokens you insert manually into the
stream are imaginary tokens, because they're not tied to the input
stream. This is no different.
Note that even if you do add a TILDE token or something that
represents the '~', unless you do something convoluted it won't
have any text or source location. You'll need to match it based
on token type rather than contents.
More information about the antlr-interest
mailing list