/proc/self/cwd/external/antlr4-cpp-runtime~/runtime/src/FailedPredicateException.cpp
Line | Count | Source |
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/ParserATNSimulator.h" |
7 | | #include "Parser.h" |
8 | | #include "atn/PredicateTransition.h" |
9 | | #include "atn/ATN.h" |
10 | | #include "atn/ATNState.h" |
11 | | #include "support/Casts.h" |
12 | | #include "support/CPPUtils.h" |
13 | | |
14 | | #include "FailedPredicateException.h" |
15 | | |
16 | | using namespace antlr4; |
17 | | using namespace antlrcpp; |
18 | | |
19 | 0 | FailedPredicateException::FailedPredicateException(Parser *recognizer) : FailedPredicateException(recognizer, "", "") { |
20 | 0 | } |
21 | | |
22 | 0 | FailedPredicateException::FailedPredicateException(Parser *recognizer, const std::string &predicate): FailedPredicateException(recognizer, predicate, "") { |
23 | 0 | } |
24 | | |
25 | | FailedPredicateException::FailedPredicateException(Parser *recognizer, const std::string &predicate, const std::string &message) |
26 | 0 | : RecognitionException(!message.empty() ? message : "failed predicate: " + predicate + "?", recognizer, |
27 | 0 | recognizer->getInputStream(), recognizer->getContext(), recognizer->getCurrentToken()) { |
28 | |
|
29 | 0 | atn::ATNState *s = recognizer->getInterpreter<atn::ATNSimulator>()->atn.states[recognizer->getState()]; |
30 | 0 | const atn::Transition *transition = s->transitions[0].get(); |
31 | 0 | if (transition->getTransitionType() == atn::TransitionType::PREDICATE) { |
32 | 0 | _ruleIndex = downCast<const atn::PredicateTransition&>(*transition).getRuleIndex(); |
33 | 0 | _predicateIndex = downCast<const atn::PredicateTransition&>(*transition).getPredIndex(); |
34 | 0 | } else { |
35 | 0 | _ruleIndex = 0; |
36 | 0 | _predicateIndex = 0; |
37 | 0 | } |
38 | |
|
39 | 0 | _predicate = predicate; |
40 | 0 | } |
41 | | |
42 | 0 | size_t FailedPredicateException::getRuleIndex() { |
43 | 0 | return _ruleIndex; |
44 | 0 | } |
45 | | |
46 | 0 | size_t FailedPredicateException::getPredIndex() { |
47 | 0 | return _predicateIndex; |
48 | 0 | } |
49 | | |
50 | 0 | std::string FailedPredicateException::getPredicate() { |
51 | 0 | return _predicate; |
52 | 0 | } |