@@ -2347,17 +2347,17 @@ NamedExpressionList NamedExpressionList1():
23472347 List<String> names = new ArrayList<String>();
23482348 Expression expr1 = null;
23492349 Expression expr2 = null;
2350- Expression expr3 = null;
2351- Expression expr4 = null;
23522350 String name = "";
23532351 Token tk1 = null;
23542352 Token tk2 = null;
2355- Token tk3 = null;
2356- Token tk4 = null;
23572353}
23582354{
23592355 (
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);}
23612361 )
23622362
23632363 {
@@ -2374,7 +2374,7 @@ NamedExpressionList NamedExpressionList1():
23742374// overlay(expr1 placing expr2 from expr3)
23752375// overlay(expr1 placing expr2 from expr3 for expr4)
23762376// expr1 has already been consumed
2377- NamedExpressionList NamedExpressionList2 ():
2377+ NamedExpressionList NamedExpressionListExprFirst ():
23782378{
23792379 NamedExpressionList retval = new NamedExpressionList();
23802380 List<Expression> expressions = new ArrayList<Expression>();
@@ -2383,18 +2383,28 @@ NamedExpressionList NamedExpressionList2():
23832383 Expression expr2 = null;
23842384 Expression expr3 = null;
23852385 Expression expr4 = null;
2386- String name = "";
2387- Token tk1 = null;
23882386 Token tk2 = null;
23892387 Token tk3 = null;
23902388 Token tk4 = null;
23912389}
23922390{
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+ }
23932398 (
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+ )?
23982408 )
23992409
24002410 {
@@ -3031,34 +3041,25 @@ Function Function() #Function:
30313041
30323042 [ "." tmp=RelObjectNameExt() { funcName+= "." + tmp; } ["." tmp=RelObjectNameExt() { funcName+= "." + tmp; }]]
30333043 "(" [ [<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.
30373044 ( 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+ ")"
30473056
30483057 [ "." tmp=RelObjectName() { retval.setAttribute(tmp); }]
30493058
30503059 [ keep = KeepExpression() ]
30513060
30523061 ["}"]
30533062 {
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- }
30623063 retval.setParameters(expressionList);
30633064 retval.setNamedParameters(namedExpressionList);
30643065 retval.setName(funcName);
0 commit comments