[latex3-commits] [git/LaTeX3-latex3-latex3] master: Split out 'core' xparse code (#718) (1fe065900)

GitHub noreply at github.com
Tue May 12 12:51:29 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/1fe065900dd841008da3c4b6af0a17f73473a6a8

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

commit 1fe065900dd841008da3c4b6af0a17f73473a6a8
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue May 12 11:51:29 2020 +0100

    Split out 'core' xparse code (#718)


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

1fe065900dd841008da3c4b6af0a17f73473a6a8
 l3packages/CHANGELOG.md                   |   3 +
 l3packages/xfp/testfiles/xfp000.tlg       |   3 +-
 l3packages/xparse/build.lua               |   2 +-
 l3packages/xparse/testfiles/xparse000.tlg |   3 +-
 l3packages/xparse/testfiles/xparse006.lvt |  30 +++++++
 l3packages/xparse/testfiles/xparse006.tlg |  43 +++++++++
 l3packages/xparse/xparse.dtx              | 142 +++++++++++++++++++++++++-----
 l3packages/xparse/xparse.ins              |   5 +-
 8 files changed, 203 insertions(+), 28 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/xfp/testfiles/xfp000.tlg b/l3packages/xfp/testfiles/xfp000.tlg
index 35bb391df..76cdae68e 100644
--- a/l3packages/xfp/testfiles/xfp000.tlg
+++ b/l3packages/xfp/testfiles/xfp000.tlg
@@ -3,10 +3,11 @@ Don't change this file in any respect.
 Author: Bruno Le Floch
 (xfp.sty (xparse.sty
 Package: xparse ....-..-.. L3 Experimental document command parser
+(xparse-generic.tex
 \l__xparse_current_arg_int=\count...
 \g__xparse_grabber_int=\count...
 \l__xparse_m_args_int=\count...
 \l__xparse_v_nesting_int=\count...
-)
+))
 Package: xfp ....-..-.. L3 Floating point unit
 )
diff --git a/l3packages/xparse/build.lua b/l3packages/xparse/build.lua
index 46de200ce..489b4db35 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-generic.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..6443924a6 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-generic.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/testfiles/xparse006.lvt b/l3packages/xparse/testfiles/xparse006.lvt
new file mode 100644
index 000000000..39d2a774f
--- /dev/null
+++ b/l3packages/xparse/testfiles/xparse006.lvt
@@ -0,0 +1,30 @@
+%
+% Copyright (C) 2020 LaTeX3 Project
+%
+
+\documentclass{minimal}
+\input{regression-test}
+
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation , log-functions }
+\ExplSyntaxOff
+% \RequirePackage{xparse}
+\input xparse-generic.tex
+
+\begin{document}
+
+\START
+\AUTHOR{Phelype Oleinik}
+
+\ExplSyntaxOn
+
+\TEST { Deprecated~argument~types }
+  {
+    \NewDocumentCommand { \testA } { G } { }
+    \NewDocumentCommand { \testA } { g } { }
+    \NewDocumentCommand { \testA } { l } { }
+    \NewDocumentCommand { \testA } { u } { }
+  }
+
+\END
diff --git a/l3packages/xparse/testfiles/xparse006.tlg b/l3packages/xparse/testfiles/xparse006.tlg
new file mode 100644
index 000000000..d26aa09ff
--- /dev/null
+++ b/l3packages/xparse/testfiles/xparse006.tlg
@@ -0,0 +1,43 @@
+This is a generated file for the LaTeX (2e + expl3) validation system.
+Don't change this file in any respect.
+Author: Phelype Oleinik
+============================================================
+TEST 1: Deprecated argument types
+============================================================
+LaTeX3 Info: Defining command \testA with sig. 'G' on line ....
+! LaTeX3 Error: Deprecated argument type 'G' for the command '\testA' requires
+(LaTeX3)        xparse.
+For immediate help type H <return>.
+ ...                                              
+l. ...  }
+The letter 'G' specifies a known argument type that requires the xparse
+package.
+LaTeX will ignore this entire definition.
+LaTeX3 Info: Defining command \testA with sig. 'g' on line ....
+! LaTeX3 Error: Deprecated argument type 'g' for the command '\testA' requires
+(LaTeX3)        xparse.
+For immediate help type H <return>.
+ ...                                              
+l. ...  }
+The letter 'g' specifies a known argument type that requires the xparse
+package.
+LaTeX will ignore this entire definition.
+LaTeX3 Info: Defining command \testA with sig. 'l' on line ....
+! LaTeX3 Error: Deprecated argument type 'l' for the command '\testA' requires
+(LaTeX3)        xparse.
+For immediate help type H <return>.
+ ...                                              
+l. ...  }
+The letter 'l' specifies a known argument type that requires the xparse
+package.
+LaTeX will ignore this entire definition.
+LaTeX3 Info: Defining command \testA with sig. 'u' on line ....
+! LaTeX3 Error: Deprecated argument type 'u' for the command '\testA' requires
+(LaTeX3)        xparse.
+For immediate help type H <return>.
+ ...                                              
+l. ...  }
+The letter 'u' specifies a known argument type that requires the xparse
+package.
+LaTeX will ignore this entire definition.
+============================================================
diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index 24f44e68d..0f1a8482b 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -1019,22 +1019,31 @@
 % \end{variable}
 % \end{variable}
 %
