^和!是什么?在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屋!
查看全文