^ 和 !在 ANTLR 语法中代表 [英] What does ^ and ! stand for in ANTLR grammar
本文介绍了^ 和 !在 ANTLR 语法中代表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很难弄清楚 ^ 和 !代表 ANTLR 语法术语.
I was having difficulty figuring out what does ^ and ! stand for in ANTLR grammar terminology.
推荐答案
查看 ANTLR 备忘单:
!
不包含在 AST 中^
制作AST根节点
!
don't include in AST
^
make AST root node
而且^
也可以用于重写规则:... ->^( ... )
.例如,以下两个解析器规则是等价的:
And ^
can also be used in rewrite rules: ... -> ^( ... )
. For example, the following two parser rules are equivalent:
expression
: A '+'^ A ';'!
;
和:
expression
: A '+' A ';' -> ^('+' A A)
;
两者都创建了以下 AST:
Both create the following AST:
+
/ \
A A
换句话说:+
是根,两个 A
的子元素,;
从树.
In other words: the +
is made as root, the two A
's its children, and the ;
is omitted from the tree.
这篇关于^ 和 !在 ANTLR 语法中代表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文