1 回答

TA贡献1789条经验 获得超8个赞
我不知道 Go,但在 Java 中你可以这样做:
// In this example, the grammar is called `T.g4`
class WhileLastMoveListener extends TBaseListener {
private boolean insideWhileCondition = false;
@Override
public void enterWhile_condition(TParser.While_conditionContext ctx) {
this.insideWhileCondition = true;
}
@Override
public void exitWhile_condition(TParser.While_conditionContext ctx) {
this.insideWhileCondition = false;
}
@Override
public void enterF_lastmove(TParser.F_lastmoveContext ctx) {
if (this.insideWhileCondition) {
// Found a `f_lastmove` rule inside a while `while_condition`
}
}
}
- 1 回答
- 0 关注
- 86 浏览
添加回答
举报