Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This is a "shadow file" (like in Forth) for dednat5.lua...
-- Note that it contains not only comments but also tests
-- (mostly in eepitch blocks).


-- «.expansion»			(to "expansion")
-- «.heads»			(to "heads")



-- «expansion»  (to ".expansion")
-- (find-dn4 "dednat5.lua" "prefixes-and-ptables")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ee_dofile "~/dednat4/dednat5.lua"

ptable_adds(expansion_table, "->", "\\to ", "|->", "\\mto ", "|-", "\\vdash ")
PP(expansion_table)
PP(expand("foo|->bar |- plic->naw", 1, expansion_table, {}))
PP(expand_all("foo|->bar |- plic->naw", 1, expansion_table, {}))
PP(expand_all("foo|->bar |- plic->|naw|", 1, expansion_table, {}))

head_add("%:", "tree")
head_add("%:*", "abbrev")
PP(head_for("% foo"))
PP(head_for("%: foo"))
PP(head_for("%:*foo*bar*"))




-- «heads»  (to ".heads")
-- (find-dn4 "dednat5.lua" "heads")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ee_dofile "~/dednat4/dednat5.lua"

head_table = {}
head_add("",   {aftereach = PP})
head_add("%L", {
    beforefirst = function () PP("beforefirst") end,
    aftereach = function (str) PP("aftereach:", str) end,
    afterlast = function () PP("afterlast") end,
  })
head_add("%L", {
    beforefirst = function () lua_lines = {} end,
    aftereach = function (str) tinsert(lua_lines, str) end,
    afterlast = function () eval(table.concat(lua_lines, "\n")) end,
  })

flines = {
  "bar",
  "%L PP('hello',",
  "%L    'world')",
  "foo",
}
linen = 1

for _,li in ipairs(flines) do
  PP(head_for(li))
end

process_blocks()





* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ee_dofile "~/dednat4/dednat5.lua"
ptable_adds(expansion_table, "->", "\\to ", "|->", "\\mto ", "|-", "\\vdash ")

-- (find-LATEXfile "2009unilog-dnc.tex" "\\TeX{}")
-- (fooi "«" "<<" "»" ">>")

-- <<\pi>> = function (pair) return pair[1] end
-- <<\pi'>> = function (pair) return pair[2] end
--     local a = <<\pi>>(<<a,b>>)
--     local b = <<\pi'>>(<<a,b>>)

S = [[
pi1 = function (pair) return pair[1] end
pi2 = function (pair) return pair[2] end
<<b|->c>> = function (b) return b+2 end
<<a,b|->a,c>> = function (<<a,b>>)
    local a = pi1(<<a,b>>)
    local b = pi2(<<a,b>>)
    local c = <<b|->c>>(b)
    local <<a,c>> = {a, c}
    return <<a,c>>
  end
]]

S = [[
<<a,b|->a,c>> = function (<<a,b>>)
    local a = pi1(<<a,b>>)
    local b = pi2(<<a,b>>)
    local c = <<b|->c>>(b)
    local <<a,c>> = {a, c}
    return <<a,c>>
  end
]]

width = "2cm"
boxname = "myboxa"

pre = function ()
    print("\\setbox0=\\hbox{%")
    print("\\begin{minipage}[c]{"..width.."}")
  end
post = function ()
    print("\\end{minipage}%")
    print("}")
    print("\\savebox{\\"..boxname.."}{\\copy0}\n")
  end

c = "!"

LATEX = {
  vfun = function (v) return "\\verb"..c..v..c end,
  dfun = function (d) return "$\\angg{"..expand(d).."}$" end,
  pfun = function (L) print("\\par "..table.concat(L)) end,
}
SOURCE = {
  vfun = function (v) return v end,
  dfun = function (d) return "\171"..d.."\187" end,
  pfun = function (L) print("\\par \\verb"..c..table.concat(L)..c) end,
  prep = function () print("\\myttchars") end,
}
dnctable = {n=0}
DNC = {
  vfun = function (v) return v end,
  dfun = function (d)
      if dnctable[d] then return dnctable[d] end
      dnctable[d] = format("dnc%02d", dnctable.n)
      dnctable.n = dnctable.n + 1
      return dnctable[d]
    end,
  pfun = function (L) print("\\par \\verb"..c..table.concat(L)..c) end,
}

dncto = function (ops, S)
    pre()
    if ops.prep then ops.prep() end
    for _,li in ipairs(splitlines(S)) do
      local L = {}
      local replfun = function (v, d)
          if v ~= "" then tinsert(L, ops.vfun(v)) end
          tinsert(L, ops.dfun(d))
          return ""
        end
      local rest = string.gsub(li, "(.-)<<(.-)>>", replfun)
      if rest ~= "" then tinsert(L, ops.vfun(rest)) end
      ops.pfun(L)
    end
    post()
  end

do
width = "5.5cm"; boxname = "myboxsrc"; dncto(SOURCE, S)
width = "5.5cm"; boxname = "myboxltx"; dncto(LATEX, S)
width = "4.4cm"; boxname = "myboxdnc"; dncto(DNC, S)
end




-- S = [[
-- «» = function (pair) return pair[1] end
-- «'» = function (pair) return pair[2] end
-- «b|->c» = function (b) return b+2 end
-- «a,b|->a,c» = function («a,b»)
--     local a = «»(«a,b»)
--     local b = «'»(«a,b»)
--     local c = «b|->c»(b)
--     local «a,c» = {a, c}
--     return «a,c»
--   end
-- ]]



%:
%:            [a,b]^1 	    
%:            -------	    
%:  [a,b]^1      b     b|->c
%:  -------      ---------  
%:     a             c	    
%:     ---------------	    
%:         a,c		    
%:       -------1	    
%:       a,b|->a,c            
%:
%:       ^bar1              
%:

pi1 = function (pair) return pair[1] end
pi2 = function (pair) return pair[2] end
f   = function (b) return b+2 end
Axf = function (ab)
    local a = pi1(ab)
    local b = pi2(ab)
    local c = f(b)
    local ac = {a, c}
    return ac
  end







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