antlr 4.2.2 output to console warning (157)

坚强是说给别人听的谎言 提交于 2019-12-23 09:58:19

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/23359363/antlr-4-2-2-output-to-console-warning-157

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!