Dalbit
Dalbit(달빛) is a Luau-to-Lua transpiler, designed specifically for Lua 5.3.
Note
This project is still in W.I.P
TO-DOs
- Implement CLI.
- Implement basic transpilation process using
darkluaandfull-moon. - Implement modifiers (such as converting number literals and generalized iterations)
- Implement basic lua polyfills.
- Add tests for polyfills.
- Add tests for transpilation. (to ensure the same results in lua and luau)
- Add tests for dalbit internally.
- Add logging for dalbit internally for debug.
-
convert_bit32modifier now convertsbit32.btest. - Add comments for docs and code readability. (WIP)
- Optimize polyfill.
Installation
Using Cargo (from crates.io)
Usage
init
Initializes dalbit manifest file in the current path.
fetch
Fetches and updates lua polyfills.
- This polyfill can be found here.
transpile
Transpiles luau code to lua code.
Example
dalbit.toml
= "lua"
= "lua53"
= true
[]
= true
[]
inputs/input.luau
local log = math.log
local floor = math.floor
local x = bit32
local band = x.band
local rshift = x.rshift
local lshift = x.lshift
local bnot = x.bnot
local bor = x.bor
local t = table.create(1)
local function byteswap(n: number): number
return bor(bor(bor(lshift(n, 24), band(lshift(n, 8), 0xff0000)), band(rshift(n, 8), 0xff00)), rshift(n, 24))
end
print(byteswap(5))
print(log(5))
print(floor(0.5))
print(t)
outputs/output.luau
local math=require. local table=require. local io=nil local module=nil local package=nil local dofile=nil local loadfile=nil local load=nil local log=math.
local floor=math.
local t=table.
local
print
print
print
print
How does it work?
- Dalbit actively utilizes darklua and full-moon to transform lua scripts.
Why darklua-demo over darklua?
darklua-demois a temporary fork to work properly with dal.darklua-demowill be replaced by officialdarkluaonce darklua released with important features to work properly with dal.
Special Thanks
- seaofvoices/darklua - Providing important and cool lua mutating rules.
- Kampfkarren/full-moon - A lossless Lua parser.
Trivia
The name of this project, Dalbit, translates to "moonshine" in Korean.