有哪些工具可用于解析 Javascript 并读取 Javascript 或 Ruby 中的结果?
我想做一些 Javascript 代码分析。我更喜欢在 AST 或 S-Expression。尽管我似乎找不到任何文档,但 V8 引擎当然有可能构建此内容关于如何从 Javascript 上下文访问此信息。
我非常乐意在 Ruby 中进行分析,尽管我能想到的唯一方法是在 Treetop 或类似的解析器生成器。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想使用 Ruby,则不必自己实现它,因为 nokogiri 出名的 Aaron Patterson 已经在 rkelly。
If you want to use Ruby you don't have to implement it yourself because Aaron Patterson of nokogiri fame already did in rkelly.
查看 UglifyJS: https://github.com/mishoo/UglifyJS
Check out UglifyJS: https://github.com/mishoo/UglifyJS
我们的 DMS 软件重组工具包 能够解析 ECMAScript(甚至嵌入 HTML 脚本标记中)或 ONxxx 属性),并构建 AST。您可以定义自己的分析程序,使用源代码级模式来识别代码或转换代码;这些操纵 AST。转换后,您可以重新生成有效的源文本,包括注释。
如果需要,您可以将 AST 作为 XML 导出为另一种语言,但 DMS 包含许多有用的机制来支持程序分析和转换,我相信当您仔细观察时,诱惑就会消失。
DMS 也适用于多种其他语言。
Our DMS Software Reengineering Toolkit is capable of parsing ECMAScript (even embedded in HTML script tags or ONxxx attrbutes), and building ASTs. You can define your own analysis procedures, use source-level patterns to recognize code or transform the code; these manipulate the ASTs. After transformation, you can regenerate valid source text, including comments.
You can export the ASTs to another language as XML if you want, but DMS contains so much useful machinery to support program analysis and transformation that I believe that temptation will go away when you look closely.
DMS works for a wide variety of other languages, too.