Search code examples
javascriptrubyparsingabstract-syntax-trees-expression

What tools exist for parsing Javascript and reading the results in Javascript or Ruby?


I'd like to do some code-analysis of Javascript. I'd prefer to operate on ASTs or S-Expressions. It's certainly possible that the V8 engine builds this, though I can't seem to find any documentation on how to access this information from a Javascript context.

I'd be perfectly happy to do my analysis in Ruby, though the only way I can think of doing that would be to write an entire grammar in Treetop or a similar parser-generator.


Solution

  • Check out UglifyJS: https://github.com/mishoo/UglifyJS