[Pkg-javascript-commits] [node-acorn-jsx] 41/484: skipSpace

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 b38a98ffd21d0104ff0673d8f4dd8dd3e4cd8596
Author: Alistair Braidwood <alistair.braidwood at rulefinancial.com>
Date:   Thu Oct 18 16:44:49 2012 +0100

    skipSpace
---
 acorn.js   | 18 ++++++++++--------
 index.html | 20 +++++++++++---------
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/acorn.js b/acorn.js
index 59522a7..bdf8084 100644
--- a/acorn.js
+++ b/acorn.js
@@ -345,7 +345,6 @@
   // are only applied when a character is found to actually have a
   // code point above 128.
 
-  var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/;
   var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u [...]
   var nonASCIIidentifierChars = "\u0371-\u0374\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a8 [...]
   var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
@@ -452,16 +451,19 @@
   function skipSpace() {
     tokComments = null;
     while (tokPos < inputLen) {
-      var ch = input.charAt(tokPos);
-      if (ch === "/") {
-        var nextCh = input.charAt(tokPos+1);
-        if (nextCh === "*") {
+      var ch = input.charCodeAt(tokPos);
+      if (ch === 47) { // '/'
+        var next = input.charCodeAt(tokPos+1);
+        if (next === 42) { // '*'
           skipBlockComment();
-        } else if (nextCh === "/") {
+        } else if (next === 47) { // '/'
           skipLineComment();
         } else break;
-      } else if (ch === " " || ch === '\t' || ch === "\n" || ch === "\r" || ch === "\f" ||
-                 ch === "\xa0" || ch === "\x0b" || (ch >= "\u1680" && nonASCIIwhitespace.test(ch))) {
+      } else if (ch < 14 && ch > 8) {
+        ++tokPos;
+      } else if (ch === 32 || ch === 160) { // ' ', '\xa0'
+        ++tokPos;
+      } else if (ch >= 5760 && (ch === 5760 || ch === 6158 || ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279 || (ch >= 8192 && ch <= 8202))) {
         ++tokPos;
       } else {
         break;
diff --git a/index.html b/index.html
index 427966b..9a11c33 100644
--- a/index.html
+++ b/index.html
@@ -194,8 +194,7 @@ switch first dispatches on the lengths, to save on comparisons.</p>
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-38">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-38">¶</a>               </div>               <p>The ECMAScript 3 reserved word list.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">isReservedWord3</span [...]
 whitespace, identifier, and identifier-start categories. These
 are only applied when a character is found to actually have a
-code point above 128.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">nonASCIIwhitespace</span> <span class="o">=</span> <span class="sr">/[\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/</span><span class="p">;</span>
-  <span class="kd">var</span> <span class="nx">nonASCIIidentifierStartChars</span> <span class="o">=</span> <span class="s2">"\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u0 [...]
+code point above 128.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">nonASCIIidentifierStartChars</span> <span class="o">=</span> <span class="s2">"\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0 [...]
   <span class="kd">var</span> <span class="nx">nonASCIIidentifierChars</span> <span class="o">=</span> <span class="s2">"\u0371-\u0374\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df- [...]
   <span class="kd">var</span> <span class="nx">nonASCIIidentifierStart</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">"["</span> <span class="o">+</span> <span class="nx">nonASCIIidentifierStartChars</span> <span class="o">+</span> <span class="s2">"]"</span><span class="p">);</span>
   <span class="kd">var</span> <span class="nx">nonASCIIidentifier</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">"["</span> <span class="o">+</span> <span class="nx">nonASCIIidentifierStartChars</span> <span class="o">+</span> <span class="nx">nonASCIIidentifierChars</span> <span class="o">+</span> <span class="s2">"]"</span><span class="p">);</span></pre></div>             </td>        [...]
@@ -267,16 +266,19 @@ whitespace and comments, and, if <code>options.trackComments</code> is on,
 will store all skipped comments in <code>tokComments</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">skipSpace</span><span class="p">()</span> <span class="p">{</span>
     <span class="nx">tokComments</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
     <span class="k">while</span> <span class="p">(</span><span class="nx">tokPos</span> <span class="o"><</span> <span class="nx">inputLen</span><span class="p">)</span> <span class="p">{</span>
-      <span class="kd">var</span> <span class="nx">ch</span> <span class="o">=</span> <span class="nx">input</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">tokPos</span><span class="p">);</span>
-      <span class="k">if</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">===</span> <span class="s2">"/"</span><span class="p">)</span> <span class="p">{</span>
-        <span class="kd">var</span> <span class="nx">nextCh</span> <span class="o">=</span> <span class="nx">input</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">tokPos</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
-        <span class="k">if</span> <span class="p">(</span><span class="nx">nextCh</span> <span class="o">===</span> <span class="s2">"*"</span><span class="p">)</span> <span class="p">{</span>
+      <span class="kd">var</span> <span class="nx">ch</span> <span class="o">=</span> <span class="nx">input</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">(</span><span class="nx">tokPos</span><span class="p">);</span>
+      <span class="k">if</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">===</span> <span class="mi">47</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// '/'</span>
+        <span class="kd">var</span> <span class="nx">next</span> <span class="o">=</span> <span class="nx">input</span><span class="p">.</span><span class="nx">charCodeAt</span><span class="p">(</span><span class="nx">tokPos</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
+        <span class="k">if</span> <span class="p">(</span><span class="nx">next</span> <span class="o">===</span> <span class="mi">42</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// '*'</span>
           <span class="nx">skipBlockComment</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">nextCh</span> <span class="o">===</span> <span class="s2">"/"</span><span class="p">)</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">next</span> <span class="o">===</span> <span class="mi">47</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// '/'</span>
           <span class="nx">skipLineComment</span><span class="p">();</span>
         <span class="p">}</span> <span class="k">else</span> <span class="k">break</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">ch</span> <span class="o">===</span> <span class="s2">" "</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="s1">'\t'</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="s2">"\n"</span> <span class="o">||</span> <span class="nx">ch</span> <s [...]
-                 <span class="nx">ch</span> <span class="o">===</span> <span class="s2">"\xa0"</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="s2">"\x0b"</span> <span class="o">||</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">>=</span> <span class="s2">"\u1680"</span> <span class="o">&&</span> <span class="nx">nonASCIIwhitespace</span><span class="p">.</span><span clas [...]
+      <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">ch</span> <span class="o"><</span> <span class="mi">14</span> <span class="o">&&</span> <span class="nx">ch</span> <span class="o">></span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span>
+        <span class="o">++</span><span class="nx">tokPos</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">ch</span> <span class="o">===</span> <span class="mi">32</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="mi">160</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// ' ', '\xa0'</span>
+        <span class="o">++</span><span class="nx">tokPos</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">ch</span> <span class="o">>=</span> <span class="mi">5760</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">===</span> <span class="mi">5760</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="mi">6158</span> <span class="o">||</span> <span class="nx">ch</s [...]
         <span class="o">++</span><span class="nx">tokPos</span><span class="p">;</span>
       <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
         <span class="k">break</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