lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi list,

I know that I can examine the internal representation of (compiled)
lpeg patterns by compiling lpeg with -DLPEG_DEBUG and then running
some methods like :pcode() and :ptree(), as in the code below... but
these methods use printfs, and so they send their output to stdout.

People, do you have any tricks - wrappers, maybe? - to display these
debugging outputs in other ways?

Here is some code that works, but that is clumsy:

--snip--snip--
rm -Rv /tmp/lpeg-1.0.2*
cd     /tmp/
wget https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.2.tar.gz
tar -xvzf   lpeg-1.0.2.tar.gz
cd     /tmp/lpeg-1.0.2/
make LUADIR=/usr/include/lua5.1 COPT="-O2 -DLPEG_DEBUG"

cat > o.lua <<'%%%'
require "lpeg"
AlphaNumeric = lpeg.R("AZ", "az", "09")
AnchorChar = AlphaNumeric + lpeg.S("!#$%()*+,-./:;=?@^_{|}~")
AnchorChar:pcode()
AnchorChar:ptree()
%%%

lua5.1 o.lua | tee o.out
--snip--snip--

  Thanks in advance!
  Eduardo Ochs
    http://anggtwu.net/luaforth.html