]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/RuleTransition.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / RuleTransition.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 "atn/RuleStartState.h"
7 #include "atn/RuleTransition.h"
8
9 using namespace antlr4::atn;
10
11 RuleTransition::RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState)
12   : RuleTransition(ruleStart, ruleIndex, 0, followState) {
13 }
14
15 RuleTransition::RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState)
16   : Transition(ruleStart), ruleIndex(ruleIndex), precedence(precedence) {
17   this->followState = followState;
18 }
19
20 Transition::SerializationType RuleTransition::getSerializationType() const {
21   return RULE;
22 }
23
24 bool RuleTransition::isEpsilon() const {
25   return true;
26 }
27
28 bool RuleTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const {
29   return false;
30 }
31
32 std::string RuleTransition::toString() const {
33   std::stringstream ss;
34   ss << "RULE " << Transition::toString() << " { ruleIndex: " << ruleIndex << ", precedence: " << precedence <<
35     ", followState: " << std::hex << followState << " }";
36   return ss.str();
37 }