Mozilla have delivered an API for parsing a Javascript module to generate an abstract syntax tree. They call it Reflect.parse.
Is there a Reflect.parse, or something similar, written as a standalone module in Javascript? something I could run on any ES5 engine to produce a syntax tree? Failing that is there a standalone tool in C++ that does this for me? Or a service?
I tried doctorjs.org for a really simple self-evaluating anonymous function and it choked. Am I doing it wrong?
(function (scope) {
....
}(this));
Check out Esprima: http://esprima.org/
A separate project that generates a similar abstract syntax tree is here: http://boshi.inimino.org/3box/PanPG/build/js_ast.html
Try Esprima (esprima.org), a project I have started few months ago. Its AST output is compatible with Mozilla Reflect.parse, it runs almost everywhere from IE 6 to Node.js, the parser is extremely fast (the fastest among its competitor), heavily unit tested (500+ and growing) with 100% code coverage.
Esprima is ES5 compliant (including strict mode), there is even WIP for ES6 (and Harmony) features support. It is known to parse tons of JavaScript out there, from standard library such jQuery to million-lines web apps code, without any problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With