TheLarkInn / js-parser-discussions

Discussions & Collaboration on a Unified/Base set of parser features for JavaScript
42 stars 1 forks source link

Key Differences Between Acorn / Esprima #6

Open xjamundx opened 8 years ago

xjamundx commented 8 years ago

I found this quote from nicholas zakas pretty interesting about why eslint couldn't use acorn directly: https://github.com/eslint/espree#frequently-asked-questions

Acorn is a great JavaScript parser that produces an AST that is compatible with Esprima. Unfortunately, ESLint relies on more than just the AST to do its job. It relies on Esprima's tokens and comment attachment features to get a complete picture of the source code. We investigated switching to Acorn, but the inconsistencies between Esprima and Acorn created too much work for a project like ESLint.

We are building on top of Acorn, however, so that we can contribute back and help make Acorn even better.

This repo should try to highlight clearly what differences exist between the various parsers, most of all of which share the same AST structure and basic API.

mikesherov commented 8 years ago

ESTree is the standard Acorn and Esprima use. It has no notion of tokens. We had some discussions around a CST that didn't really go all that far.

xjamundx commented 8 years ago

@mikesherov was jscs using esprima directly the whole time?

mikesherov commented 8 years ago

Until 3.0. But a CST module was created that intelligently combined the tree with the tokens for easy manipulation, whitespace changes.

xjamundx commented 8 years ago

This is helpful. Describes the differences between babylon and estree: https://github.com/babel/babylon#output

ariya commented 8 years ago

I plan to write something for #5, I think that should help normalizing the understanding.