[Pkg-javascript-commits] [node-acorn-jsx] 188/484: ecma 6 partial support: let and const

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:24 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 1e5bfc2c55a60ddaad774fc7324c30f93cc99362
Author: Artem Govorov <artem.govorov at gmail.com>
Date:   Fri Jun 6 12:59:18 2014 +1000

    ecma 6 partial support: let and const
---
 acorn.js      |   35 +-
 index.html    |   35 +-
 test/tests.js | 1688 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1736 insertions(+), 22 deletions(-)

diff --git a/acorn.js b/acorn.js
index ad2f609..3326eab 100644
--- a/acorn.js
+++ b/acorn.js
@@ -51,9 +51,9 @@
 
   var defaultOptions = exports.defaultOptions = {
     // `ecmaVersion` indicates the ECMAScript version to parse. Must
-    // be either 3 or 5. This
-    // influences support for strict mode, the set of reserved words, and
-    // support for getters and setter.
+    // be either 3, or 5, or 6. This
+    // influences support for strict mode, the set of reserved words,
+    // support for getters and setters and other features.
     ecmaVersion: 5,
     // Turn on `strictSemicolons` to prevent the parser from doing
     // automatic semicolon insertion.
@@ -113,6 +113,8 @@
     for (var opt in defaultOptions) if (!Object.prototype.hasOwnProperty.call(options, opt))
       options[opt] = defaultOptions[opt];
     sourceFile = options.sourceFile || null;
+
+    isKeyword = options.ecmaVersion >= 6 ? isEcma6Keyword : isEcma5AndLessKeyword;
   }
 
   // The `getLineInfo` function is mostly useful when the
@@ -276,6 +278,7 @@
   var _finally = {keyword: "finally"}, _for = {keyword: "for", isLoop: true}, _function = {keyword: "function"};
   var _if = {keyword: "if"}, _return = {keyword: "return", beforeExpr: true}, _switch = {keyword: "switch"};
   var _throw = {keyword: "throw", beforeExpr: true}, _try = {keyword: "try"}, _var = {keyword: "var"};
+  var _let = {keyword: "let"}, _const = {keyword: "const"};
   var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true};
   var _this = {keyword: "this"};
 
@@ -296,7 +299,8 @@
                       "continue": _continue, "debugger": _debugger, "default": _default,
                       "do": _do, "else": _else, "finally": _finally, "for": _for,
                       "function": _function, "if": _if, "return": _return, "switch": _switch,
-                      "throw": _throw, "try": _try, "var": _var, "while": _while, "with": _with,
+                      "throw": _throw, "try": _try, "var": _var, "let": _let, "const": _const,
+                      "while": _while, "with": _with,
                       "null": _null, "true": _true, "false": _false, "new": _new, "in": _in,
                       "instanceof": {keyword: "instanceof", binop: 7, beforeExpr: true}, "this": _this,
                       "typeof": {keyword: "typeof", prefix: true, beforeExpr: true},
@@ -415,7 +419,13 @@
 
   // And the keywords.
 
-  var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this");
+  var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
+
+  var isEcma5AndLessKeyword = makePredicate(ecma5AndLessKeywords);
+
+  var isEcma6Keyword = makePredicate(ecma5AndLessKeywords + " let const");
+
+  var isKeyword = isEcma5AndLessKeyword;
 
   // ## Character categories
 
@@ -1207,10 +1217,11 @@
       labels.push(loopLabel);
       expect(_parenL);
       if (tokType === _semi) return parseFor(node, null);
