Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file: -- http://anggtwu.net/LUA/CaeproLisp1.lua.html -- http://anggtwu.net/LUA/CaeproLisp1.lua -- (find-angg "LUA/CaeproLisp1.lua") -- Author: Eduardo Ochs <eduardoochs@gmail.com> -- -- (defun e () (interactive) (find-angg "LUA/CaeproLisp1.lua")) -- (defun c1 () (interactive) (find-angg "LUA/Caepro1.lua")) -- (defun cl1 () (interactive) (find-angg "LUA/CaeproLisp1.lua")) -- (defun l3 () (interactive) (find-angg "LUA/Lisp3.lua")) -- «.parsefindpage» (to "parsefindpage") -- «.parsefindpage-tests» (to "parsefindpage-tests") -- «.ElispFile» (to "ElispFile") -- «.ElispFile-tests» (to "ElispFile-tests") -- (find-angg ".emacs" "c3q222") require "Lisp3" -- (find-angg "LUA/Lisp3.lua") -- __ _ _ -- _ __ __ _ _ __ ___ ___ / _(_)_ __ __| |_ __ __ _ __ _ ___ -- | '_ \ / _` | '__/ __|/ _ \ |_| | '_ \ / _` | '_ \ / _` |/ _` |/ _ \ -- | |_) | (_| | | \__ \ __/ _| | | | | (_| | |_) | (_| | (_| | __/ -- | .__/ \__,_|_| |___/\___|_| |_|_| |_|\__,_| .__/ \__,_|\__, |\___| -- |_| |_| |___/ -- -- «parsefindpage» (to ".parsefindpage") -- anchorpat = function (tag) return ";; «" .. tag .. "»[^\n]*" end afteranchorpat = function (tag) local pat1 = anchorpat(tag) local pat2 = anchorpat("[!-~]+") local pat3 = pat1.."\n(.-\n)"..pat2 return pat3 end string.afteranchor = function (str, tag) return str:match(afteranchorpat(tag)) end string.tmatch = function (str, pat) local A = VTable {} for m in str:gmatch(pat) do table.insert(A, m) end return A end findpagepat = ";; (%(find-[!-~]*page [^\n]*)" genfindpagesin = function (str) return str:gmatch(findpagepat) end allfindpagesin = function (str) return str:tmatch(findpagepat) end findpagesin = function (str) return table.concat(allfindpagesin(str), "\n") end parsesexp = function (str) subj = str return sexp:match(subj) end parsefindpage = function (str) local ast = parsesexp(str) return ast[1]:value(), ast[2]:value(), ast[3]:value() end -- «parsefindpage-tests» (to ".parsefindpage-tests") --[[ * (eepitch-lua52) * (eepitch-kill) * (eepitch-lua52) dofile "Caepro1.lua" bigstr = ee_readfile "~/.emacs" qb = bigstr:afteranchor "c2q222" = qb = findpagesin(qb) = allfindpagesin(qb) af = allfindpagesin(qb) = af fp = af[5] = fp = trees(parsesexp(fp)) PP(parsefindpage(fp)) --]] -- _____ _ _ _____ _ _ -- | ____| (_)___ _ __ | ___(_) | ___ -- | _| | | / __| '_ \| |_ | | |/ _ \ -- | |___| | \__ \ |_) | _| | | | __/ -- |_____|_|_|___/ .__/|_| |_|_|\___| -- |_| -- -- «ElispFile» (to ".ElispFile") -- ElispFile = Class { type = "ElispFile", from = function (fname) return ElispFile {bigstr = ee_readfile(fname)} end, __index = { qdash = function (ef, pat) return (pat:gsub("%-", "%%-")) end, match0 = function (ef, pat) return ef.bigstr:match(pat) end, match = function (ef, pat) return ef.bigstr:match(ef:qdash(pat)) end, qblock0 = function (ef, tag) return ef:match0(anchorpat(ef:qdash(tag))) end, qblock = function (ef, tag) return ef:match0(afteranchorpat(ef:qdash(tag))) end, allfindpagesin = function (ef, tag) return allfindpagesin(ef:qblock(tag)) end, findpagesin = function (ef, tag) return findpagesin(ef:qblock(tag)) end, }, } -- «ElispFile-tests» (to ".ElispFile-tests") --[==[ * (eepitch-lua52) * (eepitch-kill) * (eepitch-lua52) dofile "CaeproLisp1.lua" dotemacs = ElispFile.from "~/.emacs" = dotemacs: qblock0("c3q222") = dotemacs: qblock("c3q222") = dotemacs:allfindpagesin("c3q222") = dotemacs: findpagesin("c3q222") = dotemacs:qdash("foo-bar") = dotemacs: qblock0("c2-2022-1-quadros") = dotemacs: qblock("c2-2022-1-quadros") = dotemacs: findpagesin("c2-2022-1-quadros") = dotemacs: findpagesin("c3-2022-1-quadros") = dotemacs: findpagesin("c2q222") = dotemacs: findpagesin("c3q222") -- (find-angg ".emacs" "c3-2022-1-quadros") -- (find-angg ".emacs" "c2-2022-1-quadros") -- (find-angg ".emacs" "c2q222") -- (find-angg ".emacs" "c3q222") --]==] -- Local Variables: -- coding: utf-8-unix -- End: