[antlr-interest] newbi question : operator + any

Kyle Ferrio kferrio at gmail.com
Tue Feb 7 15:32:55 PST 2012


Hi.  Joining late.  I don't know how much this helps, but my experience is
that when I make a grammar "too" simple (usually in an effort to understand
antlr better) I sometimes run into interesting edge cases which teach/test
something different from my original intent.  I don't know what you need to
do, but if you place some constraints on your grammar...like comparisons
operate on expressions and (e.g.) expressions are limited to well-formed
alphanumeric identifiers...you might find a fast path to a solution.  If
you really need to compare 'anything's with almost no syntactic limits,
then you should ignore this advice!

Kyle
 On Feb 6, 2012 5:30 AM, "Marco Laponder" <marco.laponder at kewill.com> wrote:

> Hi All,
>
>
>
> I am trying to setup a very simple grammar, ik should be able to handle
>
>
>
> "> thiscouldbeanything"
>
>
>
> So I tried:
>
>
>
> COMPARE : '>';
>
> ANYTHING : (.)+;
>
> testExpression : COMPARE ANYTHING;
>
>
>
> but when generating java resources it gave me the error:
>
>
>
> "The following alternatives can never be matched: 1"
>
>
>
> The problems seems to be the ANYTHING, so how should I define a grammar
> to be able to handle this ?
>
>
>
> Kind regards,
>
> Marco
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list