Python中的JavaScript解析器 [英] JavaScript parser in Python

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

问题描述

至少在C和Java(Mozilla),JavaScript(Mozilla)和Ruby中都有一个JavaScript解析器。目前有没有Python?

There is a JavaScript parser at least in C and Java (Mozilla), in JavaScript (Mozilla again) and Ruby. Is there any currently out there for Python?

我本身不需要JavaScript解释器,只需要一个符合ECMA-262标准的解析器。

I don't need a JavaScript interpreter, per se, just a parser that's up to ECMA-262 standards.

快速谷歌搜索显示没有立即答案,所以我问SO社区。

A quick google search revealed no immediate answers, so I'm asking the SO community.

推荐答案


ANTLR ,另一种语言识别工具,是一种语言提供框架,用于构建包含各种目标语言操作的语法描述的识别器,解释器,编译器和翻译器。

ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages.

ANTLR 网站提供了许多语法,包括一个用于JavaScript

The ANTLR site provides many grammars , including one for JavaScript.

碰巧,有一个 Python API 可用 - 所以你可以直接从Python调用语法生成的词法分析器(识别器)。祝你好运。

As it happens, there is a Python API available - so you can call the lexer (recognizer) generated from the grammar directly from Python (good luck).

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

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