Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 750
James A. Rosen Avatar asked Jun 20 '26 10:06

James A. Rosen


2 Answers

If you want to use Ruby you don't have to implement it yourself because Aaron Patterson of nokogiri fame already did in rkelly.

like image 89
Jonas Elfström Avatar answered Jun 21 '26 23:06

Jonas Elfström


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

like image 44
Lloyd Avatar answered Jun 21 '26 22:06

Lloyd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!