]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/RangeTransition.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / RangeTransition.cpp
1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 #include "misc/IntervalSet.h"
7
8 #include "atn/RangeTransition.h"
9
10 using namespace antlr4;
11 using namespace antlr4::atn;
12
13 RangeTransition::RangeTransition(ATNState *target, size_t from, size_t to) : Transition(target), from(from), to(to) {
14 }
15
16 Transition::SerializationType RangeTransition::getSerializationType() const {
17   return RANGE;
18 }
19
20 misc::IntervalSet RangeTransition::label() const {
21   return misc::IntervalSet::of((int)from, (int)to);
22 }
23
24 bool RangeTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const {
25   return symbol >= from && symbol <= to;
26 }
27
28 std::string RangeTransition::toString() const {
29   return "RANGE " + Transition::toString() + " { from: " + std::to_string(from) + ", to: " + std::to_string(to) + " }";
30 }