use of org.antlr.v4.runtime.tree.ParseTree in project cafebabepy by cafebabepy.
the class CafeBabePyAstCreateVisitor method visitTestlist_comp.
@Override
public PyObject visitTestlist_comp(PythonParser.Testlist_compContext ctx) {
List<PyObject> list = new ArrayList<>();
PythonParser.Comp_forContext comp_forContext = ctx.comp_for();
if (comp_forContext == null) {
int count = ctx.getChildCount();
for (int i = 0; i < count; i++) {
ParseTree c = ctx.getChild(i);
PyObject element = c.accept(this);
if (element != null) {
list.add(element);
}
}
} else {
list.add(ctx.getChild(0).accept(this));
PyObject comp_for = visitComp_for(comp_forContext);
this.runtime.iter(comp_for, list::add);
}
return this.runtime.list(list);
}
use of org.antlr.v4.runtime.tree.ParseTree 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.tree.ParseTree 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.tree.ParseTree 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.tree.ParseTree 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