I has a python translator!!1
Now at version 0.3 : Moving towards 1.0 compliance, and the last version that will run the pre 1.0 examples
Rather than being an interpreter, it translates LOLCODE from lolcode into valid python code.
It can optionally run the translated python securely in a sandbox so lolpy can be embedded in a webpage etc, and run malicious code without problem. Yay for python!
It currently runs the “hai-world”, “count-1” and “gimmeh” examples fine, with many more keywords to come as they are invented, and as I get around to putting them in.
It's written entirely in python, so get the code from the homepage (or the direct link here) and run it with python. There aren't any extra modules to install. There is just the one .py file.
When I started writing it, the Python interpreter wasn't there, and I have an unnatural fear of lex
Not bad. I strayed away from making a direct translator like this one or the Perl one because I'm sure eventually lolcode will contain something that won't translate nicely into Python code and I'm not sure I'm smart enough to be able to refactor it on the fly. That's why I went with the lex/yacc approach (plus I've used them before).
One bug I noticed: “UP VAR!!” doesn't have to take a number; it says the default is one if none is given. This translator doesn't seem to support that.
— Steve Losh, 2007/05/30 19:45
Thanks for the feedback, and pointing out the bug.
I'm not really that good at lex/yacc, so I figured I might as well just try and elegantly (laugh) translate it rather write an interpreter. I'm almost surprised that it was possible.
Nice work on your interpreter BTW
— David Basden, 2007/05/31 15:16