|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://anggtwu.net/LUA/LpegDebugMode1.lua.html
-- http://anggtwu.net/LUA/LpegDebugMode1.lua
-- (find-angg "LUA/LpegDebugMode1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- If we compile lpeg with the option -DLPEG_DEBUG then two debugging
-- methods, :pcode() and :ptree(), become available... but they are
-- implemented using "printf"s - see:
--
-- (find-es "lpeg" "lpeg-debug-mode")
-- (find-es "lpeg" "replace-printfs-1")
--
-- This file implements a trick to capture their outputs in strings.
--
-- (defun e () (interactive) (find-angg "LUA/LpegDebugMode1.lua"))
header = [=[
Path.prependtocpath "~/usrc/lpeg-1.1.0/?.so"
require "lpeg"
B,C,P,R,S,V = lpeg.B,lpeg.C,lpeg.P,lpeg.R,lpeg.S,lpeg.V
Cb,Cc,Cf,Cg = lpeg.Cb,lpeg.Cc,lpeg.Cf,lpeg.Cg
Cp,Cs,Ct = lpeg.Cp,lpeg.Cs,lpeg.Ct
Carg,Cmt = lpeg.Carg,lpeg.Cmt
;
]=]
run = function (str)
ee_writefile("/tmp/o0", header..str)
return getoutput("lua5.1 /tmp/o0")
end
--[==[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "LpegDebugMode1.lua"
= run [=[
AlphaNumeric = lpeg.R("AZ", "az", "09")
AnchorChar = AlphaNumeric + lpeg.S("!#$%()*+,-./:;=?@^_{|}~")
AnchorChar:pcode()
]=]
= run " P(1):pcode() "
= run " P(2):pcode() "
= run " P(200):pcode() "
= run " C(1):pcode() "
--]==]
-- Local Variables:
-- coding: utf-8-unix
-- End: