antlr4-runtime
Version:
JavaScript runtime for ANTLR4
31 lines (26 loc) • 1.07 kB
JavaScript
/* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved.
* Use is of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
import Predicate from "../atn/Predicate.js";
import Transition from "./Transition.js";
import AbstractPredicateTransition from "../atn/AbstractPredicateTransition.js";
export default class PredicateTransition extends AbstractPredicateTransition {
constructor(target, ruleIndex, predIndex, isCtxDependent) {
super(target);
this.serializationType = Transition.PREDICATE;
this.ruleIndex = ruleIndex;
this.predIndex = predIndex;
this.isCtxDependent = isCtxDependent; // e.g., $i ref in pred
this.isEpsilon = true;
}
matches(symbol, minVocabSymbol, maxVocabSymbol) {
return false;
}
getPredicate() {
return new Predicate(this.ruleIndex, this.predIndex, this.isCtxDependent);
}
toString() {
return "pred_" + this.ruleIndex + ":" + this.predIndex;
}
}