librelist archives

« back to archive

py2js - opcodes vs AST experience

py2js - opcodes vs AST experience

From:
Ondřej Čertík
Date:
2012-07-01 @ 17:50
Hi,

I just wanted to share some experience with a Python to Javascript
translator that I started some time ago. First using opcodes:

https://github.com/certik/pyvascript

but I have abandoned the approach, because the opcodes made it really
hard to understand the original Python syntax (it is just too
low-level). So I then wrote py2js using AST:

https://github.com/qsnake/py2js

That works well. I just didn't have time to work on it, but as far as
I know, the approach should allow to translate pretty much any Python
to Javascript.
So you can use it to get ideas how to get things done, as some of it
is not super well documented in the official Python docs.
In the above, I did reuse some codes from other people.

Ondrej