diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3regex.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3regex.dtx | 789 |
1 files changed, 456 insertions, 333 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx index c693af6f7d2..0c0434054d7 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx @@ -29,7 +29,7 @@ % \fi % % \title{^^A -% The \textsf{l3regex} package: regular expressions in \TeX{}^^A +% The \textsf{l3regex} package: Regular expressions in \TeX{}^^A % } % % \author{^^A @@ -41,7 +41,7 @@ % }^^A % } % -% \date{Released 2018/03/05} +% \date{Released 2018-04-30} % % \maketitle % @@ -50,8 +50,6 @@ % {\begin{itemize}\def\\{\char`\\}\def\makelabel##1{\hss\llap{\ttfamily##1}}} % {\end{itemize}} % -% \section{Regular expressions} -% % The \pkg{l3regex} package provides regular expression testing, % extraction of submatches, splitting, and replacement, all acting % on token lists. The syntax of regular expressions is mostly a subset @@ -96,7 +94,7 @@ % giving us access to the name of the environment when doing % replacements. % -% \subsection{Syntax of regular expressions} +% \section{Syntax of regular expressions} % % We start with a few examples, and encourage the reader to apply % \cs{regex_show:n} to these regular expressions. @@ -203,7 +201,8 @@ % equivalent to |[\^^J\^^K\^^L\^^M]|. Note that |\^^K| is a vertical space, % but not a space, for compatibility with Perl. % \item[\\w] Any word character, \emph{i.e.}, -% alpha-numerics and underscore, equivalent to |[A-Za-z0-9\_]|. +% alphanumerics and underscore, equivalent to the explicit +% class |[A-Za-z0-9\_]|. % \item[\\D] Any token not matched by |\d|. % \item[\\H] Any token not matched by |\h|. % \item[\\N] Any token other than the |\n| character (hex 0A). @@ -381,7 +380,7 @@ % true match is |{acbc3}|, with first submatch |{bc}|, but |\K| resets % the beginning of the match to the last position where it appears. % -% \subsection{Syntax of the replacement text} +% \section{Syntax of the replacement text} % % Most of the features described in regular expressions do not make % sense within the replacement text. Backslash introduces various @@ -456,7 +455,7 @@ % \end{verbatim} % results in \cs{l_my_tl} holding |first,\emph{second},first,first|. % -% \subsection{Pre-compiling regular expressions} +% \section{Pre-compiling regular expressions} % % If a regular expression is to be used several times, % it is better to compile it once rather than doing it @@ -509,7 +508,7 @@ % the second branch is not anchored to the beginning of the match. % \end{function} % -% \subsection{Matching} +% \section{Matching} % % All regular expression functions are available in both |:n| and |:N| % variants. The former require a \enquote{standard} regular expression, @@ -551,9 +550,9 @@ % results in \cs{l_foo_int} taking the value $5$. % \end{function} % -% \subsection{Submatch extraction} +% \section{Submatch extraction} % -% \begin{function}[TF, added = 2017-05-26] +% \begin{function}[noTF, added = 2017-05-26] % {\regex_extract_once:nnN, \regex_extract_once:NnN} % \begin{syntax} % \cs{regex_extract_once:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} @@ -584,7 +583,7 @@ % functions such as \cs{regex_replace_once:nnN}. % \end{function} % -% \begin{function}[TF, added = 2017-05-26] +% \begin{function}[noTF, added = 2017-05-26] % {\regex_extract_all:nnN, \regex_extract_all:NnN} % \begin{syntax} % \cs{regex_extract_all:nnN} \Arg{regex} \Arg{token list} \meta{seq~var} @@ -608,7 +607,7 @@ % and the \texttt{true} branch is left in the input stream. % \end{function} % -% \begin{function}[TF, added = 2017-05-26]{\regex_split:nnN, \regex_split:NnN} +% \begin{function}[noTF, added = 2017-05-26]{\regex_split:nnN, \regex_split:NnN} % \begin{syntax} % \cs{regex_split:nnN} \Arg{regular expression} \Arg{token list} \meta{seq~var} % \cs{regex_split:nnNTF} \Arg{regular expression} \Arg{token list} \meta{seq~var} \Arg{true code} \Arg{false code} @@ -634,9 +633,9 @@ % is left in the input stream. % \end{function} % -% \subsection{Replacement} +% \section{Replacement} % -% \begin{function}[TF, added = 2017-05-26] +% \begin{function}[noTF, added = 2017-05-26] % {\regex_replace_once:nnN,\regex_replace_once:NnN} % \begin{syntax} % \cs{regex_replace_once:nnN} \Arg{regular expression} \Arg{replacement} \meta{tl~var} @@ -649,7 +648,7 @@ % first capturing group, |\2| of the second, \emph{etc.} % \end{function} % -% \begin{function}[TF, added = 2017-05-26] +% \begin{function}[noTF, added = 2017-05-26] % {\regex_replace_all:nnN, \regex_replace_all:NnN} % \begin{syntax} % \cs{regex_replace_all:nnN} \Arg{regular expression} \Arg{replacement} \meta{tl~var} @@ -663,7 +662,7 @@ % locally to \meta{tl~var}. % \end{function} % -% \subsection{Constants and variables} +% \section{Constants and variables} % % \begin{variable}[added = 2017-12-11]{\l_tmpa_regex, \l_tmpb_regex} % Scratch regex for local assignment. These are never used by @@ -679,7 +678,7 @@ % code and so should only be used for short-term storage. % \end{variable} % -% \subsection{Bugs, misfeatures, future work, and other possibilities} +% \section{Bugs, misfeatures, future work, and other possibilities} % % The following need to be done now. % \begin{itemize} @@ -716,7 +715,7 @@ % \item If possible, when a state is reused by the same thread, kill % other subthreads. % \item Use an array rather than \cs{l__regex_balance_tl} -% to build \cs{__regex_replacement_balance_one_match:n}. +% to build the function \cs{__regex_replacement_balance_one_match:n}. % \item Reduce the number of epsilon-transitions in alternatives. % \item Optimize simple strings: use less states (|abcade| should give % two states, for |abc| and |ade|). [Does that really make sense?] @@ -744,7 +743,7 @@ % \item Conditional subpatterns with look ahead/behind: \enquote{if % what follows is [\ldots{}], then [\ldots{}]}. % \item |(*..)| and |(?..)| sequences to set some options. -% \item UTF-8 mode for pdf\TeX{}. +% \item UTF-8 mode for \pdfTeX{}. % \item Newline conventions are not done. % In particular, we should have an option for |.| not to match newlines. % Also, |\A| should differ from |^|, and |\Z|, |\z| and |$| should @@ -798,7 +797,7 @@ % \item Comments: \TeX{} already has its own system for comments. % \item |\Q...\E| escaping: this would require to read the argument % verbatim, which is not in the scope of this module. -% \item |\C| single byte in UTF-8 mode: Xe\TeX{} and Lua\TeX{} serve +% \item |\C| single byte in UTF-8 mode: \XeTeX{} and \LuaTeX{} serve % us characters directly, and splitting those into bytes is tricky, % encoding dependent, and most likely not useful anyways. % \end{itemize} @@ -869,8 +868,7 @@ % \tn{toks} registers, by accessing them directly by number rather than % tying them to control sequence using the \tn{newtoks} allocation % functions. Specifically, these arrays and \tn{toks} are used as -% follows. When compiling, \tn{toks} registers are used under the hood -% by functions from the \pkg{l3tl-build} module. When building, +% follows. When building, % \tn{toks}\meta{state} holds the tests and actions to perform in the % \meta{state} of the \textsc{nfa}. When matching, % \begin{itemize} @@ -917,6 +915,15 @@ % % \subsection{Helpers} % +% \begin{macro} +% {\@@_int_eval:w} +% Access the primitive: performance is key here, so we do not use +% the slower route \emph{via} \cs{int_eval:n}. +% \begin{macrocode} +\cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@@_standard_escapechar:} % Make the \tn{escapechar} into the standard backslash. % \begin{macrocode} @@ -936,7 +943,7 @@ % Empty a \tn{toks} or set it to a value, given its number. % \begin{macrocode} \cs_new_protected:Npn \@@_toks_clear:N #1 - { \tex_toks:D #1 { } } + { \@@_toks_set:Nn #1 { } } \cs_new_eq:NN \@@_toks_set:Nn \tex_toks:D \cs_new_protected:Npn \@@_toks_set:No #1 { \@@_toks_set:Nn #1 \exp_after:wN } @@ -1029,6 +1036,14 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\l_@@_build_tl} +% This temporary variable is specifically for use with the |tl_build| +% machinery. +% \begin{macrocode} +\tl_new:N \l_@@_build_tl +% \end{macrocode} +% \end{variable} +% % \begin{variable}{\c_@@_no_match_regex} % This regular expression matches nothing, but is still a valid % regular expression. We could use a failing assertion, but I went for @@ -1050,9 +1065,9 @@ % registers. We also store the balance of begin-group/end-group % characters into \cs{g_@@_balance_intarray}. % \begin{macrocode} -\__intarray_new:Nn \g_@@_charcode_intarray { 65536 } -\__intarray_new:Nn \g_@@_catcode_intarray { 65536 } -\__intarray_new:Nn \g_@@_balance_intarray { 65536 } +\intarray_new:Nn \g_@@_charcode_intarray { 65536 } +\intarray_new:Nn \g_@@_catcode_intarray { 65536 } +\intarray_new:Nn \g_@@_balance_intarray { 65536 } % \end{macrocode} % \end{variable} % @@ -1200,12 +1215,14 @@ \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: } @@ -1243,7 +1260,7 @@ } \cs_new_protected:Npn \@@_item_catcode:nT #1 { - \if_int_odd:w \__int_eval:n { #1 / \@@_item_catcode: } + \if_int_odd:w \int_eval:n { #1 / \@@_item_catcode: } \exp_stop_f: \exp_after:wN \use:n \else: \exp_after:wN \use_none:n @@ -1273,7 +1290,8 @@ { \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 + \tl_if_in:noTF { \scan_stop: #1 \scan_stop: } + \l_@@_internal_a_tl { \@@_break_true:w } { } } { } @@ -1300,12 +1318,14 @@ \@@_single_match: \@@_disable_submatches: \@@_build_for_cs:n {#1} - \bool_set_eq:NN \l_@@_saved_success_bool \g_@@_success_bool + \bool_set_eq:NN \l_@@_saved_success_bool + \g_@@_success_bool \exp_args:NV \@@_match:n \l_@@_cs_name_tl \if_meaning:w \c_true_bool \g_@@_success_bool \group_insert_after:N \@@_break_true:w \fi: - \bool_gset_eq:NN \g_@@_success_bool \l_@@_saved_success_bool + \bool_gset_eq:NN \g_@@_success_bool + \l_@@_saved_success_bool \group_end: } } @@ -1444,42 +1464,41 @@ % character, then fed to \meta{inline~3}. The result is then left in the % input stream. Spaces are ignored unless escaped. % -% The conversion is mostly done within an \texttt{x}-expanding -% assignment, except for the |\x| escape sequence, which is not amenable -% to that in general. For this, we use the general framework of -% \cs{__tl_build:Nw}. +% The conversion is done within an \texttt{x}-expanding assignment. % % \begin{macro}{\@@_escape_use:nnnn} -% The result is built in \cs{l_@@_internal_a_tl}, which is then -% left in the input stream. Go through |#4| once, applying |#1|, +% The result is built in \cs{l_@@_internal_a_tl}, which is then left +% in the input stream. Tracing code is added as appropriate inside +% this token list. Go through |#4| once, applying |#1|, % |#2|, or |#3| as relevant to each character (after de-escaping -% it). Note that we cannot replace \cs{tl_set:Nx} and -% \cs{__tl_build_one:o} by a single call to \cs{__tl_build_one:x}, because -% the \texttt{x}-expanding assignment may be interrupted by |\x|. +% it). % \begin{macrocode} \__kernel_patch:nnNNpn { \@@_trace_push:nnN { regex } { 1 } \@@_escape_use:nnnn - \__tl_build:Nw \l_@@_internal_a_tl - \__tl_build_one:n { \@@_trace_pop:nnN { regex } { 1 } \@@_escape_use:nnnn } - \use_none:nn + \group_begin: + \tl_set:Nx \l_@@_internal_a_tl + { \@@_trace_pop:nnN { regex } { 1 } \@@_escape_use:nnnn } + \use_none:nnn } { } \cs_new_protected:Npn \@@_escape_use:nnnn #1#2#3#4 { - \__tl_build:Nw \l_@@_internal_a_tl + \group_begin: + \tl_clear:N \l_@@_internal_a_tl \cs_set:Npn \@@_escape_unescaped:N ##1 { #1 } \cs_set:Npn \@@_escape_escaped:N ##1 { #2 } \cs_set:Npn \@@_escape_raw:N ##1 { #3 } \@@_standard_escapechar: - \tl_gset:Nx \g_@@_internal_tl { \__str_to_other_fast:n {#4} } - \tl_set:Nx \l_@@_internal_b_tl + \tl_gset:Nx \g_@@_internal_tl + { \__kernel_str_to_other_fast:n {#4} } + \tl_put_right:Nx \l_@@_internal_a_tl { \exp_after:wN \@@_escape_loop:N \g_@@_internal_tl - { break } \__prg_break_point: + { break } \prg_break_point: } - \__tl_build_one:o \l_@@_internal_b_tl - \__tl_build_end: + \exp_after:wN + \group_end: \l_@@_internal_a_tl } % \end{macrocode} @@ -1532,12 +1551,11 @@ % backslash. Spaces are ignored, and |\a|, |\e|, |\f|, |\n|, |\r|, % |\t| take their meaning here. % \begin{macrocode} -\cs_new_eq:NN \@@_escape_break:w \__prg_break: +\cs_new_eq:NN \@@_escape_break:w \prg_break: \cs_new:cpn { @@_escape_/break:w } { - \if_false: { \fi: } - \__kernel_msg_error:nn { kernel } { trailing-backslash } - \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi: + \__kernel_msg_expandable_error:nn { kernel } { trailing-backslash } + \prg_break: } \cs_new:cpn { @@_escape_~:w } { } \cs_new:cpx { @@_escape_/a:w } @@ -1567,17 +1585,14 @@ \cs_new:cpn { @@_escape_/x:w } \@@_escape_loop:N { \exp_after:wN \@@_escape_x_end:w - \__int_value:w "0 \@@_escape_x_test:N + \int_value:w "0 \@@_escape_x_test:N } \cs_new:Npn \@@_escape_x_end:w #1 ; { \int_compare:nNnTF {#1} > \c_max_char_int { - \if_false: { \fi: } - \__tl_build_one:o \l_@@_internal_b_tl - \__kernel_msg_error:nnx { kernel } { x-overflow } {#1} - \tl_set:Nx \l_@@_internal_b_tl - { \if_false: } \fi: + \__kernel_msg_expandable_error:nnff { kernel } { x-overflow } + {#1} { \int_to_Hex:n {#1} } } { \exp_last_unbraced:Nf \@@_escape_raw:N @@ -1662,11 +1677,8 @@ } \cs_new:Npn \@@_escape_x_loop_error:n #1 { - \if_false: { \fi: } - \__tl_build_one:o \l_@@_internal_b_tl - \__kernel_msg_error:nnx { kernel } { x-missing-rbrace } {#1} - \tl_set:Nx \l_@@_internal_b_tl - { \if_false: } \fi: \@@_escape_loop:N #1 + \__kernel_msg_expandable_error:nnn { kernel } { x-missing-rbrace } {#1} + \@@_escape_loop:N #1 } % \end{macrocode} % \end{macro} @@ -1682,7 +1694,7 @@ #1 \prg_return_true: \else: \if_case:w - \__int_eval:n { \exp_after:wN ` \token_to_str:N #1 - `a } + \int_eval:n { \exp_after:wN ` \token_to_str:N #1 - `a } A \or: B \or: C @@ -2097,7 +2109,8 @@ \if_int_compare:w \l_@@_mode_int = \c_@@_catcode_mode_int \int_set_eq:NN \l_@@_mode_int \c_@@_outer_mode_int \else: - \if_int_compare:w \l_@@_mode_int = \c_@@_catcode_in_class_mode_int + \if_int_compare:w \l_@@_mode_int = + \c_@@_catcode_in_class_mode_int \int_set_eq:NN \l_@@_mode_int \c_@@_class_mode_int \fi: \fi: @@ -2117,13 +2130,16 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_compile:w { - \__tl_build_x:Nw \l_@@_internal_regex + \group_begin: + \tl_build_begin:N \l_@@_build_tl \int_zero:N \l_@@_group_level_int - \int_set_eq:NN \l_@@_default_catcodes_int \c_@@_all_catcodes_int + \int_set_eq:NN \l_@@_default_catcodes_int + \c_@@_all_catcodes_int \int_set_eq:NN \l_@@_catcodes_int \l_@@_default_catcodes_int \cs_set:Npn \@@_item_equal:n { \@@_item_caseful_equal:n } \cs_set:Npn \@@_item_range:nn { \@@_item_caseful_range:nn } - \__tl_build_one:n { \@@_branch:n { \if_false: } \fi: } + \tl_build_put_right:Nn \l_@@_build_tl + { \@@_branch:n { \if_false: } \fi: } } \cs_new_protected:Npn \@@_compile_end: { @@ -2140,17 +2156,23 @@ \prg_replicate:nn { \l_@@_group_level_int } { - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } \if_false: { \fi: } { 1 } { 0 } \c_true_bool } - \__tl_build_end: - \__tl_build_one:o \l_@@_internal_regex + \tl_build_end:N \l_@@_build_tl + \exp_args:NNNo + \group_end: + \tl_build_put_right:Nn \l_@@_build_tl + { \l_@@_build_tl } } \fi: - \__tl_build_one:n { \if_false: { \fi: } } - \__tl_build_end: + \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } } + \tl_build_end:N \l_@@_build_tl + \exp_args:NNNx + \group_end: + \tl_set:Nn \l_@@_internal_regex { \l_@@_build_tl } } % \end{macrocode} % \end{macro} @@ -2219,7 +2241,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_compile_one:x} +% \begin{macro}{\@@_compile_one:n} % This is used after finding one \enquote{test}, such as |\d|, or a % raw character. If that followed a catcode test (\emph{e.g.}, |\cL|), % then restore the mode. If we are not in a class, then the test is @@ -2227,17 +2249,18 @@ % search for quantifiers. In any case, insert the test, possibly % together with a catcode test if appropriate. % \begin{macrocode} -\cs_new_protected:Npn \@@_compile_one:x #1 +\cs_new_protected:Npn \@@_compile_one:n #1 { \@@_mode_quit_c: \@@_if_in_class:TF { } { - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \@@_class:NnnnN \c_true_bool { \if_false: } \fi: } } - \__tl_build_one:x + \tl_build_put_right:Nx \l_@@_build_tl { - \if_int_compare:w \l_@@_catcodes_int < \c_@@_all_catcodes_int + \if_int_compare:w \l_@@_catcodes_int < + \c_@@_all_catcodes_int \@@_item_catcode:nT { \int_use:N \l_@@_catcodes_int } { \exp_not:N \exp_not:n {#1} } \else: @@ -2292,7 +2315,10 @@ % whatever characters were grabbed are left raw). % \begin{macrocode} \cs_new_protected:Npn \@@_compile_quantifier_none: - { \__tl_build_one:n { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } } + { + \tl_build_put_right:Nn \l_@@_build_tl + { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } + } \cs_new_protected:Npn \@@_compile_quantifier_abort:xNN #1#2#3 { \@@_compile_quantifier_none: @@ -2315,9 +2341,13 @@ \cs_new_protected:Npn \@@_compile_quantifier_lazyness:nnNN #1#2#3#4 { \str_if_eq:nnTF { #3 #4 } { \@@_compile_special:N ? } - { \__tl_build_one:n { \if_false: { \fi: } { #1 } { #2 } \c_true_bool } } { - \__tl_build_one:n { \if_false: { \fi: } { #1 } { #2 } \c_false_bool } + \tl_build_put_right:Nn \l_@@_build_tl + { \if_false: { \fi: } { #1 } { #2 } \c_true_bool } + } + { + \tl_build_put_right:Nn \l_@@_build_tl + { \if_false: { \fi: } { #1 } { #2 } \c_false_bool } #3 #4 } } @@ -2408,7 +2438,8 @@ \str_if_eq_x:nnTF { #1 #2 } { \@@_compile_special:N \c_right_brace_str } { - \if_int_compare:w \l_@@_internal_a_int > \l_@@_internal_b_int + \if_int_compare:w \l_@@_internal_a_int > + \l_@@_internal_b_int \__kernel_msg_error:nnxx { kernel } { backwards-quantifier } { \int_use:N \l_@@_internal_a_int } { \int_use:N \l_@@_internal_b_int } @@ -2461,14 +2492,14 @@ \str_if_eq:nnTF {#2#3} { \@@_compile_special:N - } { \@@_compile_range:Nw #1 } { - \@@_compile_one:x - { \@@_item_equal:n { \__int_value:w `#1 ~ } } + \@@_compile_one:n + { \@@_item_equal:n { \int_value:w `#1 } } #2 #3 } } { - \@@_compile_one:x - { \@@_item_equal:n { \__int_value:w `#1 ~ } } + \@@_compile_one:n + { \@@_item_equal:n { \int_value:w `#1 } } #2 #3 } } @@ -2504,24 +2535,24 @@ \if_int_compare:w `#1 > `#3 \exp_stop_f: \__kernel_msg_error:nnxx { kernel } { range-backwards } {#1} {#3} \else: - \__tl_build_one:x + \tl_build_put_right:Nx \l_@@_build_tl { \if_int_compare:w `#1 = `#3 \exp_stop_f: \@@_item_equal:n \else: - \@@_item_range:nn { \__int_value:w `#1 ~ } + \@@_item_range:nn { \int_value:w `#1 } \fi: - { \__int_value:w `#3 ~ } + { \int_value:w `#3 } } \fi: } { \__kernel_msg_warning:nnxx { kernel } { range-missing-end } {#1} { \c_backslash_str #3 } - \__tl_build_one:x + \tl_build_put_right:Nx \l_@@_build_tl { - \@@_item_equal:n { \__int_value:w `#1 ~ } - \@@_item_equal:n { \__int_value:w `- ~ } + \@@_item_equal:n { \int_value:w `#1 \exp_stop_f: } + \@@_item_equal:n { \int_value:w `- \exp_stop_f: } } #2#3 } @@ -2540,7 +2571,7 @@ { \exp_not:N \@@_if_in_class:TF { \@@_compile_raw:N . } - { \@@_compile_one:x \exp_not:c { @@_prop_.: } } + { \@@_compile_one:n \exp_not:c { @@_prop_.: } } } \cs_new_protected:cpn { @@_prop_.: } { @@ -2568,10 +2599,10 @@ \cs_set_protected:Npn \@@_tmp:w #1#2 { \cs_new_protected:cpx { @@_compile_/#1: } - { \@@_compile_one:x \exp_not:c { @@_prop_#1: } } + { \@@_compile_one:n \exp_not:c { @@_prop_#1: } } \cs_new_protected:cpx { @@_compile_/#2: } { - \@@_compile_one:x + \@@_compile_one:n { \@@_item_reverse:n \exp_not:c { @@_prop_#1: } } } } @@ -2581,7 +2612,7 @@ \@@_tmp:w v V \@@_tmp:w w W \cs_new_protected:cpn { @@_compile_/N: } - { \@@_compile_one:x \@@_prop_N: } + { \@@_compile_one:n \@@_prop_N: } % \end{macrocode} % \end{macro} % @@ -2602,7 +2633,7 @@ { \@@_if_in_class_or_catcode:TF {#2} { - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \@@_assertion:Nn \c_true_bool { \@@_anchor:N #1 } } } } @@ -2639,7 +2670,7 @@ \@@_if_in_class_or_catcode:TF { \@@_compile_raw_error:N b } { - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \@@_assertion:Nn \c_true_bool { \@@_b_test: } } } } @@ -2648,7 +2679,7 @@ \@@_if_in_class_or_catcode:TF { \@@_compile_raw_error:N B } { - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \@@_assertion:Nn \c_false_bool { \@@_b_test: } } } } @@ -2668,8 +2699,9 @@ { \@@_if_in_class:TF { - \if_int_compare:w \l_@@_mode_int > \c_@@_catcode_in_class_mode_int - \__tl_build_one:n { \if_false: { \fi: } } + \if_int_compare:w \l_@@_mode_int > + \c_@@_catcode_in_class_mode_int + \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } } \fi: \tex_advance:D \l_@@_mode_int - 15 \exp_stop_f: \tex_divide:D \l_@@_mode_int 13 \exp_stop_f: @@ -2733,7 +2765,7 @@ \cs_new_protected:Npn \@@_compile_class_catcode:w #1; { \if_int_compare:w \l_@@_mode_int = \c_@@_catcode_mode_int - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \@@_class:NnnnN \c_true_bool { \if_false: } \fi: } \fi: \int_set_eq:NN \l_@@_catcodes_int \l_@@_default_catcodes_int @@ -2752,14 +2784,14 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_compile_class:TFNN #1#2#3#4 { - \l_@@_mode_int = \__int_value:w \l_@@_mode_int 3 \exp_stop_f: + \l_@@_mode_int = \int_value:w \l_@@_mode_int 3 \exp_stop_f: \str_if_eq:nnTF { #3 #4 } { \@@_compile_special:N ^ } { - \__tl_build_one:n { #2 { \if_false: } \fi: } + \tl_build_put_right:Nn \l_@@_build_tl { #2 { \if_false: } \fi: } \@@_compile_class:NN } { - \__tl_build_one:n { #1 { \if_false: } \fi: } + \tl_build_put_right:Nn \l_@@_build_tl { #1 { \if_false: } \fi: } \@@_compile_class:NN #3 #4 } } @@ -2794,8 +2826,14 @@ \str_case:nn { #2 } { : { \@@_compile_class_posix:NNNNw } - = { \__kernel_msg_warning:nnx { kernel } { posix-unsupported } { = } } - . { \__kernel_msg_warning:nnx { kernel } { posix-unsupported } { . } } + = { + \__kernel_msg_warning:nnx { kernel } + { posix-unsupported } { = } + } + . { + \__kernel_msg_warning:nnx { kernel } + { posix-unsupported } { . } + } } } \@@_compile_raw:N [ #1 #2 @@ -2827,7 +2865,7 @@ { \cs_if_exist:cTF { @@_posix_ \l_@@_internal_a_tl : } { - \@@_compile_one:x + \@@_compile_one:n { \bool_if:NF \l_@@_internal_bool \@@_item_reverse:n \exp_not:c { @@_posix_ \l_@@_internal_a_tl : } @@ -2857,9 +2895,9 @@ % % \begin{macro}{\@@_compile_group_begin:N, \@@_compile_group_end:} % The contents of a regex group are turned into compiled code in -% \cs{l_@@_internal_regex}, which ends up with items of the form +% \cs{l_@@_build_tl}, which ends up with items of the form % \cs{@@_branch:n} \Arg{concatenation}. This construction is done -% using \pkg{l3tl-build} within a \TeX{} group, which automatically +% using \cs[no-index]{tl_build_\ldots{}} functions within a \TeX{} group, which automatically % makes sure that options (case-sensitivity and default catcode) are % reset at the end of the group. The argument |#1| is % \cs{@@_group:nnnN} or a variant thereof. A small subtlety to @@ -2870,20 +2908,24 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_compile_group_begin:N #1 { - \__tl_build_one:n { #1 { \if_false: } \fi: } + \tl_build_put_right:Nn \l_@@_build_tl { #1 { \if_false: } \fi: } \@@_mode_quit_c: - \__tl_build:Nw \l_@@_internal_regex + \group_begin: + \tl_build_begin:N \l_@@_build_tl \int_set_eq:NN \l_@@_default_catcodes_int \l_@@_catcodes_int \int_incr:N \l_@@_group_level_int - \__tl_build_one:n { \@@_branch:n { \if_false: } \fi: } + \tl_build_put_right:Nn \l_@@_build_tl + { \@@_branch:n { \if_false: } \fi: } } \cs_new_protected:Npn \@@_compile_group_end: { \if_int_compare:w \l_@@_group_level_int > 0 \exp_stop_f: - \__tl_build_one:n { \if_false: { \fi: } } - \__tl_build_end: + \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } } + \tl_build_end:N \l_@@_build_tl + \exp_args:NNNx + \group_end: + \tl_build_put_right:Nn \l_@@_build_tl { \l_@@_build_tl } \int_set_eq:NN \l_@@_catcodes_int \l_@@_default_catcodes_int - \__tl_build_one:o \l_@@_internal_regex \exp_after:wN \@@_compile_quantifier:w \else: \__kernel_msg_warning:nn { kernel } { extra-rparen } @@ -2894,14 +2936,23 @@ % \end{macro} % % \begin{macro}{\@@_compile_(:} -% In a class, parentheses are not special. Outside, check for a |?|, -% denoting special groups, and run the code for the corresponding -% special group. +% In a class, parentheses are not special. In a catcode test inside a +% class, a left parenthesis gives an error, to catch |[a\cL(bcd)e]|. +% Otherwise check for a |?|, denoting special groups, and run the code +% for the corresponding special group. % \begin{macrocode} \cs_new_protected:cpn { @@_compile_(: } { \@@_if_in_class:TF { \@@_compile_raw:N ( } - { \@@_compile_lparen:w } + { + \if_int_compare:w \l_@@_mode_int = + \c_@@_catcode_in_class_mode_int + \__kernel_msg_error:nn { kernel } { c-lparen-in-class } + \exp_after:wN \@@_compile_raw:N \exp_after:wN ( + \else: + \exp_after:wN \@@_compile_lparen:w + \fi: + } } \cs_new_protected:Npn \@@_compile_lparen:w #1#2#3#4 { @@ -2932,7 +2983,7 @@ { \@@_if_in_class:TF { \@@_compile_raw:N | } { - \__tl_build_one:n + \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } \@@_branch:n { \if_false: } \fi: } } } @@ -2973,8 +3024,10 @@ { \str_if_eq:nnTF { #1 #2 } { \@@_compile_special:N ) } { - \cs_set:Npn \@@_item_equal:n { \@@_item_caseless_equal:n } - \cs_set:Npn \@@_item_range:nn { \@@_item_caseless_range:nn } + \cs_set:Npn \@@_item_equal:n + { \@@_item_caseless_equal:n } + \cs_set:Npn \@@_item_range:nn + { \@@_item_caseless_range:nn } } { \__kernel_msg_warning:nnx { kernel } { unknown-option } { (?i #2 } @@ -2989,8 +3042,10 @@ \str_if_eq:nnTF { #1 #2 #3 #4 } { \@@_compile_raw:N i \@@_compile_special:N ) } { - \cs_set:Npn \@@_item_equal:n { \@@_item_caseful_equal:n } - \cs_set:Npn \@@_item_range:nn { \@@_item_caseful_range:nn } + \cs_set:Npn \@@_item_equal:n + { \@@_item_caseful_equal:n } + \cs_set:Npn \@@_item_range:nn + { \@@_item_caseful_range:nn } } { \__kernel_msg_warning:nnx { kernel } { unknown-option } { (?-#2#4 } @@ -3019,7 +3074,8 @@ { \int_if_exist:cTF { c_@@_catcode_#2_int } { - \int_set_eq:Nc \l_@@_catcodes_int { c_@@_catcode_#2_int } + \int_set_eq:Nc \l_@@_catcodes_int + { c_@@_catcode_#2_int } \l_@@_mode_int = \if_case:w \l_@@_mode_int \c_@@_catcode_mode_int @@ -3112,7 +3168,7 @@ } \cs_new_protected:Npn \@@_compile_c_lbrack_add:N #1 { - \if_int_odd:w \__int_eval:n { \l_@@_catcodes_int / #1 } + \if_int_odd:w \int_eval:n { \l_@@_catcodes_int / #1 } \exp_stop_f: \else: \int_add:Nn \l_@@_catcodes_int {#1} \fi: @@ -3176,11 +3232,14 @@ \exp_after:wN \@@_compile_cs_aux:Nn \l_@@_internal_regex \q_nil \q_nil \q_recursion_stop } - \exp_args:Nx \@@_compile_one:x + \exp_args:Nx \@@_compile_one:n { \flag_if_raised:nTF { @@_cs } { \@@_item_cs:n { \exp_not:o \l_@@_internal_regex } } - { \@@_item_exact_cs:n { \tl_tail:N \l_@@_internal_a_tl } } + { + \@@_item_exact_cs:n + { \tl_tail:N \l_@@_internal_a_tl } + } } } \cs_new:Npn \@@_compile_cs_aux:Nn #1#2 @@ -3193,7 +3252,7 @@ \@@_compile_cs_aux:Nn } { - \quark_if_nil:NF #1 { \flag_raise:n { @@_cs } } + \quark_if_nil:NF #1 { \flag_raise_if_clear:n { @@_cs } } \use_none_delimit_by_q_recursion_stop:w } } @@ -3215,7 +3274,7 @@ { \quark_if_nil:NF #1 { - \flag_raise:n { @@_cs } + \flag_raise_if_clear:n { @@_cs } \use_i_delimit_by_q_recursion_stop:nw } \use_none_delimit_by_q_recursion_stop:w @@ -3245,7 +3304,8 @@ \@@_if_in_class_or_catcode:TF { \@@_compile_raw_error:N u #1 #2 } { - \str_if_eq_x:nnTF {#1#2} { \@@_compile_special:N \c_left_brace_str } + \str_if_eq_x:nnTF {#1#2} + { \@@_compile_special:N \c_left_brace_str } { \tl_set:Nx \l_@@_internal_a_tl { \if_false: } \fi: \@@_compile_u_loop:NN @@ -3305,8 +3365,11 @@ \cs_new_protected:Npn \@@_compile_u_in_cs: { \tl_gset:Nx \g_@@_internal_tl - { \exp_args:No \__str_to_other_fast:n { \l_@@_internal_a_tl } } - \__tl_build_one:x + { + \exp_args:No \__kernel_str_to_other_fast:n + { \l_@@_internal_a_tl } + } + \tl_build_put_right:Nx \l_@@_build_tl { \tl_map_function:NN \g_@@_internal_tl \@@_compile_u_in_cs_aux:n @@ -3315,7 +3378,7 @@ \cs_new:Npn \@@_compile_u_in_cs_aux:n #1 { \@@_class:NnnnN \c_true_bool - { \@@_item_caseful_equal:n { \__int_value:w `#1 } } + { \@@_item_caseful_equal:n { \int_value:w `#1 } } { 1 } { 0 } \c_false_bool } % \end{macrocode} @@ -3329,16 +3392,17 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_compile_u_not_cs: { - \exp_args:No \__tl_analysis_map_inline:nn { \l_@@_internal_a_tl } + \tl_analysis_map_inline:Nn \l_@@_internal_a_tl { - \__tl_build_one:n + \tl_build_put_right:Nx \l_@@_build_tl { \@@_class:NnnnN \c_true_bool { - \if_int_compare:w "##2 = 0 \exp_stop_f: - \@@_item_exact_cs:n { \exp_after:wN \cs_to_str:N ##1 } + \if_int_compare:w "##3 = 0 \exp_stop_f: + \@@_item_exact_cs:n + { \exp_after:wN \cs_to_str:N ##1 } \else: - \@@_item_exact:nn { \__int_value:w "##2 } { ##3 } + \@@_item_exact:nn { \int_value:w "##3 } { ##2 } \fi: } { 1 } { 0 } \c_false_bool @@ -3359,7 +3423,7 @@ \cs_new_protected:cpn { @@_compile_/K: } { \int_compare:nNnTF \l_@@_mode_int = \c_@@_outer_mode_int - { \__tl_build_one:n { \@@_command_K: } } + { \tl_build_put_right:Nn \l_@@_build_tl { \@@_command_K: } } { \@@_compile_raw_error:N K } } % \end{macrocode} @@ -3368,19 +3432,22 @@ % \subsubsection{Showing regexes} % % \begin{macro}{\@@_show:N} -% Within a \cs{__tl_build:Nw} \ldots{} \cs{__tl_build_end:} group, we +% Within a group and within \cs{tl_build_begin:N} \ldots{} \cs{tl_build_end:N} we % redefine all the function that can appear in a compiled regex, then % run the regex. The result stored in \cs{l_@@_internal_a_tl} is then % meant to be shown. % \begin{macrocode} \cs_new_protected:Npn \@@_show:N #1 { - \__tl_build:Nw \l_@@_internal_a_tl + \group_begin: + \tl_build_begin:N \l_@@_build_tl \cs_set_protected:Npn \@@_branch:n { - \seq_pop_right:NN \l_@@_show_prefix_seq \l_@@_internal_a_tl + \seq_pop_right:NN \l_@@_show_prefix_seq + \l_@@_internal_a_tl \@@_show_one:n { +-branch } - \seq_put_right:No \l_@@_show_prefix_seq \l_@@_internal_a_tl + \seq_put_right:No \l_@@_show_prefix_seq + \l_@@_internal_a_tl \use:n } \cs_set_protected:Npn \@@_group:nnnN @@ -3393,13 +3460,19 @@ \cs_set_protected:Npn \@@_command_K: { \@@_show_one:n { reset~match~start~(\iow_char:N\\K) } } \cs_set_protected:Npn \@@_assertion:Nn ##1##2 - { \@@_show_one:n { \bool_if:NF ##1 { negative~ } assertion:~##2 } } + { + \@@_show_one:n + { \bool_if:NF ##1 { negative~ } assertion:~##2 } + } \cs_set:Npn \@@_b_test: { word~boundary } \cs_set_eq:NN \@@_anchor:N \@@_show_anchor_to_str:N \cs_set_protected:Npn \@@_item_caseful_equal:n ##1 { \@@_show_one:n { char~code~\int_eval:n{##1} } } \cs_set_protected:Npn \@@_item_caseful_range:nn ##1##2 - { \@@_show_one:n { range~[\int_eval:n{##1}, \int_eval:n{##2}] } } + { + \@@_show_one:n + { range~[\int_eval:n{##1}, \int_eval:n{##2}] } + } \cs_set_protected:Npn \@@_item_caseless_equal:n ##1 { \@@_show_one:n { char~code~\int_eval:n{##1}~(caseless) } } \cs_set_protected:Npn \@@_item_caseless_range:nn ##1##2 @@ -3422,7 +3495,10 @@ \seq_clear:N \l_@@_show_prefix_seq \@@_show_push:n { ~ } \cs_if_exist_use:N #1 - \__tl_build_end: + \tl_build_end:N \l_@@_build_tl + \exp_args:NNNo + \group_end: + \tl_set:Nn \l_@@_internal_a_tl { \l_@@_build_tl } } % \end{macrocode} % \end{macro} @@ -3434,7 +3510,7 @@ \cs_new_protected:Npn \@@_show_one:n #1 { \int_incr:N \l_@@_show_lines_int - \__tl_build_one:x + \tl_build_put_right:Nx \l_@@_build_tl { \exp_not:N \iow_newline: \seq_map_function:NN \l_@@_show_prefix_seq \use:n @@ -3495,42 +3571,39 @@ % \begin{macrocode} \cs_set:Npn \@@_show_class:NnnnN #1#2#3#4#5 { - \__tl_build:Nw \l_@@_internal_a_tl + \group_begin: + \tl_build_begin:N \l_@@_build_tl \int_zero:N \l_@@_show_lines_int \@@_show_push:n {~} #2 - \exp_last_unbraced:Nf - \int_case:nnF { \l_@@_show_lines_int } + \int_compare:nTF { \l_@@_show_lines_int = 0 } { - {0} + \group_end: + \@@_show_one:n { \bool_if:NTF #1 { Fail } { Pass } } + } + { + \bool_if:nTF + { #1 && \int_compare_p:n { \l_@@_show_lines_int = 1 } } { - \__tl_build_end: - \@@_show_one:n { \bool_if:NTF #1 { Fail } { Pass } } + \group_end: + #2 + \tl_build_put_right:Nn \l_@@_build_tl + { \@@_msg_repeated:nnN {#3} {#4} #5 } } - {1} { - \__tl_build_end: - \bool_if:NTF #1 - { - #2 - \__tl_build_one:n { \@@_msg_repeated:nnN {#3} {#4} #5 } - } + \tl_build_end:N \l_@@_build_tl + \exp_args:NNNo + \group_end: + \tl_set:Nn \l_@@_internal_a_tl \l_@@_build_tl + \@@_show_one:n { - \@@_show_one:n - { Don't~match~\@@_msg_repeated:nnN {#3} {#4} #5 } - \__tl_build_one:o \l_@@_internal_a_tl + \bool_if:NTF #1 { Match } { Don't~match } + \@@_msg_repeated:nnN {#3} {#4} #5 } + \tl_build_put_right:Nx \l_@@_build_tl + { \exp_not:o \l_@@_internal_a_tl } } } - { - \__tl_build_end: - \@@_show_one:n - { - \bool_if:NTF #1 { M } { Don't~m } atch - \@@_msg_repeated:nnN {#3} {#4} #5 - } - \__tl_build_one:o \l_@@_internal_a_tl - } } % \end{macrocode} % \end{macro} @@ -4011,8 +4084,8 @@ { \int_use:N \l_@@_capturing_group_int } { \int_use:N \l_@@_capturing_group_int } #1 - { ?? \__prg_break:n } { } - \__prg_break_point: + { ?? \prg_break:n } { } + \prg_break_point: } } \cs_new_protected:Npn \@@_group_resetting_loop:nnNn #1#2#3#4 @@ -4109,7 +4182,7 @@ \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} > 1 \exp_stop_f: + \if_int_compare:w \int_eval:n {#1} > 1 \exp_stop_f: \int_set:Nn \l_@@_internal_c_int { ( #1 - 1 ) @@ -4295,7 +4368,10 @@ \@@_action_submatch:n { 0< } \bool_set_true:N \l_@@_fresh_thread_bool \@@_action_free:n - { \int_eval:n { \l_@@_right_state_int - \l_@@_left_state_int } } + { + \int_eval:n + { \l_@@_right_state_int - \l_@@_left_state_int } + } \bool_set_false:N \l_@@_fresh_thread_bool } } @@ -4459,8 +4535,8 @@ % threads to be considered in the next step, more precisely the % states in which these threads are. % \begin{macrocode} -\__intarray_new:Nn \g_@@_state_active_intarray { 65536 } -\__intarray_new:Nn \g_@@_thread_state_intarray { 65536 } +\intarray_new:Nn \g_@@_state_active_intarray { 65536 } +\intarray_new:Nn \g_@@_thread_state_intarray { 65536 } % \end{macrocode} % \end{variable} % @@ -4545,8 +4621,8 @@ \int_set:Nn \l_@@_curr_pos_int { 2 * \l_@@_max_state_int } \@@_query_set:nnn { } { -1 } { -2 } \int_set_eq:NN \l_@@_min_pos_int \l_@@_curr_pos_int - \__tl_analysis_map_inline:nn {#1} - { \@@_query_set:nnn {##1} {"##2} {##3} } + \tl_analysis_map_inline:nn {#1} + { \@@_query_set:nnn {##1} {"##3} {##2} } \int_set_eq:NN \l_@@_max_pos_int \l_@@_curr_pos_int \@@_query_set:nnn { } { -1 } { -2 } \@@_match_init: @@ -4558,9 +4634,12 @@ \cs_new_protected:Npn \@@_match_init: { \bool_gset_false:N \g_@@_success_bool - \int_step_inline:nnnn - \l_@@_min_state_int { 1 } { \l_@@_max_state_int - 1 } - { \__intarray_gset_fast:Nnn \g_@@_state_active_intarray {##1} { 1 } } + \int_step_inline:nnn + \l_@@_min_state_int { \l_@@_max_state_int - 1 } + { + \__kernel_intarray_gset:Nnn + \g_@@_state_active_intarray {##1} { 1 } + } \int_set_eq:NN \l_@@_min_active_int \l_@@_max_state_int \int_zero:N \l_@@_step_int \int_set_eq:NN \l_@@_success_pos_int \l_@@_min_pos_int @@ -4591,7 +4670,10 @@ { \if_meaning:w \c_true_bool \l_@@_empty_success_bool \cs_set:Npn \@@_if_two_empty_matches:F - { \int_compare:nNnF \l_@@_start_pos_int = \l_@@_curr_pos_int } + { + \int_compare:nNnF + \l_@@_start_pos_int = \l_@@_curr_pos_int + } \else: \cs_set_eq:NN \@@_if_two_empty_matches:F \use:n \fi: @@ -4618,7 +4700,11 @@ \cs_new_protected:Npn \@@_single_match: { \tl_set:Nn \l_@@_every_match_tl - { \bool_gset_eq:NN \g_@@_success_bool \l_@@_match_success_bool } + { + \bool_gset_eq:NN + \g_@@_success_bool + \l_@@_match_success_bool + } } \cs_new_protected:Npn \@@_multi_match:n #1 { @@ -4658,14 +4744,13 @@ \use:x { \int_set_eq:NN \l_@@_max_active_int \l_@@_min_active_int - \int_step_function:nnnN + \int_step_function:nnN { \l_@@_min_active_int } - { 1 } { \l_@@_max_active_int - 1 } \@@_match_one_active:n } - \__prg_break_point: - \bool_set_false:N \l_@@_fresh_thread_bool %^^A was arg of break_point:n + \prg_break_point: + \bool_set_false:N \l_@@_fresh_thread_bool \if_int_compare:w \l_@@_max_active_int > \l_@@_min_active_int \if_int_compare:w \l_@@_curr_pos_int < \l_@@_max_pos_int \exp_after:wN \exp_after:wN \exp_after:wN \@@_match_loop: @@ -4675,7 +4760,7 @@ \cs_new:Npn \@@_match_one_active:n #1 { \@@_use_state_and_submatches:nn - { \__intarray_item_fast:Nn \g_@@_thread_state_intarray {#1} } + { \__kernel_intarray_item:Nn \g_@@_thread_state_intarray {#1} } { \@@_toks_use:w #1 } } % \end{macrocode} @@ -4691,11 +4776,11 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_query_set:nnn #1#2#3 { - \__intarray_gset_fast:Nnn \g_@@_charcode_intarray + \__kernel_intarray_gset:Nnn \g_@@_charcode_intarray { \l_@@_curr_pos_int } {#3} - \__intarray_gset_fast:Nnn \g_@@_catcode_intarray + \__kernel_intarray_gset:Nnn \g_@@_catcode_intarray { \l_@@_curr_pos_int } {#2} - \__intarray_gset_fast:Nnn \g_@@_balance_intarray + \__kernel_intarray_gset:Nnn \g_@@_balance_intarray { \l_@@_curr_pos_int } { \l_@@_balance_int } \@@_toks_set:Nn \l_@@_curr_pos_int {#1} \int_incr:N \l_@@_curr_pos_int @@ -4714,10 +4799,10 @@ \cs_new_protected:Npn \@@_query_get: { \l_@@_curr_char_int - = \__intarray_item_fast:Nn \g_@@_charcode_intarray + = \__kernel_intarray_item:Nn \g_@@_charcode_intarray { \l_@@_curr_pos_int } \scan_stop: \l_@@_curr_catcode_int - = \__intarray_item_fast:Nn \g_@@_catcode_intarray + = \__kernel_intarray_item:Nn \g_@@_catcode_intarray { \l_@@_curr_pos_int } \scan_stop: } % \end{macrocode} @@ -4734,15 +4819,19 @@ % point will be terminated. % \begin{macrocode} \__kernel_patch:nnNNpn - { \@@_trace:nnx { regex } { 2 } { state~\int_use:N \l_@@_curr_state_int } } + { + \@@_trace:nnx { regex } { 2 } + { state~\int_use:N \l_@@_curr_state_int } + } { } \cs_new_protected:Npn \@@_use_state: { - \__intarray_gset_fast:Nnn \g_@@_state_active_intarray + \__kernel_intarray_gset:Nnn \g_@@_state_active_intarray { \l_@@_curr_state_int } { \l_@@_step_int } \@@_toks_use:w \l_@@_curr_state_int - \__intarray_gset_fast:Nnn \g_@@_state_active_intarray - { \l_@@_curr_state_int } { \l_@@_step_int + 1 } + \__kernel_intarray_gset:Nnn \g_@@_state_active_intarray + { \l_@@_curr_state_int } + { \int_eval:n { \l_@@_step_int + 1 } } } % \end{macrocode} % \end{macro} @@ -4757,7 +4846,7 @@ { \int_set:Nn \l_@@_curr_state_int {#1} \if_int_compare:w - \__intarray_item_fast:Nn \g_@@_state_active_intarray + \__kernel_intarray_item:Nn \g_@@_state_active_intarray { \l_@@_curr_state_int } < \l_@@_step_int \tl_set:Nn \l_@@_curr_submatches_prop {#2} @@ -4814,7 +4903,7 @@ \exp_not:n { \if_int_compare:w - \__intarray_item_fast:Nn \g_@@_state_active_intarray + \__kernel_intarray_item:Nn \g_@@_state_active_intarray { \l_@@_curr_state_int } #1 \exp_after:wN \@@_use_state: @@ -4838,8 +4927,8 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_action_cost:n #1 { - \exp_args:No \@@_store_state:n - { \__int_value:w \__int_eval:n { \l_@@_curr_state_int + #1 } } + \exp_args:Nx \@@_store_state:n + { \int_eval:n { \l_@@_curr_state_int + #1 } } } % \end{macrocode} % \end{macro} @@ -4853,7 +4942,7 @@ \cs_new_protected:Npn \@@_store_state:n #1 { \@@_store_submatches: - \__intarray_gset_fast:Nnn \g_@@_thread_state_intarray + \__kernel_intarray_gset:Nnn \g_@@_thread_state_intarray { \l_@@_max_active_int } {#1} \int_incr:N \l_@@_max_active_int } @@ -4898,7 +4987,7 @@ % empty match. Then mark that there was a successful match; it is % empty if it is \enquote{fresh}; and we store the current position % and submatches. The current step is then interrupted with -% \cs{__prg_break:}, and only paths with higher precedence are +% \cs{prg_break:}, and only paths with higher precedence are % pursued further. The values stored here may be overwritten by a % later success of a path with higher precedence. % \begin{macrocode} @@ -4912,7 +5001,7 @@ \int_set_eq:NN \l_@@_success_pos_int \l_@@_curr_pos_int \prop_set_eq:NN \l_@@_success_submatches_prop \l_@@_curr_submatches_prop - \__prg_break: + \prg_break: } } % \end{macrocode} @@ -4983,8 +5072,8 @@ \cs_new:Npn \@@_replacement_do_one_match:n #1 { \@@_query_range:nn - { \__intarray_item_fast:Nn \g_@@_submatch_prev_intarray {#1} } - { \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray {#1} } + { \__kernel_intarray_item:Nn \g_@@_submatch_prev_intarray {#1} } + { \__kernel_intarray_item:Nn \g_@@_submatch_begin_intarray {#1} } } % \end{macrocode} % \end{macro} @@ -5020,19 +5109,19 @@ \cs_new:Npn \@@_query_range:nn #1#2 { \exp_after:wN \@@_query_range_loop:ww - \__int_value:w \__int_eval:w #1 \exp_after:wN ; - \__int_value:w \__int_eval:w #2 ; - \__prg_break_point: + \int_value:w \@@_int_eval:w #1 \exp_after:wN ; + \int_value:w \@@_int_eval:w #2 ; + \prg_break_point: } \cs_new:Npn \@@_query_range_loop:ww #1 ; #2 ; { \if_int_compare:w #1 < #2 \exp_stop_f: \else: - \exp_after:wN \__prg_break: + \exp_after:wN \prg_break: \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 + 1 ; #2 ; } % \end{macrocode} % \end{macro} @@ -5044,13 +5133,13 @@ \cs_new:Npn \@@_query_submatch:n #1 { \@@_query_range:nn - { \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray {#1} } - { \__intarray_item_fast:Nn \g_@@_submatch_end_intarray {#1} } + { \__kernel_intarray_item:Nn \g_@@_submatch_begin_intarray {#1} } + { \__kernel_intarray_item:Nn \g_@@_submatch_end_intarray {#1} } } % \end{macrocode} % \end{macro} % -% \begin{macro}[rEXP]{\@@_submatch_balance:n} +% \begin{macro}{\@@_submatch_balance:n} % Every user function must result in a balanced token list (unbalanced % token lists cannot be stored by TeX). When we unpacked the query, we % kept track of the brace balance, hence the contribution from a given @@ -5061,22 +5150,36 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_submatch_balance:n #1 { - \__int_eval:n + \int_eval:n { \int_compare:nNnTF - { \__intarray_item_fast:Nn \g_@@_submatch_end_intarray {#1} } = 0 + { + \__kernel_intarray_item:Nn + \g_@@_submatch_end_intarray {#1} + } + = 0 { 0 } { - \__intarray_item_fast:Nn \g_@@_balance_intarray - { \__intarray_item_fast:Nn \g_@@_submatch_end_intarray {#1} } + \__kernel_intarray_item:Nn \g_@@_balance_intarray + { + \__kernel_intarray_item:Nn + \g_@@_submatch_end_intarray {#1} + } } - \int_compare:nNnTF - { \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray {#1} } = 0 + { + \__kernel_intarray_item:Nn + \g_@@_submatch_begin_intarray {#1} + } + = 0 { 0 } { - \__intarray_item_fast:Nn \g_@@_balance_intarray - { \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray {#1} } + \__kernel_intarray_item:Nn \g_@@_balance_intarray + { + \__kernel_intarray_item:Nn + \g_@@_submatch_begin_intarray {#1} + } } } } @@ -5087,8 +5190,7 @@ % % \begin{macro}{\@@_replacement:n} % \begin{macro}{\@@_replacement_aux:n} -% The replacement text is built incrementally by abusing \tn{toks} -% within a group (see \pkg{l3tl-build}). We keep track in +% The replacement text is built incrementally. We keep track in % \cs{l_@@_balance_int} of the balance of explicit begin- and % end-group tokens and we store in \cs{l_@@_balance_tl} some % code to compute the brace balance from submatches (see its @@ -5103,7 +5205,8 @@ { \@@_trace_pop:nnN { regex } { 1 } \@@_replacement:n } \cs_new_protected:Npn \@@_replacement:n #1 { - \__tl_build:Nw \l_@@_internal_a_tl + \group_begin: + \tl_build_begin:N \l_@@_build_tl \int_zero:N \l_@@_balance_int \tl_clear:N \l_@@_balance_tl \@@_escape_use:nnnn @@ -5122,7 +5225,7 @@ \if_int_compare:w \l_@@_replacement_csnames_int > 0 \exp_stop_f: \__kernel_msg_error:nnx { kernel } { replacement-missing-rbrace } { \int_use:N \l_@@_replacement_csnames_int } - \__tl_build_one:x + \tl_build_put_right:Nx \l_@@_build_tl { \prg_replicate:nn \l_@@_replacement_csnames_int \cs_end: } \fi: \seq_if_empty:NF \l_@@_replacement_category_seq @@ -5137,16 +5240,24 @@ \l_@@_balance_tl - \@@_submatch_balance:n {##1} } - \__tl_build_end: - \exp_args:No \@@_replacement_aux:n \l_@@_internal_a_tl + \tl_build_end:N \l_@@_build_tl + \exp_args:NNo + \group_end: + \@@_replacement_aux:n \l_@@_build_tl } \cs_new_protected:Npn \@@_replacement_aux:n #1 { \cs_set:Npn \@@_replacement_do_one_match:n ##1 { \@@_query_range:nn - { \__intarray_item_fast:Nn \g_@@_submatch_prev_intarray {##1} } - { \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray {##1} } + { + \__kernel_intarray_item:Nn + \g_@@_submatch_prev_intarray {##1} + } + { + \__kernel_intarray_item:Nn + \g_@@_submatch_begin_intarray {##1} + } #1 } } @@ -5156,7 +5267,7 @@ % % \begin{macro}{\@@_replacement_normal:n} % Most characters are simply sent to the output by -% \cs{__tl_build_one:n}, unless a particular category code has been +% \cs{tl_build_put_right:Nn}, unless a particular category code has been % requested: then \cs{@@_replacement_c_A:w} or a similar auxiliary is % called. One exception is right parentheses, which restore the % category code in place before the group started. Note that the @@ -5167,7 +5278,7 @@ \cs_new_protected:Npn \@@_replacement_normal:n #1 { \tl_if_empty:NTF \l_@@_replacement_category_tl - { \__tl_build_one:n {#1} } + { \tl_build_put_right:Nn \l_@@_build_tl {#1} } { % ( \token_if_eq_charcode:NNTF #1 ) { @@ -5175,7 +5286,11 @@ \l_@@_replacement_category_tl } { - \use:c { @@_replacement_c_ \l_@@_replacement_category_tl :w } + \use:c + { + @@_replacement_c_ + \l_@@_replacement_category_tl :w + } \@@_replacement_normal:n {#1} } } @@ -5212,17 +5327,21 @@ % Unless the submatch appears inside a |\c{...}| or |\u{...}| % construction, it must be taken into account in the brace balance. % Later on, |##1| will be replaced by a pointer to the $0$-th submatch for a -% given match. We cannot use \cs{int_eval:n} because it is -% expandable, and would be expanded too early (short of adding -% \cs{exp_not:N}, making the code messy again). +% given match. There is an \cs{exp_not:N} here as at the point-of-use +% of \cs{l_@@_balance_tl} there is an \texttt{x}-type expansion which is needed +% to get |##1| in correctly. % \begin{macrocode} \cs_new_protected:Npn \@@_replacement_put_submatch:n #1 { \if_int_compare:w #1 < \l_@@_capturing_group_int - \__tl_build_one:n { \@@_query_submatch:n { #1 + ##1 } } + \tl_build_put_right:Nn \l_@@_build_tl + { \@@_query_submatch:n { \int_eval:n { #1 + ##1 } } } \if_int_compare:w \l_@@_replacement_csnames_int = 0 \exp_stop_f: \tl_put_right:Nn \l_@@_balance_tl - { + \@@_submatch_balance:n { \__int_eval:n { #1+##1 } } } + { + + \@@_submatch_balance:n + { \exp_not:N \int_eval:n { #1 + ##1 } } + } \fi: \fi: } @@ -5237,7 +5356,9 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_replacement_g:w #1#2 { - \str_if_eq_x:nnTF { #1#2 } { \@@_replacement_normal:n \c_left_brace_str } + \str_if_eq_x:nnTF + { #1#2 } + { \@@_replacement_normal:n \c_left_brace_str } { \l_@@_internal_a_int = \@@_replacement_g_digits:NN } { \@@_replacement_error:NNN g #1 #2 } } @@ -5308,9 +5429,11 @@ \cs_new_protected:Npn \@@_replacement_cu_aux:Nw #1 { \if_case:w \l_@@_replacement_csnames_int - \__tl_build_one:n { \exp_not:n { \exp_after:wN #1 \cs:w } } + \tl_build_put_right:Nn \l_@@_build_tl + { \exp_not:n { \exp_after:wN #1 \cs:w } } \else: - \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } + \tl_build_put_right:Nn \l_@@_build_tl + { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } \fi: \int_incr:N \l_@@_replacement_csnames_int } @@ -5324,7 +5447,9 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_replacement_u:w #1#2 { - \str_if_eq_x:nnTF { #1#2 } { \@@_replacement_normal:n \c_left_brace_str } + \str_if_eq_x:nnTF + { #1#2 } + { \@@_replacement_normal:n \c_left_brace_str } { \@@_replacement_cu_aux:Nw \exp_not:V } { \@@_replacement_error:NNN u #1#2 } } @@ -5339,7 +5464,7 @@ \cs_new_protected:Npn \@@_replacement_rbrace:N #1 { \if_int_compare:w \l_@@_replacement_csnames_int > 0 \exp_stop_f: - \__tl_build_one:n \cs_end: + \tl_build_put_right:Nn \l_@@_build_tl { \cs_end: } \int_decr:N \l_@@_replacement_csnames_int \else: \@@_replacement_normal:n {#1} @@ -5370,7 +5495,11 @@ #2 #3 } { - \str_if_eq:nnTF { #2 #3 } { \@@_replacement_normal:n ( } % ) + \str_if_eq:nnTF + { #2#3 } + { + \@@_replacement_normal:n ( % ) + } { \seq_push:NV \l_@@_replacement_category_seq \l_@@_replacement_category_tl @@ -5416,7 +5545,7 @@ \cs_new_protected:Npn \@@_replacement_char:nNN #1#2#3 { \tex_lccode:D 0 = `#3 \scan_stop: - \tex_lowercase:D { \__tl_build_one:n {#1} } + \tex_lowercase:D { \tl_build_put_right:Nn \l_@@_build_tl {#1} } } % \end{macrocode} % \end{macro} @@ -5460,7 +5589,10 @@ % character, we prepare for two \texttt{x}-expansions. % \begin{macrocode} \cs_new_protected:Npn \@@_replacement_c_C:w #1#2 - { \__tl_build_one:n { \exp_not:N \exp_not:N \exp_not:c {#2} } } + { + \tl_build_put_right:Nn \l_@@_build_tl + { \exp_not:N \exp_not:N \exp_not:c {#2} } + } % \end{macrocode} % \end{macro} % @@ -5546,7 +5678,7 @@ \__kernel_msg_error:nn { kernel } { replacement-null-space } \fi: \tex_lccode:D `\ = `#2 \scan_stop: - \tex_lowercase:D { \__tl_build_one:n {~} } + \tex_lowercase:D { \tl_build_put_right:Nn \l_@@_build_tl {~} } } % \end{macrocode} % \end{macro} @@ -5650,7 +5782,7 @@ } \cs_new_protected:Npn \regex_show:N #1 { - \__kernel_check_defined:NT #1 + \__kernel_chk_defined:NT #1 { \@@_show:N #1 \msg_show:nnxxxx { LaTeX / kernel } { show-regex } @@ -5691,15 +5823,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro} -% { -% \regex_extract_once:nnN, \regex_extract_once:NnN, -% \regex_extract_all:nnN, \regex_extract_all:NnN, -% \regex_replace_once:nnN, \regex_replace_once:NnN, -% \regex_replace_all:nnN, \regex_replace_all:NnN, -% \regex_split:nnN, \regex_split:NnN -% } -% \begin{macro}[TF] +% \begin{macro}[noTF] % { % \regex_extract_once:nnN, \regex_extract_once:NnN, % \regex_extract_all:nnN, \regex_extract_all:NnN, @@ -5735,7 +5859,6 @@ \@@_tmp:w \@@_split:nnN \regex_split:nnN \regex_split:NnN % \end{macrocode} % \end{macro} -% \end{macro} % % \subsubsection{Variables and helpers for user functions} % @@ -5777,9 +5900,9 @@ % \begin{variable}{\g_@@_submatch_prev_intarray, \g_@@_submatch_begin_intarray, \g_@@_submatch_end_intarray} % Hold the place where the match attempt begun and the end-points of each submatch. % \begin{macrocode} -\__intarray_new:Nn \g_@@_submatch_prev_intarray { 65536 } -\__intarray_new:Nn \g_@@_submatch_begin_intarray { 65536 } -\__intarray_new:Nn \g_@@_submatch_end_intarray { 65536 } +\intarray_new:Nn \g_@@_submatch_prev_intarray { 65536 } +\intarray_new:Nn \g_@@_submatch_begin_intarray { 65536 } +\intarray_new:Nn \g_@@_submatch_end_intarray { 65536 } % \end{macrocode} % \end{variable} % @@ -5883,17 +6006,18 @@ \group_begin: \@@_multi_match:n { - \if_int_compare:w \l_@@_start_pos_int < \l_@@_success_pos_int + \if_int_compare:w + \l_@@_start_pos_int < \l_@@_success_pos_int \@@_extract: - \__intarray_gset_fast:Nnn \g_@@_submatch_prev_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray { \l_@@_zeroth_submatch_int } { 0 } - \__intarray_gset_fast:Nnn \g_@@_submatch_end_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray { \l_@@_zeroth_submatch_int } { - \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray + \__kernel_intarray_item:Nn \g_@@_submatch_begin_intarray { \l_@@_zeroth_submatch_int } } - \__intarray_gset_fast:Nnn \g_@@_submatch_begin_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_begin_intarray { \l_@@_zeroth_submatch_int } { \l_@@_start_pos_int } \fi: @@ -5901,12 +6025,12 @@ #1 \@@_match:n {#2} %<assert>\assert_int:n { \l_@@_curr_pos_int = \l_@@_max_pos_int } - \__intarray_gset_fast:Nnn \g_@@_submatch_prev_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray { \l_@@_submatch_int } { 0 } - \__intarray_gset_fast:Nnn \g_@@_submatch_end_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray { \l_@@_submatch_int } { \l_@@_max_pos_int } - \__intarray_gset_fast:Nnn \g_@@_submatch_begin_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_begin_intarray { \l_@@_submatch_int } { \l_@@_start_pos_int } \int_incr:N \l_@@_submatch_int @@ -5925,39 +6049,36 @@ % from \cs{l_@@_min_submatch_int} to % \cs{l_@@_submatch_int} (exclusive). Extract the relevant ranges % into \cs{l_@@_internal_a_tl}. We detect unbalanced results using -% the two flags \texttt{@@_begin} and \texttt{@@_end}, raised +% the two flags \texttt{__regex_begin} and \texttt{__regex_end}, raised % whenever we see too many begin-group or end-group tokens in a -% submatch. We disable \cs{__seq_item:n} to prevent two -% \texttt{x}-expansions. +% submatch. % \begin{macrocode} \cs_new_protected:Npn \@@_group_end_extract_seq:N #1 { - \cs_set_eq:NN \__seq_item:n \scan_stop: \flag_clear:n { @@_begin } \flag_clear:n { @@_end } - \tl_set:Nx \l_@@_internal_a_tl + \seq_set_from_function:NnN \l_@@_internal_seq { - \s__seq - \int_step_function:nnnN - { \l_@@_min_submatch_int } - { 1 } + \int_step_function:nnN { \l_@@_min_submatch_int } { \l_@@_submatch_int - 1 } - \@@_extract_seq_aux:n } + \@@_extract_seq_aux:n \int_compare:nNnF - { \flag_height:n { @@_begin } + \flag_height:n { @@_end } } - = 0 + { + \flag_height:n { @@_begin } + + \flag_height:n { @@_end } + } + = 0 { \__kernel_msg_error:nnxxx { kernel } { result-unbalanced } { splitting~or~extracting~submatches } { \flag_height:n { @@_end } } { \flag_height:n { @@_begin } } } - \use:x - { - \group_end: - \tl_set:Nn \exp_not:N #1 { \l_@@_internal_a_tl } - } + \seq_set_map:NNn \l_@@_internal_seq \l_@@_internal_seq {##1} + \exp_args:NNNo + \group_end: + \tl_set:Nn #1 { \l_@@_internal_seq } } % \end{macrocode} % \end{macro} @@ -5970,11 +6091,8 @@ % \begin{macrocode} \cs_new:Npn \@@_extract_seq_aux:n #1 { - \__seq_item:n - { - \exp_after:wN \@@_extract_seq_aux:ww - \__int_value:w \@@_submatch_balance:n {#1} ; #1; - } + \exp_after:wN \@@_extract_seq_aux:ww + \int_value:w \@@_submatch_balance:n {#1} ; #1; } \cs_new:Npn \@@_extract_seq_aux:ww #1; #2; { @@ -6010,31 +6128,34 @@ \int_set_eq:NN \l_@@_zeroth_submatch_int \l_@@_submatch_int \prg_replicate:nn \l_@@_capturing_group_int { - \__intarray_gset_fast:Nnn \g_@@_submatch_begin_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_begin_intarray { \l_@@_submatch_int } { 0 } - \__intarray_gset_fast:Nnn \g_@@_submatch_end_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray { \l_@@_submatch_int } { 0 } - \__intarray_gset_fast:Nnn \g_@@_submatch_prev_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray { \l_@@_submatch_int } { 0 } \int_incr:N \l_@@_submatch_int } \prop_map_inline:Nn \l_@@_success_submatches_prop { \if_int_compare:w ##1 - 1 \exp_stop_f: - \exp_after:wN \@@_extract_e:wn \__int_value:w + \exp_after:wN \@@_extract_e:wn \int_value:w \else: - \exp_after:wN \@@_extract_b:wn \__int_value:w + \exp_after:wN \@@_extract_b:wn \int_value:w \fi: - \__int_eval:w \l_@@_zeroth_submatch_int + ##1 {##2} + \@@_int_eval:w \l_@@_zeroth_submatch_int + ##1 {##2} } - \__intarray_gset_fast:Nnn \g_@@_submatch_prev_intarray + \__kernel_intarray_gset:Nnn \g_@@_submatch_prev_intarray { \l_@@_zeroth_submatch_int } { \l_@@_start_pos_int } \fi: } \cs_new_protected:Npn \@@_extract_b:wn #1 < #2 - { \__intarray_gset_fast:Nnn \g_@@_submatch_begin_intarray {#1} {#2} } + { + \__kernel_intarray_gset:Nnn + \g_@@_submatch_begin_intarray {#1} {#2} + } \cs_new_protected:Npn \@@_extract_e:wn #1 > #2 - { \__intarray_gset_fast:Nnn \g_@@_submatch_end_intarray {#1} {#2} } + { \__kernel_intarray_gset:Nnn \g_@@_submatch_end_intarray {#1} {#2} } % \end{macrocode} % \end{macro} % @@ -6072,10 +6193,11 @@ } \tl_set:Nx \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 { - \__intarray_item_fast:Nn \g_@@_submatch_end_intarray + \__kernel_intarray_item:Nn \g_@@_submatch_end_intarray { \l_@@_zeroth_submatch_int } } { \l_@@_max_pos_int } @@ -6170,26 +6292,20 @@ % % Messages for the preparsing phase. % \begin{macrocode} -\__kernel_msg_new:nnnn { kernel } { trailing-backslash } - { Trailing~escape~character~'\iow_char:N\\'. } - { - A~regular~expression~or~its~replacement~text~ends~with~ - the~escape~character~'\iow_char:N\\'.~It~will~be~ignored. - } -\__kernel_msg_new:nnnn { kernel } { x-missing-rbrace } - { Missing~closing~brace~in~'\iow_char:N\\x'~hexadecimal~sequence. } +\use:x { - You~wrote~something~like~ - '\iow_char:N\\x\{...#1'.~ - The~closing~brace~is~missing. - } -\__kernel_msg_new:nnnn { kernel } { x-overflow } - { Character~code~'#1'~too~large~in~'\iow_char:N\\x'~hexadecimal~sequence. } - { - You~wrote~something~like~ - '\iow_char:N\\x\{\int_to_Hex:n{#1}\}'.~ - The~character~code~#1~is~larger~than~ - the~maximum~value~\int_use:N \c_max_char_int. + \__kernel_msg_new:nnn { kernel } { trailing-backslash } + { Trailing~escape~char~'\iow_char:N\\'~in~regex~or~replacement. } + \__kernel_msg_new:nnn { kernel } { x-missing-rbrace } + { + Missing~brace~'\iow_char:N\}'~in~regex~ + '...\iow_char:N\\x\iow_char:N\{...##1'. + } + \__kernel_msg_new:nnn { kernel } { x-overflow } + { + Character~code~##1~too~large~in~ + \iow_char:N\\x\iow_char:N\{##2\iow_char:N\}~regex. + } } % \end{macrocode} % @@ -6294,6 +6410,12 @@ control~sequence~or~the~next~group~to~be~made~of~control~sequences.~ It~only~makes~sense~to~follow~it~by~'.'~or~by~a~group. } +\__kernel_msg_new:nnnn { kernel } { c-lparen-in-class } + { Catcode~test~cannot~apply~to~group~in~character~class } + { + Construction~such~as~'\iow_char:N\\cL(abc)'~are~not~allowed~inside~a~ + class~'[...]'~because~classes~do~not~match~multiple~characters~at~once. + } \__kernel_msg_new:nnnn { kernel } { c-missing-rbrace } { Missing~right~brace~inserted~for~'\iow_char:N\\c'~escape. } { @@ -6334,7 +6456,8 @@ \str_if_eq_x:nnTF { } {#2} { reached~the~end~of~the~string~ } { encountered~an~escaped~alphanumeric~character '\iow_char:N\\#2'~ } - when~parsing~the~argument~of~an~'\iow_char:N\\u\iow_char:N\{...\}'~escape. + when~parsing~the~argument~of~an~ + '\iow_char:N\\u\iow_char:N\{...\}'~escape. } % \end{macrocode} % @@ -6467,7 +6590,8 @@ { Missing~right~parenthesis~inserted~in~replacement~text. } { There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~ - missing~right~\int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } . + missing~right~ + \int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } . } % \end{macrocode} % @@ -6518,7 +6642,7 @@ % typically~1. If the module's current tracing level is less than % |#2| show nothing, otherwise write |#3| to the terminal. % \begin{macrocode} -\__kernel_debug:TF +\__kernel_if_debug:TF { \cs_new_protected:Npn \@@_trace_push:nnN #1#2#3 { \@@_trace:nnx {#1} {#2} { entering~ \token_to_str:N #3 } } @@ -6547,13 +6671,12 @@ % stored in \tn{toks} from $0$ to \cs{l_@@_max_state_int} % (excluded). % \begin{macrocode} -\__kernel_debug:TF +\__kernel_if_debug:TF { \cs_new_protected:Npn \@@_trace_states:n #1 { - \int_step_inline:nnnn + \int_step_inline:nnn \l_@@_min_state_int - { 1 } { \l_@@_max_state_int - 1 } { \@@_trace:nnx { regex } {#1} |