bitmark-grammar
Version:
52 lines (42 loc) • 1.26 kB
text/typescript
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
// ConvertTo-TS run at 2016-10-04T11:26:37.3060135-07:00
import { ATNState } from "./ATNState";
import { IntervalSet } from "../misc/IntervalSet";
import { Override, NotNull, Nullable } from "../Decorators";
import { Token } from "../Token";
import { Transition } from "./Transition";
import { TransitionType } from "./TransitionType";
/** A transition containing a set of values. */
export class SetTransition extends Transition {
public set: IntervalSet;
// TODO (sam): should we really allow undefined here?
constructor( target: ATNState, set: IntervalSet) {
super(target);
if (set == null) {
set = IntervalSet.of(Token.INVALID_TYPE);
}
this.set = set;
}
get serializationType(): TransitionType {
return TransitionType.SET;
}
get label(): IntervalSet {
return this.set;
}
public matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean {
return this.set.contains(symbol);
}
public toString(): string {
return this.set.toString();
}
}