gpt4 book ai didi

java - RuleContext 类实现中的 invokingState 是什么?

转载 作者:行者123 更新时间:2023-12-02 02:06:35 27 4
gpt4 key购买 nike

我在 JavaParser.java 中看到规则索引,但还有另一个整数值,即调用状态。这个调用状态与 getStartToken 相关吗?或者它与规则索引有何不同?

最佳答案

调用状态是 ATN 状态,用于到达由该规则上下文表示的规则。 comment in the source code很好地解释了这一点:

/** What state invoked the rule associated with this context? * The "return address" is the followState of invokingState * If parent is null, this should be -1 this context object represents * the start rule. */

这是一个例子:

enter image description here

这是规则 start: e EOF; 的 ATN,其中 e 表示子规则。状态 4 是 e 的调用状态,状态 5 是返回(或跟随)状态。请记住,可以从多个位置调用规则,因此您无法使用从规则结束状态的转换返回到调用规则(因此需要 followState 成员)。该返回状态存储在 rule transition 中从调用状态(本例中为状态 4)转到规则开始状态 e

关于java - RuleContext 类实现中的 invokingState 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50680438/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com