From bc87562aff8fc274d17760a6c393c75083d4dda7 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 15 Feb 2012 11:01:01 -0600 Subject: [PATCH] Remove unused exception LexerRecognitionExeption [sic] --- .../v4/runtime/LexerRecognitionExeption.java | 65 ------------------- .../v4/test/TestATNLexerInterpreter.java | 12 ++-- 2 files changed, 6 insertions(+), 71 deletions(-) delete mode 100644 runtime/Java/src/org/antlr/v4/runtime/LexerRecognitionExeption.java diff --git a/runtime/Java/src/org/antlr/v4/runtime/LexerRecognitionExeption.java b/runtime/Java/src/org/antlr/v4/runtime/LexerRecognitionExeption.java deleted file mode 100644 index fbdb7d234..000000000 --- a/runtime/Java/src/org/antlr/v4/runtime/LexerRecognitionExeption.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - [The "BSD license"] - Copyright (c) 2011 Terence Parr - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.antlr.v4.runtime; - -// TODO: del or rename LexerNoViableAlt? -public class LexerRecognitionExeption extends RuntimeException { - /** Who threw the exception? */ - public Lexer lexer; - - /** What is index of token/char were we looking at when the error occurred? */ - public int index; - - /** The current char when an error occurred. For lexers. */ - public int c; - - /** Track the line at which the error occurred in case this is - * generated from a lexer. We need to track this since the - * unexpected char doesn't carry the line info. - */ - public int line; - - public int charPositionInLine; - - /** Used for remote debugger deserialization */ - public LexerRecognitionExeption() { - } - - public LexerRecognitionExeption(Lexer lexer, CharStream input) { - this.lexer = lexer; - this.index = input.index(); - this.c = input.LA(1); - if ( lexer!=null ) { - this.line = lexer.getLine(); - this.charPositionInLine = lexer.getCharPositionInLine(); - } - } - -} diff --git a/tool/test/org/antlr/v4/test/TestATNLexerInterpreter.java b/tool/test/org/antlr/v4/test/TestATNLexerInterpreter.java index 3e021d8f0..947d6a6c1 100644 --- a/tool/test/org/antlr/v4/test/TestATNLexerInterpreter.java +++ b/tool/test/org/antlr/v4/test/TestATNLexerInterpreter.java @@ -2,7 +2,7 @@ package org.antlr.v4.test; import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.LexerRecognitionExeption; +import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.atn.ATN; import org.antlr.v4.runtime.atn.ATNState; import org.antlr.v4.runtime.misc.Utils; @@ -72,7 +72,7 @@ public class TestATNLexerInterpreter extends BaseTest { " | 'xy' .\n" + // should not pursue '.' since xy already hit stop " ;\n"); checkLexerMatches(lg, "xy", "A, EOF"); - LexerRecognitionExeption e = checkLexerMatches(lg, "xyz", "A, EOF"); + RecognitionException e = checkLexerMatches(lg, "xyz", "A, EOF"); assertEquals("NoViableAltException('z')", e.toString()); } @@ -83,7 +83,7 @@ public class TestATNLexerInterpreter extends BaseTest { " | 'xy' . 'z'\n" + // will not pursue '.' since xy already hit stop (prior alt) " ;\n"); // checkLexerMatches(lg, "xy", "A, EOF"); - LexerRecognitionExeption e = checkLexerMatches(lg, "xyqz", "A, EOF"); + RecognitionException e = checkLexerMatches(lg, "xyqz", "A, EOF"); assertEquals("NoViableAltException('q')", e.toString()); } @@ -244,7 +244,7 @@ public class TestATNLexerInterpreter extends BaseTest { checkLexerMatches(lg, "a", expecting); } - protected LexerRecognitionExeption checkLexerMatches(LexerGrammar lg, String inputString, String expecting) { + protected RecognitionException checkLexerMatches(LexerGrammar lg, String inputString, String expecting) { ATN atn = createATN(lg); CharStream input = new ANTLRInputStream(inputString); ATNState startState = atn.modeNameToStartState.get("DEFAULT_MODE"); @@ -252,11 +252,11 @@ public class TestATNLexerInterpreter extends BaseTest { System.out.println(dot.getDOT(startState, true)); List tokenTypes = null; - LexerRecognitionExeption retException = null; + RecognitionException retException = null; try { tokenTypes = getTokenTypes(lg, atn, input, false); } - catch (LexerRecognitionExeption lre) { retException = lre; } + catch (RecognitionException lre) { retException = lre; } if ( retException!=null ) return retException; String result = Utils.join(tokenTypes.iterator(), ", ");