diff options
author | Karl Berry <karl@freefriends.org> | 2012-12-21 23:31:35 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-12-21 23:31:35 +0000 |
commit | 8bcf0c7ef3cd19666c206271cea9280846b5c7e6 (patch) | |
tree | ee538c7e2a14ad105a169fdd2e745356147577cc /Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | |
parent | ef0453041a9700a2d974c3c76e3398e40c4e4aeb (diff) |
l3 (21dec12)
git-svn-id: svn://tug.org/texlive/trunk@28608 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | 105 |
1 files changed, 74 insertions, 31 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index c86a1ebeef2..4aa22e27714 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3candidates.dtx 4298 2012-11-09 13:34:43Z joseph $ +\GetIdInfo$Id: l3candidates.dtx 4383 2012-12-20 15:10:48Z bruno $ {L3 Experimental additions to l3kernel} %</driver|package> %<*driver> @@ -803,7 +803,7 @@ % \meta{char} is again made active). % \end{function} % -% \begin{function}[TF]{\peek_N_type:} +% \begin{function}[TF, updated = 2012-12-20]{\peek_N_type:} % \begin{syntax} % \cs{peek_N_type:TF} \Arg{true code} \Arg{false code} % \end{syntax} @@ -812,7 +812,8 @@ % if the next \meta{token} is either an explicit or implicit % begin-group or end-group token (with any character code), or % an explicit or implicit space character (with character code $32$ -% and category code $10$), and \meta{true} in all other cases. +% and category code $10$), or an outer token (never used in \LaTeX3) +% and \meta{true} in all other cases. % Note that a \meta{true} result ensures that the next \meta{token} is % a valid \texttt{N}-type argument. However, if the next \meta{token} % is for instance \cs{c_space_token}, the test will take the @@ -1629,14 +1630,14 @@ % % \begin{macro}[EXP]{\clist_use:Nnnn} % \begin{macro}[EXP, aux] -% {\@@_use:wwn, \@@_use_ii:nwwwwnwn, \@@_use_iii:nwwn} +% {\@@_use:wwn, \@@_use:nwwwwnwn, \@@_use:nwwn} % First check that the variable exists. Then count the items in the % comma list. If it has none, output nothing. If it has one item, % output that item, brace stripped (note that space-trimming has % already been done when the comma list was assigned). If it has two, % place the \meta{separator~between~two} in the middle. % -% Otherwise, \cs{@@_use_ii:nwwwwnwn} takes the following arguments; 1: +% Otherwise, \cs{@@_use:nwwwwnwn} takes the following arguments; 1: % a \meta{separator}, 2, 3, 4: three items from the comma list (or % quarks), 5: the rest of the comma list, 6: a \meta{continuation} % function (\texttt{use_ii} or \texttt{use_iii} with its @@ -1664,20 +1665,20 @@ { 2 } { \exp_after:wN \@@_use:wwn #1 , {#2} } } { - \exp_after:wN \@@_use_ii:nwwwwnwn + \exp_after:wN \@@_use:nwwwwnwn \exp_after:wN { \exp_after:wN } #1 , - \q_mark , { \@@_use_ii:nwwwwnwn {#3} } - \q_mark , { \@@_use_iii:nwwn {#4} } + \q_mark , { \@@_use:nwwwwnwn {#3} } + \q_mark , { \@@_use:nwwn {#4} } \q_stop { } } } { \__msg_kernel_expandable_error:nnn { kernel } { bad-variable } {#1} } } \cs_new:Npn \@@_use:wwn #1 , #2 , #3 { \exp_not:n { #1 #3 #2 } } -\cs_new:Npn \@@_use_ii:nwwwwnwn +\cs_new:Npn \@@_use:nwwwwnwn #1#2 , #3 , #4 , #5 \q_mark , #6#7 \q_stop #8 { #6 {#3} , {#4} , #5 \q_mark , {#6} #7 \q_stop { #8 #1 #2 } } -\cs_new:Npn \@@_use_iii:nwwn #1#2 , #3 \q_stop #4 +\cs_new:Npn \@@_use:nwwn #1#2 , #3 \q_stop #4 { \exp_not:n { #4 #1 #2 } } % \end{macrocode} % \end{macro} @@ -2526,7 +2527,7 @@ % % \begin{macro}[EXP]{\seq_use:Nnnn} % \begin{macro}[EXP, aux] -% {\@@_use:NnNnn, \@@_use_ii:nwwwwnwn, \@@_use_iii:nwwn} +% {\@@_use:NnNnn, \@@_use:nwwwwnwn, \@@_use:nwwn} % See \cs{clist_use:Nnnn} for a general explanation. The main % difference is that we use \cs{@@_item:n} as a delimiter rather than % commas. We also need to add \cs{@@_item:n} at various places. @@ -2542,10 +2543,10 @@ { 2 } { \exp_after:wN \@@_use:NnNnn #1 {#2} } } { - \exp_after:wN \@@_use_ii:nwwwwnwn + \exp_after:wN \@@_use:nwwwwnwn \exp_after:wN { \exp_after:wN } #1 \@@_item:n - \q_mark { \@@_use_ii:nwwwwnwn {#3} } - \q_mark { \@@_use_iii:nwwn {#4} } + \q_mark { \@@_use:nwwwwnwn {#3} } + \q_mark { \@@_use:nwwn {#4} } \q_stop { } } } @@ -2553,14 +2554,14 @@ } \cs_new:Npn \@@_use:NnNnn \@@_item:n #1 \@@_item:n #2#3 { \exp_not:n { #1 #3 #2 } } -\cs_new:Npn \@@_use_ii:nwwwwnwn +\cs_new:Npn \@@_use:nwwwwnwn #1 \@@_item:n #2 \@@_item:n #3 \@@_item:n #4#5 \q_mark #6#7 \q_stop #8 { #6 \@@_item:n {#3} \@@_item:n {#4} #5 \q_mark {#6} #7 \q_stop { #8 #1 #2 } } -\cs_new:Npn \@@_use_iii:nwwn #1 \@@_item:n #2 #3 \q_stop #4 +\cs_new:Npn \@@_use:nwwn #1 \@@_item:n #2 #3 \q_stop #4 { \exp_not:n { #4 #1 #2 } } % \end{macrocode} % \end{macro} @@ -2835,24 +2836,66 @@ % \end{macrocode} % % \begin{macro}[TF]{\peek_N_type:} -% \begin{macro}{\@@_execute_branches_N_type:} -% The next token is normal if it is neither a begin-group token, -% nor an end-group token, nor a charcode-$32$ space token. -% Note that implicit begin-group tokens, end-group tokens, and -% spaces are also recognized as non-\texttt{N}-type. -% Here, there is no \meta{search token}, so we feed a dummy -% \cs{scan_stop:} to the \cs{peek_token_generic::NN} functions. +% \begin{macro}[aux] +% {\@@_execute_branches_N_type:, \@@_N_type:w, \@@_N_type_aux:nnw} +% All tokens are \texttt{N}-type tokens, except in four cases: +% begin-group tokens, end-group tokens, space tokens with character +% code~$32$, and outer tokens. Since \cs{l_peek_token} might be +% outer, we cannot use the convenient \cs{bool_if:nTF} function, and +% must resort to the old trick of using \tn{ifodd} to expand a set of +% tests. The \texttt{false} branch of this test is taken if the token +% is one of the first three kinds of non-\texttt{N}-type tokens +% (explicit or implicit), thus we call \cs{@@_false:w}. In the +% \texttt{true} branch, we must detect outer tokens, without impacting +% performance too much for non-outer tokens. The first filter is to +% search for \texttt{outer} in the \tn{meaning} of \cs{l_peek_token}. +% If that is absent, \cs{use_none_delimit_by_q_stop:w} cleans up, and +% we call \cs{@@_true:w}. Otherwise, the token can be a non-outer +% macro or a primitive mark whose parameter or replacement text +% contains \texttt{outer}, it can be the primitive \tn{outer}, or it +% can be an outer token. Macros and marks would have \texttt{ma} in +% the part before the first occurrence of \texttt{outer}; the meaning +% of \tn{outer} has nothing after \texttt{outer}, contrarily to outer +% macros; and that covers all cases, calling \cs{@@_true:w} or +% \cs{@@_false:w} as appropriate. Here, there is no \meta{search +% token}, so we feed a dummy \cs{scan_stop:} to the +% \cs{@@_token_generic:NNTF} function. % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_execute_branches_N_type: +\group_begin: + \char_set_catcode_other:N \O + \char_set_catcode_other:N \U + \char_set_catcode_other:N \T + \char_set_catcode_other:N \E + \char_set_catcode_other:N \R + \tl_to_lowercase:n + { + \cs_new_protected_nopar:Npn \@@_execute_branches_N_type: + { + \if_int_odd:w + \if_catcode:w \exp_not:N \l_peek_token { \c_two \fi: + \if_catcode:w \exp_not:N \l_peek_token } \c_two \fi: + \if_meaning:w \l_peek_token \c_space_token \c_two \fi: + \c_one + \exp_after:wN \@@_N_type:w + \token_to_meaning:N \l_peek_token + \q_mark \@@_N_type_aux:nnw + OUTER \q_mark \use_none_delimit_by_q_stop:w + \q_stop + \exp_after:wN \@@_true:w + \else: + \exp_after:wN \@@_false:w + \fi: + } + \cs_new_protected_nopar:Npn \@@_N_type:w #1 OUTER #2 \q_mark #3 + { #3 {#1} {#2} } + } +\group_end: +\cs_new_protected_nopar:Npn \@@_N_type_aux:nnw #1 #2 #3 \fi: { - \bool_if:nTF - { - \token_if_eq_catcode_p:NN \l_peek_token \c_group_begin_token || - \token_if_eq_catcode_p:NN \l_peek_token \c_group_end_token || - \token_if_eq_meaning_p:NN \l_peek_token \c_space_token - } - { \@@_false:w } + \fi: + \tl_if_in:noTF {#1} { \tl_to_str:n {ma} } { \@@_true:w } + { \tl_if_empty:nTF {#2} { \@@_true:w } { \@@_false:w } } } \cs_new_protected_nopar:Npn \peek_N_type:TF { \@@_token_generic:NNTF \@@_execute_branches_N_type: \scan_stop: } |