从JSLINT解析树生成JavaScript [英] Generating JavaScript from a JSLINT parse tree

查看:142
本文介绍了从JSLINT解析树生成JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Crockford的 JSLINT ,在调用JSLINT()解析某些JavaScript源之后,它可以访问解析通过JSLINT.tree

With Crockford's JSLINT, after calling JSLINT() to parse some JavaScript source, it provides access to the parse tree via JSLINT.tree

能够分析树,在分析的基础上对其进行结构更改,然后从修改后的树中生成新的JavaScript,这将非常强大.

It would be really powerful to be able to analyse the tree, make structural changes to it based on the analysis and then generate new JavaScript from the modified tree.

是否存在通过从解析树到JavaScript的转换而在JSLINT上构建的开源项目?

Is there an open source project that builds on JSLINT by providing a conversion from a parse tree back to JavaScript?

(这是否有可能,即JSLINT是否从解析中保留了足够的信息以使重要的所有信息往返?)

(Is this even possible, i.e. does JSLINT keep complete enough information from the parse to round-trip everything significant?)

推荐答案

我不知道JSLint是否可以做到(在一些论坛帖子中,看起来维护树不是他们的目标,但它是副产品进行起毛过程).

I dont know if JSLint can do it (looking at some of the forum postings, it doesnt look like maintaining the tree is their goal but its a by-product for doing the linting process).

uglifyjs 项目可能有助于从javascript生成AST并将AST转换为代码.请参阅方法以了解AST到javascript的方法.

The uglifyjs project may help with generating an AST from javascript and re-converting a AST to code. See this method for AST to javascript.

这篇关于从JSLINT解析树生成JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