summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3kernel/l3regex.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3regex.dtx')
-rw-r--r--macros/latex/contrib/l3kernel/l3regex.dtx545
1 files changed, 271 insertions, 274 deletions
diff --git a/macros/latex/contrib/l3kernel/l3regex.dtx b/macros/latex/contrib/l3kernel/l3regex.dtx
index 37245cb0b9..952c115d29 100644
--- a/macros/latex/contrib/l3kernel/l3regex.dtx
+++ b/macros/latex/contrib/l3kernel/l3regex.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2024-01-04}
+% \date{Released 2024-01-22}
%
% \maketitle
%
@@ -228,7 +228,7 @@
% Matches any of the specified tokens.
% \item[{[\char`\^\ldots{}]}] Negative character class.
% Matches any token other than the specified characters.
-% \item[{x-y}] Within a character class, this denotes a range (can be
+% \item[{[x-y]}] Within a character class, this denotes a range (can be
% used with escaped characters).
% \item[{[:\meta{name}:]}] Within a character class (one more set of
% brackets), this denotes the \textsc{posix} character class
@@ -928,9 +928,6 @@
% \item Does |\K| really need a new state for itself?
% \item When compiling, use a boolean \texttt{in_cs} and less magic
% numbers.
-% \item Instead of checking whether the character is special or
-% alphanumeric using its character code, check if it is special in
-% regexes with \cs[no-index]{cs_if_exist} tests.
% \end{itemize}
%
% The following features are likely to be implemented at some point
@@ -1135,10 +1132,10 @@
% Empty a \tn{toks} or set it to a value, given its number.
% \begin{macrocode}
\cs_new_protected:Npn \@@_toks_clear:N #1
- { \@@_toks_set:Nn #1 { } }
+ { \tex_toks:D #1 = { } }
\cs_new_eq:NN \@@_toks_set:Nn \tex_toks:D
\cs_new_protected:Npn \@@_toks_set:No #1
- { \tex_toks:D #1 \exp_after:wN }
+ { \tex_toks:D #1 = \exp_after:wN }
% \end{macrocode}
% \end{macro}
%
@@ -1167,20 +1164,24 @@
% \cs{@@_toks_put_right:Ne} is provided because it is more
% efficient than \texttt{e}-expanding with \cs{exp_not:n}.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_toks_put_left:Ne #1#2
+\cs_if_exist:NTF \tex_etokspre:D
+ { \cs_new_eq:NN \@@_toks_put_left:Ne \tex_etokspre:D }
{
- \cs_set_nopar:Npe \@@_tmp:w { #2 }
- \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN
- { \exp_after:wN \@@_tmp:w \tex_the:D \tex_toks:D #1 }
+ \cs_new_protected:Npn \@@_toks_put_left:Ne #1#2
+ { \tex_toks:D #1 = \tex_expanded:D {{ #2 \tex_the:D \tex_toks:D #1 }} }
}
-\cs_new_protected:Npn \@@_toks_put_right:Ne #1#2
+\cs_if_exist:NTF \tex_etoksapp:D
+ { \cs_new_eq:NN \@@_toks_put_right:Ne \tex_etoksapp:D }
{
- \cs_set_nopar:Npe \@@_tmp:w {#2}
- \tex_toks:D #1 \exp_after:wN
- { \tex_the:D \tex_toks:D \exp_after:wN #1 \@@_tmp:w }
+ \cs_new_protected:Npn \@@_toks_put_right:Ne #1#2
+ { \tex_toks:D #1 = \tex_expanded:D {{ \tex_the:D \tex_toks:D #1 #2 }} }
+ }
+\cs_if_exist:NTF \tex_toksapp:D
+ { \cs_new_eq:NN \@@_toks_put_right:Nn \tex_toksapp:D }
+ {
+ \cs_new_protected:Npn \@@_toks_put_right:Nn #1#2
+ { \tex_toks:D #1 = \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } }
}
-\cs_new_protected:Npn \@@_toks_put_right:Nn #1#2
- { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1203,15 +1204,13 @@
% Item of intarray, with a default value.
% \begin{macrocode}
\cs_new:Npn \@@_intarray_item:NnF #1#2
- { \exp_args:Nf \@@_intarray_item_aux:nNF { \int_eval:n {#2} } #1 }
+ { \exp_args:No \@@_intarray_item_aux:nNF { \tex_the:D \@@_int_eval:w #2 } #1 }
\cs_new:Npn \@@_intarray_item_aux:nNF #1#2
{
\if_int_compare:w #1 > \c_zero_int
- \exp_after:wN \use_i:nn
- \else:
- \exp_after:wN \use_ii:nn
+ \exp_after:wN \use_ii:nnn
\fi:
- { \__kernel_intarray_item:Nn #2 {#1} }
+ \use_ii:nn { \__kernel_intarray_item:Nn #2 {#1} }
}
% \end{macrocode}
% \end{macro}
@@ -1465,14 +1464,12 @@
\if_int_compare:w \l_@@_curr_char_int > `Z \exp_stop_f:
\if_int_compare:w \l_@@_curr_char_int > `z \exp_stop_f: \else:
\if_int_compare:w \l_@@_curr_char_int < `a \exp_stop_f: \else:
- \int_sub:Nn \l_@@_case_changed_char_int
- { \c_@@_ascii_lower_int }
+ \int_sub:Nn \l_@@_case_changed_char_int \c_@@_ascii_lower_int
\fi:
\fi:
\else:
\if_int_compare:w \l_@@_curr_char_int < `A \exp_stop_f: \else:
- \int_add:Nn \l_@@_case_changed_char_int
- { \c_@@_ascii_lower_int }
+ \int_add:Nn \l_@@_case_changed_char_int \c_@@_ascii_lower_int
\fi:
\fi:
\cs_set_eq:NN \@@_maybe_compute_ccc: \prg_do_nothing:
@@ -1510,12 +1507,12 @@
\or: 1000000 \or: 4000000 \else: 1*0
\fi:
}
-\cs_new_protected:Npn \@@_item_catcode:nT #1
+\prg_new_protected_conditional:Npnn \@@_item_catcode:n #1 { T }
{
- \if_int_odd:w \int_eval:n { #1 / \@@_item_catcode: } \exp_stop_f:
- \exp_after:wN \use:n
+ \if_int_odd:w \@@_int_eval:w #1 / \@@_item_catcode: \scan_stop:
+ \prg_return_true:
\else:
- \exp_after:wN \use_none:n
+ \prg_return_false:
\fi:
}
\cs_new_protected:Npn \@@_item_catcode_reverse:nT #1#2
@@ -1539,9 +1536,9 @@
}
\cs_new_protected:Npn \@@_item_exact_cs:n #1
{
- \int_compare:nNnTF \l_@@_curr_catcode_int = 0
+ \int_compare:nNnTF \l_@@_curr_catcode_int = \c_zero_int
{
- \__kernel_tl_set:Ne \l_@@_internal_a_tl
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl
{ \scan_stop: \@@_curr_cs_to_str: \scan_stop: }
\tl_if_in:noTF { \scan_stop: #1 \scan_stop: }
\l_@@_internal_a_tl
@@ -1560,7 +1557,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_item_cs:n #1
{
- \int_compare:nNnT \l_@@_curr_catcode_int = 0
+ \int_compare:nNnT \l_@@_curr_catcode_int = \c_zero_int
{
\group_begin:
\@@_single_match:
@@ -1729,7 +1726,7 @@
\cs_set:Npn \@@_escape_escaped:N ##1 { #2 }
\cs_set:Npn \@@_escape_raw:N ##1 { #3 }
\@@_standard_escapechar:
- \__kernel_tl_gset:Ne \g_@@_internal_tl
+ \__kernel_tl_gset:Nx \g_@@_internal_tl
{ \__kernel_str_to_other_fast:n {#4} }
\tl_put_right:Ne \l_@@_internal_a_tl
{
@@ -1936,13 +1933,13 @@
% lowercase letters, which we need to detect and replace by their
% uppercase counterpart.
% \begin{macrocode}
-\prg_new_conditional:Npnn \@@_hexadecimal_use:N #1 { TF }
+\cs_new:Npn \@@_hexadecimal_use:NTF #1
{
- \if_int_compare:w 1 < "1 \token_to_str:N #1 \exp_stop_f:
- #1 \prg_return_true:
+ \if_int_compare:w \c_one_int < "1 \token_to_str:N #1 \exp_stop_f:
+ #1
\else:
\if_case:w
- \int_eval:n { \exp_after:wN ` \token_to_str:N #1 - `a }
+ \@@_int_eval:w \exp_after:wN ` \token_to_str:N #1 - `a \scan_stop:
A
\or: B
\or: C
@@ -1950,11 +1947,10 @@
\or: E
\or: F
\else:
- \prg_return_false:
- \exp_after:wN \use_none:n
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
\fi:
- \prg_return_true:
\fi:
+ \use_i:nn
}
% \end{macrocode}
% \end{macro}
@@ -1986,43 +1982,57 @@
% \begin{macrocode}
\prg_new_conditional:Npnn \@@_char_if_special:N #1 { TF }
{
- \if_int_compare:w `#1 > `Z \exp_stop_f:
- \if_int_compare:w `#1 > `z \exp_stop_f:
- \if_int_compare:w `#1 < \c_@@_ascii_max_int
- \prg_return_true: \else: \prg_return_false: \fi:
- \else:
- \if_int_compare:w `#1 < `a \exp_stop_f:
- \prg_return_true: \else: \prg_return_false: \fi:
- \fi:
+ \if:w
+ T
+ \if_int_compare:w `#1 > `Z \exp_stop_f:
+ \if_int_compare:w `#1 > `z \exp_stop_f:
+ \if_int_compare:w `#1 < \c_@@_ascii_max_int
+ \else: F \fi:
+ \else:
+ \if_int_compare:w `#1 < `a \exp_stop_f:
+ \else: F \fi:
+ \fi:
+ \else:
+ \if_int_compare:w `#1 > `9 \exp_stop_f:
+ \if_int_compare:w `#1 < `A \exp_stop_f:
+ \else: F \fi:
+ \else:
+ \if_int_compare:w `#1 < `0 \exp_stop_f:
+ \if_int_compare:w `#1 < `\ \exp_stop_f:
+ F \fi:
+ \else: F \fi:
+ \fi:
+ \fi:
+ T
+ \prg_return_true:
\else:
- \if_int_compare:w `#1 > `9 \exp_stop_f:
- \if_int_compare:w `#1 < `A \exp_stop_f:
- \prg_return_true: \else: \prg_return_false: \fi:
- \else:
- \if_int_compare:w `#1 < `0 \exp_stop_f:
- \if_int_compare:w `#1 < `\ \exp_stop_f:
- \prg_return_false: \else: \prg_return_true: \fi:
- \else: \prg_return_false: \fi:
- \fi:
+ \prg_return_false:
\fi:
}
\prg_new_conditional:Npnn \@@_char_if_alphanumeric:N #1 { TF }
{
- \if_int_compare:w `#1 > `Z \exp_stop_f:
- \if_int_compare:w `#1 > `z \exp_stop_f:
- \prg_return_false:
- \else:
- \if_int_compare:w `#1 < `a \exp_stop_f:
- \prg_return_false: \else: \prg_return_true: \fi:
- \fi:
+ \if:w
+ T
+ \if_int_compare:w `#1 > `Z \exp_stop_f:
+ \if_int_compare:w `#1 > `z \exp_stop_f:
+ F
+ \else:
+ \if_int_compare:w `#1 < `a \exp_stop_f:
+ F \fi:
+ \fi:
+ \else:
+ \if_int_compare:w `#1 > `9 \exp_stop_f:
+ \if_int_compare:w `#1 < `A \exp_stop_f:
+ F \fi:
+ \else:
+ \if_int_compare:w `#1 < `0 \exp_stop_f:
+ F \fi:
+ \fi:
+ \fi:
+ T
+ \prg_return_true:
\else:
- \if_int_compare:w `#1 > `9 \exp_stop_f:
- \if_int_compare:w `#1 < `A \exp_stop_f:
- \prg_return_false: \else: \prg_return_true: \fi:
- \else:
- \if_int_compare:w `#1 < `0 \exp_stop_f:
- \prg_return_false: \else: \prg_return_true: \fi:
- \fi:
+ \prg_return_false:
\fi:
}
% \end{macrocode}
@@ -2179,17 +2189,14 @@
% Besides, the expanding behaviour of \cs{if:w} is very useful as that
% means we can use \cs{c_left_brace_str} and the like.
% \begin{macrocode}
-\prg_new_conditional:Npnn \@@_two_if_eq:NNNN #1#2#3#4 { TF }
+\cs_new:Npn \@@_two_if_eq:NNNNTF #1#2#3#4
{
\if_meaning:w #1 #3
\if:w #2 #4
- \prg_return_true:
- \else:
- \prg_return_false:
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nnn
\fi:
- \else:
- \prg_return_false:
\fi:
+ \use_ii:nn
}
% \end{macrocode}
% \end{macro}
@@ -2220,17 +2227,14 @@
% Test used when grabbing digits for the |{m,n}| quantifier.
% It only accepts non-escaped digits.
% \begin{macrocode}
-\prg_new_conditional:Npnn \@@_if_raw_digit:NN #1#2 { TF }
+\cs_new:Npn \@@_if_raw_digit:NNTF #1#2
{
\if_meaning:w \@@_compile_raw:N #1
- \if_int_compare:w 1 < 1 #2 \exp_stop_f:
- \prg_return_true:
- \else:
- \prg_return_false:
+ \if_int_compare:w \c_one_int < 1 #2 \exp_stop_f:
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nnn
\fi:
- \else:
- \prg_return_false:
\fi:
+ \use_ii:nn
}
% \end{macrocode}
% \end{macro}
@@ -2284,12 +2288,12 @@
% and special characters are normal. Also, for every raw character, we
% must look ahead for a possible raw dash.
% \begin{macrocode}
-\cs_new:Npn \@@_if_in_class:TF
+\prg_new_conditional:Npnn \@@_if_in_class: { TF }
{
\if_int_odd:w \l_@@_mode_int
- \exp_after:wN \use_i:nn
+ \prg_return_true:
\else:
- \exp_after:wN \use_ii:nn
+ \prg_return_false:
\fi:
}
% \end{macrocode}
@@ -2302,14 +2306,12 @@
\cs_new:Npn \@@_if_in_cs:TF
{
\if_int_odd:w \l_@@_mode_int
- \exp_after:wN \use_ii:nn
\else:
\if_int_compare:w \l_@@_mode_int < \c_@@_outer_mode_int
- \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn
- \else:
- \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nnn
\fi:
\fi:
+ \use_ii:nn
}
% \end{macrocode}
% \end{macro}
@@ -2321,14 +2323,13 @@
\cs_new:Npn \@@_if_in_class_or_catcode:TF
{
\if_int_odd:w \l_@@_mode_int
- \exp_after:wN \use_i:nn
\else:
\if_int_compare:w \l_@@_mode_int > \c_@@_outer_mode_int
- \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn
\else:
- \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
\fi:
\fi:
+ \use_i:nn
}
% \end{macrocode}
% \end{macro}
@@ -2339,12 +2340,12 @@
% it applies (modes $23$ and $63$). This is used to tweak how left
% brackets behave in modes $2$ and $6$.
% \begin{macrocode}
-\cs_new:Npn \@@_if_within_catcode:TF
+\prg_new_conditional:Npnn \@@_if_within_catcode: { TF }
{
\if_int_compare:w \l_@@_mode_int > \c_@@_outer_mode_int
- \exp_after:wN \use_i:nn
+ \prg_return_true:
\else:
- \exp_after:wN \use_ii:nn
+ \prg_return_false:
\fi:
}
% \end{macrocode}
@@ -2357,15 +2358,14 @@
\cs_new_protected:Npn \@@_chk_c_allowed:T
{
\if_int_compare:w \l_@@_mode_int = \c_@@_outer_mode_int
- \exp_after:wN \use:n
\else:
\if_int_compare:w \l_@@_mode_int = \c_@@_class_mode_int
- \exp_after:wN \exp_after:wN \exp_after:wN \use:n
\else:
\msg_error:nn { regex } { c-bad-mode }
- \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n
+ \exp_after:wN \use_i:nnn
\fi:
\fi:
+ \use:n
}
% \end{macrocode}
% \end{macro}
@@ -2424,7 +2424,7 @@
\msg_error:nne { regex } { missing-rparen }
{ \int_use:N \l_@@_group_level_int }
\prg_replicate:nn
- { \l_@@_group_level_int }
+ \l_@@_group_level_int
{
\tl_build_put_right:Nn \l_@@_build_tl
{
@@ -2712,7 +2712,7 @@
{ \@@_compile_special:N \c_right_brace_str }
{
\exp_args:No \@@_compile_quantifier_lazyness:nnNN
- { \int_use:N \l_@@_internal_a_int } { 0 }
+ { \int_use:N \l_@@_internal_a_int } 0
}
{ \@@_compile_special:N , }
{
@@ -2818,21 +2818,19 @@
% raw character; any special character, except a right bracket. In
% particular, escaped characters are forbidden.
% \begin{macrocode}
-\prg_new_protected_conditional:Npnn \@@_if_end_range:NN #1#2 { TF }
+\cs_new_protected:Npn \@@_if_end_range:NNTF #1#2
{
\if_meaning:w \@@_compile_raw:N #1
- \prg_return_true:
\else:
\if_meaning:w \@@_compile_special:N #1
\if_charcode:w ] #2
- \prg_return_false:
- \else:
- \prg_return_true:
+ \use_i:nn
\fi:
\else:
- \prg_return_false:
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
\fi:
\fi:
+ \use_i:nn
}
\cs_new_protected:Npn \@@_compile_range:Nw #1#2#3
{
@@ -3133,12 +3131,12 @@
\@@_two_if_eq:NNNNTF #5 #6 \@@_compile_special:N ^
{
\bool_set_false:N \l_@@_internal_bool
- \__kernel_tl_set:Ne \l_@@_internal_a_tl { \if_false: } \fi:
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl { \if_false: } \fi:
\@@_compile_class_posix_loop:w
}
{
\bool_set_true:N \l_@@_internal_bool
- \__kernel_tl_set:Ne \l_@@_internal_a_tl { \if_false: } \fi:
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl { \if_false: } \fi:
\@@_compile_class_posix_loop:w #5 #6
}
}
@@ -3460,7 +3458,7 @@
}
\cs_new_protected:Npn \@@_compile_c_lbrack_add:N #1
{
- \if_int_odd:w \int_eval:n { \l_@@_catcodes_int / #1 } \exp_stop_f:
+ \if_int_odd:w \@@_int_eval:w \l_@@_catcodes_int / #1 \scan_stop:
\else:
\int_add:Nn \l_@@_catcodes_int {#1}
\fi:
@@ -3510,7 +3508,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{variable}{@@_cs}
+% \begin{variable}{\l_@@_cs_flag}
% \begin{macro}+\@@_compile_}:+
% \begin{macro}{\@@_compile_end_cs:}
% \begin{macro}[EXP]{\@@_compile_cs_aux:Nn, \@@_compile_cs_aux:NNnnnN}
@@ -3524,7 +3522,7 @@
% \cs{@@_item_exact_cs:n} with an argument consisting of all
% possibilities separated by \cs{scan_stop:}.
% \begin{macrocode}
-\flag_new:n { @@_cs }
+\flag_new:N \l_@@_cs_flag
\cs_new_protected:cpn { @@_compile_ \c_right_brace_str : }
{
\@@_if_in_cs:TF
@@ -3534,15 +3532,15 @@
\cs_new_protected:Npn \@@_compile_end_cs:
{
\@@_compile_end:
- \flag_clear:n { @@_cs }
- \__kernel_tl_set:Ne \l_@@_internal_a_tl
+ \flag_clear:N \l_@@_cs_flag
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl
{
\exp_after:wN \@@_compile_cs_aux:Nn \l_@@_internal_regex
\q_@@_nil \q_@@_nil \q_@@_recursion_stop
}
\exp_args:Ne \@@_compile_one:n
{
- \flag_if_raised:nTF { @@_cs }
+ \flag_if_raised:NTF \l_@@_cs_flag
{ \@@_item_cs:n { \exp_not:o \l_@@_internal_regex } }
{
\@@_item_exact_cs:n
@@ -3561,7 +3559,7 @@
\@@_compile_cs_aux:Nn
}
{
- \@@_quark_if_nil:NF #1 { \flag_ensure_raised:n { @@_cs } }
+ \@@_quark_if_nil:NF #1 { \flag_ensure_raised:N \l_@@_cs_flag }
\@@_use_none_delimit_by_q_recursion_stop:w
}
}
@@ -3573,7 +3571,7 @@
{#2}
{ \tl_if_head_eq_meaning_p:nN {#3} \@@_item_caseful_equal:n }
{ \int_compare_p:nNn { \tl_count:n {#3} } = { 2 } }
- { \int_compare_p:nNn {#5} = { 0 } }
+ { \int_compare_p:nNn {#5} = \c_zero_int }
}
{
\prg_replicate:nn {#4}
@@ -3583,7 +3581,7 @@
{
\@@_quark_if_nil:NF #1
{
- \flag_ensure_raised:n { @@_cs }
+ \flag_ensure_raised:N \l_@@_cs_flag
\@@_use_i_delimit_by_q_recursion_stop:nw
}
\@@_use_none_delimit_by_q_recursion_stop:w
@@ -3624,7 +3622,7 @@
\@@_two_if_eq:NNNNTF #2 #3 \@@_compile_special:N \c_left_brace_str
{
\tl_set:Nn \l_@@_internal_b_tl {#1}
- \__kernel_tl_set:Ne \l_@@_internal_a_tl { \if_false: } \fi:
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl { \if_false: } \fi:
\@@_compile_u_loop:NN
}
{
@@ -3758,7 +3756,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_compile_u_in_cs:
{
- \__kernel_tl_gset:Ne \g_@@_internal_tl
+ \__kernel_tl_gset:Nx \g_@@_internal_tl
{
\exp_args:No \__kernel_str_to_other_fast:n
{ \l_@@_internal_a_tl }
@@ -3857,10 +3855,10 @@
}
\cs_new:Npn \@@_clean_int_aux:N #1
{
- \if_int_compare:w 1 < 1 #1 ~
+ \if_int_compare:w \c_one_int < 1 #1 ~
#1
\else:
- \exp_after:wN \str_map_break:
+ \str_map_break:n
\fi:
}
\cs_new:Npn \@@_clean_regex:n #1
@@ -3881,7 +3879,7 @@
}
\cs_new:Npn \@@_clean_branch_loop:n #1
{
- \tl_if_single:nF {#1} { \prg_break: }
+ \tl_if_single:nF {#1} \prg_break:
\token_case_meaning:NnF #1
{
\@@_command_K: { #1 \@@_clean_branch_loop:n }
@@ -3891,7 +3889,7 @@
\@@_group_no_capture:nnnN { #1 \@@_clean_group:nnnN }
\@@_group_resetting:nnnN { #1 \@@_clean_group:nnnN }
}
- { \prg_break: }
+ \prg_break:
}
\cs_new:Npn \@@_clean_assertion:Nn #1#2
{
@@ -3912,16 +3910,16 @@
{
\@@_clean_bool:n {#1}
{ \@@_clean_class:n {#2} }
- { \int_max:nn { 0 } { \@@_clean_int:n {#3} } }
- { \int_max:nn { -1 } { \@@_clean_int:n {#4} } }
+ { \int_max:nn \c_zero_int { \@@_clean_int:n {#3} } }
+ { \int_max:nn { -\c_one_int } { \@@_clean_int:n {#4} } }
\@@_clean_bool:n {#5}
\@@_clean_branch_loop:n
}
\cs_new:Npn \@@_clean_group:nnnN #1#2#3#4
{
{ \@@_clean_regex:n {#1} }
- { \int_max:nn { 0 } { \@@_clean_int:n {#2} } }
- { \int_max:nn { -1 } { \@@_clean_int:n {#3} } }
+ { \int_max:nn \c_zero_int { \@@_clean_int:n {#2} } }
+ { \int_max:nn { -\c_one_int } { \@@_clean_int:n {#3} } }
\@@_clean_bool:n {#4}
\@@_clean_branch_loop:n
}
@@ -3936,7 +3934,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_clean_class_loop:nnn #1#2#3
{
- \tl_if_single:nF {#1} { \prg_break: }
+ \tl_if_single:nF {#1} \prg_break:
\token_case_meaning:NnTF #1
{
\@@_item_cs:n { #1 { \@@_clean_regex:n {#2} } }
@@ -3968,10 +3966,10 @@
\@@_clean_class_loop:nnn
}
{
- \exp_args:Nf \str_case:nnTF
+ \exp_args:Ne \str_case:nnTF
{
- \exp_args:Nf \str_range:nnn
- { \cs_to_str:N #1 } { 1 } { 13 }
+ \exp_args:Ne \str_range:nnn
+ { \cs_to_str:N #1 } \c_one_int { 13 }
}
{
{ @@_prop_ } { }
@@ -3981,7 +3979,7 @@
#1
\@@_clean_class_loop:nnn {#2} {#3}
}
- { \prg_break: }
+ \prg_break:
}
}
}
@@ -4164,14 +4162,14 @@
\int_zero:N \l_@@_show_lines_int
\@@_show_push:n {~}
#2
- \int_compare:nTF { \l_@@_show_lines_int = 0 }
+ \int_compare:nTF { \l_@@_show_lines_int = \c_zero_int }
{
\group_end:
\@@_show_one:n { \bool_if:NTF #1 { Fail } { Pass } }
}
{
\bool_if:nTF
- { #1 && \int_compare_p:n { \l_@@_show_lines_int = 1 } }
+ { #1 && \int_compare_p:n { \l_@@_show_lines_int = \c_one_int } }
{
\group_end:
#2
@@ -4389,7 +4387,7 @@
%
\@@_build_new_state:
\@@_toks_put_left:Ne \l_@@_left_state_int
- { \@@_action_submatch:nN { 0 } < }
+ { \@@_action_submatch:nN \c_zero_int < }
\@@_push_lr_states:
\int_zero:N \l_@@_case_max_group_int
\int_gzero:N \g_@@_case_int
@@ -4403,18 +4401,15 @@
}
\cs_new_protected:Npn \@@_case_build_loop:n #1
{
- \int_set:Nn \l_@@_capturing_group_int { 1 }
+ \int_set_eq:NN \l_@@_capturing_group_int \c_one_int
\@@_compile_use:n {#1}
\int_set:Nn \l_@@_case_max_group_int
- {
- \int_max:nn { \l_@@_case_max_group_int }
- { \l_@@_capturing_group_int }
- }
+ { \int_max:nn \l_@@_case_max_group_int \l_@@_capturing_group_int }
\seq_pop:NN \l_@@_right_state_seq \l_@@_internal_a_tl
\int_set:Nn \l_@@_right_state_int \l_@@_internal_a_tl
\@@_toks_put_left:Ne \l_@@_right_state_int
{
- \@@_action_submatch:nN { 0 } >
+ \@@_action_submatch:nN \c_zero_int >
\int_gset:Nn \g_@@_case_int
{ \int_use:N \g_@@_case_int }
\@@_action_success:
@@ -4500,9 +4495,9 @@
% differing usage later on. Both functions could be optimized.
% \begin{macrocode}
\cs_new_protected:Npn \@@_build_transition_left:NNN #1#2#3
- { \@@_toks_put_left:Ne #2 { #1 { \int_eval:n { #3 - #2 } } } }
+ { \@@_toks_put_left:Ne #2 { #1 { \tex_the:D \@@_int_eval:w #3 - #2 } } }
\cs_new_protected:Npn \@@_build_transition_right:nNn #1#2#3
- { \@@_toks_put_right:Ne #2 { #1 { \int_eval:n { #3 - #2 } } } }
+ { \@@_toks_put_right:Ne #2 { #1 { \tex_the:D \@@_int_eval:w #3 - #2 } } }
% \end{macrocode}
% \end{macro}
%
@@ -4534,11 +4529,11 @@
\@@_toks_put_right:Ne \l_@@_left_state_int
{
\if_meaning:w \c_true_bool #1
- #2 { \int_eval:n { #3 - \l_@@_left_state_int } }
- #4 { \int_eval:n { #5 - \l_@@_left_state_int } }
+ #2 { \tex_the:D \@@_int_eval:w #3 - \l_@@_left_state_int }
+ #4 { \tex_the:D \@@_int_eval:w #5 - \l_@@_left_state_int }
\else:
- #4 { \int_eval:n { #5 - \l_@@_left_state_int } }
- #2 { \int_eval:n { #3 - \l_@@_left_state_int } }
+ #4 { \tex_the:D \@@_int_eval:w #5 - \l_@@_left_state_int }
+ #2 { \tex_the:D \@@_int_eval:w #3 - \l_@@_left_state_int }
\fi:
}
}
@@ -4636,7 +4631,7 @@
{
\@@_class_repeat:n {#1}
\int_set:Nn \l_@@_internal_a_int
- { \l_@@_max_state_int + #2 - 1 }
+ { \l_@@_max_state_int + #2 - \c_one_int }
\prg_replicate:nn { #2 }
{
\@@_build_transitions_lazyness:NNNNN #3
@@ -4730,8 +4725,8 @@
\use_none:nn #3 { \int_set:Nn \l_@@_capturing_group_int {#1} }
\int_set:Nn \l_@@_capturing_group_int {#2}
#3 {#4}
- \exp_args:Nf \@@_group_resetting_loop:nnNn
- { \int_max:nn {#1} { \l_@@_capturing_group_int } }
+ \exp_args:Ne \@@_group_resetting_loop:nnNn
+ { \int_max:nn {#1} \l_@@_capturing_group_int }
{#2}
}
% \end{macrocode}
@@ -4774,7 +4769,7 @@
{
\if_int_compare:w #2 = \c_zero_int
\int_set:Nn \l_@@_max_state_int
- { \l_@@_left_state_int - 1 }
+ { \l_@@_left_state_int - \c_one_int }
\@@_build_new_state:
\else:
\@@_group_repeat_aux:n {#2}
@@ -4816,14 +4811,14 @@
\l_@@_right_state_int \l_@@_max_state_int
\int_set_eq:NN \l_@@_internal_a_int \l_@@_left_state_int
\int_set_eq:NN \l_@@_internal_b_int \l_@@_max_state_int
- \if_int_compare:w \int_eval:n {#1} > \c_one_int
+ \if_int_compare:w \@@_int_eval:w #1 > \c_one_int
\int_set:Nn \l_@@_internal_c_int
{
- ( #1 - 1 )
+ ( #1 - \c_one_int )
* ( \l_@@_internal_b_int - \l_@@_internal_a_int )
}
- \int_add:Nn \l_@@_right_state_int { \l_@@_internal_c_int }
- \int_add:Nn \l_@@_max_state_int { \l_@@_internal_c_int }
+ \int_add:Nn \l_@@_right_state_int \l_@@_internal_c_int
+ \int_add:Nn \l_@@_max_state_int \l_@@_internal_c_int
\@@_toks_memcpy:NNn
\l_@@_internal_b_int
\l_@@_internal_a_int
@@ -4859,7 +4854,7 @@
\@@_group_submatches:nNN {#1}
\l_@@_left_state_int \l_@@_right_state_int
\int_set:Nn \l_@@_internal_a_int
- { \l_@@_left_state_int - 1 }
+ { \l_@@_left_state_int - \c_one_int }
\@@_build_transition_right:nNn \@@_action_free:n
\l_@@_right_state_int \l_@@_internal_a_int
\@@_build_new_state:
@@ -4919,7 +4914,7 @@
\l_@@_left_state_int \l_@@_max_state_int
}
\else:
- \prg_replicate:nn { #3 - 1 }
+ \prg_replicate:nn { #3 - \c_one_int }
{
\int_sub:Nn \l_@@_right_state_int
{ \l_@@_internal_b_int - \l_@@_internal_a_int }
@@ -4928,7 +4923,7 @@
}
\if_int_compare:w #2 = \c_zero_int
\int_set:Nn \l_@@_right_state_int
- { \l_@@_left_state_int - 1 }
+ { \l_@@_left_state_int - \c_one_int }
\else:
\int_sub:Nn \l_@@_right_state_int
{ \l_@@_internal_b_int - \l_@@_internal_a_int }
@@ -4963,8 +4958,8 @@
{
\@@_action_free:n
{
- \int_eval:n
- { \l_@@_right_state_int - \l_@@_left_state_int }
+ \tex_the:D \@@_int_eval:w
+ \l_@@_right_state_int - \l_@@_left_state_int
}
}
\bool_if:NT #1 { { } }
@@ -5009,12 +5004,12 @@
\@@_build_new_state:
\@@_toks_put_right:Ne \l_@@_left_state_int
{
- \@@_action_submatch:nN { 0 } <
+ \@@_action_submatch:nN \c_zero_int <
\bool_set_true:N \l_@@_fresh_thread_bool
\@@_action_free:n
{
- \int_eval:n
- { \l_@@_right_state_int - \l_@@_left_state_int }
+ \tex_the:D \@@_int_eval:w
+ \l_@@_right_state_int - \l_@@_left_state_int
}
\bool_set_false:N \l_@@_fresh_thread_bool
}
@@ -5300,10 +5295,10 @@
{
\bool_gset_false:N \g_@@_success_bool
\int_step_inline:nnn
- \l_@@_min_state_int { \l_@@_max_state_int - 1 }
+ \l_@@_min_state_int { \l_@@_max_state_int - \c_one_int }
{
\__kernel_intarray_gset:Nnn
- \g_@@_state_active_intarray {##1} { 1 }
+ \g_@@_state_active_intarray {##1} \c_one_int
}
\int_zero:N \l_@@_step_int
\int_set:Nn \l_@@_min_pos_int { 2 }
@@ -5311,7 +5306,7 @@
\int_set:Nn \l_@@_last_char_success_int { -2 }
\tl_build_begin:N \l_@@_matched_analysis_tl
\tl_clear:N \l_@@_curr_analysis_tl
- \int_set:Nn \l_@@_min_submatch_int { 1 }
+ \int_set_eq:NN \l_@@_min_submatch_int \c_one_int
\int_set_eq:NN \l_@@_submatch_int \l_@@_min_submatch_int
\bool_set_false:N \l_@@_empty_success_bool
}
@@ -5353,8 +5348,7 @@
{ \prg_replicate:nn { 2 * \l_@@_capturing_group_int } { 0 , } }
\int_set_eq:NN \l_@@_max_thread_int \l_@@_min_thread_int
\@@_store_state:n { \l_@@_min_state_int }
- \int_set:Nn \l_@@_curr_pos_int
- { \l_@@_start_pos_int - 1 }
+ \int_set:Nn \l_@@_curr_pos_int { \l_@@_start_pos_int - \c_one_int }
\int_set_eq:NN \l_@@_curr_char_int \l_@@_last_char_success_int
\tl_build_get_intermediate:NN \l_@@_matched_analysis_tl \l_@@_internal_a_tl
\exp_args:NNf \@@_match_once_init_aux:
@@ -5432,15 +5426,15 @@
{
\int_set_eq:NN \l_@@_max_thread_int \l_@@_min_thread_int
\int_step_function:nnN
- { \l_@@_min_thread_int }
- { \l_@@_max_thread_int - 1 }
+ \l_@@_min_thread_int
+ { \l_@@_max_thread_int - \c_one_int }
\@@_match_one_active:n
}
\prg_break_point:
\bool_set_false:N \l_@@_fresh_thread_bool
\if_int_compare:w \l_@@_max_thread_int > \l_@@_min_thread_int
\if_int_compare:w -2 < \l_@@_curr_char_int
- \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n
+ \exp_after:wN \use_i:nn
\fi:
\fi:
\l_@@_every_match_tl
@@ -5450,8 +5444,8 @@
\@@_use_state_and_submatches:w
\__kernel_intarray_range_to_clist:Nnn
\g_@@_thread_info_intarray
- { 1 + #1 * (\l_@@_capturing_group_int * 2 + 1) }
- { (1 + #1) * (\l_@@_capturing_group_int * 2 + 1) }
+ { \c_one_int + #1 * (\l_@@_capturing_group_int * 2 + \c_one_int) }
+ { (\c_one_int + #1) * (\l_@@_capturing_group_int * 2 + \c_one_int) }
;
}
% \end{macrocode}
@@ -5471,11 +5465,11 @@
\cs_new_protected:Npn \@@_use_state:
{
\__kernel_intarray_gset:Nnn \g_@@_state_active_intarray
- { \l_@@_curr_state_int } { \l_@@_step_int }
+ \l_@@_curr_state_int \l_@@_step_int
\@@_toks_use:w \l_@@_curr_state_int
\__kernel_intarray_gset:Nnn \g_@@_state_active_intarray
- { \l_@@_curr_state_int }
- { \int_eval:n { \l_@@_step_int + 1 } }
+ \l_@@_curr_state_int
+ { \@@_int_eval:w \l_@@_step_int + \c_one_int \scan_stop: }
}
% \end{macrocode}
% \end{macro}
@@ -5491,7 +5485,7 @@
\int_set:Nn \l_@@_curr_state_int {#1}
\if_int_compare:w
\__kernel_intarray_item:Nn \g_@@_state_active_intarray
- { \l_@@_curr_state_int }
+ \l_@@_curr_state_int
< \l_@@_step_int
\tl_set:Nn \l_@@_curr_submatches_tl { #2 , }
\exp_after:wN \@@_use_state:
@@ -5548,7 +5542,7 @@
{
\if_int_compare:w
\__kernel_intarray_item:Nn \g_@@_state_active_intarray
- { \l_@@_curr_state_int }
+ \l_@@_curr_state_int
#1
\exp_after:wN \@@_use_state:
\fi:
@@ -5571,8 +5565,8 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_action_cost:n #1
{
- \exp_args:Ne \@@_store_state:n
- { \int_eval:n { \l_@@_curr_state_int + #1 } }
+ \exp_args:No \@@_store_state:n
+ { \tex_the:D \@@_int_eval:w \l_@@_curr_state_int + #1 }
}
% \end{macrocode}
% \end{macro}
@@ -5595,8 +5589,8 @@
\g_@@_thread_info_intarray
{
\@@_int_eval:w
- 1 + \l_@@_max_thread_int *
- (\l_@@_capturing_group_int * 2 + 1)
+ \c_one_int + \l_@@_max_thread_int *
+ (\l_@@_capturing_group_int * 2 + \c_one_int)
}
{ #2 , #1 }
}
@@ -5792,11 +5786,11 @@
{
\if_int_compare:w #1 < #2 \exp_stop_f:
\else:
- \exp_after:wN \prg_break:
+ \prg_break:n
\fi:
\@@_toks_use:w #1 \exp_stop_f:
\exp_after:wN \@@_query_range_loop:ww
- \int_value:w \@@_int_eval:w #1 + 1 ; #2 ;
+ \int_value:w \@@_int_eval:w #1 + \c_one_int ; #2 ;
}
% \end{macrocode}
% \end{macro}
@@ -5824,22 +5818,21 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_submatch_balance:n #1
{
- \int_eval:n
- {
- \@@_intarray_item:NnF \g_@@_balance_intarray
- {
- \__kernel_intarray_item:Nn
- \g_@@_submatch_end_intarray {#1}
- }
- { 0 }
- -
- \@@_intarray_item:NnF \g_@@_balance_intarray
- {
- \__kernel_intarray_item:Nn
- \g_@@_submatch_begin_intarray {#1}
- }
- { 0 }
- }
+ \tex_the:D \@@_int_eval:w
+ \@@_intarray_item:NnF \g_@@_balance_intarray
+ {
+ \__kernel_intarray_item:Nn
+ \g_@@_submatch_end_intarray {#1}
+ }
+ \c_zero_int
+ -
+ \@@_intarray_item:NnF \g_@@_balance_intarray
+ {
+ \__kernel_intarray_item:Nn
+ \g_@@_submatch_begin_intarray {#1}
+ }
+ \c_zero_int
+ \scan_stop:
}
% \end{macrocode}
% \end{macro}
@@ -5984,7 +5977,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_replacement_normal:n #1
{
- \int_compare:nNnTF { \l_@@_replacement_csnames_int } > 0
+ \int_compare:nNnTF \l_@@_replacement_csnames_int > \c_zero_int
{ \exp_args:No \@@_replacement_put:n { \token_to_str:N #1 } }
{
\tl_if_empty:NTF \l_@@_replacement_category_tl
@@ -6040,7 +6033,7 @@
{
\cs_if_exist_use:cF { @@_replacement_#1:w }
{
- \if_int_compare:w 1 < 1#1 \exp_stop_f:
+ \if_int_compare:w \c_one_int < 1#1 \exp_stop_f:
\@@_replacement_put_submatch:n {#1}
\else:
\@@_replacement_normal:n {#1}
@@ -6066,16 +6059,16 @@
\@@_replacement_put_submatch_aux:n {#1}
\else:
\msg_expandable_error:nnff { regex } { submatch-too-big }
- {#1} { \int_eval:n { \l_@@_capturing_group_int - 1 } }
+ {#1} { \int_eval:n { \l_@@_capturing_group_int - \c_one_int } }
\fi:
}
\cs_new_protected:Npn \@@_replacement_put_submatch_aux:n #1
{
\tl_build_put_right:Nn \l_@@_build_tl
- { \@@_query_submatch:n { \int_eval:n { #1 + ##1 } } }
+ { \@@_query_submatch:n { \@@_int_eval:w #1 + ##1 \scan_stop: } }
\if_int_compare:w \l_@@_replacement_csnames_int = \c_zero_int
\tl_gput_right:Nn \g_@@_balance_tl
- { + \@@_submatch_balance:n { \int_eval:n { #1 + ##1 } } }
+ { + \@@_submatch_balance:n { \@@_int_eval:w #1 + ##1 \scan_stop: } }
\fi:
}
% \end{macrocode}
@@ -6097,7 +6090,7 @@
{
\token_if_eq_meaning:NNTF #1 \@@_replacement_normal:n
{
- \if_int_compare:w 1 < 1#2 \exp_stop_f:
+ \if_int_compare:w \c_one_int < 1#2 \exp_stop_f:
#2
\exp_after:wN \use_i:nnn
\exp_after:wN \@@_replacement_g_digits:NN
@@ -6232,7 +6225,7 @@
\token_if_eq_meaning:NNTF \prg_do_nothing: #3
{ \msg_error:nn { regex } { replacement-catcode-end } }
{
- \int_compare:nNnTF { \l_@@_replacement_csnames_int } > 0
+ \int_compare:nNnTF \l_@@_replacement_csnames_int > \c_zero_int
{
\msg_error:nnnn
{ regex } { replacement-catcode-in-cs } {#1} {#3}
@@ -6284,7 +6277,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_replacement_char:nNN #1#2#3
{
- \tex_lccode:D 0 = `#3 \scan_stop:
+ \tex_lccode:D \c_zero_int = `#3 \scan_stop:
\tex_lowercase:D { \@@_replacement_put:n {#1} }
}
% \end{macrocode}
@@ -6637,7 +6630,6 @@
\prg_generate_conditional_variant:Nnn #2 { nV } { T , F , TF }
\cs_generate_variant:Nn #3 { NV }
\prg_generate_conditional_variant:Nnn #3 { NV } { T , F , TF }
-
}
\@@_tmp:w \@@_extract_once:nnN
\regex_extract_once:nnN \regex_extract_once:NnN
@@ -6728,12 +6720,12 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}{@@_begin, @@_end}
+% \begin{variable}{\l_@@_begin_flag, \l_@@_end_flag}
% Those flags are raised to indicate begin-group or end-group tokens
% that had to be added when extracting submatches.
% \begin{macrocode}
-\flag_new:n { @@_begin }
-\flag_new:n { @@_end }
+\flag_new:N \l_@@_begin_flag
+\flag_new:N \l_@@_end_flag
% \end{macrocode}
% \end{variable}
%
@@ -6819,7 +6811,7 @@
\int_incr:N \l_@@_curr_pos_int
\@@_toks_set:Nn \l_@@_curr_pos_int {#1}
\__kernel_intarray_gset:Nnn \g_@@_balance_intarray
- { \l_@@_curr_pos_int } { \l_@@_balance_int }
+ \l_@@_curr_pos_int \l_@@_balance_int
\if_case:w "#2 \exp_stop_f:
\or: \int_incr:N \l_@@_balance_int
\or: \int_decr:N \l_@@_balance_int
@@ -6946,29 +6938,29 @@
\l_@@_start_pos_int < \l_@@_success_pos_int
\@@_extract:
\__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray
- { \l_@@_zeroth_submatch_int } { 0 }
+ \l_@@_zeroth_submatch_int \c_zero_int
\__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray
- { \l_@@_zeroth_submatch_int }
+ \l_@@_zeroth_submatch_int
{
\__kernel_intarray_item:Nn \g_@@_submatch_begin_intarray
- { \l_@@_zeroth_submatch_int }
+ \l_@@_zeroth_submatch_int
}
\__kernel_intarray_gset:Nnn \g_@@_submatch_begin_intarray
- { \l_@@_zeroth_submatch_int }
- { \l_@@_start_pos_int }
+ \l_@@_zeroth_submatch_int
+ \l_@@_start_pos_int
\fi:
}
#1
\@@_match:n {#2}
\@@_query_set:n {#2}
\__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray
- { \l_@@_submatch_int } { 0 }
+ \l_@@_submatch_int \c_zero_int
\__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray
- { \l_@@_submatch_int }
- { \l_@@_max_pos_int }
+ \l_@@_submatch_int
+ \l_@@_max_pos_int
\__kernel_intarray_gset:Nnn \g_@@_submatch_begin_intarray
- { \l_@@_submatch_int }
- { \l_@@_start_pos_int }
+ \l_@@_submatch_int
+ \l_@@_start_pos_int
\int_incr:N \l_@@_submatch_int
\if_meaning:w \c_true_bool \l_@@_empty_success_bool
\if_int_compare:w \l_@@_start_pos_int = \l_@@_max_pos_int
@@ -6998,24 +6990,24 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_group_end_extract_seq:N #1
{
- \flag_clear:n { @@_begin }
- \flag_clear:n { @@_end }
+ \flag_clear:N \l_@@_begin_flag
+ \flag_clear:N \l_@@_end_flag
\cs_set_eq:NN \@@_tmp:w \scan_stop:
- \__kernel_tl_gset:Ne \g_@@_internal_tl
+ \__kernel_tl_gset:Nx \g_@@_internal_tl
{
- \int_step_function:nnN { \l_@@_min_submatch_int }
- { \l_@@_submatch_int - 1 } \@@_extract_seq_aux:n
+ \int_step_function:nnN \l_@@_min_submatch_int
+ { \l_@@_submatch_int - \c_one_int } \@@_extract_seq_aux:n
\@@_tmp:w
}
\int_set:Nn \l_@@_added_begin_int
- { \flag_height:n { @@_begin } }
+ { \flag_height:N \l_@@_begin_flag }
\int_set:Nn \l_@@_added_end_int
- { \flag_height:n { @@_end } }
+ { \flag_height:N \l_@@_end_flag }
\tex_afterassignment:D \@@_extract_check:w
- \__kernel_tl_gset:Ne \g_@@_internal_tl
+ \__kernel_tl_gset:Nx \g_@@_internal_tl
{ \g_@@_internal_tl \if_false: { \fi: } }
\int_compare:nNnT
- { \l_@@_added_begin_int + \l_@@_added_end_int } > 0
+ { \l_@@_added_begin_int + \l_@@_added_end_int } > \c_zero_int
{
\msg_error:nneee { regex } { result-unbalanced }
{ splitting~or~extracting~submatches }
@@ -7063,7 +7055,7 @@
\if_int_compare:w #1 < \c_zero_int
\prg_replicate:nn {-#1}
{
- \flag_raise:n { @@_begin }
+ \flag_raise:N \l_@@_begin_flag
\exp_not:n { { \if_false: } \fi: }
}
\fi:
@@ -7071,7 +7063,7 @@
\if_int_compare:w #1 > \c_zero_int
\prg_replicate:nn {#1}
{
- \flag_raise:n { @@_end }
+ \flag_raise:N \l_@@_end_flag
\exp_not:n { \if_false: { \fi: } }
}
\fi:
@@ -7087,17 +7079,17 @@
% In \cs{@@_group_end_extract_seq:N} we had to expand
% \cs{g_@@_internal_tl} to turn \cs{if_false:} constructions into
% actual begin-group and end-group tokens. This is done with a
-% \cs{__kernel_tl_gset:Ne} assignment, and \cs{@@_extract_check:w} is
+% \cs{__kernel_tl_gset:Nx} assignment, and \cs{@@_extract_check:w} is
% run immediately after this assignment ends, thanks to the
% \tn{afterassignment} primitive. If all of the items were properly
% balanced (enough begin-group tokens before end-group tokens, so |}{|
% is not) then \cs{@@_extract_check:w} is called just before the
-% closing brace of the \cs{__kernel_tl_gset:Ne} (thanks to our sneaky
+% closing brace of the \cs{__kernel_tl_gset:Nx} (thanks to our sneaky
% \cs{if_false:} |{| \cs{fi:} |}| construction), and finds that there
% is nothing left to expand. If any of the items is unbalanced, the
% assignment gets ended early by an extra end-group token, and our
% check finds more tokens needing to be expanded in a new
-% \cs{__kernel_tl_gset:Ne} assignment. We need to add a begin-group
+% \cs{__kernel_tl_gset:Nx} assignment. We need to add a begin-group
% and an end-group tokens to the unbalanced item, namely to the last
% item found so far, which we reach through a loop.
% \begin{macrocode}
@@ -7113,7 +7105,7 @@
\int_incr:N \l_@@_added_begin_int
\int_incr:N \l_@@_added_end_int
\tex_afterassignment:D \@@_extract_check:w
- \__kernel_tl_gset:Ne \g_@@_internal_tl
+ \__kernel_tl_gset:Nx \g_@@_internal_tl
{
\exp_after:wN \@@_extract_check_loop:w
\g_@@_internal_tl
@@ -7169,15 +7161,15 @@
\prg_replicate:nn \l_@@_capturing_group_int
{
\__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray
- { \l_@@_submatch_int } { 0 }
+ \l_@@_submatch_int \c_zero_int
\__kernel_intarray_gset:Nnn \g_@@_submatch_case_intarray
- { \l_@@_submatch_int } { 0 }
+ \l_@@_submatch_int \c_zero_int
\int_incr:N \l_@@_submatch_int
}
\__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray
- { \l_@@_zeroth_submatch_int } { \l_@@_start_pos_int }
+ \l_@@_zeroth_submatch_int \l_@@_start_pos_int
\__kernel_intarray_gset:Nnn \g_@@_submatch_case_intarray
- { \l_@@_zeroth_submatch_int } { \g_@@_case_int }
+ \l_@@_zeroth_submatch_int \g_@@_case_int
\int_zero:N \l_@@_internal_a_int
\exp_after:wN \@@_extract_aux:w \l_@@_success_submatches_tl
\prg_break_point: \@@_use_none_delimit_by_q_recursion_stop:w ,
@@ -7192,7 +7184,12 @@
{ \@@_int_eval:w \l_@@_zeroth_submatch_int + \l_@@_internal_a_int } {#1}
\else:
\__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray
- { \@@_int_eval:w \l_@@_zeroth_submatch_int + \l_@@_internal_a_int - \l_@@_capturing_group_int } {#1}
+ {
+ \@@_int_eval:w
+ \l_@@_zeroth_submatch_int + \l_@@_internal_a_int
+ - \l_@@_capturing_group_int
+ }
+ {#1}
\fi:
\int_incr:N \l_@@_internal_a_int
\@@_extract_aux:w
@@ -7230,20 +7227,16 @@
\exp_args:No \@@_query_set:n {#3}
#2
\int_set:Nn \l_@@_balance_int
+ { \@@_replacement_balance_one_match:n \l_@@_zeroth_submatch_int }
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl
{
- \@@_replacement_balance_one_match:n
- { \l_@@_zeroth_submatch_int }
- }
- \__kernel_tl_set:Ne \l_@@_internal_a_tl
- {
- \@@_replacement_do_one_match:n
- { \l_@@_zeroth_submatch_int }
+ \@@_replacement_do_one_match:n \l_@@_zeroth_submatch_int
\@@_query_range:nn
{
\__kernel_intarray_item:Nn \g_@@_submatch_end_intarray
- { \l_@@_zeroth_submatch_int }
+ \l_@@_zeroth_submatch_int
}
- { \l_@@_max_pos_int }
+ \l_@@_max_pos_int
}
\@@_group_end_replace:N #3
}
@@ -7276,19 +7269,19 @@
#2
\int_set:Nn \l_@@_balance_int
{
- 0
+ \c_zero_int
\int_step_function:nnnN
- { \l_@@_min_submatch_int }
+ \l_@@_min_submatch_int
\l_@@_capturing_group_int
- { \l_@@_submatch_int - 1 }
+ { \l_@@_submatch_int - \c_one_int }
\@@_replacement_balance_one_match:n
}
- \__kernel_tl_set:Ne \l_@@_internal_a_tl
+ \__kernel_tl_set:Nx \l_@@_internal_a_tl
{
\int_step_function:nnnN
- { \l_@@_min_submatch_int }
+ \l_@@_min_submatch_int
\l_@@_capturing_group_int
- { \l_@@_submatch_int - 1 }
+ { \l_@@_submatch_int - \c_one_int }
\@@_replacement_do_one_match:n
\@@_query_range:nn
\l_@@_start_pos_int \l_@@_max_pos_int
@@ -7321,11 +7314,12 @@
\cs_new_protected:Npn \@@_group_end_replace:N #1
{
\int_set:Nn \l_@@_added_begin_int
- { \int_max:nn { - \l_@@_balance_int } { 0 } }
+ { \int_max:nn { - \l_@@_balance_int } \c_zero_int }
\int_set:Nn \l_@@_added_end_int
- { \int_max:nn { \l_@@_balance_int } { 0 } }
+ { \int_max:nn \l_@@_balance_int \c_zero_int }
\@@_group_end_replace_try:
- \int_compare:nNnT { \l_@@_added_begin_int + \l_@@_added_end_int } > 0
+ \int_compare:nNnT { \l_@@_added_begin_int + \l_@@_added_end_int }
+ > \c_zero_int
{
\msg_error:nneee { regex } { result-unbalanced }
{ replacing } { \int_use:N \l_@@_added_begin_int }
@@ -7337,11 +7331,11 @@
\cs_new_protected:Npn \@@_group_end_replace_try:
{
\tex_afterassignment:D \@@_group_end_replace_check:w
- \__kernel_tl_gset:Ne \g_@@_internal_tl
+ \__kernel_tl_gset:Nx \g_@@_internal_tl
{
- \prg_replicate:nn { \l_@@_added_begin_int } { { \if_false: } \fi: }
+ \prg_replicate:nn \l_@@_added_begin_int { { \if_false: } \fi: }
\l_@@_internal_a_tl
- \prg_replicate:nn { \l_@@_added_end_int } { \if_false: { \fi: } }
+ \prg_replicate:nn \l_@@_added_end_int { \if_false: { \fi: } }
\if_false: { \fi: }
}
}
@@ -7618,14 +7612,13 @@
\use:e
{
\exp_not:n { \exp_after:wN \l_@@_peek_true_tl \exp:w }
- \@@_replacement_do_one_match:n
- { \l_@@_zeroth_submatch_int }
+ \@@_replacement_do_one_match:n \l_@@_zeroth_submatch_int
\@@_query_range:nn
{
\__kernel_intarray_item:Nn \g_@@_submatch_end_intarray
- { \l_@@_zeroth_submatch_int }
+ \l_@@_zeroth_submatch_int
}
- { \l_@@_max_pos_int }
+ \l_@@_max_pos_int
\exp_end:
}
}
@@ -7708,10 +7701,14 @@
{
\if_case:w \l_@@_replacement_csnames_int
\tl_build_put_right:Nn \l_@@_build_tl
- { \@@_query_submatch:n { \int_eval:n { #1 + ##1 } } }
+ { \@@_query_submatch:n { \@@_int_eval:w #1 + ##1 \scan_stop: } }
\else:
\tl_build_put_right:Nn \l_@@_build_tl
- { \exp:w \@@_query_submatch:n { \int_eval:n { #1 + ##1 } } \exp_end: }
+ {
+ \exp:w
+ \@@_query_submatch:n { \@@_int_eval:w #1 + ##1 \scan_stop: }
+ \exp_end:
+ }
\fi:
}
% \end{macrocode}
@@ -8141,7 +8138,7 @@
{
\int_step_inline:nnn
\l_@@_min_state_int
- { \l_@@_max_state_int - 1 }
+ { \l_@@_max_state_int - \c_one_int }
{
\@@_trace:nne { regex } {#1}
{ \iow_char:N \\toks ##1 = { \@@_toks_use:w ##1 } }