aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/LuaMinify.h
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-11-27 14:28:39 +0800
committerLi Jin <dragon-fly@qq.com>2023-11-27 14:28:39 +0800
commit1288432c7cb5db2aff4fd6cf46ee8d8442913046 (patch)
treecf64cc7f07da1224fd4fc7a0b04659e629a0a37e /src/3rdParty/LuaMinify.h
parentcd827731ca155f198d26b61a0965469560e1bb34 (diff)
downloadyuescript-1288432c7cb5db2aff4fd6cf46ee8d8442913046.tar.gz
yuescript-1288432c7cb5db2aff4fd6cf46ee8d8442913046.tar.bz2
yuescript-1288432c7cb5db2aff4fd6cf46ee8d8442913046.zip
fix luaminify issue.
Diffstat (limited to 'src/3rdParty/LuaMinify.h')
-rw-r--r--src/3rdParty/LuaMinify.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/3rdParty/LuaMinify.h b/src/3rdParty/LuaMinify.h
index 7ade925..f1f496f 100644
--- a/src/3rdParty/LuaMinify.h
+++ b/src/3rdParty/LuaMinify.h
@@ -45,7 +45,7 @@ local function PrintTable(tb, atIndent)
45 out = out..(useNewlines and baseIndent or '') 45 out = out..(useNewlines and baseIndent or '')
46 if type(k) == 'number' then 46 if type(k) == 'number' then
47 --nothing to do 47 --nothing to do
48 elseif type(k) == 'string' and k:match("^[A-Za-z_][A-Za-z0-9_]*$") then 48 elseif type(k) == 'string' and k:match("^[A-Za-z_][A-Za-z0-9_]*$") then
49 out = out..k.." = " 49 out = out..k.." = "
50 elseif type(k) == 'string' then 50 elseif type(k) == 'string' then
51 out = out.."[\""..k.."\"] = " 51 out = out.."[\""..k.."\"] = "
@@ -547,7 +547,7 @@ local function LexLua(src)
547 --get the initial char 547 --get the initial char
548 local thisLine = line 548 local thisLine = line
549 local thisChar = char 549 local thisChar = char
550 --local errorAt = ":"..line..":"..char..":> " 550 -- local errorAt = ":"..line..":"..char..":> "
551 local c = peek() 551 local c = peek()
552 552
553 --symbol to emit 553 --symbol to emit
@@ -1316,6 +1316,9 @@ R"lua_codes(
1316 if not tok:ConsumeKeyword('then', tokenList) then 1316 if not tok:ConsumeKeyword('then', tokenList) then
1317 return false, GenerateError("`then` expected.") 1317 return false, GenerateError("`then` expected.")
1318 end 1318 end
1319 if tok:IsSymbol(';') then
1320 tok:Get()
1321 end
1319 local st, nodeBody = ParseStatementList(scope) 1322 local st, nodeBody = ParseStatementList(scope)
1320 if not st then return false, nodeBody end 1323 if not st then return false, nodeBody end
1321 nodeIfStat.Clauses[#nodeIfStat.Clauses+1] = { 1324 nodeIfStat.Clauses[#nodeIfStat.Clauses+1] = {
@@ -1779,7 +1782,7 @@ local function Format_Mini(ast)
1779 --don't want to accidentally call last statement, can't join directly 1782 --don't want to accidentally call last statement, can't join directly
1780 return a..sep..b 1783 return a..sep..b
1781 else 1784 else
1782 --print("asdf", '"'..a..'"', '"'..b..'"') 1785 --print("asdf", '"'..a..'"', '"'..b..'"')
1783 return a..b 1786 return a..b
1784 end 1787 end
1785 end 1788 end
@@ -2470,7 +2473,7 @@ local function GetYueLineMap(luaCodes)
2470 local current = 1 2473 local current = 1
2471 local lastLine = 1 2474 local lastLine = 1
2472 local lineMap = { } 2475 local lineMap = { }
2473 for lineCode in luaCodes:gmatch("[^\n\r]*") do 2476 for lineCode in luaCodes:gmatch("([^\r\n]*)\r?\n?") do
2474 local num = lineCode:match("--%s*(%d+)%s*$") 2477 local num = lineCode:match("--%s*(%d+)%s*$")
2475 if num then 2478 if num then
2476 local line = tonumber(num) 2479 local line = tonumber(num)