[antlr-interest] Can antlr v3 lex star | tristar properly?
Jim Idle
jimi at temporal-wave.com
Wed Nov 21 14:53:15 PST 2007
> -----Original Message-----
> From: Guntis Ozols [mailto:guntiso at latnet.lv]
> Sent: Wednesday, November 21, 2007 2:55 PM
> To: antlr-interest
> Subject: Re: [antlr-interest] Can antlr v3 lex star | tristar properly?
>
> > fragment STAR
> > : '*' ;
> >
> > TRISTAR
> > : '*'
> > ( '*' '*'
> > | { $type = STAR; }
> > )
> > ;
>
> Does not work
You probably do need the predicate:
( ('**')=> '**'
| ...
You should regard the lexer as a kind of simplified parser. You would not expect to just throw a bunch o rules at the parser and hope it sorts them out, and you also need to make sure you are no expecting the lexer part of this to do the same :-)
Jim
More information about the antlr-interest
mailing list