Search in sources :

Example 1 with QueryPrintVisitor

use of org.apache.asterix.lang.common.visitor.QueryPrintVisitor in project asterixdb by apache.

the class SqlppAstPrintUtil method print.

/**
     * Prints the AST of a list of top-level language statements.
     *
     * @param statements
     *            a list of statements of a query
     * @param output
     *            a writer for printing strings.
     * @throws CompilationException
     */
public static void print(List<Statement> statements, PrintWriter output) throws CompilationException {
    QueryPrintVisitor visitor = astPrintVisitorFactory.createLangVisitor(output);
    for (Statement statement : statements) {
        statement.accept(visitor, 0);
    }
    output.flush();
}
Also used : Statement(org.apache.asterix.lang.common.base.Statement) QueryPrintVisitor(org.apache.asterix.lang.common.visitor.QueryPrintVisitor)

Example 2 with QueryPrintVisitor

use of org.apache.asterix.lang.common.visitor.QueryPrintVisitor in project asterixdb by apache.

the class SqlppAstPrintUtil method toString.

/**
     * @param exprs
     *            a list of language expression.
     * @return an AST of the input language expressions.
     * @throws CompilationException
     */
public static String toString(List<ILangExpression> exprs) throws CompilationException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    PrintWriter output = new PrintWriter(bos);
    QueryPrintVisitor visitor = astPrintVisitorFactory.createLangVisitor(output);
    for (ILangExpression expr : exprs) {
        expr.accept(visitor, 0);
    }
    output.close();
    return bos.toString();
}
Also used : QueryPrintVisitor(org.apache.asterix.lang.common.visitor.QueryPrintVisitor) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter)

Example 3 with QueryPrintVisitor

use of org.apache.asterix.lang.common.visitor.QueryPrintVisitor in project asterixdb by apache.

the class SqlppAstPrintUtil method print.

/**
     * Prints the AST (abstract syntax tree) of an ILangExpression.
     *
     * @param expr
     *            the language expression.
     * @param output
     *            a writer for printing strings.
     * @throws CompilationException
     */
public static void print(ILangExpression expr, PrintWriter output) throws CompilationException {
    QueryPrintVisitor visitor = astPrintVisitorFactory.createLangVisitor(output);
    expr.accept(visitor, 0);
    output.flush();
}
Also used : QueryPrintVisitor(org.apache.asterix.lang.common.visitor.QueryPrintVisitor)

Aggregations

QueryPrintVisitor (org.apache.asterix.lang.common.visitor.QueryPrintVisitor)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)1 Statement (org.apache.asterix.lang.common.base.Statement)1