lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Jan 17, 2008 1:59 AM, Richard Warburton <richard@warburton.it> wrote:
Kahlua, looks pretty cool, but I could really do with a Java implementation of a Lua Compiler as well - aka, have lua based config files for a simple Java app.

You can load Metalua or Yueliang (lua compilers in lua) as precompiled Lua applications, both provide Lua->bytecode compilation implemented in Lua. I don't remember for Yueliang, but Metalua currently only produces bytecode in the default format (Lua 5.1, 32 bits little endian platforms, numbers represented as doubles). That's most likely what Kahlua expects but I haven't checked. If it doesn't suit you, adaptation isn't difficult.

A more real issue is that kahlua seems to miss some APIs. From http://code.google.com/p/kahlua/wiki/lua_api, the missing APIs that might be an issue are:

string.find
string.format
string.gmatch
string.gsub
string.match
table.concat
You'll probably need to reimplement these in Lua (Kahlua people would certainly be grateful), or hack the compiler to remove the dependencies. For  Metalua, the heaviest part would be the lexer.

About version choice: metalua 0.3 has the advantage of being in pure Lua, whereas the development version (http://repo.or.cz/w/metalua.git) is more stable and clean, but relies on some auxiliary C code. These dependencies can be removed however, especially if you're only interested in the pure Lua subset of the language (they're here to ensure watertightness across metalevels, something you don't care about).

I'd be interested to see this work, so don't hesitate to ask for help!

-- Fabien.