Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

antlr 4.2.2 output to console warning (157)

Tags:

java

antlr

antlr4

I downloaded latest release of ANTLR - 4.2.2 (antlr-4.2.2-complete.jar) When I use it to generate parsers for grammar file Java.g4 it prints me some warnings like: "Java.g4:525:16: rule 'expression' contains an 'assoc' terminal option in an unrecognized location"

Files was generated but didn't compile

Previous version works fine.

Whats wrong?

like image 925
anastassiakh Avatar asked Apr 29 '14 08:04

anastassiakh


1 Answers

The <assoc> should now be moved left of the "expression".

It must be placed always right to the surrounding |:

Look here: https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Left-recursive+rules

 ...
 |   expression '&&' expression
    |   expression '||' expression
    |   expression '?' expression ':' expression
    |<assoc=right>   expression
        (   '='
        |   '+='
        |   '-='
        |   '*='
        |   '/='
        |   '&='
        |   '|='
        |   '^='
        |   '>>='
        |   '>>>='
        |   '<<='
        |   '%='
        )
        expression
like image 68
Onur Avatar answered Nov 15 '22 05:11

Onur