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.dtx83
1 files changed, 36 insertions, 47 deletions
diff --git a/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx b/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
index f1d6ebf872d..564907d4acb 100644
--- a/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
+++ b/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
@@ -3,7 +3,7 @@
%% David Carlisle
%% (C) Copyright 2004-2008 Frank Mittelbach,
%% LaTeX3 Project
-%% (C) Copyright 2009 LaTeX3 Project
+%% (C) Copyright 2009-2010 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
@@ -41,7 +41,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: xparse.dtx 1927 2010-05-23 11:00:21Z joseph $
+\GetIdInfo$Id: xparse.dtx 2037 2010-09-20 21:22:45Z joseph $
{Generic document command parser}
%\iffalse
%<*driver>
@@ -640,10 +640,6 @@
% letters in the argument specification).
%\end{variable}
%
-%\begin{variable}{\q_xparse_stop}
-% A private delimiting quark: needed by the expandable function system.
-%\end{variable}
-%
%\subsection{Internal functions}
%
%\begin{function}{
@@ -1077,14 +1073,6 @@
\int_new:N \l_xparse_total_args_int
% \end{macrocode}
%\end{macro}
-%
-%\begin{macro}{\q_xparse_stop}
-% A private quark, used for delimiting arguments when making
-% expandable functions.
-% \begin{macrocode}
-\quark_new:N \q_xparse_stop
-% \end{macrocode}
-%\end{macro}
%
%\subsection{Turning the argument specifier into grabbers}
%
@@ -1579,7 +1567,7 @@
% Tests for \cs{NoValue}.
% \begin{macrocode}
\prg_new_conditional:Nnn \xparse_if_no_value:n { TF,T,F } {
- \tl_if_eq:nnTF {#1} { \NoValue } {
+ \str_if_eq:nnTF {#1} { \NoValue } {
\prg_return_true:
}{
\prg_return_false:
@@ -1801,7 +1789,7 @@
%\begin{macro}[aux]{\xparse_grab_D_nested:NNnNn}
%\begin{macro}{\_l_xparse_nesting_a_tl}
%\begin{macro}{\_l_xparse_nesting_b_tl}
-%\begin{macro}{\_q_xparse}
+%\begin{macro}{\q_xparse}
% Catching nested optional arguments means more work. The aim here is
% to collect up each pair of optional tokens without \TeX\ helping out,
% and without counting anything. The code above will already have
@@ -1816,23 +1804,23 @@
% \begin{macrocode}
\tl_new:N \_l_xparse_nesting_a_tl
\tl_new:N \_l_xparse_nesting_b_tl
-\quark_new:N \_q_xparse
+\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
+ #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 }
+ { \xparse_grab_arg:w ##2 \q_xparse }
{
\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_last_unbraced:NV \xparse_grab_arg:w
- \l_xparse_tmp_tl \_q_xparse
+ \l_xparse_tmp_tl \q_xparse
}
{
\tl_put_right:Nn \_l_xparse_nesting_a_tl {##2}
@@ -1843,7 +1831,7 @@
}
}
}
- \xparse_grab_arg:w #3 \_q_xparse
+ \xparse_grab_arg:w #3 \q_xparse
}
% \end{macrocode}
%\end{macro}
@@ -2131,10 +2119,10 @@
\tl_replace_all_in:Nnn \_l_xparse_split_argument_tl { @ } {#2}
}
\cs_set_protected:Npn \_xparse_split_argument_aux_i:w
- ##1 \q_nil ##2 #2 ##3 \q_stop
+ ##1 \q_mark ##2 #2 ##3 \q_stop
{
\tl_put_right:Nn \ProcessedArgument { {##2} }
- ##1 \q_nil ##3 \q_stop
+ ##1 \q_mark ##3 \q_stop
}
\cs_set_protected:Npn \_xparse_split_argument_aux_iii:w
##1 #2 ##2 \q_stop
@@ -2150,7 +2138,7 @@
\prg_replicate:nn { #1 + 1 }
{ \_xparse_split_argument_aux_i:w }
\_xparse_split_argument_aux_ii:w
- \exp_not:N \q_nil
+ \exp_not:N \q_mark
\exp_not:V \_l_xparse_split_argument_tl
\prg_replicate:nn {#1} { \exp_not:n {#2} \NoValue }
\exp_not:n { #2 \q_stop }
@@ -2160,7 +2148,7 @@
\group_end:
\cs_set_protected:Npn \_xparse_split_argument_aux_i:w { }
\cs_set_protected:Npn \_xparse_split_argument_aux_ii:w
- #1 \q_nil #2 \q_stop
+ #1 \q_mark #2 \q_stop
{
\tl_if_empty:nF {#2}
{ \_xparse_split_argument_aux_iii:w #2 \q_stop }
@@ -2220,7 +2208,7 @@
% The trick here is to pass each grabbed argument along a chain of
% auxiliary functions. Each one ultimately calls the next in the chain,
% so that all of the arguments are passed along delimited using
-% \cs{q_xparse_stop}. At the end of the chain, the marker is removed
+% \cs{q_xparse}. At the end of the chain, the marker is removed
% so that the user-supplied code can be passed the correct number
% of arguments. All of this is done by expansion!
%
@@ -2244,28 +2232,27 @@
% case, the second auxiliary function is called. It finds the closing
% delimiter and so the optional argument (if any). The function then
% calls the next one in the chain, passing along the argument(s)
-% grabbed thus-far using \cs{q_xparse_stop} as a marker.
+% grabbed thus-far using \cs{q_xparse} as a marker.
% \begin{macrocode}
\cs_new: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_stop ##2 {
+ \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_stop
+ ##1 \exp_not:N \q_xparse
}{
\exp_not:c { \l_xparse_tmp_tl aux }
- ##1 \exp_not:N \q_xparse_stop #3 #2 {##2}
+ ##1 \exp_not:N \q_xparse #3 #2 {##2}
}
}
- \xparse_exp_set:cpx { \l_xparse_tmp_tl aux}
- ##1 \q_xparse_stop ##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
\intexpr_eval:n { \l_xparse_total_args_int + 1 }
- } ##1 {##2} \exp_not:N \q_xparse_stop
+ } ##1 {##2} \exp_not:N \q_xparse
}
\xparse_exp_prepare_function:N
}
@@ -2283,12 +2270,12 @@
\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_stop ##2## {
+ } ##1 \q_xparse ##2## {
\exp_not:c {
\exp_after:wN \token_to_str:N \l_xparse_function_tl
\intexpr_eval:n { \l_xparse_total_args_int + 1 }
}
- ##1 {##2} \exp_not:N \q_xparse_stop
+ ##1 {##2} \exp_not:N \q_xparse
}
\xparse_exp_prepare_function:N
}
@@ -2297,12 +2284,12 @@
\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_stop ##2 {
+ } ##1 \q_xparse ##2 {
\exp_not:c {
\exp_after:wN \token_to_str:N \l_xparse_function_tl
\intexpr_eval:n { \l_xparse_total_args_int + 1 }
}
- ##1 {##2} \exp_not:N \q_xparse_stop
+ ##1 {##2} \exp_not:N \q_xparse
}
\xparse_exp_prepare_function:N
}
@@ -2325,13 +2312,13 @@
\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_stop ##2 {
+ } ##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_stop }
+ ##1 \exp_not:n { { \BooleanTrue } \q_xparse }
}{
\exp_not:c { \l_xparse_tmp_tl }
- ##1 \exp_not:n { { \BooleanFalse } \q_xparse_stop {##2} }
+ ##1 \exp_not:n { { \BooleanFalse } \q_xparse {##2} }
}
}
\xparse_exp_prepare_function:N
@@ -2349,12 +2336,12 @@
\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_stop ##2 #1 {
+ } ##1 \q_xparse ##2 #1 {
\exp_not:c {
\exp_after:wN \token_to_str:N \l_xparse_function_tl
\intexpr_eval:n { \l_xparse_total_args_int + 1 }
}
- ##1 {##2} \exp_not:N \q_xparse_stop
+ ##1 {##2} \exp_not:N \q_xparse
}
\xparse_exp_prepare_function:N
}
@@ -2430,11 +2417,11 @@
}
\cs_new: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_stop
+ \exp_not:c { \token_to_str:N #1 1 } x \exp_not:N \q_xparse
}
\cs_set_nopar:cpx {
\token_to_str:N #1 \intexpr_eval:n { \l_xparse_total_args_int + 1 }
- } x ##1 \q_xparse_stop {
+ } x ##1 \q_xparse {
\exp_not:c { \token_to_str:N #1 } ##1
}
\cs_generate_from_arg_count:cNnn
@@ -2506,7 +2493,7 @@
}
\cs_new:Npn \xparse_exp_prepare_function_long:N #1 {
\quark_if_nil:NF #1 {
- \tl_if_eq:nnTF {#1} { + } {
+ \str_if_eq:nnTF {#1} { + } {
\xparse_exp_prepare_function_short:N
}{
\msg_kernel_error:nn { xparse } { expandable-inconsistent-long }
@@ -2590,7 +2577,7 @@
}
{
The~arguments~for~an~expandable~command~must~either~all~be \\
- short~or~all~be~long.~You~have~tried~to mix~the~two~types.
+ short~or~all~be~long.~You~have~tried~to~mix~the~two~types.
}
\msg_kernel_new:nnnn { xparse } { grouped-in-expandable }
{%
@@ -2684,7 +2671,9 @@
}
\cs_new_protected:Npn \RenewDocumentCommand #1#2#3 {
\cs_if_exist:NTF #1 {
- \xparse_declare_cmd:Nnn #1 {#2} {#3}
+ \xparse_declare_cmd_aux:Nnn #1 {#2} {#3}
+ \msg_kernel_info:nnxx { xparse } { redefine-command }
+ { \token_to_str:N #1 } { \exp_not:n {#2} }
}{
\msg_kernel_error:nnx { xparse } { command-not-yet-defined }
{ \token_to_str:N #1 }