Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Acorn: top-level parsing experiment
// See https://jsperf.com/acorn-top-level-parsing-experiment/1 for example
acorn.plugins.top_level = function (instance) {
// Could skip other things as well, but this
// is where the most time can be saved
instance.parseBlock = function () {
var node = this.startNode();
var length = this.context.length;
do {
this.next();
} while (this.context.length >= length);
this.next(); // this.expect(tt.braceR);
node.body = [];
return this.finishNode(node, "BlockStatement");
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.