[antlr-interest] Interesting problem with labels in V4b1
Sam Harwell
sam at tunnelvisionlabs.com
Sat Sep 22 15:25:56 PDT 2012
Your alternatives should be separated by |, not !.
Sam
-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Mike Cargal
Sent: Saturday, September 22, 2012 4:56 PM
To: antlr-interest at antlr.org list
Subject: [antlr-interest] Interesting problem with labels in V4b1
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