+%    \begin{macrocode}
+%</package>
+%    \end{macrocode}
+%
 % \subsection{Reload check}
 %
 % A simple reload check.
 %    \begin{macrocode}
+%<*core>
 \cs_if_exist:NT \NewDocumentCommand
   { \file_input_stop: }
+%</core>
 %    \end{macrocode}
 %
+%  Load the core code.
 %    \begin{macrocode}
-%</package>
+%<*2ekernel|package>
+\file_input:n { xparse-generic.tex }
+%</2ekernel|package>
 %    \end{macrocode}
 %
 % \subsection{Variables and constants}
 %
 %    \begin{macrocode}
-%<*package|2ekernel>
+%<*!package>
 %    \end{macrocode}
 %
 % \begin{variable}{\c_@@_special_chars_seq}
@@ -1049,6 +1058,17 @@
 %    \end{macrocode}
 % \end{variable}
 %
+%    \begin{macrocode}
+%<*core>
+\if_charcode:w xx
+  \cs_new:Npn \@@_file_end_hook: { }
+\else
+  \ExplSyntaxOn
+  \cs_new:Npn \@@_file_end_hook: { \ExplSyntaxOff }
+\fi:
+%</core>
+%    \end{macrocode}
+%
 % \begin{variable}{\l_@@_arg_spec_tl}
 %   Holds the argument specification after normalization of shorthands.
 %    \begin{macrocode}
@@ -1477,9 +1497,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 +1545,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 +1568,9 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_start_env:nnnnn #1#2
   {
-%<*package|2ekernel>
+%<*core>
     \cs_if_exist_use:N \conditionally at traceoff
-%</package|2ekernel>
+%</core>
     \str_set:Nn \l_@@_environment_str {#2}
     \bool_set_true:N \l_@@_environment_bool
     \@@_start_aux:ccnnnn
@@ -1560,9 +1580,9 @@
   }
 \cs_new_protected:Npx \@@_start:nNNnnn #1#2#3
   {
-%<*package|2ekernel>
+%<*core>
     \exp_not:n { \cs_if_exist_use:N \conditionally at traceoff }
-%</package|2ekernel>
+%</core>
     \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 +1619,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}
@@ -1885,11 +1905,39 @@
     \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
+      }
+  }
+%</!package>
+%<*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>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1923,8 +1971,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 +1984,12 @@
       { \@@_normalize_type_t:w * }
   }
 \exp_args:No \@@_tmp:w { \c_novalue_tl }
+%</!package>
+%<*package>
+\cs_new_protected:Npx \@@_normalize_type_g:w
+  { \exp_not:N \@@_normalize_type_G:w { \exp_not:V \c_novalue_tl } }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2051,6 +2103,8 @@
         \@@_normalize_E_unique_check:w #2 \q_stop
       }
   }
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_normalize_type_G:w #1
   {
     \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
@@ -2059,6 +2113,8 @@
     \tl_put_right:Nn \l_@@_last_delimiters_tl { { } }
     \@@_normalize_arg_spec_loop:n
   }
