summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/trac-deb.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/trac-deb.lua')
-rw-r--r--tex/context/base/mkiv/trac-deb.lua96
1 files changed, 90 insertions, 6 deletions
diff --git a/tex/context/base/mkiv/trac-deb.lua b/tex/context/base/mkiv/trac-deb.lua
index a6174034c..71055eafa 100644
--- a/tex/context/base/mkiv/trac-deb.lua
+++ b/tex/context/base/mkiv/trac-deb.lua
@@ -13,16 +13,100 @@ local status = status
local tonumber, tostring, type = tonumber, tostring, type
local format, concat, match, find, gsub = string.format, table.concat, string.match, string.find, string.gsub
+local lpegmatch = lpeg.match
-- maybe tracers -> tracers.tex (and tracers.lua for current debugger)
------ report_tex = logs.reporter("tex error")
------ report_lua = logs.reporter("lua error")
-local report_nl = logs.newline
-local report_str = logs.writer
+----- report_tex = logs.reporter("tex error")
+----- report_lua = logs.reporter("lua error")
+local report_nl = logs.newline
+local report_str = logs.writer
-tracers = tracers or { }
-local tracers = tracers
+tracers = tracers or { }
+local tracers = tracers
+
+tracers.lists = { }
+local lists = tracers.lists
+
+tracers.strings = { }
+local strings = tracers.strings
+
+local texgetdimen = tex.getdimen
+local texgettoks = tex.gettoks
+local texgetcount = tex.getcount
+local texgethelp = tex.gethelptext or function() end
+local fatalerror = tex.fatalerror
+
+local implement = interfaces.implement
+
+-- this is used in lmx files but needs to be redone
+
+strings.undefined = "undefined"
+
+function tracers.dimen(name)
+ local d = texgetdimen(name)
+ return d and number.topoints(d) or strings.undefined
+end
+
+function tracers.count(name)
+ return texgetcount(name) or strings.undefined
+end
+
+function tracers.toks(name,limit)
+ local t = texgettoks(name)
+ return t and string.limit(t,tonumber(limit) or 40) or strings.undefined
+end
+
+function tracers.primitive(name)
+ return tex[name] or strings.undefined
+end
+
+lists.scratch = {
+ 0, 2, 4, 6, 8
+}
+
+lists.internals = {
+ 'p:hsize', 'p:parindent', 'p:leftskip','p:rightskip',
+ 'p:vsize', 'p:parskip', 'p:baselineskip', 'p:lineskip', 'p:topskip'
+}
+
+lists.context = {
+ 'd:lineheight',
+ 'c:realpageno', 'c:userpageno', 'c:pageno', 'c:subpageno'
+}
+
+local types = {
+ ['d'] = tracers.dimen,
+ ['c'] = tracers.count,
+ ['t'] = tracers.toks,
+ ['p'] = tracers.primitive
+}
+
+local splitboth = lpeg.splitat(":")
+
+function tracers.type(csname)
+ local tag, name = lpegmatch(splitboth,csname)
+ return tag or ""
+end
+
+function tracers.name(csname)
+ local tag, name = lpegmatch(splitboth,csname)
+ return name or csname
+end
+
+function tracers.cs(csname)
+ local tag, name = lpegmatch(splitboth,csname)
+ if name and types[tag] then
+ return types[tag](name)
+ else
+ return tracers.primitive(csname)
+ end
+end
+
+function tracers.knownlist(name)
+ local l = lists[name]
+ return l and #l > 0
+end
local savedluaerror = nil
local usescitelexer = nil