[antlr-interest] Modifying token text - is it possible?
Jim Idle
jimi at temporal-wave.com
Tue Nov 20 15:11:16 PST 2007
How about:
fragment
TAG_GUTS: LETTER+
{ emit(); }
;
HTML_TAG: '<' TAG_GUTS '>'
;
You may need to set the token type for the emitted token.
You can also do: xxx=FRAGRULE and set the token text to $xxx.text
Jim
> -----Original Message-----
> From: Steve Bennett [mailto:stevagewp at gmail.com]
> Sent: Tuesday, November 20, 2007 3:10 PM
> To: Terence Parr
> Cc: antlr-interest Interest
> Subject: Re: [antlr-interest] Modifying token text - is it possible?
>
> On 11/21/07, Terence Parr <parrt at cs.usfca.edu> wrote:
> > Hi. that is v2 stuff so beware. Try setText, which modifies the text
> > member of the lexer.
>
> So what about this syntax:
>
> > > FOO: '<'! ... ; // '<' does not become part of the token
>
> Is there a v3 equivalent? What's the correct way to get behaviour like:
>
> HTML_TAG: '<'! LETTER+ '>'!;
>
> Steve
More information about the antlr-interest
mailing list