[antlr-interest] Interesting problem with labels in V4b1

Eric researcher0x00 at gmail.com
Sat Sep 22 15:03:12 PDT 2012


Hi Mike,

Just giving it a quick syntactic look it looks like the vertical bar before
'^' is an exclamation point.

Eric

On Sat, Sep 22, 2012 at 5:56 PM, Mike Cargal <mike at cargal.net> wrote:

> This:
>
> grammar Foo;
> expr        :   '(' expr ')'           # parenExpr
>             |   '%' expr               # pctExpr
>             !   '^' expr               # expnExpr
>             |   expr ('*'|'/') expr    # multExpr
>             |   expr ('+'|'-') expr    # addExpr
>             ;
> gives me the following errors…
> error(50): Foo.g4:4:16: mismatched input ''^'' expecting SEMI while
> matching a rule
> error(50): Foo.g4:4:37: '#' came as a complete surprise to me while
> matching rule preamble
>
>
> This:
>
> grammar Foo;
> expr        :   '(' expr ')'           # parenExpr
>             |   '%' expr               # pctExpr
> //            !   '^' expr               # expnExpr
>             |   expr ('*'|'/') expr    # multExpr
>             |   expr ('+'|'-') expr    # addExpr
>             ;
>
> generates without error
>
> and this:
>
> grammar Foo;
> expr        :   '(' expr ')'
>             |   '%' expr
>             !   '^' expr
>             |   expr ('*'|'/') expr
>             |   expr ('+'|'-') expr
>             ;
>
> generates without error
>
> all compiled using:
> java -jar /usr/local/lib/antlr-4.0b1-complete.jar -visitor Foo.g4
>
> Somehow the exponentiation expression is a problem if and only if I'm
> using labels.
>
> 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