1 回答

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊
我不知道 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 關(guān)注
- 99 瀏覽
添加回答
舉報(bào)