Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://anggtwu.net/LUA/ELpeg3.lua.html
--   http://anggtwu.net/LUA/ELpeg3.lua
--          (find-angg "LUA/ELpeg3.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- This is just a test for ELPeg1.lua (the name is bad).
--
-- (defun e1 () (interactive) (find-angg "LUA/ELpeg1.lua"))
-- (defun e2 () (interactive) (find-angg "LUA/ELpeg2.lua"))
-- (defun e3 () (interactive) (find-angg "LUA/ELpeg3.lua"))
--
-- «.Vlast»	(to "Vlast")
-- «.paren»	(to "paren")

require "ELpeg1"  -- (find-angg "LUA/ELpeg1.lua")
gr,V,VA,VE,PE = Gram.new()
_ = S(" ")^0

-- «Vlast»  (to ".Vlast")
-- (find-angg "LUA/ELpeg1.lua" "Gram" "local V =")
setmetatable(V, {
  __call     = function (_,name) return lpeg.V(name) end,
  __index    = function (_,name) return lpeg.V(name) end,
  __newindex = function (_,name,pat) Vlast = pat; gr.entries[name] = pat end,
})

-- «paren»  (to ".paren")
paren = function (o,c,pat) return Cast(o..c, P(o)*_* pat *_*P(c)) end

plus  = function (...) return mkast("+", ...) end
word  = function (s)   return mkast("word", s) end
und   = function (o,s) return mkast("und", o, word(s)) end


-- E[    "g(x)"                        ] = ap("g", "x")
-- E[  "f(g(x))"                       ] = ap("f", E"g(x)")
-- E[".(f(g(x)))"                      ] =
-- E[".(f(g(x))) [f(y):=e^y;;g(x):=4x]"] =



VA.word     = Cs(R("AZ","az","09","__")^1)
V.opadd     = Cs"+"
V.opund     = P"." * Cc"und"
V.exprbasic = paren("{", "}", V.expr) + V.word
V.exprund   = assocl(Vlast,   V.opund)
V.expradd   = assocl(Vlast,   V.opadd)
V.expr      = Vlast

fmts      = VTable {}
totex00   = ToTeX0 {fmts=fmts}
fmts.word = "<1>"
fmts.und  = "\\underbrace{<1>}_{<2>}"
fmts["+"] = "<1> + <2>"

--[[
* (code-etv2 "SHOW2DIR" "~/LUA/" "Show2-outer")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "ELpeg3.lua"
AST.alttags = {add="*"}

-- (find-angg "LUA/ELpeg1.lua" "E-tests")
= grcm("expr", "{T_1.4 + {T_2.5 + T_3.5}.10}.14")
=            E["{T_1.4 + {T_2.5 + T_3.5}.10}.14"]
=            E["{T_1.4 + {T_2.5 + T_3.5}.10}.14"]:totex()
             E["{T_1.4 + {T_2.5 + T_3.5}.10}.14"]:totex():show()
             E["{T_1.4 + {T_2.5 + T_3.5}.10}.14"]:show()
             E["{T_1.4 + {T_2.5 + T_3.5}.10}.14"]:show(2)
* (etv)

--]]


-- Local Variables:
-- coding:  utf-8-unix
-- End: