ANTLR 4 规则中的选项发生了什么变化? [英] What happened to options in rules in ANTLR 4?

查看:41
本文介绍了ANTLR 4 规则中的选项发生了什么变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不会在 ANTLR 4 中编译:

This does not compile in ANTLR 4:

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

因为 backtrace=true...发生了什么?

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

我应该在 ANTLR 4 中使用什么来代替它?

WHat should I use in ANTLR 4 instread of it?

推荐答案

目前,ANTLR v4 中没有规则级别的选项.注意 backtrack=true 不再需要,因为新的解析算法不需要回溯.另请注意,在 ANTLR v3 中,backtrack=true 在词法分析器规则中无效,仅在解析器规则中有效.

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.

这篇关于ANTLR 4 规则中的选项发生了什么变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