Package xbird.xquery.expr.flwr

Examples of xbird.xquery.expr.flwr.FLWRExpr$ActionSequence


    [37] WhereClause   ::= "where" ExprSingle
    [38] OrderByClause ::= (<"order" "by"> | <"stable" "order" "by">) OrderSpecList
    [39] OrderSpecList ::= OrderSpec ("," OrderSpec)*
    ************************************************************************/
    final public XQExpression parseFLWRExpr() throws ParseException, XQueryException {
        final FLWRExpr flower = new FLWRExpr();
        List<Binding> bindings = null;
        XQExpression whereExpr = null;
        OrderSpec order = null;
        XQExpression returnExpr = null;
        currentModule.pushVarScope();
        locate(flower);
        label_7: while(true) {
            switch(jj_nt.kind) {
                case ForVariable:
                    bindings = parseForClause();
                    break;
                case LetVariable:
                    bindings = parseLetClause();
                    break;
                default:
                    jj_la1[59] = jj_gen;
                    jj_consume_token(-1);
                    throw new ParseException();
            }
            flower.addClauses(bindings);
            switch(jj_nt.kind) {
                case ForVariable:
                case LetVariable:
                    ;
                    break;
                default:
                    jj_la1[60] = jj_gen;
                    break label_7;
            }
        }
        switch(jj_nt.kind) {
            case Where:
                currentToken = jj_consume_token(Where);
                whereExpr = parseExprSingle();
                flower.setWhereExpr(whereExpr);
                break;
            default:
                jj_la1[61] = jj_gen;
                ;
        }
        switch(jj_nt.kind) {
            case GroupBy:
                Grouping grouping = null;
                grouping = parseGroupByClause();
                flower.setGroupByClause(grouping);
                label_8: while(true) {
                    switch(jj_nt.kind) {
                        case LetVariable:
                            ;
                            break;
                        default:
                            jj_la1[62] = jj_gen;
                            break label_8;
                    }
                    bindings = parseLetClause();
                    grouping.addLetClauses(bindings);
                }
                switch(jj_nt.kind) {
                    case Where:
                        currentToken = jj_consume_token(Where);
                        whereExpr = parseExprSingle();
                        grouping.setWhereExpression(whereExpr);
                        break;
                    default:
                        jj_la1[63] = jj_gen;
                        ;
                }
                break;
            default:
                jj_la1[64] = jj_gen;
                ;
        }
        switch(jj_nt.kind) {
            case OrderBy:
            case OrderByStable:
                switch(jj_nt.kind) {
                    case OrderBy:
                        currentToken = jj_consume_token(OrderBy);
                        break;
                    case OrderByStable:
                        currentToken = jj_consume_token(OrderByStable);
                        flower.setStableOrdering(true);
                        break;
                    default:
                        jj_la1[65] = jj_gen;
                        jj_consume_token(-1);
                        throw new ParseException();
                }
                order = parseOrderSpec();
                flower.addOrderSpec(order);
                label_9: while(true) {
                    switch(jj_nt.kind) {
                        case Comma:
                            ;
                            break;
                        default:
                            jj_la1[66] = jj_gen;
                            break label_9;
                    }
                    currentToken = jj_consume_token(Comma);
                    order = parseOrderSpec();
                    flower.addOrderSpec(order);
                }
                break;
            default:
                jj_la1[67] = jj_gen;
                ;
        }
        currentToken = jj_consume_token(Return);
        returnExpr = parseExprSingle();
        flower.setReturnExpr(returnExpr);
        currentModule.popVarScope();
        {
            if(true)
                return flower.normalize();
        }
        throw new Error("Missing return statement in function");
    }