-      if (tokType === _var) {
+      if (tokType === _var || tokType === _let) {
+        var varKind = tokType.keyword;
         var init = startNode();
         next();
-        parseVar(init, true);
+        parseVar(init, true, varKind);
         finishNode(init, "VariableDeclaration");
         if (init.declarations.length === 1 && eat(_in))
           return parseForIn(node, init);
@@ -1308,9 +1319,11 @@
         raise(node.start, "Missing catch or finally clause");
       return finishNode(node, "TryStatement");
 
+    case _const:
+    case _let:
     case _var:
       next();
-      parseVar(node);
+      parseVar(node, false, starttype.keyword);
       semicolon();
       return finishNode(node, "VariableDeclaration");
 
@@ -1421,15 +1434,15 @@
 
   // Parse a list of variable declarations.
 
-  function parseVar(node, noIn) {
+  function parseVar(node, noIn, kind) {
     node.declarations = [];
-    node.kind = "var";
+    node.kind = kind;
     for (;;) {
       var decl = startNode();
       decl.id = parseIdent();
       if (strict && isStrictBadIdWord(decl.id.name))
         raise(decl.id.start, "Binding " + decl.id.name + " in strict mode");
-      decl.init = eat(_eq) ? parseExpression(true, noIn) : null;
+      decl.init = eat(_eq) ? parseExpression(true, noIn) : (kind === _const.keyword ? unexpected() : null);
       node.declarations.push(finishNode(decl, "VariableDeclarator"));
       if (!eat(_comma)) break;
     }
diff --git a/index.html b/index.html
index 1f74c47..00c0182 100644
--- a/index.html
+++ b/index.html
@@ -34,9 +34,9 @@ API</a>, with the caveat that the SpiderMonkey-specific syntax
     <span class="k">return</span> <span class="nx">parseTopLevel</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">program</span><span class="p">);</span>
   <span class="p">};</span></pre></div>             </td>           </tr>                               <tr id="section-3">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-3">¶</a>               </div>               <p>A second optional argument can be given to further configure
 the parser process. These options are recognized:</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">defaultOptions</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">defaultOptions</span> <span class="o">=</span> <span class="p">{</span></pre></div>             </td>           </tr>                               <tr id="section-4">             <t [...]
-be either 3 or 5. This
-influences support for strict mode, the set of reserved words, and
-support for getters and setter.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">ecmaVersion</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span></pre></div>             </td>           </tr>                               <tr id="section-5">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-5">¶</a>               </div>       [...]
+be either 3, or 5, or 6. This
+influences support for strict mode, the set of reserved words,
+support for getters and setters and other features.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">ecmaVersion</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span></pre></div>             </td>           </tr>                               <tr id="section-5">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-5">¶</a>        [...]
 automatic semicolon insertion.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">strictSemicolons</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span></pre></div>             </td>           </tr>                               <tr id="section-6">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-6">¶</a>               </di [...]
 trailing commas in array and object literals.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">allowTrailingCommas</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span></pre></div>             </td>           </tr>                               <tr id="section-7">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-7">¶</a>   [...]
 <code>forbidReserved</code> to enforce them. When this option has the
@@ -73,6 +73,8 @@ file in every node's <code>loc</code> object.</p>             </td>
     <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">opt</span> <span class="k">in</span> <span class="nx">defaultOptions</span><span class="p">)</span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">.</span><span class="nx">call</span><span class="p">( [...]
       <span class="nx">options</span><span class="p">[</span><span class="nx">opt</span><span class="p">]</span> <span class="o">=</span> <span class="nx">defaultOptions</span><span class="p">[</span><span class="nx">opt</span><span class="p">];</span>
     <span class="nx">sourceFile</span> <span class="o">=</span> <span class="nx">options</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="nx">isKeyword</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">ecmaVersion</span> <span class="o">>=</span> <span class="mi">6</span> <span class="o">?</span> <span class="nx">isEcma6Keyword</span> <span class="o">:</span> <span class="nx">isEcma5AndLessKeyword</span><span class="p">;</span>
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-15">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-15">¶</a>               </div>               <p>The <code>getLineInfo</code> function is mostly useful when the
 <code>locations</code> option is off (for performance reasons) and you
 want to find the line/column position for a given character
@@ -172,6 +174,7 @@ continue jumps to that label.</p>             </td>             <td class="code"
   <span class="kd">var</span> <span class="nx">_finally</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"finally"</span><span class="p">},</span> <span class="nx">_for</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"for"</span><span class="p">,</span> <span class="nx">isLoop</span><span class="o">:</span> <s [...]
   <span class="kd">var</span> <span class="nx">_if</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"if"</span><span class="p">},</span> <span class="nx">_return</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"return"</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <s [...]
   <span class="kd">var</span> <span class="nx">_throw</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"throw"</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span> <span class="nx">_try</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class=" [...]
+  <span class="kd">var</span> <span class="nx">_let</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"let"</span><span class="p">},</span> <span class="nx">_const</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"const"</span><span class="p">};</span>
   <span class="kd">var</span> <span class="nx">_while</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"while"</span><span class="p">,</span> <span class="nx">isLoop</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span> <span class="nx">_with</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2" [...]
   <span class="kd">var</span> <span class="nx">_this</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"this"</span><span class="p">};</span></pre></div>             </td>           </tr>                               <tr id="section-33">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-33">¶</a>               </div>              [...]
   <span class="kd">var</span> <span class="nx">_false</span> <span class="o">=</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"false"</span><span class="p">,</span> <span class="nx">atomValue</span><span class="o">:</span> <span class="kc">false</span><span class="p">};</span></pre></div>             </td>           </tr>                               <tr id="section-34">             <td class="docs">               <div c [...]
