OSDN Git Service

simple query grammar
authorleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Thu, 6 Aug 2009 06:30:41 +0000 (06:30 +0000)
committerleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Thu, 6 Aug 2009 06:30:41 +0000 (06:30 +0000)
git-svn-id: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core@3522 ae02f08e-27ec-0310-ae8c-8ba02fe2eafd

src/main/java/org/xerial/json/JSONWriter.java
src/main/java/org/xerial/lens/ObjectLens.java
src/main/java/org/xerial/lens/relation/TupleIndex.java
src/main/java/org/xerial/lens/relation/query/impl/LensQuery.g
src/main/java/org/xerial/lens/relation/query/impl/LensQuery.tokens
src/main/java/org/xerial/lens/relation/query/impl/LensQueryLexer.java
src/main/java/org/xerial/lens/relation/query/impl/LensQueryParser.java
src/main/java/org/xerial/lens/relation/query/lang/LensQuery.tokens [new file with mode: 0644]
src/main/java/org/xerial/lens/relation/query/lang/RelationExpr.java
src/main/java/org/xerial/lens/relation/query/lang/RelationItem.java [new file with mode: 0644]
src/test/java/org/xerial/lens/relation/query/lang/RelationExprTest.java

index 7317e12..065385a 100644 (file)
@@ -137,7 +137,7 @@ public class JSONWriter {
         writer.append(stringFragment);
     }
 
