@@ -2151,32 +2151,30 @@ Expression Condition():
2151
2151
{
2152
2152
Expression result;
2153
2153
Token token;
2154
+ boolean not = false;
2154
2155
}
2155
2156
{
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()
2162
2162
)
2163
2163
2164
- { return result; }
2164
+ { return not?new NotExpression(result): result; }
2165
2165
}
2166
2166
2167
2167
Expression RegularCondition() #RegularCondition:
2168
2168
{
2169
2169
Expression result = null;
2170
2170
Expression leftExpression;
2171
2171
Expression rightExpression;
2172
- boolean not = false;
2173
2172
int oracleJoin=EqualsTo.NO_ORACLE_JOIN;
2174
2173
int oraclePrior=EqualsTo.NO_ORACLE_PRIOR;
2175
2174
boolean binary = false;
2176
2175
}
2177
2176
{
2178
2177
[ LOOKAHEAD(2) <K_PRIOR> { oraclePrior = EqualsTo.ORACLE_PRIOR_START; }]
2179
- [ <K_NOT> { not = true; } ]
2180
2178
leftExpression=ComparisonItem() { result = leftExpression; }
2181
2179
2182
2180
[ "(" "+" ")" { oracleJoin=EqualsTo.ORACLE_JOIN_RIGHT; } ]
@@ -2216,8 +2214,6 @@ Expression RegularCondition() #RegularCondition:
2216
2214
BinaryExpression regCond = (BinaryExpression) result;
2217
2215
regCond.setLeftExpression(leftExpression);
2218
2216
regCond.setRightExpression(rightExpression);
2219
- if (not)
2220
- regCond.setNot();
2221
2217
2222
2218
if (oracleJoin>0)
2223
2219
((SupportsOldOracleJoinSyntax)result).setOldOracleJoinSyntax(oracleJoin);
@@ -2300,18 +2296,9 @@ Expression LikeExpression() #LikeExpression:
2300
2296
Expression rightExpression = null;
2301
2297
}
2302
2298
{
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()); }]
2315
2302
{
2316
2303
result.setLeftExpression(leftExpression);
2317
2304
result.setRightExpression(rightExpression);
@@ -2326,13 +2313,8 @@ Expression IsNullExpression():
2326
2313
Expression leftExpression = null;
2327
2314
}
2328
2315
{
2329
- (
2330
- <K_NOT> { result.setNot(true); } leftExpression=SimpleExpression()
2331
- ( <K_ISNULL> { result.setUseIsNull(true); } | <K_IS> <K_NULL> )
2332
- |
2333
2316
leftExpression=SimpleExpression()
2334
2317
(<K_ISNULL> { result.setUseIsNull(true); } | <K_IS> [<K_NOT> { result.setNot(true); } ] <K_NULL> )
2335
- )
2336
2318
2337
2319
{
2338
2320
result.setLeftExpression(leftExpression);
@@ -2346,7 +2328,7 @@ Expression ExistsExpression():
2346
2328
Expression rightExpression = null;
2347
2329
}
2348
2330
{
2349
- [<K_NOT> { result.setNot(true); } ] <K_EXISTS> rightExpression=SimpleExpression()
2331
+ <K_EXISTS> rightExpression=SimpleExpression()
2350
2332
{
2351
2333
result.setRightExpression(rightExpression);
2352
2334
return result;
@@ -2984,7 +2966,7 @@ Expression CaseWhenExpression() #CaseWhenExpression:
2984
2966
(LOOKAHEAD(RegularCondition()) switchExp=RegularCondition() | switchExp=BitwiseAndOr())
2985
2967
( clause=WhenThenValue() { whenClauses.add(clause); } )+
2986
2968
)
2987
- [<K_ELSE> elseExp=SimpleExpression ()]
2969
+ [<K_ELSE> elseExp=Condition ()]
2988
2970
<K_END>
2989
2971
{
2990
2972
caseExp.setSwitchExpression(switchExp);
@@ -3001,7 +2983,8 @@ WhenClause WhenThenSearchCondition():
3001
2983
Expression thenExp = null;
3002
2984
}
3003
2985
{
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()
3005
2988
{
3006
2989
whenThen.setWhenExpression(whenExp);
3007
2990
whenThen.setThenExpression(thenExp);
0 commit comments