Skip to content

pyzh/orz

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 

Repository files navigation

orz

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
$

Lua 5.2

Language Features

Most Lua language features are missing.

GC Metamethod No
Weak Table No
Coroutine No
goto statement Partial
proper tail recursion No

Libraries

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

Basic Library

assert Yes
collectgarbage No
dofile No
error Partial
_G Partial
getmetatable Yes
ipairs Yes
load Different1
loadfile Different2
next No
pairs No
pcall No
print 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

Package Library

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 Library

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

I/O Library

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 Library

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

Known Bugs

Number

All ValueError are converted to nan, and all OverflowError are converted to inf.

tonumber

The convertion of fraction part of hexadecimal constants may overflow.

Format

string.format is simply equivalent to formatstring%... in Python, now.

_ENV

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


  1. 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

  2. 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

  3. Currently, patterns are just Python regular expressions.

  4. Currently, patterns are just Python regular expressions.

  5. Currently, patterns are just Python regular expressions.

About

porting programming languages to CPython VM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%