lua-users home
lua-l archive

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


Hi,

I am looking to embed Lua into an small embedded system.

I have found the Technical Notes LTN 1 and LTN 2 about how to remove
the lexer and parser to reduce the size of the binary.

However, these notes are for Lua 3 and 4 and I have not found anything
similar for Lua 5.
The only thing I have found is the last question in the FAQ on the Wiki:

> Lua code can be stored and loaded in a pre-compiled binary form which can be generated by its standard compiler tool, luac.
> The binary form is more memory-efficient than source text, but also allows another possibility for the interpreter: the parsing/compiling
> code can be removed altogether. This reduces the size of the already small Lua core to about 40K. Lua programs in binary form can
> also be encoded as C strings and easily stored in the host's source code. It is therefore convenient to use Lua in devices that lack
> a filesystem.

So this strategy seems to be still possible to do, but I am not sure
that the guidelines of LTN 2 are still meaningful.
For instance `lua_dobuffer()` has been removed and the replacement is
to use `luaL_loadbuffer()` which accepts both text and binary.
I have not found a function that can load/run only binaries. So, I am
wondering if the parser is more linked into the library (and harder to
remove) in Lua 5.

To conclude: is there a guide to remove the parser from Lua 5?
Is there a better function than `luaL_loadbuffer()` to run binaries?

Thanks for your help

Regards,

Benjamin