use of org.antlr.v4.runtime.tree.Tree in project hive by apache.
the class Exec method include.
/**
* Execute statements from an include file
*/
void include(String content) throws Exception {
InputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
HplsqlLexer lexer = new HplsqlLexer(new ANTLRInputStream(input));
CommonTokenStream tokens = new CommonTokenStream(lexer);
HplsqlParser parser = new HplsqlParser(tokens);
ParseTree tree = parser.program();
visit(tree);
}
use of org.antlr.v4.runtime.tree.Tree in project metron by apache.
the class WindowProcessor method syntaxTree.
/**
* Create a textual representation of the syntax tree. This is useful for those intrepid souls
* who wish to extend the window selector language. God speed.
* @param statement
* @return A string representation of the syntax tree.
*/
public static String syntaxTree(String statement) {
TokenStream tokens = createTokenStream(statement);
if (tokens == null) {
return null;
}
WindowParser parser = createParser(tokens, Optional.empty());
ParseTree tree = parser.window();
return GrammarUtils.toSyntaxTree(tree);
}
use of org.antlr.v4.runtime.tree.Tree in project grakn by graknlabs.
the class TemplateParser method parseGraqlTemplate.
private ParseTree parseGraqlTemplate(CommonTokenStream tokens, GraqlErrorListener errorListener) {
GraqlTemplateParser parser = new GraqlTemplateParser(tokens);
parser.setBuildParseTree(true);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
ParseTree tree = parser.template();
if (errorListener.hasErrors()) {
throw GraqlSyntaxException.create(errorListener.toString());
}
return tree;
}
use of org.antlr.v4.runtime.tree.Tree in project drools by kiegroup.
the class FEELImpl method compile.
@Override
public CompiledExpression compile(String expression, CompilerContext ctx) {
FEEL_1_1Parser parser = FEELParser.parse(getEventsManager(ctx.getListeners()), expression, ctx.getInputVariableTypes(), ctx.getInputVariables(), ctx.getFEELFunctions(), profiles);
ParseTree tree = parser.compilation_unit();
ASTBuilderVisitor v = new ASTBuilderVisitor(ctx.getInputVariableTypes());
BaseNode expr = v.visit(tree);
CompiledExpression ce = new CompiledExpressionImpl(expr);
return ce;
}
Aggregations