summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx')
-rw-r--r--Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx68
1 files changed, 65 insertions, 3 deletions
diff --git a/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx b/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
index 32514be2fe1..45b7ab9bb96 100644
--- a/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
+++ b/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
@@ -41,7 +41,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: xparse.dtx 1897 2010-04-26 05:56:56Z joseph $
+\GetIdInfo$Id: xparse.dtx 1905 2010-05-19 07:45:31Z joseph $
{Generic document command parser}
%\iffalse
%<*driver>
@@ -428,6 +428,23 @@
% before the split takes place.
%\end{function}
%
+%\begin{function}{ \SplitList }
+% \begin{syntax}
+% \cs{SplitList} \Arg{token}
+% \end{syntax}
+% This processor splits the argument given at each occurrence of the
+% \meta{token} where the number of items is not fixed. Each item is
+% then wrapped in braces within "#1". The result is that the
+% processed argument can be further processed using a mapping function.
+% \begin{verbatim}
+% \DeclareDocumentCommand \foo
+% { > { \SplitList { ; } } m }
+% { \MappingFunction #1 }
+% \end{verbatim}
+% Any category code \( 13 \) (active) \meta{tokens} will be replaced
+% before the split takes place.
+%\end{function}
+%
%\subsection{Separating interface and implementation}
%
% One \emph{experimental} idea implemented in \pkg{xparse} is to
@@ -2106,7 +2123,7 @@
{ \exp_not:n {#2} } {#1} { \exp_not:n {#3} }
}
}
- \tl_set:Nx \_l_xparse_tmp_tl
+ \tl_set:Nx \l_xparse_tmp_tl
{
\prg_replicate:nn { #1 + 1 }
{ \_xparse_split_argument_aux_i:w }
@@ -2116,7 +2133,7 @@
\prg_replicate:nn {#1} { \exp_not:n {#2} \NoValue }
\exp_not:n { #2 \q_stop }
}
- \_l_xparse_tmp_tl
+ \l_xparse_tmp_tl
}
\group_end:
\cs_set_protected:Npn \_xparse_split_argument_aux_i:w { }
@@ -2134,6 +2151,48 @@
%\end{macro}
%\end{macro}
%
+%\begin{macro}{\_l_xparse_split_list_tl}
+%\begin{macro}{\_xparse_split_list:nn}
+%\begin{macro}{\_xparse_split_list_aux:w}
+% Splitting a list is done again by first dealing with active
+% characters, then looping over the list using the same method as the
+% \cs{clist_map_\ldots} functions.
+% \begin{macrocode}
+\tl_new:N \_l_xparse_split_list_tl
+\group_begin:
+ \char_make_active:N \@
+ \cs_gset_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_last_unbraced:NV \_xparse_split_list_aux:w
+ \_l_xparse_split_list_tl #1
+ \q_recursion_tail #1 \q_recursion_stop
+ }
+ }
+\group_end:
+\cs_set:Npn \_xparse_split_list_aux:w { }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
%\subsection{Creating expandable functions}
%
% The trick here is to pass each grabbed argument along a chain of
@@ -2756,11 +2815,14 @@
%\end{macro}
%
%\begin{macro}{\SplitArgument}
+%\begin{macro}{\SplitList}
% Another simple copy.
% \begin{macrocode}
\cs_new_eq:NN \SplitArgument \_xparse_split_argument:nnn
+\cs_new_eq:NN \SplitList \_xparse_split_list:nn
% \end{macrocode}
%\end{macro}
+%\end{macro}
%
% \begin{macrocode}
%</initex|package>