]> source.dussan.org Git - jackcess.git/commitdiff
fix handling of equivalent precedence
authorJames Ahlborn <jtahlborn@yahoo.com>
Sun, 16 Oct 2016 20:07:33 +0000 (20:07 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Sun, 16 Oct 2016 20:07:33 +0000 (20:07 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1049 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/util/Expressionator.java
src/test/java/com/healthmarketscience/jackcess/util/ExpressionatorTest.java

index 38d8ae67a58b22aa7a08fdd7dc6b32f63d37b547..22a0676d036bd8159f8da839388e887ffe942437 100644 (file)
@@ -1081,12 +1081,10 @@ public class Expressionator
         // incorrect).  note, we only need to check precedence against "this",
         // as all other precedence has been resolved in previous parsing
         // rounds.
-        if((leftOp._right == this) && isHigherPrecendence(leftOp._op, _op)) {
+        if((leftOp._right == this) && !isHigherPrecendence(_op, leftOp._op)) {
 
-          // FIXME, need to move up if precedecne is the same!
-          
-          // doh, "this" is lower precedence, restore the original order of
-          // things
+          // doh, "this" is lower (or the same) precedence, restore the
+          // original order of things
           leftOp._right = _left;
           _left = leftOp;
           outerExpr = this;
index 895adf8f56795ae1fa8ddde74355fee9555eb070..e63e7b861372bf591c2ac1aab492b7e596834556 100644 (file)
@@ -50,5 +50,12 @@ public class ExpressionatorTest extends TestCase
         Expressionator.Type.FIELD_VALIDATOR, "\"A\" Eqv \"B\" Xor \"C\" Or \"D\" And \"E\"", null);
     assertEquals("<ELogicalOp>{<ELiteralValue>{\"A\"} Eqv <ELogicalOp>{<ELiteralValue>{\"B\"} Xor <ELogicalOp>{<ELiteralValue>{\"C\"} Or <ELogicalOp>{<ELiteralValue>{\"D\"} And <ELiteralValue>{\"E\"}}}}}",
                  expr.toDebugString());
+
+    expr = Expressionator.parse(
+        Expressionator.Type.FIELD_VALIDATOR, "\"A\" Or \"B\" Or \"C\"", null);
+    assertEquals("<ELogicalOp>{<ELogicalOp>{<ELiteralValue>{\"A\"} Or <ELiteralValue>{\"B\"}} Or <ELiteralValue>{\"C\"}}",
+                 expr.toDebugString());
+
+
   }
 }