-    public void endString() throws IOException {
+    public void endString() {
         if (getCurrentState() != JSONState.InString)
             throw new XerialError(JSONErrorCode.NotInAJSONString,
                     "cannot end the string not beginning from startString() method.");
index 64c9786..b494028 100644 (file)
@@ -463,9 +463,17 @@ public class ObjectLens {
                 json.endObject();\r
         }\r
         else {\r
-            json.startObject();\r
-            outputParemters(json, obj);\r
-            json.endObject();\r
+            if (!lens.getterContainer.isEmpty()) {\r
+                json.startObject();\r
+                outputParemters(json, obj);\r
+                json.endObject();\r
+            }\r
+            else {\r
+                // empty getter object. try toString()\r
+                json.startString();\r
+                json.append(obj.toString());\r
+                json.endString();\r
+            }\r
         }\r
     }\r
 \r
index a33af76..21b2817 100644 (file)
@@ -34,8 +34,7 @@ import org.xerial.core.XerialErrorCode;
  * @author leo\r
  * \r
  */\r
-public class TupleIndex implements Comparable<TupleIndex>\r
-{\r
+public class TupleIndex implements Comparable<TupleIndex> {\r
     private int[] index;\r
 \r
     /**\r
@@ -43,8 +42,7 @@ public class TupleIndex implements Comparable<TupleIndex>
      * \r
      * @param baseIndex\r
      */\r
-    public TupleIndex(int baseIndex)\r
-    {\r
+    public TupleIndex(int baseIndex) {\r
         this.index = new int[1];\r
         this.index[0] = baseIndex;\r
     }\r
@@ -56,15 +54,12 @@ public class TupleIndex implements Comparable<TupleIndex>
      * @param parent\r
      * @param childIndex\r
      */\r
-    public TupleIndex(TupleIndex parent, int childIndex)\r
-    {\r
-        if (parent == null)\r
-        {\r
+    public TupleIndex(TupleIndex parent, int childIndex) {\r
+        if (parent == null) {\r
             this.index = new int[1];\r
             this.index[0] = childIndex;\r
         }\r
-        else\r
-        {\r
+        else {\r
             this.index = new int[parent.size() + 1];\r
             for (int i = 0; i < parent.size(); ++i)\r
                 index[i] = parent.get(i);\r
@@ -72,8 +67,11 @@ public class TupleIndex implements Comparable<TupleIndex>
         }\r
     }\r
 \r
-    public static TupleIndex parse(String indexStr)\r
-    {\r
+    public static TupleIndex root() {\r
+        return new TupleIndex(0);\r
+    }\r
+\r
+    public static TupleIndex parse(String indexStr) {\r
         if (indexStr == null)\r
             throw new NullPointerException("indexStr");\r
 \r
@@ -87,13 +85,11 @@ public class TupleIndex implements Comparable<TupleIndex>
         return new TupleIndex(index);\r
     }\r
 \r
-    private TupleIndex(int[] index)\r
-    {\r
+    private TupleIndex(int[] index) {\r
         this.index = index;\r
     }\r
 \r
-    public TupleIndex parent()\r
-    {\r
+    public TupleIndex parent() {\r
         if (index.length <= 1)\r
             return null;\r
 \r
@@ -103,8 +99,7 @@ public class TupleIndex implements Comparable<TupleIndex>
         return new TupleIndex(newIndex);\r
     }\r
 \r
-    public TupleIndex tail()\r
-    {\r
+    public TupleIndex tail() {\r
         if (index.length < 2)\r
             return null;\r
 \r
@@ -114,8 +109,7 @@ public class TupleIndex implements Comparable<TupleIndex>
         return new TupleIndex(newIndex);\r
     }\r
 \r
-    public TupleIndex sibling()\r
-    {\r
+    public TupleIndex sibling() {\r
         int[] newIndex = new int[index.length];\r
         for (int i = 0; i < index.length; ++i)\r
             newIndex[i] = index[i];\r
@@ -128,18 +122,15 @@ public class TupleIndex implements Comparable<TupleIndex>
      * \r
      * @return nested level\r
      */\r
-    public int size()\r
-    {\r
+    public int size() {\r
         return index.length;\r
     }\r
 \r
-    public boolean hasParent()\r
-    {\r
+    public boolean hasParent() {\r
         return index.length > 1;\r
     }\r
 \r
-    public boolean hasTail()\r
-    {\r
+    public boolean hasTail() {\r
         return index.length > 1;\r
     }\r
 \r
@@ -149,17 +140,14 @@ public class TupleIndex implements Comparable<TupleIndex>
      * @param level\r
      * @return\r
      */\r
-    public int get(int level)\r
-    {\r
+    public int get(int level) {\r
         return index[level];\r
     }\r
 \r
     @Override\r
-    public String toString()\r
-    {\r
+    public String toString() {\r
         StringBuilder buf = new StringBuilder();\r
-        for (int i = 0; i < index.length; i++)\r
-        {\r
+        for (int i = 0; i < index.length; i++) {\r
             if (i != 0)\r
                 buf.append(".");\r
             buf.append(index[i]);\r
@@ -168,14 +156,12 @@ public class TupleIndex implements Comparable<TupleIndex>
     }\r
 \r
     @Override\r
-    public boolean equals(Object obj)\r
-    {\r
+    public boolean equals(Object obj) {\r
         TupleIndex other = TupleIndex.class.cast(obj);\r
         if (this.index.length != other.index.length)\r
             return false;\r
 \r
-        for (int i = 0; i < this.index.length; ++i)\r
-        {\r
+        for (int i = 0; i < this.index.length; ++i) {\r
             if (this.index[i] != other.index[i])\r
                 return false;\r
         }\r
@@ -183,13 +169,11 @@ public class TupleIndex implements Comparable<TupleIndex>
 \r
     }\r
 \r
-    public int compareTo(TupleIndex other)\r
-    {\r
+    public int compareTo(TupleIndex other) {\r
         int i1 = 0;\r
         int i2 = 0;\r
         int cmp = 0;\r
-        while (i1 < this.index.length && i2 < other.index.length)\r
-        {\r
+        while (i1 < this.index.length && i2 < other.index.length) {\r
             int e1 = this.index[i1];\r
             int e2 = other.index[i2];\r
             cmp = e1 - e2;\r
@@ -201,8 +185,7 @@ public class TupleIndex implements Comparable<TupleIndex>
         }\r
         if (i1 < this.index.length)\r
             return 1;\r
-        else\r
-        {\r
+        else {\r
             if (i2 < other.index.length)\r
                 return -1;\r
             else\r
@@ -211,8 +194,7 @@ public class TupleIndex implements Comparable<TupleIndex>
     }\r
 \r
     @Override\r
-    public int hashCode()\r
-    {\r
+    public int hashCode() {\r
         int hash = 3;\r
         for (int i = 0; i < index.length; ++i)\r
             hash += 137 * index[i];\r
index a3ba12b..43764ee 100644 (file)
@@ -35,9 +35,11 @@ tokens {
   OPERAND;\r
   PATTERNMATCH;\r
   NODE;\r
+  ALIAS;\r
   NODEVALUE;\r
   NAME;\r
   VALUE;\r
+  INDEX;\r
 }\r
 \r
 \r
@@ -96,12 +98,17 @@ package org.xerial.lens.relation.query.impl;
 //\r
 //--------------------------------------\r
 package org.xerial.lens.relation.query.impl;\r
+\r
+import org.xerial.lens.relation.TupleIndex;\r
 }\r
 \r
 @lexer::members {\r
-  \r
+\r
 }\r
\r
+\r
+@members {\r
+   private TupleIndex currentIndex = null;\r
+} \r
 \r
 // lexer rules\r
 \r
@@ -155,6 +162,8 @@ Dot: '.';
 Comma: ',';\r
 Colon: ':';\r
 \r
+As: 'as';\r
+\r
 LParen: '(';  \r
 RParen: ')';\r
 \r
@@ -163,16 +172,14 @@ Star: '*';
 fragment\r
 UnsafeUnicodeChar: '(' | ')' | '[' | ']' | '{' | '}' | ',' | ':' | '#' | '<' | '>' | '|' | '*' | '\'' | '"' | '@' | '%' | '\\' | '.' | '-'; \r
 \r
-\r
 fragment SafeFirstLetter: 'A' .. 'Z' | 'a' .. 'z';\r
 fragment SafeLetter: SafeFirstLetter | '0' .. '9' | '-' | '_';\r
 \r
-fragment ModuleName: SafeFirstLetter SafeLetter* ('.' SafeFirstLetter SafeLetter*)*; \r
-ModuleDef: 'module' WhiteSpaces s=ModuleName { setText($s.text); }; \r
 \r
 fragment QNameChar: ~(LineBreakChar | UnsafeUnicodeChar | WhiteSpace);\r
 QName: QNameChar+ (Dot QNameChar+)*;\r
 \r
+\r
 fragment \r
 WhiteSpace: ' ' | '\t';\r
  \r
@@ -185,19 +192,53 @@ expr:
   relation \r
   ; \r
  \r
-relation: QName LParen nodeItem (Comma nodeItem)* RParen\r
-  -> ^(RELATION NAME[$QName.text] nodeItem+)\r
+relation \r
+scope \r
+{\r
+  int nodeItemIndex;\r
+  TupleIndex relationIndex; \r
+}\r
+@init \r
+{\r
+  $relation::nodeItemIndex = 1;\r
+  if(currentIndex == null)\r
+    currentIndex = new TupleIndex(1);\r
+  else\r
+    currentIndex = new TupleIndex(currentIndex, 1); \r
+}\r
+@after\r
+{\r
+  currentIndex = currentIndex.parent();\r
+}\r
+   : relation_i -> ^(RELATION relation_i INDEX[currentIndex.toString()])\r
+;\r
+\r
+relation_i: nodeName alias? LParen! nodeItem (Comma! nodeItem)* RParen!;\r
+\r
+fragment\r
+nodeName\r
+  : QName -> NAME[$QName.text]\r
+  | String -> NAME[$String.text]\r
   ;\r
 \r
 fragment\r
+alias: As QName -> ALIAS[$QName.text];\r
+  \r
+\r
+fragment\r
 nodeItem\r
-  : QName nodeValue? \r
-    -> ^(NODE NAME[$QName.text] nodeValue?)\r
-  | relation\r
+@init {\r
+  int index = $relation::nodeItemIndex++;\r
+}\r
+  : nodeName alias? nodeValue? \r
+    -> ^(NODE nodeName alias? nodeValue? INDEX[new TupleIndex(currentIndex, index).toString()])\r
+  | relation \r
   ;\r
 \r
 fragment\r
-value: String | Integer | Double;  \r
+value\r
+  : String | Integer | Double | QName\r
+  ;  \r
   \r
 fragment  \r
 nodeValue\r
index c8f980c..c2f2c46 100644 (file)
@@ -1,55 +1,56 @@
+INDEX=15\r
 PATTERNMATCH=9\r
-RBrace=33\r
-Match=42\r
-LBracket=34\r
-Regex=43\r
-Digit=17\r
-Frac=26\r
-HexDigit=19\r
+Match=44\r
+RBrace=35\r
+Regex=45\r
+LBracket=36\r
+Digit=19\r
+Frac=28\r
+HexDigit=21\r
 QUERY=4\r
-VALUE=13\r
-Letter=18\r
-Comma=45\r
-Dot=44\r
-EscapeSequence=21\r
-Integer=25\r
+ALIAS=11\r
+VALUE=14\r
+Letter=20\r
+Comma=47\r
+Dot=46\r
+EscapeSequence=23\r
+Integer=27\r
 WhiteSpace=56\r
 OPERATOR=7\r
-False=30\r
-Colon=46\r
-LineComment=15\r
-NODEVALUE=11\r
-ModuleName=53\r
-SafeFirstLetter=51\r
-Null=31\r
-Star=49\r
-Eq=40\r
-Exp=27\r
+False=32\r
+Colon=48\r
+LineComment=17\r
+NODEVALUE=12\r
+As=49\r
+SafeFirstLetter=54\r
+Null=33\r
+Star=52\r
+Eq=42\r
+Exp=29\r
 QNameChar=57\r
 RELATION=5\r
-Gt=37\r
-RParen=48\r
-UnicodeChar=20\r
-StringChar=22\r
-True=29\r
+Gt=39\r
+RParen=51\r
+UnicodeChar=22\r
+StringChar=24\r
+True=31\r
 OPERAND=8\r
-LineBreak=16\r
-ModuleDef=55\r
-LParen=47\r
-String=24\r
-SafeLetter=52\r
-LineBreakChar=14\r
+LineBreak=18\r
+LParen=50\r
+String=26\r
+SafeLetter=55\r
+LineBreakChar=16\r
 COMPARE=6\r
 QName=58\r
-Geq=39\r
+Geq=41\r
 NODE=10\r
-StringChar_s=23\r
-Neq=41\r
-UnsafeUnicodeChar=50\r
-Double=28\r
-LBrace=32\r
-RBracket=35\r
-Lt=36\r
-NAME=12\r
-Leq=38\r
-WhiteSpaces=54\r
+StringChar_s=25\r
+Neq=43\r
+UnsafeUnicodeChar=53\r
+Double=30\r
+LBrace=34\r
+RBracket=37\r
+Lt=38\r
+NAME=13\r
+Leq=40\r
+WhiteSpaces=59\r
index 6396521..31c0483 100644 (file)
@@ -1,4 +1,4 @@
-// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-08-06 11:41:05\r
+// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-08-06 15:20:41\r
 \r
 /*--------------------------------------------------------------------------\r
  *  Copyright 2009 Taro L. Saito\r
@@ -33,64 +33,65 @@ import java.util.List;
 import java.util.ArrayList;\r
 \r
 public class LensQueryLexer extends Lexer {\r
+    public static final int INDEX=15;\r
     public static final int PATTERNMATCH=9;\r
-    public static final int RBrace=33;\r
-    public static final int Match=42;\r
-    public static final int Regex=43;\r
-    public static final int LBracket=34;\r
-    public static final int Digit=17;\r
-    public static final int Frac=26;\r
-    public static final int HexDigit=19;\r
+    public static final int Match=44;\r
+    public static final int RBrace=35;\r
+    public static final int LBracket=36;\r
+    public static final int Regex=45;\r
+    public static final int Digit=19;\r
+    public static final int Frac=28;\r
+    public static final int HexDigit=21;\r
     public static final int QUERY=4;\r
-    public static final int VALUE=13;\r
-    public static final int Letter=18;\r
-    public static final int Comma=45;\r
-    public static final int Dot=44;\r
-    public static final int EscapeSequence=21;\r
-    public static final int Integer=25;\r
+    public static final int ALIAS=11;\r
+    public static final int VALUE=14;\r
+    public static final int Letter=20;\r
+    public static final int Comma=47;\r
+    public static final int Dot=46;\r
+    public static final int EscapeSequence=23;\r
+    public static final int Integer=27;\r
     public static final int WhiteSpace=56;\r
     public static final int OPERATOR=7;\r
-    public static final int False=30;\r
-    public static final int Colon=46;\r
-    public static final int LineComment=15;\r
-    public static final int NODEVALUE=11;\r
-    public static final int ModuleName=53;\r
-    public static final int SafeFirstLetter=51;\r
-    public static final int Null=31;\r
-    public static final int Star=49;\r
-    public static final int Eq=40;\r
-    public static final int Exp=27;\r
+    public static final int False=32;\r
+    public static final int Colon=48;\r
+    public static final int LineComment=17;\r
+    public static final int NODEVALUE=12;\r
+    public static final int As=49;\r
+    public static final int SafeFirstLetter=54;\r
+    public static final int Null=33;\r
+    public static final int Star=52;\r
+    public static final int Eq=42;\r
+    public static final int Exp=29;\r
     public static final int QNameChar=57;\r
     public static final int RELATION=5;\r
-    public static final int Gt=37;\r
-    public static final int RParen=48;\r
-    public static final int UnicodeChar=20;\r
-    public static final int StringChar=22;\r
-    public static final int True=29;\r
+    public static final int Gt=39;\r
+    public static final int RParen=51;\r
+    public static final int UnicodeChar=22;\r
+    public static final int StringChar=24;\r
+    public static final int True=31;\r
     public static final int OPERAND=8;\r
-    public static final int LineBreak=16;\r
-    public static final int ModuleDef=55;\r
-    public static final int LParen=47;\r
-    public static final int String=24;\r
-    public static final int SafeLetter=52;\r
-    public static final int LineBreakChar=14;\r
+    public static final int LineBreak=18;\r
+    public static final int LParen=50;\r
+    public static final int String=26;\r
+    public static final int SafeLetter=55;\r
+    public static final int LineBreakChar=16;\r
     public static final int COMPARE=6;\r
     public static final int QName=58;\r
-    public static final int Geq=39;\r
+    public static final int Geq=41;\r
     public static final int EOF=-1;\r
     public static final int NODE=10;\r
-    public static final int Neq=41;\r
-    public static final int StringChar_s=23;\r
-    public static final int UnsafeUnicodeChar=50;\r
-    public static final int LBrace=32;\r
-    public static final int Double=28;\r
-    public static final int Lt=36;\r
-    public static final int RBracket=35;\r
-    public static final int NAME=12;\r
-    public static final int Leq=38;\r
-    public static final int WhiteSpaces=54;\r
+    public static final int Neq=43;\r
+    public static final int StringChar_s=25;\r
+    public static final int UnsafeUnicodeChar=53;\r
+    public static final int LBrace=34;\r
+    public static final int Double=30;\r
+    public static final int Lt=38;\r
+    public static final int RBracket=37;\r
+    public static final int NAME=13;\r
+    public static final int Leq=40;\r
+    public static final int WhiteSpaces=59;\r
+\r
 \r
-      \r
 \r
 \r
     // delegates\r
@@ -109,7 +110,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "LineBreakChar"\r
     public final void mLineBreakChar() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:109:23: ( '\\n' | '\\r' )\r
+            // LensQuery.g:116:23: ( '\\n' | '\\r' )\r
             // LensQuery.g:\r
             {\r
             if ( input.LA(1)=='\n'||input.LA(1)=='\r' ) {\r
@@ -135,11 +136,11 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = LineComment;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:110:12: ( '#' (~ ( LineBreakChar ) )* )\r
-            // LensQuery.g:110:14: '#' (~ ( LineBreakChar ) )*\r
+            // LensQuery.g:117:12: ( '#' (~ ( LineBreakChar ) )* )\r
+            // LensQuery.g:117:14: '#' (~ ( LineBreakChar ) )*\r
             {\r
             match('#'); \r
-            // LensQuery.g:110:18: (~ ( LineBreakChar ) )*\r
+            // LensQuery.g:117:18: (~ ( LineBreakChar ) )*\r
             loop1:\r
             do {\r
                 int alt1=2;\r
@@ -152,7 +153,7 @@ public class LensQueryLexer extends Lexer {
 \r
                 switch (alt1) {\r
                case 1 :\r
-                   // LensQuery.g:110:18: ~ ( LineBreakChar )\r
+                   // LensQuery.g:117:18: ~ ( LineBreakChar )\r
                    {\r
                    if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) {\r
                        input.consume();\r
@@ -189,10 +190,10 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = LineBreak;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:113:10: ( ( '\\r' '\\n' | '\\r' | '\\n' ) )\r
-            // LensQuery.g:113:12: ( '\\r' '\\n' | '\\r' | '\\n' )\r
+            // LensQuery.g:120:10: ( ( '\\r' '\\n' | '\\r' | '\\n' ) )\r
+            // LensQuery.g:120:12: ( '\\r' '\\n' | '\\r' | '\\n' )\r
             {\r
-            // LensQuery.g:113:12: ( '\\r' '\\n' | '\\r' | '\\n' )\r
+            // LensQuery.g:120:12: ( '\\r' '\\n' | '\\r' | '\\n' )\r
             int alt2=3;\r
             int LA2_0 = input.LA(1);\r
 \r
@@ -216,7 +217,7 @@ public class LensQueryLexer extends Lexer {
             }\r
             switch (alt2) {\r
                 case 1 :\r
-                    // LensQuery.g:113:13: '\\r' '\\n'\r
+                    // LensQuery.g:120:13: '\\r' '\\n'\r
                     {\r
                     match('\r'); \r
                     match('\n'); \r
@@ -224,14 +225,14 @@ public class LensQueryLexer extends Lexer {
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:113:25: '\\r'\r
+                    // LensQuery.g:120:25: '\\r'\r
                     {\r
                     match('\r'); \r
 \r
                     }\r
                     break;\r
                 case 3 :\r
-                    // LensQuery.g:113:32: '\\n'\r
+                    // LensQuery.g:120:32: '\\n'\r
                     {\r
                     match('\n'); \r
 \r
@@ -255,8 +256,8 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "Digit"\r
     public final void mDigit() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:116:15: ( '0' .. '9' )\r
-            // LensQuery.g:116:17: '0' .. '9'\r
+            // LensQuery.g:123:15: ( '0' .. '9' )\r
+            // LensQuery.g:123:17: '0' .. '9'\r
             {\r
             matchRange('0','9'); \r
 \r
@@ -271,7 +272,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "Letter"\r
     public final void mLetter() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:117:16: ( 'A' .. 'F' | 'a' .. 'f' )\r
+            // LensQuery.g:124:16: ( 'A' .. 'F' | 'a' .. 'f' )\r
             // LensQuery.g:\r
             {\r
             if ( (input.LA(1)>='A' && input.LA(1)<='F')||(input.LA(1)>='a' && input.LA(1)<='f') ) {\r
@@ -295,7 +296,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "HexDigit"\r
     public final void mHexDigit() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:118:18: ( Digit | Letter )\r
+            // LensQuery.g:125:18: ( Digit | Letter )\r
             // LensQuery.g:\r
             {\r
             if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='F')||(input.LA(1)>='a' && input.LA(1)<='f') ) {\r
@@ -319,8 +320,8 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "UnicodeChar"\r
     public final void mUnicodeChar() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:119:21: (~ ( '\"' | '\\\\' ) )\r
-            // LensQuery.g:119:23: ~ ( '\"' | '\\\\' )\r
+            // LensQuery.g:126:21: (~ ( '\"' | '\\\\' ) )\r
+            // LensQuery.g:126:23: ~ ( '\"' | '\\\\' )\r
             {\r
             if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) {\r
                 input.consume();\r
@@ -343,11 +344,11 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "EscapeSequence"\r
     public final void mEscapeSequence() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:121:3: ( '\\\\' ( '\\\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit ) )\r
-            // LensQuery.g:121:5: '\\\\' ( '\\\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit )\r
+            // LensQuery.g:128:3: ( '\\\\' ( '\\\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit ) )\r
+            // LensQuery.g:128:5: '\\\\' ( '\\\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit )\r
             {\r
             match('\\'); \r
-            // LensQuery.g:121:10: ( '\\\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit )\r
+            // LensQuery.g:128:10: ( '\\\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit )\r
             int alt3=9;\r
             switch ( input.LA(1) ) {\r
             case '\"':\r
@@ -404,63 +405,63 @@ public class LensQueryLexer extends Lexer {
 \r
             switch (alt3) {\r
                 case 1 :\r
-                    // LensQuery.g:121:11: '\\\"'\r
+                    // LensQuery.g:128:11: '\\\"'\r
                     {\r
                     match('\"'); \r
 \r
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:121:18: '\\\\'\r
+                    // LensQuery.g:128:18: '\\\\'\r
                     {\r
                     match('\\'); \r
 \r
                     }\r
                     break;\r
                 case 3 :\r
-                    // LensQuery.g:121:25: '/'\r
+                    // LensQuery.g:128:25: '/'\r
                     {\r
                     match('/'); \r
 \r
                     }\r
                     break;\r
                 case 4 :\r
-                    // LensQuery.g:121:31: 'b'\r
+                    // LensQuery.g:128:31: 'b'\r
                     {\r
                     match('b'); \r
 \r
                     }\r
                     break;\r
                 case 5 :\r
-                    // LensQuery.g:121:37: 'f'\r
+                    // LensQuery.g:128:37: 'f'\r
                     {\r
                     match('f'); \r
 \r
                     }\r
                     break;\r
                 case 6 :\r
-                    // LensQuery.g:121:43: 'n'\r
+                    // LensQuery.g:128:43: 'n'\r
                     {\r
                     match('n'); \r
 \r
                     }\r
                     break;\r
                 case 7 :\r
-                    // LensQuery.g:121:49: 'r'\r
+                    // LensQuery.g:128:49: 'r'\r
                     {\r
                     match('r'); \r
 \r
                     }\r
                     break;\r
                 case 8 :\r
-                    // LensQuery.g:121:55: 't'\r
+                    // LensQuery.g:128:55: 't'\r
                     {\r
                     match('t'); \r
 \r
                     }\r
                     break;\r
                 case 9 :\r
-                    // LensQuery.g:121:61: 'u' HexDigit HexDigit HexDigit HexDigit\r
+                    // LensQuery.g:128:61: 'u' HexDigit HexDigit HexDigit HexDigit\r
                     {\r
                     match('u'); \r
                     mHexDigit(); \r
@@ -485,7 +486,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "StringChar"\r
     public final void mStringChar() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:124:21: ( UnicodeChar | EscapeSequence )\r
+            // LensQuery.g:131:21: ( UnicodeChar | EscapeSequence )\r
             int alt4=2;\r
             int LA4_0 = input.LA(1);\r
 \r
@@ -503,14 +504,14 @@ public class LensQueryLexer extends Lexer {
             }\r
             switch (alt4) {\r
                 case 1 :\r
-                    // LensQuery.g:124:24: UnicodeChar\r
+                    // LensQuery.g:131:24: UnicodeChar\r
                     {\r
                     mUnicodeChar(); \r
 \r
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:124:38: EscapeSequence\r
+                    // LensQuery.g:131:38: EscapeSequence\r
                     {\r
                     mEscapeSequence(); \r
 \r
@@ -527,10 +528,10 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "StringChar_s"\r
     public final void mStringChar_s() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:125:22: ( ( StringChar )* )\r
-            // LensQuery.g:125:24: ( StringChar )*\r
+            // LensQuery.g:132:22: ( ( StringChar )* )\r
+            // LensQuery.g:132:24: ( StringChar )*\r
             {\r
-            // LensQuery.g:125:24: ( StringChar )*\r
+            // LensQuery.g:132:24: ( StringChar )*\r
             loop5:\r
             do {\r
                 int alt5=2;\r
@@ -543,7 +544,7 @@ public class LensQueryLexer extends Lexer {
 \r
                 switch (alt5) {\r
                case 1 :\r
-                   // LensQuery.g:125:24: StringChar\r
+                   // LensQuery.g:132:24: StringChar\r
                    {\r
                    mStringChar(); \r
 \r
@@ -571,8 +572,8 @@ public class LensQueryLexer extends Lexer {
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
             Token s=null;\r
 \r
-            // LensQuery.g:127:7: ( '\"' s= StringChar_s '\"' )\r
-            // LensQuery.g:127:9: '\"' s= StringChar_s '\"'\r
+            // LensQuery.g:134:7: ( '\"' s= StringChar_s '\"' )\r
+            // LensQuery.g:134:9: '\"' s= StringChar_s '\"'\r
             {\r
             match('\"'); \r
             int sStart244 = getCharIndex();\r
@@ -596,10 +597,10 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Integer;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:130:8: ( ( '-' )? ( '0' | '1' .. '9' ( Digit )* ) )\r
-            // LensQuery.g:130:10: ( '-' )? ( '0' | '1' .. '9' ( Digit )* )\r
+            // LensQuery.g:137:8: ( ( '-' )? ( '0' | '1' .. '9' ( Digit )* ) )\r
+            // LensQuery.g:137:10: ( '-' )? ( '0' | '1' .. '9' ( Digit )* )\r
             {\r
-            // LensQuery.g:130:10: ( '-' )?\r
+            // LensQuery.g:137:10: ( '-' )?\r
             int alt6=2;\r
             int LA6_0 = input.LA(1);\r
 \r
@@ -608,7 +609,7 @@ public class LensQueryLexer extends Lexer {
             }\r
             switch (alt6) {\r
                 case 1 :\r
-                    // LensQuery.g:130:10: '-'\r
+                    // LensQuery.g:137:10: '-'\r
                     {\r
                     match('-'); \r
 \r
@@ -617,7 +618,7 @@ public class LensQueryLexer extends Lexer {
 \r
             }\r
 \r
-            // LensQuery.g:130:15: ( '0' | '1' .. '9' ( Digit )* )\r
+            // LensQuery.g:137:15: ( '0' | '1' .. '9' ( Digit )* )\r
             int alt8=2;\r
             int LA8_0 = input.LA(1);\r
 \r
@@ -635,17 +636,17 @@ public class LensQueryLexer extends Lexer {
             }\r
             switch (alt8) {\r
                 case 1 :\r
-                    // LensQuery.g:130:16: '0'\r
+                    // LensQuery.g:137:16: '0'\r
                     {\r
                     match('0'); \r
 \r
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:130:22: '1' .. '9' ( Digit )*\r
+                    // LensQuery.g:137:22: '1' .. '9' ( Digit )*\r
                     {\r
                     matchRange('1','9'); \r
-                    // LensQuery.g:130:31: ( Digit )*\r
+                    // LensQuery.g:137:31: ( Digit )*\r
                     loop7:\r
                     do {\r
                         int alt7=2;\r
@@ -658,7 +659,7 @@ public class LensQueryLexer extends Lexer {
 \r
                         switch (alt7) {\r
                        case 1 :\r
-                           // LensQuery.g:130:31: Digit\r
+                           // LensQuery.g:137:31: Digit\r
                            {\r
                            mDigit(); \r
 \r
@@ -690,11 +691,11 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "Frac"\r
     public final void mFrac() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:131:14: ( '.' ( Digit )+ )\r
-            // LensQuery.g:131:16: '.' ( Digit )+\r
+            // LensQuery.g:138:14: ( '.' ( Digit )+ )\r
+            // LensQuery.g:138:16: '.' ( Digit )+\r
             {\r
             match('.'); \r
-            // LensQuery.g:131:20: ( Digit )+\r
+            // LensQuery.g:138:20: ( Digit )+\r
             int cnt9=0;\r
             loop9:\r
             do {\r
@@ -708,7 +709,7 @@ public class LensQueryLexer extends Lexer {
 \r
                 switch (alt9) {\r
                case 1 :\r
-                   // LensQuery.g:131:20: Digit\r
+                   // LensQuery.g:138:20: Digit\r
                    {\r
                    mDigit(); \r
 \r
@@ -736,8 +737,8 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "Exp"\r
     public final void mExp() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:132:13: ( ( 'e' | 'E' ) ( '+' | '-' )? ( Digit )+ )\r
-            // LensQuery.g:132:15: ( 'e' | 'E' ) ( '+' | '-' )? ( Digit )+\r
+            // LensQuery.g:139:13: ( ( 'e' | 'E' ) ( '+' | '-' )? ( Digit )+ )\r
+            // LensQuery.g:139:15: ( 'e' | 'E' ) ( '+' | '-' )? ( Digit )+\r
             {\r
             if ( input.LA(1)=='E'||input.LA(1)=='e' ) {\r
                 input.consume();\r
@@ -748,7 +749,7 @@ public class LensQueryLexer extends Lexer {
                 recover(mse);\r
                 throw mse;}\r
 \r
-            // LensQuery.g:132:27: ( '+' | '-' )?\r
+            // LensQuery.g:139:27: ( '+' | '-' )?\r
             int alt10=2;\r
             int LA10_0 = input.LA(1);\r
 \r
@@ -774,7 +775,7 @@ public class LensQueryLexer extends Lexer {
 \r
             }\r
 \r
-            // LensQuery.g:132:40: ( Digit )+\r
+            // LensQuery.g:139:40: ( Digit )+\r
             int cnt11=0;\r
             loop11:\r
             do {\r
@@ -788,7 +789,7 @@ public class LensQueryLexer extends Lexer {
 \r
                 switch (alt11) {\r
                case 1 :\r
-                   // LensQuery.g:132:40: Digit\r
+                   // LensQuery.g:139:40: Digit\r
                    {\r
                    mDigit(); \r
 \r
@@ -818,11 +819,11 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Double;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:133:7: ( Integer ( Frac ( Exp )? | Exp ) )\r
-            // LensQuery.g:133:9: Integer ( Frac ( Exp )? | Exp )\r
+            // LensQuery.g:140:7: ( Integer ( Frac ( Exp )? | Exp ) )\r
+            // LensQuery.g:140:9: Integer ( Frac ( Exp )? | Exp )\r
             {\r
             mInteger(); \r
-            // LensQuery.g:133:17: ( Frac ( Exp )? | Exp )\r
+            // LensQuery.g:140:17: ( Frac ( Exp )? | Exp )\r
             int alt13=2;\r
             int LA13_0 = input.LA(1);\r
 \r
@@ -840,10 +841,10 @@ public class LensQueryLexer extends Lexer {
             }\r
             switch (alt13) {\r
                 case 1 :\r
-                    // LensQuery.g:133:18: Frac ( Exp )?\r
+                    // LensQuery.g:140:18: Frac ( Exp )?\r
                     {\r
                     mFrac(); \r
-                    // LensQuery.g:133:23: ( Exp )?\r
+                    // LensQuery.g:140:23: ( Exp )?\r
                     int alt12=2;\r
                     int LA12_0 = input.LA(1);\r
 \r
@@ -852,7 +853,7 @@ public class LensQueryLexer extends Lexer {
                     }\r
                     switch (alt12) {\r
                         case 1 :\r
-                            // LensQuery.g:133:23: Exp\r
+                            // LensQuery.g:140:23: Exp\r
                             {\r
                             mExp(); \r
 \r
@@ -865,7 +866,7 @@ public class LensQueryLexer extends Lexer {
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:133:30: Exp\r
+                    // LensQuery.g:140:30: Exp\r
                     {\r
                     mExp(); \r
 \r
@@ -890,8 +891,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = True;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:135:5: ( 'true' )\r
-            // LensQuery.g:135:7: 'true'\r
+            // LensQuery.g:142:5: ( 'true' )\r
+            // LensQuery.g:142:7: 'true'\r
             {\r
             match("true"); \r
 \r
@@ -911,8 +912,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = False;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:136:6: ( 'false' )\r
-            // LensQuery.g:136:8: 'false'\r
+            // LensQuery.g:143:6: ( 'false' )\r
+            // LensQuery.g:143:8: 'false'\r
             {\r
             match("false"); \r
 \r
@@ -932,8 +933,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Null;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:137:5: ( 'null' )\r
-            // LensQuery.g:137:7: 'null'\r
+            // LensQuery.g:144:5: ( 'null' )\r
+            // LensQuery.g:144:7: 'null'\r
             {\r
             match("null"); \r
 \r
@@ -953,8 +954,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = LBrace;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:139:7: ( '{' )\r
-            // LensQuery.g:139:9: '{'\r
+            // LensQuery.g:146:7: ( '{' )\r
+            // LensQuery.g:146:9: '{'\r
             {\r
             match('{'); \r
 \r
@@ -973,8 +974,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = RBrace;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:140:7: ( '}' )\r
-            // LensQuery.g:140:9: '}'\r
+            // LensQuery.g:147:7: ( '}' )\r
+            // LensQuery.g:147:9: '}'\r
             {\r
             match('}'); \r
 \r
@@ -993,8 +994,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = LBracket;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:141:9: ( '[' )\r
-            // LensQuery.g:141:11: '['\r
+            // LensQuery.g:148:9: ( '[' )\r
+            // LensQuery.g:148:11: '['\r
             {\r
             match('['); \r
 \r
@@ -1013,8 +1014,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = RBracket;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:142:9: ( ']' )\r
-            // LensQuery.g:142:11: ']'\r
+            // LensQuery.g:149:9: ( ']' )\r
+            // LensQuery.g:149:11: ']'\r
             {\r
             match(']'); \r
 \r
@@ -1033,8 +1034,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Lt;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:145:3: ( '<' )\r
-            // LensQuery.g:145:5: '<'\r
+            // LensQuery.g:152:3: ( '<' )\r
+            // LensQuery.g:152:5: '<'\r
             {\r
             match('<'); \r
 \r
@@ -1053,8 +1054,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Gt;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:146:3: ( '>' )\r
-            // LensQuery.g:146:5: '>'\r
+            // LensQuery.g:153:3: ( '>' )\r
+            // LensQuery.g:153:5: '>'\r
             {\r
             match('>'); \r
 \r
@@ -1073,8 +1074,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Leq;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:147:4: ( '<=' )\r
-            // LensQuery.g:147:6: '<='\r
+            // LensQuery.g:154:4: ( '<=' )\r
+            // LensQuery.g:154:6: '<='\r
             {\r
             match("<="); \r
 \r
@@ -1094,8 +1095,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Geq;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:148:4: ( '>=' )\r
-            // LensQuery.g:148:6: '>='\r
+            // LensQuery.g:155:4: ( '>=' )\r
+            // LensQuery.g:155:6: '>='\r
             {\r
             match(">="); \r
 \r
@@ -1115,8 +1116,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Eq;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:149:3: ( '=' )\r
-            // LensQuery.g:149:5: '='\r
+            // LensQuery.g:156:3: ( '=' )\r
+            // LensQuery.g:156:5: '='\r
             {\r
             match('='); \r
 \r
@@ -1135,8 +1136,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Neq;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:150:4: ( '!=' )\r
-            // LensQuery.g:150:6: '!='\r
+            // LensQuery.g:157:4: ( '!=' )\r
+            // LensQuery.g:157:6: '!='\r
             {\r
             match("!="); \r
 \r
@@ -1156,8 +1157,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Match;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:151:6: ( '~=' )\r
-            // LensQuery.g:151:8: '~='\r
+            // LensQuery.g:158:6: ( '~=' )\r
+            // LensQuery.g:158:8: '~='\r
             {\r
             match("~="); \r
 \r
@@ -1177,11 +1178,11 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Regex;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:152:6: ( '/' ( options {greedy=false; } : . )* '/' ( 'a' .. 'z' | 'A' .. 'Z' )* )\r
-            // LensQuery.g:152:8: '/' ( options {greedy=false; } : . )* '/' ( 'a' .. 'z' | 'A' .. 'Z' )*\r
+            // LensQuery.g:159:6: ( '/' ( options {greedy=false; } : . )* '/' ( 'a' .. 'z' | 'A' .. 'Z' )* )\r
+            // LensQuery.g:159:8: '/' ( options {greedy=false; } : . )* '/' ( 'a' .. 'z' | 'A' .. 'Z' )*\r
             {\r
             match('/'); \r
-            // LensQuery.g:152:13: ( options {greedy=false; } : . )*\r
+            // LensQuery.g:159:13: ( options {greedy=false; } : . )*\r
             loop14:\r
             do {\r
                 int alt14=2;\r
@@ -1197,7 +1198,7 @@ public class LensQueryLexer extends Lexer {
 \r
                 switch (alt14) {\r
                case 1 :\r
-                   // LensQuery.g:152:38: .\r
+                   // LensQuery.g:159:38: .\r
                    {\r
                    matchAny(); \r
 \r
@@ -1210,7 +1211,7 @@ public class LensQueryLexer extends Lexer {
             } while (true);\r
 \r
             match('/'); \r
-            // LensQuery.g:152:46: ( 'a' .. 'z' | 'A' .. 'Z' )*\r
+            // LensQuery.g:159:46: ( 'a' .. 'z' | 'A' .. 'Z' )*\r
             loop15:\r
             do {\r
                 int alt15=2;\r
@@ -1259,8 +1260,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Dot;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:154:4: ( '.' )\r
-            // LensQuery.g:154:6: '.'\r
+            // LensQuery.g:161:4: ( '.' )\r
+            // LensQuery.g:161:6: '.'\r
             {\r
             match('.'); \r
 \r
@@ -1279,8 +1280,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Comma;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:155:6: ( ',' )\r
-            // LensQuery.g:155:8: ','\r
+            // LensQuery.g:162:6: ( ',' )\r
+            // LensQuery.g:162:8: ','\r
             {\r
             match(','); \r
 \r
@@ -1299,8 +1300,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Colon;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:156:6: ( ':' )\r
-            // LensQuery.g:156:8: ':'\r
+            // LensQuery.g:163:6: ( ':' )\r
+            // LensQuery.g:163:8: ':'\r
             {\r
             match(':'); \r
 \r
@@ -1314,13 +1315,34 @@ public class LensQueryLexer extends Lexer {
     }\r
     // $ANTLR end "Colon"\r
 \r
+    // $ANTLR start "As"\r
+    public final void mAs() throws RecognitionException {\r
+        try {\r
+            int _type = As;\r
+            int _channel = DEFAULT_TOKEN_CHANNEL;\r
+            // LensQuery.g:165:3: ( 'as' )\r
+            // LensQuery.g:165:5: 'as'\r
+            {\r
+            match("as"); \r
+\r
+\r
+            }\r
+\r
+            state.type = _type;\r
+            state.channel = _channel;\r
+        }\r
+        finally {\r
+        }\r
+    }\r
+    // $ANTLR end "As"\r
+\r
     // $ANTLR start "LParen"\r
     public final void mLParen() throws RecognitionException {\r
         try {\r
             int _type = LParen;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:158:7: ( '(' )\r
-            // LensQuery.g:158:9: '('\r
+            // LensQuery.g:167:7: ( '(' )\r
+            // LensQuery.g:167:9: '('\r
             {\r
             match('('); \r
 \r
@@ -1339,8 +1361,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = RParen;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:159:7: ( ')' )\r
-            // LensQuery.g:159:9: ')'\r
+            // LensQuery.g:168:7: ( ')' )\r
+            // LensQuery.g:168:9: ')'\r
             {\r
             match(')'); \r
 \r
@@ -1359,8 +1381,8 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = Star;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:161:5: ( '*' )\r
-            // LensQuery.g:161:7: '*'\r
+            // LensQuery.g:170:5: ( '*' )\r
+            // LensQuery.g:170:7: '*'\r
             {\r
             match('*'); \r
 \r
@@ -1377,7 +1399,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "UnsafeUnicodeChar"\r
     public final void mUnsafeUnicodeChar() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:164:18: ( '(' | ')' | '[' | ']' | '{' | '}' | ',' | ':' | '#' | '<' | '>' | '|' | '*' | '\\'' | '\"' | '@' | '%' | '\\\\' | '.' | '-' )\r
+            // LensQuery.g:173:18: ( '(' | ')' | '[' | ']' | '{' | '}' | ',' | ':' | '#' | '<' | '>' | '|' | '*' | '\\'' | '\"' | '@' | '%' | '\\\\' | '.' | '-' )\r
             // LensQuery.g:\r
             {\r
             if ( (input.LA(1)>='\"' && input.LA(1)<='#')||input.LA(1)=='%'||(input.LA(1)>='\'' && input.LA(1)<='*')||(input.LA(1)>=',' && input.LA(1)<='.')||input.LA(1)==':'||input.LA(1)=='<'||input.LA(1)=='>'||input.LA(1)=='@'||(input.LA(1)>='[' && input.LA(1)<=']')||(input.LA(1)>='{' && input.LA(1)<='}') ) {\r
@@ -1401,7 +1423,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "SafeFirstLetter"\r
     public final void mSafeFirstLetter() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:167:25: ( 'A' .. 'Z' | 'a' .. 'z' )\r
+            // LensQuery.g:175:25: ( 'A' .. 'Z' | 'a' .. 'z' )\r
             // LensQuery.g:\r
             {\r
             if ( (input.LA(1)>='A' && input.LA(1)<='Z')||(input.LA(1)>='a' && input.LA(1)<='z') ) {\r
@@ -1425,7 +1447,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "SafeLetter"\r
     public final void mSafeLetter() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:168:20: ( SafeFirstLetter | '0' .. '9' | '-' | '_' )\r
+            // LensQuery.g:176:20: ( SafeFirstLetter | '0' .. '9' | '-' | '_' )\r
             // LensQuery.g:\r
             {\r
             if ( input.LA(1)=='-'||(input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) {\r
@@ -1446,131 +1468,11 @@ public class LensQueryLexer extends Lexer {
     }\r
     // $ANTLR end "SafeLetter"\r
 \r
-    // $ANTLR start "ModuleName"\r
-    public final void mModuleName() throws RecognitionException {\r
-        try {\r
-            // LensQuery.g:170:20: ( SafeFirstLetter ( SafeLetter )* ( '.' SafeFirstLetter ( SafeLetter )* )* )\r
-            // LensQuery.g:170:22: SafeFirstLetter ( SafeLetter )* ( '.' SafeFirstLetter ( SafeLetter )* )*\r
-            {\r
-            mSafeFirstLetter(); \r
-            // LensQuery.g:170:38: ( SafeLetter )*\r
-            loop16:\r
-            do {\r
-                int alt16=2;\r
-                int LA16_0 = input.LA(1);\r
-\r
-                if ( (LA16_0=='-'||(LA16_0>='0' && LA16_0<='9')||(LA16_0>='A' && LA16_0<='Z')||LA16_0=='_'||(LA16_0>='a' && LA16_0<='z')) ) {\r
-                    alt16=1;\r
-                }\r
-\r
-\r
-                switch (alt16) {\r
-               case 1 :\r
-                   // LensQuery.g:170:38: SafeLetter\r
-                   {\r
-                   mSafeLetter(); \r
-\r
-                   }\r
-                   break;\r
-\r
-               default :\r
-                   break loop16;\r
-                }\r
-            } while (true);\r
-\r
-            // LensQuery.g:170:50: ( '.' SafeFirstLetter ( SafeLetter )* )*\r
-            loop18:\r
-            do {\r
-                int alt18=2;\r
-                int LA18_0 = input.LA(1);\r
-\r
-                if ( (LA18_0=='.') ) {\r
-                    alt18=1;\r
-                }\r
-\r
-\r
-                switch (alt18) {\r
-               case 1 :\r
-                   // LensQuery.g:170:51: '.' SafeFirstLetter ( SafeLetter )*\r
-                   {\r
-                   match('.'); \r
-                   mSafeFirstLetter(); \r
-                   // LensQuery.g:170:71: ( SafeLetter )*\r
-                   loop17:\r
-                   do {\r
-                       int alt17=2;\r
-                       int LA17_0 = input.LA(1);\r
-\r
-                       if ( (LA17_0=='-'||(LA17_0>='0' && LA17_0<='9')||(LA17_0>='A' && LA17_0<='Z')||LA17_0=='_'||(LA17_0>='a' && LA17_0<='z')) ) {\r
-                           alt17=1;\r
-                       }\r
-\r
-\r
-                       switch (alt17) {\r
-                       case 1 :\r
-                           // LensQuery.g:170:71: SafeLetter\r
-                           {\r
-                           mSafeLetter(); \r
-\r
-                           }\r
-                           break;\r
-\r
-                       default :\r
-                           break loop17;\r
-                       }\r
-                   } while (true);\r
-\r
-\r
-                   }\r
-                   break;\r
-\r
-               default :\r
-                   break loop18;\r
-                }\r
-            } while (true);\r
-\r
-\r
-            }\r
-\r
-        }\r
-        finally {\r
-        }\r
-    }\r
-    // $ANTLR end "ModuleName"\r
-\r
-    // $ANTLR start "ModuleDef"\r
-    public final void mModuleDef() throws RecognitionException {\r
-        try {\r
-            int _type = ModuleDef;\r
-            int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            Token s=null;\r
-\r
-            // LensQuery.g:171:10: ( 'module' WhiteSpaces s= ModuleName )\r
-            // LensQuery.g:171:12: 'module' WhiteSpaces s= ModuleName\r
-            {\r
-            match("module"); \r
-\r
-            mWhiteSpaces(); \r
-            int sStart694 = getCharIndex();\r
-            mModuleName(); \r
-            s = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, sStart694, getCharIndex()-1);\r
-             setText((s!=null?s.getText():null)); \r
-\r
-            }\r
-\r
-            state.type = _type;\r
-            state.channel = _channel;\r
-        }\r
-        finally {\r
-        }\r
-    }\r
-    // $ANTLR end "ModuleDef"\r
-\r
     // $ANTLR start "QNameChar"\r
     public final void mQNameChar() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:173:19: (~ ( LineBreakChar | UnsafeUnicodeChar | WhiteSpace ) )\r
-            // LensQuery.g:173:21: ~ ( LineBreakChar | UnsafeUnicodeChar | WhiteSpace )\r
+            // LensQuery.g:179:19: (~ ( LineBreakChar | UnsafeUnicodeChar | WhiteSpace ) )\r
+            // LensQuery.g:179:21: ~ ( LineBreakChar | UnsafeUnicodeChar | WhiteSpace )\r
             {\r
             if ( (input.LA(1)>='\u0000' && input.LA(1)<='\b')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\u001F')||input.LA(1)=='!'||input.LA(1)=='$'||input.LA(1)=='&'||input.LA(1)=='+'||(input.LA(1)>='/' && input.LA(1)<='9')||input.LA(1)==';'||input.LA(1)=='='||input.LA(1)=='?'||(input.LA(1)>='A' && input.LA(1)<='Z')||(input.LA(1)>='^' && input.LA(1)<='z')||(input.LA(1)>='~' && input.LA(1)<='\uFFFF') ) {\r
                 input.consume();\r
@@ -1595,24 +1497,24 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = QName;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:174:6: ( ( QNameChar )+ ( Dot ( QNameChar )+ )* )\r
-            // LensQuery.g:174:8: ( QNameChar )+ ( Dot ( QNameChar )+ )*\r
+            // LensQuery.g:180:6: ( ( QNameChar )+ ( Dot ( QNameChar )+ )* )\r
+            // LensQuery.g:180:8: ( QNameChar )+ ( Dot ( QNameChar )+ )*\r
             {\r
-            // LensQuery.g:174:8: ( QNameChar )+\r
-            int cnt19=0;\r
-            loop19:\r
+            // LensQuery.g:180:8: ( QNameChar )+\r
+            int cnt16=0;\r
+            loop16:\r
             do {\r
-                int alt19=2;\r
-                int LA19_0 = input.LA(1);\r
+                int alt16=2;\r
+                int LA16_0 = input.LA(1);\r
 \r
-                if ( ((LA19_0>='\u0000' && LA19_0<='\b')||(LA19_0>='\u000B' && LA19_0<='\f')||(LA19_0>='\u000E' && LA19_0<='\u001F')||LA19_0=='!'||LA19_0=='$'||LA19_0=='&'||LA19_0=='+'||(LA19_0>='/' && LA19_0<='9')||LA19_0==';'||LA19_0=='='||LA19_0=='?'||(LA19_0>='A' && LA19_0<='Z')||(LA19_0>='^' && LA19_0<='z')||(LA19_0>='~' && LA19_0<='\uFFFF')) ) {\r
-                    alt19=1;\r
+                if ( ((LA16_0>='\u0000' && LA16_0<='\b')||(LA16_0>='\u000B' && LA16_0<='\f')||(LA16_0>='\u000E' && LA16_0<='\u001F')||LA16_0=='!'||LA16_0=='$'||LA16_0=='&'||LA16_0=='+'||(LA16_0>='/' && LA16_0<='9')||LA16_0==';'||LA16_0=='='||LA16_0=='?'||(LA16_0>='A' && LA16_0<='Z')||(LA16_0>='^' && LA16_0<='z')||(LA16_0>='~' && LA16_0<='\uFFFF')) ) {\r
+                    alt16=1;\r
                 }\r
 \r
 \r
-                switch (alt19) {\r
+                switch (alt16) {\r
                case 1 :\r
-                   // LensQuery.g:174:8: QNameChar\r
+                   // LensQuery.g:180:8: QNameChar\r
                    {\r
                    mQNameChar(); \r
 \r
@@ -1620,45 +1522,45 @@ public class LensQueryLexer extends Lexer {
                    break;\r
 \r
                default :\r
-                   if ( cnt19 >= 1 ) break loop19;\r
+                   if ( cnt16 >= 1 ) break loop16;\r
                         EarlyExitException eee =\r
-                            new EarlyExitException(19, input);\r
+                            new EarlyExitException(16, input);\r
                         throw eee;\r
                 }\r
-                cnt19++;\r
+                cnt16++;\r
             } while (true);\r
 \r
-            // LensQuery.g:174:19: ( Dot ( QNameChar )+ )*\r
-            loop21:\r
+            // LensQuery.g:180:19: ( Dot ( QNameChar )+ )*\r
+            loop18:\r
             do {\r
-                int alt21=2;\r
-                int LA21_0 = input.LA(1);\r
+                int alt18=2;\r
+                int LA18_0 = input.LA(1);\r
 \r
-                if ( (LA21_0=='.') ) {\r
-                    alt21=1;\r
+                if ( (LA18_0=='.') ) {\r
+                    alt18=1;\r
                 }\r
 \r
 \r
-                switch (alt21) {\r
+                switch (alt18) {\r
                case 1 :\r
-                   // LensQuery.g:174:20: Dot ( QNameChar )+\r
+                   // LensQuery.g:180:20: Dot ( QNameChar )+\r
                    {\r
                    mDot(); \r
-                   // LensQuery.g:174:24: ( QNameChar )+\r
-                   int cnt20=0;\r
-                   loop20:\r
+                   // LensQuery.g:180:24: ( QNameChar )+\r
+                   int cnt17=0;\r
+                   loop17:\r
                    do {\r
-                       int alt20=2;\r
-                       int LA20_0 = input.LA(1);\r
+                       int alt17=2;\r
+                       int LA17_0 = input.LA(1);\r
 \r
-                       if ( ((LA20_0>='\u0000' && LA20_0<='\b')||(LA20_0>='\u000B' && LA20_0<='\f')||(LA20_0>='\u000E' && LA20_0<='\u001F')||LA20_0=='!'||LA20_0=='$'||LA20_0=='&'||LA20_0=='+'||(LA20_0>='/' && LA20_0<='9')||LA20_0==';'||LA20_0=='='||LA20_0=='?'||(LA20_0>='A' && LA20_0<='Z')||(LA20_0>='^' && LA20_0<='z')||(LA20_0>='~' && LA20_0<='\uFFFF')) ) {\r
-                           alt20=1;\r
+                       if ( ((LA17_0>='\u0000' && LA17_0<='\b')||(LA17_0>='\u000B' && LA17_0<='\f')||(LA17_0>='\u000E' && LA17_0<='\u001F')||LA17_0=='!'||LA17_0=='$'||LA17_0=='&'||LA17_0=='+'||(LA17_0>='/' && LA17_0<='9')||LA17_0==';'||LA17_0=='='||LA17_0=='?'||(LA17_0>='A' && LA17_0<='Z')||(LA17_0>='^' && LA17_0<='z')||(LA17_0>='~' && LA17_0<='\uFFFF')) ) {\r
+                           alt17=1;\r
                        }\r
 \r
 \r
-                       switch (alt20) {\r
+                       switch (alt17) {\r
                        case 1 :\r
-                           // LensQuery.g:174:24: QNameChar\r
+                           // LensQuery.g:180:24: QNameChar\r
                            {\r
                            mQNameChar(); \r
 \r
@@ -1666,12 +1568,12 @@ public class LensQueryLexer extends Lexer {
                            break;\r
 \r
                        default :\r
-                           if ( cnt20 >= 1 ) break loop20;\r
+                           if ( cnt17 >= 1 ) break loop17;\r
                                EarlyExitException eee =\r
-                                   new EarlyExitException(20, input);\r
+                                   new EarlyExitException(17, input);\r
                                throw eee;\r
                        }\r
-                       cnt20++;\r
+                       cnt17++;\r
                    } while (true);\r
 \r
 \r
@@ -1679,7 +1581,7 @@ public class LensQueryLexer extends Lexer {
                    break;\r
 \r
                default :\r
-                   break loop21;\r
+                   break loop18;\r
                 }\r
             } while (true);\r
 \r
@@ -1697,7 +1599,7 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR start "WhiteSpace"\r
     public final void mWhiteSpace() throws RecognitionException {\r
         try {\r
-            // LensQuery.g:177:11: ( ' ' | '\\t' )\r
+            // LensQuery.g:184:11: ( ' ' | '\\t' )\r
             // LensQuery.g:\r
             {\r
             if ( input.LA(1)=='\t'||input.LA(1)==' ' ) {\r
@@ -1723,24 +1625,24 @@ public class LensQueryLexer extends Lexer {
         try {\r
             int _type = WhiteSpaces;\r
             int _channel = DEFAULT_TOKEN_CHANNEL;\r
-            // LensQuery.g:179:12: ( ( WhiteSpace )+ )\r
-            // LensQuery.g:179:14: ( WhiteSpace )+\r
+            // LensQuery.g:186:12: ( ( WhiteSpace )+ )\r
+            // LensQuery.g:186:14: ( WhiteSpace )+\r
             {\r
-            // LensQuery.g:179:14: ( WhiteSpace )+\r
-            int cnt22=0;\r
-            loop22:\r
+            // LensQuery.g:186:14: ( WhiteSpace )+\r
+            int cnt19=0;\r
+            loop19:\r
             do {\r
-                int alt22=2;\r
-                int LA22_0 = input.LA(1);\r
+                int alt19=2;\r
+                int LA19_0 = input.LA(1);\r
 \r
-                if ( (LA22_0=='\t'||LA22_0==' ') ) {\r
-                    alt22=1;\r
+                if ( (LA19_0=='\t'||LA19_0==' ') ) {\r
+                    alt19=1;\r
                 }\r
 \r
 \r
-                switch (alt22) {\r
+                switch (alt19) {\r
                case 1 :\r
-                   // LensQuery.g:179:14: WhiteSpace\r
+                   // LensQuery.g:186:14: WhiteSpace\r
                    {\r
                    mWhiteSpace(); \r
 \r
@@ -1748,12 +1650,12 @@ public class LensQueryLexer extends Lexer {
                    break;\r
 \r
                default :\r
-                   if ( cnt22 >= 1 ) break loop22;\r
+                   if ( cnt19 >= 1 ) break loop19;\r
                         EarlyExitException eee =\r
-                            new EarlyExitException(22, input);\r
+                            new EarlyExitException(19, input);\r
                         throw eee;\r
                 }\r
-                cnt22++;\r
+                cnt19++;\r
             } while (true);\r
 \r
              _channel = HIDDEN; \r
@@ -1769,10 +1671,10 @@ public class LensQueryLexer extends Lexer {
     // $ANTLR end "WhiteSpaces"\r
 \r
     public void mTokens() throws RecognitionException {\r
-        // LensQuery.g:1:8: ( LineComment | LineBreak | String | Integer | Double | True | False | Null | LBrace | RBrace | LBracket | RBracket | Lt | Gt | Leq | Geq | Eq | Neq | Match | Regex | Dot | Comma | Colon | LParen | RParen | Star | ModuleDef | QName | WhiteSpaces )\r
-        int alt23=29;\r
-        alt23 = dfa23.predict(input);\r
-        switch (alt23) {\r
+        // LensQuery.g:1:8: ( LineComment | LineBreak | String | Integer | Double | True | False | Null | LBrace | RBrace | LBracket | RBracket | Lt | Gt | Leq | Geq | Eq | Neq | Match | Regex | Dot | Comma | Colon | As | LParen | RParen | Star | QName | WhiteSpaces )\r
+        int alt20=29;\r
+        alt20 = dfa20.predict(input);\r
+        switch (alt20) {\r
             case 1 :\r
                 // LensQuery.g:1:10: LineComment\r
                 {\r
@@ -1935,42 +1837,42 @@ public class LensQueryLexer extends Lexer {
                 }\r
                 break;\r
             case 24 :\r
-                // LensQuery.g:1:151: LParen\r
+                // LensQuery.g:1:151: As\r
                 {\r
-                mLParen(); \r
+                mAs(); \r
 \r
                 }\r
                 break;\r
             case 25 :\r
-                // LensQuery.g:1:158: RParen\r
+                // LensQuery.g:1:154: LParen\r
                 {\r
-                mRParen(); \r
+                mLParen(); \r
 \r
                 }\r
                 break;\r
             case 26 :\r
-                // LensQuery.g:1:165: Star\r
+                // LensQuery.g:1:161: RParen\r
                 {\r
-                mStar(); \r
+                mRParen(); \r
 \r
                 }\r
                 break;\r
             case 27 :\r
-                // LensQuery.g:1:170: ModuleDef\r
+                // LensQuery.g:1:168: Star\r
                 {\r
-                mModuleDef(); \r
+                mStar(); \r
 \r
                 }\r
                 break;\r
             case 28 :\r
-                // LensQuery.g:1:180: QName\r
+                // LensQuery.g:1:173: QName\r
                 {\r
                 mQName(); \r
 \r
                 }\r
                 break;\r
             case 29 :\r
-                // LensQuery.g:1:186: WhiteSpaces\r
+                // LensQuery.g:1:179: WhiteSpaces\r
                 {\r
                 mWhiteSpaces(); \r
 \r
@@ -1982,44 +1884,43 @@ public class LensQueryLexer extends Lexer {
     }\r
 \r
 \r
-    protected DFA23 dfa23 = new DFA23(this);\r
-    static final String DFA23_eotS =\r
-        "\5\uffff\2\37\3\33\4\uffff\1\47\1\51\1\52\3\33\6\uffff\1\33\2\uffff"+\r
+    protected DFA20 dfa20 = new DFA20(this);\r
+    static final String DFA20_eotS =\r
+        "\5\uffff\2\37\3\33\4\uffff\1\47\1\51\1\52\3\33\3\uffff\1\33\5\uffff"+\r
         "\2\37\2\uffff\1\33\1\37\3\33\5\uffff\1\72\1\73\1\uffff\1\57\1\uffff"+\r
-        "\2\33\1\uffff\1\37\1\62\1\33\1\62\3\33\2\uffff\1\57\1\33\1\57\2"+\r
-        "\33\1\110\1\33\1\112\1\57\2\33\1\62\1\uffff\1\114\1\uffff\1\33\1"+\r
-        "\uffff\1\33\1\uffff";\r
-    static final String DFA23_eofS =\r
-        "\117\uffff";\r
-    static final String DFA23_minS =\r
+        "\1\33\1\77\1\uffff\1\37\1\62\1\33\1\62\3\33\2\uffff\1\57\1\33\1"+\r
+        "\57\1\uffff\1\33\1\107\1\33\1\111\1\57\1\33\1\62\1\uffff\1\112\2"+\r
+        "\uffff";\r
+    static final String DFA20_eofS =\r
+        "\113\uffff";\r
+    static final String DFA20_minS =\r
         "\1\0\3\uffff\1\60\2\0\1\162\1\141\1\165\4\uffff\2\75\1\0\2\75\1"+\r
-        "\0\6\uffff\1\157\2\uffff\2\56\1\uffff\1\0\1\53\1\0\1\165\2\154\5"+\r
-        "\uffff\4\0\1\uffff\1\0\1\144\1\uffff\1\56\1\0\1\60\1\0\1\145\1\163"+\r
-        "\1\154\2\uffff\3\0\1\165\1\53\1\0\1\145\2\0\1\154\1\60\1\0\1\uffff"+\r
-        "\1\0\1\uffff\1\145\1\uffff\1\11\1\uffff";\r
-    static final String DFA23_maxS =\r
+        "\0\3\uffff\1\163\5\uffff\2\56\1\uffff\1\0\1\53\1\0\1\165\2\154\5"+\r
+        "\uffff\4\0\1\uffff\2\0\1\uffff\1\56\1\0\1\60\1\0\1\145\1\163\1\154"+\r
+        "\2\uffff\3\0\1\uffff\1\53\1\0\1\145\2\0\1\60\1\0\1\uffff\1\0\2\uffff";\r
+    static final String DFA20_maxS =\r
         "\1\uffff\3\uffff\1\71\2\uffff\1\162\1\141\1\165\4\uffff\2\75\1"+\r
-        "\uffff\2\75\1\uffff\6\uffff\1\157\2\uffff\2\145\1\uffff\1\uffff"+\r
-        "\1\71\1\uffff\1\165\2\154\5\uffff\4\uffff\1\uffff\1\uffff\1\144"+\r
-        "\1\uffff\1\145\1\uffff\1\71\1\uffff\1\145\1\163\1\154\2\uffff\3"+\r
-        "\uffff\1\165\1\71\1\uffff\1\145\2\uffff\1\154\1\71\1\uffff\1\uffff"+\r
-        "\1\uffff\1\uffff\1\145\1\uffff\1\40\1\uffff";\r
-    static final String DFA23_acceptS =\r
+        "\uffff\2\75\1\uffff\3\uffff\1\163\5\uffff\2\145\1\uffff\1\uffff"+\r
+        "\1\71\1\uffff\1\165\2\154\5\uffff\4\uffff\1\uffff\2\uffff\1\uffff"+\r
+        "\1\145\1\uffff\1\71\1\uffff\1\145\1\163\1\154\2\uffff\3\uffff\1"+\r
+        "\uffff\1\71\1\uffff\1\145\2\uffff\1\71\1\uffff\1\uffff\1\uffff\2"+\r
+        "\uffff";\r
+    static final String DFA20_acceptS =\r
         "\1\uffff\1\1\1\2\1\3\6\uffff\1\11\1\12\1\13\1\14\6\uffff\1\25\1"+\r
-        "\26\1\27\1\30\1\31\1\32\1\uffff\1\34\1\35\2\uffff\1\4\6\uffff\1"+\r
+        "\26\1\27\1\uffff\1\31\1\32\1\33\1\34\1\35\2\uffff\1\4\6\uffff\1"+\r
         "\17\1\15\1\20\1\16\1\21\4\uffff\1\24\2\uffff\1\5\7\uffff\1\22\1"+\r
-        "\23\14\uffff\1\6\1\uffff\1\10\1\uffff\1\7\1\uffff\1\33";\r
-    static final String DFA23_specialS =\r
-        "\1\17\4\uffff\1\20\1\25\11\uffff\1\11\2\uffff\1\15\14\uffff\1\12"+\r
-        "\1\uffff\1\14\10\uffff\1\21\1\10\1\5\1\4\1\uffff\1\23\3\uffff\1"+\r
-        "\3\1\uffff\1\22\5\uffff\1\0\1\2\1\7\2\uffff\1\24\1\uffff\1\1\1\6"+\r
-        "\2\uffff\1\16\1\uffff\1\13\5\uffff}>";\r
-    static final String[] DFA23_transitionS = {\r
+        "\23\3\uffff\1\30\7\uffff\1\6\1\uffff\1\10\1\7";\r
+    static final String DFA20_specialS =\r
+        "\1\0\4\uffff\1\20\1\1\11\uffff\1\21\2\uffff\1\22\14\uffff\1\6\1"+\r
+        "\uffff\1\25\10\uffff\1\2\1\17\1\12\1\24\1\uffff\1\14\1\16\2\uffff"+\r
+        "\1\11\1\uffff\1\10\5\uffff\1\5\1\26\1\23\2\uffff\1\3\1\uffff\1\4"+\r
+        "\1\13\1\uffff\1\15\1\uffff\1\7\2\uffff}>";\r
+    static final String[] DFA20_transitionS = {\r
             "\11\33\1\34\1\2\2\33\1\2\22\33\1\34\1\21\1\3\1\1\1\33\1\uffff"+\r
-            "\1\33\1\uffff\1\27\1\30\1\31\1\33\1\25\1\4\1\24\1\23\1\5\11"+\r
+            "\1\33\1\uffff\1\30\1\31\1\32\1\33\1\25\1\4\1\24\1\23\1\5\11"+\r
             "\6\1\26\1\33\1\16\1\20\1\17\1\33\1\uffff\32\33\1\14\1\uffff"+\r
-            "\1\15\10\33\1\10\6\33\1\32\1\11\5\33\1\7\6\33\1\12\1\uffff\1"+\r
-            "\13\1\22\uff81\33",\r
+            "\1\15\3\33\1\27\4\33\1\10\7\33\1\11\5\33\1\7\6\33\1\12\1\uffff"+\r
+            "\1\13\1\22\uff81\33",\r
             "",\r
             "",\r
             "",\r
@@ -2053,10 +1954,10 @@ public class LensQueryLexer extends Lexer {
             "",\r
             "",\r
             "",\r
+            "\1\61",\r
             "",\r
             "",\r
             "",\r
-            "\1\61",\r
             "",\r
             "",\r
             "\1\62\26\uffff\1\62\37\uffff\1\62",\r
@@ -2098,7 +1999,10 @@ public class LensQueryLexer extends Lexer {
             "\11\60\2\57\2\60\1\57\22\60\1\57\1\60\2\57\1\60\1\57\1\60"+\r
             "\4\57\1\60\2\57\1\55\1\56\12\60\1\57\1\60\1\57\1\60\1\57\1\60"+\r
             "\1\57\32\60\3\57\35\60\3\57\uff82\60",\r
-            "\1\77",\r
+            "\11\33\2\uffff\2\33\1\uffff\22\33\1\uffff\1\33\2\uffff\1\33"+\r
+            "\1\uffff\1\33\4\uffff\1\33\2\uffff\14\33\1\uffff\1\33\1\uffff"+\r
+            "\1\33\1\uffff\1\33\1\uffff\32\33\3\uffff\35\33\3\uffff\uff82"+\r
+            "\33",\r
             "",\r
             "\1\62\1\uffff\12\63\13\uffff\1\62\37\uffff\1\62",\r
             "\11\33\2\uffff\2\33\1\uffff\22\33\1\uffff\1\33\2\uffff\1\33"+\r
@@ -2126,13 +2030,13 @@ public class LensQueryLexer extends Lexer {
             "\1\uffff\1\60\4\uffff\1\60\2\uffff\1\55\1\56\12\60\1\uffff\1"+\r
             "\60\1\uffff\1\60\1\uffff\1\60\1\uffff\32\76\3\uffff\3\60\32"+\r
             "\76\3\uffff\uff82\60",\r
-            "\1\105",\r
-            "\1\106\1\uffff\1\62\2\uffff\12\107",\r
+            "",\r
+            "\1\105\1\uffff\1\62\2\uffff\12\106",\r
             "\11\33\2\uffff\2\33\1\uffff\22\33\1\uffff\1\33\2\uffff\1\33"+\r
             "\1\uffff\1\33\4\uffff\1\33\2\uffff\14\33\1\uffff\1\33\1\uffff"+\r
             "\1\33\1\uffff\1\33\1\uffff\32\33\3\uffff\35\33\3\uffff\uff82"+\r
             "\33",\r
-            "\1\111",\r
+            "\1\110",\r
             "\11\33\2\uffff\2\33\1\uffff\22\33\1\uffff\1\33\2\uffff\1\33"+\r
             "\1\uffff\1\33\4\uffff\1\33\2\uffff\14\33\1\uffff\1\33\1\uffff"+\r
             "\1\33\1\uffff\1\33\1\uffff\32\33\3\uffff\35\33\3\uffff\uff82"+\r
@@ -2141,10 +2045,9 @@ public class LensQueryLexer extends Lexer {
             "\1\uffff\1\75\4\uffff\1\75\2\uffff\1\55\1\74\12\75\1\uffff\1"+\r
             "\75\1\uffff\1\75\1\uffff\1\75\1\uffff\32\104\3\uffff\3\75\32"+\r
             "\104\3\uffff\uff82\75",\r
-            "\1\113",\r
-            "\12\107",\r
+            "\12\106",\r
             "\11\33\2\uffff\2\33\1\uffff\22\33\1\uffff\1\33\2\uffff\1\33"+\r
-            "\1\uffff\1\33\4\uffff\1\33\2\uffff\2\33\12\107\1\uffff\1\33"+\r
+            "\1\uffff\1\33\4\uffff\1\33\2\uffff\2\33\12\106\1\uffff\1\33"+\r
             "\1\uffff\1\33\1\uffff\1\33\1\uffff\32\33\3\uffff\35\33\3\uffff"+\r
             "\uff82\33",\r
             "",\r
@@ -2153,391 +2056,398 @@ public class LensQueryLexer extends Lexer {
             "\1\33\1\uffff\1\33\1\uffff\32\33\3\uffff\35\33\3\uffff\uff82"+\r
             "\33",\r
             "",\r
-            "\1\115",\r
-            "",\r
-            "\1\116\26\uffff\1\116",\r
             ""\r
     };\r
 \r
-    static final short[] DFA23_eot = DFA.unpackEncodedString(DFA23_eotS);\r
-    static final short[] DFA23_eof = DFA.unpackEncodedString(DFA23_eofS);\r
-    static final char[] DFA23_min = DFA.unpackEncodedStringToUnsignedChars(DFA23_minS);\r
-    static final char[] DFA23_max = DFA.unpackEncodedStringToUnsignedChars(DFA23_maxS);\r
-    static final short[] DFA23_accept = DFA.unpackEncodedString(DFA23_acceptS);\r
-    static final short[] DFA23_special = DFA.unpackEncodedString(DFA23_specialS);\r
-    static final short[][] DFA23_transition;\r
+    static final short[] DFA20_eot = DFA.unpackEncodedString(DFA20_eotS);\r
+    static final short[] DFA20_eof = DFA.unpackEncodedString(DFA20_eofS);\r
+    static final char[] DFA20_min = DFA.unpackEncodedStringToUnsignedChars(DFA20_minS);\r
+    static final char[] DFA20_max = DFA.unpackEncodedStringToUnsignedChars(DFA20_maxS);\r
+    static final short[] DFA20_accept = DFA.unpackEncodedString(DFA20_acceptS);\r
+    static final short[] DFA20_special = DFA.unpackEncodedString(DFA20_specialS);\r
+    static final short[][] DFA20_transition;\r
 \r
     static {\r
-        int numStates = DFA23_transitionS.length;\r
-        DFA23_transition = new short[numStates][];\r
+        int numStates = DFA20_transitionS.length;\r
+        DFA20_transition = new short[numStates][];\r
         for (int i=0; i<numStates; i++) {\r
-            DFA23_transition[i] = DFA.unpackEncodedString(DFA23_transitionS[i]);\r
+            DFA20_transition[i] = DFA.unpackEncodedString(DFA20_transitionS[i]);\r
         }\r
     }\r
 \r
-    class DFA23 extends DFA {\r
+    class DFA20 extends DFA {\r
 \r
-        public DFA23(BaseRecognizer recognizer) {\r
+        public DFA20(BaseRecognizer recognizer) {\r
             this.recognizer = recognizer;\r
-            this.decisionNumber = 23;\r
-            this.eot = DFA23_eot;\r
-            this.eof = DFA23_eof;\r
-            this.min = DFA23_min;\r
-            this.max = DFA23_max;\r
-            this.accept = DFA23_accept;\r
-            this.special = DFA23_special;\r
-            this.transition = DFA23_transition;\r
+            this.decisionNumber = 20;\r
+            this.eot = DFA20_eot;\r
+            this.eof = DFA20_eof;\r
+            this.min = DFA20_min;\r
+            this.max = DFA20_max;\r
+            this.accept = DFA20_accept;\r
+            this.special = DFA20_special;\r
+            this.transition = DFA20_transition;\r
         }\r
         public String getDescription() {\r
-            return "1:1: Tokens : ( LineComment | LineBreak | String | Integer | Double | True | False | Null | LBrace | RBrace | LBracket | RBracket | Lt | Gt | Leq | Geq | Eq | Neq | Match | Regex | Dot | Comma | Colon | LParen | RParen | Star | ModuleDef | QName | WhiteSpaces );";\r
+            return "1:1: Tokens : ( LineComment | LineBreak | String | Integer | Double | True | False | Null | LBrace | RBrace | LBracket | RBracket | Lt | Gt | Leq | Geq | Eq | Neq | Match | Regex | Dot | Comma | Colon | As | LParen | RParen | Star | QName | WhiteSpaces );";\r
         }\r
         public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {\r
             IntStream input = _input;\r
                int _s = s;\r
             switch ( s ) {\r
                     case 0 : \r
-                        int LA23_60 = input.LA(1);\r
+                        int LA20_0 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_60>='A' && LA23_60<='Z')||(LA23_60>='a' && LA23_60<='z')) ) {s = 68;}\r
+                        if ( (LA20_0=='#') ) {s = 1;}\r
 \r
-                        else if ( (LA23_60=='/') ) {s = 60;}\r
+                        else if ( (LA20_0=='\n'||LA20_0=='\r') ) {s = 2;}\r
 \r
-                        else if ( (LA23_60=='.') ) {s = 45;}\r
+                        else if ( (LA20_0=='\"') ) {s = 3;}\r
 \r
-                        else if ( ((LA23_60>='\u0000' && LA23_60<='\b')||(LA23_60>='\u000B' && LA23_60<='\f')||(LA23_60>='\u000E' && LA23_60<='\u001F')||LA23_60=='!'||LA23_60=='$'||LA23_60=='&'||LA23_60=='+'||(LA23_60>='0' && LA23_60<='9')||LA23_60==';'||LA23_60=='='||LA23_60=='?'||(LA23_60>='^' && LA23_60<='`')||(LA23_60>='~' && LA23_60<='\uFFFF')) ) {s = 61;}\r
+                        else if ( (LA20_0=='-') ) {s = 4;}\r
 \r
-                        else s = 47;\r
+                        else if ( (LA20_0=='0') ) {s = 5;}\r
 \r
-                        if ( s>=0 ) return s;\r
-                        break;\r
-                    case 1 : \r
-                        int LA23_67 = input.LA(1);\r
+                        else if ( ((LA20_0>='1' && LA20_0<='9')) ) {s = 6;}\r
 \r
-                        s = -1;\r
-                        if ( ((LA23_67>='\u0000' && LA23_67<='\b')||(LA23_67>='\u000B' && LA23_67<='\f')||(LA23_67>='\u000E' && LA23_67<='\u001F')||LA23_67=='!'||LA23_67=='$'||LA23_67=='&'||LA23_67=='+'||(LA23_67>='.' && LA23_67<='9')||LA23_67==';'||LA23_67=='='||LA23_67=='?'||(LA23_67>='A' && LA23_67<='Z')||(LA23_67>='^' && LA23_67<='z')||(LA23_67>='~' && LA23_67<='\uFFFF')) ) {s = 27;}\r
+                        else if ( (LA20_0=='t') ) {s = 7;}\r
 \r
-                        else s = 74;\r
+                        else if ( (LA20_0=='f') ) {s = 8;}\r
 \r
-                        if ( s>=0 ) return s;\r
-                        break;\r
-                    case 2 : \r
-                        int LA23_61 = input.LA(1);\r
+                        else if ( (LA20_0=='n') ) {s = 9;}\r
 \r
-                        s = -1;\r
-                        if ( (LA23_61=='/') ) {s = 60;}\r
-\r
-                        else if ( (LA23_61=='.') ) {s = 45;}\r
+                        else if ( (LA20_0=='{') ) {s = 10;}\r
 \r
-                        else if ( ((LA23_61>='\u0000' && LA23_61<='\b')||(LA23_61>='\u000B' && LA23_61<='\f')||(LA23_61>='\u000E' && LA23_61<='\u001F')||LA23_61=='!'||LA23_61=='$'||LA23_61=='&'||LA23_61=='+'||(LA23_61>='0' && LA23_61<='9')||LA23_61==';'||LA23_61=='='||LA23_61=='?'||(LA23_61>='A' && LA23_61<='Z')||(LA23_61>='^' && LA23_61<='z')||(LA23_61>='~' && LA23_61<='\uFFFF')) ) {s = 61;}\r
+                        else if ( (LA20_0=='}') ) {s = 11;}\r
 \r
-                        else if ( ((LA23_61>='\t' && LA23_61<='\n')||LA23_61=='\r'||LA23_61==' '||(LA23_61>='\"' && LA23_61<='#')||LA23_61=='%'||(LA23_61>='\'' && LA23_61<='*')||(LA23_61>=',' && LA23_61<='-')||LA23_61==':'||LA23_61=='<'||LA23_61=='>'||LA23_61=='@'||(LA23_61>='[' && LA23_61<=']')||(LA23_61>='{' && LA23_61<='}')) ) {s = 47;}\r
+                        else if ( (LA20_0=='[') ) {s = 12;}\r
 \r
-                        else s = 27;\r
+                        else if ( (LA20_0==']') ) {s = 13;}\r
 \r
-                        if ( s>=0 ) return s;\r
-                        break;\r
-                    case 3 : \r
-                        int LA23_52 = input.LA(1);\r
+                        else if ( (LA20_0=='<') ) {s = 14;}\r
 \r
-                        s = -1;\r
-                        if ( ((LA23_52>='\u0000' && LA23_52<='\b')||(LA23_52>='\u000B' && LA23_52<='\f')||(LA23_52>='\u000E' && LA23_52<='\u001F')||LA23_52=='!'||LA23_52=='$'||LA23_52=='&'||LA23_52=='+'||(LA23_52>='.' && LA23_52<='/')||LA23_52==';'||LA23_52=='='||LA23_52=='?'||(LA23_52>='A' && LA23_52<='D')||(LA23_52>='F' && LA23_52<='Z')||(LA23_52>='^' && LA23_52<='d')||(LA23_52>='f' && LA23_52<='z')||(LA23_52>='~' && LA23_52<='\uFFFF')) ) {s = 27;}\r
+                        else if ( (LA20_0=='>') ) {s = 15;}\r
 \r
-                        else if ( (LA23_52=='E'||LA23_52=='e') ) {s = 64;}\r
+                        else if ( (LA20_0=='=') ) {s = 16;}\r
 \r
-                        else if ( ((LA23_52>='0' && LA23_52<='9')) ) {s = 52;}\r
+                        else if ( (LA20_0=='!') ) {s = 17;}\r
 \r
-                        else s = 50;\r
+                        else if ( (LA20_0=='~') ) {s = 18;}\r
 \r
-                        if ( s>=0 ) return s;\r
-                        break;\r
-                    case 4 : \r
-                        int LA23_46 = input.LA(1);\r
+                        else if ( (LA20_0=='/') ) {s = 19;}\r
 \r
-                        s = -1;\r
-                        if ( ((LA23_46>='A' && LA23_46<='Z')||(LA23_46>='a' && LA23_46<='z')) ) {s = 62;}\r
+                        else if ( (LA20_0=='.') ) {s = 20;}\r
 \r
-                        else if ( (LA23_46=='.') ) {s = 45;}\r
+                        else if ( (LA20_0==',') ) {s = 21;}\r
 \r
-                        else if ( (LA23_46=='/') ) {s = 46;}\r
+                        else if ( (LA20_0==':') ) {s = 22;}\r
 \r
-                        else if ( ((LA23_46>='\u0000' && LA23_46<='\b')||(LA23_46>='\u000B' && LA23_46<='\f')||(LA23_46>='\u000E' && LA23_46<='\u001F')||LA23_46=='!'||LA23_46=='$'||LA23_46=='&'||LA23_46=='+'||(LA23_46>='0' && LA23_46<='9')||LA23_46==';'||LA23_46=='='||LA23_46=='?'||(LA23_46>='^' && LA23_46<='`')||(LA23_46>='~' && LA23_46<='\uFFFF')) ) {s = 48;}\r
+                        else if ( (LA20_0=='a') ) {s = 23;}\r
 \r
-                        else s = 47;\r
+                        else if ( (LA20_0=='(') ) {s = 24;}\r
 \r
-                        if ( s>=0 ) return s;\r
-                        break;\r
-                    case 5 : \r
-                        int LA23_45 = input.LA(1);\r
+                        else if ( (LA20_0==')') ) {s = 25;}\r
 \r
-                        s = -1;\r
-                        if ( (LA23_45=='/') ) {s = 60;}\r
+                        else if ( (LA20_0=='*') ) {s = 26;}\r
 \r
-                        else if ( ((LA23_45>='\u0000' && LA23_45<='\b')||(LA23_45>='\u000B' && LA23_45<='\f')||(LA23_45>='\u000E' && LA23_45<='\u001F')||LA23_45=='!'||LA23_45=='$'||LA23_45=='&'||LA23_45=='+'||(LA23_45>='0' && LA23_45<='9')||LA23_45==';'||LA23_45=='='||LA23_45=='?'||(LA23_45>='A' && LA23_45<='Z')||(LA23_45>='^' && LA23_45<='z')||(LA23_45>='~' && LA23_45<='\uFFFF')) ) {s = 61;}\r
+                        else if ( ((LA20_0>='\u0000' && LA20_0<='\b')||(LA20_0>='\u000B' && LA20_0<='\f')||(LA20_0>='\u000E' && LA20_0<='\u001F')||LA20_0=='$'||LA20_0=='&'||LA20_0=='+'||LA20_0==';'||LA20_0=='?'||(LA20_0>='A' && LA20_0<='Z')||(LA20_0>='^' && LA20_0<='`')||(LA20_0>='b' && LA20_0<='e')||(LA20_0>='g' && LA20_0<='m')||(LA20_0>='o' && LA20_0<='s')||(LA20_0>='u' && LA20_0<='z')||(LA20_0>='\u007F' && LA20_0<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( ((LA23_45>='\t' && LA23_45<='\n')||LA23_45=='\r'||LA23_45==' '||(LA23_45>='\"' && LA23_45<='#')||LA23_45=='%'||(LA23_45>='\'' && LA23_45<='*')||(LA23_45>=',' && LA23_45<='.')||LA23_45==':'||LA23_45=='<'||LA23_45=='>'||LA23_45=='@'||(LA23_45>='[' && LA23_45<=']')||(LA23_45>='{' && LA23_45<='}')) ) {s = 47;}\r
+                        else if ( (LA20_0=='\t'||LA20_0==' ') ) {s = 28;}\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 6 : \r
-                        int LA23_68 = input.LA(1);\r
+                    case 1 : \r
+                        int LA20_6 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_68>='A' && LA23_68<='Z')||(LA23_68>='a' && LA23_68<='z')) ) {s = 68;}\r
+                        if ( (LA20_6=='.') ) {s = 32;}\r
 \r
-                        else if ( (LA23_68=='.') ) {s = 45;}\r
+                        else if ( ((LA20_6>='0' && LA20_6<='9')) ) {s = 34;}\r
 \r
-                        else if ( (LA23_68=='/') ) {s = 60;}\r
+                        else if ( (LA20_6=='E'||LA20_6=='e') ) {s = 33;}\r
 \r
-                        else if ( ((LA23_68>='\u0000' && LA23_68<='\b')||(LA23_68>='\u000B' && LA23_68<='\f')||(LA23_68>='\u000E' && LA23_68<='\u001F')||LA23_68=='!'||LA23_68=='$'||LA23_68=='&'||LA23_68=='+'||(LA23_68>='0' && LA23_68<='9')||LA23_68==';'||LA23_68=='='||LA23_68=='?'||(LA23_68>='^' && LA23_68<='`')||(LA23_68>='~' && LA23_68<='\uFFFF')) ) {s = 61;}\r
+                        else if ( ((LA20_6>='\u0000' && LA20_6<='\b')||(LA20_6>='\u000B' && LA20_6<='\f')||(LA20_6>='\u000E' && LA20_6<='\u001F')||LA20_6=='!'||LA20_6=='$'||LA20_6=='&'||LA20_6=='+'||LA20_6=='/'||LA20_6==';'||LA20_6=='='||LA20_6=='?'||(LA20_6>='A' && LA20_6<='D')||(LA20_6>='F' && LA20_6<='Z')||(LA20_6>='^' && LA20_6<='d')||(LA20_6>='f' && LA20_6<='z')||(LA20_6>='~' && LA20_6<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else s = 47;\r
+                        else s = 31;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 7 : \r
-                        int LA23_62 = input.LA(1);\r
+                    case 2 : \r
+                        int LA20_43 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_62>='A' && LA23_62<='Z')||(LA23_62>='a' && LA23_62<='z')) ) {s = 62;}\r
-\r
-                        else if ( (LA23_62=='.') ) {s = 45;}\r
-\r
-                        else if ( (LA23_62=='/') ) {s = 46;}\r
+                        if ( ((LA20_43>='\u0000' && LA20_43<='\b')||(LA20_43>='\u000B' && LA20_43<='\f')||(LA20_43>='\u000E' && LA20_43<='\u001F')||LA20_43=='!'||LA20_43=='$'||LA20_43=='&'||LA20_43=='+'||(LA20_43>='.' && LA20_43<='9')||LA20_43==';'||LA20_43=='='||LA20_43=='?'||(LA20_43>='A' && LA20_43<='Z')||(LA20_43>='^' && LA20_43<='z')||(LA20_43>='~' && LA20_43<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( ((LA23_62>='\u0000' && LA23_62<='\b')||(LA23_62>='\u000B' && LA23_62<='\f')||(LA23_62>='\u000E' && LA23_62<='\u001F')||LA23_62=='!'||LA23_62=='$'||LA23_62=='&'||LA23_62=='+'||(LA23_62>='0' && LA23_62<='9')||LA23_62==';'||LA23_62=='='||LA23_62=='?'||(LA23_62>='^' && LA23_62<='`')||(LA23_62>='~' && LA23_62<='\uFFFF')) ) {s = 48;}\r
-\r
-                        else s = 47;\r
+                        else s = 58;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 8 : \r
-                        int LA23_44 = input.LA(1);\r
+                    case 3 : \r
+                        int LA20_65 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_44>='\u0000' && LA23_44<='\b')||(LA23_44>='\u000B' && LA23_44<='\f')||(LA23_44>='\u000E' && LA23_44<='\u001F')||LA23_44=='!'||LA23_44=='$'||LA23_44=='&'||LA23_44=='+'||(LA23_44>='.' && LA23_44<='9')||LA23_44==';'||LA23_44=='='||LA23_44=='?'||(LA23_44>='A' && LA23_44<='Z')||(LA23_44>='^' && LA23_44<='z')||(LA23_44>='~' && LA23_44<='\uFFFF')) ) {s = 27;}\r
+                        if ( ((LA20_65>='\u0000' && LA20_65<='\b')||(LA20_65>='\u000B' && LA20_65<='\f')||(LA20_65>='\u000E' && LA20_65<='\u001F')||LA20_65=='!'||LA20_65=='$'||LA20_65=='&'||LA20_65=='+'||(LA20_65>='.' && LA20_65<='9')||LA20_65==';'||LA20_65=='='||LA20_65=='?'||(LA20_65>='A' && LA20_65<='Z')||(LA20_65>='^' && LA20_65<='z')||(LA20_65>='~' && LA20_65<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else s = 59;\r
+                        else s = 71;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 9 : \r
-                        int LA23_16 = input.LA(1);\r
+                    case 4 : \r
+                        int LA20_67 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_16>='\u0000' && LA23_16<='\b')||(LA23_16>='\u000B' && LA23_16<='\f')||(LA23_16>='\u000E' && LA23_16<='\u001F')||LA23_16=='!'||LA23_16=='$'||LA23_16=='&'||LA23_16=='+'||(LA23_16>='.' && LA23_16<='9')||LA23_16==';'||LA23_16=='='||LA23_16=='?'||(LA23_16>='A' && LA23_16<='Z')||(LA23_16>='^' && LA23_16<='z')||(LA23_16>='~' && LA23_16<='\uFFFF')) ) {s = 27;}\r
+                        if ( ((LA20_67>='\u0000' && LA20_67<='\b')||(LA20_67>='\u000B' && LA20_67<='\f')||(LA20_67>='\u000E' && LA20_67<='\u001F')||LA20_67=='!'||LA20_67=='$'||LA20_67=='&'||LA20_67=='+'||(LA20_67>='.' && LA20_67<='9')||LA20_67==';'||LA20_67=='='||LA20_67=='?'||(LA20_67>='A' && LA20_67<='Z')||(LA20_67>='^' && LA20_67<='z')||(LA20_67>='~' && LA20_67<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else s = 42;\r
+                        else s = 73;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 10 : \r
-                        int LA23_32 = input.LA(1);\r
+                    case 5 : \r
+                        int LA20_60 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_32>='0' && LA23_32<='9')) ) {s = 52;}\r
+                        if ( ((LA20_60>='A' && LA20_60<='Z')||(LA20_60>='a' && LA20_60<='z')) ) {s = 68;}\r
 \r
-                        else if ( ((LA23_32>='\u0000' && LA23_32<='\b')||(LA23_32>='\u000B' && LA23_32<='\f')||(LA23_32>='\u000E' && LA23_32<='\u001F')||LA23_32=='!'||LA23_32=='$'||LA23_32=='&'||LA23_32=='+'||LA23_32=='/'||LA23_32==';'||LA23_32=='='||LA23_32=='?'||(LA23_32>='A' && LA23_32<='Z')||(LA23_32>='^' && LA23_32<='z')||(LA23_32>='~' && LA23_32<='\uFFFF')) ) {s = 27;}\r
+                        else if ( (LA20_60=='/') ) {s = 60;}\r
 \r
-                        if ( s>=0 ) return s;\r
-                        break;\r
-                    case 11 : \r
-                        int LA23_73 = input.LA(1);\r
+                        else if ( (LA20_60=='.') ) {s = 45;}\r
 \r
-                        s = -1;\r
-                        if ( ((LA23_73>='\u0000' && LA23_73<='\b')||(LA23_73>='\u000B' && LA23_73<='\f')||(LA23_73>='\u000E' && LA23_73<='\u001F')||LA23_73=='!'||LA23_73=='$'||LA23_73=='&'||LA23_73=='+'||(LA23_73>='.' && LA23_73<='9')||LA23_73==';'||LA23_73=='='||LA23_73=='?'||(LA23_73>='A' && LA23_73<='Z')||(LA23_73>='^' && LA23_73<='z')||(LA23_73>='~' && LA23_73<='\uFFFF')) ) {s = 27;}\r
+                        else if ( ((LA20_60>='\u0000' && LA20_60<='\b')||(LA20_60>='\u000B' && LA20_60<='\f')||(LA20_60>='\u000E' && LA20_60<='\u001F')||LA20_60=='!'||LA20_60=='$'||LA20_60=='&'||LA20_60=='+'||(LA20_60>='0' && LA20_60<='9')||LA20_60==';'||LA20_60=='='||LA20_60=='?'||(LA20_60>='^' && LA20_60<='`')||(LA20_60>='~' && LA20_60<='\uFFFF')) ) {s = 61;}\r
 \r
-                        else s = 76;\r
+                        else s = 47;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 12 : \r
-                        int LA23_34 = input.LA(1);\r
+                    case 6 : \r
+                        int LA20_32 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( (LA23_34=='.') ) {s = 32;}\r
+                        if ( ((LA20_32>='0' && LA20_32<='9')) ) {s = 52;}\r
 \r
-                        else if ( (LA23_34=='E'||LA23_34=='e') ) {s = 33;}\r
+                        else if ( ((LA20_32>='\u0000' && LA20_32<='\b')||(LA20_32>='\u000B' && LA20_32<='\f')||(LA20_32>='\u000E' && LA20_32<='\u001F')||LA20_32=='!'||LA20_32=='$'||LA20_32=='&'||LA20_32=='+'||LA20_32=='/'||LA20_32==';'||LA20_32=='='||LA20_32=='?'||(LA20_32>='A' && LA20_32<='Z')||(LA20_32>='^' && LA20_32<='z')||(LA20_32>='~' && LA20_32<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( ((LA23_34>='0' && LA23_34<='9')) ) {s = 34;}\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
+                    case 7 : \r
+                        int LA20_72 = input.LA(1);\r
 \r
-                        else if ( ((LA23_34>='\u0000' && LA23_34<='\b')||(LA23_34>='\u000B' && LA23_34<='\f')||(LA23_34>='\u000E' && LA23_34<='\u001F')||LA23_34=='!'||LA23_34=='$'||LA23_34=='&'||LA23_34=='+'||LA23_34=='/'||LA23_34==';'||LA23_34=='='||LA23_34=='?'||(LA23_34>='A' && LA23_34<='D')||(LA23_34>='F' && LA23_34<='Z')||(LA23_34>='^' && LA23_34<='d')||(LA23_34>='f' && LA23_34<='z')||(LA23_34>='~' && LA23_34<='\uFFFF')) ) {s = 27;}\r
+                        s = -1;\r
+                        if ( ((LA20_72>='\u0000' && LA20_72<='\b')||(LA20_72>='\u000B' && LA20_72<='\f')||(LA20_72>='\u000E' && LA20_72<='\u001F')||LA20_72=='!'||LA20_72=='$'||LA20_72=='&'||LA20_72=='+'||(LA20_72>='.' && LA20_72<='9')||LA20_72==';'||LA20_72=='='||LA20_72=='?'||(LA20_72>='A' && LA20_72<='Z')||(LA20_72>='^' && LA20_72<='z')||(LA20_72>='~' && LA20_72<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else s = 31;\r
+                        else s = 74;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 13 : \r
-                        int LA23_19 = input.LA(1);\r
+                    case 8 : \r
+                        int LA20_54 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( (LA23_19=='.') ) {s = 45;}\r
+                        if ( ((LA20_54>='0' && LA20_54<='9')) ) {s = 54;}\r
 \r
-                        else if ( (LA23_19=='/') ) {s = 46;}\r
+                        else if ( ((LA20_54>='\u0000' && LA20_54<='\b')||(LA20_54>='\u000B' && LA20_54<='\f')||(LA20_54>='\u000E' && LA20_54<='\u001F')||LA20_54=='!'||LA20_54=='$'||LA20_54=='&'||LA20_54=='+'||(LA20_54>='.' && LA20_54<='/')||LA20_54==';'||LA20_54=='='||LA20_54=='?'||(LA20_54>='A' && LA20_54<='Z')||(LA20_54>='^' && LA20_54<='z')||(LA20_54>='~' && LA20_54<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( ((LA23_19>='\t' && LA23_19<='\n')||LA23_19=='\r'||LA23_19==' '||(LA23_19>='\"' && LA23_19<='#')||LA23_19=='%'||(LA23_19>='\'' && LA23_19<='*')||(LA23_19>=',' && LA23_19<='-')||LA23_19==':'||LA23_19=='<'||LA23_19=='>'||LA23_19=='@'||(LA23_19>='[' && LA23_19<=']')||(LA23_19>='{' && LA23_19<='}')) ) {s = 47;}\r
-\r
-                        else if ( ((LA23_19>='\u0000' && LA23_19<='\b')||(LA23_19>='\u000B' && LA23_19<='\f')||(LA23_19>='\u000E' && LA23_19<='\u001F')||LA23_19=='!'||LA23_19=='$'||LA23_19=='&'||LA23_19=='+'||(LA23_19>='0' && LA23_19<='9')||LA23_19==';'||LA23_19=='='||LA23_19=='?'||(LA23_19>='A' && LA23_19<='Z')||(LA23_19>='^' && LA23_19<='z')||(LA23_19>='~' && LA23_19<='\uFFFF')) ) {s = 48;}\r
-\r
-                        else s = 27;\r
+                        else s = 50;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 14 : \r
-                        int LA23_71 = input.LA(1);\r
+                    case 9 : \r
+                        int LA20_52 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_71>='0' && LA23_71<='9')) ) {s = 71;}\r
+                        if ( (LA20_52=='E'||LA20_52=='e') ) {s = 64;}\r
 \r
-                        else if ( ((LA23_71>='\u0000' && LA23_71<='\b')||(LA23_71>='\u000B' && LA23_71<='\f')||(LA23_71>='\u000E' && LA23_71<='\u001F')||LA23_71=='!'||LA23_71=='$'||LA23_71=='&'||LA23_71=='+'||(LA23_71>='.' && LA23_71<='/')||LA23_71==';'||LA23_71=='='||LA23_71=='?'||(LA23_71>='A' && LA23_71<='Z')||(LA23_71>='^' && LA23_71<='z')||(LA23_71>='~' && LA23_71<='\uFFFF')) ) {s = 27;}\r
+                        else if ( ((LA20_52>='0' && LA20_52<='9')) ) {s = 52;}\r
+\r
+                        else if ( ((LA20_52>='\u0000' && LA20_52<='\b')||(LA20_52>='\u000B' && LA20_52<='\f')||(LA20_52>='\u000E' && LA20_52<='\u001F')||LA20_52=='!'||LA20_52=='$'||LA20_52=='&'||LA20_52=='+'||(LA20_52>='.' && LA20_52<='/')||LA20_52==';'||LA20_52=='='||LA20_52=='?'||(LA20_52>='A' && LA20_52<='D')||(LA20_52>='F' && LA20_52<='Z')||(LA20_52>='^' && LA20_52<='d')||(LA20_52>='f' && LA20_52<='z')||(LA20_52>='~' && LA20_52<='\uFFFF')) ) {s = 27;}\r
 \r
                         else s = 50;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
-                    case 15 : \r
-                        int LA23_0 = input.LA(1);\r
+                    case 10 : \r
+                        int LA20_45 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( (LA23_0=='#') ) {s = 1;}\r
-\r
-                        else if ( (LA23_0=='\n'||LA23_0=='\r') ) {s = 2;}\r
-\r
-                        else if ( (LA23_0=='\"') ) {s = 3;}\r
+                        if ( (LA20_45=='/') ) {s = 60;}\r
 \r
-                        else if ( (LA23_0=='-') ) {s = 4;}\r
+                        else if ( ((LA20_45>='\u0000' && LA20_45<='\b')||(LA20_45>='\u000B' && LA20_45<='\f')||(LA20_45>='\u000E' && LA20_45<='\u001F')||LA20_45=='!'||LA20_45=='$'||LA20_45=='&'||LA20_45=='+'||(LA20_45>='0' && LA20_45<='9')||LA20_45==';'||LA20_45=='='||LA20_45=='?'||(LA20_45>='A' && LA20_45<='Z')||(LA20_45>='^' && LA20_45<='z')||(LA20_45>='~' && LA20_45<='\uFFFF')) ) {s = 61;}\r
 \r
-                        else if ( (LA23_0=='0') ) {s = 5;}\r
+                        else if ( ((LA20_45>='\t' && LA20_45<='\n')||LA20_45=='\r'||LA20_45==' '||(LA20_45>='\"' && LA20_45<='#')||LA20_45=='%'||(LA20_45>='\'' && LA20_45<='*')||(LA20_45>=',' && LA20_45<='.')||LA20_45==':'||LA20_45=='<'||LA20_45=='>'||LA20_45=='@'||(LA20_45>='[' && LA20_45<=']')||(LA20_45>='{' && LA20_45<='}')) ) {s = 47;}\r
 \r
-                        else if ( ((LA23_0>='1' && LA23_0<='9')) ) {s = 6;}\r
-\r
-                        else if ( (LA23_0=='t') ) {s = 7;}\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
+                    case 11 : \r
+                        int LA20_68 = input.LA(1);\r
 \r
-                        else if ( (LA23_0=='f') ) {s = 8;}\r
+                        s = -1;\r
+                        if ( ((LA20_68>='A' && LA20_68<='Z')||(LA20_68>='a' && LA20_68<='z')) ) {s = 68;}\r
 \r
-                        else if ( (LA23_0=='n') ) {s = 9;}\r
+                        else if ( (LA20_68=='/') ) {s = 60;}\r
 \r
-                        else if ( (LA23_0=='{') ) {s = 10;}\r
+                        else if ( (LA20_68=='.') ) {s = 45;}\r
 \r
-                        else if ( (LA23_0=='}') ) {s = 11;}\r
+                        else if ( ((LA20_68>='\u0000' && LA20_68<='\b')||(LA20_68>='\u000B' && LA20_68<='\f')||(LA20_68>='\u000E' && LA20_68<='\u001F')||LA20_68=='!'||LA20_68=='$'||LA20_68=='&'||LA20_68=='+'||(LA20_68>='0' && LA20_68<='9')||LA20_68==';'||LA20_68=='='||LA20_68=='?'||(LA20_68>='^' && LA20_68<='`')||(LA20_68>='~' && LA20_68<='\uFFFF')) ) {s = 61;}\r
 \r
-                        else if ( (LA23_0=='[') ) {s = 12;}\r
+                        else s = 47;\r
 \r
-                        else if ( (LA23_0==']') ) {s = 13;}\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
+                    case 12 : \r
+                        int LA20_48 = input.LA(1);\r
 \r
-                        else if ( (LA23_0=='<') ) {s = 14;}\r
+                        s = -1;\r
+                        if ( (LA20_48=='.') ) {s = 45;}\r
 \r
-                        else if ( (LA23_0=='>') ) {s = 15;}\r
+                        else if ( (LA20_48=='/') ) {s = 46;}\r
 \r
-                        else if ( (LA23_0=='=') ) {s = 16;}\r
+                        else if ( ((LA20_48>='\u0000' && LA20_48<='\b')||(LA20_48>='\u000B' && LA20_48<='\f')||(LA20_48>='\u000E' && LA20_48<='\u001F')||LA20_48=='!'||LA20_48=='$'||LA20_48=='&'||LA20_48=='+'||(LA20_48>='0' && LA20_48<='9')||LA20_48==';'||LA20_48=='='||LA20_48=='?'||(LA20_48>='A' && LA20_48<='Z')||(LA20_48>='^' && LA20_48<='z')||(LA20_48>='~' && LA20_48<='\uFFFF')) ) {s = 48;}\r
 \r
-                        else if ( (LA23_0=='!') ) {s = 17;}\r
+                        else if ( ((LA20_48>='\t' && LA20_48<='\n')||LA20_48=='\r'||LA20_48==' '||(LA20_48>='\"' && LA20_48<='#')||LA20_48=='%'||(LA20_48>='\'' && LA20_48<='*')||(LA20_48>=',' && LA20_48<='-')||LA20_48==':'||LA20_48=='<'||LA20_48=='>'||LA20_48=='@'||(LA20_48>='[' && LA20_48<=']')||(LA20_48>='{' && LA20_48<='}')) ) {s = 47;}\r
 \r
-                        else if ( (LA23_0=='~') ) {s = 18;}\r
+                        else s = 27;\r
 \r
-                        else if ( (LA23_0=='/') ) {s = 19;}\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
+                    case 13 : \r
+                        int LA20_70 = input.LA(1);\r
 \r
-                        else if ( (LA23_0=='.') ) {s = 20;}\r
+                        s = -1;\r
+                        if ( ((LA20_70>='0' && LA20_70<='9')) ) {s = 70;}\r
 \r
-                        else if ( (LA23_0==',') ) {s = 21;}\r
+                        else if ( ((LA20_70>='\u0000' && LA20_70<='\b')||(LA20_70>='\u000B' && LA20_70<='\f')||(LA20_70>='\u000E' && LA20_70<='\u001F')||LA20_70=='!'||LA20_70=='$'||LA20_70=='&'||LA20_70=='+'||(LA20_70>='.' && LA20_70<='/')||LA20_70==';'||LA20_70=='='||LA20_70=='?'||(LA20_70>='A' && LA20_70<='Z')||(LA20_70>='^' && LA20_70<='z')||(LA20_70>='~' && LA20_70<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( (LA23_0==':') ) {s = 22;}\r
+                        else s = 50;\r
 \r
-                        else if ( (LA23_0=='(') ) {s = 23;}\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
+                    case 14 : \r
+                        int LA20_49 = input.LA(1);\r
 \r
-                        else if ( (LA23_0==')') ) {s = 24;}\r
+                        s = -1;\r
+                        if ( ((LA20_49>='\u0000' && LA20_49<='\b')||(LA20_49>='\u000B' && LA20_49<='\f')||(LA20_49>='\u000E' && LA20_49<='\u001F')||LA20_49=='!'||LA20_49=='$'||LA20_49=='&'||LA20_49=='+'||(LA20_49>='.' && LA20_49<='9')||LA20_49==';'||LA20_49=='='||LA20_49=='?'||(LA20_49>='A' && LA20_49<='Z')||(LA20_49>='^' && LA20_49<='z')||(LA20_49>='~' && LA20_49<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( (LA23_0=='*') ) {s = 25;}\r
+                        else s = 63;\r
 \r
-                        else if ( (LA23_0=='m') ) {s = 26;}\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
+                    case 15 : \r
+                        int LA20_44 = input.LA(1);\r
 \r
-                        else if ( ((LA23_0>='\u0000' && LA23_0<='\b')||(LA23_0>='\u000B' && LA23_0<='\f')||(LA23_0>='\u000E' && LA23_0<='\u001F')||LA23_0=='$'||LA23_0=='&'||LA23_0=='+'||LA23_0==';'||LA23_0=='?'||(LA23_0>='A' && LA23_0<='Z')||(LA23_0>='^' && LA23_0<='e')||(LA23_0>='g' && LA23_0<='l')||(LA23_0>='o' && LA23_0<='s')||(LA23_0>='u' && LA23_0<='z')||(LA23_0>='\u007F' && LA23_0<='\uFFFF')) ) {s = 27;}\r
+                        s = -1;\r
+                        if ( ((LA20_44>='\u0000' && LA20_44<='\b')||(LA20_44>='\u000B' && LA20_44<='\f')||(LA20_44>='\u000E' && LA20_44<='\u001F')||LA20_44=='!'||LA20_44=='$'||LA20_44=='&'||LA20_44=='+'||(LA20_44>='.' && LA20_44<='9')||LA20_44==';'||LA20_44=='='||LA20_44=='?'||(LA20_44>='A' && LA20_44<='Z')||(LA20_44>='^' && LA20_44<='z')||(LA20_44>='~' && LA20_44<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else if ( (LA23_0=='\t'||LA23_0==' ') ) {s = 28;}\r
+                        else s = 59;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
                     case 16 : \r
-                        int LA23_5 = input.LA(1);\r
+                        int LA20_5 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( (LA23_5=='.') ) {s = 32;}\r
+                        if ( (LA20_5=='.') ) {s = 32;}\r
 \r
-                        else if ( (LA23_5=='E'||LA23_5=='e') ) {s = 33;}\r
+                        else if ( (LA20_5=='E'||LA20_5=='e') ) {s = 33;}\r
 \r
-                        else if ( ((LA23_5>='\u0000' && LA23_5<='\b')||(LA23_5>='\u000B' && LA23_5<='\f')||(LA23_5>='\u000E' && LA23_5<='\u001F')||LA23_5=='!'||LA23_5=='$'||LA23_5=='&'||LA23_5=='+'||(LA23_5>='/' && LA23_5<='9')||LA23_5==';'||LA23_5=='='||LA23_5=='?'||(LA23_5>='A' && LA23_5<='D')||(LA23_5>='F' && LA23_5<='Z')||(LA23_5>='^' && LA23_5<='d')||(LA23_5>='f' && LA23_5<='z')||(LA23_5>='~' && LA23_5<='\uFFFF')) ) {s = 27;}\r
+                        else if ( ((LA20_5>='\u0000' && LA20_5<='\b')||(LA20_5>='\u000B' && LA20_5<='\f')||(LA20_5>='\u000E' && LA20_5<='\u001F')||LA20_5=='!'||LA20_5=='$'||LA20_5=='&'||LA20_5=='+'||(LA20_5>='/' && LA20_5<='9')||LA20_5==';'||LA20_5=='='||LA20_5=='?'||(LA20_5>='A' && LA20_5<='D')||(LA20_5>='F' && LA20_5<='Z')||(LA20_5>='^' && LA20_5<='d')||(LA20_5>='f' && LA20_5<='z')||(LA20_5>='~' && LA20_5<='\uFFFF')) ) {s = 27;}\r
 \r
                         else s = 31;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
                     case 17 : \r
-                        int LA23_43 = input.LA(1);\r
+                        int LA20_16 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_43>='\u0000' && LA23_43<='\b')||(LA23_43>='\u000B' && LA23_43<='\f')||(LA23_43>='\u000E' && LA23_43<='\u001F')||LA23_43=='!'||LA23_43=='$'||LA23_43=='&'||LA23_43=='+'||(LA23_43>='.' && LA23_43<='9')||LA23_43==';'||LA23_43=='='||LA23_43=='?'||(LA23_43>='A' && LA23_43<='Z')||(LA23_43>='^' && LA23_43<='z')||(LA23_43>='~' && LA23_43<='\uFFFF')) ) {s = 27;}\r
+                        if ( ((LA20_16>='\u0000' && LA20_16<='\b')||(LA20_16>='\u000B' && LA20_16<='\f')||(LA20_16>='\u000E' && LA20_16<='\u001F')||LA20_16=='!'||LA20_16=='$'||LA20_16=='&'||LA20_16=='+'||(LA20_16>='.' && LA20_16<='9')||LA20_16==';'||LA20_16=='='||LA20_16=='?'||(LA20_16>='A' && LA20_16<='Z')||(LA20_16>='^' && LA20_16<='z')||(LA20_16>='~' && LA20_16<='\uFFFF')) ) {s = 27;}\r
 \r
-                        else s = 58;\r
+                        else s = 42;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
                     case 18 : \r
-                        int LA23_54 = input.LA(1);\r
+                        int LA20_19 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_54>='\u0000' && LA23_54<='\b')||(LA23_54>='\u000B' && LA23_54<='\f')||(LA23_54>='\u000E' && LA23_54<='\u001F')||LA23_54=='!'||LA23_54=='$'||LA23_54=='&'||LA23_54=='+'||(LA23_54>='.' && LA23_54<='/')||LA23_54==';'||LA23_54=='='||LA23_54=='?'||(LA23_54>='A' && LA23_54<='Z')||(LA23_54>='^' && LA23_54<='z')||(LA23_54>='~' && LA23_54<='\uFFFF')) ) {s = 27;}\r
+                        if ( (LA20_19=='.') ) {s = 45;}\r
 \r
-                        else if ( ((LA23_54>='0' && LA23_54<='9')) ) {s = 54;}\r
+                        else if ( (LA20_19=='/') ) {s = 46;}\r
 \r
-                        else s = 50;\r
+                        else if ( ((LA20_19>='\t' && LA20_19<='\n')||LA20_19=='\r'||LA20_19==' '||(LA20_19>='\"' && LA20_19<='#')||LA20_19=='%'||(LA20_19>='\'' && LA20_19<='*')||(LA20_19>=',' && LA20_19<='-')||LA20_19==':'||LA20_19=='<'||LA20_19=='>'||LA20_19=='@'||(LA20_19>='[' && LA20_19<=']')||(LA20_19>='{' && LA20_19<='}')) ) {s = 47;}\r
+\r
+                        else if ( ((LA20_19>='\u0000' && LA20_19<='\b')||(LA20_19>='\u000B' && LA20_19<='\f')||(LA20_19>='\u000E' && LA20_19<='\u001F')||LA20_19=='!'||LA20_19=='$'||LA20_19=='&'||LA20_19=='+'||(LA20_19>='0' && LA20_19<='9')||LA20_19==';'||LA20_19=='='||LA20_19=='?'||(LA20_19>='A' && LA20_19<='Z')||(LA20_19>='^' && LA20_19<='z')||(LA20_19>='~' && LA20_19<='\uFFFF')) ) {s = 48;}\r
+\r
+                        else s = 27;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
                     case 19 : \r
-                        int LA23_48 = input.LA(1);\r
+                        int LA20_62 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( (LA23_48=='.') ) {s = 45;}\r
+                        if ( (LA20_62=='.') ) {s = 45;}\r
 \r
-                        else if ( (LA23_48=='/') ) {s = 46;}\r
+                        else if ( ((LA20_62>='A' && LA20_62<='Z')||(LA20_62>='a' && LA20_62<='z')) ) {s = 62;}\r
 \r
-                        else if ( ((LA23_48>='\u0000' && LA23_48<='\b')||(LA23_48>='\u000B' && LA23_48<='\f')||(LA23_48>='\u000E' && LA23_48<='\u001F')||LA23_48=='!'||LA23_48=='$'||LA23_48=='&'||LA23_48=='+'||(LA23_48>='0' && LA23_48<='9')||LA23_48==';'||LA23_48=='='||LA23_48=='?'||(LA23_48>='A' && LA23_48<='Z')||(LA23_48>='^' && LA23_48<='z')||(LA23_48>='~' && LA23_48<='\uFFFF')) ) {s = 48;}\r
+                        else if ( (LA20_62=='/') ) {s = 46;}\r
 \r
-                        else if ( ((LA23_48>='\t' && LA23_48<='\n')||LA23_48=='\r'||LA23_48==' '||(LA23_48>='\"' && LA23_48<='#')||LA23_48=='%'||(LA23_48>='\'' && LA23_48<='*')||(LA23_48>=',' && LA23_48<='-')||LA23_48==':'||LA23_48=='<'||LA23_48=='>'||LA23_48=='@'||(LA23_48>='[' && LA23_48<=']')||(LA23_48>='{' && LA23_48<='}')) ) {s = 47;}\r
+                        else if ( ((LA20_62>='\u0000' && LA20_62<='\b')||(LA20_62>='\u000B' && LA20_62<='\f')||(LA20_62>='\u000E' && LA20_62<='\u001F')||LA20_62=='!'||LA20_62=='$'||LA20_62=='&'||LA20_62=='+'||(LA20_62>='0' && LA20_62<='9')||LA20_62==';'||LA20_62=='='||LA20_62=='?'||(LA20_62>='^' && LA20_62<='`')||(LA20_62>='~' && LA20_62<='\uFFFF')) ) {s = 48;}\r
 \r
-                        else s = 27;\r
+                        else s = 47;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
                     case 20 : \r
-                        int LA23_65 = input.LA(1);\r
+                        int LA20_46 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( ((LA23_65>='\u0000' && LA23_65<='\b')||(LA23_65>='\u000B' && LA23_65<='\f')||(LA23_65>='\u000E' && LA23_65<='\u001F')||LA23_65=='!'||LA23_65=='$'||LA23_65=='&'||LA23_65=='+'||(LA23_65>='.' && LA23_65<='9')||LA23_65==';'||LA23_65=='='||LA23_65=='?'||(LA23_65>='A' && LA23_65<='Z')||(LA23_65>='^' && LA23_65<='z')||(LA23_65>='~' && LA23_65<='\uFFFF')) ) {s = 27;}\r
+                        if ( ((LA20_46>='A' && LA20_46<='Z')||(LA20_46>='a' && LA20_46<='z')) ) {s = 62;}\r
+\r
+                        else if ( (LA20_46=='.') ) {s = 45;}\r
+\r
+                        else if ( (LA20_46=='/') ) {s = 46;}\r
 \r
-                        else s = 72;\r
+                        else if ( ((LA20_46>='\u0000' && LA20_46<='\b')||(LA20_46>='\u000B' && LA20_46<='\f')||(LA20_46>='\u000E' && LA20_46<='\u001F')||LA20_46=='!'||LA20_46=='$'||LA20_46=='&'||LA20_46=='+'||(LA20_46>='0' && LA20_46<='9')||LA20_46==';'||LA20_46=='='||LA20_46=='?'||(LA20_46>='^' && LA20_46<='`')||(LA20_46>='~' && LA20_46<='\uFFFF')) ) {s = 48;}\r
+\r
+                        else s = 47;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
                     case 21 : \r
-                        int LA23_6 = input.LA(1);\r
+                        int LA20_34 = input.LA(1);\r
 \r
                         s = -1;\r
-                        if ( (LA23_6=='.') ) {s = 32;}\r
+                        if ( ((LA20_34>='0' && LA20_34<='9')) ) {s = 34;}\r
 \r
-                        else if ( ((LA23_6>='0' && LA23_6<='9')) ) {s = 34;}\r
+                        else if ( (LA20_34=='.') ) {s = 32;}\r
 \r
-                        else if ( (LA23_6=='E'||LA23_6=='e') ) {s = 33;}\r
+                        else if ( (LA20_34=='E'||LA20_34=='e') ) {s = 33;}\r
 \r
-                        else if ( ((LA23_6>='\u0000' && LA23_6<='\b')||(LA23_6>='\u000B' && LA23_6<='\f')||(LA23_6>='\u000E' && LA23_6<='\u001F')||LA23_6=='!'||LA23_6=='$'||LA23_6=='&'||LA23_6=='+'||LA23_6=='/'||LA23_6==';'||LA23_6=='='||LA23_6=='?'||(LA23_6>='A' && LA23_6<='D')||(LA23_6>='F' && LA23_6<='Z')||(LA23_6>='^' && LA23_6<='d')||(LA23_6>='f' && LA23_6<='z')||(LA23_6>='~' && LA23_6<='\uFFFF')) ) {s = 27;}\r
+                        else if ( ((LA20_34>='\u0000' && LA20_34<='\b')||(LA20_34>='\u000B' && LA20_34<='\f')||(LA20_34>='\u000E' && LA20_34<='\u001F')||LA20_34=='!'||LA20_34=='$'||LA20_34=='&'||LA20_34=='+'||LA20_34=='/'||LA20_34==';'||LA20_34=='='||LA20_34=='?'||(LA20_34>='A' && LA20_34<='D')||(LA20_34>='F' && LA20_34<='Z')||(LA20_34>='^' && LA20_34<='d')||(LA20_34>='f' && LA20_34<='z')||(LA20_34>='~' && LA20_34<='\uFFFF')) ) {s = 27;}\r
 \r
                         else s = 31;\r
 \r
                         if ( s>=0 ) return s;\r
                         break;\r
+                    case 22 : \r
+                        int LA20_61 = input.LA(1);\r
+\r
+                        s = -1;\r
+                        if ( (LA20_61=='/') ) {s = 60;}\r
+\r
+                        else if ( (LA20_61=='.') ) {s = 45;}\r
+\r
+                        else if ( ((LA20_61>='\u0000' && LA20_61<='\b')||(LA20_61>='\u000B' && LA20_61<='\f')||(LA20_61>='\u000E' && LA20_61<='\u001F')||LA20_61=='!'||LA20_61=='$'||LA20_61=='&'||LA20_61=='+'||(LA20_61>='0' && LA20_61<='9')||LA20_61==';'||LA20_61=='='||LA20_61=='?'||(LA20_61>='A' && LA20_61<='Z')||(LA20_61>='^' && LA20_61<='z')||(LA20_61>='~' && LA20_61<='\uFFFF')) ) {s = 61;}\r
+\r
+                        else if ( ((LA20_61>='\t' && LA20_61<='\n')||LA20_61=='\r'||LA20_61==' '||(LA20_61>='\"' && LA20_61<='#')||LA20_61=='%'||(LA20_61>='\'' && LA20_61<='*')||(LA20_61>=',' && LA20_61<='-')||LA20_61==':'||LA20_61=='<'||LA20_61=='>'||LA20_61=='@'||(LA20_61>='[' && LA20_61<=']')||(LA20_61>='{' && LA20_61<='}')) ) {s = 47;}\r
+\r
+                        else s = 27;\r
+\r
+                        if ( s>=0 ) return s;\r
+                        break;\r
             }\r
             NoViableAltException nvae =\r
-                new NoViableAltException(getDescription(), 23, _s, input);\r
+                new NoViableAltException(getDescription(), 20, _s, input);\r
             error(nvae);\r
             throw nvae;\r
         }\r
index 1bbe702..3f087dc 100644 (file)
@@ -1,4 +1,4 @@
-// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-08-06 11:41:05\r
+// $ANTLR 3.1.3 Mar 17, 2009 19:23:44 LensQuery.g 2009-08-06 15:20:40\r
 \r
 /*--------------------------------------------------------------------------\r
  *  Copyright 2009 Taro L. Saito\r
@@ -24,6 +24,8 @@
 //--------------------------------------\r
 package org.xerial.lens.relation.query.impl;\r
 \r
+import org.xerial.lens.relation.TupleIndex;\r
+\r
 \r
 import org.antlr.runtime.*;\r
 import java.util.Stack;\r
@@ -35,64 +37,65 @@ import org.antlr.runtime.tree.*;
 \r
 public class LensQueryParser extends Parser {\r
     public static final String[] tokenNames = new String[] {\r
-        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "QUERY", "RELATION", "COMPARE", "OPERATOR", "OPERAND", "PATTERNMATCH", "NODE", "NODEVALUE", "NAME", "VALUE", "LineBreakChar", "LineComment", "LineBreak", "Digit", "Letter", "HexDigit", "UnicodeChar", "EscapeSequence", "StringChar", "StringChar_s", "String", "Integer", "Frac", "Exp", "Double", "True", "False", "Null", "LBrace", "RBrace", "LBracket", "RBracket", "Lt", "Gt", "Leq", "Geq", "Eq", "Neq", "Match", "Regex", "Dot", "Comma", "Colon", "LParen", "RParen", "Star", "UnsafeUnicodeChar", "SafeFirstLetter", "SafeLetter", "ModuleName", "WhiteSpaces", "ModuleDef", "WhiteSpace", "QNameChar", "QName"\r
+        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "QUERY", "RELATION", "COMPARE", "OPERATOR", "OPERAND", "PATTERNMATCH", "NODE", "ALIAS", "NODEVALUE", "NAME", "VALUE", "INDEX", "LineBreakChar", "LineComment", "LineBreak", "Digit", "Letter", "HexDigit", "UnicodeChar", "EscapeSequence", "StringChar", "StringChar_s", "String", "Integer", "Frac", "Exp", "Double", "True", "False", "Null", "LBrace", "RBrace", "LBracket", "RBracket", "Lt", "Gt", "Leq", "Geq", "Eq", "Neq", "Match", "Regex", "Dot", "Comma", "Colon", "As", "LParen", "RParen", "Star", "UnsafeUnicodeChar", "SafeFirstLetter", "SafeLetter", "WhiteSpace", "QNameChar", "QName", "WhiteSpaces"\r
     };\r
+    public static final int INDEX=15;\r
     public static final int PATTERNMATCH=9;\r
-    public static final int RBrace=33;\r
-    public static final int Match=42;\r
-    public static final int LBracket=34;\r
-    public static final int Regex=43;\r
-    public static final int Digit=17;\r
-    public static final int Frac=26;\r
-    public static final int HexDigit=19;\r
+    public static final int Match=44;\r
+    public static final int RBrace=35;\r
+    public static final int Regex=45;\r
+    public static final int LBracket=36;\r
+    public static final int Digit=19;\r
+    public static final int Frac=28;\r
+    public static final int HexDigit=21;\r
     public static final int QUERY=4;\r
-    public static final int VALUE=13;\r
-    public static final int Letter=18;\r
-    public static final int Comma=45;\r
-    public static final int Dot=44;\r
-    public static final int EscapeSequence=21;\r
-    public static final int Integer=25;\r
+    public static final int ALIAS=11;\r
+    public static final int VALUE=14;\r
+    public static final int Letter=20;\r
+    public static final int Comma=47;\r
+    public static final int Dot=46;\r
+    public static final int EscapeSequence=23;\r
+    public static final int Integer=27;\r
     public static final int WhiteSpace=56;\r
     public static final int OPERATOR=7;\r
-    public static final int False=30;\r
-    public static final int Colon=46;\r
-    public static final int LineComment=15;\r
-    public static final int NODEVALUE=11;\r
-    public static final int ModuleName=53;\r
-    public static final int SafeFirstLetter=51;\r
-    public static final int Null=31;\r
-    public static final int Star=49;\r
-    public static final int Eq=40;\r
-    public static final int Exp=27;\r
+    public static final int False=32;\r
+    public static final int Colon=48;\r
+    public static final int LineComment=17;\r
+    public static final int NODEVALUE=12;\r
+    public static final int As=49;\r
+    public static final int SafeFirstLetter=54;\r
+    public static final int Null=33;\r
+    public static final int Star=52;\r
+    public static final int Eq=42;\r
+    public static final int Exp=29;\r
     public static final int QNameChar=57;\r
     public static final int RELATION=5;\r
-    public static final int Gt=37;\r
-    public static final int RParen=48;\r
-    public static final int UnicodeChar=20;\r
-    public static final int StringChar=22;\r
-    public static final int True=29;\r
+    public static final int Gt=39;\r
+    public static final int RParen=51;\r
+    public static final int UnicodeChar=22;\r
+    public static final int StringChar=24;\r
+    public static final int True=31;\r
     public static final int OPERAND=8;\r
-    public static final int LineBreak=16;\r
-    public static final int ModuleDef=55;\r
-    public static final int LParen=47;\r
-    public static final int String=24;\r
-    public static final int SafeLetter=52;\r
-    public static final int LineBreakChar=14;\r
+    public static final int LineBreak=18;\r
+    public static final int LParen=50;\r
+    public static final int String=26;\r
+    public static final int SafeLetter=55;\r
+    public static final int LineBreakChar=16;\r
     public static final int COMPARE=6;\r
     public static final int QName=58;\r
     public static final int EOF=-1;\r
-    public static final int Geq=39;\r
+    public static final int Geq=41;\r
     public static final int NODE=10;\r
-    public static final int StringChar_s=23;\r
-    public static final int Neq=41;\r
-    public static final int UnsafeUnicodeChar=50;\r
-    public static final int Double=28;\r
-    public static final int LBrace=32;\r
-    public static final int RBracket=35;\r
-    public static final int Lt=36;\r
-    public static final int NAME=12;\r
-    public static final int Leq=38;\r
-    public static final int WhiteSpaces=54;\r
+    public static final int StringChar_s=25;\r
+    public static final int Neq=43;\r
+    public static final int UnsafeUnicodeChar=53;\r
+    public static final int Double=30;\r
+    public static final int LBrace=34;\r
+    public static final int RBracket=37;\r
+    public static final int Lt=38;\r
+    public static final int NAME=13;\r
+    public static final int Leq=40;\r
+    public static final int WhiteSpaces=59;\r
 \r
     // delegates\r
     // delegators\r
@@ -119,13 +122,16 @@ public class LensQueryParser extends Parser {
     public String getGrammarFileName() { return "LensQuery.g"; }\r
 \r
 \r
+       private TupleIndex currentIndex = null;\r
+\r
+\r
     public static class expr_return extends ParserRuleReturnScope {\r
         Object tree;\r
         public Object getTree() { return tree; }\r
     };\r
 \r
     // $ANTLR start "expr"\r
-    // LensQuery.g:184:1: expr : relation ;\r
+    // LensQuery.g:191:1: expr : relation ;\r
     public final LensQueryParser.expr_return expr() throws RecognitionException {\r
         LensQueryParser.expr_return retval = new LensQueryParser.expr_return();\r
         retval.start = input.LT(1);\r
@@ -137,12 +143,12 @@ public class LensQueryParser extends Parser {
 \r
 \r
         try {\r
-            // LensQuery.g:184:5: ( relation )\r
-            // LensQuery.g:185:3: relation\r
+            // LensQuery.g:191:5: ( relation )\r
+            // LensQuery.g:192:3: relation\r
             {\r
             root_0 = (Object)adaptor.nil();\r
 \r
-            pushFollow(FOLLOW_relation_in_expr821);\r
+            pushFollow(FOLLOW_relation_in_expr806);\r
             relation1=relation();\r
 \r
             state._fsp--;\r
@@ -169,93 +175,374 @@ public class LensQueryParser extends Parser {
     }\r
     // $ANTLR end "expr"\r
 \r
+    protected static class relation_scope {\r
+        int nodeItemIndex;\r
+        TupleIndex relationIndex;\r
+    }\r
+    protected Stack relation_stack = new Stack();\r
+\r
     public static class relation_return extends ParserRuleReturnScope {\r
         Object tree;\r
         public Object getTree() { return tree; }\r
     };\r
 \r
     // $ANTLR start "relation"\r
-    // LensQuery.g:188:1: relation : QName LParen nodeItem ( Comma nodeItem )* RParen -> ^( RELATION NAME[$QName.text] ( nodeItem )+ ) ;\r
+    // LensQuery.g:195:1: relation : relation_i -> ^( RELATION relation_i INDEX[currentIndex.toString()] ) ;\r
     public final LensQueryParser.relation_return relation() throws RecognitionException {\r
+        relation_stack.push(new relation_scope());\r
         LensQueryParser.relation_return retval = new LensQueryParser.relation_return();\r
         retval.start = input.LT(1);\r
 \r
         Object root_0 = null;\r
 \r
-        Token QName2=null;\r
-        Token LParen3=null;\r
-        Token Comma5=null;\r
-        Token RParen7=null;\r
-        LensQueryParser.nodeItem_return nodeItem4 = null;\r
+        LensQueryParser.relation_i_return relation_i2 = null;\r
+\r
+\r
+        RewriteRuleSubtreeStream stream_relation_i=new RewriteRuleSubtreeStream(adaptor,"rule relation_i");\r
+\r
+          ((relation_scope)relation_stack.peek()).nodeItemIndex = 1;\r
+          if(currentIndex == null)\r
+            currentIndex = new TupleIndex(1);\r
+          else\r
+            currentIndex = new TupleIndex(currentIndex, 1); \r
+\r
+        try {\r
+            // LensQuery.g:213:4: ( relation_i -> ^( RELATION relation_i INDEX[currentIndex.toString()] ) )\r
+            // LensQuery.g:213:6: relation_i\r
+            {\r
+            pushFollow(FOLLOW_relation_i_in_relation840);\r
+            relation_i2=relation_i();\r
+\r
+            state._fsp--;\r
+\r
+            stream_relation_i.add(relation_i2.getTree());\r
+\r
+\r
+            // AST REWRITE\r
+            // elements: relation_i\r
+            // token labels: \r
+            // rule labels: retval\r
+            // token list labels: \r
+            // rule list labels: \r
+            // wildcard labels: \r
+            retval.tree = root_0;\r
+            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
+\r
+            root_0 = (Object)adaptor.nil();\r
+            // 213:17: -> ^( RELATION relation_i INDEX[currentIndex.toString()] )\r
+            {\r
+                // LensQuery.g:213:20: ^( RELATION relation_i INDEX[currentIndex.toString()] )\r
+                {\r
+                Object root_1 = (Object)adaptor.nil();\r
+                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RELATION, "RELATION"), root_1);\r
+\r
+                adaptor.addChild(root_1, stream_relation_i.nextTree());\r
+                adaptor.addChild(root_1, (Object)adaptor.create(INDEX, currentIndex.toString()));\r
+\r
+                adaptor.addChild(root_0, root_1);\r
+                }\r
+\r
+            }\r
+\r
+            retval.tree = root_0;\r
+            }\r
+\r
+            retval.stop = input.LT(-1);\r
+\r
+            retval.tree = (Object)adaptor.rulePostProcessing(root_0);\r
+            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
+\r
+\r
+              currentIndex = currentIndex.parent();\r
+\r
+        }\r
+        catch (RecognitionException re) {\r
+            reportError(re);\r
+            recover(input,re);\r
+       retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
+\r
+        }\r
+        finally {\r
+            relation_stack.pop();\r
+        }\r
+        return retval;\r
+    }\r
+    // $ANTLR end "relation"\r
+\r
+    public static class relation_i_return extends ParserRuleReturnScope {\r
+        Object tree;\r
+        public Object getTree() { return tree; }\r
+    };\r
+\r
+    // $ANTLR start "relation_i"\r
+    // LensQuery.g:216:1: relation_i : nodeName ( alias )? LParen nodeItem ( Comma nodeItem )* RParen ;\r
+    public final LensQueryParser.relation_i_return relation_i() throws RecognitionException {\r
+        LensQueryParser.relation_i_return retval = new LensQueryParser.relation_i_return();\r
+        retval.start = input.LT(1);\r
+\r
+        Object root_0 = null;\r
+\r
+        Token LParen5=null;\r
+        Token Comma7=null;\r
+        Token RParen9=null;\r
+        LensQueryParser.nodeName_return nodeName3 = null;\r
+\r
+        LensQueryParser.alias_return alias4 = null;\r
 \r
         LensQueryParser.nodeItem_return nodeItem6 = null;\r
 \r
+        LensQueryParser.nodeItem_return nodeItem8 = null;\r
+\r
+\r
+        Object LParen5_tree=null;\r
+        Object Comma7_tree=null;\r
+        Object RParen9_tree=null;\r
 \r
-        Object QName2_tree=null;\r
-        Object LParen3_tree=null;\r
-        Object Comma5_tree=null;\r
-        Object RParen7_tree=null;\r
-        RewriteRuleTokenStream stream_Comma=new RewriteRuleTokenStream(adaptor,"token Comma");\r
-        RewriteRuleTokenStream stream_RParen=new RewriteRuleTokenStream(adaptor,"token RParen");\r
-        RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");\r
-        RewriteRuleTokenStream stream_LParen=new RewriteRuleTokenStream(adaptor,"token LParen");\r
-        RewriteRuleSubtreeStream stream_nodeItem=new RewriteRuleSubtreeStream(adaptor,"rule nodeItem");\r
         try {\r
-            // LensQuery.g:188:9: ( QName LParen nodeItem ( Comma nodeItem )* RParen -> ^( RELATION NAME[$QName.text] ( nodeItem )+ ) )\r
-            // LensQuery.g:188:11: QName LParen nodeItem ( Comma nodeItem )* RParen\r
+            // LensQuery.g:216:11: ( nodeName ( alias )? LParen nodeItem ( Comma nodeItem )* RParen )\r
+            // LensQuery.g:216:13: nodeName ( alias )? LParen nodeItem ( Comma nodeItem )* RParen\r
             {\r
-            QName2=(Token)match(input,QName,FOLLOW_QName_in_relation834);  \r
-            stream_QName.add(QName2);\r
+            root_0 = (Object)adaptor.nil();\r
 \r
-            LParen3=(Token)match(input,LParen,FOLLOW_LParen_in_relation836);  \r
-            stream_LParen.add(LParen3);\r
+            pushFollow(FOLLOW_nodeName_in_relation_i859);\r
+            nodeName3=nodeName();\r
 \r
-            pushFollow(FOLLOW_nodeItem_in_relation838);\r
-            nodeItem4=nodeItem();\r
+            state._fsp--;\r
+\r
+            adaptor.addChild(root_0, nodeName3.getTree());\r
+            // LensQuery.g:216:22: ( alias )?\r
+            int alt1=2;\r
+            int LA1_0 = input.LA(1);\r
+\r
+            if ( (LA1_0==As) ) {\r
+                alt1=1;\r
+            }\r
+            switch (alt1) {\r
+                case 1 :\r
+                    // LensQuery.g:216:22: alias\r
+                    {\r
+                    pushFollow(FOLLOW_alias_in_relation_i861);\r
+                    alias4=alias();\r
+\r
+                    state._fsp--;\r
+\r
+                    adaptor.addChild(root_0, alias4.getTree());\r
+\r
+                    }\r
+                    break;\r
+\r
+            }\r
+\r
+            LParen5=(Token)match(input,LParen,FOLLOW_LParen_in_relation_i864); \r
+            pushFollow(FOLLOW_nodeItem_in_relation_i867);\r
+            nodeItem6=nodeItem();\r
 \r
             state._fsp--;\r
 \r
-            stream_nodeItem.add(nodeItem4.getTree());\r
-            // LensQuery.g:188:33: ( Comma nodeItem )*\r
-            loop1:\r
+            adaptor.addChild(root_0, nodeItem6.getTree());\r
+            // LensQuery.g:216:46: ( Comma nodeItem )*\r
+            loop2:\r
             do {\r
-                int alt1=2;\r
-                int LA1_0 = input.LA(1);\r
+                int alt2=2;\r
+                int LA2_0 = input.LA(1);\r
 \r
-                if ( (LA1_0==Comma) ) {\r
-                    alt1=1;\r
+                if ( (LA2_0==Comma) ) {\r
+                    alt2=1;\r
                 }\r
 \r
 \r
-                switch (alt1) {\r
+                switch (alt2) {\r
                case 1 :\r
-                   // LensQuery.g:188:34: Comma nodeItem\r
+                   // LensQuery.g:216:47: Comma nodeItem\r
                    {\r
-                   Comma5=(Token)match(input,Comma,FOLLOW_Comma_in_relation841);  \r
-                   stream_Comma.add(Comma5);\r
-\r
-                   pushFollow(FOLLOW_nodeItem_in_relation843);\r
-                   nodeItem6=nodeItem();\r
+                   Comma7=(Token)match(input,Comma,FOLLOW_Comma_in_relation_i870); \r
+                   pushFollow(FOLLOW_nodeItem_in_relation_i873);\r
+                   nodeItem8=nodeItem();\r
 \r
                    state._fsp--;\r
 \r
-                   stream_nodeItem.add(nodeItem6.getTree());\r
+                   adaptor.addChild(root_0, nodeItem8.getTree());\r
 \r
                    }\r
                    break;\r
 \r
                default :\r
-                   break loop1;\r
+                   break loop2;\r
                 }\r
             } while (true);\r
 \r
-            RParen7=(Token)match(input,RParen,FOLLOW_RParen_in_relation847);  \r
-            stream_RParen.add(RParen7);\r
+            RParen9=(Token)match(input,RParen,FOLLOW_RParen_in_relation_i877); \r
+\r
+            }\r
+\r
+            retval.stop = input.LT(-1);\r
+\r
+            retval.tree = (Object)adaptor.rulePostProcessing(root_0);\r
+            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
+\r
+        }\r
+        catch (RecognitionException re) {\r
+            reportError(re);\r
+            recover(input,re);\r
+       retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
+\r
+        }\r
+        finally {\r
+        }\r
+        return retval;\r
+    }\r
+    // $ANTLR end "relation_i"\r
+\r
+    public static class nodeName_return extends ParserRuleReturnScope {\r
+        Object tree;\r
+        public Object getTree() { return tree; }\r
+    };\r
+\r
+    // $ANTLR start "nodeName"\r
+    // LensQuery.g:218:1: fragment nodeName : ( QName -> NAME[$QName.text] | String -> NAME[$String.text] );\r
+    public final LensQueryParser.nodeName_return nodeName() throws RecognitionException {\r
+        LensQueryParser.nodeName_return retval = new LensQueryParser.nodeName_return();\r
+        retval.start = input.LT(1);\r
+\r
+        Object root_0 = null;\r
+\r
+        Token QName10=null;\r
+        Token String11=null;\r
+\r
+        Object QName10_tree=null;\r
+        Object String11_tree=null;\r
+        RewriteRuleTokenStream stream_String=new RewriteRuleTokenStream(adaptor,"token String");\r
+        RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");\r
+\r
+        try {\r
+            // LensQuery.g:220:3: ( QName -> NAME[$QName.text] | String -> NAME[$String.text] )\r
+            int alt3=2;\r
+            int LA3_0 = input.LA(1);\r
+\r
+            if ( (LA3_0==QName) ) {\r
+                alt3=1;\r
+            }\r
+            else if ( (LA3_0==String) ) {\r
+                alt3=2;\r
+            }\r
+            else {\r
+                NoViableAltException nvae =\r
+                    new NoViableAltException("", 3, 0, input);\r
+\r
+                throw nvae;\r
+            }\r
+            switch (alt3) {\r
+                case 1 :\r
+                    // LensQuery.g:220:5: QName\r
+                    {\r
+                    QName10=(Token)match(input,QName,FOLLOW_QName_in_nodeName890);  \r
+                    stream_QName.add(QName10);\r
+\r
+\r
+\r
+                    // AST REWRITE\r
+                    // elements: \r
+                    // token labels: \r
+                    // rule labels: retval\r
+                    // token list labels: \r
+                    // rule list labels: \r
+                    // wildcard labels: \r
+                    retval.tree = root_0;\r
+                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
+\r
+                    root_0 = (Object)adaptor.nil();\r
+                    // 220:11: -> NAME[$QName.text]\r
+                    {\r
+                        adaptor.addChild(root_0, (Object)adaptor.create(NAME, (QName10!=null?QName10.getText():null)));\r
+\r
+                    }\r
+\r
+                    retval.tree = root_0;\r
+                    }\r
+                    break;\r
+                case 2 :\r
+                    // LensQuery.g:221:5: String\r
+                    {\r
+                    String11=(Token)match(input,String,FOLLOW_String_in_nodeName901);  \r
+                    stream_String.add(String11);\r
+\r
+\r
+\r
+                    // AST REWRITE\r
+                    // elements: \r
+                    // token labels: \r
+                    // rule labels: retval\r
+                    // token list labels: \r
+                    // rule list labels: \r
+                    // wildcard labels: \r
+                    retval.tree = root_0;\r
+                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
+\r
+                    root_0 = (Object)adaptor.nil();\r
+                    // 221:12: -> NAME[$String.text]\r
+                    {\r
+                        adaptor.addChild(root_0, (Object)adaptor.create(NAME, (String11!=null?String11.getText():null)));\r
+\r
+                    }\r
+\r
+                    retval.tree = root_0;\r
+                    }\r
+                    break;\r
+\r
+            }\r
+            retval.stop = input.LT(-1);\r
+\r
+            retval.tree = (Object)adaptor.rulePostProcessing(root_0);\r
+            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
+\r
+        }\r
+        catch (RecognitionException re) {\r
+            reportError(re);\r
+            recover(input,re);\r
+       retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
+\r
+        }\r
+        finally {\r
+        }\r
+        return retval;\r
+    }\r
+    // $ANTLR end "nodeName"\r
+\r
+    public static class alias_return extends ParserRuleReturnScope {\r
+        Object tree;\r
+        public Object getTree() { return tree; }\r
+    };\r
+\r
+    // $ANTLR start "alias"\r
+    // LensQuery.g:224:1: fragment alias : As QName -> ALIAS[$QName.text] ;\r
+    public final LensQueryParser.alias_return alias() throws RecognitionException {\r
+        LensQueryParser.alias_return retval = new LensQueryParser.alias_return();\r
+        retval.start = input.LT(1);\r
+\r
+        Object root_0 = null;\r
+\r
+        Token As12=null;\r
+        Token QName13=null;\r
+\r
+        Object As12_tree=null;\r
+        Object QName13_tree=null;\r
+        RewriteRuleTokenStream stream_As=new RewriteRuleTokenStream(adaptor,"token As");\r
+        RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");\r
+\r
+        try {\r
+            // LensQuery.g:225:6: ( As QName -> ALIAS[$QName.text] )\r
+            // LensQuery.g:225:8: As QName\r
+            {\r
+            As12=(Token)match(input,As,FOLLOW_As_in_alias918);  \r
+            stream_As.add(As12);\r
+\r
+            QName13=(Token)match(input,QName,FOLLOW_QName_in_alias920);  \r
+            stream_QName.add(QName13);\r
 \r
 \r
 \r
             // AST REWRITE\r
-            // elements: nodeItem\r
+            // elements: \r
             // token labels: \r
             // rule labels: retval\r
             // token list labels: \r
@@ -265,25 +552,9 @@ public class LensQueryParser extends Parser {
             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
 \r
             root_0 = (Object)adaptor.nil();\r
-            // 189:3: -> ^( RELATION NAME[$QName.text] ( nodeItem )+ )\r
+            // 225:17: -> ALIAS[$QName.text]\r
             {\r
-                // LensQuery.g:189:6: ^( RELATION NAME[$QName.text] ( nodeItem )+ )\r
-                {\r
-                Object root_1 = (Object)adaptor.nil();\r
-                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RELATION, "RELATION"), root_1);\r
-\r
-                adaptor.addChild(root_1, (Object)adaptor.create(NAME, (QName2!=null?QName2.getText():null)));\r
-                if ( !(stream_nodeItem.hasNext()) ) {\r
-                    throw new RewriteEarlyExitException();\r
-                }\r
-                while ( stream_nodeItem.hasNext() ) {\r
-                    adaptor.addChild(root_1, stream_nodeItem.nextTree());\r
-\r
-                }\r
-                stream_nodeItem.reset();\r
-\r
-                adaptor.addChild(root_0, root_1);\r
-                }\r
+                adaptor.addChild(root_0, (Object)adaptor.create(ALIAS, (QName13!=null?QName13.getText():null)));\r
 \r
             }\r
 \r
@@ -306,7 +577,7 @@ public class LensQueryParser extends Parser {
         }\r
         return retval;\r
     }\r
-    // $ANTLR end "relation"\r
+    // $ANTLR end "alias"\r
 \r
     public static class nodeItem_return extends ParserRuleReturnScope {\r
         Object tree;\r
@@ -314,73 +585,203 @@ public class LensQueryParser extends Parser {
     };\r
 \r
     // $ANTLR start "nodeItem"\r
-    // LensQuery.g:192:1: fragment nodeItem : ( QName ( nodeValue )? -> ^( NODE NAME[$QName.text] ( nodeValue )? ) | relation );\r
+    // LensQuery.g:228:1: fragment nodeItem : ( nodeName ( alias )? ( nodeValue )? -> ^( NODE nodeName ( alias )? ( nodeValue )? INDEX[new TupleIndex(currentIndex, index).toString()] ) | relation );\r
     public final LensQueryParser.nodeItem_return nodeItem() throws RecognitionException {\r
         LensQueryParser.nodeItem_return retval = new LensQueryParser.nodeItem_return();\r
         retval.start = input.LT(1);\r
 \r
         Object root_0 = null;\r
 \r
-        Token QName8=null;\r
-        LensQueryParser.nodeValue_return nodeValue9 = null;\r
+        LensQueryParser.nodeName_return nodeName14 = null;\r
 \r
-        LensQueryParser.relation_return relation10 = null;\r
+        LensQueryParser.alias_return alias15 = null;\r
 \r
+        LensQueryParser.nodeValue_return nodeValue16 = null;\r
 \r
-        Object QName8_tree=null;\r
-        RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");\r
+        LensQueryParser.relation_return relation17 = null;\r
+\r
+\r
+        RewriteRuleSubtreeStream stream_nodeName=new RewriteRuleSubtreeStream(adaptor,"rule nodeName");\r
         RewriteRuleSubtreeStream stream_nodeValue=new RewriteRuleSubtreeStream(adaptor,"rule nodeValue");\r
+        RewriteRuleSubtreeStream stream_alias=new RewriteRuleSubtreeStream(adaptor,"rule alias");\r
+\r
+          int index = ((relation_scope)relation_stack.peek()).nodeItemIndex++;\r
+\r
         try {\r
-            // LensQuery.g:194:3: ( QName ( nodeValue )? -> ^( NODE NAME[$QName.text] ( nodeValue )? ) | relation )\r
-            int alt3=2;\r
-            int LA3_0 = input.LA(1);\r
+            // LensQuery.g:233:3: ( nodeName ( alias )? ( nodeValue )? -> ^( NODE nodeName ( alias )? ( nodeValue )? INDEX[new TupleIndex(currentIndex, index).toString()] ) | relation )\r
+            int alt6=2;\r
+            int LA6_0 = input.LA(1);\r
 \r
-            if ( (LA3_0==QName) ) {\r
-                int LA3_1 = input.LA(2);\r
+            if ( (LA6_0==QName) ) {\r
+                switch ( input.LA(2) ) {\r
+                case As:\r
+                    {\r
+                    int LA6_3 = input.LA(3);\r
 \r
-                if ( (LA3_1==LParen) ) {\r
-                    alt3=2;\r
-                }\r
-                else if ( ((LA3_1>=Lt && LA3_1<=Match)||(LA3_1>=Comma && LA3_1<=Colon)||LA3_1==RParen) ) {\r
-                    alt3=1;\r
+                    if ( (LA6_3==QName) ) {\r
+                        int LA6_6 = input.LA(4);\r
+\r
+                        if ( ((LA6_6>=Lt && LA6_6<=Match)||(LA6_6>=Comma && LA6_6<=Colon)||LA6_6==RParen) ) {\r
+                            alt6=1;\r
+                        }\r
+                        else if ( (LA6_6==LParen) ) {\r
+                            alt6=2;\r
+                        }\r
+                        else {\r
+                            NoViableAltException nvae =\r
+                                new NoViableAltException("", 6, 6, input);\r
+\r
+                            throw nvae;\r
+                        }\r
+                    }\r
+                    else {\r
+                        NoViableAltException nvae =\r
+                            new NoViableAltException("", 6, 3, input);\r
+\r
+                        throw nvae;\r
+                    }\r
+                    }\r
+                    break;\r
+                case Lt:\r
+                case Gt:\r
+                case Leq:\r
+                case Geq:\r
+                case Eq:\r
+                case Neq:\r
+                case Match:\r
+                case Comma:\r
+                case Colon:\r
+                case RParen:\r
+                    {\r
+                    alt6=1;\r
+                    }\r
+                    break;\r
+                case LParen:\r
+                    {\r
+                    alt6=2;\r
+                    }\r
+                    break;\r
+                default:\r
+                    NoViableAltException nvae =\r
+                        new NoViableAltException("", 6, 1, input);\r
+\r
+                    throw nvae;\r
                 }\r
-                else {\r
+\r
+            }\r
+            else if ( (LA6_0==String) ) {\r
+                switch ( input.LA(2) ) {\r
+                case As:\r
+                    {\r
+                    int LA6_3 = input.LA(3);\r
+\r
+                    if ( (LA6_3==QName) ) {\r
+                        int LA6_6 = input.LA(4);\r
+\r
+                        if ( ((LA6_6>=Lt && LA6_6<=Match)||(LA6_6>=Comma && LA6_6<=Colon)||LA6_6==RParen) ) {\r
+                            alt6=1;\r
+                        }\r
+                        else if ( (LA6_6==LParen) ) {\r
+                            alt6=2;\r
+                        }\r
+                        else {\r
+                            NoViableAltException nvae =\r
+                                new NoViableAltException("", 6, 6, input);\r
+\r
+                            throw nvae;\r
+                        }\r
+                    }\r
+                    else {\r
+                        NoViableAltException nvae =\r
+                            new NoViableAltException("", 6, 3, input);\r
+\r
+                        throw nvae;\r
+                    }\r
+                    }\r
+                    break;\r
+                case LParen:\r
+                    {\r
+                    alt6=2;\r
+                    }\r
+                    break;\r
+                case Lt:\r
+                case Gt:\r
+                case Leq:\r
+                case Geq:\r
+                case Eq:\r
+                case Neq:\r
+                case Match:\r
+                case Comma:\r
+                case Colon:\r
+                case RParen:\r
+                    {\r
+                    alt6=1;\r
+                    }\r
+                    break;\r
+                default:\r
                     NoViableAltException nvae =\r
-                        new NoViableAltException("", 3, 1, input);\r
+                        new NoViableAltException("", 6, 2, input);\r
 \r
                     throw nvae;\r
                 }\r
+\r
             }\r
             else {\r
                 NoViableAltException nvae =\r
-                    new NoViableAltException("", 3, 0, input);\r
+                    new NoViableAltException("", 6, 0, input);\r
 \r
                 throw nvae;\r
             }\r
-            switch (alt3) {\r
+            switch (alt6) {\r
                 case 1 :\r
-                    // LensQuery.g:194:5: QName ( nodeValue )?\r
+                    // LensQuery.g:233:5: nodeName ( alias )? ( nodeValue )?\r
                     {\r
-                    QName8=(Token)match(input,QName,FOLLOW_QName_in_nodeItem876);  \r
-                    stream_QName.add(QName8);\r
+                    pushFollow(FOLLOW_nodeName_in_nodeItem945);\r
+                    nodeName14=nodeName();\r
+\r
+                    state._fsp--;\r
+\r
+                    stream_nodeName.add(nodeName14.getTree());\r
+                    // LensQuery.g:233:14: ( alias )?\r
+                    int alt4=2;\r
+                    int LA4_0 = input.LA(1);\r
+\r
+                    if ( (LA4_0==As) ) {\r
+                        alt4=1;\r
+                    }\r
+                    switch (alt4) {\r
+                        case 1 :\r
+                            // LensQuery.g:233:14: alias\r
+                            {\r
+                            pushFollow(FOLLOW_alias_in_nodeItem947);\r
+                            alias15=alias();\r
+\r
+                            state._fsp--;\r
 \r
-                    // LensQuery.g:194:11: ( nodeValue )?\r
-                    int alt2=2;\r
-                    int LA2_0 = input.LA(1);\r
+                            stream_alias.add(alias15.getTree());\r
+\r
+                            }\r
+                            break;\r
 \r
-                    if ( ((LA2_0>=Lt && LA2_0<=Match)||LA2_0==Colon) ) {\r
-                        alt2=1;\r
                     }\r
-                    switch (alt2) {\r
+\r
+                    // LensQuery.g:233:21: ( nodeValue )?\r
+                    int alt5=2;\r
+                    int LA5_0 = input.LA(1);\r
+\r
+                    if ( ((LA5_0>=Lt && LA5_0<=Match)||LA5_0==Colon) ) {\r
+                        alt5=1;\r
+                    }\r
+                    switch (alt5) {\r
                         case 1 :\r
-                            // LensQuery.g:194:11: nodeValue\r
+                            // LensQuery.g:233:21: nodeValue\r
                             {\r
-                            pushFollow(FOLLOW_nodeValue_in_nodeItem878);\r
-                            nodeValue9=nodeValue();\r
+                            pushFollow(FOLLOW_nodeValue_in_nodeItem950);\r
+                            nodeValue16=nodeValue();\r
 \r
                             state._fsp--;\r
 \r
-                            stream_nodeValue.add(nodeValue9.getTree());\r
+                            stream_nodeValue.add(nodeValue16.getTree());\r
 \r
                             }\r
                             break;\r
@@ -390,7 +791,7 @@ public class LensQueryParser extends Parser {
 \r
 \r
                     // AST REWRITE\r
-                    // elements: nodeValue\r
+                    // elements: alias, nodeValue, nodeName\r
                     // token labels: \r
                     // rule labels: retval\r
                     // token list labels: \r
@@ -400,20 +801,27 @@ public class LensQueryParser extends Parser {
                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
 \r
                     root_0 = (Object)adaptor.nil();\r
-                    // 195:5: -> ^( NODE NAME[$QName.text] ( nodeValue )? )\r
+                    // 234:5: -> ^( NODE nodeName ( alias )? ( nodeValue )? INDEX[new TupleIndex(currentIndex, index).toString()] )\r
                     {\r
-                        // LensQuery.g:195:8: ^( NODE NAME[$QName.text] ( nodeValue )? )\r
+                        // LensQuery.g:234:8: ^( NODE nodeName ( alias )? ( nodeValue )? INDEX[new TupleIndex(currentIndex, index).toString()] )\r
                         {\r
                         Object root_1 = (Object)adaptor.nil();\r
                         root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(NODE, "NODE"), root_1);\r
 \r
-                        adaptor.addChild(root_1, (Object)adaptor.create(NAME, (QName8!=null?QName8.getText():null)));\r
-                        // LensQuery.g:195:33: ( nodeValue )?\r
+                        adaptor.addChild(root_1, stream_nodeName.nextTree());\r
+                        // LensQuery.g:234:24: ( alias )?\r
+                        if ( stream_alias.hasNext() ) {\r
+                            adaptor.addChild(root_1, stream_alias.nextTree());\r
+\r
+                        }\r
+                        stream_alias.reset();\r
+                        // LensQuery.g:234:31: ( nodeValue )?\r
                         if ( stream_nodeValue.hasNext() ) {\r
                             adaptor.addChild(root_1, stream_nodeValue.nextTree());\r
 \r
                         }\r
                         stream_nodeValue.reset();\r
+                        adaptor.addChild(root_1, (Object)adaptor.create(INDEX, new TupleIndex(currentIndex, index).toString()));\r
 \r
                         adaptor.addChild(root_0, root_1);\r
                         }\r
@@ -424,16 +832,16 @@ public class LensQueryParser extends Parser {
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:196:5: relation\r
+                    // LensQuery.g:235:5: relation\r
                     {\r
                     root_0 = (Object)adaptor.nil();\r
 \r
-                    pushFollow(FOLLOW_relation_in_nodeItem902);\r
-                    relation10=relation();\r
+                    pushFollow(FOLLOW_relation_in_nodeItem979);\r
+                    relation17=relation();\r
 \r
                     state._fsp--;\r
 \r
-                    adaptor.addChild(root_0, relation10.getTree());\r
+                    adaptor.addChild(root_0, relation17.getTree());\r
 \r
                     }\r
                     break;\r
@@ -463,27 +871,27 @@ public class LensQueryParser extends Parser {
     };\r
 \r
     // $ANTLR start "value"\r
-    // LensQuery.g:199:1: fragment value : ( String | Integer | Double );\r
+    // LensQuery.g:238:1: fragment value : ( String | Integer | Double | QName );\r
     public final LensQueryParser.value_return value() throws RecognitionException {\r
         LensQueryParser.value_return retval = new LensQueryParser.value_return();\r
         retval.start = input.LT(1);\r
 \r
         Object root_0 = null;\r
 \r
-        Token set11=null;\r
+        Token set18=null;\r
 \r
-        Object set11_tree=null;\r
+        Object set18_tree=null;\r
 \r
         try {\r
-            // LensQuery.g:200:6: ( String | Integer | Double )\r
+            // LensQuery.g:240:3: ( String | Integer | Double | QName )\r
             // LensQuery.g:\r
             {\r
             root_0 = (Object)adaptor.nil();\r
 \r
-            set11=(Token)input.LT(1);\r
-            if ( (input.LA(1)>=String && input.LA(1)<=Integer)||input.LA(1)==Double ) {\r
+            set18=(Token)input.LT(1);\r
+            if ( (input.LA(1)>=String && input.LA(1)<=Integer)||input.LA(1)==Double||input.LA(1)==QName ) {\r
                 input.consume();\r
-                adaptor.addChild(root_0, (Object)adaptor.create(set11));\r
+                adaptor.addChild(root_0, (Object)adaptor.create(set18));\r
                 state.errorRecovery=false;\r
             }\r
             else {\r
@@ -518,52 +926,52 @@ public class LensQueryParser extends Parser {
     };\r
 \r
     // $ANTLR start "nodeValue"\r
-    // LensQuery.g:202:1: fragment nodeValue : ( Colon value -> NODEVALUE[$value.text] | nodeCmp );\r
+    // LensQuery.g:243:1: fragment nodeValue : ( Colon value -> NODEVALUE[$value.text] | nodeCmp );\r
     public final LensQueryParser.nodeValue_return nodeValue() throws RecognitionException {\r
         LensQueryParser.nodeValue_return retval = new LensQueryParser.nodeValue_return();\r
         retval.start = input.LT(1);\r
 \r
         Object root_0 = null;\r
 \r
-        Token Colon12=null;\r
-        LensQueryParser.value_return value13 = null;\r
+        Token Colon19=null;\r
+        LensQueryParser.value_return value20 = null;\r
 \r
-        LensQueryParser.nodeCmp_return nodeCmp14 = null;\r
+        LensQueryParser.nodeCmp_return nodeCmp21 = null;\r
 \r
 \r
-        Object Colon12_tree=null;\r
+        Object Colon19_tree=null;\r
         RewriteRuleTokenStream stream_Colon=new RewriteRuleTokenStream(adaptor,"token Colon");\r
         RewriteRuleSubtreeStream stream_value=new RewriteRuleSubtreeStream(adaptor,"rule value");\r
         try {\r
-            // LensQuery.g:204:3: ( Colon value -> NODEVALUE[$value.text] | nodeCmp )\r
-            int alt4=2;\r
-            int LA4_0 = input.LA(1);\r
+            // LensQuery.g:245:3: ( Colon value -> NODEVALUE[$value.text] | nodeCmp )\r
+            int alt7=2;\r
+            int LA7_0 = input.LA(1);\r
 \r
-            if ( (LA4_0==Colon) ) {\r
-                alt4=1;\r
+            if ( (LA7_0==Colon) ) {\r
+                alt7=1;\r
             }\r
-            else if ( ((LA4_0>=Lt && LA4_0<=Match)) ) {\r
-                alt4=2;\r
+            else if ( ((LA7_0>=Lt && LA7_0<=Match)) ) {\r
+                alt7=2;\r
             }\r
             else {\r
                 NoViableAltException nvae =\r
-                    new NoViableAltException("", 4, 0, input);\r
+                    new NoViableAltException("", 7, 0, input);\r
 \r
                 throw nvae;\r
             }\r
-            switch (alt4) {\r
+            switch (alt7) {\r
                 case 1 :\r
-                    // LensQuery.g:204:5: Colon value\r
+                    // LensQuery.g:245:5: Colon value\r
                     {\r
-                    Colon12=(Token)match(input,Colon,FOLLOW_Colon_in_nodeValue940);  \r
-                    stream_Colon.add(Colon12);\r
+                    Colon19=(Token)match(input,Colon,FOLLOW_Colon_in_nodeValue1028);  \r
+                    stream_Colon.add(Colon19);\r
 \r
-                    pushFollow(FOLLOW_value_in_nodeValue942);\r
-                    value13=value();\r
+                    pushFollow(FOLLOW_value_in_nodeValue1030);\r
+                    value20=value();\r
 \r
                     state._fsp--;\r
 \r
-                    stream_value.add(value13.getTree());\r
+                    stream_value.add(value20.getTree());\r
 \r
 \r
                     // AST REWRITE\r
@@ -577,9 +985,9 @@ public class LensQueryParser extends Parser {
                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
 \r
                     root_0 = (Object)adaptor.nil();\r
-                    // 204:17: -> NODEVALUE[$value.text]\r
+                    // 245:17: -> NODEVALUE[$value.text]\r
                     {\r
-                        adaptor.addChild(root_0, (Object)adaptor.create(NODEVALUE, (value13!=null?input.toString(value13.start,value13.stop):null)));\r
+                        adaptor.addChild(root_0, (Object)adaptor.create(NODEVALUE, (value20!=null?input.toString(value20.start,value20.stop):null)));\r
 \r
                     }\r
 \r
@@ -587,16 +995,16 @@ public class LensQueryParser extends Parser {
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:205:5: nodeCmp\r
+                    // LensQuery.g:246:5: nodeCmp\r
                     {\r
                     root_0 = (Object)adaptor.nil();\r
 \r
-                    pushFollow(FOLLOW_nodeCmp_in_nodeValue953);\r
-                    nodeCmp14=nodeCmp();\r
+                    pushFollow(FOLLOW_nodeCmp_in_nodeValue1041);\r
+                    nodeCmp21=nodeCmp();\r
 \r
                     state._fsp--;\r
 \r
-                    adaptor.addChild(root_0, nodeCmp14.getTree());\r
+                    adaptor.addChild(root_0, nodeCmp21.getTree());\r
 \r
                     }\r
                     break;\r
@@ -626,59 +1034,59 @@ public class LensQueryParser extends Parser {
     };\r
 \r
     // $ANTLR start "nodeCmp"\r
-    // LensQuery.g:208:1: fragment nodeCmp : ( cmpOp value -> ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] ) | Match Regex -> ^( PATTERNMATCH OPERAND[$Regex.text] ) );\r
+    // LensQuery.g:249:1: fragment nodeCmp : ( cmpOp value -> ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] ) | Match Regex -> ^( PATTERNMATCH OPERAND[$Regex.text] ) );\r
     public final LensQueryParser.nodeCmp_return nodeCmp() throws RecognitionException {\r
         LensQueryParser.nodeCmp_return retval = new LensQueryParser.nodeCmp_return();\r
         retval.start = input.LT(1);\r
 \r
         Object root_0 = null;\r
 \r
-        Token Match17=null;\r
-        Token Regex18=null;\r
-        LensQueryParser.cmpOp_return cmpOp15 = null;\r
+        Token Match24=null;\r
+        Token Regex25=null;\r
+        LensQueryParser.cmpOp_return cmpOp22 = null;\r
 \r
-        LensQueryParser.value_return value16 = null;\r
+        LensQueryParser.value_return value23 = null;\r
 \r
 \r
-        Object Match17_tree=null;\r
-        Object Regex18_tree=null;\r
+        Object Match24_tree=null;\r
+        Object Regex25_tree=null;\r
         RewriteRuleTokenStream stream_Match=new RewriteRuleTokenStream(adaptor,"token Match");\r
         RewriteRuleTokenStream stream_Regex=new RewriteRuleTokenStream(adaptor,"token Regex");\r
         RewriteRuleSubtreeStream stream_value=new RewriteRuleSubtreeStream(adaptor,"rule value");\r
         RewriteRuleSubtreeStream stream_cmpOp=new RewriteRuleSubtreeStream(adaptor,"rule cmpOp");\r
         try {\r
-            // LensQuery.g:210:3: ( cmpOp value -> ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] ) | Match Regex -> ^( PATTERNMATCH OPERAND[$Regex.text] ) )\r
-            int alt5=2;\r
-            int LA5_0 = input.LA(1);\r
+            // LensQuery.g:251:3: ( cmpOp value -> ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] ) | Match Regex -> ^( PATTERNMATCH OPERAND[$Regex.text] ) )\r
+            int alt8=2;\r
+            int LA8_0 = input.LA(1);\r
 \r
-            if ( ((LA5_0>=Lt && LA5_0<=Neq)) ) {\r
-                alt5=1;\r
+            if ( ((LA8_0>=Lt && LA8_0<=Neq)) ) {\r
+                alt8=1;\r
             }\r
-            else if ( (LA5_0==Match) ) {\r
-                alt5=2;\r
+            else if ( (LA8_0==Match) ) {\r
+                alt8=2;\r
             }\r
             else {\r
                 NoViableAltException nvae =\r
-                    new NoViableAltException("", 5, 0, input);\r
+                    new NoViableAltException("", 8, 0, input);\r
 \r
                 throw nvae;\r
             }\r
-            switch (alt5) {\r
+            switch (alt8) {\r
                 case 1 :\r
-                    // LensQuery.g:210:5: cmpOp value\r
+                    // LensQuery.g:251:5: cmpOp value\r
                     {\r
-                    pushFollow(FOLLOW_cmpOp_in_nodeCmp973);\r
-                    cmpOp15=cmpOp();\r
+                    pushFollow(FOLLOW_cmpOp_in_nodeCmp1061);\r
+                    cmpOp22=cmpOp();\r
 \r
                     state._fsp--;\r
 \r
-                    stream_cmpOp.add(cmpOp15.getTree());\r
-                    pushFollow(FOLLOW_value_in_nodeCmp975);\r
-                    value16=value();\r
+                    stream_cmpOp.add(cmpOp22.getTree());\r
+                    pushFollow(FOLLOW_value_in_nodeCmp1063);\r
+                    value23=value();\r
 \r
                     state._fsp--;\r
 \r
-                    stream_value.add(value16.getTree());\r
+                    stream_value.add(value23.getTree());\r
 \r
 \r
                     // AST REWRITE\r
@@ -692,15 +1100,15 @@ public class LensQueryParser extends Parser {
                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
 \r
                     root_0 = (Object)adaptor.nil();\r
-                    // 210:17: -> ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] )\r
+                    // 251:17: -> ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] )\r
                     {\r
-                        // LensQuery.g:210:20: ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] )\r
+                        // LensQuery.g:251:20: ^( COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text] )\r
                         {\r
                         Object root_1 = (Object)adaptor.nil();\r
                         root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(COMPARE, "COMPARE"), root_1);\r
 \r
-                        adaptor.addChild(root_1, (Object)adaptor.create(OPERATOR, (cmpOp15!=null?input.toString(cmpOp15.start,cmpOp15.stop):null)));\r
-                        adaptor.addChild(root_1, (Object)adaptor.create(OPERAND, (value16!=null?input.toString(value16.start,value16.stop):null)));\r
+                        adaptor.addChild(root_1, (Object)adaptor.create(OPERATOR, (cmpOp22!=null?input.toString(cmpOp22.start,cmpOp22.stop):null)));\r
+                        adaptor.addChild(root_1, (Object)adaptor.create(OPERAND, (value23!=null?input.toString(value23.start,value23.stop):null)));\r
 \r
                         adaptor.addChild(root_0, root_1);\r
                         }\r
@@ -711,13 +1119,13 @@ public class LensQueryParser extends Parser {
                     }\r
                     break;\r
                 case 2 :\r
-                    // LensQuery.g:211:5: Match Regex\r
+                    // LensQuery.g:252:5: Match Regex\r
                     {\r
-                    Match17=(Token)match(input,Match,FOLLOW_Match_in_nodeCmp993);  \r
-                    stream_Match.add(Match17);\r
+                    Match24=(Token)match(input,Match,FOLLOW_Match_in_nodeCmp1081);  \r
+                    stream_Match.add(Match24);\r
 \r
-                    Regex18=(Token)match(input,Regex,FOLLOW_Regex_in_nodeCmp995);  \r
-                    stream_Regex.add(Regex18);\r
+                    Regex25=(Token)match(input,Regex,FOLLOW_Regex_in_nodeCmp1083);  \r
+                    stream_Regex.add(Regex25);\r
 \r
 \r
 \r
@@ -732,14 +1140,14 @@ public class LensQueryParser extends Parser {
                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
 \r
                     root_0 = (Object)adaptor.nil();\r
-                    // 211:17: -> ^( PATTERNMATCH OPERAND[$Regex.text] )\r
+                    // 252:17: -> ^( PATTERNMATCH OPERAND[$Regex.text] )\r
                     {\r
-                        // LensQuery.g:211:20: ^( PATTERNMATCH OPERAND[$Regex.text] )\r
+                        // LensQuery.g:252:20: ^( PATTERNMATCH OPERAND[$Regex.text] )\r
                         {\r
                         Object root_1 = (Object)adaptor.nil();\r
                         root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(PATTERNMATCH, "PATTERNMATCH"), root_1);\r
 \r
-                        adaptor.addChild(root_1, (Object)adaptor.create(OPERAND, (Regex18!=null?Regex18.getText():null)));\r
+                        adaptor.addChild(root_1, (Object)adaptor.create(OPERAND, (Regex25!=null?Regex25.getText():null)));\r
 \r
                         adaptor.addChild(root_0, root_1);\r
                         }\r
@@ -775,27 +1183,27 @@ public class LensQueryParser extends Parser {
     };\r
 \r
     // $ANTLR start "cmpOp"\r
-    // LensQuery.g:214:1: fragment cmpOp : ( Lt | Gt | Eq | Leq | Geq | Neq ) ;\r
+    // LensQuery.g:255:1: fragment cmpOp : ( Lt | Gt | Eq | Leq | Geq | Neq ) ;\r
     public final LensQueryParser.cmpOp_return cmpOp() throws RecognitionException {\r
         LensQueryParser.cmpOp_return retval = new LensQueryParser.cmpOp_return();\r
         retval.start = input.LT(1);\r
 \r
         Object root_0 = null;\r
 \r
-        Token set19=null;\r
+        Token set26=null;\r
 \r
-        Object set19_tree=null;\r
+        Object set26_tree=null;\r
 \r
         try {\r
-            // LensQuery.g:215:6: ( ( Lt | Gt | Eq | Leq | Geq | Neq ) )\r
-            // LensQuery.g:215:8: ( Lt | Gt | Eq | Leq | Geq | Neq )\r
+            // LensQuery.g:256:6: ( ( Lt | Gt | Eq | Leq | Geq | Neq ) )\r
+            // LensQuery.g:256:8: ( Lt | Gt | Eq | Leq | Geq | Neq )\r
             {\r
             root_0 = (Object)adaptor.nil();\r
 \r
-            set19=(Token)input.LT(1);\r
+            set26=(Token)input.LT(1);\r
             if ( (input.LA(1)>=Lt && input.LA(1)<=Neq) ) {\r
                 input.consume();\r
-                adaptor.addChild(root_0, (Object)adaptor.create(set19));\r
+                adaptor.addChild(root_0, (Object)adaptor.create(set26));\r
                 state.errorRecovery=false;\r
             }\r
             else {\r
@@ -829,24 +1237,31 @@ public class LensQueryParser extends Parser {
 \r
  \r
 \r
-    public static final BitSet FOLLOW_relation_in_expr821 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_QName_in_relation834 = new BitSet(new long[]{0x0000800000000000L});\r
-    public static final BitSet FOLLOW_LParen_in_relation836 = new BitSet(new long[]{0x0400000000000000L});\r
-    public static final BitSet FOLLOW_nodeItem_in_relation838 = new BitSet(new long[]{0x0001200000000000L});\r
-    public static final BitSet FOLLOW_Comma_in_relation841 = new BitSet(new long[]{0x0400000000000000L});\r
-    public static final BitSet FOLLOW_nodeItem_in_relation843 = new BitSet(new long[]{0x0001200000000000L});\r
-    public static final BitSet FOLLOW_RParen_in_relation847 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_QName_in_nodeItem876 = new BitSet(new long[]{0x000047F000000002L});\r
-    public static final BitSet FOLLOW_nodeValue_in_nodeItem878 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_relation_in_nodeItem902 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_relation_in_expr806 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_relation_i_in_relation840 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_nodeName_in_relation_i859 = new BitSet(new long[]{0x0006000000000000L});\r
+    public static final BitSet FOLLOW_alias_in_relation_i861 = new BitSet(new long[]{0x0004000000000000L});\r
+    public static final BitSet FOLLOW_LParen_in_relation_i864 = new BitSet(new long[]{0x0400000004000000L});\r
+    public static final BitSet FOLLOW_nodeItem_in_relation_i867 = new BitSet(new long[]{0x0008800000000000L});\r
+    public static final BitSet FOLLOW_Comma_in_relation_i870 = new BitSet(new long[]{0x0400000004000000L});\r
+    public static final BitSet FOLLOW_nodeItem_in_relation_i873 = new BitSet(new long[]{0x0008800000000000L});\r
+    public static final BitSet FOLLOW_RParen_in_relation_i877 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_QName_in_nodeName890 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_String_in_nodeName901 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_As_in_alias918 = new BitSet(new long[]{0x0400000000000000L});\r
+    public static final BitSet FOLLOW_QName_in_alias920 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_nodeName_in_nodeItem945 = new BitSet(new long[]{0x00031FC000000002L});\r
+    public static final BitSet FOLLOW_alias_in_nodeItem947 = new BitSet(new long[]{0x00011FC000000002L});\r
+    public static final BitSet FOLLOW_nodeValue_in_nodeItem950 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_relation_in_nodeItem979 = new BitSet(new long[]{0x0000000000000002L});\r
     public static final BitSet FOLLOW_set_in_value0 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_Colon_in_nodeValue940 = new BitSet(new long[]{0x0000000013000000L});\r
-    public static final BitSet FOLLOW_value_in_nodeValue942 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_nodeCmp_in_nodeValue953 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_cmpOp_in_nodeCmp973 = new BitSet(new long[]{0x0000000013000000L});\r
-    public static final BitSet FOLLOW_value_in_nodeCmp975 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_Match_in_nodeCmp993 = new BitSet(new long[]{0x0000080000000000L});\r
-    public static final BitSet FOLLOW_Regex_in_nodeCmp995 = new BitSet(new long[]{0x0000000000000002L});\r
-    public static final BitSet FOLLOW_set_in_cmpOp1020 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_Colon_in_nodeValue1028 = new BitSet(new long[]{0x040000004C000000L});\r
+    public static final BitSet FOLLOW_value_in_nodeValue1030 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_nodeCmp_in_nodeValue1041 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_cmpOp_in_nodeCmp1061 = new BitSet(new long[]{0x040000004C000000L});\r
+    public static final BitSet FOLLOW_value_in_nodeCmp1063 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_Match_in_nodeCmp1081 = new BitSet(new long[]{0x0000200000000000L});\r
+    public static final BitSet FOLLOW_Regex_in_nodeCmp1083 = new BitSet(new long[]{0x0000000000000002L});\r
+    public static final BitSet FOLLOW_set_in_cmpOp1108 = new BitSet(new long[]{0x0000000000000002L});\r
 \r
 }
\ No newline at end of file
diff --git a/src/main/java/org/xerial/lens/relation/query/lang/LensQuery.tokens b/src/main/java/org/xerial/lens/relation/query/lang/LensQuery.tokens
new file mode 100644 (file)
index 0000000..c2f2c46
--- /dev/null
@@ -0,0 +1,56 @@
+INDEX=15\r
+PATTERNMATCH=9\r
+Match=44\r
+RBrace=35\r
+Regex=45\r
+LBracket=36\r
+Digit=19\r
+Frac=28\r
+HexDigit=21\r
+QUERY=4\r
+ALIAS=11\r
+VALUE=14\r
+Letter=20\r
+Comma=47\r
+Dot=46\r
+EscapeSequence=23\r
+Integer=27\r
+WhiteSpace=56\r
+OPERATOR=7\r
+False=32\r
+Colon=48\r
+LineComment=17\r
+NODEVALUE=12\r
+As=49\r
+SafeFirstLetter=54\r
+Null=33\r
+Star=52\r
+Eq=42\r
+Exp=29\r
+QNameChar=57\r
+RELATION=5\r
+Gt=39\r
+RParen=51\r
+UnicodeChar=22\r
+StringChar=24\r
+True=31\r
+OPERAND=8\r
+LineBreak=18\r
+LParen=50\r
+String=26\r
+SafeLetter=55\r
+LineBreakChar=16\r
+COMPARE=6\r
+QName=58\r
+Geq=41\r
+NODE=10\r
+StringChar_s=25\r
+Neq=43\r
+UnsafeUnicodeChar=53\r
+Double=30\r
+LBrace=34\r
+RBracket=37\r
+Lt=38\r
+NAME=13\r
+Leq=40\r
+WhiteSpaces=59\r
index 3947b45..b2f1436 100644 (file)
@@ -24,7 +24,7 @@
 //--------------------------------------\r
 package org.xerial.lens.relation.query.lang;\r
 \r
-import java.util.ArrayList;\r
+import java.util.List;\r
 \r
 import org.antlr.runtime.ANTLRStringStream;\r
 import org.antlr.runtime.CommonTokenStream;\r
@@ -33,8 +33,11 @@ import org.antlr.runtime.tree.Tree;
 import org.xerial.core.XerialErrorCode;\r
 import org.xerial.core.XerialException;\r
 import org.xerial.lens.Lens;\r
+import org.xerial.lens.relation.TupleIndex;\r
 import org.xerial.lens.relation.query.impl.LensQueryLexer;\r
 import org.xerial.lens.relation.query.impl.LensQueryParser;\r
+import org.xerial.util.antlr.ANTLRUtil;\r
+import org.xerial.util.log.Logger;\r
 \r
 /**\r
  * Relation expression\r
@@ -43,12 +46,27 @@ import org.xerial.lens.relation.query.impl.LensQueryParser;
  * \r
  */\r
 public class RelationExpr {\r
-    public static class Node {\r
+\r
+    private static Logger _logger = Logger.getLogger(RelationExpr.class);\r
+\r
+    public class Node {\r
+\r
         public String name;\r
+        public String alias;\r
+\r
         public String nodeValue;\r
 \r
         public Compare compare = null;\r
         public PatternMatch patternMatch = null;\r
+\r
+        public void setIndex(String tupleIndex) {\r
+            index = TupleIndex.parse(tupleIndex);\r
+        }\r
+\r
+        public TupleIndex getIndex() {\r
+            return index;\r
+        }\r
+\r
     }\r
 \r
     public static class Compare {\r
@@ -61,7 +79,22 @@ public class RelationExpr {
     }\r
 \r
     public String name;\r
-    public ArrayList<Node> node;\r
+    public String alias;\r
+    public List<Node> node;\r
+    public List<RelationExpr> relation;\r
+    private TupleIndex index = new TupleIndex(0);\r
+\r
+    public void setIndex(String tupleIndex) {\r
+        index = TupleIndex.parse(tupleIndex);\r
+    }\r
+\r
+    public TupleIndex getIndex() {\r
+        return index;\r
+    }\r
+\r
+    private static class RelationQuery {\r
+        public RelationExpr relation;\r
+    }\r
 \r
     public static RelationExpr parse(String expr) throws XerialException {\r
 \r
@@ -71,8 +104,14 @@ public class RelationExpr {
 \r
         try {\r
             LensQueryParser.relation_return ret = p.relation();\r
-            return Lens.loadANTLRParseTree(RelationExpr.class, (Tree) ret.getTree(),\r
+            if (_logger.isDebugEnabled())\r
+                _logger.debug("\n"\r
+                        + ANTLRUtil.parseTree((Tree) ret.getTree(), LensQueryParser.tokenNames));\r
+\r
+            RelationQuery r = Lens.loadANTLRParseTree(RelationQuery.class, (Tree) ret.getTree(),\r
                     LensQueryParser.tokenNames);\r
+\r
+            return r.relation;\r
         }\r
         catch (RecognitionException e) {\r
             throw new XerialException(XerialErrorCode.PARSE_ERROR, e);\r
diff --git a/src/main/java/org/xerial/lens/relation/query/lang/RelationItem.java b/src/main/java/org/xerial/lens/relation/query/lang/RelationItem.java
new file mode 100644 (file)
index 0000000..2066ef9
--- /dev/null
@@ -0,0 +1,36 @@
+/*--------------------------------------------------------------------------\r
+ *  Copyright 2009 Taro L. Saito\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ *--------------------------------------------------------------------------*/\r
+//--------------------------------------\r
+// XerialJ\r
+//\r
+// Node.java\r
+// Since: Aug 6, 2009 1:22:15 PM\r
+//\r
+// $URL$\r
+// $Author$\r
+//--------------------------------------\r
+package org.xerial.lens.relation.query.lang;\r
+\r
+/**\r
+ * base class of relation expression\r
+ * \r
+ * @author leo\r
+ * \r
+ */\r
+public class RelationItem {\r
+    public String name;\r
+    public String alias;\r
+}\r
index 6dd16dc..43c26f7 100644 (file)
@@ -39,9 +39,24 @@ public class RelationExprTest {
     @After\r
     public void tearDown() throws Exception {}\r
 \r
+    public void parse(String query) throws Exception {\r
+        RelationExpr e = RelationExpr.parse(query);\r
+        _logger.info(Lens.toJSON(e));\r
+    }\r
+\r
+    @Test\r
+    public void q1() throws Exception {\r
+        parse("A(B, C)");\r
+    }\r
+\r
     @Test\r
-    public void parseTest() throws Exception {\r
-        RelationExpr e1 = RelationExpr.parse("A(B, C)");\r
-        _logger.info(Lens.toJSON(e1));\r
+    public void q2() throws Exception {\r
+        parse("book(author, isbn10 as isbn)");\r
     }\r
+\r
+    @Test\r
+    public void q3() throws Exception {\r
+        parse("entry(dc.subject:sigmod09, link(rel:related, href), summary)");\r
+    }\r
+\r
 }\r