Search in sources :

Example 6 with VarExprPair

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.

the class Normalizer method doForExpr.

// does a for and a quantified expression
// takes the iterator for var expr paris
private void doForExpr(Iterator iter, Expr expr) {
    Collection vars = new ArrayList();
    // go through expression and cache variables
    while (iter.hasNext()) {
        VarExprPair pair = (VarExprPair) iter.next();
        QName var = pair.varname();
        Expr e = pair.expr();
        // XXX this is wrong!
        // need to define new scope, and reference "inner scope"
        // [shadow outer vars]
        /*
			 * if(_sc.variable_exists(var)) report_error(new
			 * StaticNameError("Variable " + var.string() +
			 * " already defined"));
			 */
        // ok we can cheat here cuz we only care about variable
        // "presence" not its specific instance / value so we
        // can fakely shadow without creating explicit scopes
        // if variable already exists.... then leave it there...
        // [we do not need to create a new instance and delete
        // it at the end]
        // we only need to if variable does not exist
        // XXX: i fink this is all wrong
        vars.add(var);
        e.accept(this);
    }
    // add variables to scope
    for (Iterator i = vars.iterator(); i.hasNext(); ) {
        QName var = (QName) i.next();
    }
    // do the bounded expression
    expr.accept(this);
// remove variables
}
Also used : PipeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PipeExpr) BinExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.BinExpr) QuantifiedExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.QuantifiedExpr) MulExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.MulExpr) IfExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IfExpr) XPathExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr) Expr(org.eclipse.wst.xml.xpath2.processor.internal.ast.Expr) MinusExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.MinusExpr) OrExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.OrExpr) TreatAsExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.TreatAsExpr) PrimaryExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PrimaryExpr) ForExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr) ParExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ParExpr) FilterExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr) DivExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.DivExpr) CastableExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr) SubExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.SubExpr) PlusExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PlusExpr) CastExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr) AndExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr) RangeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.RangeExpr) StepExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.StepExpr) InstOfExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.InstOfExpr) IntersectExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IntersectExpr) IDivExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IDivExpr) UnExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.UnExpr) CntxItemExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CntxItemExpr) ExceptExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ExceptExpr) AddExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr) UnionExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.UnionExpr) CmpExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr) ModExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ModExpr) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 7 with VarExprPair

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.

the class Normalizer method printVarExprPairs.

private void printVarExprPairs(Iterator i) {
    while (i.hasNext()) {
        VarExprPair pair = (VarExprPair) i.next();
        QName var = pair.varname();
        Expr e = pair.expr();
        e.accept(this);
    }
}
Also used : PipeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PipeExpr) BinExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.BinExpr) QuantifiedExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.QuantifiedExpr) MulExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.MulExpr) IfExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IfExpr) XPathExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr) Expr(org.eclipse.wst.xml.xpath2.processor.internal.ast.Expr) MinusExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.MinusExpr) OrExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.OrExpr) TreatAsExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.TreatAsExpr) PrimaryExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PrimaryExpr) ForExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr) ParExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ParExpr) FilterExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr) DivExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.DivExpr) CastableExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr) SubExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.SubExpr) PlusExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PlusExpr) CastExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr) AndExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr) RangeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.RangeExpr) StepExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.StepExpr) InstOfExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.InstOfExpr) IntersectExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IntersectExpr) IDivExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IDivExpr) UnExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.UnExpr) CntxItemExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CntxItemExpr) ExceptExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ExceptExpr) AddExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr) UnionExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.UnionExpr) CmpExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr) ModExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ModExpr) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 8 with VarExprPair

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.

the class Normalizer method visit.

/**
 * @param fex
 *            is the For expression.
 * @return fex expression.
 */
public Object visit(ForExpr fex) {
    ForExpr last = fex;
    Expr ret = fex.expr();
    int depth = 0;
    for (Iterator i = fex.iterator(); i.hasNext(); ) {
        VarExprPair ve = (VarExprPair) i.next();
        // ok we got nested fors...
        if (depth > 0) {
            Collection pairs = new ArrayList();
            pairs.add(ve);
            ForExpr fe = new ForExpr(pairs, ret);
            last.set_expr(fe);
            last = fe;
        }
        depth++;
    }
    // normalize return value, and set it to the last for expr
    ret.accept(this);
    // get rid of the pairs in the parent (original) for
    if (depth > 1)
        fex.truncate_pairs();
    return fex;
}
Also used : PipeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PipeExpr) BinExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.BinExpr) QuantifiedExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.QuantifiedExpr) MulExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.MulExpr) IfExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IfExpr) XPathExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr) Expr(org.eclipse.wst.xml.xpath2.processor.internal.ast.Expr) MinusExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.MinusExpr) OrExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.OrExpr) TreatAsExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.TreatAsExpr) PrimaryExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PrimaryExpr) ForExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr) ParExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ParExpr) FilterExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr) DivExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.DivExpr) CastableExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr) SubExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.SubExpr) PlusExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PlusExpr) CastExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr) AndExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr) RangeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.RangeExpr) StepExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.StepExpr) InstOfExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.InstOfExpr) IntersectExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IntersectExpr) IDivExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.IDivExpr) UnExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.UnExpr) CntxItemExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CntxItemExpr) ExceptExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ExceptExpr) AddExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr) UnionExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.UnionExpr) CmpExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr) ModExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ModExpr) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) Collection(java.util.Collection) ForExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Aggregations

VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)8 Iterator (java.util.Iterator)6 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)6 AddExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr)5 AndExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr)5 BinExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.BinExpr)5 CastExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr)5 CastableExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr)5 CmpExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr)5 CntxItemExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CntxItemExpr)5 DivExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.DivExpr)5 ExceptExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ExceptExpr)5 Expr (org.eclipse.wst.xml.xpath2.processor.internal.ast.Expr)5 FilterExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr)5 ForExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr)5 IDivExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IDivExpr)5 IfExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IfExpr)5 InstOfExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.InstOfExpr)5 IntersectExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IntersectExpr)5 MinusExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.MinusExpr)5