什么是 JavaScript AST,如何使用它? [英] What is JavaScript AST, how to play with it?

查看:35
本文介绍了什么是 JavaScript AST,如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抽象语法树..我一直听说在 Github 上编译为 SpiderMonkey AST.
那么,这是 JS 语法树的实际标准吗?还有 V8,V8 是否使用相同类型的 AST?

Abstract Syntax Tree.. I always heard that compile to SpiderMonkey AST on Github.
So, is that a actual standard of JS syntax tree? And there's V8, is V8 using the same kind of AST?

我该怎么玩?

推荐答案

SpiderMonkey 提供了 parser api.这可能是掌握语法对象的最简单方法.

SpiderMonkey offers the parser api. This is probably the easiest way to get your hands on the syntax objects.

还有开放的 js-js 解析器,例如 Esprima(实际上是 ECMAScript,但它就在胡同)

There's also open js-js parsers like Esprima (which is ECMAScript, really, but it's right up the alley)

这篇关于什么是 JavaScript AST,如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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