[Pkg-javascript-commits] [node-acorn-jsx] 67/484: Formatting

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:06 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 cc5971f61776b5910e2d2cbeaf98080a3ca22dcd
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Fri Jan 4 09:37:21 2013 +0100

    Formatting
---
 acorn.js      |  12 +++---
 index.html    |  68 +++++++++++++++++++-----------
 test/tests.js | 130 +++++++++++++++++++++++++++++-----------------------------
 3 files changed, 116 insertions(+), 94 deletions(-)

diff --git a/acorn.js b/acorn.js
index 1c7ec8f..bf16e18 100644
--- a/acorn.js
+++ b/acorn.js
@@ -887,15 +887,15 @@
   // `commentsBefore` property to it.
 
   var node_t = function(s) {
-    this.type=null;
-    this.start=tokStart;
-    this.end=null;
+    this.type = null;
+    this.start = tokStart;
+    this.end = null;
   };
 
   var node_loc_t = function(s) {
-    this.start=tokStartLoc;
-    this.end=null;
-    if (sourceFile !== null) this.source=sourceFile;
+    this.start = tokStartLoc;
+    this.end = null;
+    if (sourceFile !== null) this.source = sourceFile;
   };
 
   function startNode() {
diff --git a/index.html b/index.html
index 55b77fd..fb8466b 100644
--- a/index.html
+++ b/index.html
@@ -221,13 +221,18 @@ the current line number and start of line offset, in order to set
     <span class="k">return</span> <span class="nx">match</span> <span class="o">?</span> <span class="nx">match</span><span class="p">.</span><span class="nx">index</span> <span class="o">+</span> <span class="nx">match</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">length</span> <span class="o">:</span> <span class="nx">input</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="mi">1</span><s [...]
   <span class="p">}</span>
 
