/proc/self/cwd/external/antlr4-cpp-runtime~/runtime/src/NoViableAltException.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 "Parser.h" |
7 | | |
8 | | #include "NoViableAltException.h" |
9 | | |
10 | | using namespace antlr4; |
11 | | |
12 | | namespace { |
13 | | |
14 | | // Create a normal shared pointer if the configurations are to be deleted. If not, then |
15 | | // the shared pointer is created with a deleter that does nothing. |
16 | 15.9k | Ref<atn::ATNConfigSet> buildConfigsRef(atn::ATNConfigSet *configs, bool deleteConfigs) { |
17 | 15.9k | if (deleteConfigs) { |
18 | 0 | return Ref<atn::ATNConfigSet>(configs); |
19 | 15.9k | } else { |
20 | 15.9k | return Ref<atn::ATNConfigSet>(configs, [](atn::ATNConfigSet *){}); |
21 | 15.9k | } |
22 | 15.9k | } |
23 | | |
24 | | } |
25 | | |
26 | | NoViableAltException::NoViableAltException(Parser *recognizer) |
27 | 0 | : NoViableAltException(recognizer, recognizer->getTokenStream(), recognizer->getCurrentToken(), |
28 | 0 | recognizer->getCurrentToken(), nullptr, recognizer->getContext(), false) { |
29 | 0 | } |
30 | | |
31 | | NoViableAltException::NoViableAltException(Parser *recognizer, TokenStream *input,Token *startToken, |
32 | | Token *offendingToken, atn::ATNConfigSet *deadEndConfigs, ParserRuleContext *ctx, bool deleteConfigs) |
33 | 15.9k | : RecognitionException("No viable alternative", recognizer, input, ctx, offendingToken), |
34 | 15.9k | _deadEndConfigs(buildConfigsRef(deadEndConfigs, deleteConfigs)), _startToken(startToken) { |
35 | 15.9k | } |
36 | | |
37 | 20.6k | NoViableAltException::~NoViableAltException() { |
38 | 20.6k | } |
39 | | |
40 | 2.70k | Token* NoViableAltException::getStartToken() const { |
41 | 2.70k | return _startToken; |
42 | 2.70k | } |
43 | | |
44 | 0 | atn::ATNConfigSet* NoViableAltException::getDeadEndConfigs() const { |
45 | 0 | return _deadEndConfigs.get(); |
46 | 0 | } |