diff options
author | Karl Berry <karl@freefriends.org> | 2019-02-28 15:11:56 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-02-28 15:11:56 +0000 |
commit | cc17ad601696f5cf966c8a0b9d79144cd42828a6 (patch) | |
tree | f6007b9b2f886d942f9b30b4797e8718001f65bd /Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua | |
parent | e298746bb92cdf7e87bc3b5b9bd973b6c429a47f (diff) |
context for tl19
git-svn-id: svn://tug.org/texlive/trunk@50165 c570f23f-e606-0410-a88d-b1316a301751
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, 70 insertions, 45 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 15e5df267ef..43e2d80a32b 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua @@ -18,41 +18,15 @@ local printtable = table.print local concat = table.concat local format = string.format -if setinspector then +if token.commands then - local istoken = token.is_token - local simple = { letter = "letter", other_char = "other" } + local commands = token.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 + tokens.commands = utilities.storage.allocate(table.swapped(commands,commands)) - tokens.istoken = istoken - tokens.astable = astable +else - setinspector("token",function(v) if istoken(v) then printtable(astable(v),tostring(v)) return true end end) + tokens.commands = { } end @@ -69,6 +43,8 @@ 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 @@ -77,25 +53,26 @@ 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 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 +if not is_defined then + + is_defined = function(name) + return get_cmdname(create_token(name)) ~= "undefined_cs" + end -function tokens.defined(name) - return get_cmdname(create_token(name)) ~= "undefined_cs" end --- set_macro = function(k,v,g) --- if g == "global" then --- context.setgvalue(k,v or '') --- else --- context.setvalue(k,v or '') --- end --- end +tokens.new = new_token +tokens.create = create_token +tokens.istoken = is_token +tokens.isdefined = is_defined +tokens.defined = is_defined local bits = { escape = 0x00000001, -- 2^00 @@ -240,6 +217,8 @@ 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, @@ -268,6 +247,7 @@ 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, @@ -297,3 +277,48 @@ 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) |