Search in sources :

Example 1 with BinaryOp

use of uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp in project mkgmap by openstreetmap.

the class ExpressionArranger method reAssociate.

/**
 * Fix a chain of AND/OR nodes so that the chain is on the right.
 *
 * Eg: given (A&B)&(C&D) we return (A&(B&(C&D)))
 */
private void reAssociate(Op op, NodeType kind) {
    assert op.isType(kind);
    assert kind == OR || kind == AND;
    // Rearrange ((A&B)&C) to (A&(B&C)).
    while (op.getFirst().isType(kind)) {
        Op aAndB = op.getFirst();
        Op a = aAndB.getFirst();
        Op b = aAndB.getSecond();
        Op c = op.getSecond();
        assert a != b;
        assert a != c;
        assert b != c;
        BinaryOp and = AbstractOp.createOp(kind).set(b, c);
        op.set(a, and);
    }
}
Also used : NotExistsOp(uk.me.parabola.mkgmap.osmstyle.eval.NotExistsOp) AbstractOp(uk.me.parabola.mkgmap.osmstyle.eval.AbstractOp) Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) GTEOp(uk.me.parabola.mkgmap.osmstyle.eval.GTEOp) ValueOp(uk.me.parabola.mkgmap.osmstyle.eval.ValueOp) LTEOp(uk.me.parabola.mkgmap.osmstyle.eval.LTEOp) LTOp(uk.me.parabola.mkgmap.osmstyle.eval.LTOp) NotEqualOp(uk.me.parabola.mkgmap.osmstyle.eval.NotEqualOp) EqualsOp(uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp) RegexOp(uk.me.parabola.mkgmap.osmstyle.eval.RegexOp) ExistsOp(uk.me.parabola.mkgmap.osmstyle.eval.ExistsOp) BinaryOp(uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp) GTOp(uk.me.parabola.mkgmap.osmstyle.eval.GTOp) NotRegexOp(uk.me.parabola.mkgmap.osmstyle.eval.NotRegexOp) OrOp(uk.me.parabola.mkgmap.osmstyle.eval.OrOp) AndOp(uk.me.parabola.mkgmap.osmstyle.eval.AndOp) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) BinaryOp(uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp)

Example 2 with BinaryOp

use of uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp in project mkgmap by openstreetmap.

the class RulesTest method checkNotLength.

public static boolean checkNotLength(Op expr, boolean hasNot) {
    if (expr == null)
        return false;
    Op f = expr.getFirst();
    if (hasNot && f != null && f.isType(FUNCTION) && Objects.equals(f.toString(), "length()"))
        return true;
    boolean invalid = false;
    NodeType t = expr.getType();
    if (expr instanceof BinaryOp) {
        if (checkNotLength(expr.getFirst(), hasNot))
            invalid = true;
        if (checkNotLength(expr.getSecond(), hasNot))
            invalid = true;
    } else if (t == NOT) {
        if (checkNotLength(expr.getFirst(), true))
            invalid = true;
    }
    return invalid;
}
Also used : NotExistsOp(uk.me.parabola.mkgmap.osmstyle.eval.NotExistsOp) Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) GTEOp(uk.me.parabola.mkgmap.osmstyle.eval.GTEOp) LTOp(uk.me.parabola.mkgmap.osmstyle.eval.LTOp) NotEqualOp(uk.me.parabola.mkgmap.osmstyle.eval.NotEqualOp) BinaryOp(uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp) OrOp(uk.me.parabola.mkgmap.osmstyle.eval.OrOp) NotOp(uk.me.parabola.mkgmap.osmstyle.eval.NotOp) ValueOp(uk.me.parabola.mkgmap.osmstyle.eval.ValueOp) EqualsOp(uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp) RegexOp(uk.me.parabola.mkgmap.osmstyle.eval.RegexOp) ExistsOp(uk.me.parabola.mkgmap.osmstyle.eval.ExistsOp) AndOp(uk.me.parabola.mkgmap.osmstyle.eval.AndOp) NodeType(uk.me.parabola.mkgmap.osmstyle.eval.NodeType) BinaryOp(uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp)

Aggregations

AndOp (uk.me.parabola.mkgmap.osmstyle.eval.AndOp)2 BinaryOp (uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp)2 EqualsOp (uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp)2 ExistsOp (uk.me.parabola.mkgmap.osmstyle.eval.ExistsOp)2 GTEOp (uk.me.parabola.mkgmap.osmstyle.eval.GTEOp)2 LTOp (uk.me.parabola.mkgmap.osmstyle.eval.LTOp)2 NotEqualOp (uk.me.parabola.mkgmap.osmstyle.eval.NotEqualOp)2 NotExistsOp (uk.me.parabola.mkgmap.osmstyle.eval.NotExistsOp)2 Op (uk.me.parabola.mkgmap.osmstyle.eval.Op)2 OrOp (uk.me.parabola.mkgmap.osmstyle.eval.OrOp)2 RegexOp (uk.me.parabola.mkgmap.osmstyle.eval.RegexOp)2 ValueOp (uk.me.parabola.mkgmap.osmstyle.eval.ValueOp)2 AbstractOp (uk.me.parabola.mkgmap.osmstyle.eval.AbstractOp)1 GTOp (uk.me.parabola.mkgmap.osmstyle.eval.GTOp)1 LTEOp (uk.me.parabola.mkgmap.osmstyle.eval.LTEOp)1 LinkedOp (uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp)1 NodeType (uk.me.parabola.mkgmap.osmstyle.eval.NodeType)1 NotOp (uk.me.parabola.mkgmap.osmstyle.eval.NotOp)1 NotRegexOp (uk.me.parabola.mkgmap.osmstyle.eval.NotRegexOp)1