Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.

Decorators Stage 2 Parsing #587

Merged
merged 14 commits into from
Jun 22, 2017
Next Next commit
Update decorator parsing to match current spec
Refer to PR #353
  • Loading branch information
bakkot authored and peey committed Jun 17, 2017
commit 06afa0761bc77664ab87007b3638bed78f051135
24 changes: 23 additions & 1 deletion src/parser/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,31 @@ export default class StatementParser extends ExpressionParser {
if (!this.hasPlugin("decorators")) {
this.unexpected();
}

const node = this.startNode();
this.next();
node.expression = this.parseMaybeAssign();

const startPos = this.state.start;
const startLoc = this.state.startLoc;
let expr = this.parseIdentifier(false);

while (this.eat(tt.dot)) {
const node = this.startNodeAt(startPos, startLoc);
node.object = expr;
node.property = this.parseIdentifier(true);
node.computed = false;
expr = this.finishNode(node, "MemberExpression");
}

if (this.eat(tt.parenL)) {
const node = this.startNodeAt(startPos, startLoc);
node.callee = expr;
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
expr = this.finishNode(node, "CallExpression");
this.toReferencedList(expr.arguments);
}

node.expression = expr;
return this.finishNode(node, "Decorator");
}

Expand Down