diff options
author | Karl Berry <karl@freefriends.org> | 2016-11-22 22:50:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-11-22 22:50:16 +0000 |
commit | f476e2547d6f421f3f59e812adb855596f668eb5 (patch) | |
tree | 859e615afe313dc934f3ca679cd4ea760e356f98 /Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx | |
parent | 4061b69b7a85fc322821dbfc8beb83b498542e45 (diff) |
l3 (22nov16)
git-svn-id: svn://tug.org/texlive/trunk@42556 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx | 314 |
1 files changed, 169 insertions, 145 deletions
diff --git a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx index 3a142e32fa9..00f10f1c432 100644 --- a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx +++ b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx @@ -41,8 +41,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{xparse}{Support package l3kernel too old} @@ -56,8 +56,8 @@ %<package> } \def\ExplFileName{xparse} \def\ExplFileDescription{L3 Experimental document command parser} -\def\ExplFileDate{2016/10/19} -\def\ExplFileVersion{6730} +\def\ExplFileDate{2016/11/21} +\def\ExplFileVersion{6760} %</driver|package> %<*driver> \documentclass[full]{l3doc} @@ -195,12 +195,14 @@ % |-NoValue-| if not present. % \item[G] As for \texttt{g} but returns \meta{default} if no value % is given: \texttt{G}\marg{default}. -% \item[k] An optional \emph{key} argument which requires a \emph{value}: -% the key should be a single \meta{token}. If the key is not present, -% returns |-NoValue-|. \emph{This is an experimental type}. -% \item[K] As for \texttt{K} but returns \meta{default} if no value -% is given: \texttt{K}\meta{token}\marg{default}. +% \item[e] An optional set of \emph{embellishments}, each of which requires a +% \emph{value}. If a key is not present, |-NoValue-| is returned. +% The returned data is a token list comprising one braced entry per key, +% ordered as for the key list in the signature. % \emph{This is an experimental type}. +% \item[E] As for \texttt{E} but returns one or more \meta{defaults} +% if values are not given: \texttt{E}\marg{defaults}. See +% Section~\ref{sec:embellishment} for more details. % \end{itemize} % % Using these specifiers, it is possible to create complex input syntax @@ -484,6 +486,25 @@ % take based on this information. % \end{function} % +% \subsection{Default values for \enquote{embellishments}} +% \label{sec:embellishment} +% +% The \texttt{E}-type argument allows one default value per test token. +% This is achieved by giving a list of defaults for each entry in the +% list, for example: +% \begin{verbatim} +% E{^_}{{UP}{DOWN}} +% \end{verbatim} +% If the list of default values is \emph{shorter} than the list of test tokens, +% the special \cs{NoValue} marker will be returned (as for the \texttt{e}-type +% argument). Thus for example +% \begin{verbatim} +% E{^_}{{UP}} +% \end{verbatim} +% has default \texttt{UP} for the |^| test token, but will return the +% \cs{NoValue} marker as a default for |_|. This allows mixing of explicit +% defaults with testing for missing values. +% % \subsection{Argument processors} % \label{sec:processors} % @@ -899,10 +920,12 @@ % \end{macrocode} % \end{variable} % -% \begin{variable}{\l_@@_tmp_tl} +% \begin{variable}{\l_@@_tmp_prop, \l_@@_tmpa_tl, \l_@@_tmpb_tl} % Scratch space. % \begin{macrocode} -\tl_new:N \l_@@_tmp_tl +\prop_new:N \l_@@_tmp_prop +\tl_new:N \l_@@_tmpa_tl +\tl_new:N \l_@@_tmpb_tl % \end{macrocode} % \end{variable} % @@ -1129,8 +1152,8 @@ \cs_new_protected:Npn \@@_count_mandatory:N #1 { \quark_if_recursion_tail_stop:N #1 - \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmp_tl - { \exp_after:wN \@@_count_mandatory:N \l_@@_tmp_tl } + \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmpa_tl + { \exp_after:wN \@@_count_mandatory:N \l_@@_tmpa_tl } { \@@_count_mandatory_aux:N #1 } } \cs_new_protected:Npn \@@_count_mandatory_aux:N #1 @@ -1149,10 +1172,10 @@ % \@@_count_type_+:w, % \@@_count_type_d:w, % \@@_count_type_D:w, +% \@@_count_type_e:w, +% \@@_count_type_E:w, % \@@_count_type_g:w, % \@@_count_type_G:w, -% \@@_count_type_k:w, -% \@@_count_type_K:w, % \@@_count_type_m:w, % \@@_count_type_r:w, % \@@_count_type_R:w, @@ -1202,23 +1225,21 @@ \quark_if_recursion_tail_stop_do:nn {#3} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_g:w - { \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_G:w #1 +\cs_new_protected:Npn \@@_count_type_e:w #1 { \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_k:w #1 +\cs_new_protected:Npn \@@_count_type_E:w #1#2 { - \@@_single_token_check:n {#1} - \quark_if_recursion_tail_stop_do:Nn #1 { \@@_bad_arg_spec:wn } + \quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_K:w #1#2 +\cs_new_protected:Npn \@@_count_type_g:w + { \@@_count_mandatory:N } +\cs_new_protected:Npn \@@_count_type_G:w #1 { - \@@_single_token_check:n {#1} - \quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn } + \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } \cs_new_protected:Npn \@@_count_type_m:w @@ -1320,8 +1341,8 @@ \cs_new_protected:Npn \@@_prepare_signature_bypass:N #1 { \quark_if_recursion_tail_stop:N #1 - \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmp_tl - { \exp_after:wN \@@_prepare_signature:N \l_@@_tmp_tl } + \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmpa_tl + { \exp_after:wN \@@_prepare_signature:N \l_@@_tmpa_tl } { \int_incr:N \l_@@_current_arg_int \@@_prepare_signature_add:N #1 @@ -1415,6 +1436,23 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_add_type_e:w, \@@_add_type_E:w} +% Setting up for the \texttt{e}-type argument is somewhat specialised as +% the |-NoValue-| tokens are inserted by the grabber rather than here. As +% such, all that is needed is to pass data straight through. +% \begin{macrocode} +\cs_new_protected:Npn \@@_add_type_e:w #1 + { \@@_add_type_E:w {#1} { } } +\cs_new_protected:Npn \@@_add_type_E:w #1#2 + { + \@@_flush_m_args: + \@@_add_grabber_optional:N E + \tl_put_right:Nn \l_@@_signature_tl { {#1} {#2} } + \@@_prepare_signature:N + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@@_add_type_g:w} % The \texttt{g} type is simply an alias for \texttt{G} with the correct % default built-in. @@ -1438,22 +1476,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_add_type_k:w, \@@_add_type_K:w} -% Similar to |d|/|D| type but just one token to store. -% \begin{macrocode} -\cs_new_protected:Npn \@@_add_type_k:w #1 - { \exp_args:NNo \@@_add_type_K:w #1 \c_@@_no_value_tl } -\cs_new_protected:Npn \@@_add_type_K:w #1#2 - { - \@@_flush_m_args: - \@@_add_grabber_optional:N K - \tl_put_right:Nn \l_@@_signature_tl { #1 {#2} } - \@@_prepare_signature:N - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\@@_add_type_l:w} % Finding \texttt{l} arguments is very simple: there is nothing to do % other than add the grabber. @@ -1728,34 +1750,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\@@_add_expandable_type_k:w} -% \begin{macro}{\@@_add_expandable_type_K:w} -% \begin{macrocode} -\cs_new_protected:Npn \@@_add_expandable_type_k:w #1 - { - \exp_args:NNo - \@@_add_expandable_type_K:w #1 \c_@@_no_value_tl - } -\cs_new_protected:Npn \@@_add_expandable_type_K:w #1#2 - { - \@@_add_expandable_grabber_optional:n { K } - \bool_if:NTF \l_@@_all_long_bool - { \cs_set:cpx } - { \cs_set_nopar:cpx } - { \l_@@_expandable_aux_name_tl } ##1 #1 ##2 - { ##1 {##2} } - \tl_put_right:Nx \l_@@_signature_tl - { - \exp_not:c { \l_@@_expandable_aux_name_tl } - \exp_not:n { #1 {#2} } - } - \bool_set_false:N \l_@@_long_bool - \@@_prepare_signature:N - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\@@_add_expandable_type_l:w} % Invalid in expandable contexts (as the next left brace may have been % inserted by \pkg{xparse} due to a failed search for an optional argument). @@ -2067,10 +2061,10 @@ { \@@_grab_D_nested:w \q_nil ##2 \q_stop } \tl_if_in:NnTF \l_@@_nesting_b_tl {#1} { - \tl_set_eq:NN \l_@@_tmp_tl \l_@@_nesting_b_tl + \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_nesting_b_tl \tl_clear:N \l_@@_nesting_b_tl \exp_after:wN \l_@@_fn_tl \exp_after:wN - \q_nil \l_@@_tmp_tl \q_nil \q_@@ \ERROR + \q_nil \l_@@_tmpa_tl \q_nil \q_@@ \ERROR } { \tl_put_right:No \l_@@_nesting_a_tl @@ -2091,6 +2085,109 @@ % \end{macro} % \end{macro} % +% \begin{macro} +% { +% \@@_grab_E:w, \@@_grab_E_long:w, +% \@@_grab_E_trailing:w, \@@_grab_E_long_trailing:w +% } +% \begin{macro}[aux]{\@@_grab_E:nnnNn} +% \begin{macro}[aux]{\@@_grab_E_setup:Nw} +% \begin{macro}[aux]{\@@_grab_E_loop:nnN} +% \begin{macro}[aux]{\@@_grab_E_finalise:} +% Everything here needs to point to a loop. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_E:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected_nopar:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \@@_grab_E_long:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \@@_grab_E_trailing:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected_nopar:Npn + { } + } +\cs_new_protected:Npn \@@_grab_E_long_trailing:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected:Npn + { } + } +% \end{macrocode} +% A loop is needed here to allow a random ordering of keys. These are +% searched for one at a time, with any not found needing to be tracked: +% they can appear later. The grabbed values are held in a property list +% which is then turned into an ordered list to be passed back to the user. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_E:nnnNn #1#2#3#4#5 + { + \exp_after:wN #4 \l_@@_fn_tl ##1##2##3 + { + \prop_put:Nnn \l_@@_tmp_prop {##1} {##3} + \@@_grab_E_loop:nnN {#5} { } ##2 \q_recursion_stop + } + \prop_clear:N \l_@@_tmp_prop + \@@_grab_E_setup:Nw + #1 \q_recursion_tail \q_mark #2 \q_recursion_tail \q_recursion_stop + \cs_set_protected:Npn \@@_grab_E_finalise: + { + \tl_clear:N \l_@@_tmpa_tl + \tl_map_inline:nn {#1} + { + \prop_get:NnNF \l_@@_tmp_prop {####1} \l_@@_tmpb_tl + { \tl_set_eq:NN \l_@@_tmpb_tl \c_@@_no_value_tl } + \tl_set:Nx \l_@@_tmpa_tl + { + \exp_not:V \l_@@_tmpa_tl + { \exp_not:V \l_@@_tmpb_tl } + } + } + \@@_add_arg:V \l_@@_tmpa_tl + #3 \l_@@_args_tl + } + \@@_grab_E_loop:nnN {#5} { } #1 \q_recursion_tail \q_recursion_stop + } +% \end{macrocode} +% To allow for flexible default values, the list of those given may be +% shorter than the number of test tokens. This can readily be achieved +% by storing only the given defaults in the property list. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_E_setup:Nw #1#2 \q_mark #3 + { + \quark_if_recursion_tail_stop:N #1 + \quark_if_recursion_tail_stop:n {#3} + \prop_put:Nnn \l_@@_tmp_prop {#1} {#3} + \@@_grab_E_setup:Nw #2 \q_mark + } +\cs_new_protected:Npn \@@_grab_E_loop:nnN #1#2#3#4 \q_recursion_stop + { + \cs_if_eq:NNTF #3 \q_recursion_tail + { \@@_grab_E_finalise: } + { + \use:c { peek_meaning_remove #1 :NTF } #3 + { \l_@@_fn_tl #3 {#2#4} } + { \@@_grab_E_loop:nnN {#1} {#2#3} #4 \q_recursion_stop } + } + } +\cs_new_protected:Npn \@@_grab_E_finalise: { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\@@_grab_G:w} % \begin{macro}{\@@_grab_G_long:w} % \begin{macro}{\@@_grab_G_trailing:w} @@ -2133,56 +2230,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\@@_grab_K:w, \@@_grab_K_long:w} -% \begin{macro}[aux]{\@@_grab_K_aux:nnnNn} -% Look ahead at one token and if it matches grab an argument. -% \begin{macrocode} -\cs_new_protected:Npn \@@_grab_K:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected_nopar:Npn - { _ignore_spaces } - } -\cs_new_protected:Npn \@@_grab_K_long:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected:Npn - { _ignore_spaces } - } -\cs_new_protected:Npn \@@_grab_K_trailing:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected_nopar:Npn - { } - } -\cs_new_protected:Npn \@@_grab_K_long_trailing:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected:Npn - { } - } -\cs_new_protected:Npn \@@_grab_K_aux:nnnNn #1#2#3#4#5 - { - \exp_after:wN #4 \l_@@_fn_tl ##1 - { - \@@_add_arg:n {##1} - #3 \l_@@_args_tl - } - \use:c { peek_meaning_remove #5 :NTF } #1 - { \l_@@_fn_tl } - { - \@@_add_arg:n {#2} - #3 \l_@@_args_tl - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\@@_grab_l:w} % \begin{macro}{\@@_grab_l_long:w} % \begin{macro}[aux]{\@@_grab_l_aux:nN} @@ -2901,29 +2948,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}[EXP]{\@@_expandable_grab_K:w} -% \begin{macro}[EXP, aux]{\@@_expandable_grab_K_aux:NNwn} -% As for the |D|-type grabber, use the auxiliary to do the look ahead -% test then reuse it for the grabbing. -% \begin{macrocode} -\cs_new:Npn \@@_expandable_grab_K:w #1 \q_@@ #2 - { #2 { \@@_expandable_grab_K_aux:NNwn #1 \q_@@ #2 } } -\cs_new:Npn \@@_expandable_grab_K_aux:NNwn #1#2#3#4 \q_@@ #5#6 - { - \str_if_eq:onTF { #1 { } #6 { } #2 { } } { { } #2 { } } - { - #1 - { \@@_expandable_grab_K_aux:Nwn #5 #4 \q_@@ } - #6 - } - { #4 {#3} \q_@@ #5 {#6} } - } -\cs_new:Npn \@@_expandable_grab_K_aux:Nwn #1#2 \q_@@ #3 - { #2 {#3} \q_@@ #1 } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}[EXP]{\@@_expandable_grab_m:w} % \begin{macro}[EXP, aux]{\@@_expandable_grab_m_aux:wNn} % The mandatory case is easy: find the auxiliary after the \cs{q_@@}, and |