From 1b26357f303f48ae0b233a5fee9c2e5b8c3d8647 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 31 Jul 2011 18:27:40 +0000 Subject: l3packages (5jun11) git-svn-id: svn://tug.org/texlive/trunk@23283 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/l3packages/l3keys2e/l3keys2e.sty | 156 +++ .../tex/latex/l3packages/xfrac/xfrac.sty | 438 +++++++ .../tex/latex/l3packages/xparse/xparse.sty | 1270 ++++++++++++++++++ .../tex/latex/l3packages/xtemplate/xtemplate.sty | 1373 ++++++++++++++++++++ 4 files changed, 3237 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty create mode 100644 Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty create mode 100644 Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty create mode 100644 Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty b/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty new file mode 100644 index 00000000000..3a84d0e1d4f --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty @@ -0,0 +1,156 @@ +%% +%% This is file `l3keys2e.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3keys2e.dtx (with options: `package') +%% +%% EXPERIMENTAL CODE +%% +%% Do not distribute this file without also distributing the +%% source files specified above. +%% +%% Do not distribute a modified version of this file. +%% +%% File: l3keys2e.dtx (C) Copyright 2009,2011 The LaTeX3 Project +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3packages bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/svnroot/experimental/trunk/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +\RequirePackage{xparse} +\GetIdInfo$Id: l3keys2e.dtx 2492 2011-07-02 13:40:38Z joseph $ + {LaTeX2e option processing using LaTeX3 keys} +\ProvidesExplPackage + {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +\@ifpackagelater { l3token } { 2011/07/02 } + { } + { + \PackageError { l3keys2e } { Support~package~l3kernel~too~old. } + { + Please~install~an~up~to~date~version~of~l3kernel~ + using~your~TeX~package~manager~or~from~CTAN.\\ \\ + Loading~l3keys2e~will~abort! + } + \tex_endinput:D + } +\clist_new:N \keys_latexe_options_clist +\bool_new:N \_l_keys_process_class_bool +\cs_new_protected:Npn \keys_latexe_options:n #1 + { + \clist_clear:N \keys_latexe_options_clist + \keys_latexe_options_global:n {#1} + \keys_latexe_options_local: + \keys_if_exist:nnF {#1} { unknown } + { + \keys_define:nn {#1} + { + unknown .code:n = + { + \msg_error:nnxx { keyvalue } { option-unknown } + { \l_keys_key_tl } { \@currname } + } + } + } + \keys_set:nV {#1} \keys_latexe_options_clist + \AtEndOfPackage { \cs_set_eq:NN \@unprocessedoptions \scan_stop: } + } +\cs_new_protected:Npn \keys_latexe_options_global:n #1 + { + \cs_if_eq:NNF \@classoptionslist \scan_stop: + { + \cs_if_eq:NNTF \@currext \@clsextension + { \keys_latexe_options_class:n {#1} } + { + \bool_if:NT \_l_keys_process_class_bool + { \keys_latexe_options_package:n {#1} } + } + } + } +\cs_new_protected:Npn \keys_latexe_options_class:n #1 + { + \keys_if_exist:nnTF {#1} { unknown } + { \clist_put_right:No \keys_latexe_options_clist \@classoptionslist } + { + \clist_map_inline:Nn \@classoptionslist + { + \keys_if_exist:nnTF {#1} { \keys_latexe_remove_equals:n {##1} } + { \clist_put_right:Nn \keys_latexe_options_clist {##1} } + { \clist_put_right:Nn \@unusedoptionlist {##1} } + } + } + } +\cs_new_protected:Npn \keys_latexe_options_package:n #1 + { + \clist_map_inline:Nn \@classoptionslist + { + \keys_if_exist:nnT {#1} { \keys_latexe_remove_equals:n {##1} } + { + \clist_put_right:Nn \keys_latexe_options_clist {##1} + \clist_remove_element:Nn \@unusedoptionlist {##1} + } + } + } +\cs_new_protected_nopar:Npn \keys_latexe_options_local: + { + \cs_if_eq:NNF \@currext \@clsextension + { + \cs_if_exist:cT { opt@ \@currname . \@currext } + { + \exp_args:NNc \clist_put_right:NV \keys_latexe_options_clist + { opt@ \@currname . \@currext } + } + } + } +\cs_new:Npn \keys_latexe_remove_equals:n #1 + { \keys_latexe_remove_equals:w #1 = \q_stop } +\cs_new:Npn \keys_latexe_remove_equals:w #1 = #2 \q_stop {#1} +\cs_new_protected_nopar:Npn \ProcessKeysOptions #1 + { + \bool_set_true:N \_l_keys_process_class_bool + \keys_latexe_options:n {#1} + } +\cs_new_protected_nopar:Npn \ProcessKeysPackageOptions #1 + { + \bool_set_false:N \_l_keys_process_class_bool + \keys_latexe_options:n {#1} + } +\@onlypreamble \ProcessKeysOptions +\@onlypreamble \ProcessKeysPackageOptions +\msg_new:nnnn { keyvalue } { option-unknown } + { Unknown~option~'#1'~for~package~#2. } + { + LaTeX~has~been~asked~to~set~an~option~called~'#1'~ + but~the~#2~package~has~not~created~an~option~with~this~name. + } +%% +%% +%% End of file `l3keys2e.sty'. diff --git a/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty b/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty new file mode 100644 index 00000000000..d53d6d62bcb --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty @@ -0,0 +1,438 @@ +%% +%% This is file `xfrac.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xfrac.dtx (with options: `package') +%% +%% EXPERIMENTAL CODE +%% +%% Do not distribute this file without also distributing the +%% source files specified above. +%% +%% Do not distribute a modified version of this file. +%% +%% File: xfrac.dtx Copyright (C) 2004, 2008-2010 Morten Hoegholm +%% (C) 2011 The LaTeX3 Project +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3packages bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/svnroot/experimental/trunk/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +\RequirePackage{amstext,graphicx,l3keys2e,textcomp,xparse,xtemplate} +\GetIdInfo$Id: xfrac.dtx 2349 2011-05-11 18:44:37Z joseph $ + {L3 Experimental split-level fractions} +\ProvidesExplPackage + {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +\keys_define:nn { xfrac } + { + cm-recommended .choice:, + cm-recommended / + false .code:n = + { \bool_set_true:N \l_xfrac_cm_std_bool }, + cm-recommended / + true .code:n = + { \bool_set_false:N \l_xfrac_cm_std_bool }, + cm-recommended .default:n = { true }, + cm-standard .bool_set:N = \l_xfrac_cm_std_bool + } +\ProcessKeysOptions { xfrac } +\box_new:N \l_xfrac_slash_box +\box_new:N \l_xfrac_tmp_box +\cs_new:Npn \xfrac_tmp:w { } +\dim_new:N \l_xfrac_denominator_bot_sep_dim +\dim_new:N \l_xfrac_numerator_bot_sep_dim +\dim_new:N \l_xfrac_numerator_top_sep_dim +\dim_new:N \l_xfrac_slash_left_sep_dim +\dim_new:N \l_xfrac_slash_right_sep_dim +\muskip_new:N \l_xfrac_slash_left_muskip +\muskip_new:N \l_xfrac_slash_right_muskip +\fp_new:N \l_xfrac_hscale_fp +\fp_new:N \l_xfrac_scale_factor_fp +\fp_new:N \l_xfrac_vscale_fp +\tl_new:N \l_xfrac_denominator_font_tl +\tl_new:N \l_xfrac_numerator_font_tl +\tl_new:N \l_xfrac_phantom_tl +\tl_new:N \l_xfrac_slash_symbol_tl +\tl_new:N \l_xfrac_slash_symbol_font_tl +\cs_new_nopar:Npn \xfrac_fontscale: +\cs_new:Npn \xfrac_math:n #1 { } +\cs_new_nopar:Npn \xfrac_denominator_font_change: { } +\cs_new:Npn \xfrac_denominator_format:n #1 { } +\cs_new_nopar:Npn \xfrac_numerator_font_change: { } +\cs_new:Npn \xfrac_numerator_format:n #1 { } +\cs_new_nopar:Npn \xfrac_relscale: { } +\cs_new_nopar:Npn \xfrac_slash_symbol_font_change: { } +\cs_new:Npn \xfrac_slash_symbol_format:n #1 { } +\cs_new:Npn \xfrac_text_or_math:n #1 { } +\DeclareObjectType { xfrac } { 3 } +\DeclareTemplateInterface { xfrac } { text } { 3 } + { + denominator-bot-sep : length = \c_max_dim , + denominator-font : tokenlist = \f@family , + denominator-format : function 1 = #1 , + h-scale : real = 1 , + math-mode : choice { false , true } + = false , + numerator-font : tokenlist = \f@family , + numerator-format : function 1 = #1 , + numerator-bot-sep : length = \c_max_dim , + numerator-top-sep : length = \c_max_dim , + phantom : tokenlist = 8 , + scale-factor : real = 0.83333 , + scale-relative : choice { false , true } + = true , + scaling : choice { false , true } + = true , + slash-left-kern : length = 0 pt , + slash-left-mkern : muskip = -2 mu , + slash-right-kern : length = 0 pt , + slash-right-mkern : muskip = -1 mu , + slash-symbol : tokenlist = \textfractionsolidus , + slash-symbol-font : tokenlist = \f@family , + slash-symbol-format : function 1 = #1 , + v-scale : real = 1 , + } +\DeclareTemplateCode { xfrac } { text } { 3 } + { + denominator-bot-sep = \l_xfrac_denominator_bot_sep_dim , + denominator-font = \l_xfrac_denominator_font_tl , + denominator-format = \xfrac_denominator_format:n , + h-scale = \l_xfrac_hscale_fp , + math-mode = + { + false = \cs_set_eq:NN \xfrac_math:n \use:n, + true = \cs_set_eq:NN \xfrac_math:n \ensuremath + }, + numerator-font = \l_xfrac_numerator_font_tl , + numerator-format = \xfrac_numerator_format:n , + numerator-bot-sep = \l_xfrac_numerator_bot_sep_dim , + numerator-top-sep = \l_xfrac_numerator_top_sep_dim , + phantom = \l_xfrac_phantom_tl , + scale-factor = \l_xfrac_scale_factor_fp , + scale-relative = + { + false = + \cs_set_nopar:Npn \xfrac_relscale: + { + \dim_eval:w + \box_ht:N \l_xfrac_tmp_box + \box_dp:N \l_xfrac_tmp_box + \dim_eval_end: + }, + true = + \cs_set_nopar:Npn \xfrac_relscale: + { \box_ht:N \l_xfrac_slash_box } + }, + scaling = + { + false = \cs_set_eq:NN \xfrac_fontscale: \prg_do_nothing:, + true = + \cs_set_nopar:Npn \xfrac_fontscale: + { + \fontsize + { \fp_use:N \l_xfrac_scale_factor_fp \xfrac_relscale: } + { \c_zero_dim } + \selectfont + } + }, + slash-left-kern = \l_xfrac_slash_left_sep_dim , + slash-left-mkern = \l_xfrac_slash_left_muskip , + slash-right-kern = \l_xfrac_slash_right_sep_dim , + slash-right-mkern = \l_xfrac_slash_right_muskip , + slash-symbol = \l_xfrac_slash_symbol_tl , + slash-symbol-font = \l_xfrac_slash_symbol_font_tl , + slash-symbol-format = \xfrac_slash_symbol_format:n , + v-scale = \l_xfrac_vscale_fp + } + { + \AssignTemplateKeys + \mode_if_math:TF + { + \cs_set_eq:NN \xfrac_text_or_math:n \text + \cs_set_nopar:Npx \xfrac_denominator_font_change: + { \tex_fam:D \l_xfrac_denominator_font_tl } + \cs_set_nopar:Npx \xfrac_numerator_font_change: + { \tex_fam:D \l_xfrac_numerator_font_tl } + \cs_set_nopar:Npx \xfrac_slash_symbol_font_change: + { \tex_fam:D \l_xfrac_slash_symbol_font_tl } + } + { + \cs_set_eq:NN \xfrac_text_or_math:n \mbox + \cs_set_nopar:Npn \xfrac_denominator_font_change: + { + \fontfamily { \l_xfrac_denominator_font_tl } + \selectfont + } + \cs_set_nopar:Npn \xfrac_numerator_font_change: + { + \fontfamily { \l_xfrac_numerator_font_tl } + \selectfont + } + \cs_set_nopar:Npn \xfrac_slash_symbol_font_change: + { + \fontfamily { \l_xfrac_slash_symbol_font_tl } + \selectfont + } + } + \xfrac_text_or_math:n + { + \m@th + \hbox_set:Nn \l_xfrac_tmp_box + { \xfrac_math:n { \vphantom { ( ) } } } + \hbox_set:Nn \l_xfrac_slash_box + { + \xfrac_math:n + { + \xfrac_slash_symbol_format:n + { + \xfrac_math:n + { + \xfrac_slash_symbol_font_change: + \IfNoValueTF {#2} + { \l_xfrac_slash_symbol_tl } {#2} + } + } + } + } + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { + \box_ht:N \l_xfrac_slash_box + - \box_dp:N \l_xfrac_slash_box + - \height + } + } + \dim_compare:nNnTF + { \l_xfrac_numerator_top_sep_dim } = { \c_max_dim } + { + \dim_compare:nNnF + { \l_xfrac_numerator_bot_sep_dim } = { \c_max_dim } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { \dim_use:N \l_xfrac_numerator_bot_sep_dim } + } + } + } + { + \dim_compare:nNnTF + { \l_xfrac_numerator_bot_sep_dim } = { \c_max_dim } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { + \box_ht:N \l_xfrac_slash_box + - \dim_use:N \l_xfrac_numerator_top_sep_dim + - \height + } + } + } + { + \msg_error:nn { xfrac } + { over-specified-numerator-sep } + } + } + \xfrac_tmp:w + { + \xfrac_fontscale: + \xfrac_numerator_format:n + { + \scalebox + { \fp_use:N \l_xfrac_hscale_fp } + [ \fp_use:N \l_xfrac_vscale_fp ] + { + \xfrac_math:n + { + \xfrac_numerator_font_change: + { + \vphantom { \l_xfrac_phantom_tl } + #1 + } + } + } + } + } + \xfrac_math:n + { % THIS IS JUST WRONG! + \mode_if_math:TF + { \tex_mskip:D \l_xfrac_slash_right_muskip } + { \tex_hskip:D \l_xfrac_slash_right_sep_dim } + } + \box_use:N \l_xfrac_slash_box + \xfrac_math:n + { + \mode_if_math:TF + { \tex_mskip:D \l_xfrac_slash_left_muskip } + { \tex_hskip:D \l_xfrac_slash_left_sep_dim } + } + \dim_compare:nNnTF + { \l_xfrac_denominator_bot_sep_dim } = { \c_max_dim } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { \raisebox { - \box_dp:N \l_xfrac_slash_box } } + } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { \dim_use:N \l_xfrac_denominator_bot_sep_dim } + } + } + \xfrac_tmp:w + { + \xfrac_fontscale: + \xfrac_denominator_format:n + { + \scalebox + { \fp_use:N \l_xfrac_hscale_fp } + [ \fp_use:N \l_xfrac_vscale_fp ] + { + \xfrac_math:n + { + \xfrac_denominator_font_change: + { + \vphantom { \l_xfrac_phantom_tl } + #3 + } + } + } + } + } + } + } +\DeclareRestrictedTemplate { xfrac } { text } { math } + { + numerator-font = \number \fam , + slash-symbol = / , + slash-symbol-font = \number \fam , + denominator-font = \number \fam , + scale-factor = 0.7 , + scale-relative = false , + scaling = true , + numerator-top-sep = 0 pt , + denominator-bot-sep = 0 pt , + math-mode = true , + phantom = ( % ) + } +\DeclareInstance { xfrac } { default } { text } { } +\DeclareInstance { xfrac } { mathdefault } { math } { } +\DeclareCollectionInstance { plainmath } { xfrac } { mathdefault } { math } + { + denominator-bot-sep = 0 pt , + numerator-bot-sep = 0 pt , + numerator-top-sep = \c_max_dim , + scale-factor = 1 , + scale-relative = false , + scaling = true , + slash-right-mkern = 0 mu , + slash-left-mkern = 0 mu + } +\DeclareInstance { xfrac } { cmr } { text } + { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.2 ex , + slash-left-kern = -0.1 em , + slash-right-kern = -0.1 em + } +\DeclareInstance { xfrac } { cmss } { text } + { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.2 ex , + slash-left-kern = -0.1 em , + slash-right-kern = -0.1 em + } +\DeclareInstance { xfrac } { cmtt } { text } + { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.2 ex , + slash-left-kern = -0.1 em , + slash-right-kern = -0.1 em + } +\bool_if:NF \l_xfrac_cm_std_bool + { + \DeclareInstance { xfrac } { cmr } { text } + { slash-symbol-font = ptm } + \DeclareInstance { xfrac } { cmss } { text } + { slash-symbol-font = ptm } + \DeclareInstance { xfrac } { cmtt } { text } + { slash-symbol-font = ppl } + } +\DeclareInstance { xfrac } { lmr } { text } + { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.1 ex , + slash-left-kern = -0.15 em , + slash-right-kern = -0.15 em + } +\DeclareInstance { xfrac } { lmss } { text } + { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0 pt , + slash-left-kern = -0.15 em , + slash-right-kern = -0.15 em + } +\DeclareInstance { xfrac } { lmtt } { text } + { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0 pt , + slash-left-kern = -0.15 em , + slash-right-kern = -0.15 em + } +\NewDocumentCommand \sfrac { o m o m } + { + \mode_if_math:TF + { + \IfInstanceExistTF { xfrac } { mathfam \number \fam } + { \UseInstance { xfrac } { mathfam \number \fam } } + { \UseInstance { xfrac } { mathdefault } } + {#2} {#3} {#4} + } + { + \IfInstanceExistTF { xfrac } {#1} + { \UseInstance { xfrac } {#1} } + { + \IfInstanceExistTF { xfrac } { \f@family } + { \UseInstance { xfrac } { \f@family } } + { \UseInstance { xfrac } { default } } + } + {#2} {#3} {#4} + } + } +\msg_new:nnnn { xfrac } { over-specified-numerator-sep } + { You have specified both numerator-top-sep and numerator-bot-sep} + {I will pretend that you didn't specify either of them} + +%% +%% +%% End of file `xfrac.sty'. diff --git a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty new file mode 100644 index 00000000000..be93d481af1 --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty @@ -0,0 +1,1270 @@ +%% +%% This is file `xparse.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xparse.dtx (with options: `package') +%% +%% EXPERIMENTAL CODE +%% +%% Do not distribute this file without also distributing the +%% source files specified above. +%% +%% Do not distribute a modified version of this file. +%% +%% File: xparse.dtx (C) Copyright 1999 Frank Mittelbach, Chris Rowley, +%% David Carlisle +%% (C) Copyright 2004-2008 Frank Mittelbach, +%% The LaTeX3 Project +%% (C) Copyright 2009-2011 The LaTeX3 Project +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3packages bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/svnroot/experimental/trunk/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +\RequirePackage{expl3} +\GetIdInfo$Id: xparse.dtx 2492 2011-07-02 13:40:38Z joseph $ + {L3 Experimental document command parser} +\ProvidesExplPackage + {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +\RequirePackage{expl3} +\@ifpackagelater { l3token } { 2011/07/02 } + { } + { + \PackageError { xparse } { Support~package~l3kernel~too~old. } + { + Please~install~an~up~to~date~version~of~l3kernel~ + using~your~TeX~package~manager~or~from~CTAN.\\ \\ + Loading~xparse~will~abort! + } + \tex_endinput:D + } +\prop_new:N \c_xparse_shorthands_prop +\prop_put:Nnn \c_xparse_shorthands_prop { o } { d[] } +\prop_put:Nnn \c_xparse_shorthands_prop { O } { D[] } +\prop_put:Nnn \c_xparse_shorthands_prop { s } { t* } + %\end{variable} +\tl_new:N \l_xparse_arg_tl +\tl_new:N \l_xparse_args_tl +\bool_new:N \l_xparse_environment_bool +\bool_new:N \l_xparse_error_bool +\tl_new:N \l_xparse_function_tl +\tl_new:N \l_xparse_last_arg_tl +\bool_new:N \l_xparse_long_bool +\int_new:N \l_xparse_m_args_int +\bool_new:N \l_xparse_m_only_bool +\int_new:N \l_xparse_mandatory_args_int +\bool_new:N \l_xparse_processor_bool +\int_new:N \l_xparse_processor_int +\tl_new:N \l_xparse_signature_tl +\tl_new:N \l_xparse_tmp_tl +\int_new:N \l_xparse_total_args_int +\cs_new_protected_nopar:Npn \xparse_add_grabber_mandatory:N #1 + { + \tl_put_right:Nx \l_xparse_signature_tl + { + \exp_not:c + { xparse_grab_ #1 \bool_if:NT \l_xparse_long_bool { _long } :w } + } + \bool_set_false:N \l_xparse_long_bool + \int_decr:N \l_xparse_mandatory_args_int + } +\cs_new_protected_nopar:Npn \xparse_add_grabber_optional:N #1 + { + \tl_put_right:Nx \l_xparse_signature_tl + { + \exp_not:c + { + xparse_grab_ #1 + \bool_if:NT \l_xparse_long_bool { _long } + \int_compare:nNnF \l_xparse_mandatory_args_int > \c_zero + { _trailing } + :w + } + } + \bool_set_false:N \l_xparse_long_bool + } +\cs_new_protected_nopar:cpn { xparse_add_type_+:w } + { + \xparse_flush_m_args: + \bool_set_true:N \l_xparse_long_bool + \bool_set_false:N \l_xparse_m_only_bool + \int_decr:N \l_xparse_total_args_int + \xparse_prepare_signature:N + } +\cs_new_protected:cpn { xparse_add_type_>:w } #1 + { + \bool_set_true:N \l_xparse_processor_bool + \xparse_flush_m_args: + \int_decr:N \l_xparse_total_args_int + \tl_put_right:Nn \l_xparse_signature_tl { \xparse_process_arg:n {#1} } + \xparse_prepare_signature_aux:N + } +\cs_new_protected:Npn \xparse_add_type_d:w #1#2 + { \xparse_add_type_D:w #1 #2 { \NoValue } } +\cs_new_protected:Npn \xparse_add_type_D:w #1#2#3 + { + \xparse_flush_m_args: + \xparse_add_grabber_optional:N D + \tl_put_right:Nn \l_xparse_signature_tl { #1 #2 {#3} } + \xparse_prepare_signature:N + } +\cs_new_protected_nopar:Npn \xparse_add_type_g:w + { \xparse_add_type_G:w { \NoValue } } +\cs_new_protected:Npn \xparse_add_type_G:w #1 + { + \xparse_flush_m_args: + \xparse_add_grabber_optional:N G + \tl_put_right:Nn \l_xparse_signature_tl { {#1} } + \xparse_prepare_signature:N + } +\cs_new_protected_nopar:Npn \xparse_add_type_l:w + { + \xparse_flush_m_args: + \xparse_add_grabber_mandatory:N l + \xparse_prepare_signature:N + } +\cs_new_protected_nopar:Npn \xparse_add_type_m:w + { + \bool_if:nTF { \l_xparse_long_bool || \l_xparse_processor_bool } + { + \xparse_flush_m_args: + \xparse_add_grabber_mandatory:N m + } + { \int_incr:N \l_xparse_m_args_int } + \xparse_prepare_signature:N + } +\cs_new_protected:Npn \xparse_add_type_t:w #1 + { + \xparse_flush_m_args: + \xparse_add_grabber_optional:N t + \tl_put_right:Nn \l_xparse_signature_tl { #1 } + \xparse_prepare_signature:N + } +\cs_new_protected:Npn \xparse_add_type_u:w #1 + { + \xparse_flush_m_args: + \xparse_add_grabber_mandatory:N u + \tl_put_right:Nn \l_xparse_signature_tl { {#1} } + \xparse_prepare_signature:N + } +\cs_new_protected_nopar:Npn \xparse_check_and_add:N #1 + { + \cs_if_free:cTF { xparse_add_type_ #1 :w } + { + \msg_error:nnx { xparse } { unknown-argument-type } + { \tl_to_str:n {#1} } + \xparse_add_type_m:w + } + { \use:c { xparse_add_type_ #1 :w } } + } +\cs_new_protected:Npn \xparse_count_mandatory:n #1 + { + \int_zero:N \l_xparse_mandatory_args_int + \xparse_count_mandatory:N #1 \q_nil + } +\cs_new_protected:Npn \xparse_count_mandatory:N #1 + { + \quark_if_nil:NF #1 + { + \prop_if_in:NnTF \c_xparse_shorthands_prop {#1} + { + \prop_get:NnN \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl + \exp_last_unbraced:NV \xparse_count_mandatory:N \l_xparse_tmp_tl + } + { \xparse_count_mandatory_aux:N #1 } + } + } +\cs_new_protected:Npn \xparse_count_mandatory_aux:N #1 + { + \cs_if_free:cTF { xparse_count_type_ #1 :w } + { \xparse_count_type_m:w } + { \use:c { xparse_count_type_ #1 :w } } + } +\cs_new_protected:cpn { xparse_count_type_>:w } #1 + { \xparse_count_mandatory:N } +\cs_new_protected_nopar:cpn { xparse_count_type_+:w } + { \xparse_count_mandatory:N } +\cs_new_protected:Npn \xparse_count_type_d:w #1#2 + { \xparse_count_mandatory:N } +\cs_new_protected:Npn \xparse_count_type_D:w #1#2#3 + { \xparse_count_mandatory:N } +\cs_new_protected_nopar:Npn \xparse_count_type_g:w + { \xparse_count_mandatory:N } +\cs_new_protected:Npn \xparse_count_type_G:w #1 + { \xparse_count_mandatory:N } +\cs_new_protected_nopar:Npn \xparse_count_type_l:w + { + \int_incr:N \l_xparse_mandatory_args_int + \xparse_count_mandatory:N + } +\cs_new_protected_nopar:Npn \xparse_count_type_m:w + { + \int_incr:N \l_xparse_mandatory_args_int + \xparse_count_mandatory:N + } +\cs_new_protected:Npn \xparse_count_type_t:w #1 + { \xparse_count_mandatory:N } +\cs_new_protected:Npn \xparse_count_type_u:w #1 + { + \int_incr:N \l_xparse_mandatory_args_int + \xparse_count_mandatory:N + } +\cs_new_protected:Npn \xparse_declare_cmd:Nnn #1#2 + { + \cs_if_exist:NTF #1 + { + \msg_warning:nnxx { xparse } { redefine-command } + { \token_to_str:N #1 } { \tl_to_str:n {#2} } + } + { + \msg_info:nnxx { xparse } { define-command } + { \token_to_str:N #1 } { \tl_to_str:n {#2} } + } + \xparse_declare_cmd_aux:Nnn #1 {#2} + } +\cs_new_protected:Npn \xparse_declare_cmd_aux:Nnn #1#2#3 + { + \tl_clear_new:c { l_xparse_ \token_to_str:N #1 _arg_spec_tl } + \tl_set:cn { l_xparse_ \token_to_str:N #1 _arg_spec_tl } {#2} + \xparse_count_mandatory:n {#2} + \xparse_prepare_signature:n {#2} + \bool_if:NTF \l_xparse_m_only_bool + { \xparse_declare_cmd_all_m:Nn #1 {#3} } + { \xparse_declare_cmd_mixed:Nn #1 {#3} } + } +\cs_generate_variant:Nn \xparse_declare_cmd_aux:Nnn { cnn } +\cs_new_protected:Npn \xparse_declare_cmd_all_m:Nn #1#2 + { + \cs_generate_from_arg_count:NNnn + #1 \cs_set_protected_nopar:Npn \l_xparse_total_args_int {#2} + } +\cs_new_protected:Npn \xparse_declare_cmd_mixed:Nn #1#2 + { + \group_begin: + \tex_escapechar:D 92 \scan_stop: + \tl_set:Nx \l_xparse_function_tl { \token_to_str:N #1 } + \exp_args:NNNo \group_end: + \tl_set:Nn \l_xparse_function_tl { \l_xparse_function_tl } + \cs_set_protected_nopar:Npx #1 + { + \exp_not:n + { + \int_zero:N \l_xparse_processor_int + \tl_set:Nn \l_xparse_args_tl + } + { \exp_not:c { \l_xparse_function_tl } } + \exp_not:o \l_xparse_signature_tl + \exp_not:N \l_xparse_args_tl + } + \cs_generate_from_arg_count:cNnn + { \token_to_str:N #1 } \cs_set:Npn \l_xparse_total_args_int {#2} + } +\cs_new_protected:Npn \xparse_declare_cmd_implementation:nNn #1#2#3 + { + \cs_generate_from_arg_count:cNnn { implementation_ #1 :w } + \cs_set:Npn {#2} {#3} + } +\cs_new_protected:Npn \xparse_declare_cmd_interface:Nnn #1#2#3 + { + \xparse_prepare_signature:n {#3} + \bool_if:NTF \l_xparse_m_only_bool + { \xparse_declare_cmd_interface_all_m:Nn #1 {#2} } + { \xparse_declare_cmd_interface_mixed:Nn #1 {#2} } + \cs_generate_from_arg_count:cNnn { implementation_ #2 :w } + \cs_set:Npn \l_xparse_total_args_int { '#2' } + } +\cs_new_protected:Npn \xparse_declare_cmd_interface_all_m:Nn #1#2 + { + \cs_generate_from_arg_count:NNnn + #1 \cs_set_protected_nopar:Npn \l_xparse_total_args_int + { \use:c { implementation_ #2 :w } } + } +\cs_new_protected:Npn \xparse_declare_cmd_interface_mixed:Nn #1#2 + { + \cs_set_protected_nopar:Npx #1 + { + \exp_not:n + { + \int_zero:N \l_xparse_processor_int + \tl_set:Nn \l_xparse_args_tl + } + { \exp_not:c { \token_to_str:N #1 } } + \exp_not:o \l_xparse_signature_tl + \exp_not:N \l_xparse_args_tl + } + \cs_generate_from_arg_count:cNnn + { \token_to_str:N #1 } \cs_set:Npn \l_xparse_total_args_int + { \use:c { implementation_ #2 :w } } + } +\cs_new_protected:Npn \xparse_declare_env:nnnn #1#2#3#4 + { + \bool_set_true:N \l_xparse_environment_bool + \cs_if_exist:cTF {#1} + { + \msg_warning:nnxx { xparse } { redefine-environment } + { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } + } + { + \msg_info:nnxx { xparse } { define-environment } + { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } + } + \xparse_declare_cmd_aux:cnn { environment_begin_ #1 :w } {#2} + { + \group_begin: + \cs_set_protected_nopar:cpx { environment_end_ #1 :w } + { + \exp_not:c { environment_end_ #1 _aux:N } + \exp_not:o \l_xparse_args_tl + \group_end: + } + #3 + } + \cs_set_protected_nopar:cpx { environment_end_ #1 : } + { \exp_not:c { environment_end_ #1 :w } } + \bool_set_false:N \l_xparse_environment_bool + \cs_set_nopar:cpx { environment_end_ #1 _aux:N } ##1 + { \exp_not:c { environment_end_ #1 _aux :w } } + \cs_generate_from_arg_count:cNnn + { environment_end_ #1 _aux :w } \cs_set:Npn + \l_xparse_total_args_int {#4} + \cs_set_eq:cc {#1} { environment_begin_ #1 :w } + \cs_set_eq:cc { end #1 } { environment_end_ #1 : } + } +\cs_new_protected_nopar:Npn \xparse_flush_m_args: + { + \cs_if_exist:cT { xparse_grab_m_ \int_use:N \l_xparse_m_args_int :w } + { + \tl_put_right:Nx \l_xparse_signature_tl + { \exp_not:c { xparse_grab_m_ \int_use:N \l_xparse_m_args_int :w } } + \int_set:Nn \l_xparse_mandatory_args_int + { \l_xparse_mandatory_args_int - \l_xparse_m_args_int } + } + \int_zero:N \l_xparse_m_args_int + \bool_set_false:N \l_xparse_m_only_bool + } +\prg_new_conditional:Npnn \xparse_if_no_value:n #1 { T , F , TF } + { \str_if_eq:nnTF {#1} { \NoValue } \prg_return_true: \prg_return_false: } +\cs_new_protected:Npn \xparse_prepare_signature:n #1 + { + \bool_set_false:N \l_xparse_long_bool + \int_zero:N \l_xparse_m_args_int + \bool_if:NTF \l_xparse_environment_bool + { \bool_set_false:N \l_xparse_m_only_bool } + { \bool_set_true:N \l_xparse_m_only_bool } + \bool_set_false:N \l_xparse_processor_bool + \tl_clear:N \l_xparse_signature_tl + \int_zero:N \l_xparse_total_args_int + \xparse_prepare_signature:N #1 \q_nil + } +\cs_new_protected:Npn \xparse_prepare_signature:N #1 + { + \bool_set_false:N \l_xparse_processor_bool + \xparse_prepare_signature_aux:N #1 + } +\cs_new_protected:Npn \xparse_prepare_signature_aux:N #1 + { + \quark_if_nil:NTF #1 + { \bool_if:NF \l_xparse_m_only_bool { \xparse_flush_m_args: } } + { + \prop_if_in:NnTF \c_xparse_shorthands_prop {#1} + { + \prop_get:NnN \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl + \exp_after:wN \xparse_prepare_signature:N \l_xparse_tmp_tl + } + { + \int_incr:N \l_xparse_total_args_int + \xparse_check_and_add:N #1 + } + } + } +\cs_new_protected:Npn \xparse_process_arg:n #1 + { + \int_incr:N \l_xparse_processor_int + \cs_set:cpn { xparse_processor_ \int_use:N \l_xparse_processor_int :n } ##1 + { #1 {##1} } + } +\cs_new_protected:Npn \xparse_add_arg:n #1 + { + \int_compare:nNnTF \l_xparse_processor_int = \c_zero + { \tl_put_right:Nn \l_xparse_args_tl { {#1} } } + { + \xparse_if_no_value:nTF {#1} + { + \int_zero:N \l_xparse_processor_int + \tl_put_right:Nn \l_xparse_args_tl { {#1} } + } + { \xparse_add_arg_aux:n {#1} } + } + } +\cs_generate_variant:Nn \xparse_add_arg:n { V } +\cs_new_protected:Npn \xparse_add_arg_aux:n #1 + { + \tl_set_eq:NN \ProcessedArgument \l_xparse_arg_tl + \use:c { xparse_processor_ \int_use:N \l_xparse_processor_int :n } {#1} + \int_decr:N \l_xparse_processor_int + \int_compare:nNnTF \l_xparse_processor_int = \c_zero + { + \tl_put_right:Nx \l_xparse_args_tl + { { \exp_not:V \ProcessedArgument } } + } + { \xparse_add_arg_aux:V \ProcessedArgument } +} +\cs_generate_variant:Nn \xparse_add_arg_aux:n { V } +\cs_new_protected:Npn \xparse_grab_arg:w { } +\cs_new_protected:Npn \xparse_grab_arg_aux_i:w { } +\cs_new_protected:Npn \xparse_grab_arg_aux_ii:w { } +\cs_new_protected:Npn \xparse_grab_D:w #1#2#3#4 \l_xparse_args_tl + { + \xparse_grab_D_aux:NNnnNn #1 #2 {#3} {#4} \cs_set_protected_nopar:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \xparse_grab_D_long:w #1#2#3#4 \l_xparse_args_tl + { + \xparse_grab_D_aux:NNnnNn #1 #2 {#3} {#4} \cs_set_protected:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \xparse_grab_D_trailing:w #1#2#3#4 \l_xparse_args_tl + { \xparse_grab_D_aux:NNnnNn #1 #2 {#3} {#4} \cs_set_protected_nopar:Npn { } } +\cs_new_protected:Npn \xparse_grab_D_long_trailing:w #1#2#3#4 \l_xparse_args_tl + { \xparse_grab_D_aux:NNnnNn #1 #2 {#3} {#4} \cs_set_protected:Npn { } } +\cs_new_protected:Npn \xparse_grab_D_aux:NNnnNn #1#2#3#4#5#6 + { + #5 \xparse_grab_arg:w #1 + { + \peek_meaning:NTF \c_group_begin_token + { \xparse_grab_arg_aux_i:w } + { \xparse_grab_arg_aux_ii:w } + } + #5 \xparse_grab_arg_aux_i:w ##1 + { + \peek_charcode:NTF #2 + { \xparse_grab_arg_aux_ii:w { {##1} } } + { \xparse_grab_arg_aux_ii:w {##1} } + } + #5 \xparse_grab_arg_aux_ii:w ##1 #2 + { + \tl_if_in:nnTF {##1} {#1} + { \xparse_grab_D_nested:NNnnN #1 #2 {##1} {#4} #5 } + { + \xparse_add_arg:n {##1} + #4 \l_xparse_args_tl + } + } + \use:c { peek_charcode #6 :NTF } #1 + { \xparse_grab_arg:w } + { + \xparse_add_arg:n {#3} + #4 \l_xparse_args_tl + } + } +\tl_new:N \l_xparse_nesting_a_tl +\tl_new:N \l_xparse_nesting_b_tl +\quark_new:N \q_xparse +\cs_new_protected:Npn \xparse_grab_D_nested:NNnnN #1#2#3#4#5 + { + \tl_clear:N \l_xparse_nesting_a_tl + \tl_clear:N \l_xparse_nesting_b_tl + #5 \xparse_grab_arg:w ##1 #1 ##2 \q_xparse ##3 #2 + { + \tl_put_right:Nn \l_xparse_nesting_a_tl { ##1 #1 } + \tl_put_right:Nn \l_xparse_nesting_b_tl { #2 ##3 } + \tl_if_in:nnTF {##2} {#1} + { \xparse_grab_arg:w ##2 \q_xparse } + { + \tl_put_right:Nn \l_xparse_nesting_a_tl {##2} + \tl_if_in:NnTF \l_xparse_nesting_b_tl {#1} + { + \tl_set_eq:NN \l_xparse_tmp_tl \l_xparse_nesting_b_tl + \tl_clear:N \l_xparse_nesting_b_tl + \exp_after:wN \xparse_grab_arg:w \l_xparse_tmp_tl \q_xparse + } + { + \tl_put_right:No \l_xparse_nesting_a_tl + \l_xparse_nesting_b_tl + \xparse_add_arg:V \l_xparse_nesting_a_tl + #4 \l_xparse_args_tl + } + } + } + \xparse_grab_arg:w #3 \q_xparse + } +\cs_new_protected:Npn \xparse_grab_G:w #1#2 \l_xparse_args_tl + { + \xparse_grab_G_aux:nnNn {#1} {#2} \cs_set_protected_nopar:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \xparse_grab_G_long:w #1#2 \l_xparse_args_tl + { + \xparse_grab_G_aux:nnNn {#1} {#2} \cs_set_protected:Npn { _ignore_spaces } + } +\cs_new_protected:Npn \xparse_grab_G_trailing:w #1#2 \l_xparse_args_tl + { \xparse_grab_G_aux:nnNn {#1} {#2} \cs_set_protected_nopar:Npn { } } +\cs_new_protected:Npn \xparse_grab_G_long_trailing:w #1#2 \l_xparse_args_tl + { \xparse_grab_G_aux:nnNn {#1} {#2} \cs_set_protected:Npn { } } +\cs_new_protected:Npn \xparse_grab_G_aux:nnNn #1#2#3#4 + { + #3 \xparse_grab_arg:w ##1 + { + \xparse_add_arg:n {##1} + #2 \l_xparse_args_tl + } + \use:c { peek_meaning #4 :NTF } \c_group_begin_token + { \xparse_grab_arg:w } + { + \xparse_add_arg:n {#1} + #2 \l_xparse_args_tl + } + } +\cs_new_protected:Npn \xparse_grab_l:w #1 \l_xparse_args_tl + { \xparse_grab_l_aux:nN {#1} \cs_set_protected_nopar:Npn } +\cs_new_protected:Npn \xparse_grab_l_long:w #1 \l_xparse_args_tl + { \xparse_grab_l_aux:nN {#1} \cs_set_protected:Npn } +\cs_new_protected:Npn \xparse_grab_l_aux:nN #1#2 + { + #2 \xparse_grab_arg:w ##1## + { + \xparse_add_arg:n {##1} + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:Npn \xparse_grab_m:w #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1 + { + \xparse_add_arg:n {##1} + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:Npn \xparse_grab_m_long:w #1 \l_xparse_args_tl + { + \cs_set_protected:Npn \xparse_grab_arg:w ##1 + { + \xparse_add_arg:n {##1} + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_1:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1 + { + \tl_put_right:Nn \l_xparse_args_tl { {##1} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_2:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2 + { + \tl_put_right:Nn \l_xparse_args_tl { {##1} {##2} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_3:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2##3 + { + \tl_put_right:Nn \l_xparse_args_tl { {##1} {##2} {##3} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_4:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2##3##4 + { + \tl_put_right:Nn \l_xparse_args_tl { {##1} {##2} {##3} {##4} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_5:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2##3##4##5 + { + \tl_put_right:Nn \l_xparse_args_tl { {##1} {##2} {##3} {##4} {##5} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_6:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2##3##4##5##6 + { + \tl_put_right:Nn \l_xparse_args_tl + { {##1} {##2} {##3} {##4} {##5} {##6} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_7:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2##3##4##5##6##7 + { + \tl_put_right:Nn \l_xparse_args_tl + { {##1} {##2} {##3} {##4} {##5} {##6} {##7} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:cpn { xparse_grab_m_8:w } #1 \l_xparse_args_tl + { + \cs_set_protected_nopar:Npn \xparse_grab_arg:w ##1##2##3##4##5##6##7##8 + { + \tl_put_right:Nn \l_xparse_args_tl + { {##1} {##2} {##3} {##4} {##5} {##6} {##7} {##8} } + #1 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:Npn \xparse_grab_t:w #1#2 \l_xparse_args_tl + { + \xparse_grab_t_aux:NnNn #1 {#2} \cs_set_protected_nopar:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \xparse_grab_t_long:w #1#2 \l_xparse_args_tl + { \xparse_grab_t_aux:NnNn #1 {#2} \cs_set_protected:Npn { _ignore_spaces } } +\cs_new_protected:Npn \xparse_grab_t_trailing:w #1#2 \l_xparse_args_tl + { \xparse_grab_t_aux:NnNn #1 {#2} \cs_set_protected_nopar:Npn { } } +\cs_new_protected:Npn \xparse_grab_t_long_trailing:w #1#2 \l_xparse_args_tl + { \xparse_grab_t_aux:NnNn #1 {#2} \cs_set_protected:Npn { } } +\cs_new_protected:Npn \xparse_grab_t_aux:NnNn #1#2#3#4 + { + #3 \xparse_grab_arg:w + { + \use:c { peek_charcode_remove #4 :NTF } #1 + { + \xparse_add_arg:n { \BooleanTrue } + #2 \l_xparse_args_tl + } + { + \xparse_add_arg:n { \BooleanFalse } + #2 \l_xparse_args_tl + } + } + \xparse_grab_arg:w + } +\cs_new_protected:Npn \xparse_grab_u:w #1#2 \l_xparse_args_tl + { \xparse_grab_u_aux:NnN {#1} {#2} \cs_set_protected_nopar:Npn } +\cs_new_protected:Npn \xparse_grab_u_long:w #1#2 \l_xparse_args_tl + { \xparse_grab_u_aux:NnN {#1} {#2} \cs_set_protected:Npn } +\cs_new_protected:Npn \xparse_grab_u_aux:NnN #1#2#3 + { + #3 \xparse_grab_arg:w ##1 #1 + { + \xparse_add_arg:n {##1} + #2 \l_xparse_args_tl + } + \xparse_grab_arg:w + } +\cs_new_protected:Npn \xparse_process_to_str:n #1 + { \tl_set:Nx \ProcessedArgument { \tl_to_str:n {#1} } } +\cs_new_protected:Npn \xparse_bool_reverse:N #1 + { + \bool_if:NTF #1 + { \tl_set:Nn \ProcessedArgument { \c_false_bool } } + { \tl_set:Nn \ProcessedArgument { \c_true_bool } } + } +\tl_new:N \l_xparse_split_argument_tl +\group_begin: + \char_set_catcode_active:N \@ + \cs_new_protected:Npn \xparse_split_argument:nnn #1#2#3 + { + \tl_set:Nn \l_xparse_split_argument_tl {#3} + \group_begin: + \char_set_lccode:nn { `\@ } { `#2} + \tl_to_lowercase:n + { + \group_end: + \tl_replace_all_in:Nnn \l_xparse_split_argument_tl { @ } {#2} + } + \cs_set_protected:Npn \xparse_split_argument_aux_i:w + ##1 \q_mark ##2 #2 ##3 \q_stop + { + \tl_put_right:Nn \ProcessedArgument { {##2} } + ##1 \q_mark ##3 \q_stop + } + \cs_set_protected:Npn \xparse_split_argument_aux_iii:w + ##1 #2 ##2 \q_stop + { + \IfNoValueF {##1} + { + \msg_error:nnxxx { xparse } { split-excess-tokens } + { \tl_to_str:n {#2} } { \tl_to_str:n {#1} } + { \tl_to_str:n {#3} } + } + } + \tl_set:Nx \l_xparse_tmp_tl + { + \prg_replicate:nn { #1 + 1 } + { \xparse_split_argument_aux_i:w } + \xparse_split_argument_aux_ii:w + \exp_not:N \q_mark + \exp_not:o \l_xparse_split_argument_tl + \prg_replicate:nn {#1} { \exp_not:n {#2} \NoValue } + \exp_not:n { #2 \q_stop } + } + \l_xparse_tmp_tl + } +\group_end: +\cs_new_protected:Npn \xparse_split_argument_aux_i:w { } +\cs_new_protected:Npn \xparse_split_argument_aux_ii:w + #1 \q_mark #2 \q_stop + { + \tl_if_empty:nF {#2} + { \xparse_split_argument_aux_iii:w #2 \q_stop } + } +\cs_new_protected:Npn \xparse_split_argument_aux_iii:w { } +\tl_new:N \l_xparse_split_list_tl +\group_begin: + \char_set_catcode_active:N \@ + \cs_new_protected:Npn \xparse_split_list:nn #1#2 + { + \tl_set:Nn \l_xparse_split_list_tl {#2} + \group_begin: + \char_set_lccode:nn { `\@ } { `#1 } + \tl_to_lowercase:n + { + \group_end: + \tl_replace_all_in:Nnn \l_xparse_split_list_tl { @ } {#1} + } + \cs_set:Npn \xparse_split_list_aux:w ##1 #1 + { + \quark_if_recursion_tail_stop:n {##1} + \tl_put_right:Nn \ProcessedArgument { {##1} } + \xparse_split_list_aux:w + } + \tl_if_empty:NTF \l_xparse_split_list_tl + { \tl_set:Nn \ProcessedArgument { { } } } + { + \tl_clear:N \ProcessedArgument + \exp_after:wN \xparse_split_list_aux:w + \l_xparse_split_list_tl #1 + \q_recursion_tail #1 \q_recursion_stop + } + } +\group_end: +\cs_new_protected:Npn \xparse_split_list_aux:w { } +\cs_new_protected:Npn \xparse_exp_add_type_d:w #1#2 + { \xparse_exp_add_type_D:w #1 #2 { \NoValue } } +\cs_new_protected:Npn \xparse_exp_add_type_D:w #1#2#3 + { + \tl_set:Nx \l_xparse_tmp_tl + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_use:N \l_xparse_total_args_int + } + \xparse_exp_set:cpx { \l_xparse_tmp_tl } ##1 \q_xparse ##2 + { + \exp_not:N \tl_if_head_eq_charcode:nNTF {##2} #1 + { + \exp_not:c { \l_xparse_tmp_tl aux } + ##1 \exp_not:N \q_xparse + } + { + \exp_not:c { \l_xparse_tmp_tl aux } + ##1 \exp_not:N \q_xparse #3 #2 {##2} + } + } + \xparse_exp_set:cpx { \l_xparse_tmp_tl aux} ##1 \q_xparse ##2 #2 + { + \exp_not:c + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_eval:n { \l_xparse_total_args_int + 1 } + } + ##1 {##2} \exp_not:N \q_xparse + } + \xparse_exp_prepare_function:N + } +\cs_new_protected_nopar:Npn \xparse_exp_add_type_l:w + { + \xparse_exp_set:cpx + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_use:N \l_xparse_total_args_int + } + ##1 \q_xparse ##2## + { + \exp_not:c + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_eval:n { \l_xparse_total_args_int + 1 } + } + ##1 {##2} \exp_not:N \q_xparse + } + \xparse_exp_prepare_function:N + } +\cs_new_protected_nopar:Npn \xparse_exp_add_type_m:w + { + \int_incr:N \l_xparse_m_args_int + \xparse_exp_set:cpx + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_use:N \l_xparse_total_args_int + } + ##1 \q_xparse ##2 + { + \exp_not:c + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_eval:n { \l_xparse_total_args_int + 1 } + } + ##1 {##2} \exp_not:N \q_xparse + } + \xparse_exp_prepare_function:N + } +\cs_new_protected:Npn \xparse_exp_add_type_t:w #1 + { + \tl_set:Nx \l_xparse_tmp_tl + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_eval:n { \l_xparse_total_args_int + 1 } + } + \xparse_exp_set:cpx + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_use:N \l_xparse_total_args_int + } + ##1 \q_xparse ##2 + { + \exp_not:N \tl_if_head_eq_charcode:nNTF {##2} #1 + { + \exp_not:c { \l_xparse_tmp_tl } + ##1 \exp_not:n { { \BooleanTrue } \q_xparse } + } + { + \exp_not:c { \l_xparse_tmp_tl } + ##1 \exp_not:n { { \BooleanFalse } \q_xparse {##2} } + } + } + \xparse_exp_prepare_function:N + } +\cs_new_protected:Npn \xparse_exp_add_type_u:w #1 + { + \xparse_exp_set:cpx + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_use:N \l_xparse_total_args_int + } + ##1 \q_xparse ##2 #1 + { + \exp_not:c + { + \exp_after:wN \token_to_str:N \l_xparse_function_tl + \int_eval:n { \l_xparse_total_args_int + 1 } + } + ##1 {##2} \exp_not:N \q_xparse + } + \xparse_exp_prepare_function:N + } +\cs_new_protected_nopar:Npn \xparse_exp_check_and_add:N #1 + { + \cs_if_free:cTF { xparse_exp_add_type_ #1 :w } + { + \msg_error:nnx { xparse } { unknown-argument-type } + { \tl_to_str:n {#1} } + \tl_set:Nn \l_xparse_last_arg_tl { m } + \xparse_exp_add_type_m:w + } + { + \tl_set:Nn \l_xparse_last_arg_tl {#1} + \use:c { xparse_exp_add_type_ #1 :w } + } + } +\cs_new_protected:Npn \xparse_exp_declare_cmd:Nnn #1#2#3 + { + \cs_if_exist:NTF #1 + { + \msg_warning:nnxx { xparse } { redefine-command } + { \token_to_str:N #1 } { \tl_to_str:n {#2} } + } + { + \msg_info:nnxx { xparse } { define-command } + { \token_to_str:N #1 } { \tl_to_str:n {#2} } + } + \group_begin: + \tex_escapechar:D 92 \scan_stop: + \tl_set:Nx \l_xparse_function_tl { \token_to_str:N #1} + \exp_args:NNNo \group_end: + \tl_set:Nn \l_xparse_function_tl { \l_xparse_function_tl } + \xparse_exp_prepare_function:n {#2} + \int_compare:nNnTF \l_xparse_total_args_int = \l_xparse_m_args_int + { \xparse_exp_declare_cmd_all_m:Nn #1 {#3} } + { \xparse_exp_declare_cmd_mixed:Nn #1 {#3} } + } +\cs_new_protected:Npn \xparse_exp_declare_cmd_all_m:Nn #1#2 + { + \bool_if:NTF \l_xparse_long_bool + { + \cs_generate_from_arg_count:NNnn + #1 \cs_set:Npn \l_xparse_total_args_int {#2} + } + { + \cs_generate_from_arg_count:NNnn + #1 \cs_set_nopar:Npn \l_xparse_total_args_int {#2} + } + } +\cs_new_protected:Npn \xparse_exp_declare_cmd_mixed:Nn #1#2 + { + \tl_if_in:noTF { l m u } \l_xparse_last_arg_tl + { \xparse_exp_declare_cmd_mixed_aux:Nn #1 {#2} } + { \msg_error:nn { xparse } { expandable-ending-optional } } + } +\cs_new_protected:Npn \xparse_exp_declare_cmd_mixed_aux:Nn #1#2 + { + \cs_set_nopar:Npx #1 + { \exp_not:c { \token_to_str:N #1 1 } x \exp_not:N \q_xparse } + \cs_set_nopar:cpx + { \token_to_str:N #1 \int_eval:n { \l_xparse_total_args_int + 1 } } + x ##1 \q_xparse + { \exp_not:c { \token_to_str:N #1 } ##1 } + \cs_generate_from_arg_count:cNnn + { \token_to_str:N #1 } \cs_set:Npn \l_xparse_total_args_int {#2} + } +\cs_new_protected:Npn \xparse_exp_prepare_function:n #1 + { + \bool_set_false:N \l_xparse_error_bool + \tl_if_in:nnT {#1} { > } + { + \msg_error:nnx { xparse } { processor-in-expandable } + { \tl_to_str:n {#1} } + \bool_set_true:N \l_xparse_error_bool + } + \tl_if_in:nnT {#1} { g } + { + \msg_error:nnx { xparse } { grouped-in-expandable } + { g } { \tl_to_str:n {#1} } + \bool_set_true:N \l_xparse_error_bool + } + \tl_if_in:nnT {#1} { G } + { + \msg_error:nnx { xparse } { grouped-in-expandable } + { G } { \tl_to_str:n {#1} } + \bool_set_true:N \l_xparse_error_bool + } + \bool_if:NF \l_xparse_error_bool + { \xparse_exp_prepare_function_aux:n {#1} } + } +\cs_new_protected:Npn \xparse_exp_prepare_function_aux:n #1 + { + \cs_set_eq:NN \xparse_prepare_next:w \xparse_exp_prepare_function:N + \cs_set_eq:NN \xparse_exp_set:cpx \cs_set_nopar:cpx + \bool_set_false:N \l_xparse_long_bool + \int_zero:N \l_xparse_m_args_int + \int_zero:N \l_xparse_total_args_int + \tl_if_in:nnT {#1} { + } + { + \bool_set_true:N \l_xparse_long_bool + \cs_set_eq:NN \xparse_exp_set:cpx \cs_set:cpx + } + \xparse_exp_prepare_function:N #1 \q_nil + } +\cs_new_protected:Npn \xparse_exp_prepare_function:N #1 + { + \bool_if:NTF \l_xparse_long_bool + { \xparse_exp_prepare_function_long:N #1 } + { \xparse_exp_prepare_function_short:N #1 } +} +\cs_new_protected:Npn \xparse_exp_prepare_function_long:N #1 + { + \quark_if_nil:NF #1 + { + \str_if_eq:nnTF {#1} { + } + { \xparse_exp_prepare_function_short:N } + { + \msg_error:nn { xparse } { inconsistent-long } + \xparse_exp_prepare_function_short:N #1 + } + } + } +\cs_new_protected:Npn \xparse_exp_prepare_function_short:N #1 + { + \quark_if_nil:NF #1 + { + \prop_if_in:NnTF \c_xparse_shorthands_prop {#1} + { + \prop_get:NnN \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl + \bool_if:NT \l_xparse_long_bool + { \tl_put_left:Nn \l_xparse_tmp_tl { + } } + \exp_after:wN \xparse_exp_prepare_function:N \l_xparse_tmp_tl + } + { + \int_incr:N \l_xparse_total_args_int + \xparse_exp_check_and_add:N #1 + } + } + } +\cs_new_eq:NN \xparse_exp_set:cpx \cs_set_nopar:cpx +\cs_new_protected:Npn \xparse_get_arg_spec:N #1 + { + \cs_if_exist:cTF { l_xparse_ \token_to_str:N #1 _arg_spec_tl } + { + \tl_set_eq:Nc \ArgumentSpecification + { l_xparse_ \token_to_str:N #1 _arg_spec_tl } + } + { + \msg_error:nnx { xparse } { unknown-document-command } + { \token_to_str:N #1 } + } + } +\cs_new_protected:Npn \xparse_get_arg_spec:n #1 + { + \cs_if_exist:cTF { l_xparse_ #1 _arg_spec_tl } + { \tl_set_eq:Nc \ArgumentSpecification { l_xparse_ #1 _arg_spec_tl } } + { + \msg_error:nnx { xparse } { unknown-document-environment } + { \tl_to_str:n {#1} } + } + } +\tl_new:N \ArgumentSpecification +\cs_new_protected:Npn \xparse_show_arg_spec:N #1 + { + \cs_if_exist:cTF { l_xparse_ \token_to_str:N #1 _arg_spec_tl } + { + \tl_set_eq:Nc \ArgumentSpecification + { l_xparse_ \token_to_str:N #1 _arg_spec_tl } + \tl_show:N \ArgumentSpecification + } + { + \msg_error:nnx { xparse } { unknown-document-command } + { \token_to_str:N #1 } + } + } +\cs_new_protected:Npn \xparse_show_arg_spec:n #1 + { + \cs_if_exist:cTF { l_xparse_ #1 _arg_spec_tl } + { + \tl_set_eq:Nc \ArgumentSpecification { l_xparse_ #1 _arg_spec_tl } + \tl_show:N \ArgumentSpecification + } + { + \msg_error:nnx { xparse } { unknown-document-environment } + { \tl_to_str:n {#1} } + } + } +\msg_new:nnnn { xparse } { command-already-defined } + { Command~'#1'~already~defined! } + { + You~have~used~\NewDocumentCommand + with~a~command~that~already~has~a~definition. \\ + The~existing~definition~of~'#1'~will~be~overwritten. + } +\msg_new:nnnn { xparse } { command-not-yet-defined } + { Command ~'#1'~not~yet~defined! } + { + You~have~used~\RenewDocumentCommand + with~a~command~that~was~never~defined.\\ + A~new~command~'#1'~will~be~created. + } +\msg_new:nnnn { xparse } { environment-already-defined } + { Environment~'#1'~already~defined! } + { + You~have~used~\NewDocumentEnvironment + with~an~environment~that~already~has~a~definition.\\ + The~existing~definition~of~'#1'~will~be~overwritten. + } +\msg_new:nnnn { xparse } { environment-mismatch } + { Mismatch~between~start~and~end~of~environment. } + { + The~current~environment~is~called~'#1',~but~you~have~tried~to~ + end~one~called~'#2'.~Environments~have~to~be~properly~nested. + } +\msg_new:nnnn { xparse } { environment-not-yet-defined } + { Environment~'#1'~not~yet~defined! } + { + You~have~used~\RenewDocumentEnvironment + with~an~environment~that~was~never~defined.\\ + A~new~environment~'#1'~will~be~created. + } +\msg_new:nnnn { xparse } { environment-unknown } + { Environment~'#1'~undefined. } + { + You~have~tried~to~start~an~environment~called~'#1',~ + but~this~has~never~been~defined.\\ + The~command~will~be~ignored. + } +\msg_new:nnnn { xparse } { expandable-ending-optional } + { Signature~for~expandable~command~ends~with~optional~argument. } + { + \c_msg_coding_error_text_tl + Expandable~commands~must~have~a~final~mandatory~argument~ + (or~no~arguments~at~all).~You~cannot~have~a~terminal~optional~ + argument~with~expandable~commands. + } +\msg_new:nnnn { xparse } { grouped-in-expandable } + { Argument~specifier~'#1'~forbidden~in~expandable~commands. } + { + \c_msg_coding_error_text_tl + Argument~specification~'#2'~contains~the~optional~grouped~ + argument~'#1':~ + this~is only~supported~for~standard~robust~functions. + } +\msg_new:nnnn { xparse } { inconsistent-long } + { Inconsistent~long~arguments~for~expandable~command. } + { + \c_msg_coding_error_text_tl + The~arguments~for~an~expandable~command~must~either~all~be~ + short~or~all~be~long.~You~have~tried~to~mix~the~two~types. + } +\msg_new:nnnn { xparse } { processor-in-expandable } + { Argument~processors~cannot~be~used~with~expandable~functions. } + { + \c_msg_coding_error_text_tl + Argument~specification~'#1'~contains~a~processor~function:~ + this~is~only~supported~for~standard~robust~functions. + } +\msg_new:nnnn { xparse } { split-excess-tokens } + { Too~many~'#1'~tokens~when~trying~to~split~argument. } + { + LaTeX~was~asked~to~split~the~input~'#3'~ + at~each~occurrence~of~the~token~'#1',~up~to~a~maximum~of~#2~parts.~ + There~were~too~many~'#1'~tokens. + } +\msg_new:nnnn { xparse } { unknown-argument-type } + { Unknown~argument~type~'#1'~replaced~by~'m'. } + { + \c_msg_coding_error_text_tl + The~letter~'#1'~does~not~specify~a~known~argument~type.~ + LaTeX~will~assume~you~want~a~standard~mandatory~argument~(type~'m'). + } +\msg_new:nnnn { xparse } { unknown-document-command } + { Unknown~document~command~'#1'. } + { + You~have~asked~for~the~argument~specification~for~a~command~'#1',~ + but~this~is~not~a~document~command. + } +\msg_new:nnnn { xparse } { unknown-document-environment } + { Unknown~document~environment~'#1'. } + { + You~have~asked~for~the~argument~specification~for~a~command~'#1',~ + but~this~is~not~a~document~environment. + } +\msg_new:nnn { xparse } { define-command } + { + Defining~document~command~#1~ + with~arg.~spec.~'#2'~\msg_line_context:. + } +\msg_new:nnn { xparse } { define-environment } + { + Defining~document~environment~'#1'~ + with~arg.~spec.~'#2'~\msg_line_context:. + } +\msg_new:nnn { xparse } { redefine-command } + { + Redefining~document~command~#1~ + with~arg.~spec.~'#2'~\msg_line_context:. + } +\msg_new:nnn { xparse } { redefine-environment } + { + Redefining~document~environment~'#1'~ + with~arg.~spec.~'#2'~\msg_line_context:. + } +\cs_new_eq:NN \BooleanFalse \c_false_bool +\cs_new_eq:NN \BooleanTrue \c_true_bool +\cs_new_protected:Npn \DeclareDocumentCommand #1#2#3 + { \xparse_declare_cmd:Nnn #1 {#2} {#3} } +\cs_new_protected:Npn \NewDocumentCommand #1#2#3 + { + \cs_if_exist:NTF #1 + { + \msg_error:nnx { xparse } { command-already-defined } + { \token_to_str:N #1 } + } + { \xparse_declare_cmd:Nnn #1 {#2} {#3} } + } +\cs_new_protected:Npn \RenewDocumentCommand #1#2#3 + { + \cs_if_exist:NTF #1 + { \xparse_declare_cmd_aux:Nnn #1 {#2} {#3} } + { + \msg_error:nnx { xparse } { command-not-yet-defined } + { \token_to_str:N #1 } + } + } +\cs_new_protected:Npn \ProvideDocumentCommand #1#2#3 + { \cs_if_exist:NF #1 { \xparse_declare_cmd:Nnn #1 {#2} {#3} } } +\cs_new_protected:Npn \DeclareDocumentCommandImplementation #1#2#3 + { \xparse_declare_cmd_implementation:nNn {#1} #2 {#3} } +\cs_new_protected:Npn \DeclareDocumentCommandInterface #1#2#3 + { \xparse_declare_cmd_interface:Nnn #1 {#2} {#3} } +\cs_new_protected:Npn \DeclareDocumentEnvironment #1#2#3#4 + { \xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } +\cs_new_protected:Npn \NewDocumentEnvironment #1#2#3#4 + { + \cs_if_exist:cTF {#1} + { \msg_error:nnx { xparse } { environment-already-defined } {#1} } + { \xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } +} +\cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4 + { + \cs_if_exist:cTF {#1} + { \xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } + { \msg_error:nnx { xparse } { environment-not-yet-defined } {#1} } + } +\cs_new_protected:Npn \ProvideDocumentEnvironment #1#2#3#4 + { \cs_if_exist:cF { #1 } { \xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } } +\cs_new_protected:Npn \DeclareExpandableDocumentCommand #1#2#3 + { \xparse_exp_declare_cmd:Nnn #1 {#2} {#3} } +\cs_new_eq:NN \IfBooleanTF \bool_if:NTF +\cs_new_eq:NN \IfBooleanT \bool_if:NT +\cs_new_eq:NN \IfBooleanF \bool_if:NF +\cs_new_eq:NN \IfNoValueF \xparse_if_no_value:nF +\cs_new_eq:NN \IfNoValueT \xparse_if_no_value:nT +\cs_new_eq:NN \IfNoValueTF \xparse_if_no_value:nTF +\cs_set:Npn \IfValueF { \xparse_if_no_value:nT } +\cs_set:Npn \IfValueT { \xparse_if_no_value:nF } +\cs_set:Npn \IfValueTF #1#2#3 { \xparse_if_no_value:nTF {#1} {#3} {#2} } +\cs_new_protected:Npn \NoValue { -NoValue- } +\tl_new:N \ProcessedArgument +\cs_new_eq:NN \ReverseBoolean \xparse_bool_reverse:N +\cs_new_eq:NN \SplitArgument \xparse_split_argument:nnn +\cs_new_eq:NN \SplitList \xparse_split_list:nn +\cs_new_eq:NN \GetDocumentCommandArgSpec \xparse_get_arg_spec:N +\cs_new_eq:NN \GetDocumentEnvironmmentArgSpec \xparse_get_arg_spec:n +\cs_new_eq:NN \ShowDocumentCommandArgSpec \xparse_show_arg_spec:N +\cs_new_eq:NN \ShowDocumentEnvironmentArgSpec \xparse_show_arg_spec:n +\DeclareOption { log-declarations = true } { } +\DeclareOption { log-declarations = false } + { + \msg_redirect_module:nnn { xparse } { info } { none } + \msg_redirect_module:nnn { xparse } { warning } { none } + } +\DeclareOption { log-declarations } { } +\ProcessOptions \scan_stop: +%% +%% +%% End of file `xparse.sty'. diff --git a/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty new file mode 100644 index 00000000000..83be1411dad --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty @@ -0,0 +1,1373 @@ +%% +%% This is file `xtemplate.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xtemplate.dtx (with options: `package') +%% +%% EXPERIMENTAL CODE +%% +%% Do not distribute this file without also distributing the +%% source files specified above. +%% +%% Do not distribute a modified version of this file. +%% +%% File: xtemplate.dtx (C) Copyright 1999 Frank Mittelbach, Chris Rowley, +%% David Carlisle +%% (C) Copyright 2004-2010 Frank Mittelbach, +%% The LaTeX3 Project +%% (C) Copyright 2011 The LaTeX3 Project +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3packages bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/svnroot/experimental/trunk/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +\RequirePackage{expl3} +\GetIdInfo$Id: xtemplate.dtx 2492 2011-07-02 13:40:38Z joseph $ + {L3 Experimental prototype document functions} +\ProvidesExplPackage + {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +\@ifpackagelater { l3token } { 2011/07/02 } + { } + { + \PackageError { xtemplate } { Support~package~l3kernel~too~old. } + { + Please~install~an~up~to~date~version~of~l3kernel~ + using~your~TeX~package~manager~or~from~CTAN.\\ \\ + Loading~xtemplate~will~abort! + } + \tex_endinput:D + } +\tl_const:Nn \c_xtemplate_code_root_tl { template~code~>~ } +\tl_const:Nn \c_xtemplate_defaults_root_tl { template~defaults~>~ } +\tl_const:Nn \c_xtemplate_instances_root_tl { template~instance~>~ } +\tl_const:Nn \c_xtemplate_keytypes_root_tl { template~key~types~>~ } +\tl_const:Nn \c_xtemplate_key_order_root_tl { template~key~order~>~ } +\tl_const:Nn \c_xtemplate_restrict_root_tl { template~restrictions~>~ } +\tl_const:Nn \c_xtemplate_values_root_tl { template~values~>~ } +\tl_const:Nn \c_xtemplate_vars_root_tl { template~vars~>~ } +\seq_new:N \c_xtemplate_keytypes_arg_seq +\seq_put_right:Nn \c_xtemplate_keytypes_arg_seq { choice } +\seq_put_right:Nn \c_xtemplate_keytypes_arg_seq { function } +\seq_put_right:Nn \c_xtemplate_keytypes_arg_seq { instance } +\prop_new:N \g_xtemplate_object_type_prop +\tl_new:N \l_xtemplate_assignments_tl +\tl_new:N \l_xtemplate_collection_tl +\prop_new:N \l_xtemplate_collections_prop +\tl_new:N \l_xtemplate_default_tl +\bool_new:N \l_xtemplate_error_bool +\bool_new:N \l_xtemplate_global_bool +\bool_new:N \l_xtemplate_restrict_bool +\clist_new:N \l_xtemplate_restrict_clist +\tl_new:N \l_xtemplate_key_name_tl +\tl_new:N \l_xtemplate_keytype_tl +\tl_new:N \l_xtemplate_keytype_arg_tl +\tl_new:N \l_xtemplate_value_tl +\tl_new:N \l_xtemplate_var_tl +\prop_new:N \l_xtemplate_keytypes_prop +\seq_new:N \l_xtemplate_key_order_seq +\prop_new:N \l_xtemplate_values_prop +\prop_new:N \l_xtemplate_vars_prop +\clist_new:N \l_xtemplate_tmp_clist +\dim_new:N \l_xtemplate_tmp_dim +\int_new:N \l_xtemplate_tmp_int +\muskip_new:N \l_xtemplate_tmp_muskip +\skip_new:N \l_xtemplate_tmp_skip +\tl_new:N \l_xtemplate_tmp_tl +\cs_new_protected:Npn \xtemplate_execute_if_arg_agree:nnT #1#2#3 + { + \prop_get:NnN \g_xtemplate_object_type_prop {#1} \l_xtemplate_tmp_tl + \int_compare:nNnTF {#2} = \l_xtemplate_tmp_tl + {#3} + { + \msg_error:nnxxx { xtemplate } + { argument-number-mismatch } {#1} { \l_xtemplate_tmp_tl } {#2} + } + } +\cs_new_protected:Npn \xtemplate_execute_if_code_exist:nnT #1#2#3 + { + \cs_if_exist:cTF { \c_xtemplate_code_root_tl #1 / #2 } + {#3} + { + \msg_error:nnxx { xtemplate } { no-template-code } + {#1} {#2} + } + } +\cs_new_protected:Npn \xtemplate_execute_if_keytype_exist:nT #1#2 + { + \cs_if_exist:cTF { xtemplate_store_value_ #1 :n } + {#2} + { \msg_error:nnx { xtemplate } { unknown-keytype } {#1} } + } +\cs_generate_variant:Nn \xtemplate_execute_if_keytype_exist:nT { o } +\cs_new_protected:Npn \xtemplate_execute_if_type_exist:nT #1#2 + { + \prop_if_in:NnTF \g_xtemplate_object_type_prop {#1} + {#2} + { \msg_error:nnx { xtemplate } { unknown-object-type } {#1} } + } +\cs_new_protected:Npn \xtemplate_if_keys_exist:nnT #1#2#3 + { + \cs_if_exist:cTF { \c_xtemplate_keytypes_root_tl #1 / #2 } + {#3} + { + \msg_error:nnxx { xtemplate } { unknown-template } + {#1} {#2} + } + } +\prg_new_conditional:Npnn \xtemplate_if_key_value:n #1 { T } + { + \str_if_eq:noTF { \KeyValue } { \tl_head:w #1 \q_stop } + {\prg_return_true: } + { \prg_return_false: } + } +\cs_generate_variant:Nn \xtemplate_if_key_value:nT { o } +\prg_new_conditional:Npnn \xtemplate_if_eval_now:n #1 { TF } + { + \str_if_eq:noTF { \EvaluateNow } { \tl_head:w #1 \q_stop } + { \prg_return_true: } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \xtemplate_if_instance_exist:nnn #1#2#3 + { T, F, TF } + { + \cs_if_exist:cTF { \c_xtemplate_instances_root_tl #1 / #2 / #3 } + { \prg_return_true: } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \xtemplate_if_use_template:n #1 { TF } + { + \str_if_eq:noTF { \UseTemplate } { \tl_head:w #1 \q_stop } + { \prg_return_true: } + { \prg_return_false: } +} +\cs_new_protected:Npn \xtemplate_store_defaults:n #1 + { + \prop_gclear_new:c { \c_xtemplate_defaults_root_tl #1 } + \prop_gset_eq:cN { \c_xtemplate_defaults_root_tl #1 } + \l_xtemplate_values_prop + } +\cs_new_protected:Npn \xtemplate_store_keytypes:n #1 + { + \prop_gclear_new:c { \c_xtemplate_keytypes_root_tl #1 } + \prop_gset_eq:cN { \c_xtemplate_keytypes_root_tl #1 } + \l_xtemplate_keytypes_prop + \seq_gclear_new:c { \c_xtemplate_key_order_root_tl #1 } + \seq_gset_eq:cN { \c_xtemplate_key_order_root_tl #1 } + \l_xtemplate_key_order_seq + } +\cs_new_protected:Npn \xtemplate_store_values:n #1 + { + \prop_clear_new:c { \c_xtemplate_values_root_tl #1 } + \prop_set_eq:cN { \c_xtemplate_values_root_tl #1 } + \l_xtemplate_values_prop + } +\cs_new_protected:Npn \xtemplate_store_restrictions:n #1 + { + \clist_gclear_new:c { \c_xtemplate_restrict_root_tl #1 } + \clist_gset_eq:cN { \c_xtemplate_restrict_root_tl #1 } + \l_xtemplate_restrict_clist + } +\cs_new_protected:Npn \xtemplate_store_vars:n #1 + { + \prop_gclear_new:c { \c_xtemplate_vars_root_tl #1 } + \prop_gset_eq:cN { \c_xtemplate_vars_root_tl #1 } + \l_xtemplate_vars_prop + } +\cs_new_protected:Npn \xtemplate_recover_defaults:n #1 + { + \prop_set_eq:Nc \l_xtemplate_values_prop + { \c_xtemplate_defaults_root_tl #1 } + } +\cs_new_protected:Npn \xtemplate_recover_keytypes:n #1 + { + \prop_set_eq:Nc \l_xtemplate_keytypes_prop + { \c_xtemplate_keytypes_root_tl #1 } + \seq_set_eq:Nc \l_xtemplate_key_order_seq + { \c_xtemplate_key_order_root_tl #1 } + } +\cs_new_protected:Npn \xtemplate_recover_restrictions:n #1 + { + \clist_set_eq:Nc \l_xtemplate_restrict_clist + { \c_xtemplate_restrict_root_tl #1 } + } +\cs_new_protected:Npn \xtemplate_recover_values:n #1 + { + \prop_set_eq:Nc \l_xtemplate_values_prop + { \c_xtemplate_values_root_tl #1 } + } +\cs_new_protected:Npn \xtemplate_recover_vars:n #1 + { + \prop_set_eq:Nc \l_xtemplate_vars_prop + { \c_xtemplate_vars_root_tl #1 } + } +\cs_new_protected:Npn \xtemplate_declare_object_type:nn #1#2 + { + \int_set:Nn \l_xtemplate_tmp_int {#2} + \bool_if:nTF + { + \int_compare_p:nNn {#2} > \c_nine || + \int_compare_p:nNn {#2} < \c_zero + } + { + \msg_error:nnxx { xtemplate } { bad-number-of-arguments } + {#1} { \exp_not:V \l_xtemplate_tmp_int } + } + { + \msg_info:nnxx { xtemplate } { declare-object-type } + {#1} {#2} + \prop_gput:NnV \g_xtemplate_object_type_prop {#1} + \l_xtemplate_tmp_int + } + } +\cs_new_protected:Npn \xtemplate_declare_template_keys:nnnn #1#2#3#4 + { + \xtemplate_execute_if_type_exist:nT {#1} + { + \xtemplate_execute_if_arg_agree:nnT {#1} {#3} + { + \prop_clear:N \l_xtemplate_values_prop + \prop_clear:N \l_xtemplate_keytypes_prop + \seq_clear:N \l_xtemplate_key_order_seq + \keyval_parse:NNn + \xtemplate_parse_keys_elt:n \xtemplate_parse_keys_elt:nn {#4} + \xtemplate_store_defaults:n { #1 / #2 } + \xtemplate_store_keytypes:n { #1 / #2 } + } + } + } +\cs_new_protected:Npn \xtemplate_parse_keys_elt:n #1 + { + \xtemplate_split_keytype:n {#1} + \bool_if:NF \l_xtemplate_error_bool + { + \xtemplate_execute_if_keytype_exist:oT \l_xtemplate_keytype_tl + { + \seq_map_function:NN \c_xtemplate_keytypes_arg_seq + \xtemplate_parse_keys_elt_aux:n + \bool_if:NF \l_xtemplate_error_bool + { + \seq_if_in:NoTF \l_xtemplate_key_order_seq + \l_xtemplate_key_name_tl + { + \msg_error:nnx { xtemplate } + { duplicate-key-interface } + { \l_xtemplate_key_name_tl } + } + { \xtemplate_parse_keys_elt_aux: } + } + } + } + } +\cs_new_protected_nopar:Npn \xtemplate_parse_keys_elt_aux:n #1 + { + \str_if_eq:onT \l_xtemplate_keytype_tl {#1} + { + \tl_if_empty:NT \l_xtemplate_keytype_arg_tl + { + \msg_error:nnx { xtemplate } + { keytype-requires-argument } {#1} + \bool_set_true:N \l_xtemplate_error_bool + \seq_map_break: + } + } + } +\cs_new_nopar:Npn \xtemplate_parse_keys_elt_aux: + { + \tl_set:Nx \l_xtemplate_tmp_tl + { + \l_xtemplate_keytype_tl + \tl_if_empty:NF \l_xtemplate_keytype_arg_tl + { { \l_xtemplate_keytype_arg_tl } } + } + \prop_put:Noo \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \seq_put_right:No \l_xtemplate_key_order_seq \l_xtemplate_key_name_tl + \str_if_eq:onT \l_xtemplate_keytype_tl { choice } + { + \clist_if_in:NnT \l_xtemplate_keytype_arg_tl { unknown } + { \msg_error:nn { xtemplate } { choice-unknown-reserved } } + } + } +\cs_new_protected:Npn \xtemplate_parse_keys_elt:nn #1#2 + { + \xtemplate_parse_keys_elt:n {#1} + \use:c { xtemplate_store_value_ \l_xtemplate_keytype_tl :n } {#2} + } +\group_begin: +\char_set_lccode:nn { `\@ } { `\: } +\char_set_catcode_other:N \@ +\tl_to_lowercase:n + { + \group_end: + \cs_new_protected:Npn \xtemplate_split_keytype:n #1 + { + \bool_set_false:N \l_xtemplate_error_bool + \tl_set:Nn \l_xtemplate_tmp_tl {#1} + \tl_remove_all:Nn \l_xtemplate_tmp_tl { ~ } + \tl_replace_all:Nnn \l_xtemplate_tmp_tl { : } { @ } + \tl_if_in:onTF \l_xtemplate_tmp_tl { @ } + { + \tl_clear:N \l_xtemplate_key_name_tl + \exp_after:wN \xtemplate_split_keytype_aux:w + \l_xtemplate_tmp_tl \q_stop + } + { + \bool_set_true:N \l_xtemplate_error_bool + \msg_error:nnx { xtemplate } { missing-keytype } {#1} + } + } + \cs_new_protected:Npn \xtemplate_split_keytype_aux:w #1 @ #2 \q_stop + { + \tl_put_right:Nx \l_xtemplate_key_name_tl { \tl_to_str:n {#1} } + \tl_if_in:nnTF {#2} { @ } + { + \tl_put_right:Nn \l_xtemplate_key_name_tl { @ } + \xtemplate_split_keytype_aux:w #2 \q_stop + } + { + \tl_if_empty:NTF \l_xtemplate_key_name_tl + { \msg_error:nnx { xtemplate } { empty-key-name } { @ #2 } } + { \xtemplate_split_keytype_arg:n {#2} } + } + } + } +\cs_new_protected:Npn \xtemplate_split_keytype_arg:n #1 + { + \tl_set:Nn \l_xtemplate_keytype_tl {#1} + \tl_clear:N \l_xtemplate_keytype_arg_tl + \cs_set_protected_nopar:Npn \xtemplate_split_keytype_arg_aux:n ##1 + { + \tl_if_in:nnT {#1} {##1} + { + \cs_set:Npn \xtemplate_split_keytype_arg_aux:w + ####1 ##1 ####2 \q_stop + { + \tl_if_empty:nT {####1} + { + \tl_set:Nn \l_xtemplate_keytype_tl {##1} + \tl_set:Nn \l_xtemplate_keytype_arg_tl {####2} + \seq_map_break: + } + } + \xtemplate_split_keytype_arg_aux:w #1 \q_stop + } + } + \seq_map_function:NN \c_xtemplate_keytypes_arg_seq + \xtemplate_split_keytype_arg_aux:n + } +\cs_generate_variant:Nn \xtemplate_split_keytype_arg:n { o } +\cs_new_nopar:Npn \xtemplate_split_keytype_arg_aux:n #1 { } +\cs_new_nopar:Npn \xtemplate_split_keytype_arg_aux:w #1 \q_stop { } +\cs_new_protected:Npn \xtemplate_store_value_boolean:n #1 + { + \xtemplate_if_eval_now:nTF {#1} + { + \bool_if:cTF { c_ #1 _bool } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl + { true } + } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl + { false } + } + } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl {#1} + } + } +\cs_new_protected:Npn \xtemplate_store_value_code:n #1 + { \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl {#1} } +\cs_new_eq:NN \xtemplate_store_value_choice:n \xtemplate_store_value_code:n +\cs_new_eq:NN \xtemplate_store_value_commalist:n \xtemplate_store_value_code:n +\cs_new_eq:NN \xtemplate_store_value_function:n \xtemplate_store_value_code:n +\cs_new_eq:NN \xtemplate_store_value_instance:n \xtemplate_store_value_code:n +\cs_new_eq:NN \xtemplate_store_value_real:n \xtemplate_store_value_code:n +\cs_new_eq:NN \xtemplate_store_value_tokenlist:n \xtemplate_store_value_code:n +\cs_new_protected:Npn \xtemplate_store_value_integer:n #1 + { + \xtemplate_if_eval_now:nTF {#1} + { + \int_set:Nn \l_xtemplate_tmp_int {#1} + \prop_put:NVV \l_xtemplate_values_prop \l_xtemplate_key_name_int + \l_xtemplate_tmp_int + } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl {#1} + } + } +\cs_new_protected:Npn \xtemplate_store_value_length:n #1 + { + \xtemplate_if_eval_now:nTF {#1} + { + \dim_set:Nn \l_xtemplate_tmp_dim {#1} + \prop_put:NVV \l_xtemplate_values_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_dim + } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl {#1} + } + } +\cs_new_protected:Npn \xtemplate_store_value_muskip:n #1 + { + \xtemplate_if_eval_now:nTF {#1} + { + \muskip_set:Nn \l_xtemplate_tmp_muskip {#1} + \prop_put:NVV \l_xtemplate_values_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_muskip + } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl {#1} + } + } +\cs_new_protected:Npn \xtemplate_store_value_skip:n #1 + { + \xtemplate_if_eval_now:nTF {#1} + { + \skip_set:Nn \l_xtemplate_tmp_skip {#1} + \prop_put:NVV \l_xtemplate_values_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_skip + } + { + \prop_put:Non \l_xtemplate_values_prop \l_xtemplate_key_name_tl {#1} + } + } +\cs_new_protected:Npn \xtemplate_declare_template_code:nnnnn #1#2#3#4#5 + { + \xtemplate_execute_if_type_exist:nT {#1} + { + \xtemplate_execute_if_arg_agree:nnT {#1}{#3} + { + \xtemplate_if_keys_exist:nnT {#1} {#2} + { + \xtemplate_store_key_implementation:nnn {#1} {#2} {#4} + \cs_generate_from_arg_count:cNnn + { \c_xtemplate_code_root_tl #1 / #2 } + \cs_gset_protected:Npn {#3} {#5} + } + } + } + } +\cs_new_protected:Npn \xtemplate_store_key_implementation:nnn #1#2#3 + { + \xtemplate_recover_defaults:n { #1 / #2 } + \xtemplate_recover_keytypes:n { #1 / #2 } + \prop_clear:N \l_xtemplate_vars_prop + \keyval_parse:NNn + \xtemplate_parse_vars_elt:n \xtemplate_parse_vars_elt:nn {#3} + \xtemplate_store_vars:n { #1 / #2 } + \clist_clear:N \l_xtemplate_restrict_clist + \xtemplate_store_restrictions:n { #1 / #2 } + \prop_if_empty:NF \l_xtemplate_keytypes_prop + { + \prop_map_inline:Nn \l_xtemplate_keytypes_prop + { + \msg_error:nnxxx { xtemplate } { key-not-implemented } + {##1} {#2} {#1} + } + } + } +\cs_new_protected:Npn \xtemplate_parse_vars_elt:n #1 + { \msg_error:nnx { xtemplate } { key-no-variable } {#1} } +\cs_new_protected:Npn \xtemplate_parse_vars_elt:nn #1#2 + { + \tl_set:Nx \l_xtemplate_key_name_tl { \tl_to_str:n {#1} } + \tl_remove_all:Nn \l_xtemplate_key_name_tl { ~ } + \prop_if_in:NoTF \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + { + \prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + \l_xtemplate_keytype_tl + \xtemplate_split_keytype_arg:o \l_xtemplate_keytype_tl + \xtemplate_parse_vars_elt_aux:n {#2} + \prop_del:NV \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + } + { \msg_error:nnx { xtemplate } { unknown-key } {#1} } + } +\cs_new_protected:Npn \xtemplate_parse_vars_elt_aux:n #1 + { + \str_if_eq:onTF \l_xtemplate_keytype_tl { choice } + { \xtemplate_implement_choices:n {#1} } + { + \str_if_eq:onTF \l_xtemplate_keytype_tl { code } + { + \prop_put:Non \l_xtemplate_vars_prop + \l_xtemplate_key_name_tl {#1} + } + { + \str_if_eq:noTF {#1} { \tl_head:w #1 \q_stop } + { + \cs_if_exist:NTF #1 + { + \prop_put:Non \l_xtemplate_vars_prop + \l_xtemplate_key_name_tl {#1} + } + { + \msg_error:nnx { xtemplate } + { variable-not-declared } + { \token_to_str:N #1 } + } + } + { + \tl_if_in:nnTF {#1} { global } + { \xtemplate_parse_vars_elt_aux:w #1 \q_stop } + { + \msg_error:nnx { xtemplate } { bad-variable } + { \tl_to_str:n {#1} } + } + } + } + } + } +\cs_new_protected:Npn \xtemplate_parse_vars_elt_aux:w #1 global #2 \q_stop + { + \tl_if_empty:nTF {#1} + { + \str_if_eq:noTF {#2} { \tl_head:w #2 \q_stop } + { + \cs_if_exist:NTF #2 + { + \prop_put:Non \l_xtemplate_vars_prop + \l_xtemplate_key_name_tl { #1 global #2 } + } + { + \msg_error:nnx { xtemplate } + { variable-not-declared } { \token_to_str:N #2 } + } + } + { + \msg_error:nnx { xtemplate } { bad-variable } + { \tl_to_str:n { #1 global #2 } } + } + } + { + \msg_error:nnx { xtemplate } { bad-variable } + { \tl_to_str:n { #1 global #2 } } + } + } +\cs_new_protected:Npn \xtemplate_implement_choices:n #1 + { + \clist_set_eq:NN \l_xtemplate_tmp_clist \l_xtemplate_keytype_arg_tl + \prop_put:Non \l_xtemplate_vars_prop \l_xtemplate_key_name_tl { } + \keyval_parse:NNn + \xtemplate_implement_choice_elt:n \xtemplate_implement_choice_elt:nn + {#1} + \prop_if_in:NoT \l_xtemplate_values_prop \l_xtemplate_key_name_tl + { \xtemplate_implement_choices_default: } + \clist_if_empty:NF \l_xtemplate_tmp_clist + { + \clist_map_inline:Nn \l_xtemplate_tmp_clist + { + \msg_error:nnx { xtemplate } { choice-not-implemented } + {##1} + } + } + } +\cs_new_protected_nopar:Npn \xtemplate_implement_choices_default: + { + \prop_get:NoN \l_xtemplate_values_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \tl_set:Nx \l_xtemplate_tmp_tl + { \l_xtemplate_key_name_tl \c_space_tl \l_xtemplate_tmp_tl } + \prop_if_in:NoF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl + { + \tl_set:Nx \l_xtemplate_tmp_tl + { \l_xtemplate_key_name_tl \c_space_tl \l_xtemplate_tmp_tl } + \prop_if_in:NoF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl + { + \prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \xtemplate_split_keytype_arg:o \l_xtemplate_tmp_tl + \prop_get:NoN \l_xtemplate_values_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \msg_error:nnxxx { xtemplate } { unknown-default-choice } + { \l_xtemplate_key_name_tl } { \l_xtemplate_key_name_tl } + { \l_xtemplate_keytype_arg_tl } + } + } + } +\cs_new_protected:Npn \xtemplate_implement_choice_elt:n #1 + { + \clist_if_empty:NTF \l_xtemplate_tmp_clist + { + \str_if_eq:nnF {#1} { unknown } + { + \prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \xtemplate_split_keytype_arg:o \l_xtemplate_tmp_tl + \msg_error:nnxxx { xtemplate } { unknown-choice } + { \l_xtemplate_key_name_tl } {#1} + { \l_xtemplate_keytype_arg_tl } + } + } + { + \clist_if_in:NnTF \l_xtemplate_tmp_clist {#1} + { \clist_remove_element:Nn \l_xtemplate_tmp_clist {#1} } + { + \prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \xtemplate_split_keytype_arg:o \l_xtemplate_tmp_tl + \msg_error:nnxxx { xtemplate } { unknown-choice } + { \l_xtemplate_key_name_tl } {#1} + { \l_xtemplate_keytype_arg_tl } + } + } + } +\cs_new_protected:Npn \xtemplate_implement_choice_elt:nn #1#2 + { + \xtemplate_implement_choice_elt:n {#1} + \tl_set:Nx \l_xtemplate_tmp_tl + { \l_xtemplate_key_name_tl \c_space_tl #1 } + \prop_put:Non \l_xtemplate_vars_prop \l_xtemplate_tmp_tl {#2} + } +\cs_new_protected:Npn \xtemplate_declare_restricted:nnnn #1#2#3#4 + { + \xtemplate_if_keys_exist:nnT {#1} {#2} + { + \xtemplate_set_template_eq:nn { #1 / #3 } { #1 / #2 } + \bool_set_true:N \l_xtemplate_restrict_bool + \xtemplate_edit_defaults_aux:nnn {#1} {#3} {#4} + } + } +\cs_new_protected:Npn \xtemplate_edit_defaults:nnn + { + \bool_set_false:N \l_xtemplate_restrict_bool + \xtemplate_edit_defaults_aux:nnn + } +\cs_new_protected:Npn \xtemplate_edit_defaults_aux:nnn #1#2#3 + { + \xtemplate_if_keys_exist:nnT {#1} {#2} + { + \xtemplate_recover_defaults:n { #1 / #2 } + \xtemplate_recover_restrictions:n { #1 / #2 } + \xtemplate_parse_values:nn { #1 / #2 } {#3} + \xtemplate_store_defaults:n { #1 / #2 } + \xtemplate_store_restrictions:n { #1 / #2 } + } + } +\cs_new_protected:Npn \xtemplate_parse_values:nn #1#2 + { + \xtemplate_recover_keytypes:n {#1} + \clist_clear:N \l_xtemplate_restrict_clist + \keyval_parse:NNn + \xtemplate_parse_values_elt:n \xtemplate_parse_values_elt:nn {#2} + } +\cs_new_protected:Npn \xtemplate_parse_values_elt:n #1 + { + \bool_set_true:N \l_xtemplate_error_bool + \msg_error:nnx { xtemplate } { key-no-value } {#1} + } +\cs_new_protected:Npn \xtemplate_parse_values_elt:nn #1#2 + { + \tl_set:Nx \l_xtemplate_key_name_tl { \tl_to_str:n {#1} } + \tl_remove_all:Nn \l_xtemplate_key_name_tl { ~ } + \prop_if_in:NoTF \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + { + \bool_if:NTF \l_xtemplate_restrict_bool + { + \clist_if_in:NoF \l_xtemplate_restrict_clist + \l_xtemplate_key_name_tl + { + \xtemplate_parse_values_elt_aux:on + \l_xtemplate_key_name_tl {#2} + } + } + { \xtemplate_parse_values_elt_aux:on \l_xtemplate_key_name_tl {#2} } + } + { + \msg_error:nnx { xtemplate } { unknown-key } + { \l_xtemplate_key_name_tl } + } + } +\cs_new_protected:Npn \xtemplate_parse_values_elt_aux:nn #1#2 + { + \clist_put_right:Nn \l_xtemplate_restrict_clist {#1} + \prop_get:NnN \l_xtemplate_keytypes_prop {#1} \l_xtemplate_tmp_tl + \xtemplate_split_keytype_arg:o \l_xtemplate_tmp_tl + \use:c { xtemplate_store_value_ \l_xtemplate_keytype_tl :n } {#2} + } +\cs_generate_variant:Nn \xtemplate_parse_values_elt_aux:nn { o } +\cs_new_protected:Npn \xtemplate_set_template_eq:nn #1#2 + { + \xtemplate_recover_defaults:n {#2} + \xtemplate_store_defaults:n {#1} + \xtemplate_recover_keytypes:n {#2} + \xtemplate_store_keytypes:n {#1} + \xtemplate_recover_vars:n {#2} + \xtemplate_store_vars:n {#1} + \cs_gset_eq:cc { \c_xtemplate_code_root_tl #1 } + { \c_xtemplate_code_root_tl #2 } + } +\cs_new_protected:Npn \xtemplate_declare_instance:nnnnn #1#2#3#4#5 + { + \xtemplate_execute_if_code_exist:nnT {#1} {#2} + { + \xtemplate_recover_defaults:n { #1 / #2 } + \xtemplate_recover_vars:n { #1 / #2 } + \xtemplate_declare_instance_aux:nnnnn {#1} {#2} {#3} {#4} {#5} + } + } +\cs_new_protected:Npn \xtemplate_declare_instance_aux:nnnnn #1#2#3#4#5 + { + \bool_set_false:N \l_xtemplate_error_bool + \xtemplate_parse_values:nn { #1 / #2 } {#5} + \bool_if:NF \l_xtemplate_error_bool + { + \prop_put:Nnn \l_xtemplate_values_prop { from~template } {#2} + \xtemplate_store_values:n { #1 / #3 / #4 } + \xtemplate_convert_to_assignments: + \cs_set_protected:cpx { \c_xtemplate_instances_root_tl #1 / #3 / #4 } + { + \exp_not:N \xtemplate_assignments_push:n + { \exp_not:o \l_xtemplate_assignments_tl } + \exp_not:c { \c_xtemplate_code_root_tl #1 / #2 } + } + \xtemplate_if_instance_exist:nnnF {#1} { } {#4} + { + \cs_set_eq:cc + { \c_xtemplate_instances_root_tl #1 / / #4 } + { \c_xtemplate_instances_root_tl #1 / #3 / #4 } + } + } + } +\cs_new_protected:Npn \xtemplate_edit_instance:nnnn #1#2#3 + { + \xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3} + { + \xtemplate_recover_values:n { #1 / #2 / #3 } + \prop_get:NnN \l_xtemplate_values_prop { from~template } + \l_xtemplate_tmp_tl + \xtemplate_edit_instance_aux:nonnn {#1} \l_xtemplate_tmp_tl + {#2} {#3} + } + { + \msg_error:nnxx { xtemplate } { unknown-instance } + {#1} {#3} + } + } +\cs_new_protected:Npn \xtemplate_edit_instance_aux:nnnnn #1#2 + { + \xtemplate_recover_vars:n { #1 / #2 } + \xtemplate_declare_instance_aux:nnnnn {#1} {#2} + } +\cs_generate_variant:Nn \xtemplate_edit_instance_aux:nnnnn { no } +\cs_new_protected_nopar:Npn \xtemplate_convert_to_assignments: + { + \tl_clear:N \l_xtemplate_assignments_tl + \seq_map_function:NN \l_xtemplate_key_order_seq + \xtemplate_convert_to_assignments_aux:n + } +\cs_new_protected:Npn \xtemplate_convert_to_assignments_aux:n #1 + { + \prop_get:NnN \l_xtemplate_keytypes_prop {#1} \l_xtemplate_tmp_tl + \xtemplate_convert_to_assignments_aux:no {#1} \l_xtemplate_tmp_tl + } +\cs_new_protected:Npn \xtemplate_convert_to_assignments_aux:nn #1#2 + { + \prop_if_in:NnT \l_xtemplate_values_prop {#1} + { + \prop_if_in:NnTF \l_xtemplate_vars_prop {#1} + { + \prop_get:NnN \l_xtemplate_values_prop {#1} \l_xtemplate_value_tl + \prop_get:NnN \l_xtemplate_vars_prop {#1} \l_xtemplate_var_tl + \xtemplate_split_keytype_arg:n {#2} + \str_if_eq:onF \l_xtemplate_keytype_tl { choice } + { + \str_if_eq:onF \l_xtemplate_keytype_tl { code } + { \xtemplate_find_global: } + } + \tl_set:Nn \l_xtemplate_key_name_tl {#1} + \use:c { xtemplate_assign_ \l_xtemplate_keytype_tl : } + } + { \msg_error:nnx { xtemplate } { unknown-attribute } {#1} } + } + } +\cs_generate_variant:Nn \xtemplate_convert_to_assignments_aux:nn { no } +\cs_new_protected_nopar:Npn \xtemplate_find_global: + { + \bool_set_false:N \l_xtemplate_global_bool + \tl_if_in:onT \l_xtemplate_var_tl { global } + { + \exp_after:wN \xtemplate_find_global_aux:w \l_xtemplate_var_tl \q_stop + } + } +\cs_new_protected:Npn \xtemplate_find_global_aux:w #1 global #2 \q_stop + { + \tl_set:Nn \l_xtemplate_var_tl {#2} + \bool_set_true:N \l_xtemplate_global_bool + } +\cs_new_protected:Npn \xtemplate_use_template:nnn #1#2#3 + { + \xtemplate_execute_if_code_exist:nnT {#1} {#2} + { + \xtemplate_recover_defaults:n { #1 / #2 } + \xtemplate_recover_vars:n { #1 / #2 } + \xtemplate_parse_values:nn { #1 / #2 } {#3} + \xtemplate_convert_to_assignments: + \use:c { \c_xtemplate_code_root_tl #1 / #2 } + } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_boolean: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_boolean_aux:n { bool_gset } } + { \xtemplate_assign_boolean_aux:n { bool_set } } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_boolean_aux:n #1 + { + \xtemplate_if_key_value:oT \l_xtemplate_value_tl + { \xtemplate_key_to_value: } + \tl_put_left:Nx \l_xtemplate_assignments_tl + { + \exp_not:c { #1 _ \l_xtemplate_value_tl :N } + \exp_not:o \l_xtemplate_var_tl + } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_choice: + { + \tl_set:Nx \l_xtemplate_tmp_tl + { \l_xtemplate_key_name_tl \c_space_tl \l_xtemplate_value_tl } + \prop_if_in:NoTF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl + { \xtemplate_assign_choice_aux:o \l_xtemplate_tmp_tl } + { + \tl_set:Nx \l_xtemplate_tmp_tl + { \l_xtemplate_key_name_tl \c_space_tl unknown } + \prop_if_in:NoTF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl + { \xtemplate_assign_choice_aux:o \l_xtemplate_tmp_tl } + { + \prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl + \l_xtemplate_tmp_tl + \xtemplate_split_keytype_arg:o \l_xtemplate_tmp_tl + \msg_error:nnxxx { xtemplate } { unknown-choice } + { \l_xtemplate_key_name_tl } { \l_xtemplate_value_tl } + { \l_xtemplate_keytype_arg_tl } + } + } + } +\cs_new_protected:Npn \xtemplate_assign_choice_aux:n #1 + { + \prop_get:NnN \l_xtemplate_vars_prop {#1} \l_xtemplate_tmp_tl + \tl_put_right:No \l_xtemplate_assignments_tl \l_xtemplate_tmp_tl + } +\cs_generate_variant:Nn \xtemplate_assign_choice_aux:n { o } +\cs_new_protected_nopar:Npn \xtemplate_assign_code: + { + \tl_put_left:Nx \l_xtemplate_assignments_tl + { + \cs_set_protected:Npn \xtemplate_assign_code:n \exp_not:n {##1} + { \exp_not:o \l_xtemplate_var_tl } + \xtemplate_assign_code:n { \exp_not:o \l_xtemplate_value_tl } + } + } +\cs_new_protected:Npn \xtemplate_assign_code:n #1 { } +\cs_new_protected_nopar:Npn \xtemplate_assign_function: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_function_aux:N \cs_gset:Npn } + { \xtemplate_assign_function_aux:N \cs_set:Npn } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_function_aux:N #1 + { + \tl_put_left:Nx \l_xtemplate_assignments_tl + { + \cs_generate_from_arg_count:NNnn + \exp_not:o \l_xtemplate_var_tl + \exp_not:N #1 + { \exp_not:o \l_xtemplate_keytype_arg_tl } + { \exp_not:o \l_xtemplate_value_tl } + } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_instance: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_instance_aux:N \cs_gset_protected:Npn } + { \xtemplate_assign_instance_aux:N \cs_set_protected:Npn } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_instance_aux:N #1 + { + \tl_put_left:Nx \l_xtemplate_assignments_tl + { + \exp_not:N #1 \exp_not:o \l_xtemplate_var_tl + { + \xtemplate_use_instance:nn + { \exp_not:o \l_xtemplate_keytype_arg_tl } + { \exp_not:o \l_xtemplate_value_tl } + } + } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_integer: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_variable:N \int_gset:Nn } + { \xtemplate_assign_variable:N \int_set:Nn } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_length: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_variable:N \dim_gset:Nn } + { \xtemplate_assign_variable:N \dim_set:Nn } +} +\cs_new_protected_nopar:Npn \xtemplate_assign_muskip: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_variable:N \muskip_gset:Nn } + { \xtemplate_assign_variable:N \muskip_set:Nn } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_real: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_variable:N \fp_gset:Nn } + { \xtemplate_assign_variable:N \fp_set:Nn } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_skip: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_variable:N \skip_gset:Nn } + { \xtemplate_assign_variable:N \skip_set:Nn } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_tokenlist: + { + \bool_if:NTF \l_xtemplate_global_bool + { \xtemplate_assign_tokenlist_aux:N \tl_gset:Nn } + { \xtemplate_assign_tokenlist_aux:N \tl_set:Nn } + } +\cs_new_eq:NN \xtemplate_assign_commalist: \xtemplate_assign_tokenlist: +\cs_new_protected_nopar:Npn \xtemplate_assign_tokenlist_aux:N #1 + { + \xtemplate_if_key_value:oT \l_xtemplate_value_tl + { \xtemplate_key_to_value: } + \tl_put_left:Nx \l_xtemplate_assignments_tl + { + #1 \exp_not:o \l_xtemplate_var_tl + { \exp_not:o \l_xtemplate_value_tl } + } + } +\cs_new_protected_nopar:Npn \xtemplate_assign_variable:N #1 + { + \xtemplate_if_key_value:oT \l_xtemplate_value_tl + { \xtemplate_key_to_value: } + \tl_put_left:Nx \l_xtemplate_assignments_tl + { + #1 \exp_not:o \l_xtemplate_var_tl + { \exp_not:o \l_xtemplate_value_tl } + } + } +\cs_new_protected_nopar:Npn \xtemplate_key_to_value: + { \exp_after:wN \xtemplate_key_to_value_aux:w \l_xtemplate_value_tl } +\cs_new_protected:Npn \xtemplate_key_to_value_aux:w \KeyValue #1 + { + \tl_set:Nx \l_xtemplate_tmp_tl { \tl_to_str:n {#1} } + \tl_remove_all:Nn \l_xtemplate_key_name_tl { ~ } + \prop_if_in:NoTF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl + { + \prop_get:NoN \l_xtemplate_vars_prop \l_xtemplate_tmp_tl + \l_xtemplate_value_tl + } + { + \msg_error:nnx { xtemplate } { unknown-attribute } + { \l_xtemplate_tmp_tl } + } + } +\cs_new_protected:Npn \xtemplate_use_instance:nn #1#2 + { + \xtemplate_if_use_template:nTF {#2} + { \xtemplate_use_instance_aux:nNnnn {#1} #2 } + { \xtemplate_use_instance_aux:nn {#1} {#2} } + } +\cs_new_protected:Npn \xtemplate_use_instance_aux:nNnnn #1#2#3#4#5 + { + \str_if_eq:nnTF {#1} {#3} + { \xtemplate_use_template:nnn {#3} {#4} {#5} } + { \msg_error:nnxx { xtemplate } { type-mismatch } {#1} {#3} } +} +\cs_new_protected:Npn \xtemplate_use_instance_aux:nn #1#2 + { + \xtemplate_get_collection:n {#1} + \xtemplate_if_instance_exist:nnnTF + {#1} { \l_xtemplate_collection_tl } {#2} + { + \use:c + { + \c_xtemplate_instances_root_tl #1 / + \l_xtemplate_collection_tl / #2 + } + } + { + \xtemplate_if_instance_exist:nnnTF {#1} { } {#2} + { \use:c { \c_xtemplate_instances_root_tl #1 / / #2 } } + { + \msg_error:nnxx { xtemplate } { unknown-instance } + {#1} {#2} + } + } + } +\cs_new_protected:Npn \xtemplate_use_collection:nn #1#2 + { \prop_put:Nnn \l_xtemplate_collections_prop {#1} {#2} } +\cs_new_protected:Npn \xtemplate_get_collection:n #1 + { + \prop_if_in:NnTF \l_xtemplate_collections_prop {#1} + { + \prop_get:NnN \l_xtemplate_collections_prop {#1} + \l_xtemplate_collection_tl + } + { \tl_clear:N \l_xtemplate_collection_tl } + } +\cs_new_nopar:Npn \xtemplate_assignments_pop: { \l_xtemplate_assignments_tl } +\cs_new_protected:Npn \xtemplate_assignments_push:n #1 + { \tl_set:Nn \l_xtemplate_assignments_tl {#1} } +\cs_new_protected_nopar:Npn \xtemplate_show_code:nn #1#2 + { \cs_show:c { \c_xtemplate_code_root_tl #1 / #2 } } +\cs_new_protected_nopar:Npn \xtemplate_show_defaults:nn #1#2 + { + \xtemplate_if_keys_exist:nnT {#1} {#2} + { + \xtemplate_recover_defaults:n { #1 / #2 } + \xtemplate_show:Nnnn \l_xtemplate_values_prop + {#1} {#2} { default~values } + } + } +\cs_new_protected_nopar:Npn \xtemplate_show_keytypes:nn #1#2 + { + \xtemplate_if_keys_exist:nnT {#1} {#2} + { + \xtemplate_recover_keytypes:n { #1 / #2 } + \xtemplate_show:Nnnn \l_xtemplate_keytypes_prop + {#1} {#2} { interface } + } + } +\cs_new_protected_nopar:Npn \xtemplate_show_vars:nn #1#2 + { + \xtemplate_execute_if_code_exist:nnT {#1} {#2} + { + \xtemplate_recover_vars:n { #1 / #2 } + \xtemplate_show:Nnnn \l_xtemplate_vars_prop + {#1} {#2} { variable~mapping } + } + } +\cs_new_protected_nopar:Npn \xtemplate_show:Nnnn #1#2#3#4 + { + \prop_if_empty:NTF #1 + { + \iow_term:x { Template~'#3'~of~object~type~'#2'~has~no~#4 . } + \tl_show:n { } + } + { + \iow_term:x { Template~'#3'~of~object~type~'#2'~has~ #4 : } + \tl_set:Nx \l_prop_show_tl + { \prop_map_function:NN #1 \xtemplate_show_aux:nn } + \etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN + { \exp_after:wN \prop_show_aux:w \l_prop_show_tl } + } +} +\cs_new:Npn \xtemplate_show_aux:nn #1#2 + { + \iow_newline: > \c_space_tl \c_space_tl + #1 + \c_space_tl \c_space_tl => \c_space_tl \c_space_tl + \exp_not:n {#2} + } +\cs_new_protected_nopar:Npn \xtemplate_show_values:nnn #1#2#3 + { + \xtemplate_if_instance_exist:nnnT {#1} {#2} {#3} + { + \xtemplate_recover_values:n { #1 / #2 / #3 } + \prop_if_empty:NTF \l_xtemplate_values_prop + { + \iow_term:x + { + \tl_if_empty:nTF {#2} + { Instance~'#3'~ } + { Collection instance~'#3'~(from~collection~'#2')~ } + of~object~type~'#1'~has~no~values. + } + \tl_show:n { } + } + { + \prop_pop:NnN \l_xtemplate_values_prop { from~template } + \l_xtemplate_tmp_tl + \iow_term:x + { + \tl_if_empty:nTF {#2} + { Instance~'#3'~ } + { Collection instance~'#3'~(from~collection~'#2')~ } + of~object~type~'#1' + \quark_if_no_value:NF \l_xtemplate_tmp_tl + { ~(from~template~' \l_xtemplate_tmp_tl ')~ } + has~values: + } + \tl_set:Nx \l_prop_show_tl + { + \prop_map_function:NN \l_xtemplate_values_prop + \xtemplate_show_aux:nn + } + \etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN + { \exp_after:wN \prop_show_aux:w \l_prop_show_tl } + } + } + } +\msg_new:nnnn { xtemplate } { argument-number-mismatch } + { Object~type~'#1'~takes~#2~argument(s). } + { + \c_msg_coding_error_text_tl + Objects~of~type~'#1'~require~#2~argument(s).\\ + You~have~tried~to~make~a~template~for~'#1'~ + with~#3~argument(s),~which~is~not~possible:~ + the~number~of~arguments~must~agree. + } +\msg_new:nnnn { xtemplate } { bad-number-of-arguments } + { Bad~number~of~arguments~for~object~type~'#1'. } + { + \c_msg_coding_error_text_tl + An~object~may~accept~between~0~and~9~arguments.\\ + You~asked~to~use~#2~arguments:~this~is~not~supported. + } +\msg_new:nnnn { xtemplate } { bad-variable } + { Incorrect~variable~description. } + { + The~argument~'#1'~is~not~of~the~form \\ + ~~''\\ + ~or~\\ + ~~'global~'.\\ + It~must~be~given~in~one~of~these~formats~to~be~used~in~a~template. + } +\msg_new:nnnn { xtemplate } { choice-not-implemented } + { The~choice~'#1'~has~no~implementation. } + { + Each~choice~listed~in~the~interface~for~a~template~must~ + have~an~implementation. + } +\msg_new:nnnn { xtemplate } { choice-no-code } + { The~choice~'#1'~requires~implementation~details. } + { + \c_msg_coding_error_text_tl + When~creating~template~code~using~\DeclareTemplateCode,~ + each~choice~name~must~have~an~associated~implementation.\\ + This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one. + } +\msg_new:nnnn { xtemplate } { duplicate-key-interface } + { Key~'#1'~appears~twice~in~interface~definition~\msg_line_context:. } + { + \c_msg_coding_error_text_tl + Each~key~can~only~have~one~interface~declared~in~a~template.\\ + LaTeX~found~two~interfaces~for~'#1'. + } +\msg_new:nnnn { xtemplate } { keytype-requires-argument } + { The~key~type~'#1'~requires~an~argument~\msg_line_context:. } + { + You~should~have~put:\\ + \ \ ~:~#1~{~~} \\ + but~LaTeX~did~not~find~an~. + } +\msg_new:nnnn { xtemplate } { invalid-keytype } + { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. } + { + \c_msg_coding_error_text_tl + Each~key~in~a~template~requires~a~key-type,~given~in~the~form:\\ + \ \ ~:~\\ + LaTeX~could~not~find~a~~in~your~input. + } +\msg_new:nnnn { xtemplate } { key-no-value } + { The~key~'#1'~has~no~value~\msg_line_context:. } + { + \c_msg_coding_error_text_tl + When~creating~an~instance~of~a~template~ + every~key~listed~must~include~a~value:\\ + \ \ ~=~ + } +\msg_new:nnnn { xtemplate } { key-no-variable } + { The~key~'#1'~requires~implementation~details~\msg_line_context:. } + { + \c_msg_coding_error_text_tl + When~creating~template~code~using~\DeclareTemplateCode,~ + each~key~name~must~have~an~associated~implementation.\\ + This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one. + } +\msg_new:nnnn { xtemplate } { key-not-implemented } + { Key~'#1'~has~no~implementation~\msg_line_context:. } + { + \c_msg_coding_error_text_tl + The~definition~of~key~implementations~for~template~'#2'~ + of~object~type~'#3'~does~not~include~any~details~for~key~'#1'.\\ + The~key~was~declared~in~the~interface~definition,~ + and~so~an~implementation~is~required. + } +\msg_new:nnnn { xtemplate } { missing-keytype } + { The~key~'#1'~is missing~a~key-type~\msg_line_context:. } + { + \c_msg_coding_error_text_tl + Key~interface~definitions~should~be~of~the~form\\ + \ \ #1~:~\\ + but~LaTeX~could~not~find~a~. + } +\msg_new:nnnn { xtemplate } { no-template-code } + { + The~template~'#2'~of~type~'#1'~is~unknown~ + or~has~no~implementation. + } + { + \c_msg_coding_error_text_tl + There~is~no~code~available~for~the~template~name~given.\\ + This~should~be~given~using~\DeclareTemplateCode. + } +\msg_new:nnnn { xtemplate } { object-type-mismatch } + { Object~types~'#1'~and~'#2'~do~not~agree. } + { + You~are~trying~to~use~a~template~directly~with~\UseInstance + (or~a~similar~function),~but~the~object~types~do~not~match. + } +\msg_new:nnnn { xtemplate } { unknown-attribute } + { The~template~attribute~'#1'~is~unknown. } + { + There~is~a~definition~in~the~current~template~reading\\ + \ \ \token_to_str:N \KeyValue {~#1~} \\ + but~there~is~no~key~called~'#1'. + } +\msg_new:nnnn { xtemplate } { unknown-choice } + { The~choice~'#2'~was~not~declared~for~key~'#1'. } + { + The~key~'#1'~takes~a~fixed~list~of~choices~ + and~this~list~does~not~include~'#2'. + } +\msg_new:nnnn { xtemplate } { unknown-default-choice } + { The~default~choice~'#2'~was~not~declared~for~key~'#1'. } + { + The~key~'#1'~takes~a~fixed~list~of~choices~ + and~this~list~does~not~include~'#2'. + } +\msg_new:nnnn { xtemplate } { unknown-instance } + { The~instance~'#2'~of~type~'#1'~is~unknown. } + { + You~have~asked~to~use~an~instance~'#2',~ + but~this~has~not~been~created. + } +\msg_new:nnnn { xtemplate } { unknown-key } + { Unknown~template~key~'#1'. } + { + \c_msg_coding_error_text_tl + The~key~'#1'~was~not~declared~in~the~interface~ + for~the~current~template. + } +\msg_new:nnnn { xtemplate } { unknown-keytype } + { The~key-type~'#1'~is~unknown. } + { + \c_msg_coding_error_text_tl + Valid~key-types~are:\\ + -~boolean;\\ + -~choice;\\ + -~code;\\ + -~commalist;\\ + -~function;\\ + -~instance;\\ + -~integer;\\ + -~length;\\ + -~muskip;\\ + -~real;\\ + -~skip;\\ + -~tokenlist. + } +\msg_new:nnnn { xtemplate } { unknown-object-type } + { The~object~type~'#1'~is~unknown. } + { + \c_msg_coding_error_text_tl + An~object~type~needs~to~be~declared~with~\DeclareObjectType + prior~to~using~it. + } +\msg_new:nnnn { xtemplate } { unknown-template } + { The~template~'#2'~of~type~'#1'~is~unknown. } + { + No~interface~has~been~declared~for~a~template~ + '#2'~of~object~type~'#1'. + } +\msg_new:nnnn { xtemplate } { variable-not-declared } + { The~variable~'#1'~has~not~been~declared. } + { + Before~declaring~an~instance,~all~of~the~required~variables~ + used~in~template~keys~must~be~created. + } +\msg_new:nnn { xtemplate } { declare-object-type } + { Declaring~object~type~'#1'~taking~#2~argument(s)~\msg_line_context:. } +\msg_new:nnn { xtemplate } { declare-template-code } + { Declaring~code~for~template~'#2'~of~object~type'#1'~\msg_line_context:. } +\msg_new:nnn { xtemplate } { declare-template-interface } + { + Declaring~interface~for~template~'#2'~of~object~type~'#1'~ + \msg_line_context:. + } +\cs_new_protected_nopar:Npn \DeclareObjectType #1#2 + { \xtemplate_declare_object_type:nn {#1} {#2} } +\cs_new_protected:Npn \DeclareTemplateInterface #1#2#3#4 + { \xtemplate_declare_template_keys:nnnn {#1} {#2} {#3} {#4} } +\cs_new_protected:Npn \DeclareTemplateCode #1#2#3#4#5 + { \xtemplate_declare_template_code:nnnnn {#1} {#2} {#3} {#4} {#5} } +\cs_new_protected:Npn \DeclareRestrictedTemplate #1#2#3#4 + { \xtemplate_declare_restricted:nnnn {#1} {#2} {#3} {#4} } +\cs_new_protected:Npn \DeclareInstance #1#2#3#4 + { \xtemplate_declare_instance:nnnnn {#1} {#3} { } {#2} {#4} } +\cs_new_protected:Npn \DeclareCollectionInstance #1#2#3#4#5 + { \xtemplate_declare_instance:nnnnn {#2} {#4} {#1} {#3} {#5} } +\cs_new_protected:Npn \EditTemplateDefaults #1#2#3 + { \xtemplate_edit_defaults:nnn {#1} {#2} {#3} } +\cs_new_protected:Npn \EditInstance #1#2#3 + { \xtemplate_edit_instance:nnnn {#1} { } {#2} {#3} } +\cs_new_protected:Npn \EditCollectionInstance #1#2#3#4 + { \xtemplate_edit_instance:nnnn {#2} {#1} {#3} {#4} } +\cs_new_protected_nopar:Npn \UseTemplate #1#2#3 + { \xtemplate_use_template:nnn {#1} {#2} {#3} } +\cs_new_protected_nopar:Npn \UseInstance #1#2 + { \xtemplate_use_instance:nn {#1} {#2} } +\cs_new_protected_nopar:Npn \UseCollection #1#2 + { \xtemplate_use_collection:nn {#1} {#2} } +\cs_new_protected_nopar:Npn \ShowTemplateCode #1#2 + { \xtemplate_show_code:nn {#1} {#2} } +\cs_new_protected_nopar:Npn \ShowTemplateDefaults #1#2 + { \xtemplate_show_defaults:nn {#1} {#2} } +\cs_new_protected_nopar:Npn \ShowTemplateInterface #1#2 + { \xtemplate_show_keytypes:nn {#1} {#2} } +\cs_new_protected_nopar:Npn \ShowTemplateVariables #1#2 + { \xtemplate_show_vars:nn {#1} {#2} } +\cs_new_protected_nopar:Npn \ShowInstanceValues #1#2 + { \xtemplate_show_values:nnn {#1} { } {#2} } +\cs_new_protected_nopar:Npn \ShowCollectionInstanceValues #1#2#3 + { \xtemplate_show_values:nnn {#1} {#2} {#3} } +\cs_new_nopar:Npn \IfInstanceExistTF #1#2 + { \xtemplate_if_instance_exist:nnnTF {#1} { } {#2} } +\cs_new_nopar:Npn \IfInstanceExistT #1#2 + { \xtemplate_if_instance_exist:nnnT {#1} { } {#2} } +\cs_new_nopar:Npn \IfInstanceExistF #1#2 + { \xtemplate_if_instance_exist:nnnF {#1} { } {#2} } +\cs_new_protected:Npn \EvaluateNow #1 {#1} +\cs_new_protected:Npn \KeyValue #1 {#1} +\cs_new_protected_nopar:Npn \AssignTemplateKeys + { \xtemplate_assignments_pop: } +\cs_new_eq:NN \ShowTemplateKeytypes \ShowTemplateInterface +%% +%% +%% End of file `xtemplate.sty'. -- cgit v1.2.3