Porting programming languages to CPython VM.
There is only an experimental partial implementation of Lua 5.2 right now. You can try it out with following commands.
$ pip install git+git://github.com/xiazheteng/orz
$ cat > hello.lua << EOF
print(_VERSION)
EOF
$ python -m orz.lua hello.lua
Lua 5.2
$
Most Lua language features are missing.
GC Metamethod | No |
Weak Table | No |
Coroutine | No |
goto statement | Partial |
proper tail recursion | No |
Only a small subset of Lua Standard Libraries are implemented.
Basic Library | Partial |
Coroutine | No |
Package Library | Partial |
String Library | Partial |
Table | Yes |
Math | Bug, see Number |
Bit32 | No |
I/O Library | Partial |
OS Library | Partial |
Debug | No |
assert | Yes |
collectgarbage | No |
dofile | No |
error | Partial |
_G | Partial |
getmetatable | Yes |
ipairs | Yes |
load | Different1 |
loadfile | Different2 |
next | No |
pairs | No |
pcall | No |
Bug | |
rawequal | Yes |
rawget | Yes |
rawlen | Yes |
rawset | Yes |
select | Yes |
setmetatable | Yes |
tonumber | Bug, see tonumber |
tostring | Yes |
type | No |
_VERSION | Yes |
xpcall | No |
require | Partial |
package.config | No |
package.cpath | No |
package.loaded | No |
package.loadlib | No |
package.path | No |
package.preload | No |
package.searchers | No |
package.searchpath | No |
string.byte | Yes |
string.char | Yes |
string.dump | No |
string.find | No |
string.format | Bug, see Format |
string.gmatch | Different3 |
string.gsub | Different4 |
string.len | Yes |
string.lower | Yes |
string.match | Different5 |
string.rep | Yes |
string.reverse | Yes |
string.sub | Yes |
string.upper | Yes |
io.close | Partial |
io.flush | Yes |
io.input | Yes |
io.lines | No |
io.open | Yes |
io.output | Yes |
io.popen | No |
io.read | Partial |
io.tmpfile | Yes |
io.type | Yes |
io.write | Yes |
file:close | Partial |
file:flush | Yes |
file:lines | No |
file:read | Partial |
file:seek | Yes |
file:setvbuf | No |
file:write | Yes |
os.clock | Yes |
os.date | Yes |
os.difftime | Yes |
os.execute | Yes |
os.exit | Partial |
os.getenv | Yes |
os.remove | Yes |
os.rename | Yes |
os.setlocale | No |
os.time | Yes |
os.tmpname | No |
All ValueError
are converted to nan
, and all OverflowError
are converted to inf
.
The convertion of fraction part of hexadecimal constants may overflow.
string.format is simply equivalent to formatstring%...
in Python, now.
The following program, Lua 5.2.1 displays 1, but orz.lua displays nil.
a = 0
function x()
_ENV = {print=print}
return 1
end
_ENV["a"] = x()
print(a)
Footnotes
load does not accept Lua chunks in binary mode but marshaled Python code objects instead. And the second argument of load is changed to filename↩
load does not accept Lua chunks in binary mode but marshaled Python code objects instead. And the second argument of load is changed to filename↩
Currently, patterns are just Python regular expressions.↩
Currently, patterns are just Python regular expressions.↩
Currently, patterns are just Python regular expressions.↩