# HG changeset patch # User Matthew Wild # Date 1679050932 0 # Node ID 2b6416334a25b6f3a10ff99ff76d878d2aea7b2b # Parent 61085789b12b704a8b8ed3cda6cb9c2b3f6b382c A range of fixes for Lua 5.2 support diff -r 61085789b12b -r 2b6416334a25 minify/llex.lua --- a/minify/llex.lua Fri Mar 17 11:01:19 2023 +0000 +++ b/minify/llex.lua Fri Mar 17 11:02:12 2023 +0000 @@ -27,12 +27,23 @@ local base = _G local string = require "string" -module "llex" +--module "llex" local find = string.find local match = string.match local sub = string.sub +local z = '' -- source +local sourceid = '' -- name of source +local I = 1 -- lexer's position in source +local ln = 1 -- line number +local tok = {} -- lexed token list* +local seminfo = {} -- lexed semantic information list* +local tokln = {} -- line numbers for messages* +local buff = '' +-- NOTE: see init() for module variables (externally visible): +-- tok, seminfo, tokln + ---------------------------------------------------------------------- -- initialize keyword list, variables ---------------------------------------------------------------------- @@ -44,14 +55,6 @@ kw[v] = true end --- NOTE: see init() for module variables (externally visible): --- tok, seminfo, tokln - -local z, -- source stream - sourceid, -- name of source - I, -- position of lexer - buff, -- buffer for strings - ln -- line number ---------------------------------------------------------------------- -- add information to token listing @@ -89,13 +92,7 @@ function init(_z, _sourceid) z = _z -- source - sourceid = _sourceid -- name of source - I = 1 -- lexer's position in source - ln = 1 -- line number - tok = {} -- lexed token list* - seminfo = {} -- lexed semantic information list* - tokln = {} -- line numbers for messages* - -- (*) externally visible thru' module + sourceid = _sourceid -- name of source -------------------------------------------------------------------- -- initial processing (shbang handling) -------------------------------------------------------------------- @@ -352,4 +349,11 @@ end--while outer end -return _M +return { +llex = llex, +init = init, +chunkid = chunkid, +tok = tok, +tokln = tokln, +seminfo = seminfo +} diff -r 61085789b12b -r 2b6416334a25 minify/lparser.lua --- a/minify/lparser.lua Fri Mar 17 11:01:19 2023 +0000 +++ b/minify/lparser.lua Fri Mar 17 11:02:12 2023 +0000 @@ -27,7 +27,10 @@ local base = _G local string = require "string" -module "lparser" +--2018-06-10: RH - The lparser return table is declared here to satisfy the stat function. Stat +-- must exist before chunk and parse so creating a placeholderis the easiest solution. +local lparser = {} + --[[-------------------------------------------------------------------- -- variable and data structure initialization @@ -1205,7 +1208,7 @@ local fn = stat_call[c] -- handles: if while do for repeat function local return break if fn then - _M[fn]() + lparser[fn]() -- return or break must be last statement if c == "return" or c == "break" then return true end else @@ -1291,4 +1294,25 @@ ilocalinfo, ilocalrefs = {}, {} end -return _M +lparser = { +expr = expr, +exp1 = exp1, +explist1 = explist1, +body = body, +block = block, +for_stat = for_stat, +while_stat = while_stat, +repeat_stat = repeat_stat, +if_stat = if_stat, +return_stat = return_stat, +break_stat = break_stat, +expr_stat = expr_stat, +function_stat = function_stat, +do_stat = do_stat, +local_stat = local_stat, +chunk = chunk, +parser = parser, +init = init +} + +return lparser diff -r 61085789b12b -r 2b6416334a25 minify/optlex.lua --- a/minify/optlex.lua Fri Mar 17 11:01:19 2023 +0000 +++ b/minify/optlex.lua Fri Mar 17 11:02:12 2023 +0000 @@ -21,7 +21,6 @@ local base = _G local string = require "string" -module "optlex" local match = string.match local sub = string.sub local find = string.find @@ -831,4 +830,4 @@ return stoks, sinfos, stoklns end -return _M; +return {optimize = optimize} diff -r 61085789b12b -r 2b6416334a25 minify/optparser.lua --- a/minify/optparser.lua Fri Mar 17 11:01:19 2023 +0000 +++ b/minify/optparser.lua Fri Mar 17 11:02:12 2023 +0000 @@ -30,7 +30,6 @@ local base = _G local string = require "string" local table = require "table" -module "optparser" ---------------------------------------------------------------------- -- Letter frequencies for reducing symbol entropy (fixed version) @@ -441,4 +440,4 @@ ------------------------------------------------------------------ end -return _M; +return {optimize = optimize} diff -r 61085789b12b -r 2b6416334a25 squishy --- a/squishy Fri Mar 17 11:01:19 2023 +0000 +++ b/squishy Fri Mar 17 11:02:12 2023 +0000 @@ -2,7 +2,7 @@ -- Set this option, same as if user specified -- '--executable' on the command-line. Can be -- disabled by user with '--no-executable' -Option "executable" +Option "executable" "/usr/bin/lua5.2" -- Output filename Output "squish" diff -r 61085789b12b -r 2b6416334a25 uglify/llex.lua --- a/uglify/llex.lua Fri Mar 17 11:01:19 2023 +0000 +++ b/uglify/llex.lua Fri Mar 17 11:02:12 2023 +0000 @@ -27,7 +27,7 @@ local base = _G local string = require "string" -module "llex" +--module "llex" local find = string.find local match = string.match @@ -47,11 +47,14 @@ -- NOTE: see init() for module variables (externally visible): -- tok, seminfo, tokln -local z, -- source stream - sourceid, -- name of source - I, -- position of lexer - buff, -- buffer for strings - ln -- line number + local z = '', -- source + sourceid = '', -- name of source + I = 1, -- lexer's position in source + buff = '', + ln = 1, -- line number + tok = {}, -- lexed token list* + seminfo = {}, -- lexed semantic information list* + tokln = {}, -- line numbers for messages* ---------------------------------------------------------------------- -- add information to token listing @@ -352,4 +355,7 @@ end--while outer end -return _M +return { +init = init, +llex = llex +}