Search in sources :

Example 1 with QuantifiedExpr

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

the class Normalizer method visit.

/**
 * @param qex
 *            is the Quantified expression.
 * @return qex expression.
 */
// XXX: code duplication
public Object visit(QuantifiedExpr qex) {
    QuantifiedExpr last = qex;
    Expr ret = qex.expr();
    int depth = 0;
    for (Iterator i = qex.iterator(); i.hasNext(); ) {
        VarExprPair ve = (VarExprPair) i.next();
        // ok we got nested fors...
        if (depth > 0) {
            Collection pairs = new ArrayList();
            pairs.add(ve);
            QuantifiedExpr qe = new QuantifiedExpr(qex.type(), pairs, ret);
            last.set_expr(qe);
            last = qe;
        }
        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)
        qex.truncate_pairs();
    return qex;
}
Also used : QuantifiedExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.QuantifiedExpr) 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) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 AddExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr)1 AndExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr)1 BinExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.BinExpr)1 CastExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr)1 CastableExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr)1 CmpExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr)1 CntxItemExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CntxItemExpr)1 DivExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.DivExpr)1 ExceptExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ExceptExpr)1 Expr (org.eclipse.wst.xml.xpath2.processor.internal.ast.Expr)1 FilterExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr)1 ForExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr)1 IDivExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IDivExpr)1 IfExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IfExpr)1 InstOfExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.InstOfExpr)1 IntersectExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IntersectExpr)1 MinusExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.MinusExpr)1