Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
-- http://angg.twu.net/LATEX/2015logicandcats.lua
-- http://angg.twu.net/LATEX/2015logicandcats.lua.html
--              (find-LATEX "2015logicandcats.lua")
-- See:         (find-LATEX "2015logicandcats.tex")

-- «.load-dednat6»	(to "load-dednat6")
-- «.load-edrxlib»	(to "load-edrxlib")
-- «.output»		(to "output")
-- «.wrap»		(to "wrap")
-- «.processzrect»	(to "processzrect")


-- «load-dednat6» (to ".load-dednat6")
-- dednat6dir = "/home/edrx/dednat5/"
dednat6dir = "dednat6/"
dofile(dednat6dir.."dednat6.lua")   -- (find-dn6 "dednat6.lua")
-- tf = TexFile.read(tex.jobname .. ".tex")
-- output = print

-- «load-edrxlib» (to ".load-edrxlib")
-- (find-es "luatex" "LUA_INIT")
-- (find-angg "LUA/lua50init.lua")
-- dofile(os.getenv("LUA_INIT"):sub(2))
-- dofile((os.getenv("LUA_INIT") or "@"..dednat6dir.."edrxlib.lua"):sub(2))

-- «output» (to ".output")
-- (find-es "luatex" "comments-in-tex.print")
deletecomments = function (str)
    return (str:gsub("%%[^%%\n]*\n[ \t]*", ""))
  end
mytexprint = function (str)
    tex.print(deletecomments(str))
  end
printboth = function (str)
    print("("..tf.nline.."):")
    print(str)
    mytexprint(str)
  end





-- «wrap» (to ".wrap")
-- (find-es "lua5" "mult-as-comp")
-- (find-dn5file "picture.lua" "\\hss")
debug.setmetatable (print, {
    __mul = function (f, g) return
        function (...) return f(g(...)) end
      end,
  })
wrap = function (pre, post)
    return function (str)
        return pre..str..post
      end
  end

-- «processzrect» (to ".processzrect")
processzrect = function (str)
    local words = split(str)
    local cellw = id         -- cell wrap (not used yet)
    local outw  = id         -- output wrap
    local coord = "lr"       -- coordinate system
    local opts  = {}
    local name  = words[1]
    local zrect = zrects[name] or error("No zrect named "..name)
    local pict  = nil        -- will be set later (maybe)
    local bord  = nil        -- draw borders
    local lcuts = nil        -- draw cuts
    local rcuts = nil        -- draw cuts
    -- print(zrect)
    -- print(zrect.topicture)
    local f   = function (a, b, str) return str end
    local fp  = function (a, b, str) return format("$(%d,%d)$",  a, b) end
    local fpc = function (a, b, str) return format("$(%d,%d),$", a, b) end
    for i=2,#words do
      local w = words[i]
      if     w:match"pt$"     then opts.scale = w
      elseif w:match"^lcuts:" then lcuts = w:match"^lcuts:(.*)"
      elseif w:match"^rcuts:" then rcuts = w:match"^rcuts:(.*)"
      -- elseif w == "c" then cellw = wrap()*cellw
      elseif w == "bul"   then f = function () return "$\\bullet$" end
      elseif w == "(x,y)"  then coord = "xy"; f = fp
      elseif w == "(X,y)"  then coord = "Xy"; f = fp
      elseif w == "(l,r)"  then coord = "lr"; f = fp
      elseif w == "(x,y)," then coord = "xy"; f = fpc
      elseif w == "(X,y)," then coord = "Xy"; f = fpc
      elseif w == "(l,r)," then coord = "lr"; f = fpc
      elseif w == "foot"  then opts.font ="\\footnotesize "
      elseif w == "scri"  then opts.font ="\\scriptsize "
      elseif w == "()"    then outw = wrap("\\left(",   "\\right)"  )*outw
      elseif w == "{}"    then outw = wrap("\\left\\{", "\\right\\}")*outw
      elseif w == "bord"  then bord = true
      elseif w == "out"   then
        pict = zrect:topicture(coord, opts, f)
        if bord then zrect:drawborders(pict) end
        if lcuts or rcuts then
          zrect:drawcuts(pict, lcuts or "", rcuts or "")
        end
        output(outw(pict:totex()))
      else error("Unknown word: "..w)
      end
    end
    return p
  end








--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "2015logicandcats.lua"
lines = splitlines(untabify(zrectdefs_bigstr_for_tests))
zrectdefs_get(lines, 1, #lines)
print(zrects.a)
print(zrects.b)
output = print
processzrect "a 12pt out"

--]]


-- Local Variables:
-- coding: raw-text-unix
-- End: