feat: add optional MemberExpression

This commit is contained in:
Sven SAULEAU
2017-04-15 18:19:43 +02:00
parent 482b8155a3
commit 7b51979152
3 changed files with 109 additions and 0 deletions

View File

@@ -284,6 +284,14 @@ pp.parseSubscripts = function (base, startPos, startLoc, noCalls) {
node.object = base;
node.callee = this.parseNoCallExpr();
return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls);
} else if (this.eat(tt.question)) {
const node = this.startNodeAt(startPos, startLoc);
node.object = base;
node.optional = true;
this.next();
node.property = this.parseIdentifier(true);
node.computed = false;
base = this.finishNode(node, "MemberExpression");
} else if (this.eat(tt.dot)) {
const node = this.startNodeAt(startPos, startLoc);
node.object = base;