You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2016/06/14 16:49:16 UTC
activemq git commit: https://issues.apache.org/jira/browse/AMQ-6325
Repository: activemq
Updated Branches:
refs/heads/master a953f11d0 -> 7b207567d
https://issues.apache.org/jira/browse/AMQ-6325
Fix issue with selector parser.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/7b207567
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/7b207567
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/7b207567
Branch: refs/heads/master
Commit: 7b207567d9d304facdfa7c1c5d7fa8a81b6fe70e
Parents: a953f11
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jun 14 12:49:08 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jun 14 12:49:08 2016 -0400
----------------------------------------------------------------------
.../src/main/grammar/SelectorParser.jj | 386 +++++++++----------
.../apache/activemq/selector/SelectorTest.java | 6 +-
2 files changed, 197 insertions(+), 195 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/7b207567/activemq-client/src/main/grammar/SelectorParser.jj
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/grammar/SelectorParser.jj b/activemq-client/src/main/grammar/SelectorParser.jj
index 91a46fb..6ccb113 100755
--- a/activemq-client/src/main/grammar/SelectorParser.jj
+++ b/activemq-client/src/main/grammar/SelectorParser.jj
@@ -21,7 +21,7 @@
options {
STATIC = false;
UNICODE_INPUT = true;
-
+
// some performance optimizations
ERROR_REPORTING = false;
}
@@ -59,9 +59,9 @@ import org.apache.activemq.filter.*;
import org.apache.activemq.filter.FunctionCallExpression.invalidFunctionExpressionException;
import org.apache.activemq.util.LRUCache;
-/**
+/**
* JMS Selector Parser generated by JavaCC
- *
+ *
* Do not edit this .java file directly - it is autogenerated from SelectorParser.jj
*/
public class SelectorParser {
@@ -180,8 +180,8 @@ 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:
+ | < 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
@@ -204,8 +204,8 @@ BooleanExpression JmsSelector() :
}
{
(
- left = orExpression()
- )
+ left = orExpression() <EOF>
+ )
{
return asBooleanExpression(left);
}
@@ -219,14 +219,14 @@ Expression orExpression() :
}
{
(
- left = andExpression()
- (
- <OR> right = andExpression()
+ left = andExpression()
+ (
+ <OR> right = andExpression()
{
left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
}
)*
- )
+ )
{
return left;
}
@@ -241,14 +241,14 @@ Expression andExpression() :
}
{
(
- left = equalityExpression()
- (
- <AND> right = equalityExpression()
+ left = equalityExpression()
+ (
+ <AND> right = equalityExpression()
{
left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));
}
)*
- )
+ )
{
return left;
}
@@ -261,31 +261,31 @@ Expression equalityExpression() :
}
{
(
- left = comparisonExpression()
- (
-
- "=" right = comparisonExpression()
+ left = comparisonExpression()
+ (
+
+ "=" right = comparisonExpression()
{
left = ComparisonExpression.createEqual(left, right);
}
- |
- "<>" right = comparisonExpression()
+ |
+ "<>" right = comparisonExpression()
{
left = ComparisonExpression.createNotEqual(left, right);
}
- |
+ |
LOOKAHEAD(2)
<IS> <NULL>
{
left = ComparisonExpression.createIsNull(left);
}
- |
+ |
<IS> <NOT> <NULL>
{
left = ComparisonExpression.createIsNotNull(left);
}
)*
- )
+ )
{
return left;
}
@@ -298,106 +298,106 @@ Expression comparisonExpression() :
Expression low;
Expression high;
String t, u;
- boolean not;
- ArrayList list;
+ boolean not;
+ ArrayList list;
}
{
(
- left = addExpression()
- (
-
- ">" right = addExpression()
+ left = addExpression()
+ (
+
+ ">" right = addExpression()
{
left = ComparisonExpression.createGreaterThan(left, right);
}
- |
- ">=" right = addExpression()
+ |
+ ">=" right = addExpression()
{
left = ComparisonExpression.createGreaterThanEqual(left, right);
}
- |
- "<" right = addExpression()
+ |
+ "<" right = addExpression()
{
left = ComparisonExpression.createLessThan(left, right);
}
- |
- "<=" right = addExpression()
+ |
+ "<=" right = addExpression()
{
left = ComparisonExpression.createLessThanEqual(left, right);
}
|
- {
- u=null;
- }
- <LIKE> t = stringLitteral()
- [ <ESCAPE> u = stringLitteral() ]
- {
+ {
+ 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() ]
- {
+ 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);
+ }
|
- <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);
- }
+ 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);
- }
+ <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);
- }
-
+ LOOKAHEAD(2)
+ <NOT> <IN>
+ "("
+ t = stringLitteral()
+ {
+ list = new ArrayList();
+ list.add( t );
+ }
+ (
+ ","
+ t = stringLitteral()
+ {
+ list.add( t );
+ }
+
+ )*
+ ")"
+ {
+ left = ComparisonExpression.createNotInFilter(left, list);
+ }
+
)*
- )
+ )
{
return left;
}
@@ -409,21 +409,21 @@ Expression addExpression() :
Expression right;
}
{
- left = multExpr()
- (
- LOOKAHEAD( ("+"|"-") multExpr())
- (
- "+" right = multExpr()
- {
- left = ArithmeticExpression.createPlus(left, right);
- }
- |
- "-" right = multExpr()
- {
- left = ArithmeticExpression.createMinus(left, right);
- }
+ left = multExpr()
+ (
+ LOOKAHEAD( ("+"|"-") multExpr())
+ (
+ "+" right = multExpr()
+ {
+ left = ArithmeticExpression.createPlus(left, right);
+ }
+ |
+ "-" right = multExpr()
+ {
+ left = ArithmeticExpression.createMinus(left, right);
+ }
)
-
+
)*
{
return left;
@@ -436,23 +436,23 @@ Expression multExpr() :
Expression right;
}
{
- left = unaryExpr()
- (
- "*" right = unaryExpr()
+ left = unaryExpr()
+ (
+ "*" right = unaryExpr()
{
- left = ArithmeticExpression.createMultiply(left, right);
+ left = ArithmeticExpression.createMultiply(left, right);
}
- |
- "/" right = unaryExpr()
+ |
+ "/" right = unaryExpr()
{
- left = ArithmeticExpression.createDivide(left, right);
+ left = ArithmeticExpression.createDivide(left, right);
}
- |
- "%" right = unaryExpr()
+ |
+ "%" right = unaryExpr()
{
- left = ArithmeticExpression.createMod(left, right);
+ left = ArithmeticExpression.createMod(left, right);
}
-
+
)*
{
return left;
@@ -466,34 +466,34 @@ Expression unaryExpr() :
Expression left=null;
}
{
- (
- LOOKAHEAD( "+" unaryExpr() )
- "+" left=unaryExpr()
- |
- "-" left=unaryExpr()
- {
- left = UnaryExpression.createNegate(left);
- }
- |
- <NOT> left=unaryExpr()
- {
- left = UnaryExpression.createNOT( asBooleanExpression(left) );
- }
- |
- <XPATH> s=stringLitteral()
- {
- left = UnaryExpression.createXPath( s );
- }
- |
- <XQUERY> s=stringLitteral()
- {
- left = UnaryExpression.createXQuery( s );
- }
- |
+ (
+ LOOKAHEAD( "+" unaryExpr() )
+ "+" left=unaryExpr()
+ |
+ "-" left=unaryExpr()
+ {
+ left = UnaryExpression.createNegate(left);
+ }
+ |
+ <NOT> left=unaryExpr()
+ {
+ left = UnaryExpression.createNOT( asBooleanExpression(left) );
+ }
+ |
+ <XPATH> s=stringLitteral()
+ {
+ left = UnaryExpression.createXPath( s );
+ }
+ |
+ <XQUERY> s=stringLitteral()
+ {
+ left = UnaryExpression.createXQuery( s );
+ }
+ |
LOOKAHEAD( <ID> "(" )
left = functionCallExpr()
- |
- left = primaryExpr()
+ |
+ left = primaryExpr()
)
{
return left;
@@ -519,7 +519,7 @@ Expression functionCallExpr () :
","
arg = unaryExpr()
{
- arg_list.add(arg);
+ arg_list.add(arg);
}
) *
)
@@ -548,7 +548,7 @@ Expression primaryExpr() :
left = variable()
|
"(" left = orExpression() ")"
- )
+ )
{
return left;
}
@@ -569,55 +569,55 @@ ConstantExpression literal() :
{
left = new ConstantExpression(s);
}
- )
- |
+ )
+ |
(
t = <DECIMAL_LITERAL>
{
- left = ConstantExpression.createFromDecimal(t.image);
- }
- )
- |
+ left = ConstantExpression.createFromDecimal(t.image);
+ }
+ )
+ |
(
t = <HEX_LITERAL>
{
- left = ConstantExpression.createFromHex(t.image);
- }
- )
- |
+ left = ConstantExpression.createFromHex(t.image);
+ }
+ )
+ |
(
t = <OCTAL_LITERAL>
{
- left = ConstantExpression.createFromOctal(t.image);
- }
- )
- |
+ left = ConstantExpression.createFromOctal(t.image);
+ }
+ )
+ |
(
t = <FLOATING_POINT_LITERAL>
{
- left = ConstantExpression.createFloat(t.image);
- }
- )
- |
+ left = ConstantExpression.createFloat(t.image);
+ }
+ )
+ |
(
<TRUE>
{
left = ConstantExpression.TRUE;
- }
- )
- |
+ }
+ )
+ |
(
<FALSE>
{
left = ConstantExpression.FALSE;
- }
- )
- |
+ }
+ )
+ |
(
<NULL>
{
left = ConstantExpression.NULL;
- }
+ }
)
)
{
@@ -632,18 +632,18 @@ String stringLitteral() :
boolean first=true;
}
{
- t = <STRING_LITERAL>
+ 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();
- }
+ // 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() :
@@ -652,11 +652,11 @@ PropertyExpression variable() :
PropertyExpression left=null;
}
{
- (
- t = <ID>
+ (
+ t = <ID>
{
left = new PropertyExpression(t.image);
- }
+ }
)
{
return left;
http://git-wip-us.apache.org/repos/asf/activemq/blob/7b207567/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java
index 84a87b4..c65674d 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java
@@ -20,14 +20,14 @@ import javax.jms.InvalidSelectorException;
import javax.jms.JMSException;
import javax.jms.Message;
-import junit.framework.TestCase;
-
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.filter.BooleanExpression;
import org.apache.activemq.filter.MessageEvaluationContext;
+import junit.framework.TestCase;
+
/**
*
*/
@@ -342,6 +342,8 @@ public class SelectorTest extends TestCase {
assertInvalidSelector(message, "3+5");
assertInvalidSelector(message, "True AND 3+5");
assertInvalidSelector(message, "=TEST 'test'");
+ assertInvalidSelector(message, "prop1 = prop2 foo AND string = 'Test'");
+ assertInvalidSelector(message, "a = 1 AMD b = 2");
}
public void testFunctionSelector() throws Exception {