diff options
author | Karl Berry <karl@freefriends.org> | 2018-03-20 22:10:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-03-20 22:10:59 +0000 |
commit | 65d009a0596b194597f47531523addd3e64ed005 (patch) | |
tree | e13bd9beecf63e26491a66aa7a8fa702482f0067 /Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua | |
parent | d1a186333ced7b341e26877907343f08211199f7 (diff) |
context [current] (20mar18)
git-svn-id: svn://tug.org/texlive/trunk@47050 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 | 102 |
1 files changed, 50 insertions, 52 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 0ce7b4836b7..8f95f6692bc 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/toks-ini.lua @@ -9,12 +9,14 @@ tokens = tokens or { } local tokens = tokens local token = token -- the built in one +local next = next local tonumber = tonumber local tostring = tostring local utfchar = utf.char local char = string.char local printtable = table.print local concat = table.concat +local format = string.format if setinspector then @@ -54,40 +56,34 @@ if setinspector then end -local scan_toks = token.scan_toks -local scan_string = token.scan_string -local scan_int = token.scan_int -local scan_code = token.scan_code -local scan_dimen = token.scan_dimen -local scan_glue = token.scan_glue -local scan_keyword = token.scan_keyword -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 get_next = token.get_next - -if not token.get_macro then - local scantoks = tex.scantoks - local gettoks = tex.gettoks - function token.get_meaning(name) - scantoks("t_get_macro",tex.ctxcatcodes,"\\"..name) - return gettoks("t_get_macro") - end - function token.get_macro(name) - scantoks("t_get_macro",tex.ctxcatcodes,"\\"..name) - local s = gettoks("t_get_macro") - return match(s,"^.-%->(.*)$") or s - end +local scan_toks = token.scan_toks +local scan_string = token.scan_string +local scan_int = token.scan_int +local scan_code = token.scan_code +local scan_dimen = token.scan_dimen +local scan_glue = token.scan_glue +local scan_keyword = token.scan_keyword +local scan_keyword_cs = token.scan_keyword_cs or scan_keyword +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 get_next = token.get_next + +local set_macro = token.set_macro +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 create_token = token.create + +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 -local set_macro = token.set_macro -local get_macro = token.get_macro -local get_meaning = token.get_meaning -local get_cmdname = token.get_cmdname -local create_token = token.create - function tokens.defined(name) return get_cmdname(create_token(name)) ~= "undefined_cs" end @@ -101,28 +97,28 @@ end -- end local bits = { - escape = 2^ 0, - begingroup = 2^ 1, - endgroup = 2^ 2, - mathshift = 2^ 3, - alignment = 2^ 4, - endofline = 2^ 5, - parameter = 2^ 6, - superscript = 2^ 7, - subscript = 2^ 8, - ignore = 2^ 9, - space = 2^10, -- 1024 - letter = 2^11, - other = 2^12, - active = 2^13, - comment = 2^14, - invalid = 2^15, + escape = 0x00000001, -- 2^00 + begingroup = 0x00000002, -- 2^01 + endgroup = 0x00000004, -- 2^02 + mathshift = 0x00000008, -- 2^03 + alignment = 0x00000010, -- 2^04 + endofline = 0x00000020, -- 2^05 + parameter = 0x00000040, -- 2^06 + superscript = 0x00000080, -- 2^07 + subscript = 0x00000100, -- 2^08 + ignore = 0x00000200, -- 2^09 + space = 0x00000400, -- 2^10 -- 1024 + letter = 0x00000800, -- 2^11 + other = 0x00001000, -- 2^12 + active = 0x00002000, -- 2^13 + comment = 0x00004000, -- 2^14 + invalid = 0x00008000, -- 2^15 -- - character = 2^11 + 2^12, - whitespace = 2^13 + 2^10, -- / needs more checking + character = 0x00001800, -- 2^11 + 2^12 + whitespace = 0x00002400, -- 2^13 + 2^10 -- / needs more checking -- - open = 2^10 + 2^1, -- space + begingroup - close = 2^10 + 2^2, -- space + endgroup + open = 0x00000402, -- 2^10 + 2^01 -- space + begingroup + close = 0x00000404, -- 2^10 + 2^02 -- space + endgroup } -- for k, v in next, bits do bits[v] = k end @@ -250,6 +246,7 @@ tokens.scanners = { -- these expand number = scan_number, boolean = scan_boolean, keyword = scan_keyword, + keywordcs = scan_keyword_cs, csname = scan_csname, } @@ -268,6 +265,7 @@ tokens.getters = { -- these don't expand tokens.setters = { macro = set_macro, + char = set_char, count = tex.setcount, dimen = tex.setdimen, skip = tex.setglue, |