You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2013/12/13 10:04:28 UTC
[9/9] git commit: [OLINGO-63] Uri Parser: adoptions in lexer and
parser, create UriParserImpl to convert the parsetree into internal structures,
moved parser antlr part from .../olingo/producer/... to
.../olingo/odata4/producer
[OLINGO-63] Uri Parser: adoptions in lexer and parser, create UriParserImpl to convert the parsetree into internal structures, moved parser antlr part from .../olingo/producer/... to .../olingo/odata4/producer
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/10ac7ee3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/10ac7ee3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/10ac7ee3
Branch: refs/heads/master
Commit: 10ac7ee37e7ffde7c3d13c8ebbaba6426087640d
Parents: 82ae606
Author: Sven Kobler <sv...@sap.com>
Authored: Mon Dec 2 16:46:53 2013 +0100
Committer: Sven Kobler <sv...@sap.com>
Committed: Fri Dec 13 10:02:36 2013 +0100
----------------------------------------------------------------------
.../commons/api/edm/EdmStructuralType.java | 7 +
.../core/edm/provider/EdmComplexTypeImpl.java | 4 +-
.../edm/provider/EdmEntityContainerImpl.java | 1 +
.../core/edm/provider/EdmEntityTypeImpl.java | 1 +
.../edm/provider/EdmStructuralTypeImpl.java | 18 +
.../odata4/producer/api/uri/KeyPredicate.java | 45 -
.../odata4/producer/api/uri/UriInfo1.java | 54 -
.../odata4/producer/api/uri/UriInfoKind.java | 3 +-
.../producer/api/uri/UriPathInfoKind.java | 2 +-
odata4-lib/odata4-producer-core/pom.xml | 2 +-
.../odata4/producer/core/uri/antlr/UriLexer.g4 | 386 ++++
.../odata4/producer/core/uri/antlr/UriParser.g4 | 524 +++++
.../olingo/producer/core/uri/antlr/UriLexer.g4 | 385 ----
.../producer/core/uri/antlr/UriLexerPart.g4 | 438 ----
.../olingo/producer/core/uri/antlr/UriParser.g4 | 555 -----
.../odata4/producer/core/uri/ErrorHandler.java | 2 +-
.../producer/core/uri/KeyPredicateImpl.java | 61 -
.../odata4/producer/core/uri/ParserAdapter.java | 81 +
.../odata4/producer/core/uri/UriInfoImpl.java | 40 +-
.../producer/core/uri/UriInfoImplAll.java | 28 +
.../producer/core/uri/UriInfoImplBatch.java | 27 +
.../producer/core/uri/UriInfoImplCrossjoin.java | 27 +
.../producer/core/uri/UriInfoImplEntity.java | 28 +
.../producer/core/uri/UriInfoImplMetadata.java | 27 +
.../producer/core/uri/UriInfoImplPath.java | 50 +
.../producer/core/uri/UriKeyPredicateList.java | 47 +
.../producer/core/uri/UriParameterlist.java | 43 +
.../producer/core/uri/UriParserException.java | 33 +
.../odata4/producer/core/uri/UriParserImpl.java | 443 ++--
.../core/uri/UriPathInfoActionImpl.java | 44 +
.../core/uri/UriPathInfoActionImportImpl.java | 24 -
.../core/uri/UriPathInfoEntitySetImpl.java | 26 +-
.../core/uri/UriPathInfoFunctionImpl.java | 57 +
.../producer/core/uri/UriPathInfoImpl.java | 169 +-
.../core/uri/UriPathInfoImplFunctionImport.java | 48 -
.../core/uri/UriPathInfoNavEntitySet.java | 38 +
.../core/uri/UriPathInfoSigletonImpl.java | 24 -
.../core/uri/UriPathInfoSingletonImpl.java | 39 +
.../producer/core/testutil/EdmTechProvider.java | 1984 ++++++++++++++++--
.../producer/core/testutil/ParserValidator.java | 14 +-
.../core/testutil/TestErrorHandler.java | 56 +
.../producer/core/testutil/TokenValidator.java | 3 +-
.../core/testutil/TraceErrorHandler.java | 2 +-
.../core/testutil/UriResourcePathValidator.java | 164 +-
.../producer/core/uri/antlr/TestLexer.java | 429 ++++
.../producer/core/uri/antlr/TestParser.java | 1450 +++++++++++++
.../core/uri/antlr/TestUriParserImpl.java | 354 ++++
.../producer/core/uri/antlr/TestLexer.java | 424 ----
.../producer/core/uri/antlr/TestParser.java | 1448 -------------
.../core/uri/antlr/UriTreeReaderTest.java | 108 -
50 files changed, 6274 insertions(+), 3993 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/EdmStructuralType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/EdmStructuralType.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/EdmStructuralType.java
index c9f5095..440c3e7 100644
--- a/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/EdmStructuralType.java
+++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/edm/EdmStructuralType.java
@@ -51,4 +51,11 @@ public interface EdmStructuralType extends EdmType {
* @return {@link EdmStructuralType}
*/
EdmStructuralType getBaseType();
+
+ /**
+ * Checks if this type is convertable to parameter {@link targetType}
+ *
+ * @return true if this type is compatible to the testType ( i.e. this type is a subtype of targetType )
+ */
+ boolean compatibleTo(EdmType targetType);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImpl.java
index eb02bac..d8c5394 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmComplexTypeImpl.java
@@ -42,9 +42,11 @@ public class EdmComplexTypeImpl extends EdmStructuralTypeImpl implements EdmComp
if (baseTypeName != null) {
baseType = edm.getComplexType(baseTypeName);
if (baseType == null) {
- throw new EdmException("Cant find base type with name: " + baseTypeName + " for complex type: " + getName());
+ throw new EdmException("Can't find base type with name: " + baseTypeName + " for complex type: " + getName());
}
}
return baseType;
}
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityContainerImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityContainerImpl.java
index 15b666c..2667b08 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityContainerImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityContainerImpl.java
@@ -36,6 +36,7 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FunctionImport;
import org.apache.olingo.odata4.commons.api.edm.provider.Singleton;
import org.apache.olingo.odata4.commons.api.exception.ODataException;
+
public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityContainer {
private final FullQualifiedName entityContainerName;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
index 4ba9170..24248b7 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmEntityTypeImpl.java
@@ -112,4 +112,5 @@ public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntit
return baseType;
}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
index 10b3705..bbd2e84 100644
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
@@ -25,12 +25,14 @@ import java.util.Map;
import org.apache.olingo.odata4.commons.api.edm.EdmElement;
import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
import org.apache.olingo.odata4.commons.api.edm.provider.NavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.provider.Property;
import org.apache.olingo.odata4.commons.api.edm.provider.StructuralType;
+
public abstract class EdmStructuralTypeImpl extends EdmTypeImpl implements EdmStructuralType {
private final Map<String, EdmElement> properties = new HashMap<String, EdmElement>();
@@ -105,6 +107,22 @@ public abstract class EdmStructuralTypeImpl extends EdmTypeImpl implements EdmSt
}
return navigationPropertyNames;
}
+
+
+ @Override
+ public boolean compatibleTo(EdmType targetType) {
+ EdmStructuralType sourceType = this;
+
+ while (sourceType.getName() != targetType.getName() ||
+ sourceType.getNamespace() != targetType.getNamespace()) {
+ sourceType = sourceType.getBaseType();
+ if (sourceType == null) {
+ return false;
+ }
+ }
+
+ return true;
+ }
protected abstract EdmStructuralType buildBaseType(FullQualifiedName baseTypeName);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/KeyPredicate.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/KeyPredicate.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/KeyPredicate.java
deleted file mode 100644
index d4dcd29..0000000
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/KeyPredicate.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.producer.api.uri;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
-
-/**
- * Key predicate, consisting of a simple-type property and its value as String literal
- * @org.apache.olingo.odata2.DoNotImplement
- *
- */
-public interface KeyPredicate {
-
- /**
- * <p>Gets the literal String in default representation.</p>
- * <p>The description for {@link org.apache.olingo.odata2.api.edm.EdmLiteral} has some motivation for using
- * this representation.</p>
- * @return String literal in default (<em>not</em> URI) representation
- * @see org.apache.olingo.odata2.api.edm.EdmLiteralKind
- */
- public String getLiteral();
-
- /**
- * Gets the key property.
- * @return {@link EdmProperty} simple-type property
- */
- public EdmProperty getProperty();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo1.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo1.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo1.java
deleted file mode 100644
index 629e640..0000000
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo1.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.producer.api.uri;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmBindingTarget;
-
-public class UriInfo1 {
- private UriType uriType;
- private EdmBindingTarget bindingTarget;
- private List<String> keyNames = Collections.emptyList();
-
- public UriType getUriType() {
- return uriType;
- }
-
- public void setUriType(final UriType uriType) {
- this.uriType = uriType;
- }
-
- public EdmBindingTarget getBindingTarget() {
- return bindingTarget;
- }
-
- public void setBindingTarget(final EdmBindingTarget bindingTarget) {
- this.bindingTarget = bindingTarget;
- }
-
- public void setKeyNames(final List<String> keyNames) {
- this.keyNames = keyNames;
- }
-
- public List<String> getKeyNames() {
- return keyNames;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoKind.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoKind.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoKind.java
index b39041b..79b676b 100644
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoKind.java
+++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoKind.java
@@ -20,5 +20,6 @@
package org.apache.olingo.odata4.producer.api.uri;
public enum UriInfoKind {
- batch, all, crossjoin;
+ batch,entity, metadata, all, crossjoin, path;
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriPathInfoKind.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriPathInfoKind.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriPathInfoKind.java
index 50aed08..8ae5a31 100644
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriPathInfoKind.java
+++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriPathInfoKind.java
@@ -20,5 +20,5 @@
package org.apache.olingo.odata4.producer.api.uri;
public enum UriPathInfoKind {
- entitySet, singleton, actionImport, functioncall;
+ entitySet, navEntitySet, singleton, action, function;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/pom.xml b/odata4-lib/odata4-producer-core/pom.xml
index a35164b..ca8f0b3 100644
--- a/odata4-lib/odata4-producer-core/pom.xml
+++ b/odata4-lib/odata4-producer-core/pom.xml
@@ -77,7 +77,7 @@
<visitor>true</visitor>
<!--maven antlr plugin has trouble with grammer import if the grammerfiles are
not directly inside src/main/antlr4, hence we have to set the libDirectory-->
- <libDirectory>src/main/antlr4/org/apache/olingo/producer/core/uri/antlr</libDirectory>
+ <libDirectory>src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr</libDirectory>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4 b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
new file mode 100644
index 0000000..68eb855
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
@@ -0,0 +1,386 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+lexer grammar UriLexer;
+
+//;==============================================================================
+// Mode "DEFAULT_MODE": Processes everything bevor the first '?' char
+// On '?' the next mode "MODE_QUERY" is used
+// The percent encoding rules a defined in RFC3986 ABNF rule "path-rootless" apply
+//;==============================================================================
+QM : '?' -> pushMode(MODE_QUERY); //first query parameter
+AMP : '&' -> pushMode(MODE_QUERY); //more query parameters
+STRING : '\'' -> more, pushMode(MODE_STRING); //reads up to next single '
+QUOTATION_MARK : ('\u0022' | '%22') -> more, pushMode(MODE_JSON_STRING); //reads up to next unescaped "
+SEARCH_INLINE : '$search' -> pushMode(MODE_SYSTEM_QUERY_SEARCH); //
+
+GEOGRAPHY : G E O G R A P H Y SQUOTE -> pushMode(MODE_ODATA_GEO); //TODO make case insensitive
+GEOMETRY : G E O M E T R Y SQUOTE -> pushMode(MODE_ODATA_GEO);
+
+//Letters for case insensitivity
+fragment A : 'A'|'a';
+fragment B : 'B'|'b';
+fragment D : 'D'|'d';
+fragment E : 'E'|'e';
+fragment F : 'F'|'f';
+fragment G : 'G'|'g';
+fragment H : 'H'|'h';
+fragment I : 'I'|'i';
+fragment L : 'L'|'l';
+fragment M : 'M'|'m';
+fragment N : 'N'|'n';
+fragment O : 'O'|'o';
+fragment P : 'P'|'p';
+fragment R : 'R'|'r';
+fragment S : 'S'|'s';
+fragment T : 'T'|'t';
+fragment U : 'U'|'u';
+fragment Y : 'Y'|'y';
+fragment Z : 'Z'|'z';
+
+//special chars
+OPEN : '(' | '%28';
+CLOSE : ')' | '%29';
+COMMA : ',' | '%2C';
+SLASH : '/';
+POINT : '.';
+AT : '@';
+EQ : '=' ;
+STAR : '*';
+SEMI : ';';
+FRAGMENT : '#';
+COLON : ':';
+
+EQ_sq : '=' -> type(EQ);
+AMP_sq : '&' -> type(AMP), popMode;
+fragment WS : ( ' ' | '%09' | '%20' | '%09' );
+WSP : WS+;
+
+//JSON support
+BEGIN_OBJECT : WS* ( '{' / '%7B' ) WS*;
+END_OBJECT : WS* ( '}' / '%7D' ) WS*;
+
+BEGIN_ARRAY : WS* ( '[' / '%5B' ) WS*;
+END_ARRAY : WS* ( ']' / '%5D' ) WS*;
+NAME_SEPARATOR : WS* COLON WS*;
+
+//alpha stuff
+fragment ALPHA : 'a'..'z' | 'A'..'Z';
+fragment ALPHA_A_TO_F : 'a'..'f' | 'A'..'F';
+fragment DIGIT : '0'..'9';
+fragment DIGITS : DIGIT+;
+fragment HEXDIG : DIGIT | ALPHA_A_TO_F;
+fragment ODI_LEADINGCHARACTER : ALPHA | '_'; //TODO; add Unicode characters from the categories L or Nl
+fragment ODI_CHARACTER : ALPHA | '_' | DIGIT; //TODO; add Unicode characters from the categories L, Nl, Nd, Mn, Mc, Pc, or Cf
+
+//helper for date/time values
+fragment ONE_TO_NINE : '1'..'9';
+fragment ZERO_TO_FIFTYNINE : ('0'..'5') DIGIT;
+fragment FRACTIONALSECONDS : DIGIT+;
+fragment SECOND : ZERO_TO_FIFTYNINE;
+fragment MINUTE : ZERO_TO_FIFTYNINE;
+fragment HOUR : ('0' | '1') DIGIT | '2' ( '0'..'3');
+fragment DAY : '0' '1'..'9' | ('1'|'2') DIGIT | '3' ('0'|'1');
+fragment MONTH : '0' ONE_TO_NINE | '1' ( '0' | '1' | '2' );
+fragment YEAR : ('-')? ( '0' DIGIT DIGIT DIGIT | ONE_TO_NINE DIGIT DIGIT DIGIT );
+
+//tags start with $
+BATCH : '$batch';
+ENTITY : '$entity';
+METADATA : '$metadata';
+
+ALL : '$all';
+CROSSJOIN : '$crossjoin';
+
+VALUE : '$value';
+REF : '$ref';
+COUNT : '$count';
+
+//inlined query parameters ( e.g. $skip)
+SKIP_INLINE : '$skip';
+FILTER_INLINE : '$filter';
+ORDERBY_INLINE: '$orderby';
+
+
+ROOT : '$root/';
+
+
+
+//rest
+NULLVALUE : 'null';
+
+TRUE : 'true';
+FALSE : 'false';
+BOOLEAN : T R U E | F A L S E;
+PLUS : '+';
+SIGN : PLUS | '%2B' |'-';
+INT : SIGN? DIGITS;
+DECIMAL : INT '.' DIGITS ('e' SIGN? DIGITS)?;
+
+//primary types
+BINARY : B I N A R Y SQUOTE (HEXDIG HEXDIG)* SQUOTE;
+DATE : YEAR '-' MONTH '-' DAY;
+DATETIMEOFFSET : YEAR '-' MONTH '-' DAY T HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )? ( Z | SIGN HOUR ':' MINUTE );
+fragment DUSECONDFRAG : DIGITS ('.' DIGITS)? 'S';
+fragment DUTIMEFRAG : 'T' (
+ ( DIGITS 'H' (DIGITS 'M')? DUSECONDFRAG?)
+ | (DIGITS 'M' DUSECONDFRAG?)
+ | DUSECONDFRAG
+ );
+fragment DUDAYTIMEFRAG : DIGITS 'D' DUTIMEFRAG? | DUTIMEFRAG;
+DURATION : D U R A T I O N SQUOTE '-'? 'P' DUDAYTIMEFRAG SQUOTE;
+TIMEOFDAY : HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )?;
+fragment GUIDVALUE : HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG'-'
+ HEXDIG HEXDIG HEXDIG HEXDIG '-'
+ HEXDIG HEXDIG HEXDIG HEXDIG '-'
+ HEXDIG HEXDIG HEXDIG HEXDIG '-'
+ HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG;
+GUID : GUIDVALUE;
+
+//expression tokens
+ASC : 'asc';
+DESC : 'desc';
+MUL : 'mul';
+DIV : 'div';
+MOD : 'mod';
+ADD : 'add';
+SUB : 'sub';
+GT : 'gt';
+GE : 'ge';
+LT : 'lt';
+LE : 'le';
+EQ_ALPHA : 'eq';
+NE : 'ne';
+AND : 'and';
+OR : 'or';
+ISOF : 'isof';
+NOT : 'not';
+MINUS :'-';
+NANINFINITY : 'NaN' | '-INF' | 'INF';
+
+IMPLICIT_VARIABLE_EXPR : '$it';
+LEVELS : '$levels';
+
+CONTAINS_WORD : 'contains(';
+STARTSWITH_WORD : 'startswith(';
+ENDSWITH_WORD : 'endswith(';
+LENGTH_WORD : 'length(';
+INDEXOF_WORD : 'indexof(';
+SUBSTRING_WORD : 'substring(';
+TOLOWER_WORD : 'tolower(';
+TOUPPER_WORD : 'toupper(';
+TRIM_WORD : 'trim(';
+CONCAT_WORD : 'concat(';
+YEAR_WORD : 'year(';
+MONTH_WORD : 'month(';
+DAY_WORD : 'day(';
+HOUR_WORD : 'hour(';
+MINUTE_WORD : 'minute(';
+SECOND_WORD : 'second(';
+FRACTIONALSECONDS_WORD : 'fractionalseconds(';
+TOTALSECONDS_WORD : 'totalseconds(';
+DATE_WORD : 'date(';
+TIME_WORD : 'time(';
+TOTALOFFSETMINUTES_WORD : 'totaloffsetminutes(';
+
+MINDATETIME_WORD : 'mindatetime(';
+MAXDATETIME_WORD : 'maxdatetime(';
+NOW_WORD : 'now(';
+
+ROUND_WORD : 'round(';
+FLOOR_WORD : 'floor(';
+CEILING_WORD : 'ceiling(';
+
+GEO_DISTANCE_WORD : 'geo.distance(';
+GEO_LENGTH_WORD : 'geo.length(';
+GEO_INTERSECTS_WORD : 'geo.intersects(';
+ISOF_WORD : 'isof(';
+CAST_WORD : 'cast(';
+
+COLLECTION_REF : 'Collection($ref)';
+COLLECTION_ENTITY_TYPE : 'Collection(Edm.EntityType)';
+COLLECTION_COMPLEX_TYPE : 'Collection(Edm.ComplexType)';
+COLLECTION : 'Collection(' -> type(COLLECTION);
+
+//used in fragment only
+DELETED_ENTITY : '$deletedEntity';
+LINK : '$link';
+DELETED_LINK : '$deletedLink';
+DELTA : '$delta';
+
+
+LEVELSMAX : '$levels=max';
+
+
+//ODI
+ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*;
+
+//;==============================================================================
+// Mode "QUERY": Processes everything between the first '?' and the '#' char
+// On '?' the next mode "FRAGMENT" is used
+// The percent encoding rules a defined in RFC3986 ABNF rule "query" apply
+mode MODE_QUERY;
+//;==============================================================================
+
+FRAGMENT_q : '#' -> type(FRAGMENT);
+FILTER : '$filter' -> pushMode(DEFAULT_MODE);
+ORDERBY : '$orderby' -> pushMode(DEFAULT_MODE);
+EXPAND : '$expand' -> pushMode(DEFAULT_MODE);
+SELECT : '$select' -> pushMode(DEFAULT_MODE);
+SKIP : '$skip' -> pushMode(DEFAULT_MODE);
+SKIPTOKEN : '$skiptoken' -> pushMode(MODE_SYSTEM_QUERY_REST);
+TOP : '$top' -> pushMode(DEFAULT_MODE);
+LEVELS_q : '$levels' -> type(LEVELS), pushMode(DEFAULT_MODE);
+FORMAT : '$format' -> pushMode(MODE_SYSTEM_QUERY_PCHAR);
+COUNT_q : '$count' -> type(COUNT), pushMode(DEFAULT_MODE);
+REF_q : '$ref' -> type(REF);
+VALUE_q : '$value' -> type(VALUE);
+ID : '$id' -> pushMode(MODE_SYSTEM_QUERY_REST);
+SEARCH : '$search' -> pushMode(MODE_SYSTEM_QUERY_SEARCH);
+
+EQ_q : '=' -> type(EQ);
+AMP_q : '&' -> type(AMP);
+
+CUSTOMNAME : ~[&=@$] ~[&=]*;
+CUSTOMVALUE : ~[&=]+;
+
+//;==============================================================================
+mode MODE_SYSTEM_QUERY_PCHAR;
+//;==============================================================================
+
+AMP_sqp : '&' -> popMode,popMode;
+
+//fragment EQ_sqp : '=';
+fragment ALPHA_sqp : 'a'..'z'|'A'..'Z';
+fragment A_TO_F_sqp : 'a'..'f'|'A'..'F';
+fragment DIGIT_sqp : '0'..'9';
+fragment HEXDIG_sqp : DIGIT_sqp | A_TO_F_sqp;
+fragment PCT_ENCODED_sqp : '%' HEXDIG_sqp HEXDIG_sqp;
+fragment SUB_DELIMS_sqp : '$' | '&' | '\'' | EQ_sqp | OTHER_DELIMS_sqp;
+fragment OTHER_DELIMS_sqp : '!' | '(' | ')' | '*' | '+' | ',' | ';';
+fragment UNRESERVED_sqp : ALPHA_sqp | DIGIT_sqp | '-' |'.' | '_' | '~';
+fragment PCHAR : UNRESERVED_sqp | PCT_ENCODED_sqp | SUB_DELIMS_sqp | ':' | '@';
+fragment PCHARSTART : UNRESERVED_sqp | PCT_ENCODED_sqp | '$' | '&' | '\'' | OTHER_DELIMS_sqp | ':' | '@';
+
+
+ATOM : [Aa][Tt][Oo][Mm];
+JSON : [Jj][Ss][Oo][Nn];
+XML : [Xx][Mm][Ll];
+
+PCHARS : PCHARSTART PCHAR*;
+
+SLASH_sqp : '/' -> type(SLASH);
+EQ_sqp : '=' -> type(EQ);
+
+//;==============================================================================
+mode MODE_SYSTEM_QUERY_REST;
+// Read the remaining characters of a URI queryparameter up to an & or #
+// character.
+//;==============================================================================
+
+AMP_sqr : '&' -> type(AMP), popMode;
+FRAGMENT_sqr : '#' -> type(FRAGMENT), popMode;
+
+EQ_sqr : '=' -> type(EQ);
+REST : ~[&#=] ~[&#]*;
+
+
+
+//;==============================================================================
+mode MODE_SYSTEM_QUERY_SEARCH;
+//;==============================================================================
+
+NOT_sqc : 'NOT' -> type(NOT);
+AND_sqc : 'AND' -> type(AND);
+OR_sqc : 'OR' -> type(OR);
+EQ_sqc : '=' -> type(EQ);
+
+fragment WS_sqc : ( ' ' | '\u0009' | '%20' | '%09' );
+WSP_sqc : WS_sqc+ -> type(WSP);
+
+QUOTATION_MARK_sqc : '\u0022' | '%22';
+
+SEARCHWORD : ('a'..'z'|'A'..'Z')+;
+SEARCHPHRASE : QUOTATION_MARK_sqc ~["]* QUOTATION_MARK_sqc -> popMode;
+
+
+//;==============================================================================
+mode MODE_STRING;
+// Read the remaining characters up to an ' character.
+// An "'" character inside a string are expressed as double ''
+//;==============================================================================
+
+STRING_s : ('\'\'' | ~[\u0027] )* '\'' -> type(STRING), popMode;
+
+//;==============================================================================
+mode MODE_JSON_STRING;
+// Read the remaining characters up to an " character.
+// An "'" character inside a string are expressed excaped \"
+//;==============================================================================
+
+STRING_IN_JSON : ('\\"' | ~[\u0022] )* ('"' | '%22') -> popMode;
+
+//;==============================================================================
+mode MODE_ODATA_GEO;
+//;==============================================================================
+
+fragment C_ : 'c'|'C';
+fragment D_ : 'd'|'D';
+fragment E_ : 'e'|'E';
+fragment G_ : 'g'|'G';
+fragment H_ : 'h'|'H';
+fragment I_ : 'i'|'I';
+fragment L_ : 'l'|'L';
+fragment M_ : 'm'|'M';
+fragment N_ : 'n'|'N';
+fragment O_ : 'o'|'O';
+fragment P_ : 'p'|'P';
+fragment R_ : 'r'|'R';
+fragment S_ : 's'|'S';
+fragment T_ : 't'|'T';
+fragment U_ : 'u'|'U';
+fragment Y_ : 'y'|'Y';
+
+fragment SP_g : ' ';//'\u0020'; // a simple space
+fragment WS_g : ( ' ' | '%20' | '%09' );
+
+OPEN_g : ('(' | '%28') -> type(OPEN);
+CLOSE_g : (')' | '%29') -> type(CLOSE);
+COMMA_g : (',' | '%2C') -> type(COMMA);
+WSP_g : WS_g+ -> type(WSP);
+POINT_g : '.' -> type(POINT);
+AT_g : '@' -> type(AT);
+SEMI_g : (';' | '%3B') -> type(SEMI);
+EQ_g : '=' -> type(EQ);
+
+fragment DIGIT_g : '0'..'9';
+fragment DIGITS_g : DIGIT_g+;
+SIGN_g : ('+' | '%2B' |'-') -> type(SIGN);
+INT_g : SIGN_g? DIGITS_g -> type(INT);
+DECIMAL_g : INT_g '.' DIGITS_g ('e' SIGN_g? DIGITS_g)? -> type(DECIMAL);
+COLLECTION_g : C_ O_ L_ L_ E_ C_ T_ I_ O_ N_ -> type(COLLECTION);
+LINESTRING : L_ I_ N_ E_ S_ T_ R_ I_ N_ G_ ;
+MULTILINESTRING : M_ U_ L_ T_ I_ L_ I_ N_ E_ S_ T_ R_ I_ N_ G_;
+MULTIPOINT : M_ U_ L_ T_ I_ P_ O_ I_ N_ T_ ;
+MULTIPOLYGON : M_ U_ L_ T_ I_ P_ O_ L_ Y_ G_ O_ N_;
+GEO_POINT : P_ O_ I_ N_ T_;
+POLYGON : P_ O_ L_ Y_ G_ O_ N_ ;
+
+SRID : S_ R_ I_ D_;
+
+SQUOTE : '\'' -> popMode;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4 b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4
new file mode 100644
index 0000000..24dd1a0
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4
@@ -0,0 +1,524 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+
+ grammar UriParser;
+
+
+//Antlr4 (as most parsers) has a lexer for token detection and a parser which defines
+//rules based on the tokens. However its hard to define a clear lexer on the
+//ODATA URI syntax due to some reasons:
+// - the syntax is based on the URI specification and there fore contains the definition
+// of delimiters and percent encoding
+// - the syntax includes JSON
+// - the syntax includes a expression syntax which comes from ODATA itself (e.g. $filter)
+// - the syntax includes searchstring and searchword
+// - the ABNF describing syntax is not defined in a context free manner
+// so there are several kinds of "String" tokens:
+// - strings with single quotes,
+// - strings with single quotes and a special syntax within the quotes (like geometry data)
+// - strings with double quotes
+// - strings without quotes ( usually identifiers, searchstrings, searchwords, custom parameters)
+// but each with different allowed charactersets
+// Drawing a simple line between lexer and parser is not possible.
+//
+// This grammer is a compromiss we have choosen to satisfy the requirements we have
+// - the grammer is context free
+// - this makes the parser much simpler and we have a clear saparation between parsing and
+// EDM validation, but also creates a parse tree which is not semantically correct from the
+// EDM perspective ( e.g.it will not pass the EDM validation)
+// - the grammer can not be applied on a full URI string
+// - the URI should be split according the URI specification before used as input for the
+// ODATA parser
+// - while creating the grammer the antlr lexer modes where only allowed in pure lexer grammers
+// not in combined grammers, and is was not possible to include lexer grammer with a mode into
+// a combined grammar without creating JAVA errors.
+
+// see https://github.com/antlr/antlr4/issues/160 "Support importing multi-mode lexer grammars"
+
+
+//Naming convention
+// ...
+//Decoding encoding
+//- within rule "resourcePath": special chars used in EDM.Strings must still be encoded when
+// used as tokenizer input
+// e.g. .../Employees(id='Hugo%2FMueller')/EmployeeName <-- SLASH must be encoded to '%2F' in "Hugo/Mueller"
+// but it must not be encoded before the EmployeeName
+
+
+
+options {
+ language = Java;
+ tokenVocab=UriLexer;
+}
+
+
+
+
+
+//;------------------------------------------------------------------------------
+//; 0. URI
+//;------------------------------------------------------------------------------
+
+//ABNF odataUri and serviceRoot are currently not used here
+//odataUri = serviceRoot [ odataRelativeUri ]
+//
+//serviceRoot = ( "https" / "http" ) ; Note: case-insensitive
+// "://" host [ ":" port ]
+// "/" *( segment-nz "/" )
+
+
+odataRelativeUriEOF : odataRelativeUri? EOF;
+
+//QM and FRAGMENT enable next lexer mode
+//TODO add the new "ENTITYCAST"
+odataRelativeUri : BATCH # altBatch
+ | ENTITY QM eo=entityOptions # altEntity
+ | ENTITY SLASH ns=namespace? odi=odataIdentifier QM eo=entityOptions # altEntityCast
+ | METADATA ( QM format )? ( FRAGMENT contextFragment )? # altMetadata
+ | resourcePath ( QM queryOptions )? # altResourcePath
+ ;
+
+//;------------------------------------------------------------------------------
+//; 1. Resource Path
+//;------------------------------------------------------------------------------
+
+resourcePath : vAll=ALL
+ | vCJ=crossjoin
+ | vPSs=pathSegments
+ ;
+crossjoin : CROSSJOIN OPEN odi+=odataIdentifier ( COMMA odi+=odataIdentifier )* CLOSE;
+
+pathSegments : vlPS+=pathSegment (SLASH vlPS+=pathSegment)* vCS=constSegment?;
+
+pathSegment : vNS=namespace? vODI=odataIdentifier vlVPO+=nameValueOptList*;
+
+nameValueOptList : OPEN (vVO=valueOnly | vNVL=nameValueList)? CLOSE;
+valueOnly : vV=primitiveLiteral ;
+nameValueList : WSP* vNVP+=nameValuePair WSP* ( COMMA WSP* vNVP+=nameValuePair WSP*)* ;
+nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vVAL=primitiveLiteral /*TODO | val2=enumX*/);
+
+constSegment : SLASH (v=value | c=count | r=ref );
+
+count : COUNT;
+ref : REF;
+value : VALUE;
+//;------------------------------------------------------------------------------
+//; 2. Query Options
+//;------------------------------------------------------------------------------
+
+queryOptions : qo+=queryOption ( AMP qo+=queryOption )*;
+
+queryOption : systemQueryOption
+ | AT aliasAndValue
+ | customQueryOption
+ ;
+
+entityOptions : (eob+=entityOption AMP )* ID EQ REST ( AMP eoa+=entityOption )*;
+entityOption : ( expand | format | select )
+ | customQueryOption
+
+ ;
+
+
+
+systemQueryOption : expand
+ | filter
+ | format
+ | id
+ | inlinecount
+ | orderby
+ | search
+ | select
+ | skip
+ | skiptoken
+ | top
+ ;
+
+id : ID EQ REST;
+skiptoken : SKIPTOKEN EQ REST;
+expand : EXPAND EQ expandItemList;
+
+expandItemList : expandItem ( COMMA expandItem )*;
+
+expandItem : STAR ( SLASH ref | OPEN (LEVELS EQ INT | LEVELSMAX) CLOSE )?
+ | expandPath expandPathExtension?;
+
+expandPath : ( namespace? odataIdentifier ) ( SLASH namespace? odataIdentifier )*;
+expandPathExtension : SLASH ref ( OPEN expandRefOption ( SEMI expandRefOption )* CLOSE )?
+ | SLASH count ( OPEN expandCountOption ( SEMI expandCountOption )* CLOSE )?
+ | OPEN expandOption ( SEMI expandOption )* CLOSE
+ ;
+expandCountOption : filterInline
+ | searchInline
+ ;
+expandRefOption : expandCountOption
+ | orderbyInline
+ | skipInline
+ | top
+ | inlinecount
+ ;
+expandOption : expandRefOption
+ | select
+ | expand
+ | LEVELS;
+
+filter : FILTER EQ commonExpr;
+filterInline : FILTER_INLINE EQ commonExpr;
+
+
+
+orderby : ORDERBY EQ orderbyItem ( COMMA orderbyItem )*;
+orderbyInline : ORDERBY_INLINE EQ orderbyItem ( COMMA orderbyItem )*;
+orderbyItem : commonExpr ( WSP ( ASC | DESC ) )?;
+
+//this is completly done in lexer grammer to avoid ambiguities with odataIdentifier and STRING
+skip : SKIP EQ INT;
+skipInline : SKIP_INLINE EQ INT;
+top : TOP EQ INT;
+format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?);
+
+inlinecount : COUNT EQ booleanNonCase;
+
+search : SEARCH searchSpecialToken;
+searchInline : SEARCH_INLINE searchSpecialToken;
+
+searchSpecialToken : EQ WSP? searchExpr;
+
+searchExpr : (NOT WSP) searchExpr
+ | searchExpr searchExpr
+ | searchExpr WSP searchExpr
+ | searchExpr ( WSP AND WSP) searchExpr
+ | searchExpr ( WSP OR WSP) searchExpr
+ | searchPhrase
+ | searchWord
+ ;
+
+searchPhrase : SEARCHPHRASE;
+searchWord : SEARCHWORD;
+
+select : SELECT EQ selectItem ( COMMA selectItem )*;
+selectItem : namespace? STAR
+ | (namespace? odataIdentifier nameValueOptList? ) ( SLASH namespace? odataIdentifier nameValueOptList? )*
+ ;
+
+aliasAndValue : odataIdentifier EQ parameterValue;
+parameterValue : //arrayOrObject
+ commonExpr
+ ;
+
+
+
+customQueryOption : customName ( EQ customValue)?
+ ;
+customName : CUSTOMNAME;
+customValue : CUSTOMVALUE;
+
+
+
+//;------------------------------------------------------------------------------
+//; 3. Context URL Fragments
+//;------------------------------------------------------------------------------
+//ps+=pathSegment (SLASH ps+=pathSegment)*
+//PRIMITIVETYPENAME
+contextFragment : REF
+ /*| PRIMITIVETYPENAME*/
+ | COLLECTION_REF
+ | COLLECTION_ENTITY_TYPE
+ | COLLECTION_COMPLEX_TYPE
+ | COLLECTION ( /*PRIMITIVETYPENAME |*/ namespace? odataIdentifier ) CLOSE
+ | namespace? odataIdentifier
+ ( SLASH ( DELETED_ENTITY | LINK | DELETED_LINK )
+ | nameValueOptList? ( SLASH namespace? odataIdentifier)* ( propertyList )? ( SLASH DELTA) ? (SLASH ENTITY) ?
+ )
+ ;
+
+propertyList : OPEN propertyListItem ( COMMA propertyListItem )* CLOSE;
+propertyListItem : STAR //; all structural properties
+ | propertyListProperty
+ ;
+propertyListProperty : namespace? odataIdentifier ( SLASH namespace? odataIdentifier)* ( PLUS )? ( propertyList)?
+ ;
+
+
+//;------------------------------------------------------------------------------
+//; 4. Expressions
+//;------------------------------------------------------------------------------
+
+// this expression part of the grammer is not similar to the ABNF because
+// we had to introduced operator precesence witch is not reflected in the ABNF
+
+test : test_expr EOF;
+test_expr : INT
+ //| test_expr /*WSP*/ ( '!' | '*' ) /*WSP*/ test_expr;
+ //| test_expr WSP ( '!' | '*' ) WSP test_expr;
+ | test_expr ( WSP '!' WSP | WSP '*' WSP ) test_expr;
+
+commonExpr : OPEN commonExpr CLOSE #altPharenthesis
+ | methodCallExpr #altMethod
+ | ( unary WSP ) commonExpr #altUnary
+ | memberExpr #altMember
+ | commonExpr (WSP MUL WSP | WSP DIV WSP | WSP MOD WSP ) commonExpr #altMult
+ | commonExpr (WSP ADD WSP | WSP SUB WSP) commonExpr #altAdd
+ | commonExpr (WSP GT WSP | WSP GE WSP | WSP LT WSP | WSP LE WSP | WSP ISOF WSP) commonExpr #altComparism
+ | commonExpr (WSP EQ_ALPHA WSP | WSP NE WSP) commonExpr #altEquality
+ | commonExpr (WSP AND WSP) commonExpr #altAnd
+ | commonExpr (WSP OR WSP) commonExpr #altOr
+ | rootExpr #altRoot //; $...
+ | AT odataIdentifier #altAlias // @...
+ | primitiveLiteral #altLiteral // ...
+ ;
+
+unary : (MINUS| NOT) ;
+
+rootExpr : ROOT pathSegments;
+
+memberExpr : '$it' | '$it/'? pathSegments;
+
+anyExpr : 'any' OPEN WSP /* [ lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr ] WS* */ CLOSE;
+allExpr : 'all' OPEN WSP /* lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr WS* */ CLOSE;
+
+methodCallExpr : indexOfMethodCallExpr
+ | toLowerMethodCallExpr
+ | toUpperMethodCallExpr
+ | trimMethodCallExpr
+ | substringMethodCallExpr
+ | concatMethodCallExpr
+ | lengthMethodCallExpr
+ | yearMethodCallExpr
+ | monthMethodCallExpr
+ | dayMethodCallExpr
+ | hourMethodCallExpr
+ | minuteMethodCallExpr
+ | secondMethodCallExpr
+ | fractionalsecondsMethodCallExpr
+ | totalsecondsMethodCallExpr
+ | dateMethodCallExpr
+ | timeMethodCallExpr
+ | roundMethodCallExpr
+ | floorMethodCallExpr
+ | ceilingMethodCallExpr
+ | distanceMethodCallExpr
+ | geoLengthMethodCallExpr
+ | totalOffsetMinutesMethodCallExpr
+ | minDateTimeMethodCallExpr
+ | maxDateTimeMethodCallExpr
+ | nowMethodCallExpr
+ //from boolean
+ | isofExpr
+ | castExpr
+ | endsWithMethodCallExpr
+ | startsWithMethodCallExpr
+ | containsMethodCallExpr
+ | intersectsMethodCallExpr
+ ;
+
+
+containsMethodCallExpr : CONTAINS_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+startsWithMethodCallExpr : STARTSWITH_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+endsWithMethodCallExpr : ENDSWITH_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+lengthMethodCallExpr : LENGTH_WORD WSP? commonExpr WSP? CLOSE;
+indexOfMethodCallExpr : INDEXOF_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+substringMethodCallExpr : SUBSTRING_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? ( COMMA WSP? commonExpr WSP? )? CLOSE;
+toLowerMethodCallExpr : TOLOWER_WORD WSP? commonExpr WSP? CLOSE;
+toUpperMethodCallExpr : TOUPPER_WORD WSP? commonExpr WSP? CLOSE;
+trimMethodCallExpr : TRIM_WORD WSP? commonExpr WSP? CLOSE;
+concatMethodCallExpr : CONCAT_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+
+yearMethodCallExpr : YEAR_WORD WSP? commonExpr WSP? CLOSE;
+monthMethodCallExpr : MONTH_WORD WSP? commonExpr WSP? CLOSE;
+dayMethodCallExpr : DAY_WORD WSP? commonExpr WSP? CLOSE;
+hourMethodCallExpr : HOUR_WORD WSP? commonExpr WSP? CLOSE;
+minuteMethodCallExpr : MINUTE_WORD WSP? commonExpr WSP? CLOSE;
+secondMethodCallExpr : SECOND_WORD WSP? commonExpr WSP? CLOSE;
+fractionalsecondsMethodCallExpr : FRACTIONALSECONDS_WORD WSP? commonExpr WSP? CLOSE;
+totalsecondsMethodCallExpr : TOTALSECONDS_WORD WSP? commonExpr WSP? CLOSE;
+dateMethodCallExpr : DATE_WORD WSP? commonExpr WSP? CLOSE;
+timeMethodCallExpr : TIME_WORD WSP? commonExpr WSP? CLOSE;
+totalOffsetMinutesMethodCallExpr : TOTALOFFSETMINUTES_WORD WSP? commonExpr WSP? CLOSE;
+
+minDateTimeMethodCallExpr : MINDATETIME_WORD WSP? CLOSE;
+maxDateTimeMethodCallExpr : MAXDATETIME_WORD WSP? CLOSE;
+nowMethodCallExpr : NOW_WORD WSP? CLOSE;
+
+roundMethodCallExpr : ROUND_WORD WSP? commonExpr WSP? CLOSE;
+floorMethodCallExpr : FLOOR_WORD WSP? commonExpr WSP? CLOSE;
+ceilingMethodCallExpr : CEILING_WORD WSP? commonExpr WSP? CLOSE;
+
+distanceMethodCallExpr : GEO_DISTANCE_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? commonExpr WSP? CLOSE;
+intersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
+
+isofExpr : ISOF_WORD WSP? ( commonExpr WSP? COMMA WSP? )? qualifiedtypename WSP? CLOSE;
+castExpr : CAST_WORD WSP? ( commonExpr WSP? COMMA WSP? )? qualifiedtypename WSP? CLOSE;
+
+//;------------------------------------------------------------------------------
+//; 5. JSON format for function parameters
+//;------------------------------------------------------------------------------
+//; Note: the query part of a URI needs to be partially percent-decoded before
+//; applying these rules, see comment at the top of this file
+//;------------------------------------------------------------------------------
+
+arrayOrObject : json_array
+ | json_object;
+
+json_array : BEGIN_ARRAY json_value ( WSP? COMMA WSP? json_value)* END_ARRAY;
+
+json_value : jsonPrimitiv
+ | rootExpr
+ | json_object
+ | json_array;
+
+json_object : BEGIN_OBJECT
+ STRING_IN_JSON
+ NAME_SEPARATOR
+ json_value
+ END_OBJECT;
+
+
+//; JSON syntax: adapted to URI restrictions from [RFC4627]
+jsonPrimitiv : STRING_IN_JSON
+ | number_in_json
+ | TRUE
+ | FALSE
+ | 'null'
+ ;
+
+number_in_json : INT | DECIMAL;
+
+//;------------------------------------------------------------------------------
+//; 6. Names and identifiers
+//;------------------------------------------------------------------------------
+
+qualifiedtypename : namespace odataIdentifier
+ | 'collection' OPEN ( namespace odataIdentifier ) CLOSE
+ ;
+
+namespace : (odataIdentifier POINT)+;
+
+odataIdentifier : ODATAIDENTIFIER;
+
+//;------------------------------------------------------------------------------
+//; 7. Literal Data Values
+//;------------------------------------------------------------------------------
+
+
+/*TODO add missing values*/
+primitiveLiteral : nullrule
+ | booleanNonCase
+ | DECIMAL //includes double and single literals
+ | INT //includes int16/int32 and int64 literals
+ | BINARY
+ | DATE
+ | DATETIMEOFFSET
+ | DURATION
+ | GUID
+ | string
+ | TIMEOFDAY
+ | geographyCollection
+ | geographyLineString
+ | geographyMultilineString
+ | geographyMultipoint
+ | geographyMultipolygon
+ | geographyPoint
+ | geographyPolygon
+ | geometryCollection
+ | geometryLineString
+ | geometryMultilineString
+ | geometryMultipoint
+ | geometryMultipolygon
+ | geometryPoint
+ | geometryPolygon
+ | enumX
+ ;
+
+
+nullrule : NULLVALUE;// (SQUOTE qualifiedtypename SQUOTE)?;
+booleanNonCase : BOOLEAN | TRUE | FALSE;
+string : STRING;
+
+
+enumX : namespace odataIdentifier STRING /*SQUOTE enumValue SQUOTE*/;
+enumValue : singleEnumValue *( COMMA singleEnumValue );
+singleEnumValue : odataIdentifier / INT;
+
+
+geographyCollection : GEOGRAPHY fullCollectionLiteral SQUOTE;
+fullCollectionLiteral : sridLiteral collectionLiteral;
+
+collectionLiteral : (COLLECTION ) OPEN geoLiteral ( COMMA geoLiteral )* CLOSE;
+
+geoLiteral : collectionLiteral
+ | lineStringLiteral
+ | multipointLiteral
+ | multilineStringLiteral
+ | multipolygonLiteral
+ | pointLiteral
+ | polygonLiteral;
+
+geographyLineString : GEOGRAPHY fullLineStringLiteral SQUOTE;
+fullLineStringLiteral : sridLiteral lineStringLiteral;
+lineStringLiteral : LINESTRING lineStringData;
+lineStringData : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE;
+
+geographyMultilineString : GEOGRAPHY fullMultilineStringLiteral SQUOTE;
+fullMultilineStringLiteral : sridLiteral multilineStringLiteral;
+multilineStringLiteral : MULTILINESTRING OPEN ( lineStringData ( COMMA lineStringData )* )? CLOSE;
+
+geographyMultipoint : GEOGRAPHY fullMultipointLiteral SQUOTE;
+fullMultipointLiteral : sridLiteral multipointLiteral;
+multipointLiteral : MULTIPOINT OPEN ( pointData ( COMMA pointData )* )? CLOSE ;
+
+geographyMultipolygon : GEOGRAPHY fullmultipolygonLiteral SQUOTE;
+fullmultipolygonLiteral : sridLiteral multipolygonLiteral;
+multipolygonLiteral : MULTIPOLYGON OPEN ( polygonData ( COMMA polygonData )* )? CLOSE;
+
+geographyPoint : GEOGRAPHY fullpointLiteral SQUOTE;
+fullpointLiteral : sridLiteral pointLiteral;
+
+pointLiteral : GEO_POINT pointData;
+pointData : OPEN positionLiteral CLOSE;
+
+positionLiteral : (DECIMAL | INT ) WSP (DECIMAL | INT ); //; longitude, then latitude
+
+
+geographyPolygon : GEOGRAPHY fullPolygonLiteral SQUOTE;
+fullPolygonLiteral : sridLiteral polygonLiteral;
+polygonLiteral : POLYGON polygonData;
+polygonData : OPEN ringLiteral ( COMMA ringLiteral )* CLOSE;
+ringLiteral : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE;
+
+
+geometryCollection : GEOMETRY fullCollectionLiteral SQUOTE;
+geometryLineString : GEOMETRY fullLineStringLiteral SQUOTE;
+geometryMultilineString : GEOMETRY fullMultilineStringLiteral SQUOTE;
+geometryMultipoint : GEOMETRY fullMultipointLiteral SQUOTE;
+geometryMultipolygon : GEOMETRY fullmultipolygonLiteral SQUOTE;
+geometryPoint : GEOMETRY fullpointLiteral SQUOTE;
+geometryPolygon : GEOMETRY fullPolygonLiteral SQUOTE;
+
+sridLiteral : SRID EQ INT SEMI;
+
+
+
+
+
+/*
+mode MODEd333gh;
+
+MO12E1 : 'ASD' -> mode(DEFAULT_MODE);*/
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/10ac7ee3/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/producer/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/producer/core/uri/antlr/UriLexer.g4 b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/producer/core/uri/antlr/UriLexer.g4
deleted file mode 100644
index 295936b..0000000
--- a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/producer/core/uri/antlr/UriLexer.g4
+++ /dev/null
@@ -1,385 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-lexer grammar UriLexer;
-
-//;==============================================================================
-// Mode "DEFAULT_MODE": Processes everything bevor the first '?' char
-// On '?' the next mode "MODE_QUERY" is used
-// The percent encoding rules a defined in RFC3986 ABNF rule "path-rootless" apply
-//;==============================================================================
-QM : '?' -> pushMode(MODE_QUERY); //first query parameter
-AMP : '&' -> pushMode(MODE_QUERY); //more query parameters
-STRING : '\'' -> more, pushMode(MODE_ODATA_STRING);
-
-GEOGRAPHY : G E O G R A P H Y SQUOTE -> pushMode(MODE_ODATA_GEO); //TODO make case insensitive
-GEOMETRY : G E O M E T R Y SQUOTE -> pushMode(MODE_ODATA_GEO);
-
-//Letters for case insensitivity
-fragment A : 'A'|'a';
-fragment B : 'B'|'b';
-fragment D : 'D'|'d';
-fragment E : 'E'|'e';
-fragment F : 'F'|'f';
-fragment G : 'G'|'g';
-fragment H : 'H'|'h';
-fragment I : 'I'|'i';
-fragment L : 'L'|'l';
-fragment M : 'M'|'m';
-fragment N : 'N'|'n';
-fragment O : 'O'|'o';
-fragment P : 'P'|'p';
-fragment R : 'R'|'r';
-fragment S : 'S'|'s';
-fragment T : 'T'|'t';
-fragment U : 'U'|'u';
-fragment Y : 'Y'|'y';
-fragment Z : 'Z'|'z';
-
-//special chars
-OPEN : '(' | '%28';
-CLOSE : ')' | '%29';
-COMMA : ',' | '%2C';
-SLASH : '/';
-POINT : '.';
-AT : '@';
-EQ : '=' ;
-STAR : '*';
-SEMI : ';';
-FRAGMENT : '#';
-
-EQ_sq : '=' -> type(EQ);
-AMP_sq : '&' -> type(AMP), popMode;
-fragment WS : ( ' ' | '%09' | '%20' | '%09' );
-WSP : WS+;
-
-//alpha stuff
-fragment ALPHA : 'a'..'z' | 'A'..'Z';
-fragment ALPHA_A_TO_F : 'a'..'f' | 'A'..'F';
-fragment DIGIT : '0'..'9';
-fragment DIGITS : DIGIT+;
-fragment HEXDIG : DIGIT | ALPHA_A_TO_F;
-fragment ODI_LEADINGCHARACTER : ALPHA | '_'; //TODO; add Unicode characters from the categories L or Nl
-fragment ODI_CHARACTER : ALPHA | '_' | DIGIT; //TODO; add Unicode characters from the categories L, Nl, Nd, Mn, Mc, Pc, or Cf
-
-//helper for date/time values
-fragment ONE_TO_NINE : '1'..'9';
-fragment ZERO_TO_FIFTYNINE : ('0'..'5') DIGIT;
-fragment FRACTIONALSECONDS : DIGIT+;
-fragment SECOND : ZERO_TO_FIFTYNINE;
-fragment MINUTE : ZERO_TO_FIFTYNINE;
-fragment HOUR : ('0' | '1') DIGIT | '2' ( '0'..'3');
-fragment DAY : '0' '1'..'9' | ('1'|'2') DIGIT | '3' ('0'|'1');
-fragment MONTH : '0' ONE_TO_NINE | '1' ( '0' | '1' | '2' );
-fragment YEAR : ('-')? ( '0' DIGIT DIGIT DIGIT | ONE_TO_NINE DIGIT DIGIT DIGIT );
-
-//tag start with $
-BATCH : '$batch';
-ENTITY : '$entity';
-METADATA : '$metadata';
-
-ALL : '$all';
-CROSSJOIN : '$crossjoin';
-
-VALUE : '$value';
-REF : '$ref';
-COUNT : '$count';
-
-//inlined query parameters ( e.g. $skip)
-SKIP_INLINE : '$skip';
-FILTER_INLINE : '$filter';
-ORDERBY_INLINE: '$orderby';
-SEARCH_INLINE : '$search'-> pushMode(MODE_SYSTEM_QUERY_SEARCH);
-
-
-
-//rest
-NULLVALUE : 'null';
-
-TRUE : 'true';
-FALSE : 'false';
-BOOLEAN : T R U E | F A L S E;
-PLUS : '+';
-SIGN : PLUS | '%2B' |'-';
-INT : SIGN? DIGITS;
-DECIMAL : INT '.' DIGITS ('e' SIGN? DIGITS)?;
-
-//primary types
-BINARY : B I N A R Y SQUOTE (HEXDIG HEXDIG)* SQUOTE;
-DATE : D A T E SQUOTE YEAR '-' MONTH '-' DAY SQUOTE;
-DATETIMEOFFSET : D A T E T I M E O F F S E T SQUOTE YEAR '-' MONTH '-' DAY T HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )? ( Z | SIGN HOUR ':' MINUTE ) SQUOTE;
-fragment DUSECONDFRAG : DIGITS ('.' DIGITS)? 'S';
-fragment DUTIMEFRAG : 'T' (
- ( DIGITS 'H' (DIGITS 'M')? DUSECONDFRAG?)
- | (DIGITS 'M' DUSECONDFRAG?)
- | DUSECONDFRAG
- );
-fragment DUDAYTIMEFRAG : DIGITS 'D' DUTIMEFRAG? | DUTIMEFRAG;
-DURATION : D U R A T I O N SQUOTE '-'? 'P' DUDAYTIMEFRAG SQUOTE;
-TIMEOFDAY : T I M E O F D A Y SQUOTE HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )? SQUOTE;
-fragment GUIDVALUE : HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG'-'
- HEXDIG HEXDIG HEXDIG HEXDIG '-'
- HEXDIG HEXDIG HEXDIG HEXDIG '-'
- HEXDIG HEXDIG HEXDIG HEXDIG '-'
- HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG;
-GUID : G U I D SQUOTE GUIDVALUE SQUOTE;
-
-//expression tokens
-ASC : 'asc';
-DESC : 'desc';
-MUL : 'mul';
-DIV : 'div';
-MOD : 'mod';
-ADD : 'add';
-SUB : 'sub';
-GT : 'gt';
-GE : 'ge';
-LT : 'lt';
-LE : 'le';
-EQ_ALPHA : 'eq';
-NE : 'ne';
-AND : 'and';
-OR : 'or';
-ISOF : 'isof';
-NOT : 'not';
-MINUS :'-';
-ROOT : '$root/';
-NANINFINITY : 'NaN' | '-INF' | 'INF';
-
-IMPLICIT_VARIABLE_EXPR : '$it';
-LEVELS : '$levels';
-
-CONTAINS_WORD : 'contains(';
-STARTSWITH_WORD : 'startswith(';
-ENDSWITH_WORD : 'endswith(';
-LENGTH_WORD : 'length(';
-INDEXOF_WORD : 'indexof(';
-SUBSTRING_WORD : 'substring(';
-TOLOWER_WORD : 'tolower(';
-TOUPPER_WORD : 'toupper(';
-TRIM_WORD : 'trim(';
-CONCAT_WORD : 'concat(';
-YEAR_WORD : 'year(';
-MONTH_WORD : 'month(';
-DAY_WORD : 'day(';
-HOUR_WORD : 'hour(';
-MINUTE_WORD : 'minute(';
-SECOND_WORD : 'second(';
-FRACTIONALSECONDS_WORD : 'fractionalseconds(';
-TOTALSECONDS_WORD : 'totalseconds(';
-DATE_WORD : 'date(';
-TIME_WORD : 'time(';
-TOTALOFFSETMINUTES_WORD : 'totaloffsetminutes(';
-
-MINDATETIME_WORD : 'mindatetime(';
-MAXDATETIME_WORD : 'maxdatetime(';
-NOW_WORD : 'now(';
-
-ROUND_WORD : 'round(';
-FLOOR_WORD : 'floor(';
-CEILING_WORD : 'ceiling(';
-
-GEO_DISTANCE_WORD : 'geo.distance(';
-GEO_LENGTH_WORD : 'geo.length(';
-GEO_INTERSECTS_WORD : 'geo.intersects(';
-ISOF_WORD : 'isof(';
-CAST_WORD : 'cast(';
-
-COLLECTION_REF : 'Collection($ref)';
-COLLECTION_ENTITY_TYPE : 'Collection(Edm.EntityType)';
-COLLECTION_COMPLEX_TYPE : 'Collection(Edm.ComplexType)';
-COLLECTION : 'Collection(' -> type(COLLECTION);
-
-//used in fragment only
-DELETED_ENTITY : '$deletedEntity';
-LINK : '$link';
-DELETED_LINK : '$deletedLink';
-DELTA : '$delta';
-//ENTITY_IN_FRAGMENT : '/$entity';
-
-
-LEVELSMAX : '$levels=max';
-
-
-//ODI
-ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*;
-
-//;==============================================================================
-// Mode "QUERY": Processes everything between the first '?' and the '#' char
-// On '?' the next mode "FRAGMENT" is used
-// The percent encoding rules a defined in RFC3986 ABNF rule "query" apply
-mode MODE_QUERY;
-//;==============================================================================
-
-FRAGMENT_q : '#' -> type(FRAGMENT);
-FILTER : '$filter' -> pushMode(DEFAULT_MODE);
-ORDERBY : '$orderby' -> pushMode(DEFAULT_MODE);
-EXPAND : '$expand' -> pushMode(DEFAULT_MODE);
-SELECT : '$select' -> pushMode(DEFAULT_MODE);
-SKIP : '$skip' -> pushMode(DEFAULT_MODE);
-SKIPTOKEN : '$skiptoken' -> pushMode(MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP);
-
-TOP : '$top' -> pushMode(DEFAULT_MODE);
-LEVELS_q : '$levels' -> type(LEVELS), pushMode(DEFAULT_MODE);
-FORMAT : '$format' -> pushMode(MODE_SYSTEM_QUERY_PCHAR);
-COUNT_q : '$count' -> type(COUNT), pushMode(DEFAULT_MODE);
-REF_q : '$ref' -> type(REF);
-VALUE_q : '$value' -> type(VALUE);
-
-ID : '$id'-> pushMode(MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP);
-
-SEARCH : '$search'-> pushMode(MODE_SYSTEM_QUERY_SEARCH);
-
-EQ_q : '=' -> type(EQ);
-
-AMP_q : '&' -> type(AMP);
-
-CUSTOMNAME : ~[&=@$] ~[&=]*;
-CUSTOMVALUE : ~[&=]+;
-
-//;==============================================================================
-mode MODE_SYSTEM_QUERY_PCHAR;
-//;==============================================================================
-
-AMP_sqp : '&' -> popMode,popMode;
-
-//fragment EQ_sqp : '=';
-fragment ALPHA_sqp : 'a'..'z'|'A'..'Z';
-fragment A_TO_F_sqp : 'a'..'f'|'A'..'F';
-fragment DIGIT_sqp : '0'..'9';
-fragment HEXDIG_sqp : DIGIT_sqp | A_TO_F_sqp;
-fragment PCT_ENCODED_sqp : '%' HEXDIG_sqp HEXDIG_sqp;
-fragment SUB_DELIMS_sqp : '$' | '&' | '\'' | EQ_sqp | OTHER_DELIMS_sqp;
-fragment OTHER_DELIMS_sqp : '!' | '(' | ')' | '*' | '+' | ',' | ';';
-fragment UNRESERVED_sqp : ALPHA_sqp | DIGIT_sqp | '-' |'.' | '_' | '~';
-fragment PCHAR : UNRESERVED_sqp | PCT_ENCODED_sqp | SUB_DELIMS_sqp | ':' | '@';
-fragment PCHARSTART : UNRESERVED_sqp | PCT_ENCODED_sqp | '$' | '&' | '\'' | OTHER_DELIMS_sqp | ':' | '@';
-
-
-ATOM : [Aa][Tt][Oo][Mm];
-JSON : [Jj][Ss][Oo][Nn];
-XML : [Xx][Mm][Ll];
-
-PCHARS : PCHARSTART PCHAR*;
-
-SLASH_sqp : '/' -> type(SLASH);
-EQ_sqp : '=' -> type(EQ);
-
-//;==============================================================================
-mode MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP;
-//;==============================================================================
-
-AMP_sqr : '&' -> type(AMP), popMode;
-FRAGMENT_sqr : '#' -> popMode;
-/*
-fragment ALPHA_sqr : 'a'..'z'|'A'..'Z';
-fragment A_TO_F_sqr : 'a'..'f'|'A'..'F';
-fragment DIGIT_sqr : '0'..'9';
-fragment HEXDIG_sqr : DIGIT_sqr | A_TO_F_sqr;
-fragment PCT_ENCODED_sqr : '%' HEXDIG_sqr HEXDIG_sqr;
-fragment UNRESERVED_sqr : ALPHA_sqr | DIGIT_sqr | '-' |'.' | '_' | '~';
-fragment OTHER_DELIMS_sqr : '!' | '(' | ')' | '*' | '+' | ',' | ';';
-fragment QCHAR_NO_AMP_sqr : UNRESERVED_sqr | PCT_ENCODED_sqr | OTHER_DELIMS_sqr | ':' | '@' | '/' | '?' | '$' | '\'' | '=';
-fragment QCHAR_NO_AMP_EQ_sqr : UNRESERVED_sqr | PCT_ENCODED_sqr | OTHER_DELIMS_sqr | ':' | '@' | '/' | '?' | '$' | '\'' ;
-*/
-
-EQ_sqr : '=' -> type(EQ);
-REST : ~[&#=] ~[&#]*;
-
-
-
-//;==============================================================================
-mode MODE_SYSTEM_QUERY_SEARCH;
-//;==============================================================================
-
-fragment ALPHA_sqc : 'a'..'z'|'A'..'Z';
-fragment WS_sqc : ( SP_g | HTAB_g | '%20' | '%09' );
-fragment DQUOTE : '\u0022';
-NOT_sqc : 'NOT' -> type(NOT);
-AND_sqc : 'AND' -> type(AND);
-OR_sqc : 'OR' -> type(OR);
-EQ_sqc : '=' -> type(EQ);
-
-WSP_sqc : WS_sqc+ -> type(WSP);
-
-
-QUOTATION_MARK : DQUOTE | '%22';
-
-REF_sqc : '$ref' -> type(REF);
-
-SEARCHWORD : ALPHA_sqc+;
-SEARCHPHRASE : QUOTATION_MARK /*QCHAR_NO_AMP_DQUOTE+*/ ~[&"]* QUOTATION_MARK -> popMode;
-
-
-//;==============================================================================
-mode MODE_ODATA_STRING;
-//;==============================================================================
-
-fragment SQUOTE_s : '\'';
-STRING_s : ('\'\'' | ~[\u0027] )* SQUOTE_s -> type(STRING), popMode;
-
-//;==============================================================================
-mode MODE_ODATA_GEO;
-//;==============================================================================
-
-fragment C_g : 'c'|'C';
-fragment D_g : 'd'|'D';
-fragment E_g : 'e'|'E';
-fragment G_g : 'g'|'G';
-fragment H_g : 'h'|'H';
-fragment I_g : 'i'|'I';
-fragment L_g : 'l'|'L';
-fragment M_g : 'm'|'M';
-fragment N_g : 'n'|'N';
-fragment O_g : 'o'|'O';
-fragment P_g : 'p'|'P';
-fragment R_g : 'r'|'R';
-fragment S_g : 's'|'S';
-fragment T_g : 't'|'T';
-fragment U_g : 'u'|'U';
-fragment Y_g : 'y'|'Y';
-
-fragment SP_g : ' ';//'\u0020'; // a simple space
-fragment HTAB_g : '%09';
-fragment WS_g : ( ' ' | HTAB_g | '%20' | '%09' );
-
-OPEN_g : ('(' | '%28') -> type(OPEN);
-CLOSE_g : (')' | '%29') -> type(CLOSE);
-COMMA_g : (',' | '%2C') -> type(COMMA);
-WSP_g : WS_g+ -> type(WSP);
-POINT_g : '.' -> type(POINT);
-AT_g : '@' -> type(AT);
-SEMI_g : (';' | '%3B') -> type(SEMI);
-EQ_g : '=' -> type(EQ);
-
-fragment DIGIT_g : '0'..'9';
-fragment DIGITS_g : DIGIT_g+;
-SIGN_g : ('+' | '%2B' |'-') -> type(SIGN);
-INT_g : SIGN_g? DIGITS_g -> type(INT);
-DECIMAL_g : INT_g '.' DIGITS_g ('e' SIGN_g? DIGITS_g)? -> type(DECIMAL);
-COLLECTION_g : C_g O_g L_g L_g E_g C_g T_g I_g O_g N_g -> type(COLLECTION);
-LINESTRING : L_g I_g N_g E_g S_g T_g R_g I_g N_g G_g ;
-MULTILINESTRING : M_g U_g L_g T_g I_g L_g I_g N_g E_g S_g T_g R_g I_g N_g G_g;
-MULTIPOINT : M_g U_g L_g T_g I_g P_g O_g I_g N_g T_g ;
-MULTIPOLYGON : M_g U_g L_g T_g I_g P_g O_g L_g Y_g G_g O_g N_g;
-GEO_POINT : P_g O_g I_g N_g T_g;
-POLYGON : P_g O_g L_g Y_g G_g O_g N_g ;
-
-SRID : S_g R_g I_g D_g;
-
-SQUOTE : '\'' -> popMode;