/proc/self/cwd/external/antlr4-cpp-runtime~/runtime/src/RecognitionException.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/ATN.h" |
7 | | #include "Recognizer.h" |
8 | | #include "ParserRuleContext.h" |
9 | | #include "misc/IntervalSet.h" |
10 | | |
11 | | #include "RecognitionException.h" |
12 | | |
13 | | using namespace antlr4; |
14 | | |
15 | | RecognitionException::RecognitionException(Recognizer *recognizer, IntStream *input, ParserRuleContext *ctx, |
16 | | Token *offendingToken) |
17 | 1.77M | : RecognitionException("", recognizer, input, ctx, offendingToken) { |
18 | 1.77M | } |
19 | | |
20 | | RecognitionException::RecognitionException(const std::string &message, Recognizer *recognizer, IntStream *input, |
21 | | ParserRuleContext *ctx, Token *offendingToken) |
22 | 1.78M | : RuntimeException(message), _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) { |
23 | 1.78M | InitializeInstanceFields(); |
24 | 1.78M | if (recognizer != nullptr) { |
25 | 1.78M | _offendingState = recognizer->getState(); |
26 | 1.78M | } |
27 | 1.78M | } |
28 | | |
29 | 1.80M | RecognitionException::~RecognitionException() { |
30 | 1.80M | } |
31 | | |
32 | 0 | size_t RecognitionException::getOffendingState() const { |
33 | 0 | return _offendingState; |
34 | 0 | } |
35 | | |
36 | 0 | void RecognitionException::setOffendingState(size_t offendingState) { |
37 | 0 | _offendingState = offendingState; |
38 | 0 | } |
39 | | |
40 | 4.99k | misc::IntervalSet RecognitionException::getExpectedTokens() const { |
41 | 4.99k | if (_recognizer) { |
42 | 4.99k | return _recognizer->getATN().getExpectedTokens(_offendingState, _ctx); |
43 | 4.99k | } |
44 | 0 | return misc::IntervalSet::EMPTY_SET; |
45 | 4.99k | } |
46 | | |
47 | 0 | RuleContext* RecognitionException::getCtx() const { |
48 | 0 | return _ctx; |
49 | 0 | } |
50 | | |
51 | 0 | IntStream* RecognitionException::getInputStream() const { |
52 | 0 | return _input; |
53 | 0 | } |
54 | | |
55 | 12.6k | Token* RecognitionException::getOffendingToken() const { |
56 | 12.6k | return _offendingToken; |
57 | 12.6k | } |
58 | | |
59 | 0 | Recognizer* RecognitionException::getRecognizer() const { |
60 | 0 | return _recognizer; |
61 | 0 | } |
62 | | |
63 | 1.78M | void RecognitionException::InitializeInstanceFields() { |
64 | | _offendingState = INVALID_INDEX; |
65 | 1.78M | } |