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

查看:104
本文介绍了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天全站免登陆