@@ -180,7 +183,8 @@ we assign a variable name to it for quick comparing.</p>             </td>
                       <span class="s2">"continue"</span><span class="o">:</span> <span class="nx">_continue</span><span class="p">,</span> <span class="s2">"debugger"</span><span class="o">:</span> <span class="nx">_debugger</span><span class="p">,</span> <span class="s2">"default"</span><span class="o">:</span> <span class="nx">_default</span><span class="p">,</span>
                       <span class="s2">"do"</span><span class="o">:</span> <span class="nx">_do</span><span class="p">,</span> <span class="s2">"else"</span><span class="o">:</span> <span class="nx">_else</span><span class="p">,</span> <span class="s2">"finally"</span><span class="o">:</span> <span class="nx">_finally</span><span class="p">,</span> <span class="s2">"for"</span><span class="o">:</span> <span class="nx">_for</span><span class="p">,</span>
                       <span class="s2">"function"</span><span class="o">:</span> <span class="nx">_function</span><span class="p">,</span> <span class="s2">"if"</span><span class="o">:</span> <span class="nx">_if</span><span class="p">,</span> <span class="s2">"return"</span><span class="o">:</span> <span class="nx">_return</span><span class="p">,</span> <span class="s2">"switch"</span><span class="o">:</span> <span class="nx">_switch</span><span c [...]
-                      <span class="s2">"throw"</span><span class="o">:</span> <span class="nx">_throw</span><span class="p">,</span> <span class="s2">"try"</span><span class="o">:</span> <span class="nx">_try</span><span class="p">,</span> <span class="s2">"var"</span><span class="o">:</span> <span class="nx">_var</span><span class="p">,</span> <span class="s2">"while"</span><span class="o">:</span> <span class="nx">_while</span><span class="p">,</ [...]
+                      <span class="s2">"throw"</span><span class="o">:</span> <span class="nx">_throw</span><span class="p">,</span> <span class="s2">"try"</span><span class="o">:</span> <span class="nx">_try</span><span class="p">,</span> <span class="s2">"var"</span><span class="o">:</span> <span class="nx">_var</span><span class="p">,</span> <span class="s2">"let"</span><span class="o">:</span> <span class="nx">_let</span><span class="p">,</span [...]
+                      <span class="s2">"while"</span><span class="o">:</span> <span class="nx">_while</span><span class="p">,</span> <span class="s2">"with"</span><span class="o">:</span> <span class="nx">_with</span><span class="p">,</span>
                       <span class="s2">"null"</span><span class="o">:</span> <span class="nx">_null</span><span class="p">,</span> <span class="s2">"true"</span><span class="o">:</span> <span class="nx">_true</span><span class="p">,</span> <span class="s2">"false"</span><span class="o">:</span> <span class="nx">_false</span><span class="p">,</span> <span class="s2">"new"</span><span class="o">:</span> <span class="nx">_new</span><span class="p">,</ [...]
                       <span class="s2">"instanceof"</span><span class="o">:</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"instanceof"</span><span class="p">,</span> <span class="nx">binop</span><span class="o">:</span> <span class="mi">7</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span> <span class="s2">"this&quo [...]
                       <span class="s2">"typeof"</span><span class="o">:</span> <span class="p">{</span><span class="nx">keyword</span><span class="o">:</span> <span class="s2">"typeof"</span><span class="p">,</span> <span class="nx">prefix</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">beforeExpr</span><span class="o">:</span> <span class="kc">true</span><span class="p">},</span>
@@ -255,7 +259,13 @@ switch first dispatches on the lengths, to save on comparisons.</p>
       <span class="nx">compareTo</span><span class="p">(</span><span class="nx">words</span><span class="p">);</span>
     <span class="p">}</span>
     <span class="k">return</span> <span class="k">new</span> <span class="nb">Function</span><span class="p">(</span><span class="s2">"str"</span><span class="p">,</span> <span class="nx">f</span><span class="p">);</span>
-  <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-42">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-42">¶</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 [...]
+  <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-42">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-42">¶</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 [...]
+
+  <span class="kd">var</span> <span class="nx">isEcma5AndLessKeyword</span> <span class="o">=</span> <span class="nx">makePredicate</span><span class="p">(</span><span class="nx">ecma5AndLessKeywords</span><span class="p">);</span>
+
+  <span class="kd">var</span> <span class="nx">isEcma6Keyword</span> <span class="o">=</span> <span class="nx">makePredicate</span><span class="p">(</span><span class="nx">ecma5AndLessKeywords</span> <span class="o">+</span> <span class="s2">" let const"</span><span class="p">);</span>
+
+  <span class="kd">var</span> <span class="nx">isKeyword</span> <span class="o">=</span> <span class="nx">isEcma5AndLessKeyword</span><span class="p">;</span></pre></div>             </td>           </tr>                               <tr id="section-47">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-47">¶</a>               </div>               <h2>Character categories</h2>             </td>             <td class= [...]
 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\u202f\u205f\u3000\ufeff]/</span><span class="p">;</span>
@@ -865,10 +875,11 @@ a regular <code>for</code> loop.</p>             </td>             <td class="co
       <span class="nx">labels</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">loopLabel</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="k">if</span> <span class="p">(</span><span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_semi</span><span class="p">)</span> <span class="k">return</span> <span class="nx">parseFor</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="kc">null</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">_var</span><span class="p">)</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">_var</span> <span class="o">||</span> <span class="nx">tokType</span> <span class="o">===</span> <span class="nx">_let</span><span class="p">)</span> <span class="p">{</span>
