[Pkg-javascript-commits] [node-acorn-jsx] 321/484: Avoid separate handling of SpreadElement in favor of UnaryExpression parser.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:49 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 72df78cc883a565cfca5118cefa89b7ab576d86d
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Sun Oct 26 20:58:05 2014 +0200

    Avoid separate handling of SpreadElement in favor of UnaryExpression parser.
---
 acorn.js | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/acorn.js b/acorn.js
index e6658d8..e6a6e64 100644
--- a/acorn.js
+++ b/acorn.js
@@ -401,8 +401,9 @@
   var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
   var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"};
   var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true};
-  var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _ellipsis = {type: "..."}, _question = {type: "?", beforeExpr: true};
+  var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};
   var _arrow = {type: "=>", beforeExpr: true}, _bquote = {type: "`"}, _dollarBraceL = {type: "${", beforeExpr: true};
+  var _ellipsis = {type: "...", prefix: true, beforeExpr: true};
 
   // Operators. These carry several kinds of properties to help the
   // parser use them properly (the presence of these properties is
@@ -1949,6 +1950,8 @@
   function parseMaybeUnary() {
     if (tokType.prefix) {
       var node = startNode(), update = tokType.isUpdate;
+      var nodeType = tokType === _ellipsis ? "SpreadElement" :
+        (update ? "UpdateExpression" : "UnaryExpression");
       node.operator = tokVal;
       node.prefix = true;
       tokRegexpAllowed = true;
@@ -1958,7 +1961,7 @@
       else if (strict && node.operator === "delete" &&
                node.argument.type === "Identifier")
         raise(node.start, "Deleting local variable in strict mode");
-      return finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
+      return finishNode(node, nodeType);
     }
     var start = storeCurrentPos();
     var expr = parseExprSubscripts();
@@ -2115,9 +2118,6 @@
     case _new:
       return parseNew();
 
-    case _ellipsis:
-      return parseSpread();
-
     case _bquote:
       return parseTemplate();
 
@@ -2140,15 +2140,6 @@
     return finishNode(node, "NewExpression");
   }
 
-  // Parse spread element '...expr'
-
-  function parseSpread() {
-    var node = startNode();
-    next();
-    node.argument = parseExpression(true);
-    return finishNode(node, "SpreadElement");
-  }
-
   // Parse template expression.
 
   function parseTemplate() {

-- 
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