On 01/11/13 12:50, Bernhard Hiller wrote:
it is NOT POSSIBLE to compare the values of two tags with each other.

That is correct.

But it is now an easy thing to implement.  There are a few syntaxes
we could use such as:

  maxspeed < get_tag(maxspeed:forward)
  maxspeed < ${maxspeed:forward}

The attached patch implements the dollar notation. So the first part of your example could be written as:

  maxspeed:forward=* & maxspeed!=* { set maxspeed='${maxspeed:forward}' }
  maxspeed:forward=* & maxspeed:forward < ${maxspeed}
                { set maxspeed='${maxspeed:forward}' }

Note there are no quotes around ${maxspeed}.

It's not limited to numeric comparisons, you could have:
  name != $name_int

Currently you can't just have one of these by itself, it has
to have another test first. I'm pretty sure that can be fixed, but
that's one for later.

(built jar: http://files.mkgmap.org.uk/download/161/mkgmap.jar)

..Steve
Index: src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java	(revision 2795)
+++ src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java	(revision )
@@ -45,15 +45,30 @@
 				break;
 
 			WordInfo wordInfo = scanner.nextWordWithInfo();
-			if (isOperation(wordInfo))
+			if (isOperation(wordInfo)) {
+				//System.out.println("saveOp" + wordInfo.getText());
 				saveOp(wordInfo.getText());
-			else if (scanner.checkToken("(")) {
+			} else if (wordInfo.isQuoted()) {
+				//System.out.println("quoted: " + wordInfo.getText());
+				pushValue(wordInfo.getText());
+			} else if (wordInfo.getText().charAt(0) == '$') {
+				//System.out.println("FOO " + wordInfo.getText());
+				String s = scanner.nextWord();
+				//System.out.println("next " + s);
+				if (s.equals("{")) {
+					s = scanner.nextWord();
+					//System.out.println("got " + s);
+					scanner.validateNext("}");
+				}
+				stack.push(new GetTagFunction(s));
+			} else if (scanner.checkToken("(")) {
 				// it is a function
 				// this requires a () after the function name
 				scanner.validateNext("(");
 				scanner.validateNext(")");
 				saveFunction(wordInfo.getText());
 			} else {
+				//System.out.println("value: " + wordInfo.getText());
 				pushValue(wordInfo.getText());
 			}
 		}
@@ -150,7 +165,7 @@
 			Op arg2 = stack.pop();
 			Op arg1 = stack.pop();
 
-			if (arg1.isType(VALUE) && arg2.isType(VALUE))
+			if (arg1.isType(VALUE) /*&& arg2.isType(VALUE)*/)
 				arg1 = new GetTagFunction(arg1.getKeyValue());
 
 			BinaryOp binaryOp = (BinaryOp) op;
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to