1 /*
2  * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3  * Use of this file is governed by the BSD 3-clause license that
4  * can be found in the LICENSE.txt file in the project root.
5  */
6 
7 package org.antlr.v4.runtime.atn;
8 
9 import org.antlr.v4.runtime.misc.IntervalSet;
10 
11 public final class RangeTransition extends Transition {
12 	public final int from;
13 	public final int to;
14 
RangeTransition(ATNState target, int from, int to)15 	public RangeTransition(ATNState target, int from, int to) {
16 		super(target);
17 		this.from = from;
18 		this.to = to;
19 	}
20 
21 	@Override
getSerializationType()22 	public int getSerializationType() {
23 		return RANGE;
24 	}
25 
26 	@Override
27 
label()28 	public IntervalSet label() { return IntervalSet.of(from, to); }
29 
30 	@Override
matches(int symbol, int minVocabSymbol, int maxVocabSymbol)31 	public boolean matches(int symbol, int minVocabSymbol, int maxVocabSymbol) {
32 		return symbol >= from && symbol <= to;
33 	}
34 
35 	@Override
toString()36 	public String toString() {
37 		return new StringBuilder("'")
38 				.appendCodePoint(from)
39 				.append("'..'")
40 				.appendCodePoint(to)
41 				.append("'")
42 				.toString();
43 	}
44 }
45