summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3regex.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3regex.dtx137
1 files changed, 99 insertions, 38 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx
index 625907bf5a0..c1e07cca601 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3regex.dtx
@@ -41,7 +41,7 @@
% }^^A
% }
%
-% \date{Released 2017/07/15}
+% \date{Released 2017/07/19}
%
% \maketitle
%
@@ -1441,9 +1441,16 @@
% \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|.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ {
+ \__debug_trace_push:nnN { regex } { 1 } \@@_escape_use:nnnn
+ \__tl_build:Nw \l_@@_internal_a_tl
+ \__tl_build_one:n { \__debug_trace_pop:nnN { regex } { 1 } \@@_escape_use:nnnn }
+ \use_none:nn
+ }
+ { }
\cs_new_protected:Npn \@@_escape_use:nnnn #1#2#3#4
{
-%<trace> \trace_push:nnn { regex } { 1 } { @@_escape_use:nnnn }
\__tl_build:Nw \l_@@_internal_a_tl
\cs_set:Npn \@@_escape_unescaped:N ##1 { #1 }
\cs_set:Npn \@@_escape_escaped:N ##1 { #2 }
@@ -1457,7 +1464,6 @@
}
\__tl_build_one:o \l_@@_internal_b_tl
\__tl_build_end:
-%<trace> \trace_pop:nnn { regex } { 1 } { @@_escape_use:nnnn }
\l_@@_internal_a_tl
}
% \end{macrocode}
@@ -3665,9 +3671,14 @@
\@@_compile:n {#1}
\@@_build:N \l_@@_internal_regex
}
+\__debug_patch:nnNNpn
+ { \__debug_trace_push:nnN { regex } { 1 } \@@_build:N }
+ {
+ \@@_trace_states:n { 2 }
+ \__debug_trace_pop:nnN { regex } { 1 } \@@_build:N
+ }
\cs_new_protected:Npn \@@_build:N #1
{
-%<trace> \trace_push:nnn { regex } { 1 } { @@_build }
\@@_standard_escapechar:
\int_zero:N \l_@@_capturing_group_int
\int_set_eq:NN \l_@@_max_state_int \l_@@_min_state_int
@@ -3678,8 +3689,6 @@
\@@_group:nnnN {#1} { 1 } { 0 } \c_false_bool
\@@_toks_put_right:Nn \l_@@_right_state_int
{ \@@_action_success: }
-%<trace> \@@_trace_states:n { 2 }
-%<trace> \trace_pop:nnn { regex } { 1 } { @@_build }
}
% \end{macrocode}
% \end{macro}
@@ -3691,9 +3700,14 @@
% work properly at the outer level, we need to put the appropriate
% \texttt{left} and \texttt{right} states in their sequence.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ { \__debug_trace_push:nnN { regex } { 1 } \@@_build_for_cs:n }
+ {
+ \@@_trace_states:n { 2 }
+ \__debug_trace_pop:nnN { regex } { 1 } \@@_build_for_cs:n
+ }
\cs_new_protected:Npn \@@_build_for_cs:n #1
{
-%<trace> \trace_push:nnn { regex } { 1 } { @@_build_for_cs }
\int_set_eq:NN \l_@@_max_state_int \l_@@_min_state_int
\@@_build_new_state:
\@@_build_new_state:
@@ -3706,8 +3720,6 @@
\exp_after:wN \@@_action_success:
\fi:
}
-%<trace> \@@_trace_states:n { 2 }
-%<trace> \trace_pop:nnn { regex } { 1 } { @@_build_for_cs }
}
% \end{macrocode}
% \end{macro}
@@ -3760,10 +3772,9 @@
% \texttt{right} state is the new empty state, and the \texttt{left}
% state points to the previously \enquote{current} state.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_build_new_state:
+\__debug_patch:nnNNpn
{
-%<*trace>
- \trace:nnx { regex } { 2 }
+ \__debug_trace:nnx { regex } { 2 }
{
regex~new~state~
L=\int_use:N \l_@@_left_state_int ~ -> ~
@@ -3771,7 +3782,10 @@
M=\int_use:N \l_@@_max_state_int ~ -> ~
\int_eval:n { \l_@@_max_state_int + 1 }
}
-%</trace>
+ }
+ { }
+\cs_new_protected:Npn \@@_build_new_state:
+ {
\@@_toks_clear:N \l_@@_max_state_int
\int_set_eq:NN \l_@@_left_state_int \l_@@_right_state_int
\int_set_eq:NN \l_@@_right_state_int \l_@@_max_state_int
@@ -3924,9 +3938,11 @@
% auxiliaries expects \texttt{left_state} and \texttt{right_state} to
% be set properly.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ { \__debug_trace_push:nnN { regex } { 1 } \@@_group_aux:nnnnN }
+ { \__debug_trace_pop:nnN { regex } { 1 } \@@_group_aux:nnnnN }
\cs_new_protected:Npn \@@_group_aux:nnnnN #1#2#3#4#5
{
-%<trace> \trace_push:nnn { regex } { 1 } { @@_group }
\if_int_compare:w #3 = 0 \exp_stop_f:
\@@_build_new_state:
%<assert>\assert_int:n { \l_@@_max_state_int = \l_@@_right_state_int + 1 }
@@ -3942,7 +3958,6 @@
\or: \@@_group_repeat:nnN {#1} {#3} #5
\else: \@@_group_repeat:nnnN {#1} {#3} {#4} #5
\fi:
-%<trace> \trace_pop:nnn { regex } { 1 } { @@_group }
}
% \end{macrocode}
% \end{macro}
@@ -4006,9 +4021,11 @@
% the group. The left and right states of the group are extracted from
% the relevant sequences.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ { \__debug_trace_push:nnN { regex } { 1 } \@@_branch:n }
+ { \__debug_trace_pop:nnN { regex } { 1 } \@@_branch:n }
\cs_new_protected:Npn \@@_branch:n #1
{
-%<trace> \trace_push:nnn { regex } { 1 } { @@_branch }
\@@_build_new_state:
\seq_get:NN \l_@@_left_state_seq \l_@@_internal_a_tl
\int_set:Nn \l_@@_left_state_int \l_@@_internal_a_tl
@@ -4018,7 +4035,6 @@
\seq_get:NN \l_@@_right_state_seq \l_@@_internal_a_tl
\@@_build_transition_right:nNn \@@_action_free:n
\l_@@_right_state_int \l_@@_internal_a_tl
-%<trace> \trace_pop:nnn { regex } { 1 } { @@_branch }
}
% \end{macrocode}
% \end{macro}
@@ -4492,6 +4508,7 @@
% \subsubsection{Matching: framework}
%
% \begin{macro}[int]{\@@_match:n}
+% \begin{macro}[aux]{\@@_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
@@ -4502,10 +4519,14 @@
% smothering an empty match at the start). Once all this is set up, we
% are ready for the ride. Find the first match.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ {
+ \__debug_trace_push:nnN { regex } { 1 } \@@_match:n
+ \__debug_trace:nnx { regex } { 1 } { analyzing~query~token~list }
+ }
+ { \__debug_trace_pop:nnN { regex } { 1 } \@@_match:n }
\cs_new_protected:Npn \@@_match:n #1
{
-%<trace> \trace_push:nnx { regex } { 1 } { @@_match }
-%<trace> \trace:nnx { regex } { 1 } { analyzing~query~token~list }
\int_zero:N \l_@@_balance_int
\int_set:Nn \l_@@_curr_pos_int { 2 * \l_@@_max_state_int }
\@@_query_set:nnn { } { -1 } { -2 }
@@ -4514,7 +4535,14 @@
{ \@@_query_set:nnn {##1} {"##2} {##3} }
\int_set_eq:NN \l_@@_max_pos_int \l_@@_curr_pos_int
\@@_query_set:nnn { } { -1 } { -2 }
-%<trace> \trace:nnx { regex } { 1 } { initializing }
+ \@@_match_init:
+ \@@_match_once:
+ }
+\__debug_patch:nnNNpn
+ { \__debug_trace:nnx { regex } { 1 } { initializing } }
+ { }
+\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 }
@@ -4526,11 +4554,10 @@
{ 2 * \l_@@_max_state_int }
\int_set_eq:NN \l_@@_submatch_int \l_@@_min_submatch_int
\bool_set_false:N \l_@@_empty_success_bool
- \@@_match_once:
-%<trace> \trace_pop:nnx { regex } { 1 } { @@_match }
}
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}[int]{\@@_match_once:}
% This function finds one match, then does some action defined by the
@@ -4692,11 +4719,11 @@
% state is marked as $\texttt{step}+1$: any thread hitting it at that
% point will be terminated.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ { \__debug_trace:nnx { regex } { 2 } { state~\int_use:N \l_@@_curr_state_int } }
+ { }
\cs_new_protected:Npn \@@_use_state:
{
-%<*trace>
- \trace:nnx { regex } { 2 } { state~\int_use:N \l_@@_curr_state_int }
-%</trace>
\__intarray_gset_fast:Nnn \g_@@_state_active_intarray
{ \l_@@_curr_state_int } { \l_@@_step_int }
\@@_toks_use:w \l_@@_curr_state_int
@@ -5056,9 +5083,11 @@
% parsed, make sure that there is no open csname. Finally, define the
% \texttt{balance_one_match} and \texttt{do_one_match} functions.
% \begin{macrocode}
+\__debug_patch:nnNNpn
+ { \__debug_trace_push:nnN { regex } { 1 } \@@_replacement:n }
+ { \__debug_trace_pop:nnN { regex } { 1 } \@@_replacement:n }
\cs_new_protected:Npn \@@_replacement:n #1
{
-%<trace> \trace_push:nnn { regex } { 1 } { @@_replacement:n }
\__tl_build:Nw \l_@@_internal_a_tl
\int_zero:N \l_@@_balance_int
\tl_clear:N \l_@@_balance_tl
@@ -5095,7 +5124,6 @@
}
\__tl_build_end:
\exp_args:No \@@_replacement_aux:n \l_@@_internal_a_tl
-%<trace> \trace_pop:nnn { regex } { 1 } { @@_replacement:n }
}
\cs_new_protected:Npn \@@_replacement_aux:n #1
{
@@ -6435,27 +6463,60 @@
%
% \subsection{Code for tracing}
%
-% The tracing code is still very experimental, and is meant to be used
-% with the \pkg{l3trace} package, currently in \texttt{l3trial}.
+% There is a more extensive implementation of tracing in the l3trial
+% package \pkg{l3trace}. Function names are a bit different but could
+% be merged.
+%
+% \begin{macro}[int]
+% {\__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
+% |#2| show nothing, otherwise write |#3| to the terminal.
+% \begin{macrocode}
+\__debug:TF
+ {
+ \cs_new_protected:Npn \__debug_trace_push:nnN #1#2#3
+ { \__debug_trace:nnx {#1} {#2} { entering~ \token_to_str:N #3 } }
+ \cs_new_protected:Npn \__debug_trace_pop:nnN #1#2#3
+ { \__debug_trace:nnx {#1} {#2} { leaving~ \token_to_str:N #3 } }
+ \cs_new_protected:Npn \__debug_trace:nnx #1#2#3
+ {
+ \int_compare:nNnF
+ { \int_use:c { g__debug_trace_#1_int } } < {#2}
+ { \iow_term:x { Trace:~#3 } }
+ }
+ }
+ { }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{variable}{\g__debug_trace_regex_int}
+% No tracing when that is zero.
+% \begin{macrocode}
+\int_new:N \g__debug_trace_regex_int
+% \end{macrocode}
+% \end{variable}
%
% \begin{macro}[int]{\@@_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).
% \begin{macrocode}
-%<*trace>
-\cs_new_protected:Npn \@@_trace_states:n #1
+\__debug:TF
{
- \int_step_inline:nnnn
- \l_@@_min_state_int
- { 1 }
- { \l_@@_max_state_int - 1 }
+ \cs_new_protected:Npn \@@_trace_states:n #1
{
- \trace:nnx { regex } { #1 }
- { \iow_char:N \\toks ##1 = { \@@_toks_use:w ##1 } }
+ \int_step_inline:nnnn
+ \l_@@_min_state_int
+ { 1 }
+ { \l_@@_max_state_int - 1 }
+ {
+ \__debug_trace:nnx { regex } {#1}
+ { \iow_char:N \\toks ##1 = { \@@_toks_use:w ##1 } }
+ }
}
}
-%</trace>
+ { }
% \end{macrocode}
% \end{macro}
%