+        <span class="kd">var</span> <span class="nx">varKind</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="kd">var</span> <span class="nx">init</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">parseVar</span><span class="p">(</span><span class="nx">init</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+        <span class="nx">parseVar</span><span class="p">(</span><span class="nx">init</span><span class="p">,</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">varKind</span><span class="p">);</span>
         <span class="nx">finishNode</span><span class="p">(</span><span class="nx">init</span><span class="p">,</span> <span class="s2">"VariableDeclaration"</span><span class="p">);</span>
         <span class="k">if</span> <span class="p">(</span><span class="nx">init</span><span class="p">.</span><span class="nx">declarations</span><span class="p">.</span><span class="nx">length</span> <span class="o">===</span> <span class="mi">1</span> <span class="o">&&</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_in</span><span class="p">))</span>
           <span class="k">return</span> <span class="nx">parseForIn</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">init</span><span class="p">);</span>
@@ -958,9 +969,11 @@ adding statements to.</p>             </td>             <td class="code">
         <span class="nx">raise</span><span class="p">(</span><span class="nx">node</span><span class="p">.</span><span class="nx">start</span><span class="p">,</span> <span class="s2">"Missing catch or finally clause"</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">"TryStatement"</span><span class="p">);</span>
 
+    <span class="k">case</span> <span class="nx">_const</span><span class="o">:</span>
+    <span class="k">case</span> <span class="nx">_let</span><span class="o">:</span>
     <span class="k">case</span> <span class="nx">_var</span><span class="o">:</span>
       <span class="nx">next</span><span class="p">();</span>
-      <span class="nx">parseVar</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
+      <span class="nx">parseVar</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="nx">starttype</span><span class="p">.</span><span class="nx">keyword</span><span class="p">);</span>
       <span class="nx">semicolon</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">"VariableDeclaration"</span><span class="p">);</span>
 
@@ -1047,15 +1060,15 @@ expression.</p>             </td>             <td class="code">               <d
     <span class="nx">node</span><span class="p">.</span><span class="nx">body</span> <span class="o">=</span> <span class="nx">parseStatement</span><span class="p">();</span>
     <span class="nx">labels</span><span class="p">.</span><span class="nx">pop</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">"ForInStatement"</span><span class="p">);</span>
-  <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-107">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-107">¶</a>               </div>               <p>Parse a list of variable declarations.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">parseVar</sp [...]
+  <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-107">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-107">¶</a>               </div>               <p>Parse a list of variable declarations.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class="nx">parseVar</sp [...]
     <span class="nx">node</span><span class="p">.</span><span class="nx">declarations</span> <span class="o">=</span> <span class="p">[];</span>
-    <span class="nx">node</span><span class="p">.</span><span class="nx">kind</span> <span class="o">=</span> <span class="s2">"var"</span><span class="p">;</span>
+    <span class="nx">node</span><span class="p">.</span><span class="nx">kind</span> <span class="o">=</span> <span class="nx">kind</span><span class="p">;</span>
     <span class="k">for</span> <span class="p">(;;)</span> <span class="p">{</span>
       <span class="kd">var</span> <span class="nx">decl</span> <span class="o">=</span> <span class="nx">startNode</span><span class="p">();</span>
       <span class="nx">decl</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">parseIdent</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">isStrictBadIdWord</span><span class="p">(</span><span class="nx">decl</span><span class="p">.</span><span class="nx">id</span><span class="p">.</span><span class="nx">name</span><span class="p">))</span>
         <span class="nx">raise</span><span class="p">(</span><span class="nx">decl</span><span class="p">.</span><span class="nx">id</span><span class="p">.</span><span class="nx">start</span><span class="p">,</span> <span class="s2">"Binding "</span> <span class="o">+</span> <span class="nx">decl</span><span class="p">.</span><span class="nx">id</span><span class="p">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">" in strict mode"</spa [...]
-      <span class="nx">decl</span><span class="p">.</span><span class="nx">init</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_eq</span><span class="p">)</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="nx">noIn</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
+      <span class="nx">decl</span><span class="p">.</span><span class="nx">init</span> <span class="o">=</span> <span class="nx">eat</span><span class="p">(</span><span class="nx">_eq</span><span class="p">)</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="nx">noIn</span><span class="p">)</span> <span class="o">:</span> <span class="p">(</span><span class="nx">kind</span> <span [...]
       <span class="nx">node</span><span class="p">.</span><span class="nx">declarations</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">decl</span><span class="p">,</span> <span class="s2">"VariableDeclarator"</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">_comma</span><span class="p">))</span> <span class="k">break</span><span class="p">;</span>
     <span class="p">}</span>
