What happened to options in rules in ANTLR 4?

我的未来我决定 提交于 2019-12-10 16:14:54

问题


This does not compile in ANTLR 4:

Number options { backtrack=true; }
  : (IntegerLiteral Range)=> IntegerLiteral { $type = IntegerLiteral; }
  | (FloatLiteral)=> FloatLiteral { $type = FloatLiteral; }
  | IntegerLiteral { $type = IntegerLiteral; }
  ;

because of backtrace= true... What happened to it?

WHat should I use in ANTLR 4 instread of it?


回答1:


At the moment, there are no rule-level options in ANTLR v4. Note that backtrack=true is no longer needed since the new parsing algorithm has no need for backtracking. Also note that in ANTLR v3, backtrack=true was not valid inside lexer rules, only parser rules.



来源:https://stackoverflow.com/questions/13661596/what-happened-to-options-in-rules-in-antlr-4

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