Package org.antlr.runtime.tree

Examples of org.antlr.runtime.tree.CommonTreeNodeStream


//        if (parser.errorMessage != null) {
//            throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
//        }
        parserTree = (CommonTree) parsedStatement.getTree();           

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
        nodes.setTokenStream(tokens);
        CmisQueryWalker walker = new CmisQueryWalker(nodes);
        return walker;
    }
View Full Code Here


        CommonTokenStream tokenStream = tokenize( input, null );
        LogicalSchema schema = null;
        Tree ast = parseSchema( tokenStream );

        try{
            CommonTreeNodeStream nodes = new CommonTreeNodeStream( ast );
            AstValidator walker = new AstValidator( nodes );
            ast = (Tree)walker.field_def_list().getTree();
            checkError( walker );

            LogicalPlanGenerator planGenerator =
                new LogicalPlanGenerator( new CommonTreeNodeStream( ast ), pigContext, scope, fileNameMap );
            schema = planGenerator.field_def_list().schema;
            checkError( planGenerator );
        } catch(RecognitionException ex) {
            throw new ParserException( ex );
        } catch(Exception ex) {
View Full Code Here

        CommonTokenStream tokenStream = tokenize( input, null );
        Object value = null;
        Tree ast = parseConstant( tokenStream );

        try{
            CommonTreeNodeStream nodes = new CommonTreeNodeStream( ast );
            AstValidator walker = new AstValidator( nodes );
            ast = (Tree)walker.literal().getTree();
            checkError( walker );

            LogicalPlanGenerator planGenerator =
                new LogicalPlanGenerator( new CommonTreeNodeStream( ast ), pigContext, scope, fileNameMap );
            value = planGenerator.literal().value;
            checkError( planGenerator );
        } catch(RecognitionException ex) {
            throw new ParserException( ex );
        } catch(Exception ex) {
View Full Code Here

        try{
            ast = validateAst( ast );
            applyRegisters(ast);

            LogicalPlanGenerator planGenerator =
                new LogicalPlanGenerator( new CommonTreeNodeStream( ast ), pigContext, scope, fileNameMap );
            planGenerator.query();

            checkError( planGenerator );

            plan = planGenerator.getLogicalPlan();
View Full Code Here

        return ast;
    }

    private static Tree validateAst(Tree ast) throws RecognitionException, ParserException {
        CommonTreeNodeStream nodes = new CommonTreeNodeStream( ast );
        AstValidator walker = new AstValidator( nodes );
        AstValidator.query_return newResult = walker.query();
        Tree newAst = (Tree)newResult.getTree();

        checkError( walker );
View Full Code Here

                    new ArrayList<PigMacro>(seen.values()), macroStack, pigContext);
            QueryParserUtils.replaceNodeWithNodeList(t, newTree, null);
        }
       
        // mask the aliases in the inlined macro
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(ast);
        AliasMasker walker = new AliasMasker(nodes);
        walker.setParams(masks, name, idx++);

        AliasMasker.query_return result2 = null;
        CommonTree commonTree = null;
View Full Code Here

        QueryParserDriver driver = new QueryParserDriver(context, "0",
                new HashMap<String, String>());
        Tree newAst = driver.expandMacro(dup);
       
        CommonTreeNodeStream nodes = new CommonTreeNodeStream( newAst );
        AstPrinter walker = new AstPrinter( nodes );
        try {
            walker.query();
        } catch (RecognitionException e) {
            throw new ParserException("Failed to print AST for command " + cmd,
View Full Code Here

        Tree ast = (Tree)result.getTree();

        System.out.println( ast.toStringTree() );
        TreePrinter.printTree( (CommonTree)ast, 0 );

        CommonTreeNodeStream nodes = new CommonTreeNodeStream( ast );
        AstValidator walker = new AstValidator( nodes );
        AstValidator.query_return newResult = walker.query();
       
        Assert.assertEquals( 0, walker.getNumberOfSyntaxErrors() );
View Full Code Here

    }
   
    public static Tree validateAst(String query)
    throws RecognitionException, ParsingFailureException, IOException {
        Tree ast = parse( query );
        CommonTreeNodeStream nodes = new CommonTreeNodeStream( ast );
        AstValidator walker = new AstValidator( nodes );
        AstValidator.query_return newResult = walker.query();
        Tree newAst = (Tree)newResult.getTree();
        TreePrinter.printTree( (CommonTree)newAst, 0 );
       
View Full Code Here

   
    public static LogicalPlan generateLogicalPlan(String query)
    throws RecognitionException, ParsingFailureException, IOException {
        Tree ast = validateAst( query );
       
        CommonTreeNodeStream input = new CommonTreeNodeStream( ast );
        LogicalPlanBuilder builder = new LogicalPlanBuilder( input );
        LogicalPlanGenerator walker = new LogicalPlanGenerator( input, builder );
        walker.query();
       
        if( 0 < walker.getNumberOfSyntaxErrors() )
View Full Code Here

TOP

Related Classes of org.antlr.runtime.tree.CommonTreeNodeStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.