[Pkg-javascript-commits] [node-acorn-jsx] 42/484: skipLineComment
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 b3366233d3723ba93d7e2b186feca07b07d88eb0
Author: Alistair Braidwood <alistair.braidwood at rulefinancial.com>
Date: Thu Oct 18 16:46:13 2012 +0100
skipLineComment
---
acorn.js | 10 ++++++----
index.html | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/acorn.js b/acorn.js
index bdf8084..88a5f36 100644
--- a/acorn.js
+++ b/acorn.js
@@ -438,10 +438,12 @@
function skipLineComment() {
var start = tokPos;
- tokPos += 2;
- while (tokPos < inputLen && !newline.test(input.charAt(tokPos))) ++tokPos;
- if (options.trackComments)
- (tokComments || (tokComments = [])).push(input.slice(start, tokPos));
+ var ch = input.charCodeAt(tokPos+=2);
+ while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8329) {
+ ++tokPos;
+ ch = input.charCodeAt(tokPos);
+ }
+ (tokComments || (tokComments = [])).push(input.slice(start, tokPos));
}
// Called at the start of the parse and after every token. Skips
diff --git a/index.html b/index.html
index 9a11c33..c241702 100644
--- a/index.html
+++ b/index.html
@@ -257,10 +257,12 @@ the right position.</p> </td> <td class="code">
<span class="kd">function</span> <span class="nx">skipLineComment</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">start</span> <span class="o">=</span> <span class="nx">tokPos</span><span class="p">;</span>
- <span class="nx">tokPos</span> <span class="o">+=</span> <span class="mi">2</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="o">&&</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">charAt</span><span class="p">(</span><span class="nx">tokPos</span><span class="p">)))</span> <span class="o [...]
- <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">trackComments</span><span class="p">)</span>
- <span class="p">(</span><span class="nx">tokComments</span> <span class="o">||</span> <span class="p">(</span><span class="nx">tokComments</span> <span class="o">=</span> <span class="p">[])).</span><span class="nx">push</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">start</span><span class="p">,</span> <span class="nx">tokPos</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="o">+=</span><span class="mi">2</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="o">&&</span> <span class="nx">ch</span> <span class="o">!==</span> <span class="mi">10</span> <span class="o">&&</span> <span class="nx">ch</span> <span class="o">!==</span> <span class="mi">13</span> <span class="o">&&</span> <span class="nx">ch</span> <span class="o">!==</span> <span class="mi">8232</sp [...]
+ <span class="o">++</span><span class="nx">tokPos</span><span class="p">;</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="p">}</span>
+ <span class="p">(</span><span class="nx">tokComments</span> <span class="o">||</span> <span class="p">(</span><span class="nx">tokComments</span> <span class="o">=</span> <span class="p">[])).</span><span class="nx">push</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">start</span><span class="p">,</span> <span class="nx">tokPos</span><span class="p">));</span>
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-53"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-53">¶</a> </div> <p>Called at the start of the parse and after every token. Skips
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>
--
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