[Pkg-javascript-commits] [node-acorn-jsx] 252/484: Treat line ending after yield keyword as end of YieldExpression
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:40 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 acbef8557f2093e9149fbfbf1559b9f8bee56614
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Sun Jul 27 04:24:26 2014 +0300
Treat line ending after yield keyword as end of YieldExpression
(as per http://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-function-definitions-runtime-semantics-evaluation).
---
acorn.js | 9 +++--
index.html | 92 +++++++++++++++++++++++++++++----------------------
test/tests-harmony.js | 80 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 139 insertions(+), 42 deletions(-)
diff --git a/acorn.js b/acorn.js
index 68d6f82..fcb3776 100644
--- a/acorn.js
+++ b/acorn.js
@@ -2436,8 +2436,13 @@
function parseYield() {
var node = startNode();
next();
- node.delegate = eat(_star);
- node.argument = parseExpression(true);
+ if (eat(_semi) || canInsertSemicolon()) {
+ node.delegate = false;
+ node.argument = null;
+ } else {
+ node.delegate = eat(_star);
+ node.argument = parseExpression(true);
+ }
return finishNode(node, "YieldExpression");
}
diff --git a/index.html b/index.html
index 33f1c3f..0e18c66 100644
--- a/index.html
+++ b/index.html
@@ -936,20 +936,21 @@ try to bind the words <code>eval</code> or <code>arguments</code>.</p>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-103"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-103">¶</a> </div> <p>Check if property name clashes with already added.
Object/class getters and setters are not allowed to clash —
either with each other or with an init property — and in
-strict mode, init properties are also not allowed to be repeated.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">checkPropClash</span><span class="p">(</span><span class="nx">prop</span><span class="p">,</span> <span class="nx">defaultKind</span><span class="p">,</span> <span class="nx">propHash</span><span class="p">)</span> <span class="p">{</span>
+strict mode, init properties are also not allowed to be repeated.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">checkPropClash</span><span class="p">(</span><span class="nx">prop</span><span class="p">,</span> <span class="nx">propHash</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="nx">prop</span><span class="p">.</span><span class="nx">key</span><span class="p">,</span> <span class="nx">name</span><span class="p">;</span>
<span class="k">switch</span> <span class="p">(</span><span class="nx">key</span><span class="p">.</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
<span class="k">case</span> <span class="s2">"Identifier"</span><span class="o">:</span> <span class="nx">name</span> <span class="o">=</span> <span class="nx">key</span><span class="p">.</span><span class="nx">name</span><span class="p">;</span> <span class="k">break</span><span class="p">;</span>
<span class="k">case</span> <span class="s2">"Literal"</span><span class="o">:</span> <span class="nx">name</span> <span class="o">=</span> <span class="nb">String</span><span class="p">(</span><span class="nx">key</span><span class="p">.</span><span class="nx">value</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span>
<span class="k">default</span><span class="o">:</span> <span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
- <span class="kd">var</span> <span class="nx">kind</span> <span class="o">=</span> <span class="nx">prop</span><span class="p">.</span><span class="nx">kind</span><span class="p">,</span> <span class="nx">other</span> <span class="o">=</span> <span class="nx">propHash</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
+ <span class="kd">var</span> <span class="nx">kind</span> <span class="o">=</span> <span class="nx">prop</span><span class="p">.</span><span class="nx">kind</span> <span class="o">||</span> <span class="s2">"init"</span><span class="p">,</span> <span class="nx">other</span> <span class="o">=</span> <span class="nx">propHash</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">other</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">isGetSet</span> <span class="o">=</span> <span class="nx">kind</span> <span class="o">!==</span> <span class="nx">defaultKind</span><span class="p">;</span>
- <span class="k">if</span> <span class="p">((</span><span class="nx">strict</span> <span class="o">||</span> <span class="nx">isGetSet</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">other</span><span class="p">[</span><span class="nx">kind</span><span class="p">]</span> <span class="o">||</span> <span class="o">!</span><span class="p">(</span><span class="nx">isGetSet</span> <span class="o">^</span> <span class="nx">other</span><span class="p">[</s [...]
+ <span class="kd">var</span> <span class="nx">isGetSet</span> <span class="o">=</span> <span class="nx">kind</span> <span class="o">!==</span> <span class="s2">"init"</span><span class="p">;</span>
+ <span class="k">if</span> <span class="p">((</span><span class="nx">strict</span> <span class="o">||</span> <span class="nx">isGetSet</span><span class="p">)</span> <span class="o">&&</span> <span class="nx">other</span><span class="p">[</span><span class="nx">kind</span><span class="p">]</span> <span class="o">||</span> <span class="o">!</span><span class="p">(</span><span class="nx">isGetSet</span> <span class="o">^</span> <span class="nx">other</span><span class="p">.</s [...]
<span class="nx">raise</span><span class="p">(</span><span class="nx">key</span><span class="p">.</span><span class="nx">start</span><span class="p">,</span> <span class="s2">"Redefinition of property"</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">other</span> <span class="o">=</span> <span class="nx">propHash</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">hash</span><span class="p">();</span>
+ <span class="nx">other</span><span class="p">.</span><span class="nx">init</span> <span class="o">=</span> <span class="nx">other</span><span class="p">.</span><span class="nx">get</span> <span class="o">=</span> <span class="nx">other</span><span class="p">.</span><span class="nx">set</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="nx">other</span><span class="p">[</span><span class="nx">kind</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-104"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-104">¶</a> </div> <p>Verify that a node is an lval — something that can be assigned
@@ -1448,20 +1449,23 @@ or <code>{}</code>.</p> </td> <td class="code">
<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">"Literal"</span><span class="p">);</span>
<span class="k">case</span> <span class="nx">_parenL</span><span class="o">:</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">tokStartLoc1</span> <span class="o">=</span> <span class="nx">tokStartLoc</span><span class="p">,</span> <span class="nx">tokStart1</span> <span class="o">=</span> <span class="nx">tokStart</span><span class="p">,</span> <span class="nx">val</span><span class="p">,</span> <span class="nx">exprList</span><span class="p">;</span>
- <span class="nx">next</span><span class="p">();</span>
- <span class="kd">var</span> <span class="nx">oldParenL</span> <span class="o">=</span> <span class="o">++</span><span class="nx">metParenL</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">_parenR</span><span class="p">)</span> <span class="p">{</span>
- <span class="nx">val</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
- <span class="nx">exprList</span> <span class="o">=</span> <span class="nx">val</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">"SequenceExpression"</span> <span class="o">?</span> <span class="nx">val</span><span class="p">.</span><span class="nx">expressions</span> <span class="o">:</span> <span class="p">[</span><span class="nx">val</span><span class="p">];</span>
+ <span class="kd">var</span> <span class="nx">tokStartLoc1</span> <span class="o">=</span> <span class="nx">tokStartLoc</span><span class="p">,</span> <span class="nx">tokStart1</span> <span class="o">=</span> <span class="nx">tokStart</span><span class="p">,</span> <span class="nx">val</span><span class="p">,</span> <span class="nx">exprList</span><span class="p">;</span>
+ <span class="nx">next</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-129"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-129">¶</a> </div> <p>check whether this is generator comprehension or regular expression</p> </td> <td class="code"> <div class="highlight"><pre> [...]
+ <span class="nx">val</span> <span class="o">=</span> <span class="nx">parseComprehension</span><span class="p">(</span><span class="nx">startNode</span><span class="p">(),</span> <span class="kc">true</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
- <span class="nx">exprList</span> <span class="o">=</span> <span class="p">[];</span>
- <span class="p">}</span>
- <span class="nx">expect</span><span class="p">(</span><span class="nx">_parenR</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-129"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-129">¶</a> </div> <p>if '=>' follows '(...)', convert contents to arguments</p> </td> <td class="code"> [...]
- <span class="nx">val</span> <span class="o">=</span> <span class="nx">parseArrowExpression</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">exprList</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-130"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-130">¶</a> </div> <p>forbid '()' before everything but '=>'</p> </td> <td class="code"> <div class="highlight"><pre> [...]
- <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">exprList</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">if</span> <span class="p">(</span><span class="nx">exprList</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">"SpreadElement"</span><span class="p">)</span> <span class="nx">unexpected</span><span class="p">();</span>
+ <span class="kd">var</span> <span class="nx">oldParenL</span> <span class="o">=</span> <span class="o">++</span><span class="nx">metParenL</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">_parenR</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">val</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
+ <span class="nx">exprList</span> <span class="o">=</span> <span class="nx">val</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">"SequenceExpression"</span> <span class="o">?</span> <span class="nx">val</span><span class="p">.</span><span class="nx">expressions</span> <span class="o">:</span> <span class="p">[</span><span class="nx">val</span><span class="p">];</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">exprList</span> <span class="o">=</span> <span class="p">[];</span>
+ <span class="p">}</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">_parenR</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-130"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-130">¶</a> </div> <p>if '=>' follows '(...)', convert contents to arguments</p> </td> <td class="code" [...]
+ <span class="nx">val</span> <span class="o">=</span> <span class="nx">parseArrowExpression</span><span class="p">(</span><span class="nx">startNode</span><span class="p">(),</span> <span class="nx">exprList</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-131"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-131">¶</a> </div> <p>forbid '()' before everything but '=>'</p> </td> <td class="code"> <div class="highlight"><pre> [...]
+ <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">exprList</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">exprList</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">type</span> <span class="o">===</span> <span class="s2">"SpreadElement"</span><span class="p">)</span> <span class="nx">unexpected</span><span class="p">();</span>
+ <span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
@@ -1478,25 +1482,8 @@ or <code>{}</code>.</p> </td> <td class="code">
<span class="k">case</span> <span class="nx">_bracketL</span><span class="o">:</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></pre></div> </td> </tr> <tr id="section-132"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-132">¶</a> </div> <p>check whether this is array comprehension or regular array</p> </td> <td class="code"> <div class="highlight"><pre> <spa [...]
- <span class="nx">node</span><span class="p">.</span><span class="nx">blocks</span> <span class="o">=</span> <span class="p">[];</span>
- <span class="k">while</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_for</span><span class="p">)</span> <span class="p">{</span>
- <span class="kd">var</span> <span class="nx">block</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">_parenL</span><span class="p">);</span>
- <span class="nx">block</span><span class="p">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">toAssignable</span><span class="p">(</span><span class="nx">parseExprAtom</span><span class="p">());</span>
- <span class="nx">checkLVal</span><span class="p">(</span><span class="nx">block</span><span class="p">.</span><span class="nx">left</span><span class="p">,</span> <span class="kc">true</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="o">||</span> <span class="nx">tokVal</span> <span class="o">!==</span> <span class="s2">"of"</span><span class="p">)</span> <span class="nx">unexpected</span><span class="p">();</span>
- <span class="nx">next</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-133"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-133">¶</a> </div> <p><code>of</code> property is here for compatibility with Esprima's AST
-which also supports deprecated [for (... in ...) expr]</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">block</span><span class="p">.</span><span class="nx">of</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
- <span class="nx">block</span><span class="p">.</span><span class="nx">right</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
- <span class="nx">expect</span><span class="p">(</span><span class="nx">_parenR</span><span class="p">);</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">blocks</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">block</span><span class="p">,</span> <span class="s2">"ComprehensionBlock"</span><span class="p">));</span>
- <span class="p">}</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">filter</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_if</span><span class="p">)</span> <span class="o">?</span> <span class="nx">parseParenExpression</span><span class="p">()</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">body</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
- <span class="nx">expect</span><span class="p">(</span><span class="nx">_bracketR</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">"ComprehensionExpression"</span><span class="p">);</span>
+ <span class="nx">next</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-133"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-133">¶</a> </div> <p>check whether this is array comprehension or regular array</p> </td> <td class="code"> <div class="highlight"><pre> <spa [...]
+ <span class="k">return</span> <span class="nx">parseComprehension</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">elements</span> <span class="o">=</span> <span class="nx">parseExprList</span><span class="p">(</span><span class="nx">_bracketR</span><span class="p">,</span> <span class="kc">true</span><span class="p">,</span> <span class="kc">true</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">"ArrayExpression"</span><span class="p">);</span>
@@ -1598,7 +1585,7 @@ least, not without wrapping it in parentheses. Thus, it uses the</p>
<span class="nx">prop</span><span class="p">.</span><span class="nx">shorthand</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="nx">unexpected</span><span class="p">();</span>
- <span class="nx">checkPropClash</span><span class="p">(</span><span class="nx">prop</span><span class="p">,</span> <span class="s2">"init"</span><span class="p">,</span> <span class="nx">propHash</span><span class="p">);</span>
+ <span class="nx">checkPropClash</span><span class="p">(</span><span class="nx">prop</span><span class="p">,</span> <span class="nx">propHash</span><span class="p">);</span>
<span class="nx">node</span><span class="p">.</span><span class="nx">properties</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">prop</span><span class="p">,</span> <span class="s2">"Property"</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">"ObjectExpression"</span><span class="p">);</span>
@@ -1754,7 +1741,7 @@ or <code>arguments</code>.</p> </td> <td class="code">
<span class="nx">method</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="nx">method</span><span class="p">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">parseMethod</span><span class="p">(</span><span class="nx">isGenerator</span><span class="p">);</span>
- <span class="nx">checkPropClash</span><span class="p">(</span><span class="nx">method</span><span class="p">,</span> <span class="s2">""</span><span class="p">,</span> <span class="nx">method</span><span class="p">.</span><span class="kr">static</span> <span class="o">?</span> <span class="nx">staticMethodHash</span> <span class="o">:</span> <span class="nx">methodHash</span><span class="p">);</span>
+ <span class="nx">checkPropClash</span><span class="p">(</span><span class="nx">method</span><span class="p">,</span> <span class="nx">method</span><span class="p">.</span><span class="kr">static</span> <span class="o">?</span> <span class="nx">staticMethodHash</span> <span class="o">:</span> <span class="nx">methodHash</span><span class="p">);</span>
<span class="nx">classBody</span><span class="p">.</span><span class="nx">body</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">method</span><span class="p">,</span> <span class="s2">"MethodDefinition"</span><span class="p">));</span>
<span class="nx">eat</span><span class="p">(</span><span class="nx">_semi</span><span class="p">);</span>
<span class="p">}</span>
@@ -1903,9 +1890,34 @@ export { x, y as z } [from '...']</p> </td> <td class="c
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-161"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-161">¶</a> </div> <p>Parses yield expression inside generator.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">parseYiel [...]
<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">node</span><span class="p">.</span><span class="nx">delegate</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_star</span><span class="p">);</span>
- <span class="nx">node</span><span class="p">.</span><span class="nx">argument</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="k">if</span> <span class="p">(</span><span class="nx">eat</span><span class="p">(</span><span class="nx">_semi</span><span class="p">)</span> <span class="o">||</span> <span class="nx">canInsertSemicolon</span><span class="p">())</span> <span class="p">{</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">delegate</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">argument</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="p">{</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">delegate</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_star</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">argument</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="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">"YieldExpression"</span><span class="p">);</span>
+ <span class="p">}</span></pre></div> </td> </tr> <tr id="section-162"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-162">¶</a> </div> <p>Parses array and generator comprehensions.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">function</span> <span class="nx">parseCom [...]
+ <span class="nx">node</span><span class="p">.</span><span class="nx">blocks</span> <span class="o">=</span> <span class="p">[];</span>
+ <span class="k">while</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_for</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">block</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">_parenL</span><span class="p">);</span>
+ <span class="nx">block</span><span class="p">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">toAssignable</span><span class="p">(</span><span class="nx">parseExprAtom</span><span class="p">());</span>
+ <span class="nx">checkLVal</span><span class="p">(</span><span class="nx">block</span><span class="p">.</span><span class="nx">left</span><span class="p">,</span> <span class="kc">true</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="o">||</span> <span class="nx">tokVal</span> <span class="o">!==</span> <span class="s2">"of"</span><span class="p">)</span> <span class="nx">unexpected</span><span class="p">();</span>
+ <span class="nx">next</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-163"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-163">¶</a> </div> <p><code>of</code> property is here for compatibility with Esprima's AST
+which also supports deprecated [for (... in ...) expr]</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">block</span><span class="p">.</span><span class="nx">of</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
+ <span class="nx">block</span><span class="p">.</span><span class="nx">right</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">_parenR</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">blocks</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">block</span><span class="p">,</span> <span class="s2">"ComprehensionBlock"</span><span class="p">));</span>
+ <span class="p">}</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">filter</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_if</span><span class="p">)</span> <span class="o">?</span> <span class="nx">parseParenExpression</span><span class="p">()</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">body</span> <span class="o">=</span> <span class="nx">parseExpression</span><span class="p">();</span>
+ <span class="nx">expect</span><span class="p">(</span><span class="nx">isGenerator</span> <span class="o">?</span> <span class="nx">_parenR</span> <span class="o">:</span> <span class="nx">_bracketR</span><span class="p">);</span>
+ <span class="nx">node</span><span class="p">.</span><span class="nx">generator</span> <span class="o">=</span> <span class="nx">isGenerator</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">"ComprehensionExpression"</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 98ec29f..a6ec0f2 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -6138,6 +6138,86 @@ test("(function* () { yield v })", {
locations: true
});
+test("(function* () { yield\nv })", {
+ type: "Program",
+ body: [{
+ type: "ExpressionStatement",
+ expression: {
+ type: "FunctionExpression",
+ id: null,
+ params: [],
+ defaults: [],
+ body: {
+ type: "BlockStatement",
+ body: [
+ {
+ type: "ExpressionStatement",
+ expression: {
+ type: "YieldExpression",
+ argument: null,
+ delegate: false,
+ range: [16, 21],
+ loc: {
+ start: {line: 1, column: 16},
+ end: {line: 1, column: 21}
+ }
+ },
+ range: [16, 21],
+ loc: {
+ start: {line: 1, column: 16},
+ end: {line: 1, column: 21}
+ }
+ },
+ {
+ type: "ExpressionStatement",
+ expression: {
+ type: "Identifier",
+ name: "v",
+ range: [22, 23],
+ loc: {
+ start: {line: 2, column: 0},
+ end: {line: 2, column: 1}
+ }
+ },
+ range: [22, 23],
+ loc: {
+ start: {line: 2, column: 0},
+ end: {line: 2, column: 1}
+ }
+ }
+ ],
+ range: [14, 25],
+ loc: {
+ start: {line: 1, column: 14},
+ end: {line: 2, column: 3}
+ }
+ },
+ rest: null,
+ generator: true,
+ expression: false,
+ range: [0, 26],
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 2, column: 4}
+ }
+ },
+ range: [0, 26],
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 2, column: 4}
+ }
+ }],
+ range: [0, 26],
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 2, column: 4}
+ }
+}, {
+ ecmaVersion: 6,
+ ranges: true,
+ locations: true
+});
+
test("(function* () { yield *v })", {
type: "Program",
body: [{
--
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