Git Product home page Git Product logo

lua-minify's People

Contributors

stravant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lua-minify's Issues

something weird going on

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()

require not working

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

Parser chokes on vararg functions

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

Minification error with ...

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.