View Full Code Here


                        ((BDQExpr) expr).setParallel(true);
                        return expr.staticAnalysis(statEnv);
                    }
                }
            } else if(expr instanceof FLWRExpr) {
                FLWRExpr flwrExpr = ((FLWRExpr) expr);
                List<Binding> clauses = flwrExpr.getClauses();
                if(!clauses.isEmpty()) {
                    Binding firstClause = clauses.get(0);
                    BindingVariable bindingVar = firstClause.getVariable();
                    XQExpression bindingExpr = bindingVar.getValue();
                    if(bindingExpr instanceof DirectFunctionCall) {
                        DirectFunctionCall funcall = (DirectFunctionCall) bindingExpr;
                        if(FnCollection.FUNC_NAME.equals(funcall.getFuncName())) {
                            List<XQExpression> params = funcall.getParams();
                            final String colpath;
                            if(params.isEmpty()) {
                                colpath = "/";
                            } else {
                                XQExpression argExpr = params.get(0);
                                colpath = argExpr.eval(null, DynamicContext.DUMMY).toString();
                            }
                            MapExpr mapExpr = new MapExpr(colpath, bindingVar, flwrExpr);
                            return mapExpr.staticAnalysis(statEnv);
                        }
                    }
                }
            } else if(expr instanceof PathExpr) {
                PathExpr pathExpr = (PathExpr) expr;
                List<XQExpression> steps = pathExpr.getSteps();
                if(steps.size() > 1) {
                    XQExpression firstStep = steps.get(0);
                    if(firstStep instanceof DirectFunctionCall) {
                        DirectFunctionCall funcall = (DirectFunctionCall) firstStep;
                        if(FnCollection.FUNC_NAME.equals(funcall.getFuncName())) {
                            List<XQExpression> params = funcall.getParams();
                            final String colpath;
                            if(params.isEmpty()) {
                                colpath = "/";
                            } else {
                                XQExpression argExpr = params.get(0);
                                colpath = argExpr.eval(null, DynamicContext.DUMMY).toString();
                            }

                            FLWRExpr newFlwr = new FLWRExpr();
                            ForVariable forVar = new ForVariable();
                            forVar.setValue(funcall);
                            newFlwr.addClause(new ForClause(forVar));
                            VarRef varref = new VarRef(forVar);
                            steps.set(0, varref);
                            newFlwr.setFilteredReturnExpr(pathExpr);

                            MapExpr mapExpr = new MapExpr(colpath, forVar, newFlwr);
                            return mapExpr.staticAnalysis(statEnv);
                        }
                    }
View Full Code Here

     [37] WhereClause   ::= "where" ExprSingle
     [38] OrderByClause ::= (<"order" "by"> | <"stable" "order" "by">) OrderSpecList
     [39] OrderSpecList ::= OrderSpec ("," OrderSpec)*
     ************************************************************************/
    final public XQExpression parseFLWRExpr() throws ParseException, XQueryException {
        final FLWRExpr flower = new FLWRExpr();
        List<Binding> bindings = null;
        XQExpression whereExpr = null;
        OrderSpec order = null;
        XQExpression returnExpr = null;
        currentModule.pushVarScope();
        locate(flower);
        label_7: while(true) {
            switch(jj_nt.kind) {
                case ForVariable:
                    bindings = parseForClause();
                    break;
                case LetVariable:
                    bindings = parseLetClause();
                    break;
                default:
                    jj_la1[59] = jj_gen;
                    jj_consume_token(-1);
                    throw new ParseException();
            }
            flower.addClauses(bindings);
            switch(jj_nt.kind) {
                case ForVariable:
                case LetVariable:
                    ;
                    break;
                default:
                    jj_la1[60] = jj_gen;
                    break label_7;
            }
        }
        switch(jj_nt.kind) {
            case Where:
                currentToken = jj_consume_token(Where);
                whereExpr = parseExprSingle();
                flower.setWhereExpr(whereExpr);
                break;
            default:
                jj_la1[61] = jj_gen;
                ;
        }
        switch(jj_nt.kind) {
            case OrderBy:
            case OrderByStable:
                switch(jj_nt.kind) {
                    case OrderBy:
                        currentToken = jj_consume_token(OrderBy);
                        break;
                    case OrderByStable:
                        currentToken = jj_consume_token(OrderByStable);
                        flower.setStableOrdering(true);
                        break;
                    default:
                        jj_la1[62] = jj_gen;
                        jj_consume_token(-1);
                        throw new ParseException();
                }
                order = parseOrderSpec();
                flower.addOrderSpec(order);
                label_8: while(true) {
                    switch(jj_nt.kind) {
                        case Comma:
                            ;
                            break;
                        default:
                            jj_la1[63] = jj_gen;
                            break label_8;
                    }
                    currentToken = jj_consume_token(Comma);
                    order = parseOrderSpec();
                    flower.addOrderSpec(order);
                }
                break;
            default:
                jj_la1[64] = jj_gen;
                ;
        }
        currentToken = jj_consume_token(Return);
        returnExpr = parseExprSingle();
        flower.setReturnExpr(returnExpr);
        currentModule.popVarScope();
        {
            if(true)
                return flower.normalize();
        }
        throw new Error("Missing return statement in function");
    }
View Full Code Here

TOP

Related Classes of xbird.xquery.expr.flwr.FLWRExpr$ActionSequence

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.