+  <span class="kd">var</span> <span class="nx">line_loc_t</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">line</span> <span class="o">=</span> <span class="nx">tokCurLine</span><span class="p">;</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">column</span> <span class="o">=</span> <span class="nx">tokPos</span> <span class="o">-</span> <span class="nx">tokLineStart</span><span class="p">;</span>
+  <span class="p">}</span>
+
   <span class="kd">function</span> <span class="nx">curLineLoc</span><span class="p">()</span> <span class="p">{</span>
     <span class="k">while</span> <span class="p">(</span><span class="nx">tokLineStartNext</span> <span class="o"><=</span> <span class="nx">tokPos</span><span class="p">)</span> <span class="p">{</span>
       <span class="o">++</span><span class="nx">tokCurLine</span><span class="p">;</span>
       <span class="nx">tokLineStart</span> <span class="o">=</span> <span class="nx">tokLineStartNext</span><span class="p">;</span>
       <span class="nx">tokLineStartNext</span> <span class="o">=</span> <span class="nx">nextLineStart</span><span class="p">();</span>
     <span class="p">}</span>
-    <span class="k">return</span> <span class="p">{</span><span class="nx">line</span><span class="o">:</span> <span class="nx">tokCurLine</span><span class="p">,</span> <span class="nx">column</span><span class="o">:</span> <span class="nx">tokPos</span> <span class="o">-</span> <span class="nx">tokLineStart</span><span class="p">};</span>
+    <span class="k">return</span> <span class="k">new</span> <span class="nx">line_loc_t</span><span class="p">();</span>
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-51">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-51">¶</a>               </div>               <p>Reset the token state. Used at the start of a parse.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx"> [...]
     <span class="nx">tokCurLine</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
     <span class="nx">tokPos</span> <span class="o">=</span> <span class="nx">tokLineStart</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
@@ -496,15 +501,17 @@ will return <code>null</code> unless the integer has exactly <code>len</code> di
     <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="sr">/[89]/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">str</span><span class="p">)</span> <span class="o">||</span> <span class="nx">strict</span><span class="p">)</span> <span class="nx">raise</span><span class="p">(</span><span class="nx">start</span><span class="p">,</span> <span class="s2">"Invalid number"</span><span class="p [...]
     <span class="k">else</span> <span class="nx">val</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">str</span><span class="p">,</span> <span class="mi">8</span><span class="p">);</span>
     <span class="k">return</span> <span class="nx">finishToken</span><span class="p">(</span><span class="nx">_num</span><span class="p">,</span> <span class="nx">val</span><span class="p">);</span>
-  <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-68">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-68">¶</a>               </div>               <p>Read a string value, interpreting backslash-escapes.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx"> [...]
+  <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-68">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-68">¶</a>               </div>               <p>Read a string value, interpreting backslash-escapes.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">rs_st [...]
+
+  <span class="kd">function</span> <span class="nx">readString</span><span class="p">(</span><span class="nx">quote</span><span class="p">)</span> <span class="p">{</span>
     <span class="nx">tokPos</span><span class="o">++</span><span class="p">;</span>
-    <span class="kd">var</span> <span class="nx">str</span> <span class="o">=</span> <span class="p">[];</span>
+    <span class="nx">rs_str</span><span class="p">.</span><span class="nx">length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
     <span class="k">for</span> <span class="p">(;;)</span> <span class="p">{</span>
       <span class="k">if</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="nx">raise</span><span class="p">(</span><span class="nx">tokStart</span><span class="p">,</span> <span class="s2">"Unterminated string constant"</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="nx">quote</span><span class="p">)</span> <span class="p">{</span>
         <span class="o">++</span><span class="nx">tokPos</span><span class="p">;</span>
-        <span class="k">return</span> <span class="nx">finishToken</span><span class="p">(</span><span class="nx">_string</span><span class="p">,</span> <span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">str</span><span class="p">));</span>
+        <span class="k">return</span> <span class="nx">finishToken</span><span class="p">(</span><span class="nx">_string</span><span class="p">,</span> <span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">rs_str</span><span class="p">));</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">92</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// '\'</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="o">++</span><span class="nx">tokPos</span><span class="p">);</span>
@@ -515,28 +522,28 @@ will return <code>null</code> unless the integer has exactly <code>len</code> di
         <span class="o">++</span><span class="nx">tokPos</span><span class="p">;</span>
         <span class="k">if</span> <span class="p">(</span><span class="nx">octal</span><span class="p">)</span> <span class="p">{</span>
           <span class="k">if</span> <span class="p">(</span><span class="nx">strict</span><span class="p">)</span> <span class="nx">raise</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="s2">"Octal literal in strict mode"</span><span class="p">);</span>
-          <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">octal</span><span class="p">,</span> <span class="mi">8</span><span class="p">));</span>
+          <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">octal</span><span class="p">,</span> <span class="mi">8</span><span class="p">));</span>
           <span class="nx">tokPos</span> <span class="o">+=</span> <span class="nx">octal</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
         <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
           <span class="k">switch</span> <span class="p">(</span><span class="nx">ch</span><span class="p">)</span> <span class="p">{</span>
-          <span class="k">case</span> <span class="mi">110</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">10</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'n' -> '\n'</span>
-          <span class="k">case</span> <span class="mi">114</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">13</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'r' -> '\r'</span>
-          <span class="k">case</span> <span class="mi">120</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">readHexChar</span><span class="p">(</span><span class="mi">2</span><span class="p">));</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'x'</span>
-          <span class="k">case</span> <span class="mi">117</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">readHexChar</span><span class="p">(</span><span class="mi">4</span><span class="p">));</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'u'</span>
-          <span class="k">case</span> <span class="mi">85</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">readHexChar</span><span class="p">(</span><span class="mi">8</span><span class="p">));</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'U'</span>
-          <span class="k">case</span> <span class="mi">116</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">9</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 't' -> '\t'</span>
-          <span class="k">case</span> <span class="mi">98</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">8</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'b' -> '\b'</span>
-          <span class="k">case</span> <span class="mi">118</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">11</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'v' -> '\u000b'</span>
-          <span class="k">case</span> <span class="mi">102</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">12</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'f' -> '\f'</span>
-          <span class="k">case</span> <span class="mi">48</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 0 -> '\0'</span>
+          <span class="k">case</span> <span class="mi">110</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">10</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'n' -> '\n'</span>
+          <span class="k">case</span> <span class="mi">114</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">13</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'r' -> '\r'</span>
+          <span class="k">case</span> <span class="mi">120</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">readHexChar</span><span class="p">(</span><span class="mi">2</span><span class="p">));</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'x'</span>
+          <span class="k">case</span> <span class="mi">117</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">readHexChar</span><span class="p">(</span><span class="mi">4</span><span class="p">));</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'u'</span>
+          <span class="k">case</span> <span class="mi">85</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">readHexChar</span><span class="p">(</span><span class="mi">8</span><span class="p">));</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'U'</span>
+          <span class="k">case</span> <span class="mi">116</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">9</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 't' -> '\t'</span>
+          <span class="k">case</span> <span class="mi">98</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">8</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'b' -> '\b'</span>
+          <span class="k">case</span> <span class="mi">118</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">11</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'v' -> '\u000b'</span>
+          <span class="k">case</span> <span class="mi">102</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">12</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 'f' -> '\f'</span>
+          <span class="k">case</span> <span class="mi">48</span><span class="o">:</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// 0 -> '\0'</span>
           <span class="k">case</span> <span class="mi">13</span><span class="o">:</span> <span class="k">if</span> <span class="p">(</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="o">===</span> <span class="mi">10</span><span class="p">)</span> <span class="o">++</span><span class="nx">tokPos</span><span class="p">;</span> <span class="c1">// '\r\n [...]
           <span class="k">case</span> <span class="mi">10</span><span class="o">:</span> <span class="k">break</span><span class="p">;</span> <span class="c1">// ' \n'</span>
-          <span class="k">default</span><span class="o">:</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ch</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="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ch</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span>
           <span class="p">}</span>
         <span class="p">}</span>
       <span class="p">}</span> <span class="k">else</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">13</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">8232</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="mi">8329</span><span class="p">)</span> <spa [...]
-        <span class="k">if</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">!==</span> <span class="mi">92</span><span class="p">)</span> <span class="nx">str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ch</span><span class="p">);</span> <span class="c1">// '\'</span>
+        <span class="k">if</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">!==</span> <span class="mi">92</span><span class="p">)</span> <span class="nx">rs_str</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ch</span><span class="p">);</span> <span class="c1">// '\'</span>
         <span class="o">++</span><span class="nx">tokPos</span><span class="p">;</span>
       <span class="p">}</span>
     <span class="p">}</span>
@@ -615,14 +622,26 @@ tests ("use strict"; 010; -- should fail).</p>             </td>             <td
     <span class="nx">skipSpace</span><span class="p">();</span>
     <span class="nx">readToken</span><span class="p">();</span>
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-78">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-78">¶</a>               </div>               <p>Start an AST node, attaching a start offset and optionally a
-<code>commentsBefore</code> property to it.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">startNode</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="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">start</span><span class="o">:</span> <span class="nx">tokStart</span><span class="p">,</span> <span class="nx">end</span><span class="o">:</span> <span class="kc">null</span><span class="p">};</span>
+<code>commentsBefore</code> property to it.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">node_t</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">type</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">tokStart</span><span class="p">;</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">end</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+  <span class="p">};</span>
+
+  <span class="kd">var</span> <span class="nx">node_loc_t</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">tokStartLoc</span><span class="p">;</span>
+    <span class="k">this</span><span class="p">.</span><span class="nx">end</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">sourceFile</span> <span class="o">!==</span> <span class="kc">null</span><span class="p">)</span> <span class="k">this</span><span class="p">.</span><span class="nx">source</span> <span class="o">=</span> <span class="nx">sourceFile</span><span class="p">;</span>
+  <span class="p">};</span>
+
+  <span class="kd">function</span> <span class="nx">startNode</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="k">new</span> <span class="nx">node_t</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">trackComments</span> <span class="o">&&</span> <span class="nx">tokCommentsBefore</span><span class="p">)</span> <span class="p">{</span>
       <span class="nx">node</span><span class="p">.</span><span class="nx">commentsBefore</span> <span class="o">=</span> <span class="nx">tokCommentsBefore</span><span class="p">;</span>
       <span class="nx">tokCommentsBefore</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</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">locations</span><span class="p">)</span>
