summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3/l3tl.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3tl.dtx')
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3tl.dtx313
1 files changed, 54 insertions, 259 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3tl.dtx b/Master/texmf-dist/source/latex/expl3/l3tl.dtx
index 24b80f731bb..c7c84a531ae 100644
--- a/Master/texmf-dist/source/latex/expl3/l3tl.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3tl.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3tl.dtx 1919 2010-05-22 05:56:38Z will $
+\GetIdInfo$Id: l3tl.dtx 2040 2010-09-21 18:11:09Z joseph $
{L3 Experimental Token Lists}
%\iffalse
%<*driver>
@@ -380,51 +380,6 @@
% \end{function}
%
%
-% \begin{function}{\tl_if_eq:nn / (TF)(EXP) |
-% \tl_if_eq:nV / (TF)(EXP) |
-% \tl_if_eq:no / (TF)(EXP) |
-% \tl_if_eq:Vn / (TF)(EXP) |
-% \tl_if_eq:on / (TF)(EXP) |
-% \tl_if_eq:VV / (TF)(EXP) |
-% \tl_if_eq:oo / (TF)(EXP) |
-% \tl_if_eq:xx / (TF)(EXP) |
-% \tl_if_eq:xn / (TF)(EXP) |
-% \tl_if_eq:nx / (TF)(EXP) |
-% \tl_if_eq:xV / (TF)(EXP) |
-% \tl_if_eq:xo / (TF)(EXP) |
-% \tl_if_eq:Vx / (TF)(EXP) |
-% \tl_if_eq:ox / (TF)(EXP) }
-% \begin{syntax}
-% "\tl_if_eq:nnTF" \Arg{tlist1} \Arg{tlist2} \Arg{true code} \Arg{false code}
-% \end{syntax}
-% Execute <true code> if the two token lists <tlist1> and <tlist2> are
-% identical. These functions are expandable if a new enough version of
-% pdf\TeX\ is being used.
-% \end{function}%
-%
-% \begin{function}{\tl_if_eq_p:nn / (EXP) |
-% \tl_if_eq_p:nV / (EXP) |
-% \tl_if_eq_p:no / (EXP) |
-% \tl_if_eq_p:Vn / (EXP) |
-% \tl_if_eq_p:on / (EXP) |
-% \tl_if_eq_p:VV / (EXP) |
-% \tl_if_eq_p:oo / (EXP) |
-% \tl_if_eq_p:xx / (EXP) |
-% \tl_if_eq_p:xn / (EXP) |
-% \tl_if_eq_p:nx / (EXP) |
-% \tl_if_eq_p:xV / (EXP) |
-% \tl_if_eq_p:xo / (EXP) |
-% \tl_if_eq_p:Vx / (EXP) |
-% \tl_if_eq_p:ox / (EXP) }
-% \begin{syntax}
-% "\tl_if_eq_p:nn" \Arg{tlist1} \Arg{tlist2}
-% \end{syntax}
-% Predicates function which returns `true' if the two token list
-% are identical and `false' otherwise. These are only defined if a new enough version
-% of pdf\TeX\ is in use.
-% \end{function}
-%
-%
% \begin{function}{\tl_if_empty_p:n / (EXP) |
% \tl_if_empty_p:V / (EXP) |
% \tl_if_empty_p:o / (EXP) |
@@ -438,6 +393,18 @@
% Execute <true code> if <\tlist> doesn't contain any tokens and <false
% code> otherwise.
% \end{function}
+%
+%\begin{function}{ \tl_if_eq:nn / (TF) }
+% \begin{syntax}
+% \cs{tl_if_eq:nnTF} \meta{token list1} \Arg{token list2} \Arg{true code}
+% ~~\Arg{false code}
+% \end{syntax}
+% Tests if \meta{token list1} and \meta{token list2} both in
+% respect of character codes and category codes. Either the
+% \meta{true code} or \meta{false code} in the input stream, as
+% appropriate to the truth of the test and the variant of the function
+% chosen.
+%\end{function}
%
% \begin{function}{\tl_if_blank_p:n / (EXP)|
% \tl_if_blank:n / (TF)(EXP)|
@@ -752,13 +719,13 @@
% \begin{syntax}
% "\tl_head:n" "{" <token1><token2>...<token\,$\sb k$> "}" \\
% "\tl_tail:n" "{" <token1><token2>...<token\,$\sb k$> "}" \\
-% "\tl_head:w" <token1><token2>...<token\,$\sb k$> "\q_nil"
+% "\tl_head:w" <token1><token2>...<token\,$\sb k$> "\q_stop"
% \end{syntax}
% These functions return either the head or the tail from a list of tokens, thus in
% the above example "\tl_head:n" would return <token1> and "\tl_tail:n"
% would return <token2>\dots<token\,$\sb k$>. "\tl_head_iii:n" returns the first
% three tokens. The ":w" versions require some care as they expect the token
-% list to be delimited by "\q_nil".
+% list to be delimited by "\q_stop".
% \begin{texnote}
% These are the Lisp functions "car" and "cdr" but with \LaTeX3 names.
% \end{texnote}
@@ -1395,6 +1362,30 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
+%
+%\begin{macro}[TF]{\tl_if_eq:nn}
+%\begin{macro}[aux]{\l_tl_tmpa_tl}
+%\begin{macro}[aux]{\l_tl_tmpb_tl}
+% A simple store and compare routine.
+% \begin{macrocode}
+\prg_new_protected_conditional:Npnn \tl_if_eq:nn #1#2 { T , F , TF } {
+ \group_begin:
+ \tl_set:Nn \l_tl_tmpa_tl {#1}
+ \tl_set:Nn \l_tl_tmpb_tl {#2}
+ \tex_ifx:D \l_tl_tmpa_tl \l_tl_tmpb_tl
+ \group_end:
+ \prg_return_false:
+ \tex_else:D
+ \group_end:
+ \prg_return_false:
+ \tex_fi:D
+}
+\tl_new:N \l_tl_tmpa_tl
+\tl_new:N \l_tl_tmpb_tl
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%
%
% \begin{macro}{\tl_if_empty_p:n,\tl_if_empty_p:V,\tl_if_empty_p:o}
@@ -1441,9 +1432,9 @@
% problem as the solutions in ``Around the Bend No~2''.
% \begin{macrocode}
\prg_new_conditional:Npnn \tl_if_blank:n #1 {p,TF,T,F} {
- \exp_after:wN \tl_if_blank_p_aux:w \tl_to_str:n {#1} aa..\q_nil
+ \exp_after:wN \tl_if_blank_p_aux:w \tl_to_str:n {#1} aa..\q_stop
}
-\cs_new:Npn \tl_if_blank_p_aux:w #1#2 a #3#4 \q_nil {
+\cs_new:Npn \tl_if_blank_p_aux:w #1#2 a #3#4 \q_stop {
\if_meaning:w #3 #4 \prg_return_true: \else: \prg_return_false: \fi:
}
\cs_generate_variant:Nn \tl_if_blank_p:n {V}
@@ -1471,7 +1462,7 @@
\tl_if_blank:nTF {#1}
{\prg_return_true:}
{
- \_tl_if_single_aux:w #1 \q_nil
+ \_tl_if_single_aux:w #1 \q_stop
}
}
}
@@ -1487,14 +1478,14 @@
\exp_after:wN \tl_if_blank:nTF #1
{\prg_return_true:}
{
- \exp_after:wN \_tl_if_single_aux:w #1 \q_nil
+ \exp_after:wN \_tl_if_single_aux:w #1 \q_stop
}
}
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \_tl_if_single_aux:w #1#2 \q_nil {
+\cs_new:Npn \_tl_if_single_aux:w #1#2 \q_stop {
\tl_if_empty:nTF {#2} \prg_return_true: \prg_return_false:
}
% \end{macrocode}
@@ -1502,202 +1493,6 @@
% \end{macro}
%
%
-% \begin{macro}[TF]{\tl_if_eq:xx,\tl_if_eq:nn,\tl_if_eq:VV,\tl_if_eq:oo,
-% \tl_if_eq:xn,\tl_if_eq:nx,\tl_if_eq:on,\tl_if_eq:no,
-% \tl_if_eq:Vn,\tl_if_eq:nV,
-% \tl_if_eq:xV,\tl_if_eq:xo,\tl_if_eq:Vx,\tl_if_eq:ox}
-% \begin{macro}{\tl_if_eq_p:xx,\tl_if_eq_p:nn,\tl_if_eq_p:VV,\tl_if_eq_p:oo,
-% \tl_if_eq_p:xn,\tl_if_eq_p:nx,\tl_if_eq_p:Vn,\tl_if_eq_p:on,
-% \tl_if_eq_p:nV,\tl_if_eq_p:no,\tl_if_eq_p:xV,\tl_if_eq_p:Vx,
-% \tl_if_eq_p:xo,\tl_if_eq_p:ox}
-% Test if two token lists are identical. pdf\TeX\ contains a most
-% interesting primitive for expandable string comparison so we make
-% use of it if available. Presumable it will be in the final
-% version.
-%
-% Firstly we give it an appropriate name. Note that this primitive
-% actually performs an \texttt{x} type expansion but it is still
-% expandable! Hence we must program these functions backwards to add
-% \verb|\exp_not:n|. We provide the combinations for the types
-% \texttt{n}, \texttt{o} and \texttt{x}.
-% \begin{macrocode}
-\cs_new_eq:NN \tl_compare:xx \pdf_strcmp:D
-\cs_new:Npn \tl_compare:nn #1#2{
- \tl_compare:xx{\exp_not:n{#1}}{\exp_not:n{#2}}
-}
-\cs_new:Npn \tl_compare:nx #1{
- \tl_compare:xx{\exp_not:n{#1}}
-}
-\cs_new:Npn \tl_compare:xn #1#2{
- \tl_compare:xx{#1}{\exp_not:n{#2}}
-}
-\cs_new:Npn \tl_compare:nV #1#2 {
- \tl_compare:xx { \exp_not:n {#1} } { \exp_not:V #2 }
-}
-\cs_new:Npn \tl_compare:no #1#2{
- \tl_compare:xx{\exp_not:n{#1}}{\exp_not:n\exp_after:wN{#2}}
-}
-\cs_new:Npn \tl_compare:Vn #1#2 {
- \tl_compare:xx { \exp_not:V #1 } { \exp_not:n {#2} }
-}
-\cs_new:Npn \tl_compare:on #1#2{
- \tl_compare:xx{\exp_not:n\exp_after:wN{#1}}{\exp_not:n{#2}}
-}
-\cs_new:Npn \tl_compare:VV #1#2 {
- \tl_compare:xx { \exp_not:V #1 } { \exp_not:V #2 }
-}
-\cs_new:Npn \tl_compare:oo #1#2{
- \tl_compare:xx{\exp_not:n\exp_after:wN{#1}}{\exp_not:n\exp_after:wN{#2}}
-}
-\cs_new:Npn \tl_compare:xV #1#2 {
- \tl_compare:xx {#1} { \exp_not:V #2 }
-}
-\cs_new:Npn \tl_compare:xo #1#2{
- \tl_compare:xx{#1}{\exp_not:n\exp_after:wN{#2}}
-}
-\cs_new:Npn \tl_compare:Vx #1#2 {
- \tl_compare:xx { \exp_not:V #1 } {#2}
-}
-\cs_new:Npn \tl_compare:ox #1#2{
- \tl_compare:xx{\exp_not:n\exp_after:wN{#1}}{#2}
-}
-% \end{macrocode}
-% Since we have a lot of basically identical functions to define we
-% define one to define the rest. Unfortunately we aren't quite set up
-% to use the new \verb|\tl_map_inline:nn| function yet.
-% \begin{macrocode}
-\cs_set_nopar:Npn \tl_tmp:w #1 {
- \tl_set:Nx \l_kernel_tmpa_tl {
- \exp_not:N \prg_new_conditional:Npnn \exp_not:c {tl_if_eq:#1}
- ####1 ####2 {p,TF,T,F} {
- \exp_not:N \tex_ifnum:D
- \exp_not:c {tl_compare:#1} {####1}{####2}
- \exp_not:n{ =\c_zero \prg_return_true: \else: \prg_return_false: \fi: }
- }
- }
- \l_kernel_tmpa_tl
-}
-\tl_tmp:w{xx} \tl_tmp:w{nx} \tl_tmp:w{ox} \tl_tmp:w{Vx}
-\tl_tmp:w{xn} \tl_tmp:w{nn} \tl_tmp:w{on} \tl_tmp:w{Vn}
-\tl_tmp:w{xo} \tl_tmp:w{no} \tl_tmp:w{oo}
-\tl_tmp:w{xV} \tl_tmp:w{nV} \tl_tmp:w{VV}
-% \end{macrocode}
-% However all of this only makes sense if we actually have that
-% primitive. Therefore we disable it again if it is not there and
-% define \verb|\tl_if_eq:nn| the old fashioned (and unexpandable)
-% way.
-%
-% In some cases below, since arbitrary token lists could be being used in
-% this function, you can't assume (as token list variables usually do) that there won't be
-% any |#| tokens. Therefore, "\tl_set:Nx" and "\exp_not:n" is used instead
-% of plain "\tl_set:Nn".
-%
-% \begin{macrocode}
-\cs_if_exist:cF{pdf_strcmp:D}{
- \prg_set_protected_conditional:Npnn \tl_if_eq:nn #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {\exp_not:n{#1}}
- \tl_set:Nx \l_kernel_testb_tl {\exp_not:n{#2}}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:nV #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl { \exp_not:n {#1} }
- \tl_set:Nx \l_kernel_testb_tl { \exp_not:V #2 }
- \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:no #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {\exp_not:n{#1}}
- \tl_set:Nx \l_kernel_testb_tl {\exp_not:o{#2}}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:nx #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {\exp_not:n{#1}}
- \tl_set:Nx \l_kernel_testb_tl {#2}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:Vn #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl { \exp_not:V #1 }
- \tl_set:Nx \l_kernel_testb_tl { \exp_not:n{#2} }
- \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:on #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {\exp_not:o{#1}}
- \tl_set:Nx \l_kernel_testb_tl {\exp_not:n{#2}}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:VV #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl { \exp_not:V #1 }
- \tl_set:Nx \l_kernel_testb_tl { \exp_not:V #2 }
- \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:oo #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {\exp_not:o{#1}}
- \tl_set:Nx \l_kernel_testb_tl {\exp_not:o{#2}}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:Vx #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl { \exp_not:V #1 }
- \tl_set:Nx \l_kernel_testb_tl {#2}
- \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:ox #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {\exp_not:o{#1}}
- \tl_set:Nx \l_kernel_testb_tl {#2}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:xn #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {#1}
- \tl_set:Nx \l_kernel_testb_tl {\exp_not:n{#2}}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:xV #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {#1}
- \tl_set:Nx \l_kernel_testb_tl { \exp_not:V #2 }
- \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:xo #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {#1}
- \tl_set:Nx \l_kernel_testb_tl {\exp_not:o{#2}}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
- \prg_set_protected_conditional:Npnn \tl_if_eq:xx #1#2 {TF,T,F} {
- \tl_set:Nx \l_kernel_testa_tl {#1}
- \tl_set:Nx \l_kernel_testb_tl {#2}
- \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
- \prg_return_true: \else: \prg_return_false:
- \fi:
- }
-}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-%
% \subsection{Working with the contents of token lists}
%
%
@@ -2232,16 +2027,16 @@
% These functions pick up either the head or the tail of a list.
% "\tl_head_iii:n" returns the first three items on a list.
% \begin{macrocode}
-\cs_new:Npn \tl_head:n #1{\tl_head:w #1\q_nil}
+\cs_new:Npn \tl_head:n #1{\tl_head:w #1\q_stop}
\cs_new_eq:NN \tl_head_i:n \tl_head:n
-\cs_new:Npn \tl_tail:n #1{\tl_tail:w #1\q_nil}
+\cs_new:Npn \tl_tail:n #1{\tl_tail:w #1\q_stop}
\cs_generate_variant:Nn \tl_tail:n {f}
-\cs_new:Npn \tl_head_iii:n #1{\tl_head_iii:w #1\q_nil}
+\cs_new:Npn \tl_head_iii:n #1{\tl_head_iii:w #1\q_stop}
\cs_generate_variant:Nn \tl_head_iii:n {f}
-\cs_new_eq:NN \tl_head:w \use_i_delimit_by_q_nil:nw
+\cs_new:Npn \tl_head:w #1#2\q_stop{#1}
\cs_new_eq:NN \tl_head_i:w \tl_head:w
-\cs_new:Npn \tl_tail:w #1#2\q_nil{#2}
-\cs_new:Npn \tl_head_iii:w #1#2#3#4\q_nil{#1#2#3}
+\cs_new:Npn \tl_tail:w #1#2\q_stop{#2}
+\cs_new:Npn \tl_head_iii:w #1#2#3#4\q_stop{#1#2#3}
\cs_generate_variant:Nn \tl_head:n { V }
\cs_generate_variant:Nn \tl_tail:n { V }
% \end{macrocode}
@@ -2277,7 +2072,7 @@
% equal but would also regard two primitives as equal.
% \begin{macrocode}
\prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 {p,TF,T,F} {
- \exp_after:wN \if_meaning:w \tl_head:w #1 \q_nil #2
+ \exp_after:wN \if_meaning:w \tl_head:w #1 \q_stop #2
\prg_return_true: \else: \prg_return_false: \fi:
}
% \end{macrocode}
@@ -2287,14 +2082,14 @@
% \begin{macrocode}
\prg_new_conditional:Npnn \tl_if_head_eq_charcode:nN #1#2 {p,TF,T,F} {
\exp_after:wN \if:w \exp_after:wN \exp_not:N
- \tl_head:w #1 \q_nil \exp_not:N #2
+ \tl_head:w #1 \q_stop \exp_not:N #2
\prg_return_true: \else: \prg_return_false: \fi:
}
% \end{macrocode}
% Actually the default is already an |f| type expansion.
% \begin{macrocode}
%% \cs_new:Npn \tl_if_head_eq_charcode_p:fN #1#2{
-%% \exp_after:wN\if_charcode:w \tl_head:w #1\q_nil\exp_not:N#2
+%% \exp_after:wN\if_charcode:w \tl_head:w #1\q_stop\exp_not:N#2
%% \c_true_bool
%% \else:
%% \c_false_bool
@@ -2314,7 +2109,7 @@
% \begin{macrocode}
\prg_new_conditional:Npnn \tl_if_head_eq_catcode:nN #1#2 {p,TF,T,F} {
\exp_after:wN \if_catcode:w \exp_after:wN \exp_not:N
- \tl_head:w #1 \q_nil \exp_not:N #2
+ \tl_head:w #1 \q_stop \exp_not:N #2
\prg_return_true: \else: \prg_return_false: \fi:
}
% \end{macrocode}