diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua | 115 |
1 files changed, 45 insertions, 70 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua index 43e2d80a32b..15e5df267ef 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua @@ -18,15 +18,41 @@ local printtable = table.print local concat = table.concat local format = string.format -if token.commands then +if setinspector then - local commands = token.commands() + local istoken = token.is_token + local simple = { letter = "letter", other_char = "other" } - tokens.commands = utilities.storage.allocate(table.swapped(commands,commands)) + local function astable(t) + if t and istoken(t) then + local cmdname = t.cmdname + local simple = simple[cmdname] + if simple then + return { + category = simple, + character = utfchar(t.mode) or nil, + } + else + return { + command = t.command, + id = t.id, + tok = t.tok, + csname = t.csname, + active = t.active, + expandable = t.expandable, + protected = t.protected, + mode = t.mode, + index = t.index, + cmdname = cmdname, + } + end + end + end -else + tokens.istoken = istoken + tokens.astable = astable - tokens.commands = { } + setinspector("token",function(v) if istoken(v) then printtable(astable(v),tostring(v)) return true end end) end @@ -43,8 +69,6 @@ local scan_token = token.scan_token local scan_word = token.scan_word local scan_number = token.scan_number local scan_csname = token.scan_csname -local scan_real = token.scan_real -local scan_float = token.scan_float local get_next = token.get_next @@ -53,26 +77,25 @@ local get_macro = token.get_macro local get_meaning = token.get_meaning local get_cmdname = token.get_cmdname local set_char = token.set_char -local set_lua = token.set_lua - local create_token = token.create -local new_token = token.new -local is_defined = token.is_defined -local is_token = token.is_token - -if not is_defined then - is_defined = function(name) - return get_cmdname(create_token(name)) ~= "undefined_cs" - end +if not set_char then -- for a while + local contextsprint = context.sprint + local ctxcatcodes = catcodes.numbers.ctxcatcodes + set_char = function(n,u) contextsprint(ctxcatcodes,format("\\chardef\\%s=%s",n,u)) end +end +function tokens.defined(name) + return get_cmdname(create_token(name)) ~= "undefined_cs" end -tokens.new = new_token -tokens.create = create_token -tokens.istoken = is_token -tokens.isdefined = is_defined -tokens.defined = is_defined +-- set_macro = function(k,v,g) +-- if g == "global" then +-- context.setgvalue(k,v or '') +-- else +-- context.setvalue(k,v or '') +-- end +-- end local bits = { escape = 0x00000001, -- 2^00 @@ -217,8 +240,6 @@ tokens.scanners = { -- these expand glue = scan_glue, skip = scan_glue, integer = scan_int, - real = scan_real, - float = scan_float, count = scan_int, string = scan_string, argument = scan_argument, @@ -247,7 +268,6 @@ tokens.getters = { -- these don't expand tokens.setters = { macro = set_macro, char = set_char, - lua = set_lua, count = tex.setcount, dimen = tex.setdimen, skip = tex.setglue, @@ -277,48 +297,3 @@ tokens.setters = { -- /* unsave_tex_scanner(texstate); */ -- return 1; -- } - -if setinspector then - - local simple = { letter = "letter", other_char = "other" } - - local function astable(t) - if t and is_token(t) then - local cmdname = t.cmdname - local simple = simple[cmdname] - if simple then - return { - category = simple, - character = utfchar(t.mode) or nil, - } - else - return { - command = t.command, - id = t.id, - tok = t.tok, - csname = t.csname, - active = t.active, - expandable = t.expandable, - protected = t.protected, - mode = t.mode, - index = t.index, - cmdname = cmdname, - } - end - end - end - - tokens.astable = astable - - setinspector("token",function(v) local t = astable(v) if t then printtable(t,tostring(v)) return true end end) - -end - -tokens.cache = table.setmetatableindex(function(t,k) - if not is_defined(k) then - set_macro(k,"","global") - end - local v = create_token(k) - t[k] = v - return v -end) |