Move the parser state into an object

Makes almost everything in acorn.js a method of this object.

Performance is not significantly affected on a modern V8. Makes the
code reentrant and allows us to more easily expose more methods
externally in the future.

On the other hand, the proliferation of `this.` is unfortunate.
This commit is contained in:
Marijn Haverbeke 2015-02-23 15:38:06 +01:00
parent 33307e789a
commit bc48c02a18
2 changed files with 1607 additions and 1652 deletions

3256
acorn.js

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,7 @@
} else {
callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded.");
}
}
else if (test.assert) {
} else if (test.assert) {
var error = test.assert(ast);
if (error) callback("fail", test.code,
"\n Assertion failed:\n " + error);