This is a simple compiler that turns Python source into Parrot bytecode. By default, it will generate both a .pasm file (containing Parrot assembly source) and a compiled .pdbc file. -S will make it only write the .pasm file, and -r will try to execute the code by running Parrot's test_prog on the .pdbc file. Limitations: * Currently this only understands a *really* limited subset of Python: simple expressions, integer variables, and the 'while' and 'if' statements (with no 'else' suites). * The only allowable type is integer; strings, floats, long ints, &c., aren't supported at all. * It will die with an assertion if you feed it a language construct it doesn't handle (def, class, most operators). * The code structure is suboptimal; this is just a quick-and-dirty hack. Example usage: ute parrot>python euclid.py # Run code with Python 96 64 32 ute parrot>python parrot-gen.py -r euclid.py # -r to run generated bytecode 96 64 32 ute parrot>cat euclid.pasm main: set I3, 96 set I10, 64 set I9, 0 add I0, I3, I9 ... ... Currently the Parrot interpreter only supports integer, floating point, and string registers. There's no way to store the contents of a register in memory as far as I can tell, and PMCs -- Parrot Magic Cookies, the polymorphic objects that would correspond to PyObjects -- aren't implemented either. This means it's not possible to handle general variables, and therefore we'll have to wait for PMCs before general Python programs can be handled. Scalar PMCs are supposed to be implemented for Parrot 0.0.3, and dictionary/list PMCs in 0.0.4. You can discuss this code on either python-dev@python.org or perl6-internals@perl.org. --amk