[Pkg-javascript-commits] [node-acorn-jsx] 46/484: Actually make strictSemicolons forbid all semicolon insertion

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:02 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 b591c41513f02dcb9bfb07fcae001658c790d6fc
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Mon Nov 5 22:25:40 2012 +0100

    Actually make strictSemicolons forbid all semicolon insertion
---
 acorn.js   | 5 ++---
 index.html | 7 +++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/acorn.js b/acorn.js
index eb1c7d4..34dfc94 100644
--- a/acorn.js
+++ b/acorn.js
@@ -911,9 +911,8 @@
   // Test whether a semicolon can be inserted at the current position.
 
   function canInsertSemicolon() {
-    return tokType === _eof || tokType === _braceR ||
-      !options.strictSemicolons &&
-      newline.test(input.slice(lastEnd, tokStart));
+    return !options.strictSemicolons &&
+      (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart)));
   }
 
   // Consume a semicolon, or, failing that, see if we are allowed to
diff --git a/index.html b/index.html
index 5d63154..216adce 100644
--- a/index.html
+++ b/index.html
@@ -626,9 +626,8 @@ type, and if yes, consumes it as a side effect.</p>             </td>
       <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
     <span class="p">}</span>
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-83">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-83">¶</a>               </div>               <p>Test whether a semicolon can be inserted at the current position.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <spa [...]
-    <span class="k">return</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_eof</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_braceR</span> <span class="o">||</span>
-      <span class="o">!</span><span class="nx">options</span><span class="p">.</span><span class="nx">strictSemicolons</span> <span class="o">&&</span>
-      <span class="nx">newline</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">input</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="nx">lastEnd</span><span class="p">,</span> <span class="nx">tokStart</span><span class="p">));</span>
+    <span class="k">return</span> <span class="o">!</span><span class="nx">options</span><span class="p">.</span><span class="nx">strictSemicolons</span> <span class="o">&&</span>
+      <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_eof</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_braceR</span> <span class="o">||</span> <span class="nx">newline</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">input</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="nx">l [...]
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-84">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-84">¶</a>               </div>               <p>Consume a semicolon, or, failing that, see if we are allowed to
 pretend that there is a semicolon at this position.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">semicolon</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">eat</span><span class="p">(</span><span class="nx">_semi</span><span class="p">)</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">canInsertSemicolon</span><span class="p">())</span> <span class="nx">unexpected</span><span class="p">();</span>
@@ -1168,7 +1167,7 @@ for array literals).</p>             </td>             <td class="code">
 when parsing properties), it will also convert keywords into
 identifiers.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">parseIdent</span><span class="p">(</span><span class="nx">liberal</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">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</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="p">(</span><span class="nx">liberal</span> <span class="o">&&</span> <span class="nx">tokType</span><span class="p">.</span><span class="nx">keyword</span><span class="p">)</span> <span class [...]
+    <span class="nx">node</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</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="p">(</span><span class="nx">liberal</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">options</span><span class="p">.</span><span class="nx">forbidReserved</span> <spa [...]
     <span class="nx">next</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">"Identifier"</span><span class="p">);</span>
   <span class="p">}</span>

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