Difference between Antlr 3 and Antlr 4 in handling of extra parentheses in grammar

115 views
Skip to first unread message

Jim Sculley

unread,
Jul 25, 2016, 11:47:18 AM7/25/16
to antlr-discussion
Is there a reason why Antlr4 rejects superfluous parentheses surrounding groups whereas Antler 3 accepts them?  For example:

grammar Test;
testRule
: THING;
THING
: 'A' ~(('A'))*;


Antlr 4 will fail with the following:

error(50): Test.g:3:14: syntax error: '(' came as a complete surprise to me while looking for lexer rule element
error
(50): Test.g:3:19: syntax error: mismatched input ')' expecting SEMI while matching a lexer rule

The extra parentheses seem harmless to me (a relative novice) but perhaps there is a valid reason that Antlr4 flags it as an error.


Reply all
Reply to author
Forward
0 new messages