@@ -2151,32 +2151,30 @@ Expression Condition():
21512151{
21522152 Expression result;
21532153 Token token;
2154+ boolean not = false;
21542155}
21552156{
2156- (LOOKAHEAD(SQLCondition()) result=SQLCondition()
2157- | LOOKAHEAD(RegularCondition()) result=RegularCondition()
2158- | LOOKAHEAD(Function()) result=Function()
2159- | <K_NOT> result=Column() { result = new NotExpression(result); }
2160- | result=Column()
2161- | LOOKAHEAD({ "0".equals(getToken(1).image) || "1".equals(getToken(1).image) }) token=<S_LONG> { result = new LongValue(token.image); }
2157+ [ <K_NOT> { not = true; }]
2158+ (
2159+ LOOKAHEAD(SQLCondition()) result=SQLCondition()
2160+ | LOOKAHEAD(RegularCondition()) result=RegularCondition()
2161+ | result=SimpleExpression()
21622162 )
21632163
2164- { return result; }
2164+ { return not?new NotExpression(result): result; }
21652165}
21662166
21672167Expression RegularCondition() #RegularCondition:
21682168{
21692169 Expression result = null;
21702170 Expression leftExpression;
21712171 Expression rightExpression;
2172- boolean not = false;
21732172 int oracleJoin=EqualsTo.NO_ORACLE_JOIN;
21742173 int oraclePrior=EqualsTo.NO_ORACLE_PRIOR;
21752174 boolean binary = false;
21762175}
21772176{
21782177 [ LOOKAHEAD(2) <K_PRIOR> { oraclePrior = EqualsTo.ORACLE_PRIOR_START; }]
2179- [ <K_NOT> { not = true; } ]
21802178 leftExpression=ComparisonItem() { result = leftExpression; }
21812179
21822180 [ "(" "+" ")" { oracleJoin=EqualsTo.ORACLE_JOIN_RIGHT; } ]
@@ -2216,8 +2214,6 @@ Expression RegularCondition() #RegularCondition:
22162214 BinaryExpression regCond = (BinaryExpression) result;
22172215 regCond.setLeftExpression(leftExpression);
22182216 regCond.setRightExpression(rightExpression);
2219- if (not)
2220- regCond.setNot();
22212217
22222218 if (oracleJoin>0)
22232219 ((SupportsOldOracleJoinSyntax)result).setOldOracleJoinSyntax(oracleJoin);
@@ -2300,18 +2296,9 @@ Expression LikeExpression() #LikeExpression:
23002296 Expression rightExpression = null;
23012297}
23022298{
2303- (
2304- LOOKAHEAD(3) (
2305- leftExpression=SimpleExpression()
2306- [<K_NOT> { result.setNot(); } ] ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
2307- [<K_ESCAPE> token=<S_CHAR_LITERAL> { result.setEscape((new StringValue(token.image)).getValue()); }]
2308- )
2309- |
2310- (
2311- [<K_NOT> { result.setNot(); } ] leftExpression=SimpleExpression() ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
2312- [<K_ESCAPE> token=<S_CHAR_LITERAL> { result.setEscape((new StringValue(token.image)).getValue()); }]
2313- )
2314- )
2299+ leftExpression=SimpleExpression()
2300+ [<K_NOT> { result.setNot(); } ] ( <K_LIKE> | <K_ILIKE> { result.setCaseInsensitive(true); } ) rightExpression=SimpleExpression()
2301+ [<K_ESCAPE> token=<S_CHAR_LITERAL> { result.setEscape((new StringValue(token.image)).getValue()); }]
23152302 {
23162303 result.setLeftExpression(leftExpression);
23172304 result.setRightExpression(rightExpression);
@@ -2326,13 +2313,8 @@ Expression IsNullExpression():
23262313 Expression leftExpression = null;
23272314}
23282315{
2329- (
2330- <K_NOT> { result.setNot(true); } leftExpression=SimpleExpression()
2331- ( <K_ISNULL> { result.setUseIsNull(true); } | <K_IS> <K_NULL> )
2332- |
23332316 leftExpression=SimpleExpression()
23342317 (<K_ISNULL> { result.setUseIsNull(true); } | <K_IS> [<K_NOT> { result.setNot(true); } ] <K_NULL> )
2335- )
23362318
23372319 {
23382320 result.setLeftExpression(leftExpression);
@@ -2346,7 +2328,7 @@ Expression ExistsExpression():
23462328 Expression rightExpression = null;
23472329}
23482330{
2349- [<K_NOT> { result.setNot(true); } ] <K_EXISTS> rightExpression=SimpleExpression()
2331+ <K_EXISTS> rightExpression=SimpleExpression()
23502332 {
23512333 result.setRightExpression(rightExpression);
23522334 return result;
@@ -2984,7 +2966,7 @@ Expression CaseWhenExpression() #CaseWhenExpression:
29842966 (LOOKAHEAD(RegularCondition()) switchExp=RegularCondition() | switchExp=BitwiseAndOr())
29852967 ( clause=WhenThenValue() { whenClauses.add(clause); } )+
29862968 )
2987- [<K_ELSE> elseExp=SimpleExpression ()]
2969+ [<K_ELSE> elseExp=Condition ()]
29882970 <K_END>
29892971 {
29902972 caseExp.setSwitchExpression(switchExp);
@@ -3001,7 +2983,8 @@ WhenClause WhenThenSearchCondition():
30012983 Expression thenExp = null;
30022984}
30032985{
3004- <K_WHEN> (LOOKAHEAD(Expression()) whenExp=Expression() | whenExp=SimpleExpression()) <K_THEN> thenExp=SimpleExpression()
2986+ <K_WHEN> (LOOKAHEAD(Expression()) whenExp=Expression() | whenExp=SimpleExpression())
2987+ <K_THEN> thenExp=Condition()
30052988 {
30062989 whenThen.setWhenExpression(whenExp);
30072990 whenThen.setThenExpression(thenExp);
0 commit comments