-      <span class="nx">node</span><span class="p">.</span><span class="nx">loc</span> <span class="o">=</span> <span class="p">{</span><span class="nx">start</span><span class="o">:</span> <span class="nx">tokStartLoc</span><span class="p">,</span> <span class="nx">end</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">source</span><span class="o">:</span> <span class="nx">sourceFile</span><span class="p">};</span>
+      <span class="nx">node</span><span class="p">.</span><span class="nx">loc</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">node_loc_t</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">ranges</span><span class="p">)</span>
       <span class="nx">node</span><span class="p">.</span><span class="nx">range</span> <span class="o">=</span> <span class="p">[</span><span class="nx">tokStart</span><span class="p">,</span> <span class="mi">0</span><span class="p">];</span>
     <span class="k">return</span> <span class="nx">node</span><span class="p">;</span>
@@ -630,13 +649,16 @@ tests ("use strict"; 010; -- should fail).</p>             </td>             <td
 based on the start of another node. For example, a binary
 operator node is only started after its left-hand side has
 already been parsed.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">startNodeFrom</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">node</span> <span class="o">=</span> <span class="p">{</span><span class="nx">type</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">start</span><span class="o">:</span> <span class="nx">other</span><span class="p">.</span><span class="nx">start</span><span class="p">};</span>
+    <span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">node_t</span><span class="p">();</span>
+    <span class="nx">node</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">other</span><span class="p">.</span><span class="nx">start</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="nx">commentsBefore</span><span class="p">)</span> <span class="p">{</span>
       <span class="nx">node</span><span class="p">.</span><span class="nx">commentsBefore</span> <span class="o">=</span> <span class="nx">other</span><span class="p">.</span><span class="nx">commentsBefore</span><span class="p">;</span>
       <span class="nx">other</span><span class="p">.</span><span class="nx">commentsBefore</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</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">locations</span><span class="p">)</span>
-      <span class="nx">node</span><span class="p">.</span><span class="nx">loc</span> <span class="o">=</span> <span class="p">{</span><span class="nx">start</span><span class="o">:</span> <span class="nx">other</span><span class="p">.</span><span class="nx">loc</span><span class="p">.</span><span class="nx">start</span><span class="p">,</span> <span class="nx">end</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">source</span><span clas [...]
+    <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">locations</span><span class="p">)</span> <span class="p">{</span>
+      <span class="nx">node</span><span class="p">.</span><span class="nx">loc</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">node_loc_t</span><span class="p">();</span>
+      <span class="nx">node</span><span class="p">.</span><span class="nx">loc</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="nx">other</span><span class="p">.</span><span class="nx">loc</span><span class="p">.</span><span class="nx">start</span><span class="p">;</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">ranges</span><span class="p">)</span>
       <span class="nx">node</span><span class="p">.</span><span class="nx">range</span> <span class="o">=</span> <span class="p">[</span><span class="nx">other</span><span class="p">.</span><span class="nx">range</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mi">0</span><span class="p">];</span>
 
diff --git a/test/tests.js b/test/tests.js
index 247decc..0c97a6f 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -26068,90 +26068,90 @@ test("foo: 10; foo: 20;", {
 // option tests
 
 test("var a = 1;", {
-  "type": "Program",
-  "start": 0,
-  "end": 10,
-  "loc": {
-    "start": {
-      "line": 1,
-      "column": 0
-    },
-    "end": {
-      "line": 1,
-      "column": 10
-    },
-    "source": "test.js"
+  type: "Program",
+  start: 0,
+  end: 10,
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 10
+    },
+    source: "test.js"
   },
-  "body": [
+  body: [
     {
-      "type": "VariableDeclaration",
-      "start": 0,
-      "end": 9,
-      "loc": {
-        "start": {
-          "line": 1,
-          "column": 0
+      type: "VariableDeclaration",
+      start: 0,
+      end: 9,
+      loc: {
+        start: {
+          line: 1,
+          column: 0
         },
-        "end": {
-          "line": 1,
-          "column": 9
+        end: {
+          line: 1,
+          column: 9
         },
-        "source": "test.js"
+        source: "test.js"
       },
-      "declarations": [
+      declarations: [
         {
-          "type": "VariableDeclarator",
-          "start": 4,
-          "end": 9,
-          "loc": {
-            "start": {
-              "line": 1,
-              "column": 4
+          type: "VariableDeclarator",
+          start: 4,
+          end: 9,
+          loc: {
+            start: {
+              line: 1,
+              column: 4
             },
-            "end": {
-              "line": 1,
-              "column": 9
+            end: {
+              line: 1,
+              column: 9
             },
-            "source": "test.js"
+            source: "test.js"
           },
-          "id": {
-            "type": "Identifier",
-            "start": 4,
-            "end": 5,
-            "loc": {
-              "start": {
-                "line": 1,
-                "column": 4
+          id: {
+            type: "Identifier",
+            start: 4,
+            end: 5,
+            loc: {
+              start: {
+                line: 1,
+                column: 4
               },
-              "end": {
-                "line": 1,
-                "column": 5
+              end: {
+                line: 1,
+                column: 5
               },
-              "source": "test.js"
+              source: "test.js"
             },
-            "name": "a"
+            name: "a"
           },
-          "init": {
-            "type": "Literal",
-            "start": 8,
-            "end": 9,
-            "loc": {
-              "start": {
-                "line": 1,
-                "column": 8
+          init: {
+            type: "Literal",
+            start: 8,
+            end: 9,
+            loc: {
+              start: {
+                line: 1,
+                column: 8
               },
-              "end": {
-                "line": 1,
-                "column": 9
+              end: {
+                line: 1,
+                column: 9
               },
-              "source": "test.js"
+              source: "test.js"
             },
-            "value": 1,
-            "raw": "1"
+            value: 1,
+            raw: "1"
           }
         }
       ],
-      "kind": "var"
+      kind: "var"
     }
   ]
 }, {

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