[Pkg-javascript-commits] [node-acorn-jsx] 341/484: Loose: respect optional semicolons in break/continue/class/import/export.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:53 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 fc2e96fa01ba6b24fea6e366e2946e4c41d13ccc
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Tue Oct 28 18:43:37 2014 +0200

    Loose: respect optional semicolons in break/continue/class/import/export.
---
 acorn_loose.js | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index dd1ea90..f551679 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -315,8 +315,12 @@
     case tt._break: case tt._continue:
       next();
       var isBreak = starttype === tt._break;
-      node.label = token.type === tt.name ? parseIdent() : null;
-      semicolon();
+      if (semicolon() || canInsertSemicolon()) {
+        node.label = null;
+      } else {
+        node.label = token.type === tt.name ? parseIdent() : null;
+        semicolon();
+      }
       return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
 
     case tt._debugger:
@@ -771,6 +775,35 @@
     return finishNode(node, "NewExpression");
   }
 
+  function parseTemplate() {
+    var node = startNode();
+    node.expressions = [];
+    node.quasis = [];
+    inTemplate = true;
+    next();
+    for (;;) {
+      var elem = startNode();
+      elem.value = {cooked: tokVal, raw: input.slice(tokStart, tokEnd)};
+      elem.tail = false;
+      next();
+      node.quasis.push(finishNode(elem, "TemplateElement"));
+      if (tokType === _bquote) { // '`', end of template
+        elem.tail = true;
+        break;
+      }
+      inTemplate = false;
+      expect(_dollarBraceL);
+      node.expressions.push(parseExpression());
+      inTemplate = true;
+      // hack to include previously skipped space
+      tokPos = tokEnd;
+      expect(_braceR);
+    }
+    inTemplate = false;
+    next();
+    return finishNode(node, "TemplateLiteral");
+  }
+
   function parseObj(isClass, isStatement) {
     var node = startNode();
     if (isClass) {
@@ -836,6 +869,7 @@
     popCx();
     eat(tt.braceR);
     if (isClass) {
+      semicolon();
       finishNode(node.body, "ClassBody");
       return finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
     } else {
@@ -983,6 +1017,7 @@
       node.declaration = null;
       parseSpecifierList(node, "Export");
     }
+    semicolon();
     return finishNode(node, "ExportDeclaration");
   }
 
@@ -1007,6 +1042,7 @@
       for (var i = 0; i < specs.length; i++) specs[i]['default'] = false;
       if (elt) node.specifiers.unshift(elt);
     }
+    semicolon();
     return finishNode(node, "ImportDeclaration");
   }
 

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