TITLE ^

Status of Lua on Parrot

Introduction ^

Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight scripting language for any program that needs one.

The homepage is http://www.lua.org/.

The reference manual is available on http://www.lua.org/manual/.

This implementation is aligned with Lua 5.1 specifications.

PIR Compiler/Interpreter ^

lua.pbc is the interpreter/compiler, see languages/lua/src/lua51.pir & languages/lua/lua.pir.

lua.pbc is written in PIR and generates PIR from Lua sources. lua.pbc uses the following Parrot compiler toolchain components :

PGE

The Lua grammar is described in languages/lua/src/lua51.pg.

The PIR code is emitted by CodeString.

PGE is also used by the Lua pattern compiler in languages/lua/src/lib/luaregex.pir.

TGE

Two stages of tree transformation are used languages/lua/src/PASTGrammar.tg & languages/lua/src/POSTGrammar.tg.

PAST

The AST is represented with compilers/pct/src/PAST/Node.pir.

POST

The OST is represented with compilers/pct/src/POST/Node.pir.

HLLCompiler

This Lua compiler extends the base class compilers/pct/src/PCT/HLLCompiler.pir.

The lexicography part could be checked with languages/lua/test_lex.pir.

The code generation could be examined with languages/lua/luap.pir.

KNOWN PROBLEMS ^

in languages/lua/t/closure.t :

    a = {}
    local x = 20
    for i=1,10 do
        local y = 0
        a[i] = function () y=y+1; return x+y end
    end

    print(a[1]())
    print(a[1]())
    print(a[2]())

    --[[
    The loop creates ten closures (that is, ten instances of the anonymous
    function). Each of these closures uses a different y variable, while all
    of them share the same x.
    ]]

y variable is not different.

Perl Compiler (deprecated) ^

This compiler is written in Perl5 :

Lua Types ^

There are eight basic types in Lua, each of them is implemented by a PMC.

languages/lua/src/pmc/luaany.pmc provides an abstract base class for all Lua types.

languages/lua/src/pmc/lua.pmc is a singleton PMC what holds some static methods.

TODO ^

Arguments passing in invoke method of table. Where are there ?

IMPROVEMENT ^

table with a mixed array and hash (like Lua 5).

Lua Standard Libraries ^

Lua 5.1 defines the following standard libraries:

languages/lua/src/lib/luaaux.pir is the equivalent of Auxiliary Library.

languages/lua/src/lib/luaregex.pir implements a regex compiler using PGE.

TODO ^

Complete some of these libraries.

Extension Libraries ^

These libraries are loaded dynamically with the Lua function require.

Next Milestones ^

Debugging & stabilisation.

FEEDBACK ^

I try to summarize all my feedback, here : http://www.nntp.perl.org/group/perl.perl6.internals/2007/10/msg40493.html.

Related Projects ^

Klaas-Jan Stol works on 2 projects :

See http://kjs.home.fmf.nl/.

AUTHOR ^

Francois Perrad.


parrot