[Pkg-javascript-commits] [node-acorn-jsx] 416/484: Closes #205.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:21:04 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 38609ae26d6fa071194026d4e15e9bd7d21fea82
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Fri Jan 23 14:14:02 2015 +0200
Closes #205.
---
acorn.js | 32 ++++++++++++++++++--------------
acorn_loose.js | 5 +++--
test/tests-harmony.js | 18 +++++++++---------
3 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/acorn.js b/acorn.js
index 334b3ff..491a3e2 100644
--- a/acorn.js
+++ b/acorn.js
@@ -1458,6 +1458,7 @@
case "ObjectPattern":
case "ArrayPattern":
case "AssignmentPattern":
+ case "RestElement":
break;
case "ObjectExpression":
@@ -1478,6 +1479,7 @@
case "SpreadElement":
if (allowSpread) {
+ node.type = "RestElement";
toAssignable(node.argument, false, checkType);
checkSpreadAssign(node.argument);
} else {
@@ -1502,17 +1504,19 @@
// Parses spread element.
- function parseSpread(isBinding) {
- var spread = startNode();
+ function parseSpread() {
+ var node = startNode();
next();
- if (isBinding) {
- var arg = parseAssignableAtom();
- checkSpreadAssign(arg);
- spread.argument = arg;
- } else {
- spread.argument = parseMaybeAssign();
- }
- return finishNode(spread, "SpreadElement");
+ node.argument = parseMaybeAssign();
+ return finishNode(node, "SpreadElement");
+ }
+
+ function parseRest() {
+ var node = startNode();
+ next();
+ node.argument = parseAssignableAtom();
+ checkSpreadAssign(node.argument);
+ return finishNode(node, "RestElement");
}
// Parses lvalue (assignable) atom.
@@ -1530,7 +1534,7 @@
while (!eat(_bracketR)) {
first ? first = false : expect(_comma);
if (tokType === _ellipsis) {
- elts.push(parseSpread(true));
+ elts.push(parseRest());
expect(_bracketR);
break;
}
@@ -1648,7 +1652,7 @@
break;
case "AssignmentPattern":
- case "SpreadElement":
+ case "RestElement":
break;
default:
@@ -2270,7 +2274,7 @@
first ? first = false : expect(_comma);
if (tokType === _ellipsis) {
spreadStart = tokStart;
- exprList.push(parseSpread(true));
+ exprList.push(parseRest());
break;
} else {
if (tokType === _parenL && !innerParenStart) {
@@ -2479,7 +2483,7 @@
} else {
toAssignable(param, i === lastI, true);
defaults.push(null);
- if (param.type === "SpreadElement") {
+ if (param.type === "RestElement") {
params.length--;
node.rest = param.argument;
break;
diff --git a/acorn_loose.js b/acorn_loose.js
index db2883c..dca43af 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -297,7 +297,7 @@
case "MemberExpression":
case "ObjectPattern":
case "ArrayPattern":
- case "SpreadElement":
+ case "RestElement":
case "AssignmentPattern":
return expr;
@@ -982,6 +982,7 @@
break;
case "SpreadElement":
+ node.type = "RestElement";
node.argument = toAssignable(node.argument);
break;
@@ -1007,7 +1008,7 @@
param = param.left;
}
param = toAssignable(param);
- if (param.type === "SpreadElement") {
+ if (param.type === "RestElement") {
param = param.argument;
if (i === params.length - 1) {
node.rest = param;
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index c0c74b8..82eafb1 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -12913,7 +12913,7 @@ test("[...a] = b", {
left: {
type: "ArrayPattern",
elements: [{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "Identifier",
name: "a",
@@ -12979,7 +12979,7 @@ test("[a, ...b] = c", {
}
},
{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "Identifier",
name: "b",
@@ -13101,7 +13101,7 @@ test("[{ a, b }, ...c] = d", {
}
},
{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "Identifier",
name: "c",
@@ -13168,7 +13168,7 @@ test("[a, ...[b, c]] = d", {
}
},
{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "ArrayPattern",
elements: [
@@ -13242,7 +13242,7 @@ test("var [...a] = b", {
id: {
type: "ArrayPattern",
elements: [{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "Identifier",
name: "a",
@@ -13308,7 +13308,7 @@ test("var [a, ...b] = c", {
}
},
{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "Identifier",
name: "b",
@@ -13430,7 +13430,7 @@ test("var [{ a, b }, ...c] = d", {
}
},
{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "Identifier",
name: "c",
@@ -13497,7 +13497,7 @@ test("var [a, ...[b, c]] = d", {
}
},
{
- type: "SpreadElement",
+ type: "RestElement",
argument: {
type: "ArrayPattern",
elements: [
@@ -14195,7 +14195,7 @@ test("[...a, ] = b", {
end: {line: 1, column: 8}
},
elements: [{
- type: "SpreadElement",
+ type: "RestElement",
loc: {
start: {line: 1, column: 1},
end: {line: 1, column: 5}
--
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