Read JavaScript Source Code, Using an AST | DigitalOcean
An AST is the result of parsing code. For JavaScript, an AST is a JavaScript object containing a tree representation of your source. Before we use it, we have to create it. Depending on the code we are parsing, we choose the appropriate parser.
some of the most well known Open Source ECMAScript parsers:
Parser | Supported Languages | Github |
---|---|---|
acorn | esnext & JSX (using acorn-jsx) | https://github.com/acornjs/acorn |
esprima | esnext & older | https://github.com/jquery/esprima |
cherow | esnext & older | https://github.com/cherow/cherow |
espree | esnext & older | https://github.com/eslint/espree |
shift | esnext & older | https://github.com/shapesecurity/shift-parser-js |
babel | esnext, JSX & typescript | https://github.com/babel/babel |
TypeScript | esnext & typescript | https://github.com/Microsoft/TypeScript |
Once upon a time, an unsuspecting Mozilla engineer created an API in Firefox that exposed the SpiderMonkey engine's JavaScript parser as a JavaScript API. Said engineer documented the format it produced, and this format caught on as a lingua franca for tools that manipulate JavaScript source code.
Meanwhile JavaScript is evolving. This site will serve as a community standard for people involved in building and using these tools to help evolve this format to keep up with the evolution of the JavaScript language.
No comments:
Post a Comment