1 /// 2 /// Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 /// Use of this file is governed by the BSD 3-clause license that 4 /// can be found in the LICENSE.txt file in the project root. 5 /// 6 7 8 public class LexerNoViableAltException: RecognitionException, CustomStringConvertible { 9 /// 10 /// Matching attempted at what input index? 11 /// 12 private let startIndex: Int 13 14 /// 15 /// Which configurations did we try at input.index() that couldn't match input.LA(1)? 16 /// 17 private let deadEndConfigs: ATNConfigSet 18 19 public init(_ lexer: Lexer?, 20 _ input: CharStream, 21 _ startIndex: Int, 22 _ deadEndConfigs: ATNConfigSet) { 23 let ctx: ParserRuleContext? = nil 24 self.startIndex = startIndex 25 self.deadEndConfigs = deadEndConfigs 26 super.init(lexer, input as IntStream, ctx) 27 28 } 29 getStartIndexnull30 public func getStartIndex() -> Int { 31 return startIndex 32 } 33 getDeadEndConfigsnull34 public func getDeadEndConfigs() -> ATNConfigSet { 35 return deadEndConfigs 36 } 37 38 public var description: String { 39 var symbol = "" 40 if let charStream = getInputStream() as? CharStream, startIndex >= 0 && startIndex < charStream.size() { 41 let interval = Interval.of(startIndex, startIndex) 42 symbol = try! charStream.getText(interval) 43 symbol = Utils.escapeWhitespace(symbol, false) 44 } 45 46 return "\(LexerNoViableAltException.self)('\(symbol)')" 47 } 48 } 49