stravant / lua-minify Goto Github PK
View Code? Open in Web Editor NEWLua minification / unminification CLI tool written in Lua
License: MIT License
Lua minification / unminification CLI tool written in Lua
License: MIT License
Completely missing bitwise operators standard in Lua 5.3
im using this inside my script
local ast = CreateLuaParser(script)
FormatAst(ast)
PrintAst(ast)
i skip this BeautifyVariables(global_scope, root_scope) because it just rename stuff ..also it doesnt matter because the output is same as below but without variables being renamed.
this is my test script
function main()
select = gg.choice({
"test1",
"test2"
})
if select == 1 then test.show() end
if select == 2 then test.show2() end
end
local a = 1
b = "3(£+£+£+£+"
local c = false
test = {
show = function()
gg.alert("find me")
end,
show2 = function()
gg.alert("yay me "..b)
end
}
function what()
gg.alert("yow")
end
what()
main()
and the script output this only
function main()
select = gg.choice({
"test1",
"test2"
})
if select == 1 then test.show() end
if select == 2 then test.show2() end
end
local a = 1
b = "3(£+£+£+£+"
local c = false
test = {
show = function()
gg.alert("find me")
end,
show2 = function()
gg.alert("yay me "..b)
end
}
function what()
gg.alert("yow")
end
what()
it forgots the main() here's the crazy part if you do this below
function what()
main()
gg.alert("yow")
end
what()
main()
the output is
function what()
main()
gg.alert("yow")
end
what()
even if you do this
function what()
main()
gg.alert("yow")
end
function what2()
gg.alert("yow")
end
what()
what2()
main()
the output will be
function what()
main()
gg.alert("yow")
end
function what2()
gg.alert("yow")
end
what()
what2()
Coming from LÖVE, having require in your code throws an issue:
require "test"
luajit: minify.lua:205: file<1:3>: Bad symbol `´` in source.
stack traceback:
[C]: in function 'olderr'
minify.lua:205: in function 'error'
minify.lua:406: in function 'CreateLuaTokenStream'
minify.lua:414: in function 'CreateLuaParser'
minify.lua:3206: in main chunk
[C]: at 0x00401f80
luajit 2.1
Can you please implement GlobalRenameIgnore
?
Currently, the parser is unable to handle vararg function declarations like e.g.
local function printf(...)
print(string.format(...))
end
local function printf_alternative(fmt, ...)
print(string.format(fmt, ...))
end
as it always expects identifiers in the argument list.
Pull request #1 is a first, incomplete attempt to fix this. I've submitted my solution in #2.
Regards, NiteHawk
Hi,
When I tried to run minify on the ltn12.lua file I get the following error:
lua: minify.lua:484: 43:23: )
expected.
stack traceback:
[C]: in function 'error'
minify.lua:484: in upvalue 'expect'
minify.lua:674: in upvalue 'funcdecl'
minify.lua:1290: in upvalue 'statement'
minify.lua:1310: in function minify.lua:1303
(...tail calls...)
minify.lua:3206: in main chunk
[C]: in ?
and the output file contains:
Tokens[-3] = .
Tokens[-2] = chain
Tokens[-1] = (
Tokens[0] = ...
Tokens[1] = )
Tokens[2] = local
Tokens[3] = arg
The function it is having this trouble with is:
-- chains a bunch of filters together
-- (thanks to Wim Couwenberg)
function filter.chain(...)
local arg = {...}
local n = select('#',...)
local top, index = 1, 1
local retry = ""
return function(chunk)
retry = chunk and retry
while true do
if index == top then
chunk = argindex
if chunk == "" or top == n then return chunk
elseif chunk then index = index + 1
else
top = top+1
index = top
end
else
chunk = arg[index](chunk or "")
if chunk == "" then
index = index - 1
chunk = retry
elseif chunk then
if index == n then return chunk
else index = index + 1 end
else base.error("filter returned inappropriate nil") end
end
end
end
end
print("Hello\32world!")
gets rejected with Invalid Escape Sequence '3'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.