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

Kevin J. Cummings cummings at kjchome.homeip.net
Wed Nov 21 14:33:41 PST 2007


Guntis Ozols wrote:
> Thanks, guys!
> 
> I've finally found (thanks to Jim Idle) a solution that both works and
> is based on syntactic predicates:
>   STAR : '*' (('**') => '**'  { type = TRISTAR; } | );
> 
> Solution by Kay Röpke also works:
>   TRISTAR : {input.LA(3) == '*'}? => '*' '*' '*';
>   STAR    : '*';
> 
> I still do not understand why
>   STAR : '*' ;
>   TRISTAR : ('***') => '***';
> does not work as expected, I think it is a bug in v3.

What happens if you reverse the order of STAR and TRISTAR in the
previous example, ie don't recognize STAR before you've check for
TRISTAR.  I was under the impression that ANTLR was dependent upon the
order of certain productions.

-- 
Kevin J. Cummings
kjchome at rcn.com
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)


More information about the antlr-interest mailing list