You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/10/07 15:33:12 UTC

git commit: [OLINGO-434] Fixed wrong MINUS position in Antlr file

Repository: olingo-odata4
Updated Branches:
  refs/heads/Olingo-434-435 d3dac46ed -> 4a4b110f9


[OLINGO-434] Fixed wrong MINUS position in Antlr file


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/4a4b110f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/4a4b110f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/4a4b110f

Branch: refs/heads/Olingo-434-435
Commit: 4a4b110f9995fc82125405e71d17087e84c25331
Parents: d3dac46
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Oct 7 15:28:52 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Oct 7 15:28:52 2014 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/server/core/uri/antlr/UriLexer.g4     | 6 ++++--
 .../olingo/server/core/uri/parser/UriParseTreeVisitor.java  | 5 ++---
 .../org/apache/olingo/server/core/uri/antlr/TestLexer.java  | 5 +++++
 .../olingo/server/core/uri/antlr/TestUriParserImpl.java     | 9 +++++++--
 4 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4a4b110f/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
index eee6486..737ad4b 100644
--- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
+++ b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4
@@ -132,7 +132,9 @@ TRUE          : 'true';
 FALSE         : 'false';
 BOOLEAN       :  T R U E |  F A L S E; 
 PLUS          : '+';
-SIGN          : PLUS  | '%2B'   |'-';
+
+MINUS         : '-';
+SIGN          : PLUS  | '%2B' | '-';
 INT           : SIGN? DIGITS;
 DECIMAL       : INT '.' DIGITS (('e'|'E') SIGN?  DIGITS)?;
 NANINFINITY   : 'NaN' | '-INF' | 'INF';
@@ -184,7 +186,7 @@ OR              : 'or';
 
 
 NOT             : 'not';
-MINUS           :'-';
+
 
 IT  : '$it';
 ITSLASH  : '$it/';

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4a4b110f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
index ff19f3e..2c3d87c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
@@ -2166,8 +2166,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
   @Override
   public ExpressionImpl visitAltUnary(@NotNull UriParserParser.AltUnaryContext ctx) {
   	UnaryImpl unary = new UnaryImpl();
-  	unary.setOperator(ctx.unary().NOT() == null?UnaryOperatorKind.MINUS:UnaryOperatorKind.NOT);
-  	unary.setOperand((ExpressionImpl)ctx.commonExpr().accept(this));
+  	unary.setOperator(ctx.unary().NOT() == null? UnaryOperatorKind.MINUS: UnaryOperatorKind.NOT);
+  	unary.setOperand((ExpressionImpl) ctx.commonExpr().accept(this));
   	return unary;
   }
   
@@ -2177,5 +2177,4 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 		alias.setParameter("@"+ctx.odataIdentifier().getChild(0).getText());
 		return alias;
 	}
-  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4a4b110f/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
index e8aa9ce..76c11aa 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
@@ -49,6 +49,11 @@ public class TestLexer {
   // ;------------------------------------------------------------------------------
 
   @Test
+  public void testUnary() {
+    test.run("- a eq a").isAllInput();
+  }
+
+  @Test
   public void testUriTokens() {
     test.globalMode(UriLexer.MODE_QUERY);
     test.run("#").isText("#").isType(UriLexer.FRAGMENT);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4a4b110f/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 1ccebbb..30e1b0d 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -567,6 +567,12 @@ public class TestUriParserImpl {
   }
 
   @Test
+  public void testUnary() throws UriParserException {
+    testFilter.runESabc("not a").isCompr("<not <a>>");
+    testFilter.runESabc("- a eq a").isCompr("<<- <a>> eq <a>>");
+  }
+
+  @Test
   public void testFilterComplexMixedPriority() throws UriParserException {
     testFilter.runESabc("a      or c      and e     ").isCompr("< <a>         or < <c>         and  <e>      >>");
     testFilter.runESabc("a      or c      and e eq f").isCompr("< <a>         or < <c>         and <<e> eq <f>>>>");
@@ -576,7 +582,6 @@ public class TestUriParserImpl {
     testFilter.runESabc("a eq b or c      and e eq f").isCompr("<<<a> eq <b>> or < <c>         and <<e> eq <f>>>>");
     testFilter.runESabc("a eq b or c eq d and e     ").isCompr("<<<a> eq <b>> or <<<c> eq <d>> and  <e>      >>");
     testFilter.runESabc("a eq b or c eq d and e eq f").isCompr("<<<a> eq <b>> or <<<c> eq <d>> and <<e> eq <f>>>>");
-    testFilter.runESabc("not a").isCompr("<not <a>>");
   }
 
   @Test
@@ -1055,7 +1060,7 @@ public class TestUriParserImpl {
 
   @Test
   public void testAlias() throws Exception {
-    testUri.run("ESAllPrim?$filter=PropertyInt16 eq @p1&@p1=1)")
+    testUri.run("ESAllPrim", "$filter=PropertyInt16 eq @p1&@p1=1)")
         .goFilter().is("<<PropertyInt16> eq <@p1>>");
   }