qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [1/3] qpid-jms git commit: rename+repackage the generated selector parser
Date Tue, 03 Mar 2015 14:59:50 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master 8b368bc73 -> d1f0b32ba


rename+repackage the generated selector parser


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/ca69a07c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/ca69a07c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/ca69a07c

Branch: refs/heads/master
Commit: ca69a07cd9455c47d477370031b94adeb0af20e1
Parents: 8b368bc
Author: Robert Gemmell <robbie@apache.org>
Authored: Tue Mar 3 14:16:50 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Tue Mar 3 14:16:50 2015 +0000

----------------------------------------------------------------------
 .../qpid/jms/selector/SelectorParser.java       |   4 +-
 .../src/main/javacc/SelectorParserImpl.jj       | 566 +++++++++++++++++++
 qpid-jms-client/src/main/javacc/StrictParser.jj | 566 -------------------
 3 files changed, 568 insertions(+), 568 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ca69a07c/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
index 28b96d9..87e74b2 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
@@ -20,7 +20,7 @@ import java.io.StringReader;
 
 import org.apache.qpid.jms.selector.filter.BooleanExpression;
 import org.apache.qpid.jms.selector.filter.FilterException;
-import org.apache.qpid.jms.selector.strict.StrictParser;
+import org.apache.qpid.jms.selector.parser.SelectorParserImpl;
 
 public class SelectorParser {
 
@@ -35,7 +35,7 @@ public class SelectorParser {
         } else {
             try {
                 BooleanExpression e = null;
-                StrictParser parser = new StrictParser(new StringReader(sql));
+                SelectorParserImpl parser = new SelectorParserImpl(new StringReader(sql));
                 e = parser.JmsSelector();
                 cache.put(sql, e);
                 return e;

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ca69a07c/qpid-jms-client/src/main/javacc/SelectorParserImpl.jj
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/javacc/SelectorParserImpl.jj b/qpid-jms-client/src/main/javacc/SelectorParserImpl.jj
new file mode 100755
index 0000000..c60b7ee
--- /dev/null
+++ b/qpid-jms-client/src/main/javacc/SelectorParserImpl.jj
@@ -0,0 +1,566 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ----------------------------------------------------------------------------
+// OPTIONS
+// ----------------------------------------------------------------------------
+options {
+  STATIC = false;
+  UNICODE_INPUT = true;
+  // some performance optimizations
+  ERROR_REPORTING = false;
+}
+
+// ----------------------------------------------------------------------------
+// PARSER
+// ----------------------------------------------------------------------------
+
+PARSER_BEGIN(SelectorParserImpl)
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.qpid.jms.selector.parser;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.qpid.jms.selector.filter.*;
+
+/**
+ * JMS Selector Parser generated by JavaCC
+ *
+ * Do not edit this .java file directly - it is generated from SelectorParserImpl.jj
+ */
+public class SelectorParserImpl {
+    private BooleanExpression asBooleanExpression(Expression value) throws ParseException
 {
+        if (value instanceof BooleanExpression) {
+            return (BooleanExpression) value;
+        }
+        if (value instanceof PropertyExpression) {
+            return UnaryExpression.createBooleanCast( value );
+        }
+        throw new ParseException("Expression will not result in a boolean value: " + value);
+    }
+}
+
+PARSER_END(SelectorParserImpl)
+
+// ----------------------------------------------------------------------------
+// Tokens
+// ----------------------------------------------------------------------------
+
+/* White Space */
+SPECIAL_TOKEN :
+{
+  " " | "\t" | "\n" | "\r" | "\f"
+}
+
+/* Comments */
+SKIP:
+{
+  <LINE_COMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >
+}
+
+SKIP:
+{
+  <BLOCK_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+}
+
+/* Reserved Words */
+TOKEN [IGNORE_CASE] :
+{
+    <  NOT     : "NOT">
+  | <  AND     : "AND">
+  | <  OR      : "OR">
+  | <  BETWEEN : "BETWEEN">
+  | <  LIKE    : "LIKE">
+  | <  ESCAPE  : "ESCAPE">
+  | <  IN      : "IN">
+  | <  IS      : "IS">
+  | <  TRUE    : "TRUE" >
+  | <  FALSE   : "FALSE" >
+  | <  NULL    : "NULL" >
+}
+
+/* Literals */
+TOKEN [IGNORE_CASE] :
+{
+
+    < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? >
+  | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
+  | < OCTAL_LITERAL: "0" (["0"-"7"])* >
+  | < FLOATING_POINT_LITERAL:
+          (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? // matches: 5.5 or 5. or 5.5E10
or 5.E10
+        | "." (["0"-"9"])+ (<EXPONENT>)?              // matches: .5 or .5E10
+        | (["0"-"9"])+ <EXPONENT>                     // matches: 5E10
+    >
+  | < #EXPONENT: "E" (["+","-"])? (["0"-"9"])+ >
+  | < STRING_LITERAL: "'" ( ("''") | ~["'"] )*  "'" >
+}
+
+TOKEN [IGNORE_CASE] :
+{
+    < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >
+    | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )*  "\""  >
+}
+
+// ----------------------------------------------------------------------------
+// Grammer
+// ----------------------------------------------------------------------------
+BooleanExpression JmsSelector() :
+{
+    Expression left=null;
+}
+{
+    (
+        left = orExpression()
+    )
+    {
+        return asBooleanExpression(left);
+    }
+
+}
+
+Expression orExpression() :
+{
+    Expression left;
+    Expression right;
+}
+{
+    (
+        left = andExpression()
+        (
+            <OR> right = andExpression()
+            {
+                left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
+            }
+        )*
+    )
+    {
+        return left;
+    }
+
+}
+
+
+Expression andExpression() :
+{
+    Expression left;
+    Expression right;
+}
+{
+    (
+        left = equalityExpression()
+        (
+            <AND> right = equalityExpression()
+            {
+                left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));
+            }
+        )*
+    )
+    {
+        return left;
+    }
+}
+
+Expression equalityExpression() :
+{
+    Expression left;
+    Expression right;
+}
+{
+    (
+        left = comparisonExpression()
+        (
+
+            "=" right = comparisonExpression()
+            {
+                left = ComparisonExpression.createEqual(left, right);
+            }
+            |
+            "<>" right = comparisonExpression()
+            {
+                left = ComparisonExpression.createNotEqual(left, right);
+            }
+            |
+            LOOKAHEAD(2)
+            <IS> <NULL>
+            {
+                left = ComparisonExpression.createIsNull(left);
+            }
+            |
+            <IS> <NOT> <NULL>
+            {
+                left = ComparisonExpression.createIsNotNull(left);
+            }
+        )*
+    )
+    {
+        return left;
+    }
+}
+
+Expression comparisonExpression() :
+{
+    Expression left;
+    Expression right;
+    Expression low;
+    Expression high;
+    String t, u;
+    boolean not;
+    ArrayList list;
+}
+{
+    (
+        left = addExpression()
+        (
+
+                ">" right = addExpression()
+                {
+                    left = ComparisonExpression.createGreaterThan(left, right);
+                }
+            |
+                ">=" right = addExpression()
+                {
+                    left = ComparisonExpression.createGreaterThanEqual(left, right);
+                }
+            |
+                "<" right = addExpression()
+                {
+                    left = ComparisonExpression.createLessThan(left, right);
+                }
+            |
+                "<=" right = addExpression()
+                {
+                    left = ComparisonExpression.createLessThanEqual(left, right);
+                }
+           |
+                {
+                    u=null;
+                }
+                <LIKE> t = stringLitteral()
+                    [ <ESCAPE> u = stringLitteral() ]
+                {
+                    left = ComparisonExpression.createLike(left, t, u);
+                }
+           |
+                LOOKAHEAD(2)
+                {
+                    u=null;
+                }
+                <NOT> <LIKE> t = stringLitteral() [ <ESCAPE> u = stringLitteral()
]
+                {
+                    left = ComparisonExpression.createNotLike(left, t, u);
+                }
+            |
+                <BETWEEN> low = addExpression() <AND> high = addExpression()
+                {
+                    left = ComparisonExpression.createBetween(left, low, high);
+                }
+            |
+                LOOKAHEAD(2)
+                <NOT> <BETWEEN> low = addExpression() <AND> high = addExpression()
+                {
+                    left = ComparisonExpression.createNotBetween(left, low, high);
+                }
+            |
+                <IN>
+                "("
+                    t = stringLitteral()
+                    {
+                        list = new ArrayList();
+                        list.add( t );
+                    }
+                    (
+                        ","
+                        t = stringLitteral()
+                        {
+                            list.add( t );
+                        }
+
+                    )*
+                ")"
+                {
+                   left = ComparisonExpression.createInFilter(left, list);
+                }
+            |
+                LOOKAHEAD(2)
+                <NOT> <IN>
+                "("
+                    t = stringLitteral()
+                    {
+                        list = new ArrayList();
+                        list.add( t );
+                    }
+                    (
+                        ","
+                        t = stringLitteral()
+                        {
+                            list.add( t );
+                        }
+
+                    )*
+                ")"
+                {
+                   left = ComparisonExpression.createNotInFilter(left, list);
+                }
+
+        )*
+    )
+    {
+        return left;
+    }
+}
+
+Expression addExpression() :
+{
+    Expression left;
+    Expression right;
+}
+{
+    left = multExpr()
+    (
+        LOOKAHEAD( ("+"|"-") multExpr())
+        (
+            "+" right = multExpr()
+            {
+                left = ArithmeticExpression.createPlus(left, right);
+            }
+            |
+            "-" right = multExpr()
+            {
+                left = ArithmeticExpression.createMinus(left, right);
+            }
+        )
+
+    )*
+    {
+        return left;
+    }
+}
+
+Expression multExpr() :
+{
+    Expression left;
+    Expression right;
+}
+{
+    left = unaryExpr()
+    (
+        "*" right = unaryExpr()
+        {
+            left = ArithmeticExpression.createMultiply(left, right);
+        }
+        |
+        "/" right = unaryExpr()
+        {
+            left = ArithmeticExpression.createDivide(left, right);
+        }
+        |
+        "%" right = unaryExpr()
+        {
+            left = ArithmeticExpression.createMod(left, right);
+        }
+
+    )*
+    {
+        return left;
+    }
+}
+
+
+Expression unaryExpr() :
+{
+    String s=null;
+    Expression left=null;
+}
+{
+    (
+        LOOKAHEAD( "+" unaryExpr() )
+        "+" left=unaryExpr()
+        |
+        "-" left=unaryExpr()
+        {
+            left = UnaryExpression.createNegate(left);
+        }
+        |
+        <NOT> left=unaryExpr()
+        {
+            left = UnaryExpression.createNOT( asBooleanExpression(left) );
+        }
+        |
+        left = primaryExpr()
+    )
+    {
+        return left;
+    }
+
+}
+
+Expression primaryExpr() :
+{
+    Expression left=null;
+}
+{
+    (
+        left = literal()
+        |
+        left = variable()
+        |
+        "(" left = orExpression() ")"
+    )
+    {
+        return left;
+    }
+}
+
+
+
+ConstantExpression literal() :
+{
+    Token t;
+    String s;
+    ConstantExpression left=null;
+}
+{
+    (
+        (
+            s = stringLitteral()
+            {
+                left = new ConstantExpression(s);
+            }
+        )
+        |
+        (
+            t = <DECIMAL_LITERAL>
+            {
+                left = ConstantExpression.createFromDecimal(t.image);
+            }
+        )
+        |
+        (
+            t = <HEX_LITERAL>
+            {
+                left = ConstantExpression.createFromHex(t.image);
+            }
+        )
+        |
+        (
+            t = <OCTAL_LITERAL>
+            {
+                left = ConstantExpression.createFromOctal(t.image);
+            }
+        )
+        |
+        (
+            t = <FLOATING_POINT_LITERAL>
+            {
+                left = ConstantExpression.createFloat(t.image);
+            }
+        )
+        |
+        (
+            <TRUE>
+            {
+                left = ConstantExpression.TRUE;
+            }
+        )
+        |
+        (
+            <FALSE>
+            {
+                left = ConstantExpression.FALSE;
+            }
+        )
+        |
+        (
+            <NULL>
+            {
+                left = ConstantExpression.NULL;
+            }
+        )
+    )
+    {
+        return left;
+    }
+}
+
+String stringLitteral() :
+{
+    Token t;
+    StringBuffer rc = new StringBuffer();
+    boolean first=true;
+}
+{
+    t = <STRING_LITERAL>
+    {
+        // Decode the sting value.
+        String image = t.image;
+        for( int i=1; i < image.length()-1; i++ ) {
+            char c = image.charAt(i);
+            if( c == '\'' )
+                i++;
+               rc.append(c);
+        }
+        return rc.toString();
+    }
+}
+
+PropertyExpression variable() :
+{
+    Token t;
+    PropertyExpression left=null;
+}
+{
+    (
+        t=<ID>
+        {
+            left = new PropertyExpression(t.image);
+        }
+        |
+        t = <QUOTED_ID>
+        {
+            // Decode the string value.
+            StringBuffer rc = new StringBuffer();
+            String image = t.image;
+            for( int i=1; i < image.length()-1; i++ ) {
+                char c = image.charAt(i);
+                if( c == '"' )
+                    i++;
+                rc.append(c);
+            }
+            return new PropertyExpression(rc.toString());
+        }
+    )
+    {
+        return left;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ca69a07c/qpid-jms-client/src/main/javacc/StrictParser.jj
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/javacc/StrictParser.jj b/qpid-jms-client/src/main/javacc/StrictParser.jj
deleted file mode 100755
index bf1bec5..0000000
--- a/qpid-jms-client/src/main/javacc/StrictParser.jj
+++ /dev/null
@@ -1,566 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// ----------------------------------------------------------------------------
-// OPTIONS
-// ----------------------------------------------------------------------------
-options {
-  STATIC = false;
-  UNICODE_INPUT = true;
-  // some performance optimizations
-  ERROR_REPORTING = false;
-}
-
-// ----------------------------------------------------------------------------
-// PARSER
-// ----------------------------------------------------------------------------
-
-PARSER_BEGIN(StrictParser)
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.qpid.jms.selector.strict;
-
-import java.io.*;
-import java.util.*;
-
-import org.apache.qpid.jms.selector.filter.*;
-
-/**
- * JMS Selector Parser generated by JavaCC
- *
- * Do not edit this .java file directly - it is autogenerated from StrictParser.jj
- */
-public class StrictParser {
-    private BooleanExpression asBooleanExpression(Expression value) throws ParseException
 {
-        if (value instanceof BooleanExpression) {
-            return (BooleanExpression) value;
-        }
-        if (value instanceof PropertyExpression) {
-            return UnaryExpression.createBooleanCast( value );
-        }
-        throw new ParseException("Expression will not result in a boolean value: " + value);
-    }
-}
-
-PARSER_END(StrictParser)
-
-// ----------------------------------------------------------------------------
-// Tokens
-// ----------------------------------------------------------------------------
-
-/* White Space */
-SPECIAL_TOKEN :
-{
-  " " | "\t" | "\n" | "\r" | "\f"
-}
-
-/* Comments */
-SKIP:
-{
-  <LINE_COMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >
-}
-
-SKIP:
-{
-  <BLOCK_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
-}
-
-/* Reserved Words */
-TOKEN [IGNORE_CASE] :
-{
-    <  NOT     : "NOT">
-  | <  AND     : "AND">
-  | <  OR      : "OR">
-  | <  BETWEEN : "BETWEEN">
-  | <  LIKE    : "LIKE">
-  | <  ESCAPE  : "ESCAPE">
-  | <  IN      : "IN">
-  | <  IS      : "IS">
-  | <  TRUE    : "TRUE" >
-  | <  FALSE   : "FALSE" >
-  | <  NULL    : "NULL" >
-}
-
-/* Literals */
-TOKEN [IGNORE_CASE] :
-{
-
-    < DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* (["l","L"])? >
-  | < HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-  | < OCTAL_LITERAL: "0" (["0"-"7"])* >
-  | < FLOATING_POINT_LITERAL:
-          (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? // matches: 5.5 or 5. or 5.5E10
or 5.E10
-        | "." (["0"-"9"])+ (<EXPONENT>)?              // matches: .5 or .5E10
-        | (["0"-"9"])+ <EXPONENT>                     // matches: 5E10
-    >
-  | < #EXPONENT: "E" (["+","-"])? (["0"-"9"])+ >
-  | < STRING_LITERAL: "'" ( ("''") | ~["'"] )*  "'" >
-}
-
-TOKEN [IGNORE_CASE] :
-{
-    < ID : ["a"-"z", "_", "$"] (["a"-"z","0"-"9","_", "$"])* >
-    | < QUOTED_ID : "\"" ( ("\"\"") | ~["\""] )*  "\""  >
-}
-
-// ----------------------------------------------------------------------------
-// Grammer
-// ----------------------------------------------------------------------------
-BooleanExpression JmsSelector() :
-{
-    Expression left=null;
-}
-{
-    (
-        left = orExpression()
-    )
-    {
-        return asBooleanExpression(left);
-    }
-
-}
-
-Expression orExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    (
-        left = andExpression()
-        (
-            <OR> right = andExpression()
-            {
-                left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
-            }
-        )*
-    )
-    {
-        return left;
-    }
-
-}
-
-
-Expression andExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    (
-        left = equalityExpression()
-        (
-            <AND> right = equalityExpression()
-            {
-                left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));
-            }
-        )*
-    )
-    {
-        return left;
-    }
-}
-
-Expression equalityExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    (
-        left = comparisonExpression()
-        (
-
-            "=" right = comparisonExpression()
-            {
-                left = ComparisonExpression.createEqual(left, right);
-            }
-            |
-            "<>" right = comparisonExpression()
-            {
-                left = ComparisonExpression.createNotEqual(left, right);
-            }
-            |
-            LOOKAHEAD(2)
-            <IS> <NULL>
-            {
-                left = ComparisonExpression.createIsNull(left);
-            }
-            |
-            <IS> <NOT> <NULL>
-            {
-                left = ComparisonExpression.createIsNotNull(left);
-            }
-        )*
-    )
-    {
-        return left;
-    }
-}
-
-Expression comparisonExpression() :
-{
-    Expression left;
-    Expression right;
-    Expression low;
-    Expression high;
-    String t, u;
-    boolean not;
-    ArrayList list;
-}
-{
-    (
-        left = addExpression()
-        (
-
-                ">" right = addExpression()
-                {
-                    left = ComparisonExpression.createGreaterThan(left, right);
-                }
-            |
-                ">=" right = addExpression()
-                {
-                    left = ComparisonExpression.createGreaterThanEqual(left, right);
-                }
-            |
-                "<" right = addExpression()
-                {
-                    left = ComparisonExpression.createLessThan(left, right);
-                }
-            |
-                "<=" right = addExpression()
-                {
-                    left = ComparisonExpression.createLessThanEqual(left, right);
-                }
-           |
-                {
-                    u=null;
-                }
-                <LIKE> t = stringLitteral()
-                    [ <ESCAPE> u = stringLitteral() ]
-                {
-                    left = ComparisonExpression.createLike(left, t, u);
-                }
-           |
-                LOOKAHEAD(2)
-                {
-                    u=null;
-                }
-                <NOT> <LIKE> t = stringLitteral() [ <ESCAPE> u = stringLitteral()
]
-                {
-                    left = ComparisonExpression.createNotLike(left, t, u);
-                }
-            |
-                <BETWEEN> low = addExpression() <AND> high = addExpression()
-                {
-                    left = ComparisonExpression.createBetween(left, low, high);
-                }
-            |
-                LOOKAHEAD(2)
-                <NOT> <BETWEEN> low = addExpression() <AND> high = addExpression()
-                {
-                    left = ComparisonExpression.createNotBetween(left, low, high);
-                }
-            |
-                <IN>
-                "("
-                    t = stringLitteral()
-                    {
-                        list = new ArrayList();
-                        list.add( t );
-                    }
-                    (
-                        ","
-                        t = stringLitteral()
-                        {
-                            list.add( t );
-                        }
-
-                    )*
-                ")"
-                {
-                   left = ComparisonExpression.createInFilter(left, list);
-                }
-            |
-                LOOKAHEAD(2)
-                <NOT> <IN>
-                "("
-                    t = stringLitteral()
-                    {
-                        list = new ArrayList();
-                        list.add( t );
-                    }
-                    (
-                        ","
-                        t = stringLitteral()
-                        {
-                            list.add( t );
-                        }
-
-                    )*
-                ")"
-                {
-                   left = ComparisonExpression.createNotInFilter(left, list);
-                }
-
-        )*
-    )
-    {
-        return left;
-    }
-}
-
-Expression addExpression() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    left = multExpr()
-    (
-        LOOKAHEAD( ("+"|"-") multExpr())
-        (
-            "+" right = multExpr()
-            {
-                left = ArithmeticExpression.createPlus(left, right);
-            }
-            |
-            "-" right = multExpr()
-            {
-                left = ArithmeticExpression.createMinus(left, right);
-            }
-        )
-
-    )*
-    {
-        return left;
-    }
-}
-
-Expression multExpr() :
-{
-    Expression left;
-    Expression right;
-}
-{
-    left = unaryExpr()
-    (
-        "*" right = unaryExpr()
-        {
-            left = ArithmeticExpression.createMultiply(left, right);
-        }
-        |
-        "/" right = unaryExpr()
-        {
-            left = ArithmeticExpression.createDivide(left, right);
-        }
-        |
-        "%" right = unaryExpr()
-        {
-            left = ArithmeticExpression.createMod(left, right);
-        }
-
-    )*
-    {
-        return left;
-    }
-}
-
-
-Expression unaryExpr() :
-{
-    String s=null;
-    Expression left=null;
-}
-{
-    (
-        LOOKAHEAD( "+" unaryExpr() )
-        "+" left=unaryExpr()
-        |
-        "-" left=unaryExpr()
-        {
-            left = UnaryExpression.createNegate(left);
-        }
-        |
-        <NOT> left=unaryExpr()
-        {
-            left = UnaryExpression.createNOT( asBooleanExpression(left) );
-        }
-        |
-        left = primaryExpr()
-    )
-    {
-        return left;
-    }
-
-}
-
-Expression primaryExpr() :
-{
-    Expression left=null;
-}
-{
-    (
-        left = literal()
-        |
-        left = variable()
-        |
-        "(" left = orExpression() ")"
-    )
-    {
-        return left;
-    }
-}
-
-
-
-ConstantExpression literal() :
-{
-    Token t;
-    String s;
-    ConstantExpression left=null;
-}
-{
-    (
-        (
-            s = stringLitteral()
-            {
-                left = new ConstantExpression(s);
-            }
-        )
-        |
-        (
-            t = <DECIMAL_LITERAL>
-            {
-                left = ConstantExpression.createFromDecimal(t.image);
-            }
-        )
-        |
-        (
-            t = <HEX_LITERAL>
-            {
-                left = ConstantExpression.createFromHex(t.image);
-            }
-        )
-        |
-        (
-            t = <OCTAL_LITERAL>
-            {
-                left = ConstantExpression.createFromOctal(t.image);
-            }
-        )
-        |
-        (
-            t = <FLOATING_POINT_LITERAL>
-            {
-                left = ConstantExpression.createFloat(t.image);
-            }
-        )
-        |
-        (
-            <TRUE>
-            {
-                left = ConstantExpression.TRUE;
-            }
-        )
-        |
-        (
-            <FALSE>
-            {
-                left = ConstantExpression.FALSE;
-            }
-        )
-        |
-        (
-            <NULL>
-            {
-                left = ConstantExpression.NULL;
-            }
-        )
-    )
-    {
-        return left;
-    }
-}
-
-String stringLitteral() :
-{
-    Token t;
-    StringBuffer rc = new StringBuffer();
-    boolean first=true;
-}
-{
-    t = <STRING_LITERAL>
-    {
-        // Decode the sting value.
-        String image = t.image;
-        for( int i=1; i < image.length()-1; i++ ) {
-            char c = image.charAt(i);
-            if( c == '\'' )
-                i++;
-               rc.append(c);
-        }
-        return rc.toString();
-    }
-}
-
-PropertyExpression variable() :
-{
-    Token t;
-    PropertyExpression left=null;
-}
-{
-    (
-        t=<ID>
-        {
-            left = new PropertyExpression(t.image);
-        }
-        |
-        t = <QUOTED_ID>
-        {
-            // Decode the string value.
-            StringBuffer rc = new StringBuffer();
-            String image = t.image;
-            for( int i=1; i < image.length()-1; i++ ) {
-                char c = image.charAt(i);
-                if( c == '"' )
-                    i++;
-                rc.append(c);
-            }
-            return new PropertyExpression(rc.toString());
-        }
-    )
-    {
-        return left;
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message