else format

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9403]
This commit is contained in:
parrt 2011-11-19 13:09:48 -08:00
parent 20f86b8018
commit 4476cbf22b
1 changed files with 10 additions and 7 deletions

View File

@ -29,9 +29,8 @@
package org.antlr.v4.runtime; package org.antlr.v4.runtime;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.misc.IntervalSet; import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.AST; import org.antlr.v4.runtime.tree.AST;
/** This is the default error handling mechanism for ANTLR parsers /** This is the default error handling mechanism for ANTLR parsers
@ -193,7 +192,7 @@ public class DefaultANTLRErrorStrategy<TSymbol> implements ANTLRErrorStrategy<TS
input = "<unknown input>"; input = "<unknown input>";
} }
String msg = "no viable alternative at input "+escapeWSAndQuote(input); String msg = "no viable alternative at input "+escapeWSAndQuote(input);
recognizer.notifyListeners((TSymbol)e.offendingNode, msg, e); recognizer.notifyListeners((TSymbol) e.offendingNode, msg, e);
} }
public void reportInputMismatch(BaseRecognizer<TSymbol> recognizer, public void reportInputMismatch(BaseRecognizer<TSymbol> recognizer,
@ -400,9 +399,11 @@ public class DefaultANTLRErrorStrategy<TSymbol> implements ANTLRErrorStrategy<TS
protected String getSymbolText(@NotNull TSymbol symbol) { protected String getSymbolText(@NotNull TSymbol symbol) {
if (symbol instanceof Token) { if (symbol instanceof Token) {
return ((Token)symbol).getText(); return ((Token)symbol).getText();
} else if (symbol instanceof AST) { }
else if (symbol instanceof AST) {
return ((AST)symbol).getText(); return ((AST)symbol).getText();
} else { }
else {
return symbol.toString(); return symbol.toString();
} }
} }
@ -410,9 +411,11 @@ public class DefaultANTLRErrorStrategy<TSymbol> implements ANTLRErrorStrategy<TS
protected int getSymbolType(@NotNull TSymbol symbol) { protected int getSymbolType(@NotNull TSymbol symbol) {
if (symbol instanceof Token) { if (symbol instanceof Token) {
return ((Token)symbol).getType(); return ((Token)symbol).getType();
} else if (symbol instanceof AST) { }
else if (symbol instanceof AST) {
return ((AST)symbol).getType(); return ((AST)symbol).getType();
} else { }
else {
return Token.INVALID_TYPE; return Token.INVALID_TYPE;
} }
} }