jspy is a toy JavaScript interpreter in Python created by Marek Stepniowski. Its implementation is directly based on ECMA-262 standard (PDF).
First install the package:
$ cd /main/jspy/folder
$ python setup.py install
You may need to have root rights, depending on your system configuration. After the installation, jspy script should be on your path. You can then just run the script with the JavaScript file as a single argument:
$ jspy file.js
To run the test suite, you either need Python 2.7 or the unittest2 package installed.
Python < 2.7:
$ cd /main/jspy/folder
$ unit2 discover
Python >= 2.7:
$ cd /main/jspy/folder
$ python -m unittest discover
You can find the newest source code of jspy on GitHub.
- Expressions (excluding
delete,typeof,instanceofandinoperators) - Statements (excluding
forandfor inloops,with,switch, labels and exception handling) - Functions (with nested execution scopes allowing for closures)
- Basic object support (
ObjectandArrayliterals, item assignment) console.log, same as in Node.js and Firebug
forandfor inloopsswitchstatement- Full object support (including an
Arrayimplementation) delete,typeof,instanceofandinoperators- Function statements
- Sane error messages
- Prototypal inheritance
- Exception handling
- Strict mode (should we run in strict mode by default?)
- Proper value behaviour (right now the behaviour of
NumberandStringobjects is Python-like and can sometimes be different than in JavaScript) - Automatic semicolon insertion (as defined in section 7.9 of ECMA-262)
- Labels for
breakandcontinuestatements withstatement (it's evil!)
The code is released open-source under the MIT license. See license.txt file for details.