@@ -2347,17 +2347,17 @@ NamedExpressionList NamedExpressionList1():
2347
2347
List<String> names = new ArrayList<String>();
2348
2348
Expression expr1 = null;
2349
2349
Expression expr2 = null;
2350
- Expression expr3 = null;
2351
- Expression expr4 = null;
2352
2350
String name = "";
2353
2351
Token tk1 = null;
2354
2352
Token tk2 = null;
2355
- Token tk3 = null;
2356
- Token tk4 = null;
2357
2353
}
2358
2354
{
2359
2355
(
2360
- expr1=SimpleExpression() (tk2=<K_FROM>|tk2=<K_IN>|tk2=<K_PLACING>) expr2=SimpleExpression() { expressions.add(expr1); names.add(tk2.image); expressions.add(expr2);}
2356
+ (tk1=<K_BOTH>|tk1=<K_LEADING>|tk1=<K_TRAILING>) { names.add(tk1.image); }
2357
+ expr1=SimpleExpression()
2358
+ (tk2=<K_FROM>|tk2=<K_IN>|tk2=<K_PLACING>)
2359
+ expr2=SimpleExpression()
2360
+ { expressions.add(expr1); names.add(tk2.image); expressions.add(expr2);}
2361
2361
)
2362
2362
2363
2363
{
@@ -2374,7 +2374,7 @@ NamedExpressionList NamedExpressionList1():
2374
2374
// overlay(expr1 placing expr2 from expr3)
2375
2375
// overlay(expr1 placing expr2 from expr3 for expr4)
2376
2376
// expr1 has already been consumed
2377
- NamedExpressionList NamedExpressionList2 ():
2377
+ NamedExpressionList NamedExpressionListExprFirst ():
2378
2378
{
2379
2379
NamedExpressionList retval = new NamedExpressionList();
2380
2380
List<Expression> expressions = new ArrayList<Expression>();
@@ -2383,18 +2383,28 @@ NamedExpressionList NamedExpressionList2():
2383
2383
Expression expr2 = null;
2384
2384
Expression expr3 = null;
2385
2385
Expression expr4 = null;
2386
- String name = "";
2387
- Token tk1 = null;
2388
2386
Token tk2 = null;
2389
2387
Token tk3 = null;
2390
2388
Token tk4 = null;
2391
2389
}
2392
2390
{
2391
+ expr1=SimpleExpression()
2392
+ (tk2=<K_FROM>|tk2=<K_IN>|tk2=<K_PLACING>)
2393
+ {
2394
+ names.add("");
2395
+ expressions.add(expr1);
2396
+ names.add(tk2.image);
2397
+ }
2393
2398
(
2394
- expr2=SimpleExpression() { names.add(""); expressions.add(expr2);}
2395
- ( (tk3=<K_FOR>|tk3=<K_FROM>) expr3=SimpleExpression() {names.add(tk3.image); expressions.add(expr3);}
2396
- ( (tk4=<K_FOR>) expr4=SimpleExpression() {names.add(tk4.image); expressions.add(expr4);} )?
2397
- )?
2399
+ expr2=SimpleExpression() { expressions.add(expr2);}
2400
+ (
2401
+ (tk3=<K_FOR>|tk3=<K_FROM>)
2402
+ expr3=SimpleExpression() {names.add(tk3.image); expressions.add(expr3);}
2403
+ (
2404
+ (tk4=<K_FOR>)
2405
+ expr4=SimpleExpression() {names.add(tk4.image); expressions.add(expr4);}
2406
+ )?
2407
+ )?
2398
2408
)
2399
2409
2400
2410
{
@@ -3031,34 +3041,25 @@ Function Function() #Function:
3031
3041
3032
3042
[ "." tmp=RelObjectNameExt() { funcName+= "." + tmp; } ["." tmp=RelObjectNameExt() { funcName+= "." + tmp; }]]
3033
3043
"(" [ [<K_DISTINCT> { retval.setDistinct(true); } | <K_ALL> { retval.setAllColumns(true); }]
3034
- // The addition of functions with named parameters (see NamedExpressionList1, NamedExpressionList2) complicates
3035
- // the parsing of the paramter lists. JavaCC needs factorization here so that the tokens which indicate branch points
3036
- // are exposed.
3037
3044
( LOOKAHEAD(4)
3038
- ( (tk1=<K_BOTH>|tk1=<K_LEADING>|tk1=<K_TRAILING>) namedExpressionList=NamedExpressionList1() {namedExpressionList.getNames().add(0,tk1.image);})
3039
-
3040
- | ( expr1=SimpleExpression() ( ((tk2=<K_FROM>|tk2=<K_IN>|tk2=<K_PLACING>) namedExpressionList=NamedExpressionList2() {namedExpressionList.getNames().set(0,tk2.image); namedExpressionList.getNames().add(0, ""); namedExpressionList.getExpressions().add(0, expr1);})
3041
- | ("," expressionList=SimpleExpressionList() {expressionList.getExpressions().add(0,expr1);} )? ) )
3042
-
3043
- | "*" { retval.setAllColumns(true); }
3044
- | expr = SubSelect() { expr.setUseBrackets(false); expressionList = new ExpressionList(expr); }
3045
- )
3046
- ] ")"
3045
+ namedExpressionList=NamedExpressionList1()
3046
+ |
3047
+ LOOKAHEAD(NamedExpressionListExprFirst()) namedExpressionList = NamedExpressionListExprFirst()
3048
+ |
3049
+ LOOKAHEAD(3) expressionList=SimpleExpressionList()
3050
+ |
3051
+ "*" { retval.setAllColumns(true); }
3052
+ |
3053
+ expr = SubSelect() { expr.setUseBrackets(false); expressionList = new ExpressionList(expr); }
3054
+ )]
3055
+ ")"
3047
3056
3048
3057
[ "." tmp=RelObjectName() { retval.setAttribute(tmp); }]
3049
3058
3050
3059
[ keep = KeepExpression() ]
3051
3060
3052
3061
["}"]
3053
3062
{
3054
- if(expr1 != null && expressionList==null && namedExpressionList == null){
3055
- // If the function has a single parameter, it is consumed before the choice point between
3056
- // named vs. simple expression list. Put it in a simple ExpressionList here.
3057
- expressions = new ArrayList<Expression>();
3058
- expressions.add(expr1);
3059
- expressionList = new ExpressionList();
3060
- expressionList.setExpressions(expressions);
3061
- }
3062
3063
retval.setParameters(expressionList);
3063
3064
retval.setNamedParameters(namedExpressionList);
3064
3065
retval.setName(funcName);
0 commit comments