[Pkg-javascript-commits] [node-acorn-jsx] 231/484: Added export declaration 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 b38c15a94bca0077b8f8ba07f67f1d02eb440663
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Fri Jul 25 20:58:46 2014 +0300
Added export declaration support.
See http://people.mozilla.org/~jorendorff/es6-draft.html#sec-exports, ariya/esprima#216, square/es6-module-transpiler#63 for latest decisions on `export default 42` vs `export default = 42` (first wins, so returning AST as it was in older Esprima Harmony and used by https://github.com/square/es6-module-transpiler/).
---
acorn.js | 62 ++++++++++++++++++++++++++++++++++++--
index.html | 58 +++++++++++++++++++++++++++++++++---
test/tests-harmony.js | 82 ++++++++++++++-------------------------------------
3 files changed, 136 insertions(+), 66 deletions(-)
diff --git a/acorn.js b/acorn.js
index cb0e569..60ee4c4 100644
--- a/acorn.js
+++ b/acorn.js
@@ -287,6 +287,8 @@
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"};
// The keywords that denote values.
@@ -313,7 +315,9 @@
"typeof": {keyword: "typeof", prefix: true, beforeExpr: true},
"void": {keyword: "void", prefix: true, beforeExpr: true},
"delete": {keyword: "delete", prefix: true, beforeExpr: true},
- "class": _class, "extends": _extends, "static": _static, "of": _of};
+ "class": _class, "extends": _extends, "static": _static, "of": _of,
+ "module": _module, "export": _export, "import": _import,
+ "from": _from, "as": _as};
// Punctuation token types. Again, the `type` property is purely for debugging.
@@ -432,7 +436,7 @@
var isEcma5AndLessKeyword = makePredicate(ecma5AndLessKeywords);
- var isEcma6Keyword = makePredicate(ecma5AndLessKeywords + " let const class extends static of");
+ var isEcma6Keyword = makePredicate(ecma5AndLessKeywords + " let const class extends static of module export import from as");
var isKeyword = isEcma5AndLessKeyword;
@@ -1249,6 +1253,7 @@
case _with: return parseWithStatement(node);
case _braceL: return parseBlock(); // no point creating a function for this
case _semi: return parseEmptyStatement(node);
+ case _export: return parseExport(node);
// If the statement does not start with a statement keyword or a
// brace, it's an ExpressionStatement or LabeledStatement. We
@@ -2169,4 +2174,57 @@
unexpected(node.start);
}
+ // Parses module export declaration.
+
+ function parseExport(node) {
+ next();
+ if (tokType === _var || tokType === _const || tokType === _let || tokType === _function || tokType === _class) {
+ node.declaration = parseStatement();
+ node.default = false;
+ node.specifiers = null;
+ node.source = null;
+ } else
+ if (eat(_default)) {
+ node.declaration = parseExpression(true);
+ node.default = true;
+ node.specifiers = null;
+ node.source = null;
+ semicolon();
+ } else
+ if (tokVal === '*') {
+ node.declaration = null;
+ node.default = false;
+ var specifier = startNode();
+ next();
+ node.specifiers = [finishNode(specifier, "ExportBatchSpecifier")];
+ 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");
+ }
+
+ // Parses a comma-separated list of module imports/exports.
+
+ function parseModuleSpecifiers(type) {
+ var nodes = [], first = true;
+ 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, type));
+ }
+ return nodes;
+ }
+
});
diff --git a/index.html b/index.html
index 88ea6a3..72770c4 100644
--- a/index.html
+++ b/index.html
@@ -178,7 +178,9 @@ continue jumps to that label.</p> </td> <td class="code"
<span class="kd">var</span> <span class="nx">_let</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"let"</span><span class="p">},</span> <span class="nx">_const</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"const"</span><span class="p">};</span>
<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">_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">_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 [...]
@@ -193,7 +195,9 @@ we assign a variable name to it for quick comparing.</p> </td>
<span class="s2">"typeof"</span><span class="o">:</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"typeof"</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">"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">"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="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">" [...]
@@ -268,7 +272,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"</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">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
@@ -909,7 +913,8 @@ complexity.</p> </td> <td class="code"> <d
<span class="k">case</span> <span class="nx">_while</span><span class="o">:</span> <span class="k">return</span> <span class="nx">parseWhileStatement</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
<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></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">_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> [...]
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
@@ -1684,6 +1689,51 @@ if possible.</p> </td> <td class="code"> <
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-139"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-139">¶</a> </div> <p>Checks if node can be assignable spread argument.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">c [...]
<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">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="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="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">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">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="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">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="nx">type</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>
<span class="p">});</span>
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index f69ae66..eed9244 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -4965,6 +4965,7 @@ test("export var document", {
end: {line: 1, column: 19}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 19],
@@ -5023,6 +5024,7 @@ test("export var document = { }", {
end: {line: 1, column: 25}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 25],
@@ -5073,6 +5075,7 @@ test("export let document", {
end: {line: 1, column: 19}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 19],
@@ -5131,6 +5134,7 @@ test("export let document = { }", {
end: {line: 1, column: 25}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 25],
@@ -5189,6 +5193,7 @@ test("export const document = { }", {
end: {line: 1, column: 27}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 27],
@@ -5243,6 +5248,7 @@ test("export function parse() { }", {
end: {line: 1, column: 27}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 27],
@@ -5293,6 +5299,7 @@ test("export class Class {}", {
end: {line: 1, column: 21}
}
},
+ default: false,
specifiers: null,
source: null,
range: [0, 21],
@@ -5312,49 +5319,33 @@ test("export class Class {}", {
locations: true
});
-test("export default = 42", {
+test("export default 42", {
type: "Program",
body: [{
type: "ExportDeclaration",
- declaration: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "default",
- range: [7, 14],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 14}
- }
- },
- init: {
- type: "Literal",
- value: 42,
- raw: "42",
- range: [17, 19],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 19}
- }
- },
- range: [7, 19],
+ declaration: {
+ type: "Literal",
+ value: 42,
+ raw: "42",
+ range: [15, 17],
loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 19}
+ start: {line: 1, column: 15},
+ end: {line: 1, column: 17}
}
- }],
+ },
+ default: true,
specifiers: null,
source: null,
- range: [0, 19],
+ range: [0, 17],
loc: {
start: {line: 1, column: 0},
- end: {line: 1, column: 19}
+ end: {line: 1, column: 17}
}
}],
- range: [0, 19],
+ range: [0, 17],
loc: {
start: {line: 1, column: 0},
- end: {line: 1, column: 19}
+ end: {line: 1, column: 17}
}
}, {
ecmaVersion: 6,
@@ -5362,36 +5353,7 @@ test("export default = 42", {
locations: true
});
-test("export *", {
- type: "Program",
- body: [{
- type: "ExportDeclaration",
- declaration: null,
- specifiers: [{
- type: "ExportBatchSpecifier",
- range: [7, 8],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }],
- source: null,
- range: [0, 8],
- 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
-});
+testFail("export *", "Unexpected token (1:8)", {ecmaVersion: 6});
test("export * from \"crypto\"", {
type: "Program",
--
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