Skip to content

Commit

Permalink
fix: don't log out to stderr on parser errors (#3052)
Browse files Browse the repository at this point in the history
By default the lexer and parser log out to stderr. This change removes these default error handlers in favour of ones that throw exceptions.
  • Loading branch information
big-andy-coates authored Jul 4, 2019
1 parent 8c6d36f commit 29dea47
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static TableElements parse(final String schema) {
final CommonTokenStream tokStream = new CommonTokenStream(lexer);
final SqlBaseParser parser = new SqlBaseParser(tokStream);

parser.addErrorListener(new BaseErrorListener() {
final BaseErrorListener errorListener = new BaseErrorListener() {
@Override
public void syntaxError(
final Recognizer<?, ?> recognizer,
Expand All @@ -61,7 +61,13 @@ public void syntaxError(
msg),
e);
}
});
};

lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);

parser.removeErrorListeners();
parser.addErrorListener(errorListener);

final List<TableElement> elements = parser.tableElements().tableElement()
.stream()
Expand Down

0 comments on commit 29dea47

Please sign in to comment.