[latex3-commits] [l3svn] r6860 - Avoid repeated code for alias arguments (d, e, g, o, O, r, s)

noreply at latex-project.org noreply at latex-project.org
Thu Feb 9 18:43:42 CET 2017


Author: bruno
Date: 2017-02-09 18:43:42 +0100 (Thu, 09 Feb 2017)
New Revision: 6860

Modified:
   trunk/l3packages/xparse/testfiles/xparse004.tlg
   trunk/l3packages/xparse/xparse.dtx
Log:
Avoid repeated code for alias arguments (d,e,g,o,O,r,s)


Modified: trunk/l3packages/xparse/testfiles/xparse004.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.tlg	2017-02-09 17:28:04 UTC (rev 6859)
+++ trunk/l3packages/xparse/testfiles/xparse004.tlg	2017-02-09 17:43:42 UTC (rev 6860)
@@ -1281,7 +1281,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'R' has the same delimiter '[' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter '[' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1294,7 +1294,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'r' has the same delimiter '[' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter '[' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1307,7 +1307,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'r' has the same delimiter ':' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter ':' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1320,7 +1320,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'R' has the same delimiter ':' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter ':' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1333,7 +1333,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'r' has the same delimiter '[' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter '[' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1374,7 +1374,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'r' has the same delimiter '*' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter '*' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1387,7 +1387,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'r' has the same delimiter '(' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter '(' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************
@@ -1400,7 +1400,7 @@
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
 * 
-* Since the mandatory argument 'r' has the same delimiter '_' as a previous
+* Since the mandatory argument 'R/r' has the same delimiter '_' as a previous
 * optional argument, it will not be possible to omit all optional arguments
 * when calling this command.
 *************************************************

Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx	2017-02-09 17:28:04 UTC (rev 6859)
+++ trunk/l3packages/xparse/xparse.dtx	2017-02-09 17:43:42 UTC (rev 6860)
@@ -973,12 +973,15 @@
 % \end{variable}
 %
 % \begin{variable}{\l_@@_tmp_prop, \l_@@_tmpa_tl, \l_@@_tmpb_tl}
+% \begin{macro}{\@@_tmp:w}
 %   Scratch space.
 %    \begin{macrocode}
 \prop_new:N \l_@@_tmp_prop
 \tl_new:N \l_@@_tmpa_tl
 \tl_new:N \l_@@_tmpb_tl
+\cs_new_eq:NN \@@_tmp:w ?
 %    \end{macrocode}
+% \end{macro}
 % \end{variable}
 %
 % \subsection{Declaring commands and environments}
@@ -1213,8 +1216,8 @@
 %
 % \begin{macro}{\@@_defaults:}
 % \begin{macro}[aux]{\@@_defaults_def:, \@@_defaults_def:nn, \@@_defaults_def:nnn, \@@_defaults_def_aux:nn}
-% \begin{macro}[aux]{\@@_defaults_tmp:w, \@@_defaults_aux:,  \@@_defaults_error:w}
-%   First construct \cs{@@_defaults_tmp:w} (see below) that will receive
+% \begin{macro}[aux]{\@@_defaults_aux:,  \@@_defaults_error:w}
+%   First construct \cs{@@_tmp:w} (see below) that will receive
 %   the arguments found so far and determine default values for any
 %   missing argument.  Then call it repeatedly until the set of
 %   arguments stabilizes.  Since that could lead to an infinite loop we
@@ -1233,11 +1236,10 @@
     \q_recursion_stop
     \tl_set_eq:NN \l_@@_args_tl \l_@@_args_i_tl
   }
-\cs_new:Npn \@@_defaults_tmp:w { }
 \cs_new_protected:Npn \@@_defaults_aux:
   {
     \tl_set:Nx \l_@@_args_ii_tl
-      { \exp_after:wN \@@_defaults_tmp:w \l_@@_args_i_tl }
+      { \exp_after:wN \@@_tmp:w \l_@@_args_i_tl }
     \tl_if_eq:NNT \l_@@_args_ii_tl \l_@@_args_i_tl
       { \use_none_delimit_by_q_recursion_stop:w }
     \tl_set_eq:NN \l_@@_args_i_tl \l_@@_args_ii_tl
@@ -1248,7 +1250,7 @@
       { \exp_after:wN \token_to_str:N \l_@@_fn_tl }
   }
 %    \end{macrocode}
-%   To construct \cs{@@_defaults_tmp:w}, first go through the arguments
+%   To construct \cs{@@_tmp:w}, first go through the arguments
 %   found and the corresponding defaults, building a token list with
 %   |{#|\meta{arg number}|}| for arguments found in the input (whose
 %   default will not be used) and otherwise