+%</package>
+%<*!package>
 \cs_new_protected:Npn \@@_normalize_type_t:w #1
   {
     \quark_if_recursion_tail_stop_do:Nn #1 { \@@_bad_arg_spec:wn }
@@ -2095,12 +2151,16 @@
 %   \cs{l_@@_arg_spec_tl}, count the mandatory argument, and empty the
 %   list of last delimiters.
 %    \begin{macrocode}
+%</!package>
+%<*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>
+%<*!package>
 \cs_new_protected:Npn \@@_normalize_type_m:w
   {
     \@@_delimiter_check:nnn { } { m } { \iow_char:N \{ }
@@ -2117,6 +2177,8 @@
     \@@_add_arg_spec_mandatory:n { R #1 #2 {#3} }
     \@@_normalize_arg_spec_loop:n
   }
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_normalize_type_u:w #1
   {
     \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
@@ -2124,6 +2186,8 @@
     \@@_add_arg_spec_mandatory:n { u {#1} }
     \@@_normalize_arg_spec_loop:n
   }
+%</package>
+%<*!package>
 \cs_new_protected:Npn \@@_normalize_type_v:w
   {
     \@@_normalize_check_gv:N v
@@ -2482,6 +2546,8 @@
 %   For the \texttt{G} type, the grabber and the default are added to the
 %   signature.
 %    \begin{macrocode}
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_add_type_G:w #1
   {
     \@@_flush_m_args:
@@ -2503,6 +2569,8 @@
     \@@_add_grabber:N l
     \@@_prepare_signature:N
   }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2558,6 +2626,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}
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_add_type_u:w #1
   {
     \@@_flush_m_args:
@@ -2566,6 +2636,8 @@
     \tl_put_right:Nn \l_@@_signature_tl { {#1} }
     \@@_prepare_signature:N
   }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2784,8 +2856,12 @@
 %   parameter text ends with |#| in fact end up being delimited by an
 %   open brace.
 %    \begin{macrocode}
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_add_expandable_type_l:w
   { \@@_add_expandable_type_u:w ## }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2834,6 +2910,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}
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_add_expandable_type_u:w #1
   {
     \@@_add_default:
@@ -2846,6 +2924,8 @@
       { \exp_not:c  { \l_@@_expandable_aux_name_tl } }
     \@@_prepare_signature:N
   }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3249,6 +3329,8 @@
 %   Optional groups are checked by meaning, so that the same code will
 %   work with, for example, \ConTeXt{}-like input.
 %    \begin{macrocode}
+%</!package>
+%<*package>
 \cs_new_protected:Npn \@@_grab_G:w #1 \@@_run_code:
   {
     \@@_grab_G_aux:nNN {#1} \cs_set_protected_nopar:Npn
@@ -3278,6 +3360,8 @@
       { \l_@@_fn_tl }
       { \@@_add_arg:o \c_novalue_tl }
   }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3290,6 +3374,8 @@
 % \begin{macro}{\@@_grab_l_aux:nN}
 %   Argument grabbers for mandatory \TeX{} arguments are pretty simple.
 %    \begin{macrocode}
+%</!package>
+%<*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 +3387,8 @@
       { \@@_add_arg:n {##1} }
     \l_@@_fn_tl
   }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3472,6 +3560,8 @@
 %   Grabbing up to a list of tokens is quite easy: define the grabber,
 %   and then collect.
 %    \begin{macrocode}
+%</!package>
+%<*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 +3573,8 @@
       { \@@_add_arg:n {##1} }
     \l_@@_fn_tl
   }
+%</package>
+%<*!package>
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3694,10 +3786,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 +4854,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}
@@ -5112,18 +5211,15 @@
 %
 %    \begin{macrocode}
 %<*2ekernel>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
 \ExplSyntaxOff
-%    \end{macrocode}
-%
-%    \begin{macrocode}
 %</2ekernel>
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-%</package|2ekernel>
+%<*core>
+\@@_file_end_hook:
+%</core>
+%</!package>
 %    \end{macrocode}
 %
 % \end{implementation}
diff --git a/l3packages/xparse/xparse.ins b/l3packages/xparse/xparse.ins
index d40f7cd6f..17a94782a 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-generic.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.