Search in sources :

Example 6 with Op

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

the class RuleFileReader method readElse.

private boolean readElse(TokenScanner scanner) {
    Token tok = scanner.nextToken();
    scanner.skipSpace();
    Token next = scanner.peekToken();
    if (next.getType() == TokType.SYMBOL && !next.isValue("(") && !next.isValue("!")) {
        scanner.pushToken(tok);
        return false;
    }
    Op[] ifExpressions = ifStack.removeLast();
    for (int i = 0; i < ifExpressions.length; i++) {
        Op op = ifExpressions[i];
        NotOp not = new NotOp();
        not.setFirst(op);
        ifExpressions[i] = not;
    }
    ifStack.addLast(ifExpressions);
    return true;
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) ValueOp(uk.me.parabola.mkgmap.osmstyle.eval.ValueOp) EqualsOp(uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp) NotOp(uk.me.parabola.mkgmap.osmstyle.eval.NotOp) Token(uk.me.parabola.mkgmap.scan.Token) NotOp(uk.me.parabola.mkgmap.osmstyle.eval.NotOp)

Example 7 with Op

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

the class RuleFileReader method saveRule.

/**
 * Save the expression as a rule.  We need to extract an index such
 * as highway=primary first and then add the rest of the expression as
 * the condition for it.
 *
 * So in other words each condition is dropped into a number of different
 * baskets based on the first 'tag=value' term.  We then only look
 * for expressions that are in the correct basket.  For each expression
 * in a basket we know that the first term is true so we can drop that
 * from the expression.
 */
private void saveRule(TokenScanner scanner, Op op, ActionList actions, GType gt) {
    log.debug("EXP", op, ", type=", gt);
    // check if the type definition is allowed
    if (inFinalizeSection && gt != null)
        throw new SyntaxException(scanner, "Element type definition is not allowed in <finalize> section");
    Iterator<Op> it = arranger.prepareForSave(op);
    while (it.hasNext()) {
        Op prepared = it.next();
        String keystring = arranger.getKeystring(scanner, prepared);
        createAndSaveRule(keystring, prepared, actions, gt);
    }
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) ValueOp(uk.me.parabola.mkgmap.osmstyle.eval.ValueOp) EqualsOp(uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp) NotOp(uk.me.parabola.mkgmap.osmstyle.eval.NotOp) SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException)

Example 8 with Op

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

the class ExpressionArrangerTest method testQuadNot.

@Test
public void testQuadNot() {
    Op op = createOp("!!!!($a<2) & length()>=1 {name 'n989225'} [0x2]");
    op = arranger.arrange(op);
    assertTrue(isSolved(op));
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Example 9 with Op

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

the class ExpressionArrangerTest method testPrepareOr.

@Test
public void testPrepareOr() {
    Op op = createOp("a=3 | b < 2 | c=*");
    op = arranger.arrange(op);
    Iterator<Op> it = arranger.prepareForSave(op);
    boolean first = true;
    while (it.hasNext()) {
        Op o = it.next();
        assertTrue("Prepared OR should all be LinkedOp's", o instanceof LinkedOp);
        assertEquals("Only first should have first flag set", first, ((LinkedOp) o).isFirstPart());
        first = false;
        assertTrue(isSolved(o));
        System.out.println(o);
    }
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Example 10 with Op

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

the class ExpressionArrangerTest method testExistsWithNot.

@Test
public void testExistsWithNot() {
    Op op = createOp("!($a=*) & $a=1 [0x1]");
    op = arranger.arrange(op);
    assertTrue(isSolved(op));
}
Also used : Op(uk.me.parabola.mkgmap.osmstyle.eval.Op) LinkedOp(uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp) Test(org.junit.Test)

Aggregations

Op (uk.me.parabola.mkgmap.osmstyle.eval.Op)35 LinkedOp (uk.me.parabola.mkgmap.osmstyle.eval.LinkedOp)28 Test (org.junit.Test)17 EqualsOp (uk.me.parabola.mkgmap.osmstyle.eval.EqualsOp)16 ValueOp (uk.me.parabola.mkgmap.osmstyle.eval.ValueOp)16 AndOp (uk.me.parabola.mkgmap.osmstyle.eval.AndOp)12 BinaryOp (uk.me.parabola.mkgmap.osmstyle.eval.BinaryOp)12 ExistsOp (uk.me.parabola.mkgmap.osmstyle.eval.ExistsOp)12 GTEOp (uk.me.parabola.mkgmap.osmstyle.eval.GTEOp)12 LTOp (uk.me.parabola.mkgmap.osmstyle.eval.LTOp)12 NotEqualOp (uk.me.parabola.mkgmap.osmstyle.eval.NotEqualOp)12 NotExistsOp (uk.me.parabola.mkgmap.osmstyle.eval.NotExistsOp)12 OrOp (uk.me.parabola.mkgmap.osmstyle.eval.OrOp)12 RegexOp (uk.me.parabola.mkgmap.osmstyle.eval.RegexOp)12 AbstractOp (uk.me.parabola.mkgmap.osmstyle.eval.AbstractOp)11 GTOp (uk.me.parabola.mkgmap.osmstyle.eval.GTOp)9 LTEOp (uk.me.parabola.mkgmap.osmstyle.eval.LTEOp)9 NotRegexOp (uk.me.parabola.mkgmap.osmstyle.eval.NotRegexOp)9 NotOp (uk.me.parabola.mkgmap.osmstyle.eval.NotOp)7 ArrayList (java.util.ArrayList)5