[antlr-interest] Manipulating text in the lexer
Gavin Lambert
antlr at mirality.co.nz
Fri Feb 27 00:53:09 PST 2009
At 12:06 27/02/2009, Sam Barnett-Cormack wrote:
>Of course, it would be hard to structure, if I have to set the
>text of the whole damn token at once. If we had the old !
>operator, it'd be easy enough... make the '"' at the beginning
>and end be missed out, make the first of the three choices be
>ignored, and make the second be !'"' '"'.
>That'd be just grand. However, I can't see an easy way to make
>the resulting token text be what I want it to be with the
>current system. If anyone knows how I can, please let me know.
Use a combination of substring (to strip the surrounding quotes)
and replace (to do anything else). Easy.
(It's even easier if you have access to a parallel replace
function, instead of the more common serial function.)
More information about the antlr-interest
mailing list