[latex3-commits] [git/LaTeX3-latex3-latex3] scan-quark: Have \__kernel_quark_test_generate:N read the module from the function (8109576a9)
PhelypeOleinik
tex.phelype at gmail.com
Mon Apr 27 05:43:26 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : scan-quark
Link : https://github.com/latex3/latex3/commit/8109576a95fffa0649b43c67f1a011344d0f5bd4
>---------------------------------------------------------------
commit 8109576a95fffa0649b43c67f1a011344d0f5bd4
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date: Mon Apr 27 00:43:26 2020 -0300
Have \__kernel_quark_test_generate:N read the module from the function
>---------------------------------------------------------------
8109576a95fffa0649b43c67f1a011344d0f5bd4
l3kernel/l3clist.dtx | 4 +--
l3kernel/l3debug.dtx | 2 +-
l3kernel/l3file.dtx | 4 +--
l3kernel/l3int.dtx | 4 +--
l3kernel/l3kernel-functions.dtx | 8 ++---
l3kernel/l3keys.dtx | 2 +-
l3kernel/l3prg.dtx | 2 +-
l3kernel/l3prop.dtx | 2 +-
l3kernel/l3quark.dtx | 65 +++++++++++++++++++++++++++++++++++----
l3kernel/l3str.dtx | 4 +--
l3kernel/l3text-purify.dtx | 2 +-
l3kernel/l3text.dtx | 2 +-
l3kernel/l3tl.dtx | 2 +-
l3kernel/testfiles/m3quark002.lvt | 32 +++++++++----------
14 files changed, 94 insertions(+), 41 deletions(-)
diff --git a/l3kernel/l3clist.dtx b/l3kernel/l3clist.dtx
index b1fdbc07a..142ffa89d 100644
--- a/l3kernel/l3clist.dtx
+++ b/l3kernel/l3clist.dtx
@@ -814,8 +814,8 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_break:nN,\@@_if_recursion_tail_stop:n}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_break:nN { @@ }
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:n { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_break:nN
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:n
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3debug.dtx b/l3kernel/l3debug.dtx
index 9d9b839ef..53c1803a1 100644
--- a/l3kernel/l3debug.dtx
+++ b/l3kernel/l3debug.dtx
@@ -158,7 +158,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_use_none_delimit_by_q_recursion_stop:w
#1 \q_@@_recursion_stop { }
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:N { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:N
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 17a7c19c8..92d665c27 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -2451,8 +2451,8 @@
% }
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:N { @@ }
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop_do:nn { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:N
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop_do:nn
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3int.dtx b/l3kernel/l3int.dtx
index 5d3c218c7..3902b0702 100644
--- a/l3kernel/l3int.dtx
+++ b/l3kernel/l3int.dtx
@@ -1079,8 +1079,8 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop_do:Nn,\@@_if_recursion_tail_stop:N}
% Functions to query quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop_do:Nn { @@ }
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:N { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop_do:Nn
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:N
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3kernel-functions.dtx b/l3kernel/l3kernel-functions.dtx
index 575ac79f3..5f70f4670 100644
--- a/l3kernel/l3kernel-functions.dtx
+++ b/l3kernel/l3kernel-functions.dtx
@@ -329,9 +329,9 @@
% and variable mappings.
% \end{variable}
%
-% \begin{function}{\__kernel_quark_test_generate:Nn}
+% \begin{function}{\__kernel_quark_test_generate:N}
% \begin{syntax}
-% \cs{__kernel_quark_test_generate:Nn} \cs[no-index]{\meta{name}:\meta{arg spec}} \Arg{namespace}
+% \cs{__kernel_quark_test_generate:N} \cs[no-index]{\meta{name}:\meta{arg spec}}
% \end{syntax}
% Defines a quark-test function \cs[no-index]{\meta{name}:\meta{arg spec}}
% which tests if its argument is \cs[no-index]{q\meta{namespace}_recursion_tail},
@@ -346,7 +346,7 @@
% in the definition of auxiliaries (for example |__module|), obtained
% for instance as |@@| when using \pkg{l3docstrip}.
%
-% \cs{__kernel_quark_test_generate:Nn} can define $6$ different
+% \cs{__kernel_quark_test_generate:N} can define $6$ different
% types of quark-test functions. Which one is defined depends on
% the \meta{arg spec} of the given function:
% \begin{description}
@@ -383,7 +383,7 @@
% Any other signature, as well as a function without signature
% are errors, and in such case the definition is aborted.
%
-% \cs{__kernel_quark_test_generate:Nn} does \emph{not} define
+% \cs{__kernel_quark_test_generate:N} does \emph{not} define
% the \cs[no-index]{q\meta{namespace}_recursion_tail} and
% \cs[no-index]{q\meta{namespace}_recursion_stop}.
% They should be manually defined with \cs{quark_new:N}.
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index 5ab62fdb1..a950856d5 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -1434,7 +1434,7 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop:n}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:n { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:n
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index 63b8c28f8..6756e0570 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -938,7 +938,7 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop_do:nn}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop_do:nn { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop_do:nn
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3prop.dtx b/l3kernel/l3prop.dtx
index 71153aae8..5249910e8 100644
--- a/l3kernel/l3prop.dtx
+++ b/l3kernel/l3prop.dtx
@@ -639,7 +639,7 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop:o}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:n { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:n
\cs_generate_variant:Nn \@@_if_recursion_tail_stop:n { o }
% \end{macrocode}
% \end{macro}
diff --git a/l3kernel/l3quark.dtx b/l3kernel/l3quark.dtx
index af1c6d9f4..b098da7d1 100644
--- a/l3kernel/l3quark.dtx
+++ b/l3kernel/l3quark.dtx
@@ -574,8 +574,8 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\__kernel_quark_test_generate:Nn}
-% The function \cs{__kernel_quark_test_generate:Nn} defines |#1| in a
+% \begin{macro}{\__kernel_quark_test_generate:N}
+% The function \cs{__kernel_quark_test_generate:N} defines |#1| in a
% similar way as
% \cs[no-index]{quark_if_recursion_tail_stop(_do):(N|n)(n)}. using
% \cs[no-index]{q\meta{namespace}_recursion_tail} as the test quark
@@ -597,7 +597,7 @@
% Any other signature causes an error, as does a function without signature.
%
% \begin{macro}{\__kernel_quark_conditional_generate:NNnn}
-% Similar to \cs{__kernel_quark_test_generate:Nn}, but defines
+% Similar to \cs{__kernel_quark_test_generate:N}, but defines
% quark branching conditionals like \cs{quark_if_nil:nTF}
% using |#2| as the test quark, |#3| as the name-space to define
% auxiliaries, and |#4| is the list of conditional variants to define.
@@ -612,11 +612,14 @@
% \begin{macro}{\@@_test_generate:NNNn, \@@_test_generate:Nccn,
% \@@_test_generate_aux:nnNNnNnn, \@@_test_generate_choose:nNnNnn}
% \begin{macrocode}
-\cs_new_protected:Npn \__kernel_quark_test_generate:Nn #1#2
+\cs_new_protected:Npn \__kernel_quark_test_generate:N #1
+ { \@@_test_generate_aux:Nn #1 { __ \@@_get_module_name:N #1 } }
+\cs_new_protected:Npn \@@_test_generate_aux:Nn #1 #2
{
\@@_test_generate:Nccn #1
{ q #2 _recursion_tail } { q #2 _recursion_stop } {#2}
}
+\cs_generate_variant:Nn \@@_test_generate_aux:Nn { Nx }
\cs_new_protected:Npn \@@_test_generate:NNNn #1
{
\exp_last_unbraced:Nf \@@_test_generate_aux:nnNNnNnn
@@ -710,9 +713,9 @@
% \cs[no-index]{use_(none|i)_delimit_by_q_recursion_stop:(|n)w}.
%
% The name is composed by the name-space and the name of the quarks.
-% Suppose \cs{__kernel_quark_test_generate:Nn} was used with:
+% Suppose \cs{__kernel_quark_test_generate:N} was used with:
% \begin{verbatim}
-% \__kernel_quark_test_generate:NNNn \__test_quark_tail:n { __test }
+% \__kernel_quark_test_generate:N \__test_quark_tail:n
% \end{verbatim}
% then the first auxiliary will be \cs[no-index]{__test_quark_recursion_tail:w},
% and the second one will be
@@ -867,6 +870,56 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[rEXP]{\@@_get_module_name:N}
+% \begin{macro}[rEXP]{
+% \@@_get_module_name_auxi:w,
+% \@@_get_module_name_auxii:w,
+% }
+% \cs{@@_get_module_name:N} takes a function and returns the \meta{module} name.
+% |#1| may be a public function named as
+% \cs[no-index]{\meta{module}_\meta{name}:\meta{signature}}, or a private
+% function named as \cs[no-index]{__\meta{module}_\meta{name}:\meta{signature}}
+% (more precisely, any number of underscore characters are removed from the start
+% of the function name, and the \meta{module} name is delimited by the next |_|).
+% \begin{macrocode}
+\cs_new:Npx \@@_get_module_name:N #1
+ {
+ \exp_not:N \exp_last_unbraced:Nf \exp_not:N \@@_get_module_name_auxi:w
+ { \exp_not:N \cs_to_str:N #1 } \token_to_str:N _ \exp_not:N \s_@@
+ }
+\cs_new:Npn \@@_get_module_name_auxi:w #1
+ {
+ \if_meaning:w \s_@@ #1
+ \__kernel_msg_expandable_error:nn { kernel } { invalid-quark-function }
+ \else:
+ \if_charcode:w _ #1
+ \exp_after:wN \use_i:nn
+ \else:
+ \exp_after:wN \use_ii:nn
+ \fi:
+ { \exp_after:wN \@@_get_module_name_auxi:w }
+ {
+ \exp_after:wN \@@_get_module_name_auxii:w
+ \exp_after:wN #1
+ }
+ \fi:
+ }
+\use:x
+ {
+ \cs_new:Npn \exp_not:N \@@_get_module_name_auxii:w ##1
+ \token_to_str:N _ ##2 \exp_not:N \s_@@
+ }
+ {
+ \if:w \scan_stop: \tl_to_str:n {#1} \scan_stop:
+ \__kernel_msg_expandable_error:nn { kernel } { invalid-quark-function }
+ \else:
+ #1
+ \fi:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Scan marks}
%
% \begin{macrocode}
diff --git a/l3kernel/l3str.dtx b/l3kernel/l3str.dtx
index 115a313e9..8ad56105d 100644
--- a/l3kernel/l3str.dtx
+++ b/l3kernel/l3str.dtx
@@ -897,8 +897,8 @@
% }
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_break:NN { @@ }
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop_do:Nn { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_break:NN
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop_do:Nn
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3text-purify.dtx b/l3kernel/l3text-purify.dtx
index 6a91cae98..029017f8a 100644
--- a/l3kernel/l3text-purify.dtx
+++ b/l3kernel/l3text-purify.dtx
@@ -68,7 +68,7 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop:N}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop:N { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop:N
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index e5bf85748..11d8136cb 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -295,7 +295,7 @@
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop_do:Nn}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_stop_do:Nn { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_stop_do:Nn
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/l3tl.dtx b/l3kernel/l3tl.dtx
index fd3afd4b8..6a6f47ef6 100644
--- a/l3kernel/l3tl.dtx
+++ b/l3kernel/l3tl.dtx
@@ -1528,7 +1528,7 @@
% \begin{macro}[pTF]{\@@_if_recursion_tail_stop:n}
% Functions to query recursion quarks.
% \begin{macrocode}
-\__kernel_quark_test_generate:Nn \@@_if_recursion_tail_break:nN { @@ }
+\__kernel_quark_test_generate:N \@@_if_recursion_tail_break:nN
\__kernel_quark_conditional_generate:NNnn \@@_if_nil:n
\q_@@_nil { @@ } { TF }
% \end{macrocode}
diff --git a/l3kernel/testfiles/m3quark002.lvt b/l3kernel/testfiles/m3quark002.lvt
index 88f7bad26..ad2dff14e 100644
--- a/l3kernel/testfiles/m3quark002.lvt
+++ b/l3kernel/testfiles/m3quark002.lvt
@@ -19,38 +19,38 @@
\quark_new:N \q__test_recursion_stop
\TEST{New~private~quark~functions~(:n)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_stop:n { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_stop:n
\cs_log:N \__test_quark_if_recursion_tail_stop:n
}
\TEST{New~private~quark~functions~(:nn)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_stop_do:nn { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_stop_do:nn
\cs_log:N \__test_quark_if_recursion_tail_stop_do:nn
}
\TEST{New~private~quark~functions~(:N)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_stop:N { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_stop:N
\cs_log:N \__test_quark_if_recursion_tail_stop:N
}
\TEST{New~private~quark~functions~(:Nn)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_stop_do:Nn { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_stop_do:Nn
\cs_log:N \__test_quark_if_recursion_tail_stop_do:Nn
}
\TEST{New~private~quark~functions~(:nN)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_break:nN { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_break:nN
\cs_log:N \__test_quark_if_recursion_tail_break:nN
}
\TEST{New~private~quark~functions~(:NN)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_break:NN { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_break:NN
\cs_log:N \__test_quark_if_recursion_tail_break:NN
}
@@ -86,10 +86,10 @@
}
\TEST{Invalid~signatures~(expect~errors)}{
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_break:nnn { __test }
- \__kernel_quark_test_generate:Nn
- \__test_quark_if_recursion_tail_break { __test }
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_break:nnn
+ \__kernel_quark_test_generate:N
+ \__test_quark_if_recursion_tail_break
}
\END
More information about the latex3-commits
mailing list.