[latex3-commits] [git/LaTeX3-latex3-latex3] xparse: Split out 'core' xparse code (e3ffcdd5b)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon May 11 18:11:42 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : xparse
Link       : https://github.com/latex3/latex3/commit/e3ffcdd5b7308040b1897729591c3e33ade532ef

>---------------------------------------------------------------

commit e3ffcdd5b7308040b1897729591c3e33ade532ef
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon May 11 17:11:42 2020 +0100

    Split out 'core' xparse code
    
    This matches the plan for expl3  in the autumn:
    there will be further re-arrangement of the code
    at that point (so the files here are temporary).


>---------------------------------------------------------------

e3ffcdd5b7308040b1897729591c3e33ade532ef
 l3packages/CHANGELOG.md                   |   3 +
 l3packages/xparse/build.lua               |   2 +-
 l3packages/xparse/testfiles/xparse000.tlg |   3 +-
 l3packages/xparse/xparse.dtx              | 124 +++++++++++++++++++++++++-----
 l3packages/xparse/xparse.ins              |   5 +-
 5 files changed, 114 insertions(+), 23 deletions(-)

diff --git a/l3packages/CHANGELOG.md b/l3packages/CHANGELOG.md
index 515f5d001..4290113ab 100644
--- a/l3packages/CHANGELOG.md
+++ b/l3packages/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Changed
+- Internal packaging of `xparse` in advance of changes to the LaTeX2e kernel
+
 ## [2020-03-06]
 
 ### Added
diff --git a/l3packages/xparse/build.lua b/l3packages/xparse/build.lua
index 46de200ce..014886b0f 100644
--- a/l3packages/xparse/build.lua
+++ b/l3packages/xparse/build.lua
@@ -7,7 +7,7 @@
 bundle = "l3packages"
 module = "xparse"
 
-installfiles = {"xparse.ltx", "xparse.sty"}
+installfiles = {"xparse.ltx", "xparse.sty", "xparse.tex"}
 
 -- Location of main directory: use Unix-style path separators
 maindir = "../.."
diff --git a/l3packages/xparse/testfiles/xparse000.tlg b/l3packages/xparse/testfiles/xparse000.tlg
index 81f95f3d6..3923341c9 100644
--- a/l3packages/xparse/testfiles/xparse000.tlg
+++ b/l3packages/xparse/testfiles/xparse000.tlg
@@ -3,8 +3,9 @@ Don't change this file in any respect.
 Author: Bruno Le Floch
 (xparse.sty
 Package: xparse ....-..-.. L3 Experimental document command parser
+(xparse.tex
 \l__xparse_current_arg_int=\count...
 \g__xparse_grabber_int=\count...
 \l__xparse_m_args_int=\count...
 \l__xparse_v_nesting_int=\count...
-)
+))
diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index 24f44e68d..cbac41dd6 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -1031,10 +1031,23 @@
 %</package>
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+%<*2ekernel|package>
+%    \end{macrocode}
+%
+%  Load the core code.
+%    \begin{macrocode}
+\file_input:n { xparse.tex }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%</2ekernel|package>
+%    \end{macrocode}
+%
 % \subsection{Variables and constants}
 %
 %    \begin{macrocode}
-%<*package|2ekernel>
+%<*core>
 %    \end{macrocode}
 %
 % \begin{variable}{\c_@@_special_chars_seq}
@@ -1477,9 +1490,9 @@
 %<*initex>
     \cs_if_exist:cTF { environment~ \l_@@_environment_str }
 %</initex>
-%<*package|2ekernel>
+%<*core>
     \cs_if_exist:cTF { \l_@@_environment_str }
