Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file: -- http://anggtwu.net/LUA/Lisp5.lua.html -- http://anggtwu.net/LUA/Lisp5.lua -- (find-angg "LUA/Lisp5.lua") -- Author: Eduardo Ochs <eduardoochs@gmail.com> -- -- (defun o () (interactive) (find-angg "LUA/Lisp4.lua")) -- (defun e () (interactive) (find-angg "LUA/Lisp5.lua")) -- (defun oe () (interactive) (find-2a '(o) '(e))) require "ELpeg1" -- (find-angg "LUA/ELpeg1.lua") local B,C,P,R,S,V = lpeg.B,lpeg.C,lpeg.P,lpeg.R,lpeg.S,lpeg.V local Cb,Cc,Cf,Cg = lpeg.Cb,lpeg.Cc,lpeg.Cf,lpeg.Cg local Cp,Cs,Ct = lpeg.Cp,lpeg.Cs,lpeg.Ct local Carg,Cmt = lpeg.Carg,lpeg.Cmt local gr,V,VA,VE,PE = Gram.new() V.top = V.skip * V.Elements V.skip = V.hspace * (V.hcomment^-1 * V.linebreak * V.hspace)^0 V.hspace = (S" \t")^0 V.hcomment = P";" * (1-P"\n")^0 V.linebreak = P"\n" V.Element = V.Quoted + V.Number + V.Symbol + V.String + V.List V.Element = V.Quoted + V.Number + V.Char + V.Symbol + V.String + V.List V.Elements = V.skip * (V.Element * V.skip)^0 VA.List = P'(' * V.Elements * P')' VA.Number = ((R"09")^1):C():Cg"s" VA.Symbol = (V.symbolchar^1):C():Cg"s" V.symbolchar = R"!~" - S [[()'"\]] VA.String = '"' * (V.strchar^0):C():Cg"s" * '"' V.strchar = (P"\\"*P(1)) + (1-P'"') VA.Quoted = P"'" * V.skip * V.Element VA.Char = "#\\" * P(1):C():Cg"s" lisp5_pat = gr:compile("top") lisp5_parse = function (bigstr) return lisp5_pat:match(bigstr) end _G.gr = gr --[==[ * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) dofile "Lisp5.lua" bigstr = [=[ (0 0) #\a ]=] = gr:cm("top", bigstr) a,b = gr:cm0("top", bigstr) a,b = lisp5_parse (bigstr) = a,b PP(a) = b = b[2] = b[2][1] = b[2][1][2] = b[2][1][2][1] --]==] -- Local Variables: -- coding: utf-8-unix -- End: