Skip to content

Instantly share code, notes, and snippets.

@jacobp100
Last active October 26, 2016 14:24
Show Gist options
  • Save jacobp100/6b702d01e472b11a989f4ff8e2966198 to your computer and use it in GitHub Desktop.
Save jacobp100/6b702d01e472b11a989f4ff8e2966198 to your computer and use it in GitHub Desktop.
pp.parseStatement = function (declaration, topLevel) {
let node = this.startNode();
if (this.match(tokenTypes._if)) {
return this.parseIfStatement(node);
} else {
...
}
}
pp.parseIfStatement = function (node) {
this.next();
node.test = this.parseParenExpression();
node.consequent = this.parseStatement(false);
node.alternate = this.eat(tokenTypes._else) ? this.parseStatement(false) : null;
return this.finishNode(node, "IfStatement");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment