ASTERIXDB-922: trailing commas in lists
Change-Id: I608f8bd94bf61c37709d3c9df0fc20dd28ea52b5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/410
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index a149700..ef69a5f 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -1946,23 +1946,11 @@
ListConstructor OrderedListConstructor() throws ParseException:
{
ListConstructor expr = new ListConstructor();
- Expression tmp = null;
- List<Expression> exprList = new ArrayList<Expression>();
+ List<Expression> exprList = null;
expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR);
}
{
-
- <LEFTBRACKET>
- ( tmp = Expression()
- {
- exprList.add(tmp);
- }
-
- (<COMMA> tmp = Expression() { exprList.add(tmp); })*
- )?
-
- <RIGHTBRACKET>
-
+ <LEFTBRACKET> exprList = ExpressionList() <RIGHTBRACKET>
{
expr.setExprList(exprList);
return expr;
@@ -1972,23 +1960,40 @@
ListConstructor UnorderedListConstructor() throws ParseException:
{
ListConstructor expr = new ListConstructor();
- Expression tmp = null;
- List<Expression> exprList = new ArrayList<Expression>();
+ List<Expression> exprList = null;
expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR);
}
{
-
- <LEFTDBLBRACE> ( tmp = Expression()
- {
- exprList.add(tmp);
- }
- (<COMMA> tmp = Expression() { exprList.add(tmp); })*)? <RIGHTDBLBRACE>
+ <LEFTDBLBRACE> exprList = ExpressionList() <RIGHTDBLBRACE>
{
expr.setExprList(exprList);
return expr;
}
}
+List<Expression> ExpressionList() throws ParseException:
+{
+ Expression expr = null;
+ List<Expression> list = null;
+ List<Expression> exprList = new ArrayList<Expression>();
+}
+{
+ ( LOOKAHEAD(2)
+ expr = Expression() { exprList.add(expr); }
+ (<COMMA> list = ExpressionList() { exprList.addAll(list); })?
+ )?
+ (Comma())?
+ {
+ return exprList;
+ }
+}
+
+void Comma():
+{}
+{
+ <COMMA>
+}
+
RecordConstructor RecordConstructor() throws ParseException:
{
RecordConstructor expr = new RecordConstructor();