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 module antlr.v4.runtime.LexerNoViableAltException; 8 9 import antlr.v4.runtime.CharStream; 10 import antlr.v4.runtime.Lexer; 11 import antlr.v4.runtime.RecognitionException; 12 import antlr.v4.runtime.atn.ATNConfigSet; 13 import antlr.v4.runtime.atn.LexerATNSimulator; 14 import antlr.v4.runtime.misc.Interval; 15 import antlr.v4.runtime.misc.Utils; 16 import std.format; 17 18 // Class LexerNoViableAltException 19 /** 20 * TODO add class description 21 */ 22 class LexerNoViableAltException : RecognitionException 23 { 24 25 /** 26 * Matching attempted at what input index? 27 */ 28 private int startIndex; 29 30 /** 31 * Which configurations did we try at input.index() that couldn't match input.LA(1)? 32 */ 33 private ATNConfigSet deadEndConfigs; 34 35 public this(Lexer lexer, CharStream input, int startIndex, ATNConfigSet deadEndConfigs) 36 { 37 super(lexer, input, null); 38 this.startIndex = startIndex; 39 this.deadEndConfigs = deadEndConfigs; 40 } 41 42 public int getStartIndex() 43 { 44 return startIndex; 45 } 46 47 public ATNConfigSet getDeadEndConfigs() 48 { 49 return deadEndConfigs; 50 } 51 52 /** 53 * @uml 54 * @override 55 */ 56 public override CharStream getInputStream() 57 { 58 return cast(CharStream)super.getInputStream; 59 } 60 61 /** 62 * @uml 63 * @override 64 */ 65 public override string toString() 66 { 67 string symbol = ""; 68 if (startIndex >= 0 && startIndex < getInputStream().size) { 69 symbol = getInputStream().getText(Interval.of(startIndex,startIndex)); 70 symbol = Utils.escapeWhitespace(symbol, false); 71 } 72 73 return format("%s('%s')", "LexerNoViableAltException", symbol); 74 } 75 76 }