forked from jasder/antlr
error->syntaxError in listener
This commit is contained in:
parent
740208ee4d
commit
f396b4dc82
|
@ -70,12 +70,12 @@ public interface ANTLRErrorListener<Symbol> {
|
|||
* the parser was able to recover in line without exiting the
|
||||
* surrounding rule.
|
||||
*/
|
||||
public <T extends Symbol> void error(Recognizer<T, ?> recognizer,
|
||||
@Nullable T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
@Nullable RecognitionException e);
|
||||
public <T extends Symbol> void syntaxError(Recognizer<T, ?> recognizer,
|
||||
@Nullable T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
@Nullable RecognitionException e);
|
||||
|
||||
/** Called when the parser detects a true ambiguity: an input sequence can be matched
|
||||
* literally by two or more pass through the grammar. ANTLR resolves the ambiguity in
|
||||
|
|
|
@ -39,12 +39,12 @@ import org.antlr.v4.runtime.misc.IntervalSet;
|
|||
public class BaseErrorListener<Symbol> implements ANTLRErrorListener<Symbol> {
|
||||
|
||||
@Override
|
||||
public <T extends Symbol> void error(Recognizer<T, ?> recognizer,
|
||||
T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
public <T extends Symbol> void syntaxError(Recognizer<T, ?> recognizer,
|
||||
T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -36,12 +36,12 @@ public class ConsoleErrorListener extends BaseErrorListener<Object> {
|
|||
public static final ConsoleErrorListener INSTANCE = new ConsoleErrorListener();
|
||||
|
||||
@Override
|
||||
public <T extends Object> void error(Recognizer<T, ?> recognizer,
|
||||
T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
public <T extends Object> void syntaxError(Recognizer<T, ?> recognizer,
|
||||
T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
{
|
||||
System.err.println("line " + line + ":" + charPositionInLine + " " + msg);
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ public abstract class Lexer extends Recognizer<Integer, LexerATNSimulator>
|
|||
_input.getText(Interval.of(_tokenStartCharIndex, _input.index()))+"'";
|
||||
|
||||
ANTLRErrorListener<? super Integer> listener = getErrorListenerDispatch();
|
||||
listener.error(this, null, _tokenStartLine, _tokenStartCharPositionInLine, msg, e);
|
||||
listener.syntaxError(this, null, _tokenStartLine, _tokenStartCharPositionInLine, msg, e);
|
||||
}
|
||||
|
||||
public String getCharErrorDisplay(int c) {
|
||||
|
|
|
@ -317,7 +317,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator<Token>
|
|||
}
|
||||
|
||||
ANTLRErrorListener<? super Token> listener = getErrorListenerDispatch();
|
||||
listener.error(this, offendingToken, line, charPositionInLine, msg, e);
|
||||
listener.syntaxError(this, offendingToken, line, charPositionInLine, msg, e);
|
||||
}
|
||||
|
||||
/** Consume the current symbol and return it. E.g., given the following
|
||||
|
|
|
@ -46,15 +46,15 @@ public class ProxyErrorListener<Symbol> implements ANTLRErrorListener<Symbol> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T extends Symbol> void error(Recognizer<T, ?> recognizer,
|
||||
T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
public <T extends Symbol> void syntaxError(Recognizer<T, ?> recognizer,
|
||||
T offendingSymbol,
|
||||
int line,
|
||||
int charPositionInLine,
|
||||
String msg,
|
||||
RecognitionException e)
|
||||
{
|
||||
for (ANTLRErrorListener<? super Symbol> listener : delegates) {
|
||||
listener.error(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
||||
listener.syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -543,7 +543,7 @@ public class TestPerformance extends BaseTest {
|
|||
public static DescriptiveErrorListener INSTANCE = new DescriptiveErrorListener();
|
||||
|
||||
@Override
|
||||
public <T extends Token> void error(Recognizer<T, ?> recognizer, T offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
|
||||
public <T extends Token> void syntaxError(Recognizer<T, ?> recognizer, T offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
|
||||
String sourceName = recognizer.getInputStream().getSourceName();
|
||||
sourceName = sourceName != null && !sourceName.isEmpty() ? sourceName+": " : "";
|
||||
System.err.println(sourceName+"line "+line+":"+charPositionInLine+" "+msg);
|
||||
|
|
Loading…
Reference in New Issue