use of org.antlr.v4.runtime.CommonTokenStream in project syncope by apache.
the class SearchCondConverter method convert.
public static SearchCond convert(final SearchCondVisitor visitor, final String filter) {
SCIMFilterParser parser = new SCIMFilterParser(new CommonTokenStream(new SCIMFilterLexer(CharStreams.fromString(filter))));
parser.setBuildParseTree(true);
parser.setTrimParseTree(true);
parser.setProfile(true);
parser.removeErrorListeners();
parser.setErrorHandler(new SCIMFilterErrorHandler());
try {
return visitor.visit(parser.scimFilter());
} catch (Exception e) {
LOG.error("Could not parse '{}'", filter, e);
throw new BadRequestException(ErrorType.invalidFilter, "Could not parse '" + filter + "'");
}
}
use of org.antlr.v4.runtime.CommonTokenStream in project ballerina by ballerina-lang.
the class SiddhiCompiler method parse.
public static SiddhiApp parse(String source) {
ANTLRInputStream input = new ANTLRInputStream(source);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
// parser.setErrorHandler(new BailErrorStrategy());
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.parse();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (SiddhiApp) eval.visit(tree);
}
use of org.antlr.v4.runtime.CommonTokenStream in project ballerina by ballerina-lang.
the class SiddhiCompiler method parseStoreQuery.
public static StoreQuery parseStoreQuery(String storeQuery) throws SiddhiParserException {
ANTLRInputStream input = new ANTLRInputStream(storeQuery);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.store_query_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (StoreQuery) eval.visit(tree);
}
use of org.antlr.v4.runtime.CommonTokenStream in project ballerina by ballerina-lang.
the class SiddhiCompiler method parseQuery.
public static Query parseQuery(String source) throws SiddhiParserException {
ANTLRInputStream input = new ANTLRInputStream(source);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.query_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (Query) eval.visit(tree);
}
use of org.antlr.v4.runtime.CommonTokenStream in project ballerina by ballerina-lang.
the class SiddhiCompiler method parseTableDefinition.
public static TableDefinition parseTableDefinition(String source) throws SiddhiParserException {
ANTLRInputStream input = new ANTLRInputStream(source);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.definition_table_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (TableDefinition) eval.visit(tree);
}
Aggregations