Converting from Antlr3 to Antlr4

匆匆过客 提交于 2019-12-12 06:32:44

问题


I am in the process of converting an antlr3 to antlr4 grammar. I have stripped out all the syntactic predicates. I am struggling to make a correct conversion of this

    relaxed_date_month_first
  : relaxed_day_of_week? relaxed_month COMMA? WHITE_SPACE relaxed_day_of_month (relaxed_year_prefix relaxed_year)?
      -> ^(EXPLICIT_DATE relaxed_day_of_month relaxed_month relaxed_day_of_week? relaxed_year?)

to antlr4 grammar.

Everytime the antlr4 tool runs into "->" character it says "extraneous input '->' expecting {TOKEN_REF, RULE_REF...ACTION}".

How do I fix this?


回答1:


ANTLR4 has no tree-rewriting. So, remove -> ... entirely:

relaxed_date_month_first
 : relaxed_day_of_week? relaxed_month COMMA? WHITE_SPACE relaxed_day_of_month (relaxed_year_prefix relaxed_year)?
 ;


来源:https://stackoverflow.com/questions/36858750/converting-from-antlr3-to-antlr4

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