diff --git a/test/tests.js b/test/tests.js
index 4bc5b4d..0b47ada 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -27262,6 +27262,1694 @@ testFail("var this = 10;", "Unexpected token (1:4)");
 
 testFail("throw\n10;", "Illegal newline after throw (1:5)");
 
+
+// ECMA < 6 mode should work as before
+
+testFail("const a;", "Unexpected token (1:6)");
+
+testFail("let x;", "Unexpected token (1:4)");
+
+testFail("const a = 1;", "Unexpected token (1:6)");
+
+testFail("let a = 1;", "Unexpected token (1:4)");
+
+testFail("for(const x = 0;;);", "Unexpected token (1:10)");
+
+testFail("for(let x = 0;;);", "Unexpected token (1:8)");
+
+test("let++", {
+  type: "Program",
+  start: 0,
+  end: 5,
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 5
+    }
+  },
+  body: [
+    {
+      type: "ExpressionStatement",
+      start: 0,
+      end: 5,
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 5
+        }
+      },
+      expression: {
+        type: "UpdateExpression",
+        start: 0,
+        end: 5,
+        loc: {
+          start: {
+            line: 1,
+            column: 0
+          },
+          end: {
+            line: 1,
+            column: 5
+          }
+        },
+        operator: "++",
+        prefix: false,
+        argument: {
+          type: "Identifier",
+          start: 0,
+          end: 3,
+          loc: {
+            start: {
+              line: 1,
+              column: 0
+            },
+            end: {
+              line: 1,
+              column: 3
+            }
+          },
+          name: "let"
+        }
+      }
+    }
+  ]
+});
+
+// ECMA 6 support
+
+test("let x", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "x",
+            loc: {
+              start: {
+                line: 1,
+                column: 4
+              },
+              end: {
+                line: 1,
+                column: 5
+              }
+            }
+          },
+          init: null,
+          loc: {
+            start: {
+              line: 1,
+              column: 4
+            },
+            end: {
+              line: 1,
+              column: 5
+            }
+          }
+        }
+      ],
+      kind: "let",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 5
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 5
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("let x, y;", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "x",
+            loc: {
+              start: {
+                line: 1,
+                column: 4
+              },
+              end: {
+                line: 1,
+                column: 5
+              }
+            }
+          },
+          init: null,
+          loc: {
+            start: {
+              line: 1,
+              column: 4
+            },
+            end: {
+              line: 1,
+              column: 5
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "y",
+            loc: {
+              start: {
+                line: 1,
+                column: 7
+              },
+              end: {
+                line: 1,
+                column: 8
+              }
+            }
+          },
+          init: null,
+          loc: {
+            start: {
+              line: 1,
+              column: 7
+            },
+            end: {
+              line: 1,
+              column: 8
+            }
+          }
+        }
+      ],
+      kind: "let",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 9
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 9
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("let x = 42", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "x",
+            loc: {
+              start: {
+                line: 1,
+                column: 4
+              },
+              end: {
+                line: 1,
+                column: 5
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 42,
+            loc: {
+              start: {
+                line: 1,
+                column: 8
+              },
+              end: {
+                line: 1,
+                column: 10
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 4
+            },
+            end: {
+              line: 1,
+              column: 10
+            }
+          }
+        }
+      ],
+      kind: "let",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 10
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 10
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("let eval = 42, arguments = 42", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "eval",
+            loc: {
+              start: {
+                line: 1,
+                column: 4
+              },
+              end: {
+                line: 1,
+                column: 8
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 42,
+            loc: {
+              start: {
+                line: 1,
+                column: 11
+              },
+              end: {
+                line: 1,
+                column: 13
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 4
+            },
+            end: {
+              line: 1,
+              column: 13
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "arguments",
+            loc: {
+              start: {
+                line: 1,
+                column: 15
+              },
+              end: {
+                line: 1,
+                column: 24
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 42,
+            loc: {
+              start: {
+                line: 1,
+                column: 27
+              },
+              end: {
+                line: 1,
+                column: 29
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 15
+            },
+            end: {
+              line: 1,
+              column: 29
+            }
+          }
+        }
+      ],
+      kind: "let",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 29
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 29
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("let x = 14, y = 3, z = 1977", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "x",
+            loc: {
+              start: {
+                line: 1,
+                column: 4
+              },
+              end: {
+                line: 1,
+                column: 5
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 14,
+            loc: {
+              start: {
+                line: 1,
+                column: 8
+              },
+              end: {
+                line: 1,
+                column: 10
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 4
+            },
+            end: {
+              line: 1,
+              column: 10
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "y",
+            loc: {
+              start: {
+                line: 1,
+                column: 12
+              },
+              end: {
+                line: 1,
+                column: 13
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 3,
+            loc: {
+              start: {
+                line: 1,
+                column: 16
+              },
+              end: {
+                line: 1,
+                column: 17
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 12
+            },
+            end: {
+              line: 1,
+              column: 17
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "z",
+            loc: {
+              start: {
+                line: 1,
+                column: 19
+              },
+              end: {
+                line: 1,
+                column: 20
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 1977,
+            loc: {
+              start: {
+                line: 1,
+                column: 23
+              },
+              end: {
+                line: 1,
+                column: 27
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 19
+            },
+            end: {
+              line: 1,
+              column: 27
+            }
+          }
+        }
+      ],
+      kind: "let",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 27
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 27
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("for(let x = 0;;);", {
+  type: "Program",
+  body: [
+    {
+      type: "ForStatement",
+      init: {
+        type: "VariableDeclaration",
+        declarations: [
+          {
+            type: "VariableDeclarator",
+            id: {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 8
+                },
+                end: {
+                  line: 1,
+                  column: 9
+                }
+              }
+            },
+            init: {
+              type: "Literal",
+              value: 0,
+              loc: {
+                start: {
+                  line: 1,
+                  column: 12
+                },
+                end: {
+                  line: 1,
+                  column: 13
+                }
+              }
+            },
+            loc: {
+              start: {
+                line: 1,
+                column: 8
+              },
+              end: {
+                line: 1,
+                column: 13
+              }
+            }
+          }
+        ],
+        kind: "let",
+        loc: {
+          start: {
+            line: 1,
+            column: 4
+          },
+          end: {
+            line: 1,
+            column: 13
+          }
+        }
+      },
+      test: null,
+      update: null,
+      body: {
+        type: "EmptyStatement",
+        loc: {
+          start: {
+            line: 1,
+            column: 16
+          },
+          end: {
+            line: 1,
+            column: 17
+          }
+        }
+      },
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 17
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 17
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("for(let x = 0, y = 1;;);", {
+  type: "Program",
+  body: [
+    {
+      type: "ForStatement",
+      init: {
+        type: "VariableDeclaration",
+        declarations: [
+          {
+            type: "VariableDeclarator",
+            id: {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 8
+                },
+                end: {
+                  line: 1,
+                  column: 9
+                }
+              }
+            },
+            init: {
+              type: "Literal",
+              value: 0,
+              loc: {
+                start: {
+                  line: 1,
+                  column: 12
+                },
+                end: {
+                  line: 1,
+                  column: 13
+                }
+              }
+            },
+            loc: {
+              start: {
+                line: 1,
+                column: 8
+              },
+              end: {
+                line: 1,
+                column: 13
+              }
+            }
+          },
+          {
+            type: "VariableDeclarator",
+            id: {
+              type: "Identifier",
+              name: "y",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 15
+                },
+                end: {
+                  line: 1,
+                  column: 16
+                }
+              }
+            },
+            init: {
+              type: "Literal",
+              value: 1,
+              loc: {
+                start: {
+                  line: 1,
+                  column: 19
+                },
+                end: {
+                  line: 1,
+                  column: 20
+                }
+              }
+            },
+            loc: {
+              start: {
+                line: 1,
+                column: 15
+              },
+              end: {
+                line: 1,
+                column: 20
+              }
+            }
+          }
+        ],
+        kind: "let",
+        loc: {
+          start: {
+            line: 1,
+            column: 4
+          },
+          end: {
+            line: 1,
+            column: 20
+          }
+        }
+      },
+      test: null,
+      update: null,
+      body: {
+        type: "EmptyStatement",
+        loc: {
+          start: {
+            line: 1,
+            column: 23
+          },
+          end: {
+            line: 1,
+            column: 24
+          }
+        }
+      },
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 24
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 24
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("for (let x in list) process(x);", {
+  type: "Program",
+  body: [
+    {
+      type: "ForInStatement",
+      left: {
+        type: "VariableDeclaration",
+        declarations: [
+          {
+            type: "VariableDeclarator",
+            id: {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 9
+                },
+                end: {
+                  line: 1,
+                  column: 10
+                }
+              }
+            },
+            init: null,
+            loc: {
+              start: {
+                line: 1,
+                column: 9
+              },
+              end: {
+                line: 1,
+                column: 10
+              }
+            }
+          }
+        ],
+        kind: "let",
+        loc: {
+          start: {
+            line: 1,
+            column: 5
+          },
+          end: {
+            line: 1,
+            column: 10
+          }
+        }
+      },
+      right: {
+        type: "Identifier",
+        name: "list",
+        loc: {
+          start: {
+            line: 1,
+            column: 14
+          },
+          end: {
+            line: 1,
+            column: 18
+          }
+        }
+      },
+      body: {
+        type: "ExpressionStatement",
+        expression: {
+          type: "CallExpression",
+          callee: {
+            type: "Identifier",
+            name: "process",
+            loc: {
+              start: {
+                line: 1,
+                column: 20
+              },
+              end: {
+                line: 1,
+                column: 27
+              }
+            }
+          },
+          arguments: [
+            {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 28
+                },
+                end: {
+                  line: 1,
+                  column: 29
+                }
+              }
+            }
+          ],
+          loc: {
+            start: {
+              line: 1,
+              column: 20
+            },
+            end: {
+              line: 1,
+              column: 30
+            }
+          }
+        },
+        loc: {
+          start: {
+            line: 1,
+            column: 20
+          },
+          end: {
+            line: 1,
+            column: 31
+          }
+        }
+      },
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 31
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 31
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("for (let x = 42 in list) process(x);", {
+  type: "Program",
+  body: [
+    {
+      type: "ForInStatement",
+      left: {
+        type: "VariableDeclaration",
+        declarations: [
+          {
+            type: "VariableDeclarator",
+            id: {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 9
+                },
+                end: {
+                  line: 1,
+                  column: 10
+                }
+              }
+            },
+            init: {
+              type: "Literal",
+              value: 42,
+              loc: {
+                start: {
+                  line: 1,
+                  column: 13
+                },
+                end: {
+                  line: 1,
+                  column: 15
+                }
+              }
+            },
+            loc: {
+              start: {
+                line: 1,
+                column: 9
+              },
+              end: {
+                line: 1,
+                column: 15
+              }
+            }
+          }
+        ],
+        kind: "let",
+        loc: {
+          start: {
+            line: 1,
+            column: 5
+          },
+          end: {
+            line: 1,
+            column: 15
+          }
+        }
+      },
+      right: {
+        type: "Identifier",
+        name: "list",
+        loc: {
+          start: {
+            line: 1,
+            column: 19
+          },
+          end: {
+            line: 1,
+            column: 23
+          }
+        }
+      },
+      body: {
+        type: "ExpressionStatement",
+        expression: {
+          type: "CallExpression",
+          callee: {
+            type: "Identifier",
+            name: "process",
+            loc: {
+              start: {
+                line: 1,
+                column: 25
+              },
+              end: {
+                line: 1,
+                column: 32
+              }
+            }
+          },
+          arguments: [
+            {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 33
+                },
+                end: {
+                  line: 1,
+                  column: 34
+                }
+              }
+            }
+          ],
+          loc: {
+            start: {
+              line: 1,
+              column: 25
+            },
+            end: {
+              line: 1,
+              column: 35
+            }
+          }
+        },
+        loc: {
+          start: {
+            line: 1,
+            column: 25
+          },
+          end: {
+            line: 1,
+            column: 36
+          }
+        }
+      },
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 36
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 36
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("for (let i = function() { return 10 in [] } in list) process(x);", {
+  type: "Program",
+  body: [
+    {
+      type: "ForInStatement",
+      left: {
+        type: "VariableDeclaration",
+        declarations: [
+          {
+            type: "VariableDeclarator",
+            id: {
+              type: "Identifier",
+              name: "i",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 9
+                },
+                end: {
+                  line: 1,
+                  column: 10
+                }
+              }
+            },
+            init: {
+              type: "FunctionExpression",
+              id: null,
+              params: [],
+              body: {
+                type: "BlockStatement",
+                body: [
+                  {
+                    type: "ReturnStatement",
+                    argument: {
+                      type: "BinaryExpression",
+                      left: {
+                        type: "Literal",
+                        value: 10,
+                        loc: {
+                          start: {
+                            line: 1,
+                            column: 33
+                          },
+                          end: {
+                            line: 1,
+                            column: 35
+                          }
+                        }
+                      },
+                      operator: "in",
+                      right: {
+                        type: "ArrayExpression",
+                        elements: [],
+                        loc: {
+                          start: {
+                            line: 1,
+                            column: 39
+                          },
+                          end: {
+                            line: 1,
+                            column: 41
+                          }
+                        }
+                      },
+                      loc: {
+                        start: {
+                          line: 1,
+                          column: 33
+                        },
+                        end: {
+                          line: 1,
+                          column: 41
+                        }
+                      }
+                    },
+                    loc: {
+                      start: {
+                        line: 1,
+                        column: 26
+                      },
+                      end: {
+                        line: 1,
+                        column: 41
+                      }
+                    }
+                  }
+                ],
+                loc: {
+                  start: {
+                    line: 1,
+                    column: 24
+                  },
+                  end: {
+                    line: 1,
+                    column: 43
+                  }
+                }
+              },
+              loc: {
+                start: {
+                  line: 1,
+                  column: 13
+                },
+                end: {
+                  line: 1,
+                  column: 43
+                }
+              }
+            },
+            loc: {
+              start: {
+                line: 1,
+                column: 9
+              },
+              end: {
+                line: 1,
+                column: 43
+              }
+            }
+          }
+        ],
+        kind: "let",
+        loc: {
+          start: {
+            line: 1,
+            column: 5
+          },
+          end: {
+            line: 1,
+            column: 43
+          }
+        }
+      },
+      right: {
+        type: "Identifier",
+        name: "list",
+        loc: {
+          start: {
+            line: 1,
+            column: 47
+          },
+          end: {
+            line: 1,
+            column: 51
+          }
+        }
+      },
+      body: {
+        type: "ExpressionStatement",
+        expression: {
+          type: "CallExpression",
+          callee: {
+            type: "Identifier",
+            name: "process",
+            loc: {
+              start: {
+                line: 1,
+                column: 53
+              },
+              end: {
+                line: 1,
+                column: 60
+              }
+            }
+          },
+          arguments: [
+            {
+              type: "Identifier",
+              name: "x",
+              loc: {
+                start: {
+                  line: 1,
+                  column: 61
+                },
+                end: {
+                  line: 1,
+                  column: 62
+                }
+              }
+            }
+          ],
+          loc: {
+            start: {
+              line: 1,
+              column: 53
+            },
+            end: {
+              line: 1,
+              column: 63
+            }
+          }
+        },
+        loc: {
+          start: {
+            line: 1,
+            column: 53
+          },
+          end: {
+            line: 1,
+            column: 64
+          }
+        }
+      },
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 64
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 64
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("const x = 42", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "x",
+            loc: {
+              start: {
+                line: 1,
+                column: 6
+              },
+              end: {
+                line: 1,
+                column: 7
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 42,
+            loc: {
+              start: {
+                line: 1,
+                column: 10
+              },
+              end: {
+                line: 1,
+                column: 12
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 6
+            },
+            end: {
+              line: 1,
+              column: 12
+            }
+          }
+        }
+      ],
+      kind: "const",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 12
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 12
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("const eval = 42, arguments = 42", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "eval",
+            loc: {
+              start: {
+                line: 1,
+                column: 6
+              },
+              end: {
+                line: 1,
+                column: 10
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 42,
+            loc: {
+              start: {
+                line: 1,
+                column: 13
+              },
+              end: {
+                line: 1,
+                column: 15
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 6
+            },
+            end: {
+              line: 1,
+              column: 15
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "arguments",
+            loc: {
+              start: {
+                line: 1,
+                column: 17
+              },
+              end: {
+                line: 1,
+                column: 26
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 42,
+            loc: {
+              start: {
+                line: 1,
+                column: 29
+              },
+              end: {
+                line: 1,
+                column: 31
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 17
+            },
+            end: {
+              line: 1,
+              column: 31
+            }
+          }
+        }
+      ],
+      kind: "const",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 31
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 31
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+test("const x = 14, y = 3, z = 1977", {
+  type: "Program",
+  body: [
+    {
+      type: "VariableDeclaration",
+      declarations: [
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "x",
+            loc: {
+              start: {
+                line: 1,
+                column: 6
+              },
+              end: {
+                line: 1,
+                column: 7
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 14,
+            loc: {
+              start: {
+                line: 1,
+                column: 10
+              },
+              end: {
+                line: 1,
+                column: 12
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 6
+            },
+            end: {
+              line: 1,
+              column: 12
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "y",
+            loc: {
+              start: {
+                line: 1,
+                column: 14
+              },
+              end: {
+                line: 1,
+                column: 15
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 3,
+            loc: {
+              start: {
+                line: 1,
+                column: 18
+              },
+              end: {
+                line: 1,
+                column: 19
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 14
+            },
+            end: {
+              line: 1,
+              column: 19
+            }
+          }
+        },
+        {
+          type: "VariableDeclarator",
+          id: {
+            type: "Identifier",
+            name: "z",
+            loc: {
+              start: {
+                line: 1,
+                column: 21
+              },
+              end: {
+                line: 1,
+                column: 22
+              }
+            }
+          },
+          init: {
+            type: "Literal",
+            value: 1977,
+            loc: {
+              start: {
+                line: 1,
+                column: 25
+              },
+              end: {
+                line: 1,
+                column: 29
+              }
+            }
+          },
+          loc: {
+            start: {
+              line: 1,
+              column: 21
+            },
+            end: {
+              line: 1,
+              column: 29
+            }
+          }
+        }
+      ],
+      kind: "const",
+      loc: {
+        start: {
+          line: 1,
+          column: 0
+        },
+        end: {
+          line: 1,
+          column: 29
+        }
+      }
+    }
+  ],
+  loc: {
+    start: {
+      line: 1,
+      column: 0
+    },
+    end: {
+      line: 1,
+      column: 29
+    }
+  }
+}, {ecmaVersion: 6, locations: true});
+
+testFail("const a;", "Unexpected token (1:7)", {ecmaVersion: 6});
+
+testFail("for(const x = 0;;);", "Unexpected token (1:4)", {ecmaVersion: 6});
+
 // Assertion Tests
 (function() {
   var actualComments = [],

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