[antlr-interest] Can antlr v3 lex star | tristar properly?

Jim Idle jimi at temporal-wave.com
Wed Nov 21 14:25:23 PST 2007


Yes - I should clarify that I tend to use the fragment because that prevents ANLTR from complaining that there is no token called STAR, which is what happens if you put in tokens { STAR; }

I just don't like warnings ;-)

Jim

> -----Original Message-----
> From: Clifford Heath [mailto:clifford.heath at gmail.com]
> Sent: Wednesday, November 21, 2007 2:29 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Can antlr v3 lex star | tristar properly?
> 
> Jim Idle wrote:
> > fragment STAR
> > : '*' ;
> >
> > TRISTAR
> > 	: '*'
> > 		(  '*' '*'
> > 		  | { $type = STAR; }
> >             )
> > 	;
> 
> Jim,
> 
> I'm missing something here. Is the fragment STAR only
> required to tell ANTLR that there's a token called STAR?
> Because your example doesn't use it in the TRISTAR rule.
> 
> Assuming that's what you meant, would it be the same to
> just have defined STAR in the @tokens section?
> 
> Clifford Heath.
> 




More information about the antlr-interest mailing list