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.
8 #include "NoViableAltException.h"
10 using namespace antlr4;
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 Ref<atn::ATNConfigSet> buildConfigsRef(atn::ATNConfigSet *configs, bool deleteConfigs) {
18 return Ref<atn::ATNConfigSet>(configs);
20 return Ref<atn::ATNConfigSet>(configs, [](atn::ATNConfigSet *){});
26 NoViableAltException::NoViableAltException(Parser *recognizer)
27 : NoViableAltException(recognizer, recognizer->getTokenStream(), recognizer->getCurrentToken(),
28 recognizer->getCurrentToken(), nullptr, recognizer->getContext(), false) {
31 NoViableAltException::NoViableAltException(Parser *recognizer, TokenStream *input,Token *startToken,
32 Token *offendingToken, atn::ATNConfigSet *deadEndConfigs, ParserRuleContext *ctx, bool deleteConfigs)
33 : RecognitionException("No viable alternative", recognizer, input, ctx, offendingToken),
34 _deadEndConfigs(buildConfigsRef(deadEndConfigs, deleteConfigs)), _startToken(startToken) {
37 NoViableAltException::~NoViableAltException() {
40 Token* NoViableAltException::getStartToken() const {
44 atn::ATNConfigSet* NoViableAltException::getDeadEndConfigs() const {
45 return _deadEndConfigs.get();