diff options
author | Li Jin <dragon-fly@qq.com> | 2023-07-26 18:21:53 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-07-26 18:21:53 +0800 |
commit | b14f2b72cecdc8a194bb75e4d4a24b866ddef528 (patch) | |
tree | 21a45a1e82df1229ef2df33d8a7b214a3ec39fd5 /src/3rdParty/luaminify.lua | |
parent | dd55e092906123232f521b5d3ff2b848806ec67a (diff) | |
download | yuescript-b14f2b72cecdc8a194bb75e4d4a24b866ddef528.tar.gz yuescript-b14f2b72cecdc8a194bb75e4d4a24b866ddef528.tar.bz2 yuescript-b14f2b72cecdc8a194bb75e4d4a24b866ddef528.zip |
make minify and line rewriting work with Lua5.1
Diffstat (limited to 'src/3rdParty/luaminify.lua')
-rw-r--r-- | src/3rdParty/luaminify.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/3rdParty/luaminify.lua b/src/3rdParty/luaminify.lua index 7f770ca..925af1e 100644 --- a/src/3rdParty/luaminify.lua +++ b/src/3rdParty/luaminify.lua | |||
@@ -1737,6 +1737,12 @@ local function Format_Mini(ast) | |||
1737 | return a.."\n"..b | 1737 | return a.."\n"..b |
1738 | end]] | 1738 | end]] |
1739 | sep = sep or ' ' | 1739 | sep = sep or ' ' |
1740 | if sep == ';' then | ||
1741 | local token = a:match("([%w_]+)%s*$") | ||
1742 | if token == "then" or token == "do" then | ||
1743 | sep = ' ' | ||
1744 | end | ||
1745 | end | ||
1740 | local aa, bb = a:sub(-1,-1), b:sub(1,1) | 1746 | local aa, bb = a:sub(-1,-1), b:sub(1,1) |
1741 | if UpperChars[aa] or LowerChars[aa] or aa == '_' then | 1747 | if UpperChars[aa] or LowerChars[aa] or aa == '_' then |
1742 | if not (UpperChars[bb] or LowerChars[bb] or bb == '_' or Digits[bb]) then | 1748 | if not (UpperChars[bb] or LowerChars[bb] or bb == '_' or Digits[bb]) then |
@@ -2094,9 +2100,15 @@ local function FormatYue(ast, lineMap) | |||
2094 | break | 2100 | break |
2095 | end | 2101 | end |
2096 | end | 2102 | end |
2103 | aa = aa or '' | ||
2097 | sep = sep or ' ' | 2104 | sep = sep or ' ' |
2098 | if spaceSep then | 2105 | if spaceSep then |
2099 | sep = '' | 2106 | sep = '' |
2107 | elseif sep == ';' then | ||
2108 | local token = aa:match("([%w_]+)%s*$") | ||
2109 | if token == "then" or token == "do" then | ||
2110 | sep = ' ' | ||
2111 | end | ||
2100 | end | 2112 | end |
2101 | local bb = b:match("^%s*([^%s])") | 2113 | local bb = b:match("^%s*([^%s])") |
2102 | if UpperChars[aa] or LowerChars[aa] or aa == '_' then | 2114 | if UpperChars[aa] or LowerChars[aa] or aa == '_' then |