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