Skip to content Skip to sidebar Skip to footer

Creating A New Language Within The Python Virtual Machine

Is it possible to create a new language for the Python Virtual Machine? I was reading over http://late.am/post/2012/03/26/exploring-python-code-objects , where the blogger discusse

Solution 1:

Why the lucky stiff once hacked together a script that would compile Ruby code into Python bytecode. I remember that it worked well for simple Ruby scripts. You can look at the sources to see how he did it.

EDIT: So what he does is let the Ruby VM generate Ruby bytecode, than translate that bytecode to Python. Could still be interesting to see how the Python bytecode is assembled :)

Solution 2:

I think a good place to start would be ply, here's a Lisp implementation using ply: http://www.juanjoconti.com.ar/files/python/mini-lisp/

I'm not sure if ply can generate syntax trees using Python's ast module, but it should be possible.

Post a Comment for "Creating A New Language Within The Python Virtual Machine"