Is there a JavaScript (ECMAScript) implementation written in Python?

三世轮回 提交于 2019-12-03 08:49:21

问题


Are there any JavaScript (ECMAScript) implementations written in pure Python? It is okay even if its implementation is very slow.


回答1:


There is one, of an unknown level of completeness, written in RPython (a subset of Python, that is to say, it runs as normal Python): https://bitbucket.org/pypy/lang-js/overview




回答2:


Doesn't seem to be under active development anymore but you could check out pynarcissus, http://code.google.com/p/pynarcissus/source/browse/trunk/jsparser.py

Seems like a binding to V8 (JavaScript interpreter in Google Chromium) is available also, http://www.advogato.org/article/985.html




回答3:


You may want to take a look at pydermonkey or python-spidermonkey, both of which, I believe, are python implementations of the Mozilla javascript interpreter.




回答4:


I would recommend that you just stick to node.js on your local development box, translate your CoffeeScript files over to JavaScript, and deploy the translated scripts with your apps.

I get that you want to avoid having node.js on your servers, that's all fair and good. Jumping through hoops with Python invoking JavaScript to translate CoffeeScript seems more hassle to me than it's worth.




回答5:


I created Jispy to embed JS in Python.

From the docs:

A JavaScript Interpreter In Python

Jispy is an interpreter for a strict subset of JavaScript, fondly called LittleJ (LJ). It employs recursive descent for parsing and is very easily extendable.

Built for embedding JavaScript

Jispy's original vision was to seamlessly allow embedding JavaScript programs in Python projects. By default, it doesn't expose the host's file system or any other sensitive element. Some checks on infinite looping and infinite recursion are provided to tackle possibly malicious code.

It comes with an interactive console, so you can get up and running in no time.

Hope this helps.




回答6:


Have you heard of PyV8? It's a Python wrapper of Google's V8 JavaScript engine. It may be what you're looking for.



来源:https://stackoverflow.com/questions/7451619/is-there-a-javascript-ecmascript-implementation-written-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!