diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3regex.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3regex.dtx | 435 |
1 files changed, 227 insertions, 208 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx index 1d9b421c8d3..80aa7a25547 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx @@ -7,7 +7,7 @@ % license or (at your option) any later version. The latest version % of this license is in the file % -% http://www.latex-project.org/lppl.txt +% https://www.latex-project.org/lppl.txt % % This file is part of the "l3kernel bundle" (The Work in LPPL) % and all files in that bundle must be distributed together. @@ -21,7 +21,7 @@ % for those people who are interested. % %<*driver> -\documentclass[full]{l3doc} +\documentclass[full,kernel]{l3doc} \begin{document} \DocInput{\jobname.dtx} \end{document} @@ -41,7 +41,7 @@ % }^^A % } % -% \date{Released 2017/11/14} +% \date{Released 2017/12/05} % % \maketitle % @@ -901,7 +901,7 @@ % % \subsection{Helpers} % -% \begin{macro}[int]{\@@_standard_escapechar:} +% \begin{macro}{\@@_standard_escapechar:} % Make the \tn{escapechar} into the standard backslash. % \begin{macrocode} \cs_new_protected:Npn \@@_standard_escapechar: @@ -909,14 +909,14 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int, EXP]{\@@_toks_use:w} +% \begin{macro}[EXP]{\@@_toks_use:w} % Unpack a \tn{toks} given its number. % \begin{macrocode} \cs_new:Npn \@@_toks_use:w { \tex_the:D \tex_toks:D } % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_toks_clear:N, \@@_toks_set:Nn, \@@_toks_set:No} +% \begin{macro}{\@@_toks_clear:N, \@@_toks_set:Nn, \@@_toks_set:No} % Empty a \tn{toks} or set it to a value, given its number. % \begin{macrocode} \cs_new_protected:Npn \@@_toks_clear:N #1 @@ -927,7 +927,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_toks_memcpy:NNn} +% \begin{macro}{\@@_toks_memcpy:NNn} % Copy |#3| \tn{toks} registers from |#2| onwards to |#1| onwards, % like |C|'s |memcpy|. % \begin{macrocode} @@ -943,8 +943,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_toks_put_left:Nx} -% \begin{macro}[int]{\@@_toks_put_right:Nx, \@@_toks_put_right:Nn} +% \begin{macro}{\@@_toks_put_left:Nx} +% \begin{macro}{\@@_toks_put_right:Nx, \@@_toks_put_right:Nn} % During the building phase we wish to add \texttt{x}-expanded % material to \tn{toks}, either to the left or to the right. The % expansion is done \enquote{by hand} for optimization (these @@ -970,7 +970,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int, rEXP]{\@@_curr_cs_to_str:} +% \begin{macro}[rEXP]{\@@_curr_cs_to_str:} % Expands to the string representation of the token (known to be a % control sequence) at the current position \cs{l_@@_curr_pos_int}. % It should only be used in \texttt{x}-expansion to avoid losing a @@ -986,7 +986,7 @@ % % \subsubsection{Constants and variables} % -% \begin{macro}[aux]{\@@_tmp:w} +% \begin{macro}{\@@_tmp:w} % Temporary function used for various short-term purposes. % \begin{macrocode} \cs_new:Npn \@@_tmp:w { } @@ -1075,8 +1075,8 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}[int]{\@@_break_point:TF} -% \begin{macro}[int]{\@@_break_true:w} +% \begin{macro}{\@@_break_point:TF} +% \begin{macro}{\@@_break_true:w} % When testing whether a character of the query token list matches % a given character class in the regular expression, we often % have to test it against several ranges of characters, checking @@ -1097,7 +1097,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_item_reverse:n} +% \begin{macro}{\@@_item_reverse:n} % This function makes showing regular expressions easier, and lets us % define |\D| in terms of |\d| for instance. There is a subtlety: the % end of the query is marked by $-2$, and thus matches |\D| and @@ -1112,7 +1112,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int] +% \begin{macro} % {\@@_item_caseful_equal:n, \@@_item_caseful_range:nn} % Simple comparisons triggering \cs{@@_break_true:w} when true. % \begin{macrocode} @@ -1133,7 +1133,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int] +% \begin{macro} % {\@@_item_caseless_equal:n, \@@_item_caseless_range:nn} % For caseless matching, we perform the test both on the % \texttt{current_char} and on the \texttt{case_changed_char}. Before @@ -1171,7 +1171,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_compute_case_changed_char:} +% \begin{macro}{\@@_compute_case_changed_char:} % This function is called when \cs{l_@@_case_changed_char_int} has % not yet been computed (or rather, when it is set to the marker value % \cs{c_max_int}). If the current character code is in the range @@ -1196,7 +1196,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int, EXP]{\@@_item_equal:n, \@@_item_range:nn} +% \begin{macro}[EXP]{\@@_item_equal:n, \@@_item_range:nn} % Those must always be defined to expand to a \texttt{caseful} % (default) or \texttt{caseless} version, and not be protected: they % must expand when compiling, to hard-code which tests are caseless or @@ -1207,8 +1207,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_item_catcode:nT, \@@_item_catcode_reverse:nT} -% \begin{macro}[aux]{\@@_item_catcode:} +% \begin{macro}{\@@_item_catcode:nT, \@@_item_catcode_reverse:nT} +% \begin{macro}{\@@_item_catcode:} % The argument is a sum of powers of $4$ with exponents given by the % allowed category codes (between $0$ and $13$). Dividing by a given % power of $4$ gives an odd result if and only if that category code @@ -1227,7 +1227,7 @@ } \cs_new_protected:Npn \@@_item_catcode:nT #1 { - \if_int_odd:w \__int_eval:w #1 / \@@_item_catcode: \__int_eval_end: + \if_int_odd:w \__int_eval:n { #1 / \@@_item_catcode: } \exp_after:wN \use:n \else: \exp_after:wN \use_none:n @@ -1239,7 +1239,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_item_exact:nn, \@@_item_exact_cs:n} +% \begin{macro}{\@@_item_exact:nn, \@@_item_exact_cs:n} % This matches an exact \meta{category}-\meta{character code} pair, or % an exact control sequence, more precisely one of several possible control sequences. % \begin{macrocode} @@ -1265,7 +1265,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_item_cs:n} +% \begin{macro}{\@@_item_cs:n} % Match a control sequence (the argument is a compiled regex). % First test the catcode of the current token to be zero. % Then perform the matching test, and break if the csname @@ -1298,7 +1298,7 @@ % % \subsubsection{Character property tests} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_prop_d:, \@@_prop_h:, \@@_prop_s:, % \@@_prop_v:, \@@_prop_w:, \@@_prop_N: @@ -1344,7 +1344,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_posix_alnum:, \@@_posix_alpha:, \@@_posix_ascii:, % \@@_posix_blank:, \@@_posix_cntrl:, \@@_posix_digit:, @@ -1433,7 +1433,7 @@ % to that in general. For this, we use the general framework of % \cs{__tl_build:Nw}. % -% \begin{macro}[int]{\@@_escape_use:nnnn} +% \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|, % |#2|, or |#3| as relevant to each character (after de-escaping @@ -1469,8 +1469,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_escape_loop:N} -% \begin{macro}[aux]+\@@_escape_\:w+ +% \begin{macro}{\@@_escape_loop:N} +% \begin{macro}+\@@_escape_\:w+ % \cs{@@_escape_loop:N} reads one character: if it is special % (space, backslash, or end-marker), perform the associated action, % otherwise it is simply an unescaped character. After a backslash, @@ -1493,7 +1493,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % {\@@_escape_unescaped:N, \@@_escape_escaped:N, \@@_escape_raw:N} % Those functions are never called before being given a new meaning, % so their definitions here don't matter. @@ -1504,13 +1504,13 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_escape_break:w, \@@_escape_/break:w, % \@@_escape_/a:w, \@@_escape_/e:w, \@@_escape_/f:w, % \@@_escape_/n:w, \@@_escape_/r:w, \@@_escape_/t:w % } -% \begin{macro}[aux]+\@@_escape_ :w+ +% \begin{macro}+\@@_escape_ :w+ % The loop is ended upon seeing the end-marker % \enquote{\texttt{break}}, with an error if the string ended in a % backslash. Spaces are ignored, and |\a|, |\e|, |\f|, |\n|, |\r|, @@ -1540,8 +1540,8 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_escape_/x:w} -% \begin{macro}[aux]{\@@_escape_x_end:w, \@@_escape_x_large:n} +% \begin{macro}{\@@_escape_/x:w} +% \begin{macro}{\@@_escape_x_end:w, \@@_escape_x_large:n} % When |\x| is encountered, \cs{@@_escape_x_test:N} is responsible for % grabbing some hexadecimal digits, and feeding the result to % \cs{@@_escape_x_end:w}. If the number is too big interrupt the @@ -1572,7 +1572,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_escape_x_test:N, \@@_escape_x_testii:N} +% \begin{macro}{\@@_escape_x_test:N, \@@_escape_x_testii:N} % Find out whether the first character is a left brace (allowing any % number of hexadecimal digits), or not (allowing up to two % hexadecimal digits). We need to check for the end-of-string marker. @@ -1604,7 +1604,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_escape_x:N} +% \begin{macro}{\@@_escape_x:N} % This looks for the second digit in the unbraced case. % \begin{macrocode} \cs_new:Npn \@@_escape_x:N #1 @@ -1619,7 +1619,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_escape_x_loop:N, \@@_escape_x_loop_error:} +% \begin{macro}{\@@_escape_x_loop:N, \@@_escape_x_loop_error:} % Grab hexadecimal digits, skip spaces, and at the end, check that % there is a right brace, otherwise raise an error outside the % assignment. @@ -1655,7 +1655,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux, rEXP]{\@@_hexadecimal_use:NTF} +% \begin{macro}[rEXP]{\@@_hexadecimal_use:NTF} % \TeX{} detects uppercase hexadecimal digits for us but not the % lowercase letters, which we need to detect and replace by their % uppercase counterpart. @@ -1665,9 +1665,8 @@ \if_int_compare:w 1 < "1 \token_to_str:N #1 \exp_stop_f: #1 \prg_return_true: \else: - \if_case:w \__int_eval:w - \exp_after:wN ` \token_to_str:N #1 - `a - \__int_eval_end: + \if_case:w + \__int_eval:n { \exp_after:wN ` \token_to_str:N #1 - `a } A \or: B \or: C @@ -1684,7 +1683,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[EXP, aux] +% \begin{macro}[EXP] % {\@@_char_if_alphanumeric:NTF, \@@_char_if_special:NTF} % These two tests are used in the first pass when parsing a regular % expression. That pass is responsible for finding escaped and @@ -1897,8 +1896,8 @@ % % \subsubsection{Generic helpers used when compiling} % -% \begin{macro}[int]{\@@_get_digits:NTFw} -% \begin{macro}[aux, rEXP]{\@@_get_digits_loop:w} +% \begin{macro}{\@@_get_digits:NTFw} +% \begin{macro}[rEXP]{\@@_get_digits_loop:w} % If followed by some raw digits, collect them one by one in the % integer variable |#1|, and take the \texttt{true} branch. Otherwise, % take the \texttt{false} branch. @@ -1919,7 +1918,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux, EXP]{\@@_if_raw_digit:NNTF} +% \begin{macro}[EXP]{\@@_if_raw_digit:NNTF} % Test used when grabbing digits for the |{m,n}| quantifier. % It only accepts non-escaped digits. % \begin{macrocode} @@ -1981,7 +1980,7 @@ % any mode. % \end{itemize} % -% \begin{macro}[int, EXP]{\@@_if_in_class:TF} +% \begin{macro}[EXP]{\@@_if_in_class:TF} % Test whether we are directly in a character class (at the innermost % level of nesting). There, many escape sequences are not recognized, % and special characters are normal. Also, for every raw character, we @@ -1998,7 +1997,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int, EXP]{\@@_if_in_cs:TF} +% \begin{macro}[EXP]{\@@_if_in_cs:TF} % Right braces are special only directly inside control sequences (at % the inner-most level of nesting, not counting groups). % \begin{macrocode} @@ -2017,7 +2016,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int, EXP]{\@@_if_in_class_or_catcode:TF} +% \begin{macro}[EXP]{\@@_if_in_class_or_catcode:TF} % Assertions are only allowed in modes $0$, $-2$, and $-6$, % \emph{i.e.}, even, non-positive modes. % \begin{macrocode} @@ -2036,7 +2035,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int, EXP]{\@@_if_within_catcode:TF} +% \begin{macro}[EXP]{\@@_if_within_catcode:TF} % This test takes the true branch if we are in a catcode test, either % immediately following it (modes $2$ and $6$) or in a class on which % it applies (modes $23$ and $63$). This is used to tweak how left @@ -2053,7 +2052,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_chk_c_allowed:T} +% \begin{macro}{\@@_chk_c_allowed:T} % The |\c| escape sequence is only allowed in modes $0$ and $3$, % \emph{i.e.}, not within any other |\c| escape sequence. % \begin{macrocode} @@ -2073,7 +2072,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_mode_quit_c:} +% \begin{macro}{\@@_mode_quit_c:} % This function changes the mode as it is needed just after a catcode % test. % \begin{macrocode} @@ -2092,7 +2091,7 @@ % % \subsubsection{Framework} % -% \begin{macro}[int]{\@@_compile:w, \@@_compile_end:} +% \begin{macro}{\@@_compile:w, \@@_compile_end:} % Used when compiling a user regex or a regex for the |\c{...}| escape % sequence within another regex. Start building a token list within a % group (with \texttt{x}-expansion at the outset), and set a few @@ -2140,7 +2139,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_compile:n} +% \begin{macro}{\@@_compile:n} % The compilation is done between \cs{@@_compile:w} and % \cs{@@_compile_end:}, starting in mode~$0$. Then % \cs{@@_escape_use:nnnn} distinguishes special characters, escaped @@ -2184,7 +2183,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_compile_escaped:N, \@@_compile_special:N} +% \begin{macro}{\@@_compile_escaped:N, \@@_compile_special:N} % If the special character or escaped alphanumeric has a particular % meaning in regexes, the corresponding function is used. Otherwise, % it is interpreted as a raw character. We distinguish special @@ -2204,7 +2203,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_compile_one:x} +% \begin{macro}{\@@_compile_one:x} % 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 @@ -2235,7 +2234,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int] +% \begin{macro} % {\@@_compile_abort_tokens:n, \@@_compile_abort_tokens:x} % This function places the collected tokens back in the input stream, % each as a raw character. Spaces are not preserved. @@ -2254,7 +2253,7 @@ % % \subsubsection{Quantifiers} % -% \begin{macro}[int]{\@@_compile_quantifier:w} +% \begin{macro}{\@@_compile_quantifier:w} % This looks ahead and finds any quantifier (special character equal % to either of \texttt{?+*\{}). % \begin{macrocode} @@ -2270,8 +2269,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_quantifier_none:} -% \begin{macro}[aux]{\@@_compile_quantifier_abort:xNN} +% \begin{macro}{\@@_compile_quantifier_none:} +% \begin{macro}{\@@_compile_quantifier_abort:xNN} % Those functions are called whenever there is no quantifier, or a % braced construction is invalid (equivalent to no quantifier, and % whatever characters were grabbed are left raw). @@ -2289,7 +2288,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_quantifier_lazyness:nnNN} +% \begin{macro}{\@@_compile_quantifier_lazyness:nnNN} % Once the \enquote{main} quantifier (\texttt{?}, \texttt{*}, % \texttt{+} or a braced construction) is found, we check whether it % is lazy (followed by a question mark). We then add to the compiled @@ -2309,7 +2308,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_compile_quantifier_?:w, % \@@_compile_quantifier_*:w, @@ -2328,8 +2327,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]+\@@_compile_quantifier_{:w+ ^^A} -% \begin{macro}[aux] +% \begin{macro}+\@@_compile_quantifier_{:w+ ^^A} +% \begin{macro} % { % \@@_compile_quantifier_braced_auxi:w, % \@@_compile_quantifier_braced_auxii:w, @@ -2421,7 +2420,7 @@ % % \subsubsection{Raw characters} % -% \begin{macro}[int]{\@@_compile_raw_error:N} +% \begin{macro}{\@@_compile_raw_error:N} % Within character classes, and following catcode tests, some escaped % alphanumeric sequences such as |\b| do not have any meaning. They % are replaced by a raw character, after spitting out an error. @@ -2434,7 +2433,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_compile_raw:N} +% \begin{macro}{\@@_compile_raw:N} % If we are in a character class and the next character is an % unescaped dash, this denotes a range. Otherwise, the current % character |#1| matches itself. @@ -2460,7 +2459,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_range:Nw, \@@_if_end_range:NNTF} +% \begin{macro}{\@@_compile_range:Nw, \@@_if_end_range:NNTF} % We have just read a raw character followed by a dash; this should be % followed by an end-point for the range. Valid end-points are: any % raw character; any special character, except a right bracket. In @@ -2516,7 +2515,7 @@ % % \subsubsection{Character properties} % -% \begin{macro}[aux]{\@@_compile_.:, \@@_prop_.:} +% \begin{macro}{\@@_compile_.:, \@@_prop_.:} % In a class, the dot has no special meaning. Outside, insert % \cs{@@_prop_.:}, which matches any character or control % sequence, and refuses $-2$ (end-marker). @@ -2536,7 +2535,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_compile_/d:, \@@_compile_/D:, % \@@_compile_/h:, \@@_compile_/H:, @@ -2572,11 +2571,11 @@ % % \subsubsection{Anchoring and simple assertions} % -% \begin{macro}[aux]{\@@_compile_anchor:NF} -% \begin{macro}[aux]+\@@_compile_^:+ -% \begin{macro}[aux]{\@@_compile_/A:, \@@_compile_/G:} -% \begin{macro}[aux]+\@@_compile_$:+ -% \begin{macro}[aux]{\@@_compile_/Z:, \@@_compile_/z:} +% \begin{macro}{\@@_compile_anchor:NF} +% \begin{macro}+\@@_compile_^:+ +% \begin{macro}{\@@_compile_/A:, \@@_compile_/G:} +% \begin{macro}+\@@_compile_$:+ +% \begin{macro}{\@@_compile_/Z:, \@@_compile_/z:} % In modes where assertions are allowed, anchor to the start of the % query, the start of the match, or the end of the query, depending on % the integer |#1|. In other modes, |#2| treats the character as raw, @@ -2614,7 +2613,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_/b:, \@@_compile_/B:} +% \begin{macro}{\@@_compile_/b:, \@@_compile_/B:} % Contrarily to |^| and |$|, which could be implemented without really % knowing what precedes in the token list, this requires more % information, namely, the knowledge of the last character code. @@ -2642,7 +2641,7 @@ % % \subsubsection{Character classes} % -% \begin{macro}[aux]{\@@_compile_]:} +% \begin{macro}{\@@_compile_]:} % Outside a class, right brackets have no meaning. In a class, change % the mode ($m\to (m-15)/13$, truncated) to reflect the fact that we % are leaving the class. Look for quantifiers, unless we are still in @@ -2667,7 +2666,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_[:} +% \begin{macro}{\@@_compile_[:} % In a class, left brackets might introduce a \textsc{posix} character % class, or mean nothing. Immediately following |\c|\meta{category}, % we must insert the appropriate catcode test, then parse the class; we @@ -2690,7 +2689,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_class_normal:w} +% \begin{macro}{\@@_compile_class_normal:w} % In the \enquote{normal} case, we insert \cs{@@_class:NnnnN} % \meta{boolean} in the compiled code. The \meta{boolean} is true for % positive classes, and false for negative classes, characterized by a @@ -2706,7 +2705,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_class_catcode:w} +% \begin{macro}{\@@_compile_class_catcode:w} % This function is called for a left bracket in modes $2$ or $6$ % (catcode test, and catcode test within a class). In mode $2$ the % whole construction needs to be put in a class (like single @@ -2729,7 +2728,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % {\@@_compile_class:TFNN, \@@_compile_class:NN} % If the first character is |^|, then the class is negative (use % |#2|), otherwise it is positive (use |#1|). If the next character @@ -2757,7 +2756,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_compile_class_posix_test:w, % \@@_compile_class_posix:NNNNw, @@ -2840,7 +2839,7 @@ % % \subsubsection{Groups and alternations} % -% \begin{macro}[aux]{\@@_compile_group_begin:N, \@@_compile_group_end:} +% \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{@@_branch:n} \Arg{concatenation}. This construction is done @@ -2878,7 +2877,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_(:} +% \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. @@ -2909,7 +2908,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]+\@@_compile_|:+ +% \begin{macro}+\@@_compile_|:+ % In a class, the pipe is not special. Otherwise, end the current % branch and open another one. % \begin{macrocode} @@ -2924,7 +2923,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_):} +% \begin{macro}{\@@_compile_):} % Within a class, parentheses are not special. Outside, close a group. % \begin{macrocode} \cs_new_protected:cpn { @@_compile_): } @@ -2935,8 +2934,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_special_group_::w} -% \begin{macro}[aux]+\@@_compile_special_group_|:w+ +% \begin{macro}{\@@_compile_special_group_::w} +% \begin{macro}+\@@_compile_special_group_|:w+ % Non-capturing, and resetting groups are easy to take care of during % compilation; for those groups, the harder parts come when building. % \begin{macrocode} @@ -2948,7 +2947,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % {\@@_compile_special_group_i:w, \@@_compile_special_group_-:w} % The match can be made case-insensitive by setting the option with % \texttt{(?i)}; the original behaviour is restored by \texttt{(?-i)}. @@ -2990,7 +2989,7 @@ % % \subsubsection{Catcodes and csnames} % -% \begin{macro}[aux]{\@@_compile_/c:, \@@_compile_c_test:NN} +% \begin{macro}{\@@_compile_/c:, \@@_compile_c_test:NN} % The |\c| escape sequence can be followed by a capital letter % representing a character category, by a left bracket which starts a % list of categories, or by a brace group holding a regular expression @@ -3023,7 +3022,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_c_C:NN} +% \begin{macro}{\@@_compile_c_C:NN} % If |\cC| is not followed by |.| or |(...)| then complain because % that construction cannot match anything, except in cases like % |\cC[\c{...}]|, where it has no effect. @@ -3043,7 +3042,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % { % \@@_compile_c_[:w, % \@@_compile_c_lbrack_loop:NN, @@ -3097,7 +3096,7 @@ } \cs_new_protected:Npn \@@_compile_c_lbrack_add:N #1 { - \if_int_odd:w \__int_eval:w \l_@@_catcodes_int / #1 \__int_eval_end: + \if_int_odd:w \__int_eval:n { \l_@@_catcodes_int / #1 } \else: \int_add:Nn \l_@@_catcodes_int {#1} \fi: @@ -3134,7 +3133,7 @@ % % \begin{macro}+\@@_compile_}:+ % \begin{macro}{\@@_compile_end_cs:} -% \begin{macro}[EXP,aux]{\@@_compile_cs_aux:Nn, \@@_compile_cs_aux:NNnnnN} +% \begin{macro}[EXP]{\@@_compile_cs_aux:Nn, \@@_compile_cs_aux:NNnnnN} % Non-escaped right braces are only special if they appear when % compiling the regular expression for a csname, but not within a % class: |\c{[{}]}| matches the control sequences |\{| and |\}|. So, @@ -3213,8 +3212,8 @@ % % \subsubsection{Raw token lists with \cs{u}} % -% \begin{macro}[aux]{\@@_compile_/u:} -% \begin{macro}[aux, EXP]{\@@_compile_u_loop:NN} +% \begin{macro}{\@@_compile_/u:} +% \begin{macro}[EXP]{\@@_compile_u_loop:NN} % The |\u| escape is invalid in classes and directly following a % catcode test. Otherwise, it must be followed by a left brace. We % then collect the characters for the argument of |\u| within an @@ -3264,7 +3263,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_u_end:} +% \begin{macro}{\@@_compile_u_end:} % Once we have extracted the variable's name, we store the contents of % that variable in \cs{l_@@_internal_a_tl}. The behaviour of |\u| % then depends on whether we are within a |\c{...}| escape (in this @@ -3282,7 +3281,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_u_in_cs:} +% \begin{macro}{\@@_compile_u_in_cs:} % When |\u| appears within a control sequence, we convert the variable % to a string with escaped spaces. Then for each character insert a % class matching exactly that character, once. @@ -3306,7 +3305,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_compile_u_not_cs:} +% \begin{macro}{\@@_compile_u_not_cs:} % In mode $0$, the |\u| escape adds one state to the NFA for each % token in \cs{l_@@_internal_a_tl}. If a given \meta{token} is a % control sequence, then insert a string comparison test, otherwise, @@ -3335,7 +3334,7 @@ % % \subsubsection{Other} % -% \begin{macro}[aux]{\@@_compile_/K:} +% \begin{macro}{\@@_compile_/K:} % The |\K| control sequence is currently the only \enquote{command}, % which performs some action, rather than matching something. It is % allowed in the same contexts as |\b|. At the compilation stage, we @@ -3352,12 +3351,13 @@ % % \subsubsection{Showing regexes} % -% \begin{macro}[aux]{\@@_show:Nn} +% \begin{macro}{\@@_show:N} % Within a \cs{__tl_build:Nw} \ldots{} \cs{__tl_build_end:} group, we % redefine all the function that can appear in a compiled regex, then -% run the regex. The result is then shown. +% 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:Nn #1#2 +\cs_new_protected:Npn \@@_show:N #1 { \__tl_build:Nw \l_@@_internal_a_tl \cs_set_protected:Npn \@@_branch:n @@ -3407,13 +3407,11 @@ \@@_show_push:n { ~ } \cs_if_exist_use:N #1 \__tl_build_end: - \__msg_show_variable:NNNnn #1 \cs_if_exist:NTF ? { } - { >~Compiled~regex~#2: \l_@@_internal_a_tl } } % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_show_one:n} +% \begin{macro}{\@@_show_one:n} % Every part of the final message go through this function, which adds % one line to the output, with the appropriate prefix. % \begin{macrocode} @@ -3422,7 +3420,7 @@ \int_incr:N \l_@@_show_lines_int \__tl_build_one:x { - \exp_not:N \\ + \exp_not:N \iow_newline: \seq_map_function:NN \l_@@_show_prefix_seq \use:n #1 } @@ -3430,7 +3428,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % {\@@_show_push:n, \@@_show_pop:, \@@_show_scope:nn} % Enter and exit levels of nesting. The \texttt{scope} function prints % its first argument as an \enquote{introduction}, then performs its @@ -3450,7 +3448,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_show_group_aux:nnnnN} +% \begin{macro}{\@@_show_group_aux:nnnnN} % We display all groups in the same way, simply adding a message, % \texttt{(no capture)} or \texttt{(resetting)}, to special groups. % The odd \cs{use_ii:nn} avoids printing a spurious \texttt{+-branch} @@ -3468,7 +3466,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_show_class:NnnnN} +% \begin{macro}{\@@_show_class:NnnnN} % I'm entirely unhappy about this function: I couldn't find a way to % test if a class is a single test. Instead, collect the % representation of the tests in the class. If that had more than one @@ -3521,7 +3519,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux, rEXP]{\@@_show_anchor_to_str:N} +% \begin{macro}[rEXP]{\@@_show_anchor_to_str:N} % The argument is an integer telling us where the anchor is. We % convert that to the relevant info. % \begin{macrocode} @@ -3539,7 +3537,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_show_item_catcode:NnT} +% \begin{macro}{\@@_show_item_catcode:NnT} % Produce a sequence of categories which the catcode bitmap |#2| % contains, and show it, indenting the tests on which this catcode % constraint applies. @@ -3560,7 +3558,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_show_item_exact_cs:n} +% \begin{macro}{\@@_show_item_exact_cs:n} % \begin{macrocode} \cs_new_protected:Npn \@@_show_item_exact_cs:n #1 { @@ -3658,7 +3656,7 @@ % corresponding end-points of nested groups. % \end{itemize} % -% \begin{macro}[int]{\@@_build:n, \@@_build:N} +% \begin{macro}{\@@_build:n, \@@_build:N} % The \texttt{n}-type function first compiles its argument. Reset some % variables. Allocate two states, and put a wildcard in state $0$ % (transitions to state $1$ and $0$ state). Then build the regex @@ -3693,7 +3691,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_build_for_cs:n} +% \begin{macro}{\@@_build_for_cs:n} % When using a regex to match a cs, we don't insert a wildcard, we % anchor at the end, and since we ignore submatches, there is no need % to surround the expression with a group. However, for branches to @@ -3726,7 +3724,7 @@ % % \subsubsection{Helpers for building an \textsc{nfa}} % -% \begin{macro}[int]{\@@_push_lr_states:, \@@_pop_lr_states:} +% \begin{macro}{\@@_push_lr_states:, \@@_pop_lr_states:} % When building the regular expression, we keep track of pointers to % the left-end and right-end of each group without help from \TeX{}'s % grouping. @@ -3748,7 +3746,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int] +% \begin{macro} % { % \@@_build_transition_left:NNN, % \@@_build_transition_right:nNn @@ -3766,7 +3764,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_build_new_state:} +% \begin{macro}{\@@_build_new_state:} % Add a new empty state to the \textsc{nfa}. Then update the % \texttt{left}, \texttt{right}, and \texttt{max} states, so that the % \texttt{right} state is the new empty state, and the \texttt{left} @@ -3794,7 +3792,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_build_transitions_lazyness:NNNNN} +% \begin{macro}{\@@_build_transitions_lazyness:NNNNN} % This function creates a new state, and puts two transitions starting % from the old current state. The order of the transitions is % controlled by |#1|, true for lazy quantifiers, and false for greedy @@ -3819,8 +3817,8 @@ % % \subsubsection{Building classes} % -% \begin{macro}[int]{\@@_class:NnnnN} -% \begin{macro}[int, rEXP]{\@@_tests_action_cost:n} +% \begin{macro}{\@@_class:NnnnN} +% \begin{macro}[rEXP]{\@@_tests_action_cost:n} % The arguments are: \meta{boolean} \Arg{tests} \Arg{min} \Arg{more} % \meta{lazyness}. First store the tests with a trailing % \cs{@@_action_cost:n}, in the true branch of @@ -3849,7 +3847,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_class_repeat:n} +% \begin{macro}{\@@_class_repeat:n} % This is used for a fixed number of repetitions. Build one state for % each repetition, with a transition controlled by the tests that we % have collected. That works just fine for |#1|${}=0$ repetitions: @@ -3867,7 +3865,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_class_repeat:nN} +% \begin{macro}{\@@_class_repeat:nN} % This implements unbounded repetitions of a single class (\emph{e.g.} % the |*| and |+| quantifiers). If the minimum number |#1| of % repetitions is $0$, then build a transition from the current state @@ -3895,7 +3893,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_class_repeat:nnN} +% \begin{macro}{\@@_class_repeat:nnN} % We want to build the code to match from |#1| to $|#1|+|#2|$ % repetitions. Match |#1| repetitions (can be $0$). Compute the final % state of the next construction as \texttt{a}. Build $|#2|>0$ states, @@ -3921,7 +3919,7 @@ % % \subsubsection{Building groups} % -% \begin{macro}[aux]{\@@_group_aux:nnnnN} +% \begin{macro}{\@@_group_aux:nnnnN} % Arguments: \Arg{label} \Arg{contents} \Arg{min} \Arg{more} % \meta{lazyness}. If \meta{min} is $0$, we need to add a state before % building the group, so that the thread which skips the group does @@ -3962,7 +3960,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_group:nnnN, \@@_group_no_capture:nnnN} +% \begin{macro}{\@@_group:nnnN, \@@_group_no_capture:nnnN} % Hand to \cs{@@_group_aux:nnnnnN} the label of that group % (expanded), and the group itself, with some extra commands to % perform. @@ -3981,8 +3979,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_group_resetting:nnnN} -% \begin{macro}[aux]{\@@_group_resetting_loop:nnNn} +% \begin{macro}{\@@_group_resetting:nnnN} +% \begin{macro}{\@@_group_resetting_loop:nnNn} % Again, hand the label $-1$ to \cs{@@_group_aux:nnnnN}, but this % time we work a little bit harder to keep track of the maximum group % label at the end of any branch, and to reset the group number at @@ -4014,7 +4012,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_branch:n} +% \begin{macro}{\@@_branch:n} % Add a free transition from the left state of the current group to a % brand new state, starting point of this branch. Once the branch is % built, add a transition from its last state to the right state of @@ -4039,7 +4037,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_group_repeat:nn} +% \begin{macro}{\@@_group_repeat:nn} % This function is called to repeat a group a fixed number of times % |#2|; if this is $0$ we remove the group altogether (but don't reset % the \texttt{capturing_group} label). Otherwise, the auxiliary @@ -4065,7 +4063,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_group_submatches:nNN} +% \begin{macro}{\@@_group_submatches:nNN} % This inserts in states |#2| and |#3| the code for tracking % submatches of the group |#1|, unless inhibited by a label of $-1$. % \begin{macrocode} @@ -4079,7 +4077,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_group_repeat_aux:n} +% \begin{macro}{\@@_group_repeat_aux:n} % Here we repeat \tn{toks} ranging from \texttt{left_state} to % \texttt{max_state}, $|#1|>0$ times. First add a transition so that % the copies \enquote{chain} properly. Compute the shift @@ -4095,7 +4093,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:w #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 ) @@ -4112,7 +4110,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_group_repeat:nnN} +% \begin{macro}{\@@_group_repeat:nnN} % This function is called to repeat a group at least $n$ times; the % case $n=0$ is very different from $n>0$. Assume first that $n=0$. % Insert submatch tracking information at the start and end of the @@ -4166,7 +4164,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_group_repeat:nnnN} +% \begin{macro}{\@@_group_repeat:nnnN} % We wish to repeat the group between |#2| and $|#2|+|#3|$ times, with % a lazyness controlled by |#4|. We insert submatch tracking up front: % in principle, we could avoid recording submatches for the first |#2| @@ -4222,7 +4220,7 @@ % % \subsubsection{Others} % -% \begin{macro}[int]{\@@_assertion:Nn, \@@_b_test:, \@@_anchor:N} +% \begin{macro}{\@@_assertion:Nn, \@@_b_test:, \@@_anchor:N} % Usage: \cs{@@_assertion:Nn} \meta{boolean} \Arg{test}, where the % \meta{test} is either of the two other functions. Add a free % transition to a new state, conditionally to the assertion test. The @@ -4269,7 +4267,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_command_K:} +% \begin{macro}{\@@_command_K:} % Change the starting point of the $0$-th submatch (full match), and % transition to a new state, pretending that this is a fresh thread. % \begin{macrocode} @@ -4462,7 +4460,7 @@ % \end{variable} % % \begin{variable}{\l_@@_fresh_thread_bool, \l_@@_empty_success_bool} -% \begin{macro}[aux]{\@@_if_two_empty_matches:F} +% \begin{macro}{\@@_if_two_empty_matches:F} % When doing multiple matches, we need to avoid infinite loops where % each iteration matches the same empty token list. When an empty % token list is matched, the next successful match of the same empty @@ -4507,8 +4505,8 @@ % % \subsubsection{Matching: framework} % -% \begin{macro}[int]{\@@_match:n} -% \begin{macro}[aux]{\@@_match_init:} +% \begin{macro}{\@@_match:n} +% \begin{macro}{\@@_match_init:} % First store the query into \tn{toks} registers and arrays (see % \cs{@@_query_set:nnn}). Then initialize the variables that should % be set once for each user function (even for multiple @@ -4559,7 +4557,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_match_once:} +% \begin{macro}{\@@_match_once:} % This function finds one match, then does some action defined by the % \texttt{every_match} token list, which may recursively call % \cs{@@_match_once:}. First initialize some variables: set the @@ -4595,7 +4593,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_single_match:, \@@_multi_match:n} +% \begin{macro}{\@@_single_match:, \@@_multi_match:n} % For a single match, the overall success is determined by whether the % only match attempt is a success. When doing multiple matches, the % overall matching is successful as soon as any match @@ -4620,8 +4618,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_match_loop:} -% \begin{macro}[aux, rEXP]{\@@_match_one_active:n} +% \begin{macro}{\@@_match_loop:} +% \begin{macro}[rEXP]{\@@_match_one_active:n} % At each new position, set some variables and get the new character % and category from the query. Then unpack the array of active % threads, and clear it by resetting its length @@ -4668,7 +4666,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_query_set:nnn} +% \begin{macro}{\@@_query_set:nnn} % The arguments are: tokens that \texttt{o} and \texttt{x} expand to % one token of the query, the catcode, and the character code. Store % those, and the current brace balance (used later to check for @@ -4693,7 +4691,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_query_get:} +% \begin{macro}{\@@_query_get:} % Extract the current character and category codes at the current % position from the appropriate arrays. % \begin{macrocode} @@ -4711,7 +4709,7 @@ % % \subsubsection{Using states of the \textsc{nfa}} % -% \begin{macro}[int]{\@@_use_state:} +% \begin{macro}{\@@_use_state:} % Use the current \textsc{nfa} instruction. The state is initially % marked as belonging to the current \texttt{step}: this allows normal % free transition to repeat, but group-repeating transitions @@ -4733,7 +4731,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_use_state_and_submatches:nn} +% \begin{macro}{\@@_use_state_and_submatches:nn} % This function is called as one item in the array of active threads % after that array has been unpacked for a new step. Update the % \texttt{current_state} and \texttt{current_submatches} and use the @@ -4756,7 +4754,7 @@ % % \subsubsection{Actions when matching} % -% \begin{macro}[int]{\@@_action_start_wildcard:} +% \begin{macro}{\@@_action_start_wildcard:} % For an unanchored match, state $0$ has a free transition to the next % and a costly one to itself, to repeat at the next position. To catch % repeated identical empty matches, we need to know if a successful @@ -4774,8 +4772,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_action_free:n, \@@_action_free_group:n} -% \begin{macro}[aux]{\@@_action_free_aux:nn} +% \begin{macro}{\@@_action_free:n, \@@_action_free_group:n} +% \begin{macro}{\@@_action_free_aux:nn} % These functions copy a thread after checking that the \textsc{nfa} % state has not already been used at this position. If not, store % submatches in the new state, and insert the instructions for that @@ -4816,7 +4814,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_action_cost:n} +% \begin{macro}{\@@_action_cost:n} % A transition which consumes the current character and shifts the % state by |#1|. The resulting state is stored in the appropriate array % for use at the next position, and we also store the current @@ -4825,13 +4823,13 @@ \cs_new_protected:Npn \@@_action_cost:n #1 { \exp_args:No \@@_store_state:n - { \__int_value:w \__int_eval:w \l_@@_curr_state_int + #1 } + { \__int_value:w \__int_eval:n { \l_@@_curr_state_int + #1 } } } % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_store_state:n} -% \begin{macro}[aux]{\@@_store_submatches:} +% \begin{macro}{\@@_store_state:n} +% \begin{macro}{\@@_store_submatches:} % Put the given state in \cs{g_@@_thread_state_intarray}, and increment % the length of the array. Also store the current submatch in the % appropriate \tn{toks}. @@ -4852,7 +4850,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_disable_submatches:} +% \begin{macro}{\@@_disable_submatches:} % Some user functions don't require tracking submatches. % We get a performance improvement by simply defining the % relevant functions to remove their argument and do nothing @@ -4866,7 +4864,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_action_submatch:n} +% \begin{macro}{\@@_action_submatch:n} % Update the current submatches with the information from the current % position. Maybe a bottleneck. % \begin{macrocode} @@ -4878,7 +4876,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_action_success:} +% \begin{macro}{\@@_action_success:} % There is a successful match when an execution path reaches the last % state in the \textsc{nfa}, unless this marks a second identical % empty match. Then mark that there was a successful match; it is @@ -4937,7 +4935,7 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}[aux, rEXP]{\@@_replacement_balance_one_match:n} +% \begin{macro}[rEXP]{\@@_replacement_balance_one_match:n} % This expects as an argument the first index of a set of entries in % \cs{g_@@_submatch_begin_intarray} (and related arrays) which hold the % submatch information for a given match. It @@ -4956,7 +4954,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux, rEXP]{\@@_replacement_do_one_match:n} +% \begin{macro}[rEXP]{\@@_replacement_do_one_match:n} % The input is the same as \cs{@@_replacement_balance_one_match:n}. % This function is redefined to expand to the part of the token list % from the end of the previous match to a given match, followed by the @@ -4975,7 +4973,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_exp_not:N} +% \begin{macro}{\@@_replacement_exp_not:N} % This function lets us navigate around the fact that the primitive % \cs{exp_not:n} requires a braced argument. As far as I can tell, it % is only needed if the user tries to include in the replacement text @@ -4990,8 +4988,8 @@ % % \subsubsection{Query and brace balance} % -% \begin{macro}[int, rEXP]{\@@_query_range:nn} -% \begin{macro}[aux, rEXP]{\@@_query_range_loop:ww} +% \begin{macro}[rEXP]{\@@_query_range:nn} +% \begin{macro}[rEXP]{\@@_query_range_loop:ww} % When it is time to extract submatches from the token list, the % various tokens are stored in \tn{toks} registers numbered from % \cs{l_@@_min_pos_int} inclusive to \cs{l_@@_max_pos_int} @@ -5024,7 +5022,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_query_submatch:n} +% \begin{macro}{\@@_query_submatch:n} % Find the start and end positions for a given submatch (of a given match). % \begin{macrocode} \cs_new:Npn \@@_query_submatch:n #1 @@ -5047,7 +5045,8 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_submatch_balance:n #1 { - \__int_eval:w + \__int_eval:n + { \int_compare:nNnTF { \__intarray_item_fast:Nn \g_@@_submatch_end_intarray {#1} } = 0 { 0 } @@ -5063,15 +5062,15 @@ \__intarray_item_fast:Nn \g_@@_balance_intarray { \__intarray_item_fast:Nn \g_@@_submatch_begin_intarray {#1} } } - \__int_eval_end: + } } % \end{macrocode} % \end{macro} % % \subsubsection{Framework} % -% \begin{macro}[int]{\@@_replacement:n} -% \begin{macro}[aux]{\@@_replacement_aux:n} +% \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 % \cs{l_@@_balance_int} of the balance of explicit begin- and @@ -5139,7 +5138,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_normal:n} +% \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 % requested: then \cs{@@_replacement_c_A:w} or a similar auxiliary is @@ -5168,7 +5167,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_escaped:N} +% \begin{macro}{\@@_replacement_escaped:N} % As in parsing a regular expression, we use an auxiliary built from % |#1| if defined. Otherwise, check for escaped digits (standing from % submatches from $0$ to $9$): anything else is a raw character. @@ -5191,7 +5190,7 @@ % % \subsubsection{Submatches} % -% \begin{macro}[aux]{\@@_replacement_put_submatch:n} +% \begin{macro}{\@@_replacement_put_submatch:n} % Insert a submatch in the replacement text. This is dropped if the % submatch number is larger than the number of capturing groups. % Unless the submatch appears inside a |\c{...}| or |\u{...}| @@ -5207,15 +5206,15 @@ \__tl_build_one:n { \@@_query_submatch: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:w #1+##1 \__int_eval_end: } } + { + \@@_submatch_balance:n { \__int_eval:n { #1+##1 } } } \fi: \fi: } % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_g:w} -% \begin{macro}[aux,rEXP]{\@@_replacement_g_digits:NN} +% \begin{macro}{\@@_replacement_g:w} +% \begin{macro}[rEXP]{\@@_replacement_g_digits:NN} % Grab digits for the |\g| escape sequence in a primitive assignment % to the integer \cs{l_@@_internal_a_int}. At the end of the run of % digits, check that it ends with a right brace. @@ -5259,7 +5258,7 @@ % % \subsubsection{Csnames in replacement} % -% \begin{macro}[aux]{\@@_replacement_c:w} +% \begin{macro}{\@@_replacement_c:w} % |\c| may only be followed by an unescaped character. If followed by % a left brace, start a control sequence by calling an auxiliary % common with |\u|. Otherwise test whether the category is known; if @@ -5282,7 +5281,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_cu_aux:Nw} +% \begin{macro}{\@@_replacement_cu_aux:Nw} % Start a control sequence with \cs{cs:w}, protected % from expansion by |#1| (either \cs{@@_replacement_exp_not:N} or % \cs{exp_not:V}), or turned to a string by \cs{tl_to_str:V} if inside @@ -5302,7 +5301,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_u:w} +% \begin{macro}{\@@_replacement_u:w} % Check that |\u| is followed by a left brace. If so, start a control % sequence with \cs{cs:w}, which is then unpacked either with % \cs{exp_not:V} or \cs{tl_to_str:V} depending on the current context. @@ -5316,7 +5315,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_rbrace:N} +% \begin{macro}{\@@_replacement_rbrace:N} % Within a |\c{...}| or |\u{...}| construction, end the control % sequence, and decrease the brace count. Otherwise, this is a raw % right brace. @@ -5335,7 +5334,7 @@ % % \subsubsection{Characters in replacement} % -% \begin{macro}[aux]{\@@_replacement_cat:NNN} +% \begin{macro}{\@@_replacement_cat:NNN} % Here, |#1| is a letter among |BEMTPUDSLOA| and |#2#3| denote the % next character. Complain if we reach the end of the replacement or % if the construction appears inside |\c{|\ldots{}|}| or @@ -5389,7 +5388,7 @@ \group_begin: % \end{macrocode} % -% \begin{macro}[aux]{\@@_replacement_char:nNN} +% \begin{macro}{\@@_replacement_char:nNN} % The only way to produce an arbitrary character--catcode pair is to % use the \tn{lowercase} or \tn{uppercase} primitives. This is a % wrapper for our purposes. The first argument is the null character @@ -5406,7 +5405,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_A:w} +% \begin{macro}{\@@_replacement_c_A:w} % For an active character, expansion must be avoided, twice because we % later do two \texttt{x}-expansions, to unpack \tn{toks} for the % query, and to expand their contents to tokens of the query. @@ -5417,7 +5416,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_B:w} +% \begin{macro}{\@@_replacement_c_B:w} % An explicit begin-group token increases the balance, unless within a % |\c{...}| or |\u{...}| construction. Add the desired begin-group % character, using the standard \cs{if_false:} trick. We eventually @@ -5438,7 +5437,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_C:w} +% \begin{macro}{\@@_replacement_c_C:w} % This is not quite catcode-related: when the user requests a % character with category \enquote{control sequence}, the % one-character control symbol is returned. As for the active @@ -5449,7 +5448,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_D:w} +% \begin{macro}{\@@_replacement_c_D:w} % Subscripts fit the mould: \tn{lowercase} the null byte with the % correct category. % \begin{macrocode} @@ -5459,7 +5458,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_E:w} +% \begin{macro}{\@@_replacement_c_E:w} % Similar to the begin-group case, the second \texttt{x}-expansion % produces the bare end-group token. % \begin{macrocode} @@ -5475,7 +5474,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_L:w} +% \begin{macro}{\@@_replacement_c_L:w} % Simply \tn{lowercase} a letter null byte to produce an arbitrary letter. % \begin{macrocode} \char_set_catcode_letter:N \^^@ @@ -5484,7 +5483,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_M:w} +% \begin{macro}{\@@_replacement_c_M:w} % No surprise here, we lowercase the null math toggle. % \begin{macrocode} \char_set_catcode_math_toggle:N \^^@ @@ -5493,7 +5492,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_O:w} +% \begin{macro}{\@@_replacement_c_O:w} % Lowercase an other null byte. % \begin{macrocode} \char_set_catcode_other:N \^^@ @@ -5502,7 +5501,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_P:w} +% \begin{macro}{\@@_replacement_c_P:w} % For macro parameters, expansion is a tricky issue. We need to % prepare for two \texttt{x}-expansions and passing through various % macro definitions. Note that we cannot replace one \cs{exp_not:n} by @@ -5519,7 +5518,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_S:w} +% \begin{macro}{\@@_replacement_c_S:w} % Spaces are normalized on input by \TeX{} to have character code % $32$. It is in fact impossible to get a token with character code % $0$ and category code $10$. Hence we use $32$ instead of $0$ as our @@ -5536,7 +5535,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_T:w} +% \begin{macro}{\@@_replacement_c_T:w} % No surprise for alignment tabs here. Those are surrounded by the % appropriate braces whenever necessary, hence they don't cause % trouble in alignment settings. @@ -5547,7 +5546,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replacement_c_U:w} +% \begin{macro}{\@@_replacement_c_U:w} % Simple call to \cs{@@_replacement_char:nNN} which lowercases the % math superscript |^^@|. % \begin{macrocode} @@ -5564,7 +5563,7 @@ % % \subsubsection{An error} % -% \begin{macro}[aux]{\@@_replacement_error:NNN} +% \begin{macro}{\@@_replacement_error:NNN} % Simple error reporting by calling one of the messages % \texttt{replacement-c}, \texttt{replacement-g}, or % \texttt{replacement-u}. @@ -5613,16 +5612,26 @@ % \begin{macro}{\regex_show:N, \regex_show:n} % User functions: the \texttt{n} variant requires compilation first. % Then show the variable with some appropriate text. The auxiliary -% \cs{@@_show:Nx} is defined in a different section. +% is defined in a different section. % \begin{macrocode} \cs_new_protected:Npn \regex_show:n #1 { \@@_compile:n {#1} - \@@_show:Nn \l_@@_internal_regex - { { \tl_to_str:n {#1} } } + \@@_show:N \l_@@_internal_regex + \msg_show:nnxxxx { LaTeX / kernel } { show-regex } + { \tl_to_str:n {#1} } { } + { \l_@@_internal_a_tl } { } } \cs_new_protected:Npn \regex_show:N #1 - { \@@_show:Nn #1 { variable~\token_to_str:N #1 } } + { + \__kernel_check_defined:NT #1 + { + \@@_show:N #1 + \msg_show:nnxxxx { LaTeX / kernel } { show-regex } + { } { \token_to_str:N #1 } + { \l_@@_internal_a_tl } { } + } + } % \end{macrocode} % \end{macro} % @@ -5748,7 +5757,7 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}[aux]{\@@_return:} +% \begin{macro}{\@@_return:} % This function triggers either \cs{prg_return_false:} or % \cs{prg_return_true:} as appropriate to whether a match was found or % not. It is used by all user conditionals. @@ -5766,7 +5775,7 @@ % % \subsubsection{Matching} % -% \begin{macro}[aux]{\@@_if_match:nn} +% \begin{macro}{\@@_if_match:nn} % We don't track submatches, and stop after a single match. Build the % \textsc{nfa} with |#1|, and perform the match on the query |#2|. % \begin{macrocode} @@ -5782,7 +5791,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_count:nnN} +% \begin{macro}{\@@_count:nnN} % Again, we don't care about submatches. Instead of aborting after the % first \enquote{longest match} is found, we search for multiple % matches, incrementing \cs{l_@@_match_count_int} every time to @@ -5806,7 +5815,7 @@ % % \subsubsection{Extracting submatches} % -% \begin{macro}[aux]{\@@_extract_once:nnN, \@@_extract_all:nnN} +% \begin{macro}{\@@_extract_once:nnN, \@@_extract_all:nnN} % Match once or multiple times. After each match (or after the only % match), extract the submatches using \cs{@@_extract:}. At the % end, store the sequence containing all the submatches into the user @@ -5832,7 +5841,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_split:nnN} +% \begin{macro}{\@@_split:nnN} % Splitting at submatches is a bit more tricky. For each match, % extract all submatches, and replace the zeroth submatch by the part % of the query between the start of the match attempt and the start of @@ -5885,7 +5894,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_group_end_extract_seq:N} +% \begin{macro}{\@@_group_end_extract_seq:N} % The end-points of submatches are stored as entries of two arrays % from \cs{l_@@_min_submatch_int} to % \cs{l_@@_submatch_int} (exclusive). Extract the relevant ranges @@ -5927,7 +5936,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux, EXP]{\@@_extract_seq_aux:n, \@@_extract_seq_aux:ww} +% \begin{macro}[EXP]{\@@_extract_seq_aux:n, \@@_extract_seq_aux:ww} % The \texttt{:n} auxiliary builds one item of the sequence of % submatches. First compute the brace balance of the submatch, then % extract the submatch from the query, adding the appropriate braces @@ -5956,7 +5965,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux] +% \begin{macro} % {\@@_extract:, \@@_extract_b:wn, \@@_extract_e:wn} % Our task here is to extract from the property list % \cs{l_@@_success_submatches_prop} the list of end-points of @@ -6005,7 +6014,7 @@ % % \subsubsection{Replacement} % -% \begin{macro}[aux]{\@@_replace_once:nnN} +% \begin{macro}{\@@_replace_once:nnN} % Build the \textsc{nfa} and the replacement functions, then find a % single match. If the match failed, simply exit the % group. Otherwise, we do the replacement. Extract submatches. Compute @@ -6051,7 +6060,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_replace_all:nnN} +% \begin{macro}{\@@_replace_all:nnN} % Match multiple times, and for every match, extract submatches and % additionally store the position at which the match attempt started. % The entries from \cs{l_@@_min_submatch_int} to @@ -6094,7 +6103,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_group_end_replace:N} +% \begin{macro}{\@@_group_end_replace:N} % If the brace balance is not $0$, raise an error. Then set the user's % variable |#1| to the \texttt{x}-expansion of % \cs{l_@@_internal_a_tl}, adding the appropriate braces to produce @@ -6436,7 +6445,17 @@ } % \end{macrocode} % -% \begin{macro}[aux]{\@@_msg_repeated:nnN} +% Used when showing a regex. +% \begin{macrocode} +\__msg_kernel_new:nnn { kernel } { show-regex } + { + >~Compiled~regex~ + \tl_if_empty:nTF {#1} { variable~ #2 } { {#1} } : + #3 + } +% \end{macrocode} +% +% \begin{macro}{\@@_msg_repeated:nnN} % This is not technically a message, but seems related enough to go % there. The arguments are: |#1| is the minimum number of repetitions; % |#2| is the number of allowed extra repetitions ($-1$ for infinite @@ -6467,7 +6486,7 @@ % package \pkg{l3trace}. Function names are a bit different but could % be merged. % -% \begin{macro}[int] +% \begin{macro} % {\__debug_trace_push:nnN, \__debug_trace_pop:nnN, \__debug_trace:nnx} % Here |#1| is the module name (\texttt{regex}) and |#2| is % typically~1. If the module's current tracing level is less than @@ -6497,7 +6516,7 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}[int]{\@@_trace_states:n} +% \begin{macro}{\@@_trace_states:n} % This function lists the contents of all states of the \textsc{nfa}, % stored in \tn{toks} from $0$ to \cs{l_@@_max_state_int} % (excluded). |