[Pkg-javascript-commits] [node-acorn-jsx] 324/484: Loose: added support for holes in arrays (but disallows trailing comma).

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:50 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit eba8a5646cde0bdd3f2d7a44c946f977cbe834f7
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Sun Oct 26 23:14:06 2014 +0200

    Loose: added support for holes in arrays (but disallows trailing comma).
---
 acorn_loose.js | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index b0b73b0..87cdbd5 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -702,7 +702,7 @@
     case tt.bracketL:
       var node = startNode();
       pushCx();
-      node.elements = parseExprList(tt.bracketR);
+      node.elements = parseExprList(tt.bracketR, true);
       return finishNode(node, "ArrayExpression");
 
     case tt.braceL:
@@ -861,11 +861,15 @@
     return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
   }
 
-  function parseExprList(close) {
+  function parseExprList(close, allowEmpty) {
     var indent = curIndent, line = curLineStart, elts = [], continuedLine = nextLineStart;
     next(); // Opening bracket
     if (curLineStart > continuedLine) continuedLine = curLineStart;
     while (!closes(close, indent + (curLineStart <= continuedLine ? 1 : 0), line)) {
+      if (allowEmpty && eat(tt.comma)) {
+        elts.push(null);
+        continue;
+      }
       var elt = parseExpression(true);
       if (isDummy(elt)) {
         if (closes(close, indent, line)) break;
@@ -873,7 +877,7 @@
       } else {
         elts.push(elt);
       }
-      while (eat(tt.comma)) {}
+      eat(tt.comma);
     }
     popCx();
     eat(close);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git



More information about the Pkg-javascript-commits mailing list