mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-25 02:10:39 +01:00
Tweak preprocessor to add -- decrement
This commit is contained in:
parent
72d4a5d4b8
commit
3dfcd95c6f
2
init.lua
2
init.lua
@ -63,7 +63,7 @@ i3 = {
|
|||||||
caches = lf"/src/caches.lua",
|
caches = lf"/src/caches.lua",
|
||||||
callbacks = lf"/src/callbacks.lua",
|
callbacks = lf"/src/callbacks.lua",
|
||||||
common = lf"/src/common.lua",
|
common = lf"/src/common.lua",
|
||||||
compress = lf"/src/compress.lua",
|
compress = lf"/src/compression.lua",
|
||||||
detached = lf"/src/detached_inv.lua",
|
detached = lf"/src/detached_inv.lua",
|
||||||
fields = lf"/src/fields.lua",
|
fields = lf"/src/fields.lua",
|
||||||
groups = lf"/src/groups.lua",
|
groups = lf"/src/groups.lua",
|
||||||
|
@ -51,6 +51,10 @@ local function compile(data)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
data = data:gsub("([%w_]+)-%-\n", function(a)
|
||||||
|
return fmt("%s = %s - 1", a, a)
|
||||||
|
end)
|
||||||
|
|
||||||
for op, func in pairs(operators) do
|
for op, func in pairs(operators) do
|
||||||
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ local files = {
|
|||||||
"caches",
|
"caches",
|
||||||
"callbacks",
|
"callbacks",
|
||||||
"common",
|
"common",
|
||||||
"compress",
|
"compression",
|
||||||
"detached_inv",
|
"detached_inv",
|
||||||
"fields",
|
"fields",
|
||||||
"groups",
|
"groups",
|
||||||
@ -91,6 +91,10 @@ local function compile(data)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
data = data:gsub("([%w_]+)-%-\n", function(a)
|
||||||
|
return fmt("%s = %s - 1", a, a)
|
||||||
|
end)
|
||||||
|
|
||||||
for op, func in pairs(operators) do
|
for op, func in pairs(operators) do
|
||||||
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
data = data:gsub("(" .. var .. "+)%s?" .. op .. "%s?(" .. var .. "*)", func)
|
||||||
end
|
end
|
||||||
@ -123,7 +127,7 @@ for _, p in ipairs(files) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _file = io.open(path:match("(.*)%.") .. ".l", "w")
|
local _file = io.open(path:match("(.*)%.") .. ".lc", "w")
|
||||||
_file:write(data)
|
_file:write(data)
|
||||||
_file:close()
|
_file:close()
|
||||||
end
|
end
|
||||||
@ -133,5 +137,5 @@ end
|
|||||||
|
|
||||||
exec "luacheck ../init.lua"
|
exec "luacheck ../init.lua"
|
||||||
exec "luacheck ../src/preprocessor.lua"
|
exec "luacheck ../src/preprocessor.lua"
|
||||||
exec "luacheck ../src/*.l"
|
exec "luacheck ../src/*.lc"
|
||||||
exec "rm ../src/*.l"
|
exec "rm ../src/*.lc"
|
||||||
|
Loading…
Reference in New Issue
Block a user