Fast ECMAScript Parser – Alternative to Acorn / Esprima
github.com
github.com
Looked at the parser code - it's well crafted. Works with integers instead of strings wherever possible.
The API is dead simple. Produces standard ESTree AST. Should take 10 minutes to port projects from `acorn` and `esprima` to `cherow`.
I wonder why he had Typescript target ES2015 only to use Buble to convert to ES5. Perhaps Buble produces more performant ES5 code than Typescript?
Still a ways away from being "a thing" in the language spec.
Cherow seems to be faster than Acorn, but it is also 30% bigger :(
A similar idea that I've thought of is a much lighter-weight version of Babel for super-fast development builds when you're targeting latest Chrome or Node.js. Disabling nearly all Babel transforms doesn't speed things up much since you still need to go through the parse-transform-format process, but it seems like the small number of remaining transforms (JSX, maybe typescript/flow, maybe imports) could potentially be done without a full AST parse and format, especially if it's just for development and doesn't need to be stable enough for production builds.
Some of the identifiers are a bit unwieldy, however; e.g.
parseForOrForInOrForOfStatement
I think something closer to this would be clearer parse_for_stmts()
since that function AFAICS parses all statements beginning with "for".I just meant that the code for for-loops in particular is complicated, and having very specific names helps in that area.
Does TypeScript minify your code or is that a separate step?
That includes proper auto complete.
But please consider that performance is not the only factor when building parsers.
Extensibility is a major concern. Afaik Babylon (used in babel) is a fork of Acorn partly driven by the need for greater extensibility. https://github.com/babel/babylon
Another example is espree used in ESLint https://github.com/eslint/espree According to their readme.md espree was based on Esprima and is now using Acorn. Specifically for extensibility reasons. https://github.com/eslint/espree/issues/200
But as far as I know Esprima does not: https://github.com/jquery/esprima/issues/1168
I have no idea about Cherow...