Search in sources :

Example 1 with Expr

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

the class Normalizer method visit.

/**
 * Returns the normalized tree
 *
 * @param xp
 *            is the xpath expression.
 * @return the xpath expressions.
 */
public Object visit(XPath xp) {
    Collection exprs = new ArrayList();
    for (Iterator i = xp.iterator(); i.hasNext(); ) {
        Expr e = (Expr) i.next();
        Expr n = (Expr) e.accept(this);
        exprs.add(n);
    }
    return new XPath(exprs);
}
Also used : XPath(org.eclipse.wst.xml.xpath2.processor.ast.XPath) 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) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 2 with Expr

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

the class StaticNameResolver method visit.

/**
 * Validate an XPath by visiting all the nodes.
 *
 * @param xp
 *            is the XPath.
 * @return null.
 */
public Object visit(XPath xp) {
    for (Iterator i = xp.iterator(); i.hasNext(); ) {
        Expr e = (Expr) i.next();
        e.accept(this);
    }
    return null;
}
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) 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)

Example 3 with Expr

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

the class StaticNameResolver method doForExpr.

// does a for and a quantified expression
// takes the iterator for var expr paris
private void doForExpr(Iterator iter, Expr expr) {
    int scopes = 0;
    // add variables to scope and check the binding sequence
    while (iter.hasNext()) {
        VarExprPair pair = (VarExprPair) iter.next();
        QName var = pair.varname();
        if (!expandVarQName(var))
            reportBadPrefix(var.prefix());
        Expr e = pair.expr();
        e.accept(this);
        pushScope(var, BuiltinTypeLibrary.XS_ANYTYPE);
        scopes++;
    }
    expr.accept(this);
    // kill the scopes
    for (int i = 0; i < scopes; i++) popScope();
}
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) 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 4 with Expr

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

the class DefaultVisitor method visit.

/**
 * Returns the normalized tree
 *
 * @param xp
 *            is the xpath expression.
 * @return the xpath expressions.
 */
public Object visit(XPath xp) {
    for (Iterator<Expr> i = xp.iterator(); i.hasNext(); ) {
        Expr e = (Expr) i.next();
        e.accept(this);
    }
    return null;
}
Also used : PipeExpr(org.eclipse.wst.xml.xpath2.processor.internal.ast.PipeExpr) 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) 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) 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) 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)

Example 5 with Expr

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

the class DefaultEvaluator method do_exists.

private XSBoolean do_exists(ListIterator iter, Expr finalexpr) {
    // we have more vars to bind...
    if (iter.hasNext()) {
        VarExprPair ve = (VarExprPair) iter.next();
        // evaluate binding sequence
        ResultSequence rs = (ResultSequence) ve.expr().accept(this);
        QName varname = ve.varname();
        try {
            for (Iterator i = rs.iterator(); i.hasNext(); ) {
                AnyType item = (AnyType) i.next();
                pushScope(varname, item);
                XSBoolean effbool = do_exists(iter, finalexpr);
                popScope();
                // out what to do with it
                if (effbool.value())
                    return XSBoolean.TRUE;
            }
        } finally {
            iter.previous();
        }
        // since none in this sequence evaluated to true, return false
        return XSBoolean.FALSE;
    } else // we finally got to do the "last expression"
    {
        return effective_boolean_value((ResultSequence) finalexpr.accept(this));
    }
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Aggregations

CastExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastExpr)14 AddExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AddExpr)13 AndExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.AndExpr)13 CastableExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CastableExpr)13 CmpExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CmpExpr)13 CntxItemExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.CntxItemExpr)13 DivExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.DivExpr)13 ExceptExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ExceptExpr)13 Expr (org.eclipse.wst.xml.xpath2.processor.internal.ast.Expr)13 FilterExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.FilterExpr)13 ForExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ForExpr)13 IDivExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IDivExpr)13 IfExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IfExpr)13 InstOfExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.InstOfExpr)13 IntersectExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.IntersectExpr)13 MinusExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.MinusExpr)13 ModExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ModExpr)13 MulExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.MulExpr)13 OrExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.OrExpr)13 ParExpr (org.eclipse.wst.xml.xpath2.processor.internal.ast.ParExpr)13