[Pkg-javascript-commits] [node-acorn-jsx] 232/484: Removed `module`-related tests and implemented corresponding alternatives support.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:35 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 26818e1f36ebc9992ebec280b1df03657dc474d1
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Fri Jul 25 22:37:25 2014 +0300
Removed `module`-related tests and implemented corresponding alternatives support.
`module ModuleName { ... }` was removed from spec in favor of separate files.
`module LocalName from '...'` is being replaced with `import * as LocalName from '...'` as per http://jsmodules.io/ and https://twitter.com/domenic/status/492735387140243456 (c) @domenic.
---
acorn.js | 112 +++-
index.html | 98 +++-
test/tests-harmony.js | 1426 ++++---------------------------------------------
3 files changed, 257 insertions(+), 1379 deletions(-)
diff --git a/acorn.js b/acorn.js
index 60ee4c4..86a7762 100644
--- a/acorn.js
+++ b/acorn.js
@@ -287,8 +287,7 @@
var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true};
var _this = {keyword: "this"};
var _class = {keyword: "class"}, _extends = {keyword: "extends", beforeExpr: true}, _static = {keyword: "static"};
- var _module = {keyword: "module"}, _export = {keyword: "export"};
- var _import = {keyword: "import"}, _from = {keyword: "from"}, _as = {keyword: "as"};
+ var _export = {keyword: "export"}, _import = {keyword: "import"}, _from = {keyword: "from"}, _as = {keyword: "as"};
// The keywords that denote values.
@@ -316,8 +315,7 @@
"void": {keyword: "void", prefix: true, beforeExpr: true},
"delete": {keyword: "delete", prefix: true, beforeExpr: true},
"class": _class, "extends": _extends, "static": _static, "of": _of,
- "module": _module, "export": _export, "import": _import,
- "from": _from, "as": _as};
+ "export": _export, "import": _import, "from": _from, "as": _as};
// Punctuation token types. Again, the `type` property is purely for debugging.
@@ -436,7 +434,7 @@
var isEcma5AndLessKeyword = makePredicate(ecma5AndLessKeywords);
- var isEcma6Keyword = makePredicate(ecma5AndLessKeywords + " let const class extends static of module export import from as");
+ var isEcma6Keyword = makePredicate(ecma5AndLessKeywords + " let const class extends static of export import from as");
var isKeyword = isEcma5AndLessKeyword;
@@ -1254,6 +1252,7 @@
case _braceL: return parseBlock(); // no point creating a function for this
case _semi: return parseEmptyStatement(node);
case _export: return parseExport(node);
+ case _import: return parseImport(node);
// If the statement does not start with a statement keyword or a
// brace, it's an ExpressionStatement or LabeledStatement. We
@@ -2178,41 +2177,108 @@
function parseExport(node) {
next();
+ // export var|const|let|function|class ...;
if (tokType === _var || tokType === _const || tokType === _let || tokType === _function || tokType === _class) {
node.declaration = parseStatement();
node.default = false;
node.specifiers = null;
node.source = null;
} else
+ // export default ...;
if (eat(_default)) {
node.declaration = parseExpression(true);
node.default = true;
node.specifiers = null;
node.source = null;
semicolon();
- } else
- if (tokVal === '*') {
+ } else {
+ // export * from '...'
+ // export { x, y as z } [from '...']
+ var isBatch = tokVal === '*';
node.declaration = null;
node.default = false;
- var specifier = startNode();
+ node.specifiers = parseExportSpecifiers();
+ if (isBatch || tokType === _from) {
+ expect(_from);
+ node.source = tokType === _string ? parseExprAtom() : unexpected();
+ } else {
+ node.source = null;
+ }
+ }
+ return finishNode(node, "ExportDeclaration");
+ }
+
+ // Parses a comma-separated list of module exports.
+
+ function parseExportSpecifiers() {
+ var nodes = [], first = true;
+ if (tokVal === "*") {
+ // export * from '...'
+ var node = startNode();
next();
- node.specifiers = [finishNode(specifier, "ExportBatchSpecifier")];
+ nodes.push(finishNode(node, "ExportBatchSpecifier"));
+ } else {
+ // export { x, y as z } [from '...']
+ expect(_braceL);
+ while (!eat(_braceR)) {
+ if (!first) {
+ expect(_comma);
+ if (options.allowTrailingCommas && eat(_braceR)) break;
+ } else first = false;
+
+ var node = startNode();
+ node.id = parseIdent();
+ node.name = eat(_as) ? parseIdent(true) : null;
+ nodes.push(finishNode(node, "ExportSpecifier"));
+ }
+ }
+ return nodes;
+ }
+
+ // Parses import declaration.
+
+ function parseImport(node) {
+ next();
+ // import '...';
+ if (tokType === _string) {
+ node.specifiers = [];
+ node.source = parseExprAtom();
+ node.kind = "";
+ } else {
+ node.specifiers = parseImportSpecifiers();
expect(_from);
node.source = tokType === _string ? parseExprAtom() : unexpected();
- } else
- if (eat(_braceL)) {
- node.declaration = null;
- node.default = false;
- node.specifiers = parseModuleSpecifiers("ExportSpecifier");
- node.source = eat(_from) ? (tokType === _string ? parseExprAtom() : unexpected()) : null;
- } else unexpected();
- return finishNode(node, "ExportDeclaration");
+ // only for backward compatibility with Esprima's AST
+ // (it doesn't support mixed default + named yet)
+ node.kind = node.specifiers[0].default ? "default" : "named";
+ }
+ return finishNode(node, "ImportDeclaration");
}
- // Parses a comma-separated list of module imports/exports.
+ // Parses a comma-separated list of module imports.
- function parseModuleSpecifiers(type) {
+ function parseImportSpecifiers() {
var nodes = [], first = true;
+ if (tokVal === '*') {
+ var node = startNode();
+ next();
+ expect(_as);
+ node.name = parseIdent();
+ checkLVal(node.name, true);
+ nodes.push(finishNode(node, "ImportBatchSpecifier"));
+ return nodes;
+ }
+ if (tokType === _name) {
+ // import defaultObj, { x, y as z } from '...'
+ var node = startNode();
+ node.id = parseIdent();
+ checkLVal(node.id, true);
+ node.name = null;
+ node.default = true;
+ nodes.push(finishNode(node, "ImportSpecifier"));
+ if (!eat(_comma)) return nodes;
+ }
+ expect(_braceL);
while (!eat(_braceR)) {
if (!first) {
expect(_comma);
@@ -2220,9 +2286,11 @@
} else first = false;
var node = startNode();
- node.id = parseIdent();
- node.name = eat(_as) ? parseIdent(true) : null;
- nodes.push(finishNode(node, type));
+ node.id = parseIdent(true);
+ node.name = eat(_as) ? parseIdent() : null;
+ checkLVal(node.name || node.id, true);
+ node.default = false;
+ nodes.push(finishNode(node, "ImportSpecifier"));
}
return nodes;
}
diff --git a/index.html b/index.html
index 72770c4..6a06009 100644
--- a/index.html
+++ b/index.html
@@ -179,8 +179,7 @@ continue jumps to that label.</p> </td> <td class="code"
<span class="kd">var</span> <span class="nx">_while</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"while"</span><span class="p">,</span> <span class="nx">isLoop</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span> <span class="nx">_with</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2" [...]
<span class="kd">var</span> <span class="nx">_this</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"this"</span><span class="p">};</span>
<span class="kd">var</span> <span class="nx">_class</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"class"</span><span class="p">},</span> <span class="nx">_extends</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"extends"</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</ [...]
- <span class="kd">var</span> <span class="nx">_module</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"module"</span><span class="p">},</span> <span class="nx">_export</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"export"</span><span class="p">};</span>
- <span class="kd">var</span> <span class="nx">_import</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"import"</span><span class="p">},</span> <span class="nx">_from</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"from"</span><span class="p">},</span> <span class="nx">_as</span> <span class="o">=</span> <sp [...]
+ <span class="kd">var</span> <span class="nx">_export</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"export"</span><span class="p">},</span> <span class="nx">_import</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"import"</span><span class="p">},</span> <span class="nx">_from</span> <span class="o">=</spa [...]
<span class="kd">var</span> <span class="nx">_false</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"false"</span><span class="p">,</span> <span class="nx">atomValue</span><span class="o">:</span> <span class="kc">false</span><span class="p">};</span></pre></div> </td> </tr> <tr id="section-35"> <td class="docs"> <div c [...]
(when parsing <code>for</code>) needs to be tested against specifically, so
we assign a variable name to it for quick comparing.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">_in</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"in"</span><span class="p">,</span> <span class="nx">binop</span><span class="o">:</span> <span class="mi">7</span><span class="p">,</span> <span class="nx [...]
@@ -196,8 +195,7 @@ we assign a variable name to it for quick comparing.</p> </td>
<span class="s2">"void"</span><span class="o">:</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"void"</span><span class="p">,</span> <span class="nx">prefix</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span>
<span class="s2">"delete"</span><span class="o">:</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"delete"</span><span class="p">,</span> <span class="nx">prefix</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span>
<span class="s2">"class"</span><span class="o">:</span> <span class="nx">_class</span><span class="p">,</span> <span class="s2">"extends"</span><span class="o">:</span> <span class="nx">_extends</span><span class="p">,</span> <span class="s2">"static"</span><span class="o">:</span> <span class="nx">_static</span><span class="p">,</span> <span class="s2">"of"</span><span class="o">:</span> <span class="nx">_of</span><span class [...]
- <span class="s2">"module"</span><span class="o">:</span> <span class="nx">_module</span><span class="p">,</span> <span class="s2">"export"</span><span class="o">:</span> <span class="nx">_export</span><span class="p">,</span> <span class="s2">"import"</span><span class="o">:</span> <span class="nx">_import</span><span class="p">,</span>
- <span class="s2">"from"</span><span class="o">:</span> <span class="nx">_from</span><span class="p">,</span> <span class="s2">"as"</span><span class="o">:</span> <span class="nx">_as</span><span class="p">};</span></pre></div> </td> </tr> <tr id="section-37"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-37">¶</a> [...]
+ <span class="s2">"export"</span><span class="o">:</span> <span class="nx">_export</span><span class="p">,</span> <span class="s2">"import"</span><span class="o">:</span> <span class="nx">_import</span><span class="p">,</span> <span class="s2">"from"</span><span class="o">:</span> <span class="nx">_from</span><span class="p">,</span> <span class="s2">"as"</span><span class="o">:</span> <span class="nx">_as</span><span class="p" [...]
<span class="kd">var</span> <span class="nx">_braceR</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="s2">"}"</span><span class="p">},</span> <span class="nx">_parenL</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="s2">"("</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span clas [...]
<span class="kd">var</span> <span class="nx">_comma</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="s2">","</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span> <span class="nx">_semi</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="s2">" [...]
<span class="kd">var</span> <span class="nx">_colon</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="s2">":"</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span> <span class="nx">_dot</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="s2">" [...]
@@ -272,7 +270,7 @@ switch first dispatches on the lengths, to save on comparisons.</p>
<span class="kd">var</span> <span class="nx">isEcma5AndLessKeyword</span> <span class="o">=</span> <span class="nx">makePredicate</span><span class="p">(</span><span class="nx">ecma5AndLessKeywords</span><span class="p">);</span>
- <span class="kd">var</span> <span class="nx">isEcma6Keyword</span> <span class="o">=</span> <span class="nx">makePredicate</span><span class="p">(</span><span class="nx">ecma5AndLessKeywords</span> <span class="o">+</span> <span class="s2">" let const class extends static of module export import from as"</span><span class="p">);</span>
+ <span class="kd">var</span> <span class="nx">isEcma6Keyword</span> <span class="o">=</span> <span class="nx">makePredicate</span><span class="p">(</span><span class="nx">ecma5AndLessKeywords</span> <span class="o">+</span> <span class="s2">" let const class extends static of export import from as"</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">isKeyword</span> <span class="o">=</span> <span class="nx">isEcma5AndLessKeyword</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-48"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-48">¶</a> </div> <h2>Character categories</h2> </td> <td class= [...]
whitespace, identifier, and identifier-start categories. These
@@ -914,7 +912,8 @@ complexity.</p> </td> <td class="code"> <d
<span class="k">case</span> <span class="nx">_with</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseWithStatement</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
<span class="k">case</span> <span class="nx">_braceL</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseBlock</span><span class="p">();</span> <span class="c1">// no point creating a function for this</span>
<span class="k">case</span> <span class="nx">_semi</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseEmptyStatement</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
- <span class="k">case</span> <span class="nx">_export</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseExport</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-99"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-99">¶</a> </div> [...]
+ <span class="k">case</span> <span class="nx">_export</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseExport</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
+ <span class="k">case</span> <span class="nx">_import</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseImport</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-99"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-99">¶</a> </div> [...]
brace, it's an ExpressionStatement or LabeledStatement. We
simply start parsing an expression, and afterwards, if the
next token is a colon and the expression was a simple
@@ -1690,38 +1689,81 @@ if possible.</p> </td> <td class="code"> <
<span class="k">if</span> <span class="p">(</span><span class="nx">node</span><span class="p">.</span><span class="nx">type</span> <span class="o">!==</span> <span class="s2">"Identifier"</span> <span class="o">&&</span> <span class="nx">node</span><span class="p">.</span><span class="nx">type</span> <span class="o">!==</span> <span class="s2">"ArrayPattern"</span><span class="p">)</span>
<span class="nx">unexpected</span><span class="p">(</span><span class="nx">node</span><span class="p">.</span><span class="nx">start</span><span class="p">);</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-140"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-140">¶</a> </div> <p>Parses module export declaration.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">parseExport</span [...]
- <span class="nx">next</span><span class="p">();</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_var</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_const</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_let</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_function</span> < [...]
+ <span class="nx">next</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-141"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-141">¶</a> </div> <p>export var|const|let|function|class ...;</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> [...]
<span class="nx">node</span><span class="p">.</span><span class="nx">declaration</span> <span class="o">=</span> <span class="nx">parseStatement</span><span class="p">();</span>
<span class="nx">node</span><span class="p">.</span><span class="k">default</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
- <span class="p">}</span> <span class="k">else</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">eat</span><span class="p">(</span><span class="nx">_default</span><span class="p">))</span> <span class="p">{</span>
+ <span class="p">}</span> <span class="k">else</span></pre></div> </td> </tr> <tr id="section-142"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-142">¶</a> </div> <p>export default ...;</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span [...]
<span class="nx">node</span><span class="p">.</span><span class="nx">declaration</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
<span class="nx">node</span><span class="p">.</span><span class="k">default</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="nx">semicolon</span><span class="p">();</span>
- <span class="p">}</span> <span class="k">else</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">tokVal</span> <span class="o">===</span> <span class="s1">'*'</span><span class="p">)</span> <span class="p">{</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-143"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-143">¶</a> </div> <p>export * from '...'
+export { x, y as z } [from '...']</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">isBatch</span> <span class="o">=</span> <span class="nx">tokVal</span> <span class="o">===</span> <span class="s1">'*'</span><span class="p">;</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">declaration</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="nx">node</span><span class="p">.</span><span class="k">default</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
- <span class="kd">var</span> <span class="nx">specifier</span> <span class="o">=</span> <span class="nx">startNode</span><span class="p">();</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="nx">parseExportSpecifiers</span><span class="p">();</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">isBatch</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_from</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">_from</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_string</span> <span class="o">?</span> <span class="nx">parseExprAtom</span><span class="p">()</span> <span class="o">:</span> <span class="nx">unexpected</span><span class="p">();</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="p">}</span>
+ <span class="p">}</span>
+ <span class="k">return</span> <span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ExportDeclaration"</span><span class="p">);</span>
+ <span class="p">}</span></pre></div> </td> </tr> <tr id="section-144"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-144">¶</a> </div> <p>Parses a comma-separated list of module exports.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">pa [...]
+ <span class="kd">var</span> <span class="nx">nodes</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">first</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">tokVal</span> <span class="o">===</span> <span class="s2">"*"</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-145"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-145">¶</a> </div> <p>export * from '...'</p> [...]
<span class="nx">next</span><span class="p">();</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="p">[</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">specifier</span><span class="p">,</span> <span class="s2">"ExportBatchSpecifier"</span><span class="p">)];</span>
+ <span class="nx">nodes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ExportBatchSpecifier"</span><span class="p">));</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-146"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-146">¶</a> </div> <p>export { x, y as z } [from '...']</p> </td> <td class="code"> <div class="highlight"><pre> <span cl [...]
+ <span class="k">while</span> <span class="p">(</span><span class="o">!</span><span class="nx">eat</span><span class="p">(</span><span class="nx">_braceR</span><span class="p">))</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">first</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">_comma</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">allowTrailingCommas</span> <span class="o">&&</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_braceR</span><span class="p">))</span> <span class="k">break</span><span class="p">;</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="nx">first</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
+
+ <span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="nx">startNode</span><span class="p">();</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">parseIdent</span><span class="p">();</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_as</span><span class="p">)</span> <span class="o">?</span> <span class="nx">parseIdent</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="nx">nodes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ExportSpecifier"</span><span class="p">));</span>
+ <span class="p">}</span>
+ <span class="p">}</span>
+ <span class="k">return</span> <span class="nx">nodes</span><span class="p">;</span>
+ <span class="p">}</span></pre></div> </td> </tr> <tr id="section-147"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-147">¶</a> </div> <p>Parses import declaration.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">parseImport</span><span [...]
+ <span class="nx">next</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-148"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-148">¶</a> </div> <p>import '...';</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><sp [...]
+ <span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="p">[];</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="nx">parseExprAtom</span><span class="p">();</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">kind</span> <span class="o">=</span> <span class="s2">""</span><span class="p">;</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="nx">parseImportSpecifiers</span><span class="p">();</span>
<span class="nx">expect</span><span class="p">(</span><span class="nx">_from</span><span class="p">);</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_string</span> <span class="o">?</span> <span class="nx">parseExprAtom</span><span class="p">()</span> <span class="o">:</span> <span class="nx">unexpected</span><span class="p">();</span>
- <span class="p">}</span> <span class="k">else</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">eat</span><span class="p">(</span><span class="nx">_braceL</span><span class="p">))</span> <span class="p">{</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">declaration</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
- <span class="nx">node</span><span class="p">.</span><span class="k">default</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span> <span class="o">=</span> <span class="nx">parseModuleSpecifiers</span><span class="p">(</span><span class="s2">"ExportSpecifier"</span><span class="p">);</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_from</span><span class="p">)</span> <span class="o">?</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_string</span> <span class="o">?</span> <span class="nx">parseExprAtom</span><span class="p">()</span> <span class="o">:</span> <span class="nx">une [...]
- <span class="p">}</span> <span class="k">else</span> <span class="nx">unexpected</span><span class="p">();</span>
- <span class="k">return</span> <span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ExportDeclaration"</span><span class="p">);</span>
- <span class="p">}</span></pre></div> </td> </tr> <tr id="section-141"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-141">¶</a> </div> <p>Parses a comma-separated list of module imports/exports.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class [...]
+ <span class="nx">node</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_string</span> <span class="o">?</span> <span class="nx">parseExprAtom</span><span class="p">()</span> <span class="o">:</span> <span class="nx">unexpected</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-149"> <td [...]
+(it doesn't support mixed default + named yet)</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">node</span><span class="p">.</span><span class="nx">kind</span> <span class="o">=</span> <span class="nx">node</span><span class="p">.</span><span class="nx">specifiers</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="k">default</span> <span class="o">?</span> <span class="s2">" [...]
+ <span class="p">}</span>
+ <span class="k">return</span> <span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ImportDeclaration"</span><span class="p">);</span>
+ <span class="p">}</span></pre></div> </td> </tr> <tr id="section-150"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-150">¶</a> </div> <p>Parses a comma-separated list of module imports.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">pa [...]
<span class="kd">var</span> <span class="nx">nodes</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">first</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">tokVal</span> <span class="o">===</span> <span class="s1">'*'</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="nx">startNode</span><span class="p">();</span>
+ <span class="nx">next</span><span class="p">();</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">_as</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">parseIdent</span><span class="p">();</span>
+ <span class="nx">checkLVal</span><span class="p">(</span><span class="nx">node</span><span class="p">.</span><span class="nx">name</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+ <span class="nx">nodes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ImportBatchSpecifier"</span><span class="p">));</span>
+ <span class="k">return</span> <span class="nx">nodes</span><span class="p">;</span>
+ <span class="p">}</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_name</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-151"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-151">¶</a> </div> <p>import defaultObj, { x, y as z } [...]
+ <span class="nx">node</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">parseIdent</span><span class="p">();</span>
+ <span class="nx">checkLVal</span><span class="p">(</span><span class="nx">node</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="nx">node</span><span class="p">.</span><span class="k">default</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+ <span class="nx">nodes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ImportSpecifier"</span><span class="p">));</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">eat</span><span class="p">(</span><span class="nx">_comma</span><span class="p">))</span> <span class="k">return</span> <span class="nx">nodes</span><span class="p">;</span>
+ <span class="p">}</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">_braceL</span><span class="p">);</span>
<span class="k">while</span> <span class="p">(</span><span class="o">!</span><span class="nx">eat</span><span class="p">(</span><span class="nx">_braceR</span><span class="p">))</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">first</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">expect</span><span class="p">(</span><span class="nx">_comma</span><span class="p">);</span>
@@ -1729,9 +1771,11 @@ if possible.</p> </td> <td class="code"> <
<span class="p">}</span> <span class="k">else</span> <span class="nx">first</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="nx">startNode</span><span class="p">();</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">parseIdent</span><span class="p">();</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_as</span><span class="p">)</span> <span class="o">?</span> <span class="nx">parseIdent</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
- <span class="nx">nodes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">type</span><span class="p">));</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">parseIdent</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_as</span><span class="p">)</span> <span class="o">?</span> <span class="nx">parseIdent</span><span class="p">()</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="nx">checkLVal</span><span class="p">(</span><span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">||</span> <span class="nx">node</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="k">default</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
+ <span class="nx">nodes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">finishNode</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="s2">"ImportSpecifier"</span><span class="p">));</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">nodes</span><span class="p">;</span>
<span class="p">}</span>
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index eed9244..ac98e27 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -4811,129 +4811,6 @@ test("var {a:b} = {}", {
// Harmony: Modules
-test("module \"crypto\" {}", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- range: [7, 15],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 15}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [],
- range: [16, 18],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 18}
- }
- },
- range: [0, 18],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- range: [0, 18],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module crypto from \"crypto\";", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Identifier",
- name: "crypto",
- range: [7, 13],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 13}
- }
- },
- source: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- range: [19, 27],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 27}
- }
- },
- body: null,
- range: [0, 28],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
- }],
- range: [0, 28],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"crypto/e\" {}", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "crypto/e",
- raw: "\"crypto/e\"",
- range: [7, 17],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 17}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [],
- range: [18, 20],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 20}
- }
- },
- range: [0, 20],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- range: [0, 20],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
test("export var document", {
type: "Program",
body: [{
@@ -5544,1014 +5421,70 @@ test("export { encrypt as default }", {
ecmaVersion: 6,
ranges: true,
locations: true
-});
-
-test("export { encrypt, decrypt as dec }", {
- type: "Program",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [
- {
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "encrypt",
- range: [9, 16],
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- name: null,
- range: [9, 16],
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- {
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "decrypt",
- range: [18, 25],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- },
- name: {
- type: "Identifier",
- name: "dec",
- range: [29, 32],
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 32}
- }
- },
- range: [18, 32],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 32}
- }
- }
- ],
- source: null,
- range: [0, 34],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
- }],
- range: [0, 34],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export var document }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- range: [26, 34],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 34}
- }
- },
- init: null,
- range: [26, 34],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 34}
- }
- }],
- kind: "var",
- range: [22, 35],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 35}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 35],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 35}
- }
- }],
- range: [13, 36],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 36}
- }
- },
- range: [0, 36],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }],
- range: [0, 36],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export var document = { } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- range: [26, 34],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 34}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- range: [37, 40],
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 40}
- }
- },
- range: [26, 40],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 40}
- }
- }],
- kind: "var",
- range: [22, 41],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 41}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 41],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 41}
- }
- }],
- range: [13, 42],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 42}
- }
- },
- range: [0, 42],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 42}
- }
- }],
- range: [0, 42],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 42}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export let document }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- range: [26, 34],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 34}
- }
- },
- init: null,
- range: [26, 34],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 34}
- }
- }],
- kind: "let",
- range: [22, 35],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 35}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 35],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 35}
- }
- }],
- range: [13, 36],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 36}
- }
- },
- range: [0, 36],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }],
- range: [0, 36],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export let document = { } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- range: [26, 34],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 34}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- range: [37, 40],
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 40}
- }
- },
- range: [26, 40],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 40}
- }
- }],
- kind: "let",
- range: [22, 41],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 41}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 41],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 41}
- }
- }],
- range: [13, 42],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 42}
- }
- },
- range: [0, 42],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 42}
- }
- }],
- range: [0, 42],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 42}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export const document = { } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- range: [28, 36],
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 36}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- range: [39, 42],
- loc: {
- start: {line: 1, column: 39},
- end: {line: 1, column: 42}
- }
- },
- range: [28, 42],
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 42}
- }
- }],
- kind: "const",
- range: [22, 43],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 43}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 43],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 43}
- }
- }],
- range: [13, 44],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 44}
- }
- },
- range: [0, 44],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
- }],
- range: [0, 44],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export function parse() { } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "parse",
- range: [31, 36],
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 36}
- }
- },
- params: [],
- defaults: [],
- body: {
- type: "BlockStatement",
- body: [],
- range: [39, 42],
- loc: {
- start: {line: 1, column: 39},
- end: {line: 1, column: 42}
- }
- },
- rest: null,
- generator: false,
- expression: false,
- range: [22, 42],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 42}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 42],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 42}
- }
- }],
- range: [13, 44],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 44}
- }
- },
- range: [0, 44],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
- }],
- range: [0, 44],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export class Class {} }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Class",
- range: [28, 33],
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 33}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [],
- range: [34, 36],
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 36}
- }
- },
- range: [22, 36],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 36}
- }
- },
- specifiers: null,
- source: null,
- range: [15, 36],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 36}
- }
- }],
- range: [13, 38],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 38}
- }
- },
- range: [0, 38],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
- }],
- range: [0, 38],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"lib\" { export * }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "lib",
- raw: "\"lib\"",
- range: [7, 12],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [{
- type: "ExportBatchSpecifier",
- range: [22, 23],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- }],
- source: null,
- range: [15, 24],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 24}
- }
- }],
- range: [13, 25],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 25}
- }
- },
- range: [0, 25],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- range: [0, 25],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"security\" { export * from \"crypto\" }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "security",
- raw: "\"security\"",
- range: [7, 17],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 17}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [{
- type: "ExportBatchSpecifier",
- range: [27, 28],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 28}
- }
- }],
- source: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- range: [34, 42],
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 42}
- }
- },
- range: [20, 43],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 43}
- }
- }],
- range: [18, 44],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 44}
- }
- },
- range: [0, 44],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
- }],
- range: [0, 44],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"crypto\" { export { encrypt } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- range: [7, 15],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 15}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [{
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "encrypt",
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- name: null,
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- }],
- source: null,
- range: [18, 37],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 37}
- }
- }],
- range: [16, 38],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 38}
- }
- },
- range: [0, 38],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
- }],
- range: [0, 38],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"crypto\" { export { encrypt, decrypt } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- range: [7, 15],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 15}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [
- {
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "encrypt",
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- name: null,
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- {
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "decrypt",
- range: [36, 43],
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 43}
- }
- },
- name: null,
- range: [36, 43],
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 43}
- }
- }
- ],
- source: null,
- range: [18, 46],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 46}
- }
- }],
- range: [16, 47],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 47}
- }
- },
- range: [0, 47],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 47}
- }
- }],
- range: [0, 47],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 47}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"crypto\" { export { encrypt, decrypt as dec } }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- range: [7, 15],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 15}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [
- {
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "encrypt",
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- name: null,
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- {
- type: "ExportSpecifier",
- id: {
- type: "Identifier",
- name: "decrypt",
- range: [36, 43],
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 43}
- }
- },
- name: {
- type: "Identifier",
- name: "dec",
- range: [47, 50],
- loc: {
- start: {line: 1, column: 47},
- end: {line: 1, column: 50}
- }
- },
- range: [36, 50],
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 50}
- }
+});
+
+test("export { encrypt, decrypt as dec }", {
+ type: "Program",
+ body: [{
+ type: "ExportDeclaration",
+ declaration: null,
+ specifiers: [
+ {
+ type: "ExportSpecifier",
+ id: {
+ type: "Identifier",
+ name: "encrypt",
+ range: [9, 16],
+ loc: {
+ start: {line: 1, column: 9},
+ end: {line: 1, column: 16}
}
- ],
- source: null,
- range: [18, 53],
+ },
+ name: null,
+ range: [9, 16],
+ loc: {
+ start: {line: 1, column: 9},
+ end: {line: 1, column: 16}
+ }
+ },
+ {
+ type: "ExportSpecifier",
+ id: {
+ type: "Identifier",
+ name: "decrypt",
+ range: [18, 25],
+ loc: {
+ start: {line: 1, column: 18},
+ end: {line: 1, column: 25}
+ }
+ },
+ name: {
+ type: "Identifier",
+ name: "dec",
+ range: [29, 32],
+ loc: {
+ start: {line: 1, column: 29},
+ end: {line: 1, column: 32}
+ }
+ },
+ range: [18, 32],
loc: {
start: {line: 1, column: 18},
- end: {line: 1, column: 53}
+ end: {line: 1, column: 32}
}
- }],
- range: [16, 54],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 54}
}
- },
- range: [0, 54],
+ ],
+ source: null,
+ range: [0, 34],
loc: {
start: {line: 1, column: 0},
- end: {line: 1, column: 54}
+ end: {line: 1, column: 34}
}
}],
- range: [0, 54],
+ range: [0, 34],
loc: {
start: {line: 1, column: 0},
- end: {line: 1, column: 54}
+ end: {line: 1, column: 34}
}
}, {
ecmaVersion: 6,
@@ -6847,55 +5780,7 @@ test("import { decrypt, encrypt as enc } from \"crypto\"", {
locations: true
});
-test("import default from \"foo\"", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [{
- type: "ImportSpecifier",
- id: {
- type: "Identifier",
- name: "default",
- range: [7, 14],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 14}
- }
- },
- name: null,
- range: [7, 14],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 14}
- }
- }],
- kind: "default",
- source: {
- type: "Literal",
- value: "foo",
- raw: "\"foo\"",
- range: [20, 25],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 25}
- }
- },
- range: [0, 25],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- range: [0, 25],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
+testFail("import default from \"foo\"", "Unexpected token (1:7)", {ecmaVersion: 6});
test("import { null as nil } from \"bar\"", {
type: "Program",
@@ -6955,164 +5840,59 @@ test("import { null as nil } from \"bar\"", {
locations: true
});
-test("module \"security\" { import \"cryto\" }", {
+test("import * as crypto from \"crypto\"", {
type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "security",
- raw: "\"security\"",
- range: [7, 17],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 17}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ImportDeclaration",
- specifiers: [],
- source: {
- type: "Literal",
- value: "cryto",
- raw: "\"cryto\"",
- range: [27, 34],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- range: [20, 35],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 35}
- }
- }],
- range: [18, 36],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 36}
- }
- },
- range: [0, 36],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }],
- range: [0, 36],
+ start: 0,
+ end: 32,
loc: {
start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module()", {
- type: "Program",
+ end: {line: 1, column: 32}
+ },
+ range: [0, 32],
body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "module",
- range: [0, 6],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 6}
- }
- },
- arguments: [],
- range: [0, 8],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 8}
- }
- },
- range: [0, 8],
+ type: "ImportDeclaration",
+ start: 0,
+ end: 32,
loc: {
start: {line: 1, column: 0},
- end: {line: 1, column: 8}
- }
- }],
- range: [0, 8],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 8}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("module \"foo\" { module() }", {
- type: "Program",
- body: [{
- type: "ModuleDeclaration",
- id: {
- type: "Literal",
- value: "foo",
- raw: "\"foo\"",
- range: [7, 12],
+ end: {line: 1, column: 32}
+ },
+ range: [0, 32],
+ specifiers: [{
+ type: "ImportBatchSpecifier",
+ start: 7,
+ end: 18,
loc: {
start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- source: null,
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "module",
- range: [15, 21],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 21}
- }
- },
- arguments: [],
- range: [15, 23],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 23}
- }
- },
- range: [15, 24],
+ end: {line: 1, column: 18}
+ },
+ range: [7, 18],
+ name: {
+ type: "Identifier",
+ start: 12,
+ end: 18,
loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 24}
- }
- }],
- range: [13, 25],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 25}
+ start: {line: 1, column: 12},
+ end: {line: 1, column: 18}
+ },
+ range: [12, 18],
+ name: "crypto"
}
+ }],
+ source: {
+ type: "Literal",
+ start: 24,
+ end: 32,
+ loc: {
+ start: {line: 1, column: 24},
+ end: {line: 1, column: 32}
+ },
+ range: [24, 32],
+ value: "crypto",
+ raw: "\"crypto\""
},
- range: [0, 25],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- range: [0, 25],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
+ kind: "named"
+ }]
}, {
ecmaVersion: 6,
ranges: true,
@@ -15717,18 +14497,6 @@ testFail("for (let x = 42 in list) process(x);", "Unexpected token (1:16)", {ecm
testFail("for (let x = 42 of list) process(x);", "Unexpected token (1:16)", {ecmaVersion: 6});
-testFail("module\n\"crypto\" {}", "Unexpected token (1:7)", {ecmaVersion: 6});
-
-testFail("module foo from bar", "Unexpected token (1:20)", {ecmaVersion: 6});
-
-testFail("module 42", "Unexpected token (1:8)", {ecmaVersion: 6});
-
-testFail("module foo bar", "Unexpected token (1:12)", {ecmaVersion: 6});
-
-testFail("module \"crypto\" { module \"e\" {} }", "Unexpected token (1:18)", {ecmaVersion: 6});
-
-testFail("module \"x\" { export * from foo }", "Unexpected token (1:31)", {ecmaVersion: 6});
-
testFail("import foo", "Unexpected token (1:11)", {ecmaVersion: 6});
testFail("import { foo, bar }", "Unexpected token (1:20)", {ecmaVersion: 6});
@@ -16096,8 +14864,6 @@ testFail("if (b,...a, );", "Unexpected token (1:11)", {ecmaVersion: 6});
testFail("(b, ...a)", "Unexpected token (1:9)", {ecmaVersion: 6});
-testFail("module \"Universe\" { ; ; ", "Unexpected token (1:27)", {ecmaVersion: 6});
-
testFail("switch (cond) { case 10: let a = 20; ", "Unexpected token (1:37)", {ecmaVersion: 6});
testFail("\"use strict\"; (eval) => 42", "Defining 'eval' in strict mode (1:15)", {ecmaVersion: 6});
--
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