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

Guntis Ozols guntiso at latnet.lv
Wed Nov 21 14:40:53 PST 2007


Citēju "Kevin J. Cummings" <cummings at kjchome.homeip.net>:

> 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.

Does not work

> --
> 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