Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file: -- http://anggtwu.net/LUA/ELpeg2.lua.html -- http://anggtwu.net/LUA/ELpeg2.lua -- (find-angg "LUA/ELpeg2.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")) -- (code-etv "~/LATEX/") -- (find-code-etv "~/LATEX/") require "ELpeg1" -- (find-angg "LUA/ELpeg1.lua") gr,V,VA,VE,PE = Gram.new() _ = S(" ")^0 mkast = function (op, ...) return AST.ify {[0]=op, ...} 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[ "T_3" ] = word("T_3") E[ "T_3.5" ] = und(E"T_3", 5) E[ "T_2" ] = word("T_2") E[ "T_2.5" ] = und(E"T_2", 5) E[ "T_2.5 + T_3.5" ] = plus(E"T_2.5", E"T_3.5") E[ "{T_2.5 + T_3.5}.10" ] = und(E"T_2.5 + T_3.5", 10) E[ "T_1" ] = word("T_1") E[ "T_1.4" ] = und(E"T_1", 4) E[ "T_1.4 + {T_2.5 + T_3.5}.10" ] = plus(E"T_1.4", E"{T_2.5 + T_3.5}.10") E["{T_1.4 + {T_2.5 + T_3.5}.10}.14"] = und(E"T_1.4 + {T_2.5 + T_3.5}.10", 14) VA.word = Cs(R("AZ","az","09","__")^1) V.opadd = Cs"+" V.opund = P"." * Cc"und" V.exprbasic = "{"*_*V.expr*_*"}" + V.word V.exprund = assocl(V.exprbasic, V.opund) V.expradd = assocl(V.exprund, V.opadd) V.expr = V.expradd fmts = VTable {} fmts.word = "<1>" fmts.und = "\\underbrace{<1>}_{<2>}" fmts["+"] = "<1> + <2>" --[[ ** (find-code-show2 "~/LATEX/Show2.tex") * (code-show2 "~/LATEX/Show2.tex") * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) -- loadshow2() dofile "ELpeg2.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: