use of uk.me.parabola.mkgmap.osmstyle.eval.ValueOp in project mkgmap by openstreetmap.
the class RuleFileReader method readIf.
private boolean readIf(TokenScanner scanner, ExpressionReader expressionReader) {
// Take the 'if' token
Token tok = scanner.nextToken();
scanner.skipSpace();
// If 'if'' is being used as a keyword then it is followed by a '('.
Token next = scanner.peekToken();
if (next.getType() == TokType.SYMBOL && next.isValue("(")) {
Op origExpr = expressionReader.readConditions();
scanner.validateNext("then");
// add rule expr { set <ifVar> = true }
String ifVar = getNextIfVar();
ArrayList<Action> actions = new ArrayList<>(1);
actions.add(new AddTagAction(ifVar, "true", true));
ActionList actionList = new ActionList(actions, Collections.singleton(ifVar + "=true"));
saveRule(scanner, origExpr, actionList, null);
// create expression (<ifVar> = true)
EqualsOp safeExpr = new EqualsOp();
safeExpr.setFirst(new GetTagFunction(ifVar));
safeExpr.setSecond(new ValueOp("true"));
Op[] ifExpressions = { origExpr, safeExpr };
ifStack.addLast(ifExpressions);
return true;
} else {
// Wrong syntax for if statement, so push back token to allow a possible expression to be read
scanner.pushToken(tok);
}
return false;
}
Aggregations