The Lua Library Compactor, or only Lim, is a simple terminal program to compact Lua scripts. It was created for easily the creation, maintain and update of libraries from Tiny Library, but nothing prevent that it will be used in other contexts.
Important
Lim cannot fix syntax and semantic errors in the code, it single objective is to compact the code and maintain it is working after of the process. If it does not work before the compaction, it will not work after it.
In summary:
- Lim will replace the identifiers, from input file, to a lower identifier (
foo -> a
). - It will remove unnecessary white spaces.
- And it will group all the result content in a block
do end
, positioned in one line.
In addition to the main line, there are other two lines, one above (with the declaration of the core table) and other below (with the declaration of the reference table). See this example:
Before compaction:
function foo()
return "foo"
end
After compaction:
local _={}
do function _.foo()return"foo"end end
local lib=_
# compact a file
lim <input>.lua [--replace] [--name <output>]
# asking for help
lim --help [flag-name | help-argument]
# examples
lim foo.lua
lim foo1.lua --name FOO-1
lim --help
lim --help --replace
Note
Please report bugs here.