Loose: Added support for assignment patterns to expression and variables.
This commit is contained in:
parent
c5145cedb2
commit
4879af22d1
@ -498,13 +498,12 @@
|
|||||||
function parseVar(node, noIn) {
|
function parseVar(node, noIn) {
|
||||||
node.declarations = [];
|
node.declarations = [];
|
||||||
node.kind = "var";
|
node.kind = "var";
|
||||||
while (token.type === tt.name) {
|
do {
|
||||||
var decl = startNode();
|
var decl = startNode();
|
||||||
decl.id = parseIdent();
|
decl.id = options.ecmaVersion >= 6 ? toAssignable(parseExprAtom()) : parseIdent();
|
||||||
decl.init = eat(tt.eq) ? parseExpression(true, noIn) : null;
|
decl.init = eat(tt.eq) ? parseExpression(true, noIn) : null;
|
||||||
node.declarations.push(finishNode(decl, "VariableDeclarator"));
|
node.declarations.push(finishNode(decl, "VariableDeclarator"));
|
||||||
if (!eat(tt.comma)) break;
|
} while (eat(tt.comma));
|
||||||
}
|
|
||||||
if (!node.declarations.length) {
|
if (!node.declarations.length) {
|
||||||
var decl = startNode();
|
var decl = startNode();
|
||||||
decl.id = dummyIdent();
|
decl.id = dummyIdent();
|
||||||
@ -541,7 +540,7 @@
|
|||||||
if (token.type.isAssign) {
|
if (token.type.isAssign) {
|
||||||
var node = startNodeAt(start);
|
var node = startNodeAt(start);
|
||||||
node.operator = token.value;
|
node.operator = token.value;
|
||||||
node.left = checkLVal(left);
|
node.left = token.type === tt.eq ? toAssignable(left) : checkLVal(left);
|
||||||
next();
|
next();
|
||||||
node.right = parseMaybeAssign(noIn);
|
node.right = parseMaybeAssign(noIn);
|
||||||
return finishNode(node, "AssignmentExpression");
|
return finishNode(node, "AssignmentExpression");
|
||||||
@ -821,7 +820,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return node;
|
return checkLVal(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseFunctionParams(node) {
|
function parseFunctionParams(node) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user