[Pkg-javascript-commits] [node-acorn-jsx] 335/484: Loose: for-of statement.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:52 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 bdce88c1842186ad0287cce397af981a895fb907
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Mon Oct 27 02:05:38 2014 +0200

    Loose: for-of statement.
---
 acorn_loose.js | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index 4f2dc7a..ec2c44b 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -338,12 +338,17 @@
       if (token.type === tt.semi) return parseFor(node, null);
       if (token.type === tt._var || token.type === tt._let) {
         var init = parseVar(true);
-        if (init.declarations.length === 1 && eat(tt._in))
-          return parseForIn(node, init);
+        if (init.declarations.length === 1) {
+          if (eat(tt._in)) return parseForIn(node, init);
+          if (token.type === tt.name && token.value === "of") {
+            next();
+            return parseForIn(node, init, true);
+          }
+        }
         return parseFor(node, init);
       }
       var init = parseExpression(false, true);
-      if (eat(tt._in)) {return parseForIn(node, checkLVal(init));}
+      if (eat(tt._in)) return parseForIn(node, checkLVal(init));
       return parseFor(node, init);
 
     case tt._function:
@@ -488,13 +493,13 @@
     return finishNode(node, "ForStatement");
   }
 
-  function parseForIn(node, init) {
+  function parseForIn(node, init, isOf) {
     node.left = init;
     node.right = parseExpression();
     popCx();
     expect(tt.parenR);
     node.body = parseStatement();
-    return finishNode(node, "ForInStatement");
+    return finishNode(node, isOf ? "ForOfStatement" : "ForInStatement");
   }
 
   function parseVar(noIn) {
@@ -680,7 +685,7 @@
       var id = parseIdent();
       return eat(tt.arrow) ? parseArrowExpression(startNodeAt(start), [id]) : id;
 
-    case tt.num: case tt.string: case tt.regexp:
+    case tt.num: case tt.string: case tt.regexp: 
       var node = startNode();
       node.value = token.value;
       node.raw = input.slice(token.start, token.end);

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