@@ -1256,7 +1258,7 @@
 %   be used.  The case of \texttt{E}-type arguments, detected by
 %   \cs{tl_if_head_is_group:nTF}, is special because we may need to
 %   partly use an argument found in the input and partly some default.
-%   This case is delayed until \cs{@@_defaults_tmp:w} is called: then we
+%   This case is delayed until \cs{@@_tmp:w} is called: then we
 %   map through the original argument and its corresponding list of
 %   defaults; for each item (corresponding to one embellishment) if a
 %   value has already been found use it otherwise use the default.
@@ -1267,7 +1269,7 @@
     \int_zero:N \l_@@_current_arg_int
     \@@_tl_mapthread_function:NNN \l_@@_args_tl \l_@@_defaults_tl
       \@@_defaults_def:nn
-    \cs_generate_from_arg_count:NNVo \@@_defaults_tmp:w \cs_set:Npn
+    \cs_generate_from_arg_count:NNVo \@@_tmp:w \cs_set:Npn
       \l_@@_current_arg_int \l_@@_tmpa_tl
   }
 \cs_generate_variant:Nn \cs_generate_from_arg_count:NNnn { NNVo }
@@ -1387,21 +1389,59 @@
 %
 % \begin{macro}
 %   {
+%     \@@_normalize_type_d:w,
+%     \@@_normalize_type_e:w,
+%     \@@_normalize_type_g:w,
+%     \@@_normalize_type_o:w,
+%     \@@_normalize_type_O:w,
+%     \@@_normalize_type_r:w,
+%     \@@_normalize_type_s:w,
+%   }
+%   These argument types are aliases of more general ones, for example
+%   with the default argument |-NoValue-|.  To easily insert that marker
+%   expanded in the definitions we will call \cs{@@_tmp:w} with argument
+%   |-NoValue-|.
+%    \begin{macrocode}
+\cs_set_protected:Npn \@@_tmp:w #1
+  {
+    \cs_new_protected:Npn \@@_normalize_type_d:w ##1##2
+      {
+        \quark_if_recursion_tail_stop_do:nn {##2} { \@@_bad_arg_spec:wn }
+        \@@_normalize_type_D:w {##1} {##2} {#1}
+      }
+    \cs_new_protected:Npn \@@_normalize_type_e:w ##1
+      {
+        \quark_if_recursion_tail_stop_do:nn {##1} { \@@_bad_arg_spec:wn }
+        \@@_normalize_type_E:w {##1} { }
+      }
+    \cs_new_protected:Npn \@@_normalize_type_g:w
+      { \@@_normalize_type_G:w {#1} }
+    \cs_new_protected:Npn \@@_normalize_type_o:w
+      { \@@_normalize_type_D:w [ ] {#1} }
+    \cs_new_protected:Npn \@@_normalize_type_O:w
+      { \@@_normalize_type_D:w [ ] }
+    \cs_new_protected:Npn \@@_normalize_type_r:w ##1##2
+      {
+        \quark_if_recursion_tail_stop_do:nn {##2} { \@@_bad_arg_spec:wn }
+        \@@_normalize_type_R:w {##1} {##2} {#1}
+      }
+    \cs_new_protected:Npn \@@_normalize_type_s:w
+      { \@@_normalize_type_t:w * }
+  }
+\exp_args:No \@@_tmp:w { \c_@@_no_value_tl }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}
+%   {
 %     \@@_normalize_type_>:w,
 %     \@@_normalize_type_+:w,
-%     \@@_normalize_type_d:w,
 %     \@@_normalize_type_D:w,
-%     \@@_normalize_type_e:w,
 %     \@@_normalize_type_E:w,
-%     \@@_normalize_type_g:w,
 %     \@@_normalize_type_G:w,
 %     \@@_normalize_type_l:w,
 %     \@@_normalize_type_m:w,
-%     \@@_normalize_type_o:w,
-%     \@@_normalize_type_O:w,
-%     \@@_normalize_type_r:w,
 %     \@@_normalize_type_R:w,
-%     \@@_normalize_type_s:w,
 %     \@@_normalize_type_t:w,
 %     \@@_normalize_type_u:w
 %     \@@_normalize_type_v:w
@@ -1454,16 +1494,6 @@
     \tl_put_right:Nn \l_@@_arg_spec_tl { + }
     \@@_normalize_arg_spec_loop:n {#1}
   }
-\cs_new_protected:Npn \@@_normalize_type_d:w #1#2
-  {
-    \@@_single_token_check:n {#1}
-    \@@_single_token_check:n {#2}
-    \quark_if_recursion_tail_stop_do:Nn #2 { \@@_bad_arg_spec:wn }
-    \tl_put_right:Nx \l_@@_arg_spec_tl
-      { \exp_not:n { D #1 #2 } { \c_@@_no_value_tl } }
-    \tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
-    \@@_normalize_arg_spec_loop:n
-  }
 \cs_new_protected:Npn \@@_normalize_type_D:w #1#2#3
   {
     \@@_single_token_check:n {#1}
@@ -1473,16 +1503,6 @@
     \tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
     \@@_normalize_arg_spec_loop:n
   }
-\cs_new_protected:Npn \@@_normalize_type_e:w #1
-  {
-    \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
-    \tl_if_blank:nT {#1} { \@@_bad_arg_spec:wn }
-    \tl_map_function:nN {#1} \@@_single_token_check:n
-    \@@_normalize_error_if_expandable:N e
-    \tl_put_right:Nn \l_@@_arg_spec_tl { E {#1} { } }
-    \tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
-    \@@_normalize_arg_spec_loop:n
-  }
 \cs_new_protected:Npn \@@_normalize_type_E:w #1#2
   {
     \quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn }
@@ -1495,13 +1515,6 @@
     \tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
     \@@_normalize_arg_spec_loop:n
   }
-\cs_new_protected:Npn \@@_normalize_type_g:w
-  {
-    \@@_normalize_error_if_expandable:N g
-    \tl_put_right:Nx \l_@@_arg_spec_tl { G { \c_@@_no_value_tl } }
-    \tl_put_right:Nn \l_@@_last_delimiters_tl { { } }
-    \@@_normalize_arg_spec_loop:n
-  }
 \cs_new_protected:Npn \@@_normalize_type_G:w #1
   {
     \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
@@ -1525,31 +1538,6 @@
     \@@_delimiter_check:nnn { } { m } { \iow_char:N \{ }
     \@@_normalize_arg_spec_loop:n
   }
-\cs_new_protected:Npn \@@_normalize_type_o:w
-  {
-    \tl_put_right:Nx \l_@@_arg_spec_tl
-      { \exp_not:n { D [ ] } { \c_@@_no_value_tl } }
-    \tl_put_right:Nn \l_@@_last_delimiters_tl { [ }
-    \@@_normalize_arg_spec_loop:n
-  }
-\cs_new_protected:Npn \@@_normalize_type_O:w #1
-  {
-    \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
-    \tl_put_right:Nn \l_@@_arg_spec_tl { D [ ] {#1} }
-    \tl_put_right:Nn \l_@@_last_delimiters_tl { [ }
-    \@@_normalize_arg_spec_loop:n
-  }
-\cs_new_protected:Npn \@@_normalize_type_r:w #1#2
-  {
-    \@@_single_token_check:n {#1}
-    \@@_single_token_check:n {#2}
-    \quark_if_recursion_tail_stop_do:Nn #2 { \@@_bad_arg_spec:wn }
-    \tl_put_right:Nx \l_@@_arg_spec_tl
-      { \exp_not:n { R #1 #2 } { \c_@@_no_value_tl } }
-    \int_incr:N \l_@@_mandatory_args_int
-    \@@_delimiter_check:nnn {#1} { r } { \tl_to_str:n {#1} }
-    \@@_normalize_arg_spec_loop:n
-  }
 \cs_new_protected:Npn \@@_normalize_type_R:w #1#2#3
   {
     \@@_single_token_check:n {#1}
@@ -1557,15 +1545,9 @@
     \quark_if_recursion_tail_stop_do:nn {#3} { \@@_bad_arg_spec:wn }
     \tl_put_right:Nn \l_@@_arg_spec_tl { R #1 #2 {#3} }
     \int_incr:N \l_@@_mandatory_args_int
-    \@@_delimiter_check:nnn {#1} { R } { \tl_to_str:n {#1} }
+    \@@_delimiter_check:nnn {#1} { R/r } { \tl_to_str:n {#1} }
     \@@_normalize_arg_spec_loop:n
   }
-\cs_new_protected:Npn \@@_normalize_type_s:w
-  {
-    \tl_put_right:Nn \l_@@_arg_spec_tl { t * }
-    \tl_put_right:Nn \l_@@_last_delimiters_tl { * }
-    \@@_normalize_arg_spec_loop:n
-  }
 \cs_new_protected:Npn \@@_normalize_type_t:w #1
   {
     \@@_single_token_check:n {#1}



More information about the latex3-commits mailing list