use of org.jabref.search.SearchLexer in project jabref by JabRef.
the class GrammarBasedSearchRule method init.
private void init(String query) throws ParseCancellationException {
if (Objects.equals(this.query, query)) {
return;
}
SearchLexer lexer = new SearchLexer(new ANTLRInputStream(query));
// no infos on file system
lexer.removeErrorListeners();
lexer.addErrorListener(ThrowingErrorListener.INSTANCE);
SearchParser parser = new SearchParser(new CommonTokenStream(lexer));
// no infos on file system
parser.removeErrorListeners();
parser.addErrorListener(ThrowingErrorListener.INSTANCE);
// ParseCancelationException on parse errors
parser.setErrorHandler(new BailErrorStrategy());
tree = parser.start();
this.query = query;
}
Aggregations