]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/AtomTransition.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / AtomTransition.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 #include "atn/Transition.h"
8
9 #include "atn/AtomTransition.h"
10
11 using namespace antlr4::misc;
12 using namespace antlr4::atn;
13
14 AtomTransition::AtomTransition(ATNState *target, size_t label) : Transition(target), _label(label) {
15 }
16
17 Transition::SerializationType AtomTransition::getSerializationType() const {
18   return ATOM;
19 }
20
21 IntervalSet AtomTransition::label() const {
22   return IntervalSet::of((int)_label);
23 }
24
25 bool AtomTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const {
26   return _label == symbol;
27 }
28
29 std::string AtomTransition::toString() const {
30   return "ATOM " + Transition::toString() + " { label: " + std::to_string(_label) + " }";
31 }