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.
6 #include "misc/Interval.h"
7 #include "support/CPPUtils.h"
8 #include "CharStream.h"
11 #include "LexerNoViableAltException.h"
13 using namespace antlr4;
15 LexerNoViableAltException::LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex,
16 atn::ATNConfigSet *deadEndConfigs)
17 : RecognitionException(lexer, input, nullptr, nullptr), _startIndex(startIndex), _deadEndConfigs(deadEndConfigs) {
20 size_t LexerNoViableAltException::getStartIndex() {
24 atn::ATNConfigSet* LexerNoViableAltException::getDeadEndConfigs() {
25 return _deadEndConfigs;
28 std::string LexerNoViableAltException::toString() {
30 if (_startIndex < getInputStream()->size()) {
31 symbol = static_cast<CharStream *>(getInputStream())->getText(misc::Interval(_startIndex, _startIndex));
32 symbol = antlrcpp::escapeWhitespace(symbol, false);
34 std::string format = "LexerNoViableAltException('" + symbol + "')";