At 17:39 10/01/2006 +0100, Klaas-Jan Stol wrote:
Hi,
As you know, I've been playing with Lua for some time now, and my attempt
to write a Lua compiler targetting Parrot has not been completely
unsuccessful, but it was quite some work.
Anyway, at some point I realized that PIR looks very much like Lua
bytecodes (which I had inspected at that time already). So, I thought it
may be a nice project to write a Lua2PIR translator, which takes a binary
Lua file (compiled with the Lua compiler, so you'll need to get Lua (to be
found at www.lua.org))
If you are interested, it can be found at
http://members.home.nl/joeijoei/lua2pir/
It works pretty good. It needs still many tests, in order to check if all
special cases are covered, but quite complex examples do work already.
Furthermore, the Lua PMCs have to be integrated, as it just uses the
Parrot basic types (Float, String, Hash, etc). It's also nice to see what
kind of code the Lua compiler should more or less be generating.
I've integrated lua2pir in languages/lua/t/harness (monkey too).
I obtain the following result :
$ cd languages && perl -I../lib -Ilua/t lua/t/harness --use-lua2pir
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
lua\t\assign.t 4 1024 5 4 80.00% 1-4
lua\t\basic.t 8 2048 9 8 88.89% 1-7 9
lua\t\constructor.t 2 512 5 2 40.00% 2 5
lua\t\examples.t 1 256 3 1 33.33% 3
lua\t\expr.t 3 768 6 3 50.00% 4-6
lua\t\function.t 1 256 2 1 50.00% 2
lua\t\if.t 5 1280 5 5 100.00% 1-5
lua\t\math.t 23 5888 23 23 100.00% 1-23
lua\t\repeat.t 2 512 2 2 100.00% 1-2
lua\t\string.t 7 1792 7 7 100.00% 1-7
lua\t\tables.t 1 256 2 1 50.00% 1
lua\t\while.t 4 1024 4 4 100.00% 1-4
Failed 12/21 test scripts, 42.86% okay. 61/143 subtests failed, 57.34% okay.
Tests concerning the Lua Standard Libraries (basic, math, string) fail
because lua2pir refers its own library.
François.
NB: l2p & luac must be in your PATH, and lualib.pbc near parrot executable.
Kind regards,
Klaas-Jan Stol