|
@@ -32,6 +32,7 @@ import {
|
|
TryStatement,
|
|
TryStatement,
|
|
UnaryOperation,
|
|
UnaryOperation,
|
|
VarDefine,
|
|
VarDefine,
|
|
|
|
+ VarDestructuringDefine,
|
|
VariableAccess,
|
|
VariableAccess,
|
|
WhileStatement,
|
|
WhileStatement,
|
|
WholeLiteral,
|
|
WholeLiteral,
|
|
@@ -349,8 +350,10 @@ export class Parser {
|
|
let isMapAccess;
|
|
let isMapAccess;
|
|
if ( (isMapAccess = this.stream.match(TokenType.LeftCurly, false)) || this.stream.match(TokenType.LeftBracket, false) ) {
|
|
if ( (isMapAccess = this.stream.match(TokenType.LeftCurly, false)) || this.stream.match(TokenType.LeftBracket, false) ) {
|
|
this.stream.expect(TokenType.LeftCurly, TokenType.LeftBracket);
|
|
this.stream.expect(TokenType.LeftCurly, TokenType.LeftBracket);
|
|
|
|
+ let tokens = [];
|
|
do {
|
|
do {
|
|
- this.stream.expect(TokenType.Identifier);
|
|
|
|
|
|
+ let token = this.stream.expect(TokenType.Identifier);
|
|
|
|
+ tokens.push(token);
|
|
} while (this.stream.match(TokenType.Comma, true));
|
|
} while (this.stream.match(TokenType.Comma, true));
|
|
if (isMapAccess) {
|
|
if (isMapAccess) {
|
|
this.stream.match(TokenType.RightCurly);
|
|
this.stream.match(TokenType.RightCurly);
|
|
@@ -358,7 +361,7 @@ export class Parser {
|
|
this.stream.match(TokenType.RightBracket);
|
|
this.stream.match(TokenType.RightBracket);
|
|
}
|
|
}
|
|
this.stream.match(TokenType.Assignment, true);
|
|
this.stream.match(TokenType.Assignment, true);
|
|
- return new VarDefine(new Span(opening, this.stream.getPrev().getSpan()), 'destructuring', this.parseExpression(), opening.getText())
|
|
|
|
|
|
+ return new VarDestructuringDefine(new Span(opening, this.stream.getPrev().getSpan()), tokens, this.parseExpression(), opening.getText())
|
|
}
|
|
}
|
|
let token = this.stream.expect(TokenType.Identifier);
|
|
let token = this.stream.expect(TokenType.Identifier);
|
|
this.checkKeyword(token.getSpan());
|
|
this.checkKeyword(token.getSpan());
|