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);
}
}
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;
}
Aggregations