[ASTERIXDB-2028][SQL] No recursion for list creation

- user model changes: no more dangling comma for lists in SQL++
- storage format changes: no
- interface changes: no

details:
- change the production to create expression lists to avoid recursion
- report the class name of Errors (not just the message)

Change-Id: I86b65371bc007b57fd80542f6530db12dd936242
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1936
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest-with-pos/left-outer-unnest-with-pos.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest-with-pos/left-outer-unnest-with-pos.1.query.sqlpp
index 7b8651b..c736e24 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest-with-pos/left-outer-unnest-with-pos.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest-with-pos/left-outer-unnest-with-pos.1.query.sqlpp
@@ -23,7 +23,7 @@
  {'id': 1, 'list': [2, 3]},
  {'id': 4, 'list': [] },
  {'id': 5, 'list': [6, 7]},
- {'id': 8, 'list': []},
+ {'id': 8, 'list': []}
 ] AS a
 LEFT OUTER UNNEST a.list AS item AT i
 ORDER BY a.id
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest/left-outer-unnest.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest/left-outer-unnest.1.query.sqlpp
index 502d073..e7b6882 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest/left-outer-unnest.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/unnest/left-outer-unnest/left-outer-unnest.1.query.sqlpp
@@ -23,7 +23,7 @@
  {'id': 1, 'list': [2, 3]},
  {'id': 4, 'list': [] },
  {'id': 5, 'list': [6, 7]},
- {'id': 8, 'list': []},
+ {'id': 8, 'list': []}
 ] AS a
 LEFT OUTER UNNEST a.list AS item
 ORDER BY a.id
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index bcba939..4c1d174 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -291,7 +291,8 @@
         } catch (Error e) {
             // this is here as the JavaCharStream that's below the lexer somtimes throws Errors that are not handled
             // by the ANTLR-generated lexer or parser (e.g it does this for invalid backslash u + 4 hex digits escapes)
-            throw new CompilationException(new ParseException(e.getMessage()));
+            final String msg = e.getClass().getSimpleName() + (e.getMessage() != null ? ": " + e.getMessage() : "");
+            throw new CompilationException(new ParseException(msg));
         } catch (ParseException e) {
             throw new CompilationException("Syntax error: " + getMessage(e));
         }
@@ -2424,21 +2425,21 @@
 }
 {
     (
-      expr = Expression() { exprList.add(expr); }
-      (LOOKAHEAD(1) <COMMA> list = ExpressionList() { exprList.addAll(list); })?
+      expr = Expression()
+      {
+        exprList.add(expr);
+      }
+      ( <COMMA> expr = Expression()
+        {
+          exprList.add(expr);
+        }
+      )*
     )?
-    (LOOKAHEAD(1) Comma())?
     {
-        return exprList;
+      return exprList;
     }
 }
 
-void Comma():
-{}
-{
-   <COMMA>
-}
-
 RecordConstructor RecordConstructor() throws ParseException:
 {
       RecordConstructor expr = new RecordConstructor();