-%</package|2ekernel>
+%</core>
       {
         \__kernel_msg_info:nnxx { xparse } { redefine-environment }
           { \l_@@_environment_str } { \tl_to_str:n {#2} }
@@ -1525,10 +1538,10 @@
         \cs_generate_from_arg_count:cNnn
           { environment~ #1 ~end~aux~ } \cs_set:Npn
           \l_@@_current_arg_int {#4}
-%<*package|2ekernel>
+%<*core>
         \cs_set_eq:cc {#1}       { environment~ #1 }
         \cs_set_eq:cc { end #1 } { environment~ #1 ~end }
-%</package|2ekernel>
+%</core>
       }
   }
 %    \end{macrocode}
@@ -1548,9 +1561,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_start_env:nnnnn #1#2
   {
-%<*package|2ekernel>
     \cs_if_exist_use:N \conditionally at traceoff
-%</package|2ekernel>
     \str_set:Nn \l_@@_environment_str {#2}
     \bool_set_true:N \l_@@_environment_bool
     \@@_start_aux:ccnnnn
@@ -1560,9 +1571,7 @@
   }
 \cs_new_protected:Npx \@@_start:nNNnnn #1#2#3
   {
-%<*package|2ekernel>
     \exp_not:n { \cs_if_exist_use:N \conditionally at traceoff }
-%</package|2ekernel>
     \exp_not:c { xparse~function~is~not~expandable }
     \exp_not:n { \bool_set_false:N \l_@@_environment_bool }
     \exp_not:N \@@_start_aux:NNnnnn
@@ -1599,9 +1608,9 @@
   {
     \tl_if_empty:NF \l_@@_defaults_tl { \@@_defaults: }
     \tl_if_empty:NF \l_@@_process_all_tl { \@@_args_process: }
-%<*package|2ekernel>
+%<*core>
     \cs_if_exist_use:N \conditionally at traceon
-%</package|2ekernel>
+%</core>
     \exp_after:wN \l_@@_fn_code_tl \l_@@_args_tl
   }
 %    \end{macrocode}
@@ -1879,17 +1888,45 @@
     \bool_if:NT \l_@@_environment_bool
       { \bool_set_false:N \l_@@_grab_expandably_bool }
   }
+%<*core>
 \cs_new_protected:Npn \@@_normalize_arg_spec_loop:n #1
   {
     \quark_if_recursion_tail_stop:n {#1}
     \int_incr:N \l_@@_current_arg_int
     \cs_if_exist_use:cF { @@_normalize_type_ \tl_to_str:n {#1} :w }
       {
+        \bool_lazy_any:nTF
+          {
+            { \str_if_eq_p:nn {#1} { G } }
+            { \str_if_eq_p:nn {#1} { g } }
+            { \str_if_eq_p:nn {#1} { l } }
+            { \str_if_eq_p:nn {#1} { u } }
+          }
+          {
+            \__kernel_msg_error:nnxx { xparse } { xparse-argument-type }
+              { \@@_environment_or_command: } { \tl_to_str:n {#1} }
+          }
+          {
+            \__kernel_msg_error:nnxx { xparse } { unknown-argument-type }
+              { \@@_environment_or_command: } { \tl_to_str:n {#1} }
+          }
+        \@@_bad_def:wn
+      }
+  }
+%</core>
+%<*package>
+\cs_gset_protected:Npn \@@_normalize_arg_spec_loop:n #1
+  {
+    \quark_if_recursion_tail_stop:n {#1}
+    \int_incr:N \l_@@_current_arg_int
+    \cs_if_exist_use:cF { @@_normalize_type_ \tl_to_str:n {#1} :w }
+      {
         \__kernel_msg_error:nnxx { xparse } { unknown-argument-type }
           { \@@_environment_or_command: } { \tl_to_str:n {#1} }
         \@@_bad_def:wn
       }
   }
+%</package>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1923,8 +1960,6 @@
         \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
@@ -1938,6 +1973,10 @@
       { \@@_normalize_type_t:w * }
   }
 \exp_args:No \@@_tmp:w { \c_novalue_tl }
+%<*package>
+\cs_new_protected:Npx \@@_normalize_type_g:w
+  { \exp_not:N \@@_normalize_type_G:w  \exp_not:V \c_novalue_tl } }
+%</package>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2051,6 +2090,8 @@
         \@@_normalize_E_unique_check:w #2 \q_stop
       }
   }
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_normalize_type_G:w #1
   {
     \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
@@ -2059,6 +2100,8 @@
     \tl_put_right:Nn \l_@@_last_delimiters_tl { { } }
     \@@_normalize_arg_spec_loop:n
   }
+%</package>
+%<*core>
 \cs_new_protected:Npn \@@_normalize_type_t:w #1
   {
     \quark_if_recursion_tail_stop_do:Nn #1 { \@@_bad_arg_spec:wn }
@@ -2095,12 +2138,16 @@
 %   \cs{l_@@_arg_spec_tl}, count the mandatory argument, and empty the
 %   list of last delimiters.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_normalize_type_l:w
   {
     \@@_normalize_check_lu:N l
     \@@_add_arg_spec_mandatory:n { l }
     \@@_normalize_arg_spec_loop:n
   }
+%</package>
+%<*core>
 \cs_new_protected:Npn \@@_normalize_type_m:w
   {
     \@@_delimiter_check:nnn { } { m } { \iow_char:N \{ }
@@ -2117,6 +2164,8 @@
     \@@_add_arg_spec_mandatory:n { R #1 #2 {#3} }
     \@@_normalize_arg_spec_loop:n
   }
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_normalize_type_u:w #1
   {
     \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
@@ -2124,6 +2173,8 @@
     \@@_add_arg_spec_mandatory:n { u {#1} }
     \@@_normalize_arg_spec_loop:n
   }
+%</package>
+%<*core>
 \cs_new_protected:Npn \@@_normalize_type_v:w
   {
     \@@_normalize_check_gv:N v
@@ -2482,6 +2533,8 @@
 %   For the \texttt{G} type, the grabber and the default are added to the
 %   signature.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_add_type_G:w #1
   {
     \@@_flush_m_args:
@@ -2503,6 +2556,8 @@
     \@@_add_grabber:N l
     \@@_prepare_signature:N
   }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2558,6 +2613,8 @@
 %   At the set up stage, the \texttt{u} type argument is identical to the
 %   \texttt{G} type except for the name of the grabber function.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_add_type_u:w #1
   {
     \@@_flush_m_args:
@@ -2566,6 +2623,8 @@
     \tl_put_right:Nn \l_@@_signature_tl { {#1} }
     \@@_prepare_signature:N
   }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2784,8 +2843,12 @@
 %   parameter text ends with |#| in fact end up being delimited by an
 %   open brace.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_add_expandable_type_l:w
   { \@@_add_expandable_type_u:w ## }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2834,6 +2897,8 @@
 %   Define an auxiliary that will be used directly in the signature.  It
 %   grabs one argument delimited by |#1| and places it before \cs{q_@@}.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_add_expandable_type_u:w #1
   {
     \@@_add_default:
@@ -2846,6 +2911,8 @@
       { \exp_not:c  { \l_@@_expandable_aux_name_tl } }
     \@@_prepare_signature:N
   }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3249,6 +3316,8 @@
 %   Optional groups are checked by meaning, so that the same code will
 %   work with, for example, \ConTeXt{}-like input.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_grab_G:w #1 \@@_run_code:
   {
     \@@_grab_G_aux:nNN {#1} \cs_set_protected_nopar:Npn
@@ -3278,6 +3347,8 @@
       { \l_@@_fn_tl }
       { \@@_add_arg:o \c_novalue_tl }
   }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3290,6 +3361,8 @@
 % \begin{macro}{\@@_grab_l_aux:nN}
 %   Argument grabbers for mandatory \TeX{} arguments are pretty simple.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_grab_l:w #1 \@@_run_code:
   { \@@_grab_l_aux:nN {#1} \cs_set_protected_nopar:Npn }
 \cs_new_protected:Npn \@@_grab_l_long:w #1 \@@_run_code:
@@ -3301,6 +3374,8 @@
       { \@@_add_arg:n {##1} }
     \l_@@_fn_tl
   }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3472,6 +3547,8 @@
 %   Grabbing up to a list of tokens is quite easy: define the grabber,
 %   and then collect.
 %    \begin{macrocode}
+%</core>
+%<*package>
 \cs_new_protected:Npn \@@_grab_u:w #1#2 \@@_run_code:
   { \@@_grab_u_aux:nnN {#1} {#2} \cs_set_protected_nopar:Npn }
 \cs_new_protected:Npn \@@_grab_u_long:w #1#2 \@@_run_code:
@@ -3483,6 +3560,8 @@
       { \@@_add_arg:n {##1} }
     \l_@@_fn_tl
   }
+%</package>
+%<*core>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3694,10 +3773,10 @@
       \c_@@_special_chars_seq
       \char_set_catcode_other:N
 %</initex>
-%<*package|2ekernel>
+%<*core>
     \cs_set_eq:NN \do \char_set_catcode_other:N
     \dospecials
-%</package|2ekernel>
+%</core>
     \tex_endlinechar:D = `\^^M \scan_stop:
     \bool_if:NTF \l_@@_long_bool
       { \char_set_catcode_other:n { \tex_endlinechar:D } }
@@ -4762,6 +4841,13 @@
     The~letter~'#2'~does~not~specify~a~known~argument~type.
     \c_@@_ignore_def_tl
   }
+\__kernel_msg_new:nnnn { xparse } { xparse-argument-type }
+  { Deprecated~argument~type~'#2'~for~the~#1~requires~xparse. }
+  {
+    The~letter~'#2'~specifies~a~known~argument~type~that~requires~
+    the~xparse~package.
+    \c_@@_ignore_def_tl
+  }
 %    \end{macrocode}
 %
 % Errors when using commands/environments.  The \texttt{if-boolean}
@@ -5111,19 +5197,19 @@
 % \end{macro}
 %
 %    \begin{macrocode}
-%<*2ekernel>
+%</core>
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\ExplSyntaxOff
+%<*2ekernel>
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-%</2ekernel>
+\ExplSyntaxOff
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-%</package|2ekernel>
+%</2ekernel>
 %    \end{macrocode}
 %
 % \end{implementation}
diff --git a/l3packages/xparse/xparse.ins b/l3packages/xparse/xparse.ins
index d40f7cd6f..e316ee04a 100644
--- a/l3packages/xparse/xparse.ins
+++ b/l3packages/xparse/xparse.ins
@@ -42,7 +42,8 @@ and all files in that bundle must be distributed together.
 
 \keepsilent
 
-\generate{\file{xparse.sty} {\from{xparse.dtx} {package}}
-          \file{xparse.ltx} {\from{xparse.dtx} {2ekernel}}}
+\generate{\file{xparse.tex}{\from{xparse.dtx}{core}}
+          \file{xparse.sty}{\from{xparse.dtx}{package}}
+          \file{xparse.ltx}{\from{xparse.dtx}{2ekernel}}}
 
 \endbatchfile





More information about the latex3-commits mailing list.