本文介绍了从Antlr3转换为Antlr4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将antlr3语法转换为antlr4语法.我删除了所有语法谓词.我正在努力对此进行正确的转换
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?)
到antlr4语法.
每当antlr4工具遇到->"字符时,它都会说外部输入'->',期望{TOKEN_REF,RULE_REF ... ACTION}".
to antlr4 grammar.
Everytime the antlr4 tool runs into "->" character it says "extraneous input '->' expecting {TOKEN_REF, RULE_REF...ACTION}".
我该如何解决?
推荐答案
ANTLR4没有树重写.因此,请完全删除-> ...
:
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)?
;
这篇关于从Antlr3转换为Antlr4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!