[Pkg-javascript-commits] [node-acorn-jsx] 327/484: Loose: Added support for let and const.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:50 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 963a26e46f158b83de3c551743ebdff574a10281
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Sun Oct 26 23:44:19 2014 +0200
Loose: Added support for let and const.
Fixes #146.
---
acorn_loose.js | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/acorn_loose.js b/acorn_loose.js
index f3523b8..4159309 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -335,10 +335,8 @@
pushCx();
expect(tt.parenL);
if (token.type === tt.semi) return parseFor(node, null);
- if (token.type === tt._var) {
- var init = startNode();
- next();
- parseVar(init, true);
+ if (token.type === tt._var || token.type === tt._let) {
+ var init = parseVar(true);
if (init.declarations.length === 1 && eat(tt._in))
return parseForIn(node, init);
return parseFor(node, init);
@@ -421,9 +419,9 @@
return finishNode(node, "TryStatement");
case tt._var:
- next();
- node = parseVar(node);
- return node;
+ case tt._let:
+ case tt._const:
+ return parseVar();
case tt._while:
next();
@@ -495,9 +493,11 @@
return finishNode(node, "ForInStatement");
}
- function parseVar(node, noIn) {
+ function parseVar(noIn) {
+ var node = startNode();
+ node.kind = token.type.keyword;
+ next();
node.declarations = [];
- node.kind = "var";
do {
var decl = startNode();
decl.id = options.ecmaVersion >= 6 ? toAssignable(parseExprAtom()) : parseIdent();
@@ -803,7 +803,7 @@
node.type = "ObjectPattern";
var props = node.properties;
for (var i = 0; i < props.length; i++) {
- toAssignable(props[i].value);
+ props[i].value = toAssignable(props[i].value);
}
break;
@@ -811,12 +811,12 @@
node.type = "ArrayPattern";
var elms = node.elements;
for (var i = 0; i < elms.length; i++) {
- toAssignable(elms[i]);
+ elms[i] = toAssignable(elms[i]);
}
break;
case "SpreadElement":
- toAssignable(node.argument);
+ node.argument = toAssignable(node.argument);
break;
}
}
--
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