diff options
author | Karl Berry <karl@freefriends.org> | 2021-03-06 21:58:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-03-06 21:58:15 +0000 |
commit | 974640d66e61e81cb197ad96fdff7b08343e4c5a (patch) | |
tree | 2e1f75f32f312b7f24ba82b4590ae230bcd6f399 /Master/texmf-dist/tex/context/base/mkxl/syst-mac.lmt | |
parent | b4fa72e61230aca75f7f6fbf988821f71edfb6b2 (diff) |
context
git-svn-id: svn://tug.org/texlive/trunk@58167 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/syst-mac.lmt')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkxl/syst-mac.lmt | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/syst-mac.lmt b/Master/texmf-dist/tex/context/base/mkxl/syst-mac.lmt new file mode 100644 index 00000000000..410a49f8b11 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkxl/syst-mac.lmt @@ -0,0 +1,117 @@ +if not modules then modules = { } end modules ['syst-mac'] = { + version = 1.001, + comment = "companion to syst-aux.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is kind of tricky and might not work for all csnames but as long as we use +-- it in a controlled way, we're okay. The engine implementation might be changed +-- a bit (no need to go through strings, but fetching a cs index and passing that +-- back also takes time). + +-- Another approach is to have the predefined stack operate use private stacks and +-- then the pop doesn't need the cs. But ... we then also need to store stuff in +-- the format so that complicates maters more than I'm willing to do. + +local insert, remove = table.insert, table.remove + +local push_macro = token.push_macro +local pop_macro = token.pop_macro +local scan_csname = token.scan_csname +local create_token = token.create +local gobble_token = token.gobble + +local context = context +local implement = interfaces.implement + +local report = logs.reporter("system","macrostack") + +local stack = table.setmetatableindex("table") + +local function pushmacro(name,global) + local s = push_macro(name,global) + if s then + insert(stack[name],s) + else + report("no macro %a to push",name) + insert(stack[name],false) + end +end + +local function popmacro(name) + local s = remove(stack[name]) + if s then + pop_macro(s) + else + report("no macro %a to pop",name) + end +end + +tokens.pushmacro = pushmacro +tokens.popmacro = popmacro + +implement { + name = "localpushmacro", + public = true, + protected = true, + actions = function() + pushmacro(scan_csname()) + end +} + +implement { + name = "globalpushmacro", + public = true, + protected = true, + actions = function() + pushmacro(scan_csname(),true) + end +} + +implement { + name = "localpopmacro", + public = true, + protected = true, + actions = function() + popmacro(scan_csname()) + end +} + +implement { + name = "globalpopmacro", + public = true, + protected = true, + actions = function() + popmacro(scan_csname()) + end +} + +implement { + name = "showmacrostack", + public = true, + protected = true, + actions = function() + local n = scan_csname() + local s = stack[n] + local m = #s + report("%s : %i stack slots used",n,m) + for i=1,m do + report("% 3i %S",i,s[i]) + end + end +} + +implement { + name = "gobblenested", + public = true, + protected = true, + arguments = "3 strings", + actions = function(start,stop,command) + gobble_token(create_token(start),create_token(stop)) + if command then + context[command]() + end + end +} |