A range of fixes for Lua 5.2 support lua5.2 tip

Fri, 17 Mar 2023 11:02:12 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 17 Mar 2023 11:02:12 +0000
branch
lua5.2
changeset 99
2b6416334a25
parent 98
61085789b12b

A range of fixes for Lua 5.2 support

minify/llex.lua file | annotate | diff | comparison | revisions
minify/lparser.lua file | annotate | diff | comparison | revisions
minify/optlex.lua file | annotate | diff | comparison | revisions
minify/optparser.lua file | annotate | diff | comparison | revisions
squishy file | annotate | diff | comparison | revisions
uglify/llex.lua file | annotate | diff | comparison | revisions
--- 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
+}
--- 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
--- 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}
--- 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}
--- 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"
--- 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
+}

mercurial