error->syntaxError in listener
This commit is contained in:
parent
740208ee4d
commit
f396b4dc82
|
@ -70,7 +70,7 @@ public interface ANTLRErrorListener<Symbol> {
|
||||||
* the parser was able to recover in line without exiting the
|
* the parser was able to recover in line without exiting the
|
||||||
* surrounding rule.
|
* surrounding rule.
|
||||||
*/
|
*/
|
||||||
public <T extends Symbol> void error(Recognizer<T, ?> recognizer,
|
public <T extends Symbol> void syntaxError(Recognizer<T, ?> recognizer,
|
||||||
@Nullable T offendingSymbol,
|
@Nullable T offendingSymbol,
|
||||||
int line,
|
int line,
|
||||||
int charPositionInLine,
|
int charPositionInLine,
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.antlr.v4.runtime.misc.IntervalSet;
|
||||||
public class BaseErrorListener<Symbol> implements ANTLRErrorListener<Symbol> {
|
public class BaseErrorListener<Symbol> implements ANTLRErrorListener<Symbol> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Symbol> void error(Recognizer<T, ?> recognizer,
|
public <T extends Symbol> void syntaxError(Recognizer<T, ?> recognizer,
|
||||||
T offendingSymbol,
|
T offendingSymbol,
|
||||||
int line,
|
int line,
|
||||||
int charPositionInLine,
|
int charPositionInLine,
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class ConsoleErrorListener extends BaseErrorListener<Object> {
|
||||||
public static final ConsoleErrorListener INSTANCE = new ConsoleErrorListener();
|
public static final ConsoleErrorListener INSTANCE = new ConsoleErrorListener();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Object> void error(Recognizer<T, ?> recognizer,
|
public <T extends Object> void syntaxError(Recognizer<T, ?> recognizer,
|
||||||
T offendingSymbol,
|
T offendingSymbol,
|
||||||
int line,
|
int line,
|
||||||
int charPositionInLine,
|
int charPositionInLine,
|
||||||
|
|
|
@ -329,7 +329,7 @@ public abstract class Lexer extends Recognizer<Integer, LexerATNSimulator>
|
||||||
_input.getText(Interval.of(_tokenStartCharIndex, _input.index()))+"'";
|
_input.getText(Interval.of(_tokenStartCharIndex, _input.index()))+"'";
|
||||||
|
|
||||||
ANTLRErrorListener<? super Integer> listener = getErrorListenerDispatch();
|
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) {
|
public String getCharErrorDisplay(int c) {
|
||||||
|
|
|
@ -317,7 +317,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator<Token>
|
||||||
}
|
}
|
||||||
|
|
||||||
ANTLRErrorListener<? super Token> listener = getErrorListenerDispatch();
|
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
|
/** Consume the current symbol and return it. E.g., given the following
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ProxyErrorListener<Symbol> implements ANTLRErrorListener<Symbol> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Symbol> void error(Recognizer<T, ?> recognizer,
|
public <T extends Symbol> void syntaxError(Recognizer<T, ?> recognizer,
|
||||||
T offendingSymbol,
|
T offendingSymbol,
|
||||||
int line,
|
int line,
|
||||||
int charPositionInLine,
|
int charPositionInLine,
|
||||||
|
@ -54,7 +54,7 @@ public class ProxyErrorListener<Symbol> implements ANTLRErrorListener<Symbol> {
|
||||||
RecognitionException e)
|
RecognitionException e)
|
||||||
{
|
{
|
||||||
for (ANTLRErrorListener<? super Symbol> listener : delegates) {
|
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();
|
public static DescriptiveErrorListener INSTANCE = new DescriptiveErrorListener();
|
||||||
|
|
||||||
@Override
|
@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();
|
String sourceName = recognizer.getInputStream().getSourceName();
|
||||||
sourceName = sourceName != null && !sourceName.isEmpty() ? sourceName+": " : "";
|
sourceName = sourceName != null && !sourceName.isEmpty() ? sourceName+": " : "";
|
||||||
System.err.println(sourceName+"line "+line+":"+charPositionInLine+" "+msg);
|
System.err.println(sourceName+"line "+line+":"+charPositionInLine+" "+msg);
|
||||||
|
|
Loading…
Reference in New Issue