diff options
author | Karl Berry <karl@freefriends.org> | 2012-07-23 17:14:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-07-23 17:14:27 +0000 |
commit | f7855c12c18bb97b7b9e49ab685ee558d8c0b47b (patch) | |
tree | 9196e768b98b68b7ea8eb5fbdf45508d766f4056 /Master/texmf-dist/tex | |
parent | c47bc266846cc8bf776d79f1f54140443a8269a3 (diff) |
l3 3990
git-svn-id: svn://tug.org/texlive/trunk@27107 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
11 files changed, 4236 insertions, 4202 deletions
diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3dt/l3dt.sty b/Master/texmf-dist/tex/latex/l3experimental/l3dt/l3dt.sty index 99bd83e7764..a672181b903 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3dt/l3dt.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3dt/l3dt.sty @@ -47,21 +47,20 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{expl3} -\GetIdInfo$Id: l3dt.dtx 3459 2012-02-26 08:58:53Z joseph $ +\GetIdInfo$Id: l3dt.dtx 3877 2012-06-30 22:24:42Z joseph $ {L3 Experimental data tables} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} -\package_check_loaded_expl: -\quark_new:N \q_dt -\quark_new:N \q_dt_row -\quark_new:N \q_dt_header +\quark_new:N \q__dt +\quark_new:N \q__dt_row +\quark_new:N \q__dt_header \tl_const:Nn \c_empty_dt { { 0 } - \q_dt + \q__dt \q_nil - \q_dt_header - \q_dt_row + \q__dt_header + \q__dt_row } \cs_new_protected:Npn \dt_new:N #1 { \cs_new_eq:NN #1 \c_empty_dt } \cs_new_protected:Npn \dt_clear:N #1 { \cs_set_eq:NN #1 \c_empty_dt } @@ -76,168 +75,166 @@ \dt_new:N \l_tmpb_dt \dt_new:N \g_tmpa_dt \dt_new:N \g_tmpb_dt -\cs_new_protected:Npn \dt_split_aux:nnnn #1#2#3#4 { #3 #2 } -\cs_new_protected:Npn \dt_split_aux:w { } -\cs_new:Npn \dt_split_header:NT #1#2 - { \exp_after:wN \dt_split_header_aux:wn #1 \q_stop {#2} } -\cs_new:Npn \dt_split_header_aux:wn #1 \q_nil \q_dt_header #2 \q_stop #3 - { #3 {#1} { \q_dt_header #2 } } -\cs_new_protected:Npn \dt_split_key:nnTF #1#2 - { \exp_args:No \dt_split_key_aux:nnTF { \tl_to_str:n {#2} } {#1} } -\cs_new_protected:Npn \dt_split_key_aux:nnTF #1#2 - { - \cs_set_protected:Npn \dt_split_aux:w - ##1 \q_dt #1 \q_dt ##2##3##4 \q_mark ##5 \q_stop - { \dt_split_aux:nnnn ##3 { { ##1 \q_dt } {##2} {##4} } } - \dt_split_aux:w #2 \q_mark - \q_dt #1 \q_dt { } { ? \use_ii:nn { } } \q_mark \q_stop - } -\cs_new_protected:Npn \dt_split_key_list:NnTF #1#2 - { \exp_args:NNo \dt_split_key_list_aux:NnTF #1 { \tl_to_str:n {#2} } } -\cs_new_protected:Npn \dt_split_key_list_aux:NnTF #1#2 - { - \cs_set_protected:Npn \dt_split_aux:w - ##1##2 \q_dt #2 \q_dt ##3##4 \q_dt_header ##5 \q_mark ##6 \q_stop +\cs_new_protected:Npn \__dt_split:nnnn #1#2#3#4 { #3 #2 } +\cs_new_protected:Npn \__dt_split:w { } +\cs_new:Npn \__dt_split_header:NT #1#2 + { \exp_after:wN \__dt_split_header:wn #1 \q_stop {#2} } +\cs_new:Npn \__dt_split_header:wn #1 \q_nil \q__dt_header #2 \q_stop #3 + { #3 {#1} { \q__dt_header #2 } } +\cs_new_protected:Npn \__dt_split_key:nnTF #1#2 + { \exp_args:No \__dt_split_key_aux:nnTF { \tl_to_str:n {#2} } {#1} } +\cs_new_protected:Npn \__dt_split_key_aux:nnTF #1#2 + { + \cs_set_protected:Npn \__dt_split:w + ##1 \q__dt #1 \q__dt ##2##3##4 \q_mark ##5 \q_stop + { \__dt_split:nnnn ##3 { { ##1 \q__dt } {##2} {##4} } } + \__dt_split:w #2 \q_mark + \q__dt #1 \q__dt { } { ? \use_ii:nn { } } \q_mark \q_stop + } +\cs_new_protected:Npn \__dt_split_key_list:NnTF #1#2 + { \exp_args:NNo \__dt_split_key_list_aux:NnTF #1 { \tl_to_str:n {#2} } } +\cs_new_protected:Npn \__dt_split_key_list_aux:NnTF #1#2 + { + \cs_set_protected:Npn \__dt_split:w + ##1##2 \q__dt #2 \q__dt ##3##4 \q__dt_header ##5 \q_mark ##6 \q_stop { - \dt_split_aux:nnnn ##3 - { { {##1} ##2 \q_dt } { ##3##4 \q_dt_header ##5 } } + \__dt_split:nnnn ##3 + { { {##1} ##2 \q__dt } { ##3##4 \q__dt_header ##5 } } } - \exp_after:wN \dt_split_aux:w #1 \q_mark - \q_dt #2 \q_dt { ? \use_ii:nn { } } \q_dt_header \q_mark \q_stop + \exp_after:wN \__dt_split:w #1 \q_mark + \q__dt #2 \q__dt { ? \use_ii:nn { } } \q__dt_header \q_mark \q_stop } -\cs_new_protected:Npn \dt_split_row:NnTF #1#2 - { \dt_split_row_aux:NfTF #1 { \int_eval:n {#2} } } -\cs_new_protected:Npn \dt_split_row_aux:NnTF #1#2 +\cs_new_protected:Npn \__dt_split_row:NnTF #1#2 + { \__dt_split_row_aux:NfTF #1 { \int_eval:n {#2} } } +\cs_new_protected:Npn \__dt_split_row_aux:NnTF #1#2 { - \cs_set_protected:Npn \dt_split_aux:w - ##1 \q_dt_row #2 \q_dt ##2##3 \q_dt_row ##4 \q_mark ##5 \q_stop + \cs_set_protected:Npn \__dt_split:w + ##1 \q__dt_row #2 \q__dt ##2##3 \q__dt_row ##4 \q_mark ##5 \q_stop { - \dt_split_aux:nnnn ##2 - { { ##1 \q_dt_row } { #2 \q_dt ##2##3 } {##4} } + \__dt_split:nnnn ##2 + { { ##1 \q__dt_row } { #2 \q__dt ##2##3 } {##4} } } - \exp_after:wN \dt_split_aux:w #1 \q_mark - \q_dt_row #2 \q_dt { ? \use_ii:nn { } } \q_dt_row \q_mark \q_stop + \exp_after:wN \__dt_split:w #1 \q_mark + \q__dt_row #2 \q__dt { ? \use_ii:nn { } } \q__dt_row \q_mark \q_stop } -\cs_generate_variant:Nn \dt_split_row_aux:NnTF { Nf } -\cs_new_protected_nopar:Npn \dt_add_key:Nn { \dt_add_key_aux:NNn \tl_set:Nx } -\cs_new_protected_nopar:Npn \dt_gadd_key:Nn { \dt_add_key_aux:NNn \tl_gset:Nx } -\cs_new_protected:Npn \dt_add_key_aux:NNn #1#2#3 +\cs_generate_variant:Nn \__dt_split_row_aux:NnTF { Nf } +\cs_new_protected_nopar:Npn \dt_add_key:Nn { \__dt_add_key:NNn \tl_set:Nx } +\cs_new_protected_nopar:Npn \dt_gadd_key:Nn { \__dt_add_key:NNn \tl_gset:Nx } +\cs_new_protected:Npn \__dt_add_key:NNn #1#2#3 { - \dt_split_key_list:NnTF #2 {#3} + \__dt_split_key_list:NnTF #2 {#3} { \use_none:nn } { - \dt_split_header:NT #2 - { \dt_add_key_aux:NNnnn #1 #2 {#3} } + \__dt_split_header:NT #2 + { \__dt_add_key:NNnnn #1 #2 {#3} } } } -\cs_new_protected:Npn \dt_add_key_aux:NNnnn #1#2#3#4#5 +\cs_new_protected:Npn \__dt_add_key:NNnnn #1#2#3#4#5 { #1 #2 { \exp_not:n {#4} \tl_to_str:n {#3} - \exp_not:n { \q_dt \q_nil #5 } + \exp_not:n { \q__dt \q_nil #5 } } } -\cs_new_protected_nopar:Npn \dt_add_row:N { \dt_add_row_aux:NN \tl_set:Nx } -\cs_new_protected_nopar:Npn \dt_gadd_row:N { \dt_add_row_aux:NN \tl_gset:Nx } -\cs_new_protected:Npn \dt_add_row_aux:NN #1#2 - { \exp_args:NNf \dt_add_row_aux:NnN #1 { \dt_rows:N #2 } #2 } -\cs_new_protected:Npn \dt_add_row_aux:NnN #1#2#3 +\cs_new_protected_nopar:Npn \dt_add_row:N { \__dt_add_row:NN \tl_set:Nx } +\cs_new_protected_nopar:Npn \dt_gadd_row:N { \__dt_add_row:NN \tl_gset:Nx } +\cs_new_protected:Npn \__dt_add_row:NN #1#2 + { \exp_args:NNf \__dt_add_row:NnN #1 { \dt_rows:N #2 } #2 } +\cs_new_protected:Npn \__dt_add_row:NnN #1#2#3 { #1 #3 { { \int_eval:n { #2 + \c_one } } - \exp_after:wN \dt_add_row_aux:nw #3 \q_stop + \exp_after:wN \__dt_add_row:nw #3 \q_stop #2 - \exp_not:n { \q_dt \q_nil \q_dt_row } + \exp_not:n { \q__dt \q_nil \q__dt_row } } } -\cs_new:Npn \dt_add_row_aux:nw #1#2 \q_stop { \exp_not:n {#2} } +\cs_new:Npn \__dt_add_row:nw #1#2 \q_stop { \exp_not:n {#2} } \cs_new_protected:Npn \dt_put:Nnn #1 { \dt_put:Nnnn #1 { \dt_rows:N #1 - \c_one } } \cs_new_protected:Npn \dt_gput:Nnn #1 { \dt_gput:Nnnn #1 { \dt_rows:N #1 - \c_one } } \cs_new_protected_nopar:Npn \dt_put:Nnnn - { \dt_put_aux:NNNnnn \dt_add_key:Nn \tl_set:Nx } + { \__dt_put:NNNnnn \dt_add_key:Nn \tl_set:Nx } \cs_new_protected_nopar:Npn \dt_gput:Nnnn - { \dt_put_aux:NNNnnn \dt_gadd_key:Nn \tl_gset:Nx } -\cs_new_protected:Npn \dt_put_aux:NNNnnn #1#2#3#4#5#6 + { \__dt_put:NNNnnn \dt_gadd_key:Nn \tl_gset:Nx } +\cs_new_protected:Npn \__dt_put:NNNnnn #1#2#3#4#5#6 { #1 #3 {#5} - \dt_split_row:NnTF #3 {#4} - { \dt_put_aux:NNnnnnn #2 #3 {#5} {#6} } + \__dt_split_row:NnTF #3 {#4} + { \__dt_put:NNnnnnn #2 #3 {#5} {#6} } { - \msg_kernel_error:nnxxx { dt } { unknown-row } + \__msg_kernel_error:nnxxx { dt } { unknown-row } { \token_to_str:N #3 } { \int_eval:n {#4} } { \dt_rows:N #3 } } } -\cs_new_protected:Npn \dt_put_aux:NNnnnnn #1#2#3#4#5#6#7 +\cs_new_protected:Npn \__dt_put:NNnnnnn #1#2#3#4#5#6#7 { - \dt_split_key:nnTF {#6} {#3} - { \dt_put_update:NNnnnnnnn #1 #2 {#3} {#4} {#5} {#7} } - { \dt_put_add_to_row:NNnnnnn #1 #2 {#3} {#4} {#5} {#6} {#7} } + \__dt_split_key:nnTF {#6} {#3} + { \__dt_put_update:NNnnnnnnn #1 #2 {#3} {#4} {#5} {#7} } + { \__dt_put_add_to_row:NNnnnnn #1 #2 {#3} {#4} {#5} {#6} {#7} } } -\cs_new_protected:Npn \dt_put_update:NNnnnnnnn #1#2#3#4#5#6#7#8#9 +\cs_new_protected:Npn \__dt_put_update:NNnnnnnnn #1#2#3#4#5#6#7#8#9 { #1 #2 { \exp_not:n { #5 #7 } \tl_to_str:n {#3} - \exp_not:n { \q_dt {#4} \q_dt #9 \q_dt_row #6 } + \exp_not:n { \q__dt {#4} \q__dt #9 \q__dt_row #6 } } } -\cs_new_protected:Npn \dt_put_add_to_row:NNnnnnn #1#2#3#4#5#6#7 +\cs_new_protected:Npn \__dt_put_add_to_row:NNnnnnn #1#2#3#4#5#6#7 { #1 #2 { \exp_not:n {#5} - \exp_not:o { \dt_put_add_row_aux:w #6 } + \exp_not:o { \__dt_put_add_to_row_aux:w #6 } \tl_to_str:n {#3} - \exp_not:n { \q_dt {#4} \q_dt \q_nil \q_dt_row #7 } + \exp_not:n { \q__dt {#4} \q__dt \q_nil \q__dt_row #7 } } } -\cs_new:Npn \dt_put_add_row_aux:w #1 \q_nil {#1} +\cs_new:Npn \__dt_put_add_to_row_aux:w #1 \q_nil {#1} \cs_new:Npn \dt_keys:N #1 - { \dt_split_header:NT #1 { \dt_keys_aux:nn } } -\cs_new:Npn \dt_keys_aux:nn #1#2 + { \__dt_split_header:NT #1 { \__dt_keys:nn } } +\cs_new:Npn \__dt_keys:nn #1#2 { \int_eval:n { 0 - \exp_after:wN \dt_keys_aux:wN \use_none:nn #1 \q_recursion_tail \q_dt - \prg_break_point:n { } + \exp_after:wN \__dt_keys:wN \use_none:nn #1 \q_recursion_tail \q__dt + \__prg_break_point:Nn \dt_map_break: { } } } -\cs_new:Npn \dt_keys_aux:wN #1 \q_dt +\cs_new:Npn \__dt_keys:wN #1 \q__dt { - \if_meaning:w \q_recursion_tail #1 - \exp_after:wN \prg_map_break: - \fi: + \__quark_if_recursion_tail_break:nN {#1} \dt_map_break: +1 - \dt_keys_aux:wN + \__dt_keys:wN } \cs_new:Npn \dt_rows:N #1 { \exp_after:wN \use_i_delimit_by_q_stop:nw #1 \q_stop } -\cs_new_protected:Npn \dt_del:Nn #1 { \dt_del:Nnn #1 +\cs_new_protected:Npn \dt_remove:Nn #1 { \dt_remove:Nnn #1 { \dt_rows:N #1 - \c_one } } -\cs_new_protected:Npn \dt_gdel:Nn #1 { \dt_gdel:Nnn #1 +\cs_new_protected:Npn \dt_gremove:Nn #1 { \dt_gremove:Nnn #1 { \dt_rows:N #1 - \c_one } } -\cs_new_protected_nopar:Npn \dt_del:Nnn { \dt_del_aux:NNnn \tl_set:Nn } -\cs_new_protected_nopar:Npn \dt_gdel:Nnn { \dt_del_aux:NNnn \tl_gset:Nn } -\cs_new_protected:Npn \dt_del_aux:NNnn #1#2#3#4 +\cs_new_protected_nopar:Npn \dt_remove:Nnn { \dt_remove_aux:NNnn \tl_set:Nn } +\cs_new_protected_nopar:Npn \dt_gremove:Nnn { \dt_remove_aux:NNnn \tl_gset:Nn } +\cs_new_protected:Npn \dt_remove_aux:NNnn #1#2#3#4 { - \dt_split_row:NnTF #2 {#3} - { \dt_del_aux:NNnnnn #1 #2 {#4} } + \__dt_split_row:NnTF #2 {#3} + { \dt_remove_aux:NNnnnn #1 #2 {#4} } { } } -\cs_new_protected:Npn \dt_del_aux:NNnnnn #1#2#3#4#5#6 +\cs_new_protected:Npn \dt_remove_aux:NNnnnn #1#2#3#4#5#6 { - \dt_split_key:nnTF {#5} {#3} - { \dt_del_aux:NNnnnnn #1 #2 {#4} {#6} } + \__dt_split_key:nnTF {#5} {#3} + { \dt_remove_aux:NNnnnnn #1 #2 {#4} {#6} } { } } -\cs_new_protected:Npn \dt_del_aux:NNnnnnn #1#2#3#4#5#6#7 +\cs_new_protected:Npn \dt_remove_aux:NNnnnnn #1#2#3#4#5#6#7 { #1 #2 { #3 #5 #7 #4 } } \cs_new_protected_nopar:Npn \dt_remove_key:Nn { \dt_remove_key_aux:NNn \tl_set:Nx } @@ -245,25 +242,23 @@ { \dt_remove_key_aux:NNn \tl_gset:Nx } \cs_new_protected:Npn \dt_remove_key_aux:NNn #1#2#3 { - \dt_split_key_list:NnTF #2 {#3} + \__dt_split_key_list:NnTF #2 {#3} { \exp_args:No \dt_remove_key_aux:nNNnn { \tl_to_str:n {#3} } #1 #2 } { } } \cs_new_protected:Npn \dt_remove_key_aux:nNNnn #1#2#3#4#5 { - \cs_set:Npn \dt_remove_key_aux:w ##1 \q_dt #1 \q_dt ##2 ##3 + \cs_set:Npn \dt_remove_key_aux:w ##1 \q__dt #1 \q__dt ##2 ##3 { \exp_not:n {##1} - \if_meaning:w \q_recursion_tail ##3 - \exp_after:wN \prg_map_break: - \fi: + \__quark_if_recursion_tail_break:nN {##3} \dt_map_break: \dt_remove_key_aux:w ##3 } #2 #3 { \exp_not:n {#4} - \dt_remove_key_aux:w #5 \q_dt #1 \q_dt { } \q_recursion_tail - \prg_break_point:n { } + \dt_remove_key_aux:w #5 \q__dt #1 \q__dt { } \q_recursion_tail + \__prg_break_point:Nn \dt_map_break: { } } } \cs_new:Npn \dt_remove_key_aux:w { } @@ -273,7 +268,7 @@ { \dt_remove_row_aux:NNn \tl_gset:Nx } \cs_new_protected:Npn \dt_remove_row_aux:NNn #1#2#3 { - \dt_split_row:NnTF #2 {#3} + \__dt_split_row:NnTF #2 {#3} { \dt_remove_row_aux:NNnnn #1 #2 } { } } @@ -283,46 +278,44 @@ { { \int_eval:n { \dt_rows:N #2 - \c_one } } \dt_remove_row_aux:nw #3 \q_stop - \dt_remove_row_loop:nw #5 \q_recursion_tail \q_dt_row - \prg_break_point:n { } + \dt_remove_row_loop:nw #5 \q_recursion_tail \q__dt_row + \__prg_break_point:Nn \dt_map_break: { } } } -\cs_new_eq:NN \dt_remove_row_aux:nw \dt_add_row_aux:nw -\cs_new:Npn \dt_remove_row_loop:nw #1#2 \q_dt_row +\cs_new_eq:NN \dt_remove_row_aux:nw \__dt_add_row:nw +\cs_new:Npn \dt_remove_row_loop:nw #1#2 \q__dt_row { - \if_meaning:w \q_recursion_tail #1 - \exp_after:wN \prg_map_break: - \fi: + \__quark_if_recursion_tail_break:nN {#1} \dt_map_break: \int_eval:n { #1 - \c_one } - \exp_not:n { #2 \q_dt_row } + \exp_not:n { #2 \q__dt_row } \dt_remove_row_loop:nw } \cs_new_protected:Npn \dt_get:NnnN #1#2#3#4 { - \dt_split_row:NnTF #1 {#2} + \__dt_split_row:NnTF #1 {#2} { \dt_get_aux:nNnnn {#3} #4 } { \tl_set:Nn #4 { \q_no_value } } } \cs_new_protected:Npn \dt_get_aux:nNnnn #1#2#3#4#5 { - \dt_split_key:nnTF {#4} {#1} + \__dt_split_key:nnTF {#4} {#1} { \dt_get_aux:Nnnn #2 } { \tl_set:Nn #2 { \q_no_value } } } \cs_new_protected:Npn \dt_get_aux:Nnnn #1#2#3#4 { \tl_set:Nn #1 {#3} } \prg_new_protected_conditional:Npnn \dt_get:NnnN #1#2#3#4 { T , F , TF } { - \dt_split_row:NnTF #1 {#2} - { \dt_get_aux_true:nNnnn {#3} #4 } + \__dt_split_row:NnTF #1 {#2} + { \__dt_get_true:nNnnn {#3} #4 } { \prg_return_false: } } -\cs_new_protected:Npn \dt_get_aux_true:nNnnn #1#2#3#4#5 +\cs_new_protected:Npn \__dt_get_true:nNnnn #1#2#3#4#5 { - \dt_split_key:nnTF {#4} {#1} - { \dt_get_aux_true:Nnnn #2 } + \__dt_split_key:nnTF {#4} {#1} + { \__dt_get_true:Nnnn #2 } { \prg_return_false: } } -\cs_new_protected:Npn \dt_get_aux_true:Nnnn #1#2#3#4 +\cs_new_protected:Npn \__dt_get_true:Nnnn #1#2#3#4 { \tl_set:Nn #1 {#3} \prg_return_true: @@ -340,36 +333,37 @@ { \int_gincr:N \g_dt_map_level_int \seq_gclear_new:c { g_dt_map_ \int_use:N \g_dt_map_level_int _seq } - \keyval_parse:NNn \use_none:n \dt_map_variables_key:nn {#2} - \dt_split_header:NT #1 { \dt_map_variables_aux:nnn {#3} } + \keyval_parse:NNn \use_none:n \__dt_map_variables_key:nn {#2} + \__dt_split_header:NT #1 { \__dt_map_variables:nnn {#3} } } -\cs_new_protected:Npn \dt_map_variables_key:nn #1#2 +\cs_new_protected:Npn \__dt_map_variables_key:nn #1#2 { \seq_gput_right:cn { g_dt_map_ \int_use:N \g_dt_map_level_int _seq } { {#1} #2 } } -\cs_new_protected:Npn \dt_map_variables_aux:nnn #1#2#3 - { \dt_map_variables_aux:nNNw {#1} #3 \q_stop } -\cs_new_protected:Npn \dt_map_variables_aux:nNNw - #1 \q_dt_header \q_dt_row #2 \q_stop +\cs_new_protected:Npn \__dt_map_variables:nnn #1#2#3 + { \__dt_map_variables:nNNw {#1} #3 \q_stop } +\cs_new_protected:Npn \__dt_map_variables:nNNw + #1 \q__dt_header \q__dt_row #2 \q_stop { \int_zero_new:c { l_dt_map_ \int_use:N \g_dt_map_level_int _row_int } - \dt_map_variables_aux:nnw {#1} #2 { } \q_recursion_tail \q_dt_row - \prg_break_point:n { \int_gdecr:N \g_dt_map_level_int } + \__dt_map_variables:nnw {#1} #2 { } \q_recursion_tail \q__dt_row + \__prg_break_point:Nn \dt_map_break: + { \int_gdecr:N \g_dt_map_level_int } } -\cs_new_protected:Npn \dt_map_variables_aux:nnw #1#2#3#4 \q_dt_row +\cs_new_protected:Npn \__dt_map_variables:nnw #1#2#3#4 \q__dt_row { - \if_meaning:w \q_recursion_tail #3 - \exp_after:wN \dt_map_break: - \fi: + \__quark_if_recursion_tail_break:nN {#3} \dt_map_break: \seq_map_inline:cn { g_dt_map_ \int_use:N \g_dt_map_level_int _seq } { \dt_get_aux:nNnnn ##1 { } {#3#4} { } } #1 \int_incr:c { l_dt_map_ \int_use:N \g_dt_map_level_int _row_int } - \dt_map_variables_aux:nnw {#1} + \__dt_map_variables:nnw {#1} } -\cs_new_eq:NN \dt_map_break: \prg_map_break: -\cs_new_eq:NN \dt_map_break:n \prg_map_break:n +\cs_new_nopar:Npn \dt_map_break: + { \__prg_map_break:Nn \dt_map_break: { } } +\cs_new_nopar:Npn \dt_map_break:n + { \__prg_map_break:Nn \dt_map_break: } \prg_new_conditional:Npnn \dt_if_empty:N #1 { T , F , TF , p } { \if_meaning:w #1 \c_empty_dt @@ -379,36 +373,36 @@ \fi: } \prg_new_conditional:Npnn \dt_if_in:Nn #1#2 { p , T , F , TF } - { \dt_split_header:NT #1 { \dt_if_in_aux:nnn {#2} } } -\cs_new:Npn \dt_if_in_aux:nnn #1#2#3 + { \__dt_split_header:NT #1 { \__dt_if_in:nnn {#2} } } +\cs_new:Npn \__dt_if_in:nnn #1#2#3 { - \exp_last_unbraced:Nno \dt_if_in_aux:nwN {#1} { \use_none:nn #2 } - \q_recursion_tail \q_dt - \prg_break_point:n { } + \exp_last_unbraced:Nno \__dt_if_in:nwN {#1} { \use_none:nn #2 } + \q_recursion_tail \q__dt + \__prg_break_point: } -\cs_new:Npn \dt_if_in_aux:nwN #1#2 \q_dt +\cs_new:Npn \__dt_if_in:nwN #1#2 \q__dt { \if_meaning:w \q_recursion_tail #2 - \exp_after:wN \prg_map_break:n + \exp_after:wN \__prg_break:n \else: \exp_after:wN \use_none:n \fi: { \prg_return_false: } \str_if_eq:nnTF {#1} {#2} - { \prg_map_break:n { \prg_return_true: } } - { \dt_if_in_aux:nwN {#1} } + { \__prg_break:n { \prg_return_true: } } + { \__dt_if_in:nwN {#1} } } \prg_new_conditional:Npnn \dt_if_in_row:Nnn #1#2#3 { p , T , F , TF } { - \exp_last_unbraced:Nno \dt_if_in_row_aux:nw {#2} #1 + \exp_last_unbraced:Nno \__dt_if_in_row:nw {#2} #1 \q_recursion_tail \q_nil - \prg_break_point:n { } + \__prg_break_point: { \tl_to_str:n {#3} } } -\cs_new:Npn \dt_if_in_row_aux:nw #1#2 \q_dt_row #3#4 \q_nil +\cs_new:Npn \__dt_if_in_row:nw #1#2 \q__dt_row #3#4 \q_nil { \if_meaning:w \q_recursion_tail #3 - \exp_after:wN \prg_map_break:n + \exp_after:wN \__prg_break:n \else: \exp_after:wN \use_none:n \fi: @@ -417,28 +411,28 @@ \prg_return_false: } \int_compare:nNnTF {#1} = {#3} - { \prg_map_break:n { \exp_args:Nno \dt_if_in_row_aux:nn {#4} } } - { \dt_if_in_row_aux:nw {#1} } + { \__prg_break:n { \exp_args:Nno \__dt_if_in_row:nn {#4} } } + { \__dt_if_in_row:nw {#1} } } -\cs_new:Npn \dt_if_in_row_aux:nn #1#2 +\cs_new:Npn \__dt_if_in_row:nn #1#2 { - \dt_if_in_row_aux:nwn {#2} #1 {#2} \q_dt { } \q_recursion_tail - \prg_break_point:n { } + \__dt_if_in_row:nwn {#2} #1 {#2} \q__dt { } \q_recursion_tail + \__prg_break_point: } -\cs_new:Npn \dt_if_in_row_aux:nwn #1 \q_dt #2 \q_dt #3 +\cs_new:Npn \__dt_if_in_row:nwn #1 \q__dt #2 \q__dt #3 { \str_if_eq:xxTF {#1} {#2} - { \dt_if_in_row_aux:N } - { \dt_if_in_row_aux:nwn {#1} } + { \__dt_if_in_row:N } + { \__dt_if_in_row:nwn {#1} } } -\cs_new:Npn \dt_if_in_row_aux:N #1 +\cs_new:Npn \__dt_if_in_row:N #1 { - \if_meaning:w \q_dt #1 + \if_meaning:w \q__dt #1 \prg_return_true: \else: \prg_return_false: \fi: - \prg_map_break: + \__prg_break: } \cs_new:Npn \dt_if_in_row_p:Nn #1 { \dt_if_in_row_p:Nnn #1 { \dt_rows:N #1 - \c_one } } @@ -448,7 +442,7 @@ { \dt_rows:N #1 - \c_one } } \cs_new:Npn \dt_if_in_row:NnTF #1 { \dt_if_in_row:NnnTF #1 { \dt_rows:N #1 - \c_one } } -\msg_kernel_new:nnnn { dt } { unknown-row } +\__msg_kernel_new:nnnn { dt } { unknown-row } { Data~table~#1~does~not~contain~a~row~'#2'. } { Data~table~#1~contains~#3~rows.~These~must~be~accessed~by~number:~row~ diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3sort/l3sort.sty b/Master/texmf-dist/tex/latex/l3experimental/l3sort/l3sort.sty index b24bacd3794..b9adcd3eeeb 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3sort/l3sort.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3sort/l3sort.sty @@ -47,176 +47,202 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{expl3} -\GetIdInfo$Id: l3sort.dtx 3467 2012-02-26 15:39:35Z bruno $ +\GetIdInfo$Id: l3sort.dtx 3953 2012-07-11 16:15:09Z bruno $ {L3 Experimental sorting functions} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} -\package_check_loaded_expl: -\int_const:Nn \c_sort_max_length_int +\int_const:Nn \c__sort_max_length_int { \luatex_if_engine:TF { 49152 } { 24576 } } -\int_new:N \l_sort_length_int -\int_new:N \l_sort_block_int -\int_new:N \l_sort_begin_int -\int_new:N \l_sort_end_int -\int_new:N \l_sort_A_int -\int_new:N \l_sort_B_int -\int_new:N \l_sort_C_int -\cs_new_protected:Npn \sort_aux:NNnNn #1#2#3#4#5 +\int_new:N \l__sort_length_int +\int_new:N \l__sort_block_int +\int_new:N \l__sort_begin_int +\int_new:N \l__sort_end_int +\int_new:N \l__sort_A_int +\int_new:N \l__sort_B_int +\int_new:N \l__sort_C_int +\cs_new:Npn \tl_sort:nN #1#2 { \__sort_quick_i:nNn {#1} #2 { } } +\cs_new:Npn \__sort_quick_i:nNn #1#2 + { + \exp_after:wN \__sort_quick_ii:wn + \use_none:n #1 \__prg_break_point: + \__sort_quick_iii:nnNnn { } { } #2 + #1 + { \__prg_break_point: } + \__prg_break_point: + } +\cs_new:Npn \__sort_quick_ii:wn #1 \__prg_break_point: #2 {#2} +\cs_new:Npn \__sort_quick_iii:nnNnn #1#2#3#4#5 + { + \__prg_break: #5 + \__sort_quick_iv:nnNnwn {#1} {#2} + \__prg_break_point: + #3 {#4} {#5} + { \__sort_quick_iii:nnNnn {#1} { #2 {#5} } } + { \__sort_quick_iii:nnNnn { #1 {#5} } {#2} } + #3 {#4} + } +\cs_new:Npn \__sort_quick_iv:nnNnwn + #1#2 \__prg_break_point: #3#4 #5 \__prg_break_point: #6 + { + \__sort_quick_i:nNn {#2} #3 + { \__sort_quick_i:nNn {#1} #3 {#6} {#4} } + } +\cs_new_protected:Npn \__sort_main:NNNnNn #1#2#3#4#5#6 { \group_begin: - \l_sort_length_int \c_zero - #2 #4 + \l__sort_length_int \c_zero + #2 #5 { - \if_num:w \l_sort_length_int = \c_sort_max_length_int - \sort_too_long_error:Nw #4 + \if_int_compare:w \l__sort_length_int = \c__sort_max_length_int + \__sort_too_long_error:NNw #3 #5 \fi: - \tex_toks:D \l_sort_length_int {##1} - \tex_advance:D \l_sort_length_int \c_one + \tex_toks:D \l__sort_length_int {##1} + \tex_advance:D \l__sort_length_int \c_one } - \cs_set:Npn \sort_compare:nn ##1 ##2 { #5 } - \l_sort_block_int \c_one - \sort_level: + \cs_set:Npn \sort_compare:nn ##1 ##2 { #6 } + \l__sort_block_int \c_one + \__sort_level: \use:x { \group_end: - #1 \exp_not:N #4 {#3} + #1 \exp_not:N #5 {#4} } } \cs_new_protected_nopar:Npn \seq_sort:Nn { - \sort_aux:NNnNn \tl_set:Nn - \seq_map_inline:Nn - { \sort_toks:NNw \exp_not:N \seq_item:n 0 ; } + \__sort_main:NNNnNn \tl_set:Nn + \seq_map_inline:Nn \seq_map_break: + { \__sort_toks:NNw \exp_not:N \__seq_item:n 0 ; } } \cs_new_protected_nopar:Npn \seq_gsort:Nn { - \sort_aux:NNnNn \tl_gset:Nn - \seq_map_inline:Nn - { \sort_toks:NNw \exp_not:N \seq_item:n 0 ; } + \__sort_main:NNNnNn \tl_gset:Nn + \seq_map_inline:Nn \seq_map_break: + { \__sort_toks:NNw \exp_not:N \__seq_item:n 0 ; } } \cs_new_protected_nopar:Npn \tl_sort:Nn { - \sort_aux:NNnNn \tl_set:Nn - \tl_map_inline:Nn - { \sort_toks:NNw \prg_do_nothing: \prg_do_nothing: 0 ; } + \__sort_main:NNNnNn \tl_set:Nn + \tl_map_inline:Nn \tl_map_break: + { \__sort_toks:NNw \prg_do_nothing: \prg_do_nothing: 0 ; } } \cs_new_protected_nopar:Npn \tl_gsort:Nn { - \sort_aux:NNnNn \tl_gset:Nn - \tl_map_inline:Nn - { \sort_toks:NNw \prg_do_nothing: \prg_do_nothing: 0 ; } + \__sort_main:NNNnNn \tl_gset:Nn + \tl_map_inline:Nn \tl_map_break: + { \__sort_toks:NNw \prg_do_nothing: \prg_do_nothing: 0 ; } } \cs_new_protected_nopar:Npn \clist_sort:Nn - { \clist_sort_aux:NNn \tl_set:Nn } + { \__sort_sort:NNn \tl_set:Nn } \cs_new_protected_nopar:Npn \clist_gsort:Nn - { \clist_sort_aux:NNn \tl_gset:Nn } -\cs_new_protected:Npn \clist_sort_aux:NNn #1#2#3 + { \__sort_sort:NNn \tl_gset:Nn } +\cs_new_protected:Npn \__sort_sort:NNn #1#2#3 { \clist_if_empty:NF #2 { - \sort_aux:NNnNn #1 - \clist_map_inline:Nn + \__sort_main:NNNnNn #1 + \clist_map_inline:Nn \clist_map_break: { \exp_last_unbraced:Nf \use_none:n - { \sort_toks:NNw \exp_args:No \clist_wrap_item:n 0 ; } + { \__sort_toks:NNw \exp_args:No \__clist_wrap_item:n 0 ; } } #2 {#3} } } -\cs_new:Npn \sort_toks:NNw #1#2#3 ; +\cs_new:Npn \__sort_toks:NNw #1#2#3 ; { - \if_num:w #3 < \l_sort_length_int + \if_int_compare:w #3 < \l__sort_length_int #1 #2 { \tex_the:D \tex_toks:D #3 } - \exp_after:wN \sort_toks:NNw \exp_after:wN #1 \exp_after:wN #2 - \int_use:N \int_eval:w #3 + \c_one \exp_after:wN ; + \exp_after:wN \__sort_toks:NNw \exp_after:wN #1 \exp_after:wN #2 + \int_use:N \__int_eval:w #3 + \c_one \exp_after:wN ; \fi: } -\cs_new_protected_nopar:Npn \sort_level: +\cs_new_protected_nopar:Npn \__sort_level: { - \if_num:w \l_sort_block_int < \l_sort_length_int - \l_sort_end_int \c_zero - \sort_merge_blocks: - \tex_multiply:D \l_sort_block_int \c_two - \exp_after:wN \sort_level: + \if_int_compare:w \l__sort_block_int < \l__sort_length_int + \l__sort_end_int \c_zero + \__sort_merge_blocks: + \tex_multiply:D \l__sort_block_int \c_two + \exp_after:wN \__sort_level: \fi: } -\cs_new_protected_nopar:Npn \sort_merge_blocks: +\cs_new_protected_nopar:Npn \__sort_merge_blocks: { - \l_sort_begin_int \l_sort_end_int - \tex_advance:D \l_sort_end_int \l_sort_block_int - \if_num:w \int_eval:w \l_sort_end_int < \l_sort_length_int - \l_sort_A_int \l_sort_end_int - \tex_advance:D \l_sort_end_int \l_sort_block_int - \if_num:w \l_sort_end_int > \l_sort_length_int - \l_sort_end_int \l_sort_length_int + \l__sort_begin_int \l__sort_end_int + \tex_advance:D \l__sort_end_int \l__sort_block_int + \if_int_compare:w \__int_eval:w \l__sort_end_int < \l__sort_length_int + \l__sort_A_int \l__sort_end_int + \tex_advance:D \l__sort_end_int \l__sort_block_int + \if_int_compare:w \l__sort_end_int > \l__sort_length_int + \l__sort_end_int \l__sort_length_int \fi: - \l_sort_B_int \l_sort_A_int - \l_sort_C_int \l_sort_length_int + \l__sort_B_int \l__sort_A_int + \l__sort_C_int \l__sort_length_int \sort_copy_block: - \tex_advance:D \l_sort_A_int \c_minus_one - \tex_advance:D \l_sort_B_int \c_minus_one - \tex_advance:D \l_sort_C_int \c_minus_one - \sort_merge_blocks_aux: - \exp_after:wN \sort_merge_blocks: + \tex_advance:D \l__sort_A_int \c_minus_one + \tex_advance:D \l__sort_B_int \c_minus_one + \tex_advance:D \l__sort_C_int \c_minus_one + \__sort_merge_blocks_aux: + \exp_after:wN \__sort_merge_blocks: \fi: } \cs_new_protected_nopar:Npn \sort_copy_block: { - \tex_toks:D \l_sort_C_int \tex_toks:D \l_sort_B_int - \tex_advance:D \l_sort_C_int \c_one - \tex_advance:D \l_sort_B_int \c_one - \if_num:w \l_sort_B_int = \l_sort_end_int + \tex_toks:D \l__sort_C_int \tex_toks:D \l__sort_B_int + \tex_advance:D \l__sort_C_int \c_one + \tex_advance:D \l__sort_B_int \c_one + \if_int_compare:w \l__sort_B_int = \l__sort_end_int \use_i:nn \fi: \sort_copy_block: } -\cs_new_protected_nopar:Npn \sort_merge_blocks_aux: +\cs_new_protected_nopar:Npn \__sort_merge_blocks_aux: { \exp_after:wN \sort_compare:nn \exp_after:wN - { \tex_the:D \tex_toks:D \exp_after:wN \l_sort_A_int \exp_after:wN } - \exp_after:wN { \tex_the:D \tex_toks:D \l_sort_C_int } + { \tex_the:D \tex_toks:D \exp_after:wN \l__sort_A_int \exp_after:wN } + \exp_after:wN { \tex_the:D \tex_toks:D \l__sort_C_int } } \cs_new_protected_nopar:Npn \sort_ordered: { - \tex_toks:D \l_sort_B_int \tex_toks:D \l_sort_C_int - \tex_advance:D \l_sort_B_int \c_minus_one - \tex_advance:D \l_sort_C_int \c_minus_one - \if_num:w \l_sort_C_int < \l_sort_length_int + \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int + \tex_advance:D \l__sort_B_int \c_minus_one + \tex_advance:D \l__sort_C_int \c_minus_one + \if_int_compare:w \l__sort_C_int < \l__sort_length_int \use_i:nn \fi: - \sort_merge_blocks_aux: + \__sort_merge_blocks_aux: } \cs_new_protected_nopar:Npn \sort_reversed: { - \tex_toks:D \l_sort_B_int \tex_toks:D \l_sort_A_int - \tex_advance:D \l_sort_B_int \c_minus_one - \tex_advance:D \l_sort_A_int \c_minus_one - \if_num:w \l_sort_A_int < \l_sort_begin_int - \sort_merge_blocks_end: \use_i:nn + \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_A_int + \tex_advance:D \l__sort_B_int \c_minus_one + \tex_advance:D \l__sort_A_int \c_minus_one + \if_int_compare:w \l__sort_A_int < \l__sort_begin_int + \__sort_merge_blocks_end: \use_i:nn \fi: - \sort_merge_blocks_aux: + \__sort_merge_blocks_aux: } -\cs_new_protected_nopar:Npn \sort_merge_blocks_end: +\cs_new_protected_nopar:Npn \__sort_merge_blocks_end: { - \tex_toks:D \l_sort_B_int \tex_toks:D \l_sort_C_int - \tex_advance:D \l_sort_B_int \c_minus_one - \tex_advance:D \l_sort_C_int \c_minus_one - \if_num:w \l_sort_B_int < \l_sort_begin_int + \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int + \tex_advance:D \l__sort_B_int \c_minus_one + \tex_advance:D \l__sort_C_int \c_minus_one + \if_int_compare:w \l__sort_B_int < \l__sort_begin_int \use_i:nn \fi: - \sort_merge_blocks_end: + \__sort_merge_blocks_end: } -\cs_new_protected:Npn \sort_too_long_error:Nw #1 \fi: +\cs_new_protected:Npn \__sort_too_long_error:NNw #1#2 \fi: { \fi: - \msg_kernel_error:nnx { sort } { too-large } { \token_to_str:N #1 } - \prg_map_break: + \__msg_kernel_error:nnx { sort } { too-large } { \token_to_str:N #2 } + #1 } -\msg_kernel_new:nnnn { sort } { too-large } +\__msg_kernel_new:nnnn { sort } { too-large } { The~list~#1~is~too~long~to~be~sorted~by~TeX. } { - TeX~has~\int_use:N \c_max_register_int \ registers~available:~ - this~only~allows~to~sorts~with~up~to~\int_use:N \c_sort_max_length_int + TeX~has~\int_eval:n { \c_max_register_int + 1 }~registers~available:~ + this~only~allows~to~sorts~with~up~to~\int_use:N \c__sort_max_length_int \ items.~All~extra~items~will~be~ignored. } %% diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3flag.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3flag.sty index b56100853ab..63970cdd45d 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3flag.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3flag.sty @@ -47,59 +47,59 @@ %% ----------------------------------------------------------------------- \RequirePackage{expl3} \GetIdInfo$Id: l3flag.dtx 3039 2011-12-08 09:22:35Z bruno $ - {L3 Experimental Flags} + {L3 Experimental flags} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \cs_new_protected:Npn \flag_new:n #1 { - \cs_new:cpn { flag_trap_#1:w } ##1 ; - { \exp_after:wN \use_none:n \cs:w l_#1_##1_flag \cs_end: } + \cs_new:cpn { __flag_trap_#1:w } ##1 ; + { \exp_after:wN \use_none:n \cs:w __flag_#1_##1: \cs_end: } } \cs_new_protected:Npn \flag_clear:n #1 - { \flag_clear_aux:ww 0 ; #1 \q_stop } -\cs_new_protected:Npn \flag_clear_aux:ww #1 ; #2 \q_stop + { \__flag_clear:ww 0 ; #1 \q_stop } +\cs_new_protected:Npn \__flag_clear:ww #1 ; #2 \q_stop { - \if_cs_exist:w l_#2_#1_flag \cs_end: + \if_cs_exist:w __flag_#2_#1: \cs_end: \else: \exp_after:wN \use_none_delimit_by_q_stop:w \fi: - \cs_set_eq:cN { l_#2_#1_flag } \c_undefined:D - \exp_after:wN \flag_clear_aux:ww - \int_use:N \int_eval:w \c_one + #1 ; + \cs_set_eq:cN { __flag_#2_#1: } \c_undefined:D + \exp_after:wN \__flag_clear:ww + \int_use:N \__int_eval:w \c_one + #1 ; #2 \q_stop } \cs_new_protected:Npn \flag_clear_new:n #1 { \flag_if_exist:nTF {#1} { \flag_clear:n } { \flag_new:n } {#1} } \cs_new_protected:Npn \flag_set_trap:nn #1#2 - { \cs_set:cpn { flag_trap_#1:w } ##1 ; {#2} } + { \cs_set:cpn { __flag_trap_#1:w } ##1 ; {#2} } \prg_new_conditional:Npnn \flag_if_exist:n #1 { p , T , F , TF } { - \cs_if_exist:cTF { flag_trap_#1:w } + \cs_if_exist:cTF { __flag_trap_#1:w } { \prg_return_true: } { \prg_return_false: } } \prg_new_conditional:Npnn \flag_if_raised:n #1 { p , T , F , TF } { - \if_cs_exist:w l_#1_0_flag \cs_end: + \if_cs_exist:w __flag_#1_0: \cs_end: \prg_return_true: \else: \prg_return_false: \fi: } -\cs_new:Npn \flag_height:n #1 { \flag_height_loop:ww 0; #1 \q_stop } -\cs_new:Npn \flag_height_loop:ww #1 ; #2 \q_stop +\cs_new:Npn \flag_height:n #1 { \__flag_height_loop:ww 0; #1 \q_stop } +\cs_new:Npn \__flag_height_loop:ww #1 ; #2 \q_stop { - \if_cs_exist:w l_#2_#1_flag \cs_end: - \exp_after:wN \flag_height_loop:ww \int_use:N \int_eval:w \c_one + + \if_cs_exist:w __flag_#2_#1: \cs_end: + \exp_after:wN \__flag_height_loop:ww \int_use:N \__int_eval:w \c_one + \else: - \exp_after:wN \flag_height_end:ww + \exp_after:wN \__flag_height_end:ww \fi: #1 ; #2 \q_stop } -\cs_new:Npn \flag_height_end:ww #1 ; #2 \q_stop { #1 } +\cs_new:Npn \__flag_height_end:ww #1 ; #2 \q_stop { #1 } \cs_new:Npn \flag_raise:n #1 { - \cs:w flag_trap_#1:w \exp_after:wN \cs_end: - \int_value:w \flag_height:n {#1} ; + \cs:w __flag_trap_#1:w \exp_after:wN \cs_end: + \__int_value:w \flag_height:n {#1} ; } %% %% diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty index 0208088744a..7b31ebc4613 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty @@ -46,448 +46,448 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{expl3} -\GetIdInfo$Id: l3regex.dtx 3488 2012-03-03 19:49:03Z bruno $ - {L3 Experimental Regular Expressions} +\GetIdInfo$Id: l3regex.dtx 3940 2012-07-09 00:41:44Z bruno $ + {L3 Experimental regular expressions} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{l3tl-build, l3tl-analysis, l3flag, l3str} \cs_generate_variant:Nn \tl_to_str:n { V } -\cs_new:Npn \regex_tmp:w { } -\tl_new:N \l_regex_internal_a_tl -\tl_new:N \l_regex_internal_b_tl -\int_new:N \l_regex_internal_a_int -\int_new:N \l_regex_internal_b_int -\int_new:N \l_regex_internal_c_int -\bool_new:N \l_regex_internal_bool -\seq_new:N \l_regex_internal_seq -\tl_new:N \g_regex_internal_tl -\tl_const:Nn \c_regex_no_match_regex - { - \regex_branch:n - { \regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } - } -\int_new:N \l_regex_balance_int -\cs_new_protected:Npn \regex_break_true:w - #1 \regex_break_point:TF #2 #3 {#2} -\cs_new_protected:Npn \regex_break_point:TF #1 #2 { #2 } -\cs_new_protected:Npn \regex_item_reverse:n #1 +\cs_new:Npn \__regex_tmp:w { } +\tl_new:N \l__regex_internal_a_tl +\tl_new:N \l__regex_internal_b_tl +\int_new:N \l__regex_internal_a_int +\int_new:N \l__regex_internal_b_int +\int_new:N \l__regex_internal_c_int +\bool_new:N \l__regex_internal_bool +\seq_new:N \l__regex_internal_seq +\tl_new:N \g__regex_internal_tl +\tl_const:Nn \c__regex_no_match_regex + { + \__regex_branch:n + { \__regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } + } +\int_new:N \l__regex_balance_int +\cs_new_protected:Npn \__regex_break_true:w + #1 \__regex_break_point:TF #2 #3 {#2} +\cs_new_protected:Npn \__regex_break_point:TF #1 #2 { #2 } +\cs_new_protected:Npn \__regex_item_reverse:n #1 { #1 - \regex_break_point:TF { } \regex_break_true:w + \__regex_break_point:TF { } \__regex_break_true:w } -\cs_new_protected:Npn \regex_item_caseful_equal:n #1 +\cs_new_protected:Npn \__regex_item_caseful_equal:n #1 { - \if_num:w #1 = \l_regex_current_char_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_char_int + \exp_after:wN \__regex_break_true:w \fi: } -\cs_new_protected:Npn \regex_item_caseful_range:nn #1 #2 +\cs_new_protected:Npn \__regex_item_caseful_range:nn #1 #2 { - \reverse_if:N \if_num:w #1 > \l_regex_current_char_int - \reverse_if:N \if_num:w #2 < \l_regex_current_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \reverse_if:N \if_int_compare:w #1 > \l__regex_current_char_int + \reverse_if:N \if_int_compare:w #2 < \l__regex_current_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: } -\cs_new_protected:Npn \regex_item_caseless_equal:n #1 +\cs_new_protected:Npn \__regex_item_caseless_equal:n #1 { - \if_num:w #1 = \l_regex_current_char_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_char_int + \exp_after:wN \__regex_break_true:w \fi: - \if_num:w \l_regex_case_changed_char_int = \c_max_int - \regex_compute_case_changed_char: + \if_int_compare:w \l__regex_case_changed_char_int = \c_max_int + \__regex_compute_case_changed_char: \fi: - \if_num:w #1 = \l_regex_case_changed_char_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_case_changed_char_int + \exp_after:wN \__regex_break_true:w \fi: } -\cs_new_protected:Npn \regex_item_caseless_range:nn #1 #2 +\cs_new_protected:Npn \__regex_item_caseless_range:nn #1 #2 { - \reverse_if:N \if_num:w #1 > \l_regex_current_char_int - \reverse_if:N \if_num:w #2 < \l_regex_current_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \reverse_if:N \if_int_compare:w #1 > \l__regex_current_char_int + \reverse_if:N \if_int_compare:w #2 < \l__regex_current_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: - \if_num:w \l_regex_case_changed_char_int = \c_max_int - \regex_compute_case_changed_char: + \if_int_compare:w \l__regex_case_changed_char_int = \c_max_int + \__regex_compute_case_changed_char: \fi: - \reverse_if:N \if_num:w #1 > \l_regex_case_changed_char_int - \reverse_if:N \if_num:w #2 < \l_regex_case_changed_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \reverse_if:N \if_int_compare:w #1 > \l__regex_case_changed_char_int + \reverse_if:N \if_int_compare:w #2 < \l__regex_case_changed_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: } -\cs_new_protected_nopar:Npn \regex_compute_case_changed_char: +\cs_new_protected_nopar:Npn \__regex_compute_case_changed_char: { - \int_set_eq:NN \l_regex_case_changed_char_int \l_regex_current_char_int - \if_num:w \l_regex_current_char_int < \c_ninety_one - \if_num:w \l_regex_current_char_int < \c_sixty_five + \int_set_eq:NN \l__regex_case_changed_char_int \l__regex_current_char_int + \if_int_compare:w \l__regex_current_char_int < \c_ninety_one + \if_int_compare:w \l__regex_current_char_int < \c_sixty_five \else: - \int_add:Nn \l_regex_case_changed_char_int { \c_thirty_two } + \int_add:Nn \l__regex_case_changed_char_int { \c_thirty_two } \fi: \else: - \if_num:w \l_regex_current_char_int < \c_one_hundred_twenty_three - \if_num:w \l_regex_current_char_int < \c_ninety_seven + \if_int_compare:w \l__regex_current_char_int < \c_one_hundred_twenty_three + \if_int_compare:w \l__regex_current_char_int < \c_ninety_seven \else: - \int_sub:Nn \l_regex_case_changed_char_int { \c_thirty_two } + \int_sub:Nn \l__regex_case_changed_char_int { \c_thirty_two } \fi: \fi: \fi: } -\cs_new_eq:NN \regex_item_equal:n ? -\cs_new_eq:NN \regex_item_range:nn ? -\cs_new_protected:Npn \regex_item_catcode_aux: +\cs_new_eq:NN \__regex_item_equal:n ? +\cs_new_eq:NN \__regex_item_range:nn ? +\cs_new_protected:Npn \__regex_item_catcode: { " - \if_case:w \l_regex_current_catcode_int + \if_case:w \l__regex_current_catcode_int 1 \or: 4 \or: 10 \or: 40 \or: 100 \or: \or: 1000 \or: 4000 \or: 10000 \or: \or: 100000 \or: 400000 \or: 1000000 \or: 4000000 \else: 1*\c_zero \fi: } -\cs_new_protected:Npn \regex_item_catcode:nT #1 +\cs_new_protected:Npn \__regex_item_catcode:nT #1 { - \if_int_odd:w \int_eval:w #1 / \regex_item_catcode_aux: \int_eval_end: + \if_int_odd:w \__int_eval:w #1 / \__regex_item_catcode: \__int_eval_end: \exp_after:wN \use:n \else: \exp_after:wN \use_none:n \fi: } -\cs_new_protected:Npn \regex_item_catcode_reverse:nT #1#2 - { \regex_item_catcode:nT {#1} { \regex_item_reverse:n {#2} } } -\cs_new_protected:Npn \regex_item_exact:nn #1#2 +\cs_new_protected:Npn \__regex_item_catcode_reverse:nT #1#2 + { \__regex_item_catcode:nT {#1} { \__regex_item_reverse:n {#2} } } +\cs_new_protected:Npn \__regex_item_exact:nn #1#2 { - \if_num:w #1 = \l_regex_current_catcode_int - \if_num:w #2 = \l_regex_current_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_catcode_int + \if_int_compare:w #2 = \l__regex_current_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: } -\cs_new_protected:Npn \regex_item_exact_cs:c #1 +\cs_new_protected:Npn \__regex_item_exact_cs:c #1 { - \int_compare:nNnTF \l_regex_current_catcode_int = \c_zero + \int_compare:nNnTF \l__regex_current_catcode_int = \c_zero { - \str_if_eq:xxTF + \str_if_eq_x:nnTF { \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l_regex_current_pos_int + \tex_the:D \tex_toks:D \l__regex_current_pos_int } { #1 } - { \regex_break_true:w } { } + { \__regex_break_true:w } { } } { } } -\cs_new_protected:Npn \regex_item_cs:n #1 +\cs_new_protected:Npn \__regex_item_cs:n #1 { - \int_compare:nNnT \l_regex_current_catcode_int = \c_zero + \int_compare:nNnT \l__regex_current_catcode_int = \c_zero { \group_begin: - \regex_single_match: - \regex_disable_submatches: - \regex_build_for_cs:n {#1} - \bool_set_eq:NN \l_regex_saved_success_bool \g_regex_success_bool - \exp_args:Nx \regex_match:n + \__regex_single_match: + \__regex_disable_submatches: + \__regex_build_for_cs:n {#1} + \bool_set_eq:NN \l__regex_saved_success_bool \g__regex_success_bool + \exp_args:Nx \__regex_match:n { \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l_regex_current_pos_int + \tex_the:D \tex_toks:D \l__regex_current_pos_int } - \if_meaning:w \c_true_bool \g_regex_success_bool - \group_insert_after:N \regex_break_true:w + \if_meaning:w \c_true_bool \g__regex_success_bool + \group_insert_after:N \__regex_break_true:w \fi: - \bool_gset_eq:NN \g_regex_success_bool \l_regex_saved_success_bool + \bool_gset_eq:NN \g__regex_success_bool \l__regex_saved_success_bool \group_end: } } -\cs_new_protected_nopar:Npn \regex_prop_d: - { \regex_item_caseful_range:nn \c_forty_eight { 57 } } % 0--9 -\cs_new_protected_nopar:Npn \regex_prop_h: - { - \regex_item_caseful_equal:n \c_thirty_two % space - \regex_item_caseful_equal:n \c_nine % tab - } -\cs_new_protected_nopar:Npn \regex_prop_s: - { - \regex_item_caseful_equal:n \c_thirty_two % space - \regex_item_caseful_equal:n \c_nine % tab - \regex_item_caseful_equal:n \c_ten % lf - \regex_item_caseful_equal:n \c_twelve % ff - \regex_item_caseful_equal:n \c_thirteen % cr - } -\cs_new_protected_nopar:Npn \regex_prop_v: - { \regex_item_caseful_range:nn \c_ten \c_thirteen } % lf, vtab, ff, cr -\cs_new_protected_nopar:Npn \regex_prop_w: - { - \regex_item_caseful_range:nn \c_ninety_seven { 122 } % a--z - \regex_item_caseful_range:nn \c_sixty_five { 90 } % A--Z - \regex_item_caseful_range:nn \c_forty_eight { 57 } % 0--9 - \regex_item_caseful_equal:n { 95 } % _ - } -\cs_new_protected_nopar:Npn \regex_prop_N: - { \regex_item_reverse:n { \regex_item_caseful_equal:n \c_ten } } -\cs_new_protected_nopar:Npn \regex_posix_alnum: - { \regex_posix_alpha: \regex_posix_digit: } -\cs_new_protected_nopar:Npn \regex_posix_alpha: - { \regex_posix_lower: \regex_posix_upper: } -\cs_new_protected_nopar:Npn \regex_posix_ascii: - { \regex_item_caseful_range:nn \c_zero \c_one_hundred_twenty_seven } -\cs_new_eq:NN \regex_posix_blank: \regex_prop_h: -\cs_new_protected_nopar:Npn \regex_posix_cntrl: - { - \regex_item_caseful_range:nn \c_zero { 31 } - \regex_item_caseful_equal:n \c_one_hundred_twenty_seven - } -\cs_new_eq:NN \regex_posix_digit: \regex_prop_d: -\cs_new_protected_nopar:Npn \regex_posix_graph: - { \regex_item_caseful_range:nn { 33 } { 126 } } -\cs_new_protected_nopar:Npn \regex_posix_lower: - { \regex_item_caseful_range:nn \c_ninety_seven { 122 } } -\cs_new_protected_nopar:Npn \regex_posix_print: - { \regex_item_caseful_range:nn \c_thirty_two { 126 } } -\cs_new_protected_nopar:Npn \regex_posix_punct: - { - \regex_item_caseful_range:nn { 33 } { 47 } - \regex_item_caseful_range:nn { 58 } { 64 } - \regex_item_caseful_range:nn { 91 } { 96 } - \regex_item_caseful_range:nn { 123 } { 126 } - } -\cs_new_protected_nopar:Npn \regex_posix_space: - { - \regex_item_caseful_equal:n \c_thirty_two - \regex_item_caseful_range:nn \c_nine \c_thirteen - } -\cs_new_protected_nopar:Npn \regex_posix_upper: - { \regex_item_caseful_range:nn \c_sixty_five { 90 } } -\cs_new_eq:NN \regex_posix_word: \regex_prop_w: -\cs_new_protected_nopar:Npn \regex_posix_xdigit: - { - \regex_posix_digit: - \regex_item_caseful_range:nn \c_sixty_five { 70 } - \regex_item_caseful_range:nn \c_ninety_seven { 102 } - } -\cs_new_protected:Npn \regex_escape_use:nnnn #1#2#3#4 - { - \trace_push:nnn { regex } { 1 } { regex_escape_use:nnnn } - \tl_set_build:Nw \l_regex_internal_a_tl - \cs_set_nopar:Npn \regex_escape_unescaped:N ##1 { #1 } - \cs_set_nopar:Npn \regex_escape_escaped:N ##1 { #2 } - \cs_set_nopar:Npn \regex_escape_raw:N ##1 { #3 } +\cs_new_protected_nopar:Npn \__regex_prop_d: + { \__regex_item_caseful_range:nn \c_forty_eight { 57 } } % 0--9 +\cs_new_protected_nopar:Npn \__regex_prop_h: + { + \__regex_item_caseful_equal:n \c_thirty_two % space + \__regex_item_caseful_equal:n \c_nine % tab + } +\cs_new_protected_nopar:Npn \__regex_prop_s: + { + \__regex_item_caseful_equal:n \c_thirty_two % space + \__regex_item_caseful_equal:n \c_nine % tab + \__regex_item_caseful_equal:n \c_ten % lf + \__regex_item_caseful_equal:n \c_twelve % ff + \__regex_item_caseful_equal:n \c_thirteen % cr + } +\cs_new_protected_nopar:Npn \__regex_prop_v: + { \__regex_item_caseful_range:nn \c_ten \c_thirteen } % lf, vtab, ff, cr +\cs_new_protected_nopar:Npn \__regex_prop_w: + { + \__regex_item_caseful_range:nn \c_ninety_seven { 122 } % a--z + \__regex_item_caseful_range:nn \c_sixty_five { 90 } % A--Z + \__regex_item_caseful_range:nn \c_forty_eight { 57 } % 0--9 + \__regex_item_caseful_equal:n { 95 } % _ + } +\cs_new_protected_nopar:Npn \__regex_prop_N: + { \__regex_item_reverse:n { \__regex_item_caseful_equal:n \c_ten } } +\cs_new_protected_nopar:Npn \__regex_posix_alnum: + { \__regex_posix_alpha: \__regex_posix_digit: } +\cs_new_protected_nopar:Npn \__regex_posix_alpha: + { \__regex_posix_lower: \__regex_posix_upper: } +\cs_new_protected_nopar:Npn \__regex_posix_ascii: + { \__regex_item_caseful_range:nn \c_zero \c_one_hundred_twenty_seven } +\cs_new_eq:NN \__regex_posix_blank: \__regex_prop_h: +\cs_new_protected_nopar:Npn \__regex_posix_cntrl: + { + \__regex_item_caseful_range:nn \c_zero { 31 } + \__regex_item_caseful_equal:n \c_one_hundred_twenty_seven + } +\cs_new_eq:NN \__regex_posix_digit: \__regex_prop_d: +\cs_new_protected_nopar:Npn \__regex_posix_graph: + { \__regex_item_caseful_range:nn { 33 } { 126 } } +\cs_new_protected_nopar:Npn \__regex_posix_lower: + { \__regex_item_caseful_range:nn \c_ninety_seven { 122 } } +\cs_new_protected_nopar:Npn \__regex_posix_print: + { \__regex_item_caseful_range:nn \c_thirty_two { 126 } } +\cs_new_protected_nopar:Npn \__regex_posix_punct: + { + \__regex_item_caseful_range:nn { 33 } { 47 } + \__regex_item_caseful_range:nn { 58 } { 64 } + \__regex_item_caseful_range:nn { 91 } { 96 } + \__regex_item_caseful_range:nn { 123 } { 126 } + } +\cs_new_protected_nopar:Npn \__regex_posix_space: + { + \__regex_item_caseful_equal:n \c_thirty_two + \__regex_item_caseful_range:nn \c_nine \c_thirteen + } +\cs_new_protected_nopar:Npn \__regex_posix_upper: + { \__regex_item_caseful_range:nn \c_sixty_five { 90 } } +\cs_new_eq:NN \__regex_posix_word: \__regex_prop_w: +\cs_new_protected_nopar:Npn \__regex_posix_xdigit: + { + \__regex_posix_digit: + \__regex_item_caseful_range:nn \c_sixty_five { 70 } + \__regex_item_caseful_range:nn \c_ninety_seven { 102 } + } +\cs_new_protected:Npn \__regex_escape_use:nnnn #1#2#3#4 + { + \trace_push:nnn { regex } { 1 } { @@_escape_use:nnnn } + \__tl_build:Nw \l__regex_internal_a_tl + \cs_set_nopar:Npn \__regex_escape_unescaped:N ##1 { #1 } + \cs_set_nopar:Npn \__regex_escape_escaped:N ##1 { #2 } + \cs_set_nopar:Npn \__regex_escape_raw:N ##1 { #3 } \int_set:Nn \tex_escapechar:D { 92 } - \str_gset_other:Nn \g_regex_internal_tl { #4 } - \tl_set:Nx \l_regex_internal_b_tl + \__str_gset_other:Nn \g__regex_internal_tl { #4 } + \tl_set:Nx \l__regex_internal_b_tl { - \exp_after:wN \regex_escape_loop:N \g_regex_internal_tl - { break } \prg_break_point:n { } + \exp_after:wN \__regex_escape_loop:N \g__regex_internal_tl + { break } \__prg_break_point: } - \tl_build_one:o \l_regex_internal_b_tl - \tl_build_end: - \trace_pop:nnn { regex } { 1 } { regex_escape_use:nnnn } - \l_regex_internal_a_tl + \__tl_build_one:o \l__regex_internal_b_tl + \__tl_build_end: + \trace_pop:nnn { regex } { 1 } { @@_escape_use:nnnn } + \l__regex_internal_a_tl } -\cs_new:Npn \regex_escape_loop:N #1 +\cs_new:Npn \__regex_escape_loop:N #1 { - \cs_if_exist_use:cF { regex_escape_\token_to_str:N #1:w } - { \regex_escape_unescaped:N #1 } - \regex_escape_loop:N + \cs_if_exist_use:cF { __regex_escape_\token_to_str:N #1:w } + { \__regex_escape_unescaped:N #1 } + \__regex_escape_loop:N } -\cs_new_nopar:cpn { regex_escape_ \c_backslash_str :w } - \regex_escape_loop:N #1 +\cs_new_nopar:cpn { __regex_escape_ \c_backslash_str :w } + \__regex_escape_loop:N #1 { - \cs_if_exist_use:cF { regex_escape_/\token_to_str:N #1:w } - { \regex_escape_escaped:N #1 } - \regex_escape_loop:N + \cs_if_exist_use:cF { __regex_escape_/\token_to_str:N #1:w } + { \__regex_escape_escaped:N #1 } + \__regex_escape_loop:N } -\cs_new_eq:NN \regex_escape_unescaped:N ? -\cs_new_eq:NN \regex_escape_escaped:N ? -\cs_new_eq:NN \regex_escape_raw:N ? -\cs_new_eq:NN \regex_escape_break:w \prg_map_break: -\cs_new_nopar:cpn { regex_escape_/break:w } +\cs_new_eq:NN \__regex_escape_unescaped:N ? +\cs_new_eq:NN \__regex_escape_escaped:N ? +\cs_new_eq:NN \__regex_escape_raw:N ? +\cs_new_eq:NN \__regex_escape_break:w \__prg_break: +\cs_new_nopar:cpn { __regex_escape_/break:w } { \if_false: { \fi: } - \msg_kernel_error:nn { regex } { trailing-backslash } + \__msg_kernel_error:nn { regex } { trailing-backslash } \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi: } -\cs_new_nopar:cpn { regex_escape_~:w } { } -\cs_new_nopar:cpx { regex_escape_/a:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^G } -\cs_new_nopar:cpx { regex_escape_/t:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^I } -\cs_new_nopar:cpx { regex_escape_/n:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^J } -\cs_new_nopar:cpx { regex_escape_/f:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^L } -\cs_new_nopar:cpx { regex_escape_/r:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^M } -\cs_new_nopar:cpx { regex_escape_/e:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^[ } -\cs_new:cpn { regex_escape_/x:w } \regex_escape_loop:N - { - \exp_after:wN \regex_escape_x_end:w - \int_value:w "0 \regex_escape_x_test:N - } -\cs_new:Npn \regex_escape_x_end:w #1 ; +\cs_new_nopar:cpn { __regex_escape_~:w } { } +\cs_new_nopar:cpx { __regex_escape_/a:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^G } +\cs_new_nopar:cpx { __regex_escape_/t:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^I } +\cs_new_nopar:cpx { __regex_escape_/n:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^J } +\cs_new_nopar:cpx { __regex_escape_/f:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^L } +\cs_new_nopar:cpx { __regex_escape_/r:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^M } +\cs_new_nopar:cpx { __regex_escape_/e:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^[ } +\cs_new:cpn { __regex_escape_/x:w } \__regex_escape_loop:N + { + \exp_after:wN \__regex_escape_x_end:w + \__int_value:w "0 \__regex_escape_x_test:N + } +\cs_new:Npn \__regex_escape_x_end:w #1 ; { \int_compare:nNnTF {#1} < \c_two_hundred_fifty_six { - \exp_last_unbraced:Nf \regex_escape_raw:N - { \str_output_byte:n {#1} } + \exp_last_unbraced:Nf \__regex_escape_raw:N + { \__str_output_byte:n {#1} } } - { \regex_escape_x_large:n {#1} } + { \__regex_escape_x_large:n {#1} } } \group_begin: \char_set_catcode_other:n { 0 } - \cs_new:Npn \regex_escape_x_large:n #1 + \cs_new:Npn \__regex_escape_x_large:n #1 { \if_false: { \fi: } - \tl_build_one:o \l_regex_internal_b_tl + \__tl_build_one:o \l__regex_internal_b_tl \int_compare:nNnTF {#1} > \c_max_char_int { - \msg_kernel_error:nnx { regex } { x-overflow } {#1} - \tl_set:Nx \l_regex_internal_b_tl - { \if_false: } \fi: \regex_escape_loop:N + \__msg_kernel_error:nnx { regex } { x-overflow } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: \__regex_escape_loop:N } { \char_set_lccode:nn { \c_zero } {#1} \tl_to_lowercase:n { - \tl_set:Nx \l_regex_internal_b_tl + \tl_set:Nx \l__regex_internal_b_tl { \if_false: } \fi: - \regex_escape_raw:N ^^@ - \regex_escape_loop:N + \__regex_escape_raw:N ^^@ + \__regex_escape_loop:N } } } \group_end: -\cs_new:Npn \regex_escape_x_test:N #1 +\cs_new:Npn \__regex_escape_x_test:N #1 { - \str_if_eq:xxTF {#1} { break } { ; } + \str_if_eq_x:nnTF {#1} { break } { ; } { \if_charcode:w \c_space_token #1 - \exp_after:wN \regex_escape_x_test:N + \exp_after:wN \__regex_escape_x_test:N \else: - \exp_after:wN \regex_escape_x_test_ii:N + \exp_after:wN \__regex_escape_x_test_ii:N \exp_after:wN #1 \fi: } } -\cs_new:Npn \regex_escape_x_test_ii:N #1 +\cs_new:Npn \__regex_escape_x_test_ii:N #1 { \if_charcode:w \c_lbrace_str #1 - \exp_after:wN \regex_escape_x_loop:N + \exp_after:wN \__regex_escape_x_loop:N \else: - \str_aux_hexadecimal_use:NTF #1 - { \exp_after:wN \regex_escape_x_ii:N } - { ; \exp_after:wN \regex_escape_loop:N \exp_after:wN #1 } + \__str_hexadecimal_use:NTF #1 + { \exp_after:wN \__regex_escape_x_ii:N } + { ; \exp_after:wN \__regex_escape_loop:N \exp_after:wN #1 } \fi: } -\cs_new:Npn \regex_escape_x_ii:N #1 +\cs_new:Npn \__regex_escape_x_ii:N #1 { - \str_if_eq:xxTF {#1} { break } { ; } + \str_if_eq_x:nnTF {#1} { break } { ; } { - \str_aux_hexadecimal_use:NTF #1 - { ; \regex_escape_loop:N } - { ; \regex_escape_loop:N #1 } + \__str_hexadecimal_use:NTF #1 + { ; \__regex_escape_loop:N } + { ; \__regex_escape_loop:N #1 } } } -\cs_new:Npn \regex_escape_x_loop:N #1 +\cs_new:Npn \__regex_escape_x_loop:N #1 { - \str_aux_hexadecimal_use:NTF #1 - { \regex_escape_x_loop:N } + \__str_hexadecimal_use:NTF #1 + { \__regex_escape_x_loop:N } { \token_if_eq_charcode:NNTF \c_space_token #1 - { \regex_escape_x_loop:N } + { \__regex_escape_x_loop:N } { ; \exp_after:wN \token_if_eq_charcode:NNTF \c_rbrace_str #1 - { \regex_escape_loop:N } + { \__regex_escape_loop:N } { \if_false: { \fi: } - \tl_build_one:o \l_regex_internal_b_tl - \msg_kernel_error:nn { regex } { x-missing-rbrace } {#1} - \tl_set:Nx \l_regex_internal_b_tl - { \if_false: } \fi: \regex_escape_loop:N #1 + \__tl_build_one:o \l__regex_internal_b_tl + \__msg_kernel_error:nn { regex } { x-missing-rbrace } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: \__regex_escape_loop:N #1 } } } } -\prg_new_conditional:Npnn \regex_char_if_special:N #1 { TF } +\prg_new_conditional:Npnn \__regex_char_if_special:N #1 { TF } { - \if_num:w `#1 < \c_ninety_one - \if_num:w `#1 < \c_fifty_eight - \if_num:w `#1 < \c_forty_eight - \if_num:w `#1 < \c_thirty_two + \if_int_compare:w `#1 < \c_ninety_one + \if_int_compare:w `#1 < \c_fifty_eight + \if_int_compare:w `#1 < \c_forty_eight + \if_int_compare:w `#1 < \c_thirty_two \prg_return_false: \else: \prg_return_true: \fi: \else: \prg_return_false: \fi: \else: - \if_num:w `#1 < \c_sixty_five + \if_int_compare:w `#1 < \c_sixty_five \prg_return_true: \else: \prg_return_false: \fi: \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_three - \if_num:w `#1 < \c_ninety_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_three + \if_int_compare:w `#1 < \c_ninety_seven \prg_return_true: \else: \prg_return_false: \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_seven \prg_return_true: \else: \prg_return_false: \fi: \fi: \fi: } -\prg_new_conditional:Npnn \regex_char_if_alphanumeric:N #1 { TF } +\prg_new_conditional:Npnn \__regex_char_if_alphanumeric:N #1 { TF } { - \if_num:w `#1 < \c_ninety_one - \if_num:w `#1 < \c_fifty_eight - \if_num:w `#1 < \c_forty_eight + \if_int_compare:w `#1 < \c_ninety_one + \if_int_compare:w `#1 < \c_fifty_eight + \if_int_compare:w `#1 < \c_forty_eight \prg_return_false: \else: \prg_return_true: \fi: \else: - \if_num:w `#1 < \c_sixty_five + \if_int_compare:w `#1 < \c_sixty_five \prg_return_false: \else: \prg_return_true: \fi: \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_three - \if_num:w `#1 < \c_ninety_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_three + \if_int_compare:w `#1 < \c_ninety_seven \prg_return_false: \else: \prg_return_true: \fi: \else: \prg_return_false: \fi: \fi: } -\int_new:N \l_regex_group_level_int -\int_new:N \l_regex_mode_int -\int_new:N \l_regex_catcodes_int -\int_new:N \l_regex_default_catcodes_int -\bool_new:N \l_regex_catcodes_bool -\int_const:Nn \c_regex_catcode_C_int { "1 } -\int_const:Nn \c_regex_catcode_B_int { "4 } -\int_const:Nn \c_regex_catcode_E_int { "10 } -\int_const:Nn \c_regex_catcode_M_int { "40 } -\int_const:Nn \c_regex_catcode_T_int { "100 } -\int_const:Nn \c_regex_catcode_P_int { "1000 } -\int_const:Nn \c_regex_catcode_U_int { "4000 } -\int_const:Nn \c_regex_catcode_D_int { "10000 } -\int_const:Nn \c_regex_catcode_S_int { "100000 } -\int_const:Nn \c_regex_catcode_L_int { "400000 } -\int_const:Nn \c_regex_catcode_O_int { "1000000 } -\int_const:Nn \c_regex_catcode_A_int { "4000000 } -\int_const:Nn \c_regex_all_catcodes_int { "5515155 } -\cs_new_eq:NN \l_regex_internal_regex \c_regex_no_match_regex -\seq_new:N \l_regex_show_prefix_seq -\int_new:N \l_regex_show_lines_int -\cs_new_protected:Npn \regex_get_digits:NTFw #1#2#3#4#5 - { - \regex_if_raw_digit:NNTF #4 #5 - { #1 = #5 \regex_get_digits_loop:nw {#2} } +\int_new:N \l__regex_group_level_int +\int_new:N \l__regex_mode_int +\int_new:N \l__regex_catcodes_int +\int_new:N \l__regex_default_catcodes_int +\bool_new:N \l__regex_catcodes_bool +\int_const:Nn \c__regex_catcode_C_int { "1 } +\int_const:Nn \c__regex_catcode_B_int { "4 } +\int_const:Nn \c__regex_catcode_E_int { "10 } +\int_const:Nn \c__regex_catcode_M_int { "40 } +\int_const:Nn \c__regex_catcode_T_int { "100 } +\int_const:Nn \c__regex_catcode_P_int { "1000 } +\int_const:Nn \c__regex_catcode_U_int { "4000 } +\int_const:Nn \c__regex_catcode_D_int { "10000 } +\int_const:Nn \c__regex_catcode_S_int { "100000 } +\int_const:Nn \c__regex_catcode_L_int { "400000 } +\int_const:Nn \c__regex_catcode_O_int { "1000000 } +\int_const:Nn \c__regex_catcode_A_int { "4000000 } +\int_const:Nn \c__regex_all_catcodes_int { "5515155 } +\cs_new_eq:NN \l__regex_internal_regex \c__regex_no_match_regex +\seq_new:N \l__regex_show_prefix_seq +\int_new:N \l__regex_show_lines_int +\cs_new_protected:Npn \__regex_get_digits:NTFw #1#2#3#4#5 + { + \__regex_if_raw_digit:NNTF #4 #5 + { #1 = #5 \__regex_get_digits_loop:nw {#2} } { #3 #4 #5 } } -\cs_new:Npn \regex_get_digits_loop:nw #1#2#3 +\cs_new:Npn \__regex_get_digits_loop:nw #1#2#3 { - \regex_if_raw_digit:NNTF #2 #3 - { #3 \regex_get_digits_loop:nw {#1} } + \__regex_if_raw_digit:NNTF #2 #3 + { #3 \__regex_get_digits_loop:nw {#1} } { \scan_stop: #1 #2 #3 } } -\prg_new_conditional:Npnn \regex_if_raw_digit:NN #1#2 { TF } +\prg_new_conditional:Npnn \__regex_if_raw_digit:NN #1#2 { TF } { - \if_meaning:w \regex_compile_raw:N #1 + \if_meaning:w \__regex_compile_raw:N #1 \if_int_compare:w \c_one < 1 #2 \exp_stop_f: \prg_return_true: \else: @@ -497,305 +497,305 @@ \prg_return_false: \fi: } -\cs_new_nopar:Npn \regex_if_in_class:TF +\cs_new_nopar:Npn \__regex_if_in_class:TF { - \if_int_odd:w \l_regex_mode_int + \if_int_odd:w \l__regex_mode_int \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: } -\cs_new_nopar:Npn \regex_if_in_cs:TF +\cs_new_nopar:Npn \__regex_if_in_cs:TF { - \if_int_odd:w \l_regex_mode_int + \if_int_odd:w \l__regex_mode_int \exp_after:wN \use_ii:nn \else: - \if_int_compare:w \l_regex_mode_int < \c_zero + \if_int_compare:w \l__regex_mode_int < \c_zero \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn \else: \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn \fi: \fi: } -\cs_new_nopar:Npn \regex_if_in_class_or_catcode:TF +\cs_new_nopar:Npn \__regex_if_in_class_or_catcode:TF { - \if_int_odd:w \l_regex_mode_int + \if_int_odd:w \l__regex_mode_int \exp_after:wN \use_i:nn \else: - \if_int_compare:w \l_regex_mode_int > \c_zero + \if_int_compare:w \l__regex_mode_int > \c_zero \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn \else: \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn \fi: \fi: } -\cs_new_nopar:Npn \regex_if_within_catcode:TF +\cs_new_nopar:Npn \__regex_if_within_catcode:TF { - \if_int_compare:w \l_regex_mode_int > \c_zero + \if_int_compare:w \l__regex_mode_int > \c_zero \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: } -\cs_new_protected:Npn \regex_chk_c_allowed:T +\cs_new_protected:Npn \__regex_chk_c_allowed:T { - \if_num:w \l_regex_mode_int = \c_zero + \if_int_compare:w \l__regex_mode_int = \c_zero \exp_after:wN \use:n \else: - \if_num:w \l_regex_mode_int = \c_three + \if_int_compare:w \l__regex_mode_int = \c_three \exp_after:wN \exp_after:wN \exp_after:wN \use:n \else: - \msg_kernel_error:nn { regex } { c-bad-mode } + \__msg_kernel_error:nn { regex } { c-bad-mode } \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n \fi: \fi: } -\cs_new_protected:Npn \regex_mode_quit_c: +\cs_new_protected:Npn \__regex_mode_quit_c: { - \if_num:w \l_regex_mode_int = \c_two - \l_regex_mode_int = \c_zero + \if_int_compare:w \l__regex_mode_int = \c_two + \l__regex_mode_int = \c_zero \else: - \if_num:w \l_regex_mode_int = \c_six - \l_regex_mode_int = \c_three + \if_int_compare:w \l__regex_mode_int = \c_six + \l__regex_mode_int = \c_three \fi: \fi: } -\cs_new_protected_nopar:Npn \regex_compile:w +\cs_new_protected_nopar:Npn \__regex_compile:w { - \tl_set_build_x:Nw \l_regex_internal_regex - \int_zero:N \l_regex_group_level_int - \int_set_eq:NN \l_regex_default_catcodes_int \c_regex_all_catcodes_int - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \cs_set_nopar:Npn \regex_item_equal:n { \regex_item_caseful_equal:n } - \cs_set_nopar:Npn \regex_item_range:nn { \regex_item_caseful_range:nn } - \tl_build_one:n { \regex_branch:n { \if_false: } \fi: } + \__tl_build_x:Nw \l__regex_internal_regex + \int_zero:N \l__regex_group_level_int + \int_set_eq:NN \l__regex_default_catcodes_int \c__regex_all_catcodes_int + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \cs_set_nopar:Npn \__regex_item_equal:n { \__regex_item_caseful_equal:n } + \cs_set_nopar:Npn \__regex_item_range:nn { \__regex_item_caseful_range:nn } + \__tl_build_one:n { \__regex_branch:n { \if_false: } \fi: } } -\cs_new_protected_nopar:Npn \regex_compile_end: +\cs_new_protected_nopar:Npn \__regex_compile_end: { - \regex_if_in_class:TF + \__regex_if_in_class:TF { - \msg_kernel_error:nn { regex } { missing-rbrack } - \use:c { regex_compile_]: } + \__msg_kernel_error:nn { regex } { missing-rbrack } + \use:c { __regex_compile_]: } \prg_do_nothing: \prg_do_nothing: } { } - \if_num:w \l_regex_group_level_int > \c_zero - \msg_kernel_error:nnx { regex } { missing-rparen } - { \int_use:N \l_regex_group_level_int } + \if_int_compare:w \l__regex_group_level_int > \c_zero + \__msg_kernel_error:nnx { regex } { missing-rparen } + { \int_use:N \l__regex_group_level_int } \prg_replicate:nn - { \l_regex_group_level_int } + { \l__regex_group_level_int } { - \tl_build_one:n + \__tl_build_one:n { \if_false: { \fi: } \if_false: { \fi: } { 1 } { 0 } \c_true_bool } - \tl_build_end: - \tl_build_one:o \l_regex_internal_regex + \__tl_build_end: + \__tl_build_one:o \l__regex_internal_regex } \fi: - \tl_build_one:n { \if_false: { \fi: } } - \tl_build_end: + \__tl_build_one:n { \if_false: { \fi: } } + \__tl_build_end: } -\cs_new_protected:Npn \regex_compile:n #1 +\cs_new_protected:Npn \__regex_compile:n #1 { - \regex_compile:w + \__regex_compile:w \int_set:Nn \tex_escapechar:D { 92 } - \int_set_eq:NN \l_regex_mode_int \c_zero - \regex_escape_use:nnnn + \int_set_eq:NN \l__regex_mode_int \c_zero + \__regex_escape_use:nnnn { - \regex_char_if_special:NTF ##1 - \regex_compile_special:N \regex_compile_raw:N ##1 + \__regex_char_if_special:NTF ##1 + \__regex_compile_special:N \__regex_compile_raw:N ##1 } { - \regex_char_if_alphanumeric:NTF ##1 - \regex_compile_escaped:N \regex_compile_raw:N ##1 + \__regex_char_if_alphanumeric:NTF ##1 + \__regex_compile_escaped:N \__regex_compile_raw:N ##1 } - { \regex_compile_raw:N ##1 } + { \__regex_compile_raw:N ##1 } { #1 } \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: - \int_compare:nNnT \l_regex_mode_int < \c_zero + \int_compare:nNnT \l__regex_mode_int < \c_zero { - \msg_kernel_error:nn { regex } { c-missing-rbrace } - \regex_compile_end: - \regex_compile_one:x - { \regex_item_cs:n { \exp_not:o \l_regex_internal_regex } } + \__msg_kernel_error:nn { regex } { c-missing-rbrace } + \__regex_compile_end: + \__regex_compile_one:x + { \__regex_item_cs:n { \exp_not:o \l__regex_internal_regex } } \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: } - \regex_compile_end: + \__regex_compile_end: } -\cs_new_protected:Npn \regex_compile_special:N #1 +\cs_new_protected:Npn \__regex_compile_special:N #1 { - \cs_if_exist_use:cF { regex_compile_#1: } - { \regex_compile_raw:N #1 } + \cs_if_exist_use:cF { __regex_compile_#1: } + { \__regex_compile_raw:N #1 } } -\cs_new_protected:Npn \regex_compile_escaped:N #1 +\cs_new_protected:Npn \__regex_compile_escaped:N #1 { - \cs_if_exist_use:cF { regex_compile_/#1: } - { \regex_compile_raw:N #1 } + \cs_if_exist_use:cF { __regex_compile_/#1: } + { \__regex_compile_raw:N #1 } } -\cs_new_protected:Npn \regex_compile_one:x #1 +\cs_new_protected:Npn \__regex_compile_one:x #1 { - \regex_mode_quit_c: - \regex_if_in_class:TF { } + \__regex_mode_quit_c: + \__regex_if_in_class:TF { } { - \tl_build_one:n - { \regex_class:NnnnN \c_true_bool { \if_false: } \fi: } + \__tl_build_one:n + { \__regex_class:NnnnN \c_true_bool { \if_false: } \fi: } } - \tl_build_one:x + \__tl_build_one:x { - \if_num:w \l_regex_catcodes_int < \c_regex_all_catcodes_int - \regex_item_catcode:nT { \int_use:N \l_regex_catcodes_int } + \if_int_compare:w \l__regex_catcodes_int < \c__regex_all_catcodes_int + \__regex_item_catcode:nT { \int_use:N \l__regex_catcodes_int } { \exp_not:N \exp_not:n {#1} } \else: \exp_not:N \exp_not:n {#1} \fi: } - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \regex_if_in_class:TF { } { \regex_compile_quantifier:w } + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \__regex_if_in_class:TF { } { \__regex_compile_quantifier:w } } -\cs_new_protected:Npn \regex_compile_abort_tokens:n #1 +\cs_new_protected:Npn \__regex_compile_abort_tokens:n #1 { \use:x { \exp_args:No \tl_map_function:nN { \tl_to_str:n {#1} } - \regex_compile_raw:N + \__regex_compile_raw:N } } -\cs_generate_variant:Nn \regex_compile_abort_tokens:n { x } -\cs_new_protected:Npn \regex_compile_quantifier:w #1#2 +\cs_generate_variant:Nn \__regex_compile_abort_tokens:n { x } +\cs_new_protected:Npn \__regex_compile_quantifier:w #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_special:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N { - \cs_if_exist_use:cF { regex_compile_quantifier_#2:w } - { \regex_compile_quantifier_none: #1 #2 } + \cs_if_exist_use:cF { __regex_compile_quantifier_#2:w } + { \__regex_compile_quantifier_none: #1 #2 } } - { \regex_compile_quantifier_none: #1 #2 } + { \__regex_compile_quantifier_none: #1 #2 } } -\cs_new_protected:Npn \regex_compile_quantifier_none: - { \tl_build_one:n { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } } -\cs_new_protected:Npn \regex_compile_quantifier_abort:xNN #1#2#3 +\cs_new_protected:Npn \__regex_compile_quantifier_none: + { \__tl_build_one:n { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } } +\cs_new_protected:Npn \__regex_compile_quantifier_abort:xNN #1#2#3 { - \regex_compile_quantifier_none: - \msg_kernel_warning:nnxx { regex } { invalid-quantifier } {#1} {#3} - \regex_compile_abort_tokens:x {#1} + \__regex_compile_quantifier_none: + \__msg_kernel_warning:nnxx { regex } { invalid-quantifier } {#1} {#3} + \__regex_compile_abort_tokens:x {#1} #2 #3 } -\cs_new_protected:Npn \regex_compile_quantifier_lazyness:nnNN #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_quantifier_lazyness:nnNN #1#2#3#4 { - \str_if_eq:nnTF { #3 #4 } { \regex_compile_special:N ? } - { \tl_build_one:n { \if_false: { \fi: } { #1 } { #2 } \c_true_bool } } + \str_if_eq:nnTF { #3 #4 } { \__regex_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_one:n { \if_false: { \fi: } { #1 } { #2 } \c_false_bool } #3 #4 } } -\cs_new_protected_nopar:cpn { regex_compile_quantifier_?:w } - { \regex_compile_quantifier_lazyness:nnNN { 0 } { 1 } } -\cs_new_protected_nopar:cpn { regex_compile_quantifier_*:w } - { \regex_compile_quantifier_lazyness:nnNN { 0 } { -1 } } -\cs_new_protected_nopar:cpn { regex_compile_quantifier_+:w } - { \regex_compile_quantifier_lazyness:nnNN { 1 } { -1 } } -\cs_new_protected:cpn { regex_compile_quantifier_ \c_lbrace_str :w } +\cs_new_protected_nopar:cpn { __regex_compile_quantifier_?:w } + { \__regex_compile_quantifier_lazyness:nnNN { 0 } { 1 } } +\cs_new_protected_nopar:cpn { __regex_compile_quantifier_*:w } + { \__regex_compile_quantifier_lazyness:nnNN { 0 } { -1 } } +\cs_new_protected_nopar:cpn { __regex_compile_quantifier_+:w } + { \__regex_compile_quantifier_lazyness:nnNN { 1 } { -1 } } +\cs_new_protected:cpn { __regex_compile_quantifier_ \c_lbrace_str :w } { - \regex_get_digits:NTFw \l_regex_internal_a_int - { \regex_compile_quantifier_braced_i:w } - { \regex_compile_quantifier_abort:xNN { \c_lbrace_str } } + \__regex_get_digits:NTFw \l__regex_internal_a_int + { \__regex_compile_quantifier_braced_i:w } + { \__regex_compile_quantifier_abort:xNN { \c_lbrace_str } } } -\cs_new_protected:Npn \regex_compile_quantifier_braced_i:w #1#2 +\cs_new_protected:Npn \__regex_compile_quantifier_braced_i:w #1#2 { - \prg_case_str:xxn { #1 #2 } + \str_case_x:nnn { #1 #2 } { - { \regex_compile_special:N \c_rbrace_str } + { \__regex_compile_special:N \c_rbrace_str } { - \exp_args:No \regex_compile_quantifier_lazyness:nnNN - { \int_use:N \l_regex_internal_a_int } { 0 } + \exp_args:No \__regex_compile_quantifier_lazyness:nnNN + { \int_use:N \l__regex_internal_a_int } { 0 } } - { \regex_compile_special:N , } + { \__regex_compile_special:N , } { - \regex_get_digits:NTFw \l_regex_internal_b_int - { \regex_compile_quantifier_braced_iii:w } - { \regex_compile_quantifier_braced_ii:w } + \__regex_get_digits:NTFw \l__regex_internal_b_int + { \__regex_compile_quantifier_braced_iii:w } + { \__regex_compile_quantifier_braced_ii:w } } } { - \regex_compile_quantifier_abort:xNN - { \c_lbrace_str \int_use:N \l_regex_internal_a_int } + \__regex_compile_quantifier_abort:xNN + { \c_lbrace_str \int_use:N \l__regex_internal_a_int } #1 #2 } } -\cs_new_protected:Npn \regex_compile_quantifier_braced_ii:w #1#2 +\cs_new_protected:Npn \__regex_compile_quantifier_braced_ii:w #1#2 { - \str_if_eq:xxTF - { #1 #2 } { \regex_compile_special:N \c_rbrace_str } + \str_if_eq_x:nnTF + { #1 #2 } { \__regex_compile_special:N \c_rbrace_str } { - \exp_args:No \regex_compile_quantifier_lazyness:nnNN - { \int_use:N \l_regex_internal_a_int } { -1 } + \exp_args:No \__regex_compile_quantifier_lazyness:nnNN + { \int_use:N \l__regex_internal_a_int } { -1 } } { - \regex_compile_quantifier_abort:xNN - { \c_lbrace_str \int_use:N \l_regex_internal_a_int , } + \__regex_compile_quantifier_abort:xNN + { \c_lbrace_str \int_use:N \l__regex_internal_a_int , } #1 #2 } } -\cs_new_protected:Npn \regex_compile_quantifier_braced_iii:w #1#2 +\cs_new_protected:Npn \__regex_compile_quantifier_braced_iii:w #1#2 { - \str_if_eq:xxTF - { #1 #2 } { \regex_compile_special:N \c_rbrace_str } + \str_if_eq_x:nnTF + { #1 #2 } { \__regex_compile_special:N \c_rbrace_str } { - \if_num:w \l_regex_internal_a_int > \l_regex_internal_b_int - \msg_kernel_error:nnxx { regex } { backwards-quantifier } - { \int_use:N \l_regex_internal_a_int } - { \int_use:N \l_regex_internal_b_int } - \int_zero:N \l_regex_internal_b_int + \if_int_compare:w \l__regex_internal_a_int > \l__regex_internal_b_int + \__msg_kernel_error:nnxx { regex } { backwards-quantifier } + { \int_use:N \l__regex_internal_a_int } + { \int_use:N \l__regex_internal_b_int } + \int_zero:N \l__regex_internal_b_int \else: - \int_sub:Nn \l_regex_internal_b_int \l_regex_internal_a_int + \int_sub:Nn \l__regex_internal_b_int \l__regex_internal_a_int \fi: - \exp_args:Noo \regex_compile_quantifier_lazyness:nnNN - { \int_use:N \l_regex_internal_a_int } - { \int_use:N \l_regex_internal_b_int } + \exp_args:Noo \__regex_compile_quantifier_lazyness:nnNN + { \int_use:N \l__regex_internal_a_int } + { \int_use:N \l__regex_internal_b_int } } { - \regex_compile_quantifier_abort:xNN + \__regex_compile_quantifier_abort:xNN { \c_lbrace_str - \int_use:N \l_regex_internal_a_int , - \int_use:N \l_regex_internal_b_int + \int_use:N \l__regex_internal_a_int , + \int_use:N \l__regex_internal_b_int } #1 #2 } } -\cs_new_protected:Npn \regex_compile_raw_error:N #1 +\cs_new_protected:Npn \__regex_compile_raw_error:N #1 { - \msg_kernel_error:nnx { regex } { bad-escape } {#1} - \regex_compile_raw:N #1 + \__msg_kernel_error:nnx { regex } { bad-escape } {#1} + \__regex_compile_raw:N #1 } -\cs_new_protected:Npn \regex_compile_raw:N #1#2#3 +\cs_new_protected:Npn \__regex_compile_raw:N #1#2#3 { - \regex_if_in_class:TF + \__regex_if_in_class:TF { - \str_if_eq:nnTF {#2#3} { \regex_compile_special:N - } - { \regex_compile_range:Nw #1 } + \str_if_eq:nnTF {#2#3} { \__regex_compile_special:N - } + { \__regex_compile_range:Nw #1 } { - \regex_compile_one:x - { \regex_item_equal:n { \int_value:w `#1 ~ } } + \__regex_compile_one:x + { \__regex_item_equal:n { \__int_value:w `#1 ~ } } #2 #3 } } { - \regex_compile_one:x - { \regex_item_equal:n { \int_value:w `#1 ~ } } + \__regex_compile_one:x + { \__regex_item_equal:n { \__int_value:w `#1 ~ } } #2 #3 } } -\prg_new_protected_conditional:Npnn \regex_if_end_range:NN #1#2 { TF } +\prg_new_protected_conditional:Npnn \__regex_if_end_range:NN #1#2 { TF } { - \if_meaning:w \regex_compile_raw:N #1 + \if_meaning:w \__regex_compile_raw:N #1 \prg_return_true: \else: - \if_meaning:w \regex_compile_special:N #1 + \if_meaning:w \__regex_compile_special:N #1 \if_charcode:w ] #2 \prg_return_false: \else: @@ -806,1815 +806,1823 @@ \fi: \fi: } -\cs_new_protected:Npn \regex_compile_range:Nw #1#2#3 +\cs_new_protected:Npn \__regex_compile_range:Nw #1#2#3 { - \regex_if_end_range:NNTF #2 #3 + \__regex_if_end_range:NNTF #2 #3 { - \if_num:w `#1 > `#3 \exp_stop_f: - \msg_kernel_error:nnxx { regex } { range-backwards } {#1} {#3} + \if_int_compare:w `#1 > `#3 \exp_stop_f: + \__msg_kernel_error:nnxx { regex } { range-backwards } {#1} {#3} \else: - \tl_build_one:x + \__tl_build_one:x { - \if_num:w `#1 = `#3 \exp_stop_f: - \regex_item_equal:n + \if_int_compare:w `#1 = `#3 \exp_stop_f: + \__regex_item_equal:n \else: - \regex_item_range:nn { \int_value:w `#1 ~ } + \__regex_item_range:nn { \__int_value:w `#1 ~ } \fi: - { \int_value:w `#3 ~ } + { \__int_value:w `#3 ~ } } \fi: } { - \msg_kernel_warning:nnxx { regex } { range-missing-end } + \__msg_kernel_warning:nnxx { regex } { range-missing-end } {#1} { \c_backslash_str #3 } - \tl_build_one:x + \__tl_build_one:x { - \regex_item_equal:n { \int_value:w `#1 ~ } - \regex_item_equal:n { \int_value:w `- ~ } + \__regex_item_equal:n { \__int_value:w `#1 ~ } + \__regex_item_equal:n { \__int_value:w `- ~ } } #2#3 } } -\cs_new_protected_nopar:cpx { regex_compile_.: } +\cs_new_protected_nopar:cpx { __regex_compile_.: } { - \exp_not:N \regex_if_in_class:TF - { \regex_compile_raw:N . } - { \regex_compile_one:x \exp_not:c { regex_prop_.: } } + \exp_not:N \__regex_if_in_class:TF + { \__regex_compile_raw:N . } + { \__regex_compile_one:x \exp_not:c { __regex_prop_.: } } } -\cs_new_protected_nopar:cpn { regex_prop_.: } +\cs_new_protected_nopar:cpn { __regex_prop_.: } { - \if_num:w \l_regex_current_char_int > - \c_two - \exp_after:wN \regex_break_true:w + \if_int_compare:w \l__regex_current_char_int > - \c_two + \exp_after:wN \__regex_break_true:w \fi: } -\cs_set_protected:Npn \regex_tmp:w #1#2 +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \cs_new_protected_nopar:cpx { regex_compile_/#1: } - { \regex_compile_one:x \exp_not:c { regex_prop_#1: } } - \cs_new_protected_nopar:cpx { regex_compile_/#2: } + \cs_new_protected_nopar:cpx { __regex_compile_/#1: } + { \__regex_compile_one:x \exp_not:c { __regex_prop_#1: } } + \cs_new_protected_nopar:cpx { __regex_compile_/#2: } { - \regex_compile_one:x - { \regex_item_reverse:n \exp_not:c { regex_prop_#1: } } + \__regex_compile_one:x + { \__regex_item_reverse:n \exp_not:c { __regex_prop_#1: } } } } -\regex_tmp:w d D -\regex_tmp:w h H -\regex_tmp:w s S -\regex_tmp:w v V -\regex_tmp:w w W -\cs_new_protected_nopar:cpn { regex_compile_/N: } - { \regex_compile_one:x \regex_prop_N: } -\cs_new_protected:Npn \regex_compile_anchor:NF #1#2 +\__regex_tmp:w d D +\__regex_tmp:w h H +\__regex_tmp:w s S +\__regex_tmp:w v V +\__regex_tmp:w w W +\cs_new_protected_nopar:cpn { __regex_compile_/N: } + { \__regex_compile_one:x \__regex_prop_N: } +\cs_new_protected:Npn \__regex_compile_anchor:NF #1#2 { - \regex_if_in_class_or_catcode:TF {#2} + \__regex_if_in_class_or_catcode:TF {#2} { - \tl_build_one:n - { \regex_assertion:Nn \c_true_bool { \regex_anchor:N #1 } } + \__tl_build_one:n + { \__regex_assertion:Nn \c_true_bool { \__regex_anchor:N #1 } } } } -\cs_set_protected:Npn \regex_tmp:w #1#2 +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \cs_new_protected_nopar:cpn { regex_compile_/#1: } - { \regex_compile_anchor:NF #2 { \regex_compile_raw_error:N #1 } } + \cs_new_protected_nopar:cpn { __regex_compile_/#1: } + { \__regex_compile_anchor:NF #2 { \__regex_compile_raw_error:N #1 } } } -\regex_tmp:w A \l_regex_min_pos_int -\regex_tmp:w G \l_regex_start_pos_int -\regex_tmp:w Z \l_regex_max_pos_int -\regex_tmp:w z \l_regex_max_pos_int -\cs_set_protected:Npn \regex_tmp:w #1#2 +\__regex_tmp:w A \l__regex_min_pos_int +\__regex_tmp:w G \l__regex_start_pos_int +\__regex_tmp:w Z \l__regex_max_pos_int +\__regex_tmp:w z \l__regex_max_pos_int +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \cs_new_protected_nopar:cpn { regex_compile_#1: } - { \regex_compile_anchor:NF #2 { \regex_compile_raw:N #1 } } + \cs_new_protected_nopar:cpn { __regex_compile_#1: } + { \__regex_compile_anchor:NF #2 { \__regex_compile_raw:N #1 } } } -\exp_args:Nx \regex_tmp:w { \iow_char:N \^ } \l_regex_min_pos_int -\exp_args:Nx \regex_tmp:w { \iow_char:N \$ } \l_regex_max_pos_int -\cs_new_protected_nopar:cpn { regex_compile_/b: } +\exp_args:Nx \__regex_tmp:w { \iow_char:N \^ } \l__regex_min_pos_int +\exp_args:Nx \__regex_tmp:w { \iow_char:N \$ } \l__regex_max_pos_int +\cs_new_protected_nopar:cpn { __regex_compile_/b: } { - \regex_if_in_class_or_catcode:TF - { \regex_compile_raw_error:N b } + \__regex_if_in_class_or_catcode:TF + { \__regex_compile_raw_error:N b } { - \tl_build_one:n - { \regex_assertion:Nn \c_true_bool { \regex_b_test: } } + \__tl_build_one:n + { \__regex_assertion:Nn \c_true_bool { \__regex_b_test: } } } } -\cs_new_protected_nopar:cpn { regex_compile_/B: } +\cs_new_protected_nopar:cpn { __regex_compile_/B: } { - \regex_if_in_class_or_catcode:TF - { \regex_compile_raw_error:N B } + \__regex_if_in_class_or_catcode:TF + { \__regex_compile_raw_error:N B } { - \tl_build_one:n - { \regex_assertion:Nn \c_false_bool { \regex_b_test: } } + \__tl_build_one:n + { \__regex_assertion:Nn \c_false_bool { \__regex_b_test: } } } } -\cs_new_protected:cpn { regex_compile_]: } +\cs_new_protected:cpn { __regex_compile_]: } { - \regex_if_in_class:TF + \__regex_if_in_class:TF { - \if_num:w \l_regex_mode_int > \c_sixteen - \tl_build_one:n { \if_false: { \fi: } } + \if_int_compare:w \l__regex_mode_int > \c_sixteen + \__tl_build_one:n { \if_false: { \fi: } } \fi: - \tex_advance:D \l_regex_mode_int - \c_fifteen - \tex_divide:D \l_regex_mode_int \c_thirteen - \if_int_odd:w \l_regex_mode_int \else: - \exp_after:wN \regex_compile_quantifier:w + \tex_advance:D \l__regex_mode_int - \c_fifteen + \tex_divide:D \l__regex_mode_int \c_thirteen + \if_int_odd:w \l__regex_mode_int \else: + \exp_after:wN \__regex_compile_quantifier:w \fi: } - { \regex_compile_raw:N ] } + { \__regex_compile_raw:N ] } } -\cs_new_protected_nopar:cpn { regex_compile_[: } +\cs_new_protected_nopar:cpn { __regex_compile_[: } { - \regex_if_in_class:TF - { \regex_compile_class_posix_test:w } + \__regex_if_in_class:TF + { \__regex_compile_class_posix_test:w } { - \regex_if_within_catcode:TF + \__regex_if_within_catcode:TF { - \exp_after:wN \regex_compile_class_catcode:w - \int_use:N \l_regex_catcodes_int ; + \exp_after:wN \__regex_compile_class_catcode:w + \int_use:N \l__regex_catcodes_int ; } - { \regex_compile_class_normal:w } + { \__regex_compile_class_normal:w } } } -\cs_new_protected_nopar:Npn \regex_compile_class_normal:w +\cs_new_protected_nopar:Npn \__regex_compile_class_normal:w { - \regex_compile_class:TFNN - { \regex_class:NnnnN \c_true_bool } - { \regex_class:NnnnN \c_false_bool } + \__regex_compile_class:TFNN + { \__regex_class:NnnnN \c_true_bool } + { \__regex_class:NnnnN \c_false_bool } } -\cs_new_protected:Npn \regex_compile_class_catcode:w #1; +\cs_new_protected:Npn \__regex_compile_class_catcode:w #1; { - \if_int_compare:w \l_regex_mode_int = \c_two - \tl_build_one:n - { \regex_class:NnnnN \c_true_bool { \if_false: } \fi: } + \if_int_compare:w \l__regex_mode_int = \c_two + \__tl_build_one:n + { \__regex_class:NnnnN \c_true_bool { \if_false: } \fi: } \fi: - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \regex_compile_class:TFNN - { \regex_item_catcode:nT {#1} } - { \regex_item_catcode_reverse:nT {#1} } + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \__regex_compile_class:TFNN + { \__regex_item_catcode:nT {#1} } + { \__regex_item_catcode_reverse:nT {#1} } } -\cs_new_protected:Npn \regex_compile_class:TFNN #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_class:TFNN #1#2#3#4 { - \l_regex_mode_int = \int_value:w \l_regex_mode_int 3 \exp_stop_f: - \str_if_eq:nnTF { #3 #4 } { \regex_compile_special:N ^ } + \l__regex_mode_int = \__int_value:w \l__regex_mode_int 3 \exp_stop_f: + \str_if_eq:nnTF { #3 #4 } { \__regex_compile_special:N ^ } { - \tl_build_one:n { #2 { \if_false: } \fi: } - \regex_compile_class_ii:NN + \__tl_build_one:n { #2 { \if_false: } \fi: } + \__regex_compile_class_ii:NN } { - \tl_build_one:n { #1 { \if_false: } \fi: } - \regex_compile_class_ii:NN #3 #4 + \__tl_build_one:n { #1 { \if_false: } \fi: } + \__regex_compile_class_ii:NN #3 #4 } } -\cs_new_protected:Npn \regex_compile_class_ii:NN #1#2 +\cs_new_protected:Npn \__regex_compile_class_ii:NN #1#2 { \token_if_eq_charcode:NNTF #2 ] - { \regex_compile_raw:N #2 } + { \__regex_compile_raw:N #2 } { #1 #2 } } -\cs_new_protected:Npn \regex_compile_class_posix_test:w #1#2 +\cs_new_protected:Npn \__regex_compile_class_posix_test:w #1#2 { - \token_if_eq_meaning:NNT \regex_compile_special:N #1 + \token_if_eq_meaning:NNT \__regex_compile_special:N #1 { - \prg_case_str:nnn { #2 } + \str_case:nnn { #2 } { - : { \regex_compile_class_posix:NNNNw } - = { \msg_kernel_warning:nnx { regex } { posix-unsupported } { = } } - . { \msg_kernel_warning:nnx { regex } { posix-unsupported } { . } } + : { \__regex_compile_class_posix:NNNNw } + = { \__msg_kernel_warning:nnx { regex } { posix-unsupported } { = } } + . { \__msg_kernel_warning:nnx { regex } { posix-unsupported } { . } } } { } } - \regex_compile_raw:N [ #1 #2 + \__regex_compile_raw:N [ #1 #2 } -\cs_new_protected:Npn \regex_compile_class_posix:NNNNw #1#2#3#4#5#6 +\cs_new_protected:Npn \__regex_compile_class_posix:NNNNw #1#2#3#4#5#6 { - \str_if_eq:nnTF { #5 #6 } { \regex_compile_special:N ^ } + \str_if_eq:nnTF { #5 #6 } { \__regex_compile_special:N ^ } { - \bool_set_false:N \l_regex_internal_bool - \tl_set:Nx \l_regex_internal_a_tl { \if_false: } \fi: - \regex_compile_class_posix_loop:w + \bool_set_false:N \l__regex_internal_bool + \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi: + \__regex_compile_class_posix_loop:w } { - \bool_set_true:N \l_regex_internal_bool - \tl_set:Nx \l_regex_internal_a_tl { \if_false: } \fi: - \regex_compile_class_posix_loop:w #5 #6 + \bool_set_true:N \l__regex_internal_bool + \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi: + \__regex_compile_class_posix_loop:w #5 #6 } } -\cs_new:Npn \regex_compile_class_posix_loop:w #1#2 +\cs_new:Npn \__regex_compile_class_posix_loop:w #1#2 { - \token_if_eq_meaning:NNTF \regex_compile_raw:N #1 - { #2 \regex_compile_class_posix_loop:w } - { \if_false: { \fi: } \regex_compile_class_posix_end:w #1 #2 } + \token_if_eq_meaning:NNTF \__regex_compile_raw:N #1 + { #2 \__regex_compile_class_posix_loop:w } + { \if_false: { \fi: } \__regex_compile_class_posix_end:w #1 #2 } } -\cs_new_protected:Npn \regex_compile_class_posix_end:w #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_class_posix_end:w #1#2#3#4 { \str_if_eq:nnTF { #1 #2 #3 #4 } - { \regex_compile_special:N : \regex_compile_special:N ] } + { \__regex_compile_special:N : \__regex_compile_special:N ] } { - \cs_if_exist:cTF { regex_posix_ \l_regex_internal_a_tl : } + \cs_if_exist:cTF { __regex_posix_ \l__regex_internal_a_tl : } { - \regex_compile_one:x + \__regex_compile_one:x { - \bool_if:NF \l_regex_internal_bool \regex_item_reverse:n - \exp_not:c { regex_posix_ \l_regex_internal_a_tl : } + \bool_if:NF \l__regex_internal_bool \__regex_item_reverse:n + \exp_not:c { __regex_posix_ \l__regex_internal_a_tl : } } } { - \msg_kernel_warning:nnx { regex } { posix-unknown } - { \l_regex_internal_a_tl } - \regex_compile_abort_tokens:x + \__msg_kernel_warning:nnx { regex } { posix-unknown } + { \l__regex_internal_a_tl } + \__regex_compile_abort_tokens:x { - [: \bool_if:NF \l_regex_internal_bool { ^ } - \l_regex_internal_a_tl :] + [: \bool_if:NF \l__regex_internal_bool { ^ } + \l__regex_internal_a_tl :] } } } { - \msg_kernel_error:nnxx { regex } { posix-missing-close } - { [: \l_regex_internal_a_tl } { #2 #4 } - \regex_compile_abort_tokens:x { [: \l_regex_internal_a_tl } + \__msg_kernel_error:nnxx { regex } { posix-missing-close } + { [: \l__regex_internal_a_tl } { #2 #4 } + \__regex_compile_abort_tokens:x { [: \l__regex_internal_a_tl } #1 #2 #3 #4 } } -\cs_new_protected:Npn \regex_compile_group_begin:N #1 +\cs_new_protected:Npn \__regex_compile_group_begin:N #1 { - \tl_build_one:n { #1 { \if_false: } \fi: } - \regex_mode_quit_c: - \tl_set_build:Nw \l_regex_internal_regex - \int_set_eq:NN \l_regex_default_catcodes_int \l_regex_catcodes_int - \int_incr:N \l_regex_group_level_int - \tl_build_one:n { \regex_branch:n { \if_false: } \fi: } + \__tl_build_one:n { #1 { \if_false: } \fi: } + \__regex_mode_quit_c: + \__tl_build:Nw \l__regex_internal_regex + \int_set_eq:NN \l__regex_default_catcodes_int \l__regex_catcodes_int + \int_incr:N \l__regex_group_level_int + \__tl_build_one:n { \__regex_branch:n { \if_false: } \fi: } } -\cs_new_protected:Npn \regex_compile_group_end: +\cs_new_protected:Npn \__regex_compile_group_end: { - \if_num:w \l_regex_group_level_int > \c_zero - \tl_build_one:n { \if_false: { \fi: } } - \tl_build_end: - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \tl_build_one:o \l_regex_internal_regex - \exp_after:wN \regex_compile_quantifier:w + \if_int_compare:w \l__regex_group_level_int > \c_zero + \__tl_build_one:n { \if_false: { \fi: } } + \__tl_build_end: + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \__tl_build_one:o \l__regex_internal_regex + \exp_after:wN \__regex_compile_quantifier:w \else: - \msg_kernel_warning:nn { regex } { extra-rparen } - \exp_after:wN \regex_compile_raw:N \exp_after:wN ) + \__msg_kernel_warning:nn { regex } { extra-rparen } + \exp_after:wN \__regex_compile_raw:N \exp_after:wN ) \fi: } -\cs_new_protected_nopar:cpn { regex_compile_(: } +\cs_new_protected_nopar:cpn { __regex_compile_(: } { - \regex_if_in_class:TF { \regex_compile_raw:N ( } - { \regex_compile_lparen:w } + \__regex_if_in_class:TF { \__regex_compile_raw:N ( } + { \__regex_compile_lparen:w } } -\cs_new_protected:Npn \regex_compile_lparen:w #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_lparen:w #1#2#3#4 { - \str_if_eq:nnTF { #1 #2 } { \regex_compile_special:N ? } + \str_if_eq:nnTF { #1 #2 } { \__regex_compile_special:N ? } { \cs_if_exist_use:cF - { regex_compile_special_group_\token_to_str:N #4 :w } + { __regex_compile_special_group_\token_to_str:N #4 :w } { - \msg_kernel_warning:nnx { regex } { special-group-unknown } + \__msg_kernel_warning:nnx { regex } { special-group-unknown } { (? \token_to_str:N #4 } - \regex_compile_group_begin:N \regex_group:nnnN - \regex_compile_raw:N ? #3 #4 + \__regex_compile_group_begin:N \__regex_group:nnnN + \__regex_compile_raw:N ? #3 #4 } } { - \regex_compile_group_begin:N \regex_group:nnnN + \__regex_compile_group_begin:N \__regex_group:nnnN #1 #2 #3 #4 } } -\cs_new_protected_nopar:cpn { regex_compile_|: } +\cs_new_protected_nopar:cpn { __regex_compile_|: } { - \regex_if_in_class:TF { \regex_compile_raw:N | } + \__regex_if_in_class:TF { \__regex_compile_raw:N | } { - \tl_build_one:n - { \if_false: { \fi: } \regex_branch:n { \if_false: } \fi: } + \__tl_build_one:n + { \if_false: { \fi: } \__regex_branch:n { \if_false: } \fi: } } } -\cs_new_protected_nopar:cpn { regex_compile_): } +\cs_new_protected_nopar:cpn { __regex_compile_): } { - \regex_if_in_class:TF { \regex_compile_raw:N ) } - { \regex_compile_group_end: } + \__regex_if_in_class:TF { \__regex_compile_raw:N ) } + { \__regex_compile_group_end: } } -\cs_new_protected_nopar:cpn { regex_compile_special_group_::w } - { \regex_compile_group_begin:N \regex_group_no_capture:nnnN } -\cs_new_protected_nopar:cpn { regex_compile_special_group_|:w } - { \regex_compile_group_begin:N \regex_group_resetting:nnnN } -\cs_new_protected:Npn \regex_compile_special_group_i:w #1#2 +\cs_new_protected_nopar:cpn { __regex_compile_special_group_::w } + { \__regex_compile_group_begin:N \__regex_group_no_capture:nnnN } +\cs_new_protected_nopar:cpn { __regex_compile_special_group_|:w } + { \__regex_compile_group_begin:N \__regex_group_resetting:nnnN } +\cs_new_protected:Npn \__regex_compile_special_group_i:w #1#2 { - \str_if_eq:nnTF { #1 #2 } { \regex_compile_special:N ) } + \str_if_eq:nnTF { #1 #2 } { \__regex_compile_special:N ) } { - \cs_set_nopar:Npn \regex_item_equal:n { \regex_item_caseless_equal:n } - \cs_set_nopar:Npn \regex_item_range:nn { \regex_item_caseless_range:nn } + \cs_set_nopar:Npn \__regex_item_equal:n { \__regex_item_caseless_equal:n } + \cs_set_nopar:Npn \__regex_item_range:nn { \__regex_item_caseless_range:nn } } { - \msg_kernel_warning:nnx { regex } { unknown-option } { (?i #2 } - \regex_compile_raw:N ( - \regex_compile_raw:N ? - \regex_compile_raw:N i + \__msg_kernel_warning:nnx { regex } { unknown-option } { (?i #2 } + \__regex_compile_raw:N ( + \__regex_compile_raw:N ? + \__regex_compile_raw:N i #1 #2 } } -\cs_new_protected_nopar:cpn { regex_compile_special_group_-:w } #1#2#3#4 +\cs_new_protected_nopar:cpn { __regex_compile_special_group_-:w } #1#2#3#4 { \str_if_eq:nnTF { #1 #2 #3 #4 } - { \regex_compile_raw:N i \regex_compile_special:N ) } + { \__regex_compile_raw:N i \__regex_compile_special:N ) } { - \cs_set_nopar:Npn \regex_item_equal:n { \regex_item_caseful_equal:n } - \cs_set_nopar:Npn \regex_item_range:nn { \regex_item_caseful_range:nn } + \cs_set_nopar:Npn \__regex_item_equal:n { \__regex_item_caseful_equal:n } + \cs_set_nopar:Npn \__regex_item_range:nn { \__regex_item_caseful_range:nn } } { - \msg_kernel_warning:nnx { regex } { unknown-option } { (?-#2#4 } - \regex_compile_raw:N ( - \regex_compile_raw:N ? - \regex_compile_raw:N - + \__msg_kernel_warning:nnx { regex } { unknown-option } { (?-#2#4 } + \__regex_compile_raw:N ( + \__regex_compile_raw:N ? + \__regex_compile_raw:N - #1 #2 #3 #4 } } -\cs_new_protected:cpn { regex_compile_/c: } - { \regex_chk_c_allowed:T { \regex_compile_c_test:NN } } -\cs_new_protected:Npn \regex_compile_c_test:NN #1#2 +\cs_new_protected:cpn { __regex_compile_/c: } + { \__regex_chk_c_allowed:T { \__regex_compile_c_test:NN } } +\cs_new_protected:Npn \__regex_compile_c_test:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_raw:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N { - \int_if_exist:cTF { c_regex_catcode_#2_int } + \int_if_exist:cTF { c__regex_catcode_#2_int } { - \int_set_eq:Nc \l_regex_catcodes_int { c_regex_catcode_#2_int } - \l_regex_mode_int - = \if_case:w \l_regex_mode_int \c_two \else: \c_six \fi: + \int_set_eq:Nc \l__regex_catcodes_int { c__regex_catcode_#2_int } + \l__regex_mode_int + = \if_case:w \l__regex_mode_int \c_two \else: \c_six \fi: } } - { \cs_if_exist_use:cF { regex_compile_c_#2:w } } + { \cs_if_exist_use:cF { __regex_compile_c_#2:w } } { - \msg_kernel_error:nnx { regex } { c-missing-category } {#2} + \__msg_kernel_error:nnx { regex } { c-missing-category } {#2} #1 #2 } } -\cs_new_protected:cpn { regex_compile_c_[:w } #1#2 +\cs_new_protected:cpn { __regex_compile_c_[:w } #1#2 { - \l_regex_mode_int - = \if_case:w \l_regex_mode_int \c_two \else: \c_six \fi: - \int_zero:N \l_regex_catcodes_int - \str_if_eq:nnTF { #1 #2 } { \regex_compile_special:N ^ } + \l__regex_mode_int + = \if_case:w \l__regex_mode_int \c_two \else: \c_six \fi: + \int_zero:N \l__regex_catcodes_int + \str_if_eq:nnTF { #1 #2 } { \__regex_compile_special:N ^ } { - \bool_set_false:N \l_regex_catcodes_bool - \regex_compile_c_lbrack_loop:NN + \bool_set_false:N \l__regex_catcodes_bool + \__regex_compile_c_lbrack_loop:NN } { - \bool_set_true:N \l_regex_catcodes_bool - \regex_compile_c_lbrack_loop:NN + \bool_set_true:N \l__regex_catcodes_bool + \__regex_compile_c_lbrack_loop:NN #1 #2 } } -\cs_new_protected:Npn \regex_compile_c_lbrack_loop:NN #1#2 +\cs_new_protected:Npn \__regex_compile_c_lbrack_loop:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_raw:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N { - \int_if_exist:cTF { c_regex_catcode_#2_int } + \int_if_exist:cTF { c__regex_catcode_#2_int } { - \exp_args:Nc \regex_compile_c_lbrack_add:N - { c_regex_catcode_#2_int } - \regex_compile_c_lbrack_loop:NN + \exp_args:Nc \__regex_compile_c_lbrack_add:N + { c__regex_catcode_#2_int } + \__regex_compile_c_lbrack_loop:NN } } { \token_if_eq_charcode:NNTF #2 ] - { \regex_compile_c_lbrack_end: } + { \__regex_compile_c_lbrack_end: } } { - \msg_kernel_error:nnx { regex } { c-missing-rbrack } {#2} - \regex_compile_c_lbrack_end: + \__msg_kernel_error:nnx { regex } { c-missing-rbrack } {#2} + \__regex_compile_c_lbrack_end: #1 #2 } } -\cs_new_protected:Npn \regex_compile_c_lbrack_add:N #1 +\cs_new_protected:Npn \__regex_compile_c_lbrack_add:N #1 { - \if_int_odd:w \int_eval:w \l_regex_catcodes_int / #1 \int_eval_end: + \if_int_odd:w \__int_eval:w \l__regex_catcodes_int / #1 \__int_eval_end: \else: - \tex_advance:D \l_regex_catcodes_int #1 + \tex_advance:D \l__regex_catcodes_int #1 \fi: } -\cs_new_protected_nopar:Npn \regex_compile_c_lbrack_end: +\cs_new_protected_nopar:Npn \__regex_compile_c_lbrack_end: { - \if_meaning:w \c_false_bool \l_regex_catcodes_bool - \int_set:Nn \l_regex_catcodes_int - { \c_regex_all_catcodes_int - \l_regex_catcodes_int } + \if_meaning:w \c_false_bool \l__regex_catcodes_bool + \int_set:Nn \l__regex_catcodes_int + { \c__regex_all_catcodes_int - \l__regex_catcodes_int } \fi: } -\cs_new_protected_nopar:cpn { regex_compile_c_ \c_lbrace_str :w } +\cs_new_protected_nopar:cpn { __regex_compile_c_ \c_lbrace_str :w } { - \regex_compile:w - \regex_disable_submatches: - \l_regex_mode_int - = - \if_case:w \l_regex_mode_int \c_two \else: \c_six \fi: + \__regex_compile:w + \__regex_disable_submatches: + \l__regex_mode_int + = - \if_case:w \l__regex_mode_int \c_two \else: \c_six \fi: } -\cs_new_protected:cpn { regex_compile_ \c_rbrace_str : } +\cs_new_protected:cpn { __regex_compile_ \c_rbrace_str : } { - \regex_if_in_cs:TF + \__regex_if_in_cs:TF { - \regex_compile_end: - \regex_compile_one:x - { \regex_item_cs:n { \exp_not:o \l_regex_internal_regex } } + \__regex_compile_end: + \__regex_compile_one:x + { \__regex_item_cs:n { \exp_not:o \l__regex_internal_regex } } } - { \exp_after:wN \regex_compile_raw:N \c_rbrace_str } + { \exp_after:wN \__regex_compile_raw:N \c_rbrace_str } } -\cs_new_protected:cpn { regex_compile_/u: } #1#2 +\cs_new_protected:cpn { __regex_compile_/u: } #1#2 { - \regex_if_in_class_or_catcode:TF - { \regex_compile_raw_error:N u #1 #2 } + \__regex_if_in_class_or_catcode:TF + { \__regex_compile_raw_error:N u #1 #2 } { - \str_if_eq:xxTF {#1#2} { \regex_compile_special:N \c_lbrace_str } + \str_if_eq_x:nnTF {#1#2} { \__regex_compile_special:N \c_lbrace_str } { - \tl_set:Nx \l_regex_internal_a_tl { \if_false: } \fi: - \regex_compile_u_loop:NN + \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi: + \__regex_compile_u_loop:NN } { - \msg_kernel_error:nn { regex } { u-missing-lbrace } - \regex_compile_raw:N u #1 #2 + \__msg_kernel_error:nn { regex } { u-missing-lbrace } + \__regex_compile_raw:N u #1 #2 } } } -\cs_new:Npn \regex_compile_u_loop:NN #1#2 +\cs_new:Npn \__regex_compile_u_loop:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_raw:N - { #2 \regex_compile_u_loop:NN } + \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N + { #2 \__regex_compile_u_loop:NN } { - \token_if_eq_meaning:NNTF #1 \regex_compile_special:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N { \exp_after:wN \token_if_eq_charcode:NNTF \c_rbrace_str #2 - { \if_false: { \fi: } \regex_compile_u_end: } - { #2 \regex_compile_u_loop:NN } + { \if_false: { \fi: } \__regex_compile_u_end: } + { #2 \__regex_compile_u_loop:NN } } { \if_false: { \fi: } - \msg_kernel_error:nnx { regex } { u-missing-rbrace } {#2} - \regex_compile_u_end: + \__msg_kernel_error:nnx { regex } { u-missing-rbrace } {#2} + \__regex_compile_u_end: #1 #2 } } } -\cs_new_protected:Npn \regex_compile_u_end: +\cs_new_protected:Npn \__regex_compile_u_end: { - \tl_set:Nv \l_regex_internal_a_tl { \l_regex_internal_a_tl } - \if_num:w \l_regex_mode_int = \c_zero - \regex_compile_u_not_cs: + \tl_set:Nv \l__regex_internal_a_tl { \l__regex_internal_a_tl } + \if_int_compare:w \l__regex_mode_int = \c_zero + \__regex_compile_u_not_cs: \else: - \regex_compile_u_in_cs: + \__regex_compile_u_in_cs: \fi: } -\cs_new_protected:Npn \regex_compile_u_in_cs: +\cs_new_protected:Npn \__regex_compile_u_in_cs: { - \exp_args:NNo \str_gset_other:Nn \g_regex_internal_tl - { \l_regex_internal_a_tl } - \tl_build_one:x + \exp_args:NNo \__str_gset_other:Nn \g__regex_internal_tl + { \l__regex_internal_a_tl } + \__tl_build_one:x { - \tl_map_function:NN \g_regex_internal_tl - \regex_compile_u_in_cs_aux:n + \tl_map_function:NN \g__regex_internal_tl + \__regex_compile_u_in_cs_aux:n } } -\cs_new:Npn \regex_compile_u_in_cs_aux:n #1 +\cs_new:Npn \__regex_compile_u_in_cs_aux:n #1 { - \regex_class:NnnnN \c_true_bool - { \regex_item_caseful_equal:n { \int_value:w `#1 } } + \__regex_class:NnnnN \c_true_bool + { \__regex_item_caseful_equal:n { \__int_value:w `#1 } } { 1 } { 0 } \c_false_bool } -\cs_new_protected:Npn \regex_compile_u_not_cs: +\cs_new_protected:Npn \__regex_compile_u_not_cs: { - \exp_args:No \tl_analysis_map_inline:nn { \l_regex_internal_a_tl } + \exp_args:No \__tl_analysis_map_inline:nn { \l__regex_internal_a_tl } { - \tl_build_one:n + \__tl_build_one:n { - \regex_class:NnnnN \c_true_bool + \__regex_class:NnnnN \c_true_bool { - \if_num:w "##2 = \c_zero - \regex_item_exact_cs:c { \exp_after:wN \cs_to_str:N ##1 } + \if_int_compare:w "##2 = \c_zero + \__regex_item_exact_cs:c { \exp_after:wN \cs_to_str:N ##1 } \else: - \regex_item_exact:nn { \int_value:w "##2 } { ##3 } + \__regex_item_exact:nn { \__int_value:w "##2 } { ##3 } \fi: } { 1 } { 0 } \c_false_bool } } } -\cs_new_protected_nopar:cpn { regex_compile_/K: } +\cs_new_protected_nopar:cpn { __regex_compile_/K: } { - \int_compare:nNnTF \l_regex_mode_int = \c_zero - { \tl_build_one:n { \regex_command_K: } } - { \regex_compile_raw_error:N K } + \int_compare:nNnTF \l__regex_mode_int = \c_zero + { \__tl_build_one:n { \__regex_command_K: } } + { \__regex_compile_raw_error:N K } } -\cs_new_protected:Npn \regex_show_aux:Nx #1#2 +\cs_new_protected:Npn \__regex_show:Nx #1#2 { - \tl_set_build:Nw \l_regex_internal_a_tl - \cs_set_protected_nopar:Npn \regex_branch:n + \__tl_build:Nw \l__regex_internal_a_tl + \cs_set_protected_nopar:Npn \__regex_branch:n { - \seq_pop_right:NN \l_regex_show_prefix_seq \l_regex_internal_a_tl - \regex_show_one:n { +-branch } - \seq_put_right:No \l_regex_show_prefix_seq \l_regex_internal_a_tl + \seq_pop_right:NN \l__regex_show_prefix_seq \l__regex_internal_a_tl + \__regex_show_one:n { +-branch } + \seq_put_right:No \l__regex_show_prefix_seq \l__regex_internal_a_tl \use:n } - \cs_set_protected_nopar:Npn \regex_group:nnnN - { \regex_show_group_aux:nnnnN { } } - \cs_set_protected_nopar:Npn \regex_group_no_capture:nnnN - { \regex_show_group_aux:nnnnN { ~(no~capture) } } - \cs_set_protected_nopar:Npn \regex_group_resetting:nnnN - { \regex_show_group_aux:nnnnN { ~(resetting) } } - \cs_set_eq:NN \regex_class:NnnnN \regex_show_class:NnnnN - \cs_set_protected_nopar:Npn \regex_command_K: - { \regex_show_one:n { reset~match~start~(\iow_char:N\\K) } } - \cs_set_protected:Npn \regex_assertion:Nn ##1##2 - { \regex_show_one:n { \bool_if:NF ##1 { negative~ } assertion:~##2 } } - \cs_set_nopar:Npn \regex_b_test: { word~boundary } - \cs_set_eq:NN \regex_anchor:N \regex_show_anchor_to_str:N - \cs_set_protected:Npn \regex_item_caseful_equal:n ##1 - { \regex_show_one:n { char~code~\int_eval:n{##1} } } - \cs_set_protected:Npn \regex_item_caseful_range:nn ##1##2 - { \regex_show_one:n { range~[\int_eval:n{##1}, \int_eval:n{##2}] } } - \cs_set_protected:Npn \regex_item_caseless_equal:n ##1 - { \regex_show_one:n { char~code~\int_eval:n{##1}~(caseless) } } - \cs_set_protected:Npn \regex_item_caseless_range:nn ##1##2 + \cs_set_protected_nopar:Npn \__regex_group:nnnN + { \__regex_show_group_aux:nnnnN { } } + \cs_set_protected_nopar:Npn \__regex_group_no_capture:nnnN + { \__regex_show_group_aux:nnnnN { ~(no~capture) } } + \cs_set_protected_nopar:Npn \__regex_group_resetting:nnnN + { \__regex_show_group_aux:nnnnN { ~(resetting) } } + \cs_set_eq:NN \__regex_class:NnnnN \__regex_show_class:NnnnN + \cs_set_protected_nopar:Npn \__regex_command_K: + { \__regex_show_one:n { reset~match~start~(\iow_char:N\\K) } } + \cs_set_protected:Npn \__regex_assertion:Nn ##1##2 + { \__regex_show_one:n { \bool_if:NF ##1 { negative~ } assertion:~##2 } } + \cs_set_nopar:Npn \__regex_b_test: { word~boundary } + \cs_set_eq:NN \__regex_anchor:N \__regex_show_anchor_to_str:N + \cs_set_protected:Npn \__regex_item_caseful_equal:n ##1 + { \__regex_show_one:n { char~code~\int_eval:n{##1} } } + \cs_set_protected:Npn \__regex_item_caseful_range:nn ##1##2 + { \__regex_show_one:n { range~[\int_eval:n{##1}, \int_eval:n{##2}] } } + \cs_set_protected:Npn \__regex_item_caseless_equal:n ##1 + { \__regex_show_one:n { char~code~\int_eval:n{##1}~(caseless) } } + \cs_set_protected:Npn \__regex_item_caseless_range:nn ##1##2 { - \regex_show_one:n + \__regex_show_one:n { Range~[\int_eval:n{##1}, \int_eval:n{##2}]~(caseless) } } - \cs_set_protected:Npn \regex_item_catcode:nT - { \regex_show_item_catcode:NnT \c_true_bool } - \cs_set_protected:Npn \regex_item_catcode_reverse:nT - { \regex_show_item_catcode:NnT \c_false_bool } - \cs_set_protected:Npn \regex_item_reverse:n - { \regex_show_scope:nn { Reversed~match } } - \cs_set_protected:Npn \regex_item_exact:nn ##1##2 - { \regex_show_one:n { char~##2,~catcode~##1 } } - \cs_set_protected:Npn \regex_item_exact_cs:c ##1 - { \regex_show_one:n { control~sequence~\iow_char:N\\##1 } } - \cs_set_protected:Npn \regex_item_cs:n - { \regex_show_scope:nn { control~sequence } } - \cs_set:cpn { regex_prop_.: } { \regex_show_one:n { any~token } } - \seq_clear:N \l_regex_show_prefix_seq - \regex_show_push:n { ~ } + \cs_set_protected:Npn \__regex_item_catcode:nT + { \__regex_show_item_catcode:NnT \c_true_bool } + \cs_set_protected:Npn \__regex_item_catcode_reverse:nT + { \__regex_show_item_catcode:NnT \c_false_bool } + \cs_set_protected:Npn \__regex_item_reverse:n + { \__regex_show_scope:nn { Reversed~match } } + \cs_set_protected:Npn \__regex_item_exact:nn ##1##2 + { \__regex_show_one:n { char~##2,~catcode~##1 } } + \cs_set_protected:Npn \__regex_item_exact_cs:c ##1 + { \__regex_show_one:n { control~sequence~\iow_char:N\\##1 } } + \cs_set_protected:Npn \__regex_item_cs:n + { \__regex_show_scope:nn { control~sequence } } + \cs_set:cpn { __regex_prop_.: } { \__regex_show_one:n { any~token } } + \seq_clear:N \l__regex_show_prefix_seq + \__regex_show_push:n { ~ } #1 - \tl_build_end: - \msg_aux_show:x { > Compiled~regex~#2: \l_regex_internal_a_tl } + \__tl_build_end: + \__msg_show_variable:x { > Compiled~regex~#2: \l__regex_internal_a_tl } } -\cs_new_protected:Npn \regex_show_one:n #1 +\cs_new_protected:Npn \__regex_show_one:n #1 { - \int_incr:N \l_regex_show_lines_int - \tl_build_one:x - { \iow_newline: \seq_use:N \l_regex_show_prefix_seq #1 } + \int_incr:N \l__regex_show_lines_int + \__tl_build_one:x + { + \iow_newline: + \seq_map_function:NN \l__regex_show_prefix_seq \use:n + #1 + } } -\cs_new_protected:Npn \regex_show_push:n #1 - { \seq_put_right:Nx \l_regex_show_prefix_seq { #1 ~ } } -\cs_new_protected:Npn \regex_show_pop: - { \seq_pop_right:NN \l_regex_show_prefix_seq \l_regex_internal_a_tl } -\cs_new_protected:Npn \regex_show_scope:nn #1#2 +\cs_new_protected:Npn \__regex_show_push:n #1 + { \seq_put_right:Nx \l__regex_show_prefix_seq { #1 ~ } } +\cs_new_protected:Npn \__regex_show_pop: + { \seq_pop_right:NN \l__regex_show_prefix_seq \l__regex_internal_a_tl } +\cs_new_protected:Npn \__regex_show_scope:nn #1#2 { - \regex_show_one:n {#1} - \regex_show_push:n { ~ } + \__regex_show_one:n {#1} + \__regex_show_push:n { ~ } #2 - \regex_show_pop: + \__regex_show_pop: } -\cs_new_protected:Npn \regex_show_group_aux:nnnnN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_show_group_aux:nnnnN #1#2#3#4#5 { - \regex_show_one:n { ,-group~begin #1 } - \regex_show_push:n { | } + \__regex_show_one:n { ,-group~begin #1 } + \__regex_show_push:n { | } \use_ii:nn #2 - \regex_show_pop: - \regex_show_one:n - { `-group~end \regex_msg_repeated:nnN {#3} {#4} #5 } + \__regex_show_pop: + \__regex_show_one:n + { `-group~end \__regex_msg_repeated:nnN {#3} {#4} #5 } } -\cs_set:Npn \regex_show_class:NnnnN #1#2#3#4#5 +\cs_set:Npn \__regex_show_class:NnnnN #1#2#3#4#5 { - \tl_set_build:Nw \l_regex_internal_a_tl - \int_zero:N \l_regex_show_lines_int - \regex_show_push:n {~} + \__tl_build:Nw \l__regex_internal_a_tl + \int_zero:N \l__regex_show_lines_int + \__regex_show_push:n {~} #2 \exp_last_unbraced:Nf - \prg_case_int:nnn { \l_regex_show_lines_int } + \int_case:nnn { \l__regex_show_lines_int } { {0} { - \tl_build_end: - \regex_show_one:n { \bool_if:NTF #1 { Fail } { Pass } } + \__tl_build_end: + \__regex_show_one:n { \bool_if:NTF #1 { Fail } { Pass } } } {1} { - \tl_build_end: + \__tl_build_end: \bool_if:NTF #1 { #2 - \tl_build_one:n { \regex_msg_repeated:nnN {#3} {#4} #5 } + \__tl_build_one:n { \__regex_msg_repeated:nnN {#3} {#4} #5 } } { - \regex_show_one:n - { Don't~match~\regex_msg_repeated:nnN {#3} {#4} #5 } - \tl_build_one:o \l_regex_internal_a_tl + \__regex_show_one:n + { Don't~match~\__regex_msg_repeated:nnN {#3} {#4} #5 } + \__tl_build_one:o \l__regex_internal_a_tl } } } { - \tl_build_end: - \regex_show_one:n + \__tl_build_end: + \__regex_show_one:n { \bool_if:NTF #1 { M } { Don't~m } atch - \regex_msg_repeated:nnN {#3} {#4} #5 + \__regex_msg_repeated:nnN {#3} {#4} #5 } - \tl_build_one:o \l_regex_internal_a_tl + \__tl_build_one:o \l__regex_internal_a_tl } } -\cs_new:Npn \regex_show_anchor_to_str:N #1 +\cs_new:Npn \__regex_show_anchor_to_str:N #1 { anchor~at~ - \prg_case_str:nnn { #1 } + \str_case:nnn { #1 } { - { \l_regex_min_pos_int } { start~(\iow_char:N\\A) } - { \l_regex_start_pos_int } { start~of~match~(\iow_char:N\\G) } - { \l_regex_max_pos_int } { end~(\iow_char:N\\Z) } + { \l__regex_min_pos_int } { start~(\iow_char:N\\A) } + { \l__regex_start_pos_int } { start~of~match~(\iow_char:N\\G) } + { \l__regex_max_pos_int } { end~(\iow_char:N\\Z) } } { <error:~'#1'~not~recognized> } } -\cs_new_protected:Npn \regex_show_item_catcode:NnT #1#2 +\cs_new_protected:Npn \__regex_show_item_catcode:NnT #1#2 { - \seq_set_split:Nnn \l_regex_internal_seq { } { CBEMTPUDSLOA } - \seq_set_filter:NNn \l_regex_internal_seq \l_regex_internal_seq - { \int_if_odd_p:n { #2 / \int_use:c { c_regex_catcode_##1_int } } } - \regex_show_scope:nn + \seq_set_split:Nnn \l__regex_internal_seq { } { CBEMTPUDSLOA } + \seq_set_filter:NNn \l__regex_internal_seq \l__regex_internal_seq + { \int_if_odd_p:n { #2 / \int_use:c { c__regex_catcode_##1_int } } } + \__regex_show_scope:nn { - categories~\seq_use:N \l_regex_internal_seq, ~ + categories~ + \seq_map_function:NN \l__regex_internal_seq \use:n + , ~ \bool_if:NF #1 { negative~ } class } } -\int_new:N \l_regex_min_state_int -\int_new:N \l_regex_max_state_int -\int_new:N \l_regex_left_state_int -\int_new:N \l_regex_right_state_int -\seq_new:N \l_regex_left_state_seq -\seq_new:N \l_regex_right_state_seq -\int_new:N \l_regex_capturing_group_int -\cs_new_protected:Npn \regex_build:n #1 +\int_new:N \l__regex_min_state_int +\int_new:N \l__regex_max_state_int +\int_new:N \l__regex_left_state_int +\int_new:N \l__regex_right_state_int +\seq_new:N \l__regex_left_state_seq +\seq_new:N \l__regex_right_state_seq +\int_new:N \l__regex_capturing_group_int +\cs_new_protected:Npn \__regex_build:n #1 { - \regex_compile:n {#1} - \regex_build:N \l_regex_internal_regex + \__regex_compile:n {#1} + \__regex_build:N \l__regex_internal_regex } -\cs_new_protected:Npn \regex_build:N #1 +\cs_new_protected:Npn \__regex_build:N #1 { - \trace_push:nnn { regex } { 1 } { regex_build } + \trace_push:nnn { regex } { 1 } { @@_build } \int_set:Nn \tex_escapechar:D { 92 } - \int_zero:N \l_regex_capturing_group_int - \int_set_eq:NN \l_regex_max_state_int \l_regex_min_state_int - \regex_build_new_state: - \regex_build_new_state: - \regex_toks_put_right:Nn \l_regex_left_state_int - { \regex_action_start_wildcard: } - \regex_group:nnnN {#1} { 1 } { 0 } \c_false_bool - \regex_toks_put_right:Nn \l_regex_right_state_int - { \regex_action_success: } - \regex_trace_states:n { 2 } - \trace_pop:nnn { regex } { 1 } { regex_build } - } -\cs_new_protected:Npn \regex_build_for_cs:n #1 - { - \trace_push:nnn { regex } { 1 } { regex_build_for_cs } - \int_set_eq:NN \l_regex_max_state_int \l_regex_min_state_int - \regex_build_new_state: - \regex_build_new_state: - \regex_push_lr_states: + \int_zero:N \l__regex_capturing_group_int + \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int + \__regex_build_new_state: + \__regex_build_new_state: + \__regex_toks_put_right:Nn \l__regex_left_state_int + { \__regex_action_start_wildcard: } + \__regex_group:nnnN {#1} { 1 } { 0 } \c_false_bool + \__regex_toks_put_right:Nn \l__regex_right_state_int + { \__regex_action_success: } + \@@_trace_states:n { 2 } + \trace_pop:nnn { regex } { 1 } { @@_build } + } +\cs_new_protected:Npn \__regex_build_for_cs:n #1 + { + \trace_push:nnn { regex } { 1 } { @@_build_for_cs } + \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int + \__regex_build_new_state: + \__regex_build_new_state: + \__regex_push_lr_states: #1 - \regex_pop_lr_states: - \regex_toks_put_right:Nn \l_regex_right_state_int + \__regex_pop_lr_states: + \__regex_toks_put_right:Nn \l__regex_right_state_int { - \if_num:w \l_regex_current_pos_int = \l_regex_max_pos_int - \exp_after:wN \regex_action_success: + \if_int_compare:w \l__regex_current_pos_int = \l__regex_max_pos_int + \exp_after:wN \__regex_action_success: \fi: } - \regex_trace_states:n { 2 } - \trace_pop:nnn { regex } { 1 } { regex_build_for_cs } + \@@_trace_states:n { 2 } + \trace_pop:nnn { regex } { 1 } { @@_build_for_cs } } -\cs_new_protected_nopar:Npn \regex_push_lr_states: +\cs_new_protected_nopar:Npn \__regex_push_lr_states: { - \seq_push:No \l_regex_left_state_seq - { \int_use:N \l_regex_left_state_int } - \seq_push:No \l_regex_right_state_seq - { \int_use:N \l_regex_right_state_int } + \seq_push:No \l__regex_left_state_seq + { \int_use:N \l__regex_left_state_int } + \seq_push:No \l__regex_right_state_seq + { \int_use:N \l__regex_right_state_int } } -\cs_new_protected_nopar:Npn \regex_pop_lr_states: +\cs_new_protected_nopar:Npn \__regex_pop_lr_states: { - \seq_pop:NN \l_regex_left_state_seq \l_regex_internal_a_tl - \int_set:Nn \l_regex_left_state_int \l_regex_internal_a_tl - \seq_pop:NN \l_regex_right_state_seq \l_regex_internal_a_tl - \int_set:Nn \l_regex_right_state_int \l_regex_internal_a_tl + \seq_pop:NN \l__regex_left_state_seq \l__regex_internal_a_tl + \int_set:Nn \l__regex_left_state_int \l__regex_internal_a_tl + \seq_pop:NN \l__regex_right_state_seq \l__regex_internal_a_tl + \int_set:Nn \l__regex_right_state_int \l__regex_internal_a_tl } -\cs_new_protected:Npn \regex_toks_put_left:Nx #1#2 +\cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 { - \cs_set_nopar:Npx \regex_tmp:w { #2 } + \cs_set_nopar:Npx \__regex_tmp:w { #2 } \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \regex_tmp:w \tex_the:D \tex_toks:D #1 } + { \exp_after:wN \__regex_tmp:w \tex_the:D \tex_toks:D #1 } } -\cs_new_protected:Npn \regex_toks_put_right:Nx #1#2 +\cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 { - \cs_set_nopar:Npx \regex_tmp:w {#2} + \cs_set_nopar:Npx \__regex_tmp:w {#2} \tex_toks:D #1 \exp_after:wN - { \tex_the:D \tex_toks:D \exp_after:wN #1 \regex_tmp:w } + { \tex_the:D \tex_toks:D \exp_after:wN #1 \__regex_tmp:w } } -\cs_new_protected:Npn \regex_toks_put_right:Nn #1#2 +\cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2 { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } } -\cs_new_protected:Npn \regex_build_transition_left:NNN #1#2#3 - { \regex_toks_put_left:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } -\cs_new_protected:Npn \regex_build_transition_right:nNn #1#2#3 - { \regex_toks_put_right:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } -\cs_new_protected_nopar:Npn \regex_build_new_state: +\cs_new_protected:Npn \__regex_build_transition_left:NNN #1#2#3 + { \__regex_toks_put_left:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } +\cs_new_protected:Npn \__regex_build_transition_right:nNn #1#2#3 + { \__regex_toks_put_right:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } +\cs_new_protected_nopar:Npn \__regex_build_new_state: { \trace:nnx { regex } { 2 } { regex~new~state~ - L=\int_use:N \l_regex_left_state_int ~ -> ~ - R=\int_use:N \l_regex_right_state_int ~ -> ~ - M=\int_use:N \l_regex_max_state_int ~ -> ~ - \int_eval:n { \l_regex_max_state_int + \c_one } + L=\int_use:N \l__regex_left_state_int ~ -> ~ + R=\int_use:N \l__regex_right_state_int ~ -> ~ + M=\int_use:N \l__regex_max_state_int ~ -> ~ + \int_eval:n { \l__regex_max_state_int + \c_one } } - \tex_toks:D \l_regex_max_state_int { } - \int_set_eq:NN \l_regex_left_state_int \l_regex_right_state_int - \int_set_eq:NN \l_regex_right_state_int \l_regex_max_state_int - \int_incr:N \l_regex_max_state_int + \tex_toks:D \l__regex_max_state_int { } + \int_set_eq:NN \l__regex_left_state_int \l__regex_right_state_int + \int_set_eq:NN \l__regex_right_state_int \l__regex_max_state_int + \int_incr:N \l__regex_max_state_int } -\cs_new_protected:Npn \regex_build_transitions_lazyness:NNNNN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_build_transitions_lazyness:NNNNN #1#2#3#4#5 { - \regex_build_new_state: - \regex_toks_put_right:Nx \l_regex_left_state_int + \__regex_build_new_state: + \__regex_toks_put_right:Nx \l__regex_left_state_int { \if_meaning:w \c_true_bool #1 - #2 { \int_eval:n { #3 - \l_regex_left_state_int } } - #4 { \int_eval:n { #5 - \l_regex_left_state_int } } + #2 { \int_eval:n { #3 - \l__regex_left_state_int } } + #4 { \int_eval:n { #5 - \l__regex_left_state_int } } \else: - #4 { \int_eval:n { #5 - \l_regex_left_state_int } } - #2 { \int_eval:n { #3 - \l_regex_left_state_int } } + #4 { \int_eval:n { #5 - \l__regex_left_state_int } } + #2 { \int_eval:n { #3 - \l__regex_left_state_int } } \fi: } } -\cs_new_protected:Npn \regex_class:NnnnN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_class:NnnnN #1#2#3#4#5 { - \cs_set_nopar:Npx \regex_tests_action_cost:n ##1 + \cs_set_nopar:Npx \__regex_tests_action_cost:n ##1 { \exp_not:n { \exp_not:n {#2} } \bool_if:NTF #1 - { \regex_break_point:TF { \regex_action_cost:n {##1} } { } } - { \regex_break_point:TF { } { \regex_action_cost:n {##1} } } + { \__regex_break_point:TF { \__regex_action_cost:n {##1} } { } } + { \__regex_break_point:TF { } { \__regex_action_cost:n {##1} } } } \if_case:w - #4 \exp_stop_f: - \regex_class_repeat:n {#3} - \or: \regex_class_repeat:nN {#3} #5 - \else: \regex_class_repeat:nnN {#3} {#4} #5 + \__regex_class_repeat:n {#3} + \or: \__regex_class_repeat:nN {#3} #5 + \else: \__regex_class_repeat:nnN {#3} {#4} #5 \fi: } -\cs_new:Npn \regex_tests_action_cost:n { \regex_action_cost:n } -\cs_new_protected:Npn \regex_class_repeat:n #1 +\cs_new:Npn \__regex_tests_action_cost:n { \__regex_action_cost:n } +\cs_new_protected:Npn \__regex_class_repeat:n #1 { \prg_replicate:nn {#1} { - \regex_build_new_state: - \regex_build_transition_right:nNn \regex_tests_action_cost:n - \l_regex_left_state_int \l_regex_right_state_int + \__regex_build_new_state: + \__regex_build_transition_right:nNn \__regex_tests_action_cost:n + \l__regex_left_state_int \l__regex_right_state_int } } -\cs_new_protected:Npn \regex_class_repeat:nN #1#2 +\cs_new_protected:Npn \__regex_class_repeat:nN #1#2 { - \if_num:w #1 = \c_zero - \regex_build_transitions_lazyness:NNNNN #2 - \regex_action_free:n \l_regex_right_state_int - \regex_tests_action_cost:n \l_regex_left_state_int + \if_int_compare:w #1 = \c_zero + \__regex_build_transitions_lazyness:NNNNN #2 + \__regex_action_free:n \l__regex_right_state_int + \__regex_tests_action_cost:n \l__regex_left_state_int \else: - \regex_class_repeat:n {#1} - \int_set_eq:NN \l_regex_internal_a_int \l_regex_left_state_int - \regex_build_transitions_lazyness:NNNNN #2 - \regex_action_free:n \l_regex_right_state_int - \regex_action_free:n \l_regex_internal_a_int + \__regex_class_repeat:n {#1} + \int_set_eq:NN \l__regex_internal_a_int \l__regex_left_state_int + \__regex_build_transitions_lazyness:NNNNN #2 + \__regex_action_free:n \l__regex_right_state_int + \__regex_action_free:n \l__regex_internal_a_int \fi: } -\cs_new_protected:Npn \regex_class_repeat:nnN #1#2#3 +\cs_new_protected:Npn \__regex_class_repeat:nnN #1#2#3 { - \regex_class_repeat:n {#1} - \int_set:Nn \l_regex_internal_a_int - { \l_regex_max_state_int + #2 - \c_one } + \__regex_class_repeat:n {#1} + \int_set:Nn \l__regex_internal_a_int + { \l__regex_max_state_int + #2 - \c_one } \prg_replicate:nn { #2 } { - \regex_build_transitions_lazyness:NNNNN #3 - \regex_action_free:n \l_regex_internal_a_int - \regex_tests_action_cost:n \l_regex_right_state_int + \__regex_build_transitions_lazyness:NNNNN #3 + \__regex_action_free:n \l__regex_internal_a_int + \__regex_tests_action_cost:n \l__regex_right_state_int } } -\cs_new_protected:Npn \regex_group_aux:nnnnN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_group_aux:nnnnN #1#2#3#4#5 { - \trace_push:nnn { regex } { 1 } { regex_group } - \if_num:w #3 = \c_zero - \regex_build_new_state: - \regex_build_transition_right:nNn \regex_action_free_group:n - \l_regex_left_state_int \l_regex_right_state_int + \trace_push:nnn { regex } { 1 } { @@_group } + \if_int_compare:w #3 = \c_zero + \__regex_build_new_state: + \__regex_build_transition_right:nNn \__regex_action_free_group:n + \l__regex_left_state_int \l__regex_right_state_int \fi: - \regex_build_new_state: - \regex_push_lr_states: + \__regex_build_new_state: + \__regex_push_lr_states: #2 - \regex_pop_lr_states: + \__regex_pop_lr_states: \if_case:w - #4 \exp_stop_f: - \regex_group_repeat:nn {#1} {#3} - \or: \regex_group_repeat:nnN {#1} {#3} #5 - \else: \regex_group_repeat:nnnN {#1} {#3} {#4} #5 + \__regex_group_repeat:nn {#1} {#3} + \or: \__regex_group_repeat:nnN {#1} {#3} #5 + \else: \__regex_group_repeat:nnnN {#1} {#3} {#4} #5 \fi: - \trace_pop:nnn { regex } { 1 } { regex_group } + \trace_pop:nnn { regex } { 1 } { @@_group } } -\cs_new_protected:Npn \regex_group:nnnN #1 +\cs_new_protected:Npn \__regex_group:nnnN #1 { - \exp_args:No \regex_group_aux:nnnnN - { \int_use:N \l_regex_capturing_group_int } + \exp_args:No \__regex_group_aux:nnnnN + { \int_use:N \l__regex_capturing_group_int } { - \int_incr:N \l_regex_capturing_group_int + \int_incr:N \l__regex_capturing_group_int #1 } } -\cs_new_protected_nopar:Npn \regex_group_no_capture:nnnN - { \regex_group_aux:nnnnN { -1 } } -\cs_new_protected:Npn \regex_group_resetting:nnnN #1 +\cs_new_protected_nopar:Npn \__regex_group_no_capture:nnnN + { \__regex_group_aux:nnnnN { -1 } } +\cs_new_protected:Npn \__regex_group_resetting:nnnN #1 { - \regex_group_aux:nnnnN { -1 } + \__regex_group_aux:nnnnN { -1 } { - \exp_args:Noo \regex_group_resetting_loop:nnNn - { \int_use:N \l_regex_capturing_group_int } - { \int_use:N \l_regex_capturing_group_int } + \exp_args:Noo \__regex_group_resetting_loop:nnNn + { \int_use:N \l__regex_capturing_group_int } + { \int_use:N \l__regex_capturing_group_int } #1 - { ?? \prg_map_break:n } { } - \prg_break_point:n { } + { ?? \__prg_break:n } { } + \__prg_break_point: } } -\cs_new_protected:Npn \regex_group_resetting_loop:nnNn #1#2#3#4 +\cs_new_protected:Npn \__regex_group_resetting_loop:nnNn #1#2#3#4 { - \use_none:nn #3 { \int_set:Nn \l_regex_capturing_group_int {#1} } - \int_set:Nn \l_regex_capturing_group_int {#2} + \use_none:nn #3 { \int_set:Nn \l__regex_capturing_group_int {#1} } + \int_set:Nn \l__regex_capturing_group_int {#2} #3 {#4} - \exp_args:Nf \regex_group_resetting_loop:nnNn - { \int_max:nn {#1} { \l_regex_capturing_group_int } } + \exp_args:Nf \__regex_group_resetting_loop:nnNn + { \int_max:nn {#1} { \l__regex_capturing_group_int } } {#2} } -\cs_new_protected:Npn \regex_branch:n #1 +\cs_new_protected:Npn \__regex_branch:n #1 { - \trace_push:nnn { regex } { 1 } { regex_branch } - \regex_build_new_state: - \seq_get:NN \l_regex_left_state_seq \l_regex_internal_a_tl - \int_set:Nn \l_regex_left_state_int \l_regex_internal_a_tl - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_left_state_int \l_regex_right_state_int + \trace_push:nnn { regex } { 1 } { @@_branch } + \__regex_build_new_state: + \seq_get:NN \l__regex_left_state_seq \l__regex_internal_a_tl + \int_set:Nn \l__regex_left_state_int \l__regex_internal_a_tl + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_left_state_int \l__regex_right_state_int #1 - \seq_get:NN \l_regex_right_state_seq \l_regex_internal_a_tl - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_internal_a_tl - \trace_pop:nnn { regex } { 1 } { regex_branch } + \seq_get:NN \l__regex_right_state_seq \l__regex_internal_a_tl + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_internal_a_tl + \trace_pop:nnn { regex } { 1 } { @@_branch } } -\cs_new_protected:Npn \regex_group_repeat:nn #1#2 +\cs_new_protected:Npn \__regex_group_repeat:nn #1#2 { - \if_num:w #2 = \c_zero - \int_set:Nn \l_regex_max_state_int - { \l_regex_left_state_int - \c_one } - \regex_build_new_state: + \if_int_compare:w #2 = \c_zero + \int_set:Nn \l__regex_max_state_int + { \l__regex_left_state_int - \c_one } + \__regex_build_new_state: \else: - \regex_group_repeat_aux:n {#2} - \regex_group_submatches:nNN {#1} - \l_regex_internal_a_int \l_regex_right_state_int - \regex_build_new_state: + \__regex_group_repeat_aux:n {#2} + \__regex_group_submatches:nNN {#1} + \l__regex_internal_a_int \l__regex_right_state_int + \__regex_build_new_state: \fi: } -\cs_new_protected:Npn \regex_group_submatches:nNN #1#2#3 +\cs_new_protected:Npn \__regex_group_submatches:nNN #1#2#3 { - \if_num:w #1 > \c_minus_one - \regex_toks_put_left:Nx #2 { \regex_action_submatch:n { #1 < } } - \regex_toks_put_left:Nx #3 { \regex_action_submatch:n { #1 > } } + \if_int_compare:w #1 > \c_minus_one + \__regex_toks_put_left:Nx #2 { \__regex_action_submatch:n { #1 < } } + \__regex_toks_put_left:Nx #3 { \__regex_action_submatch:n { #1 > } } \fi: } -\cs_new_protected:Npn \regex_group_repeat_aux:n #1 +\cs_new_protected:Npn \__regex_group_repeat_aux:n #1 { - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_max_state_int - \int_set_eq:NN \l_regex_internal_a_int \l_regex_left_state_int - \int_set_eq:NN \l_regex_internal_b_int \l_regex_max_state_int - \if_num:w \int_eval:w #1 > \c_one - \int_set:Nn \l_regex_internal_c_int + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_max_state_int + \int_set_eq:NN \l__regex_internal_a_int \l__regex_left_state_int + \int_set_eq:NN \l__regex_internal_b_int \l__regex_max_state_int + \if_int_compare:w \__int_eval:w #1 > \c_one + \int_set:Nn \l__regex_internal_c_int { ( #1 - \c_one ) - * ( \l_regex_internal_b_int - \l_regex_internal_a_int ) + * ( \l__regex_internal_b_int - \l__regex_internal_a_int ) } - \tex_advance:D \l_regex_right_state_int \l_regex_internal_c_int - \tex_advance:D \l_regex_max_state_int \l_regex_internal_c_int - \prg_replicate:nn \l_regex_internal_c_int + \tex_advance:D \l__regex_right_state_int \l__regex_internal_c_int + \tex_advance:D \l__regex_max_state_int \l__regex_internal_c_int + \prg_replicate:nn \l__regex_internal_c_int { - \tex_toks:D \l_regex_internal_b_int - = \tex_toks:D \l_regex_internal_a_int - \tex_advance:D \l_regex_internal_a_int \c_one - \tex_advance:D \l_regex_internal_b_int \c_one + \tex_toks:D \l__regex_internal_b_int + = \tex_toks:D \l__regex_internal_a_int + \tex_advance:D \l__regex_internal_a_int \c_one + \tex_advance:D \l__regex_internal_b_int \c_one } \fi: } -\cs_new_protected:Npn \regex_group_repeat:nnN #1#2#3 +\cs_new_protected:Npn \__regex_group_repeat:nnN #1#2#3 { - \if_num:w #2 = \c_zero - \regex_group_submatches:nNN {#1} - \l_regex_left_state_int \l_regex_right_state_int - \int_set:Nn \l_regex_internal_a_int - { \l_regex_left_state_int - \c_one } - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_internal_a_int - \regex_build_new_state: + \if_int_compare:w #2 = \c_zero + \__regex_group_submatches:nNN {#1} + \l__regex_left_state_int \l__regex_right_state_int + \int_set:Nn \l__regex_internal_a_int + { \l__regex_left_state_int - \c_one } + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_internal_a_int + \__regex_build_new_state: \if_meaning:w \c_true_bool #3 - \regex_build_transition_left:NNN \regex_action_free:n - \l_regex_internal_a_int \l_regex_right_state_int + \__regex_build_transition_left:NNN \__regex_action_free:n + \l__regex_internal_a_int \l__regex_right_state_int \else: - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_internal_a_int \l_regex_right_state_int + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_internal_a_int \l__regex_right_state_int \fi: \else: - \regex_group_repeat_aux:n {#2} - \regex_group_submatches:nNN {#1} - \l_regex_internal_a_int \l_regex_right_state_int + \__regex_group_repeat_aux:n {#2} + \__regex_group_submatches:nNN {#1} + \l__regex_internal_a_int \l__regex_right_state_int \if_meaning:w \c_true_bool #3 - \regex_build_transition_right:nNn \regex_action_free_group:n - \l_regex_right_state_int \l_regex_internal_a_int + \__regex_build_transition_right:nNn \__regex_action_free_group:n + \l__regex_right_state_int \l__regex_internal_a_int \else: - \regex_build_transition_left:NNN \regex_action_free_group:n - \l_regex_right_state_int \l_regex_internal_a_int + \__regex_build_transition_left:NNN \__regex_action_free_group:n + \l__regex_right_state_int \l__regex_internal_a_int \fi: - \regex_build_new_state: + \__regex_build_new_state: \fi: } -\cs_new_protected:Npn \regex_group_repeat:nnnN #1#2#3#4 +\cs_new_protected:Npn \__regex_group_repeat:nnnN #1#2#3#4 { - \regex_group_submatches:nNN {#1} - \l_regex_left_state_int \l_regex_right_state_int - \regex_group_repeat_aux:n { #2 + #3 } + \__regex_group_submatches:nNN {#1} + \l__regex_left_state_int \l__regex_right_state_int + \__regex_group_repeat_aux:n { #2 + #3 } \if_meaning:w \c_true_bool #4 - \int_set_eq:NN \l_regex_left_state_int \l_regex_max_state_int + \int_set_eq:NN \l__regex_left_state_int \l__regex_max_state_int \prg_replicate:nn { #3 } { - \int_sub:Nn \l_regex_left_state_int - { \l_regex_internal_b_int - \l_regex_internal_a_int } - \regex_build_transition_left:NNN \regex_action_free:n - \l_regex_left_state_int \l_regex_max_state_int + \int_sub:Nn \l__regex_left_state_int + { \l__regex_internal_b_int - \l__regex_internal_a_int } + \__regex_build_transition_left:NNN \__regex_action_free:n + \l__regex_left_state_int \l__regex_max_state_int } \else: \prg_replicate:nn { #3 - \c_one } { - \int_sub:Nn \l_regex_right_state_int - { \l_regex_internal_b_int - \l_regex_internal_a_int } - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_max_state_int + \int_sub:Nn \l__regex_right_state_int + { \l__regex_internal_b_int - \l__regex_internal_a_int } + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_max_state_int } - \if_num:w #2 = \c_zero - \int_set:Nn \l_regex_right_state_int - { \l_regex_left_state_int - \c_one } + \if_int_compare:w #2 = \c_zero + \int_set:Nn \l__regex_right_state_int + { \l__regex_left_state_int - \c_one } \else: - \int_sub:Nn \l_regex_right_state_int - { \l_regex_internal_b_int - \l_regex_internal_a_int } + \int_sub:Nn \l__regex_right_state_int + { \l__regex_internal_b_int - \l__regex_internal_a_int } \fi: - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_max_state_int + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_max_state_int \fi: - \regex_build_new_state: + \__regex_build_new_state: } -\cs_new_protected:Npn \regex_assertion:Nn #1#2 +\cs_new_protected:Npn \__regex_assertion:Nn #1#2 { - \regex_build_new_state: - \regex_toks_put_right:Nx \l_regex_left_state_int + \__regex_build_new_state: + \__regex_toks_put_right:Nx \l__regex_left_state_int { \exp_not:n {#2} - \regex_break_point:TF + \__regex_break_point:TF \bool_if:NF #1 { { } } { - \regex_action_free:n + \__regex_action_free:n { \int_eval:n - { \l_regex_right_state_int - \l_regex_left_state_int } + { \l__regex_right_state_int - \l__regex_left_state_int } } } \bool_if:NT #1 { { } } } } -\cs_new_protected:Npn \regex_anchor:N #1 +\cs_new_protected:Npn \__regex_anchor:N #1 { - \if_num:w #1 = \l_regex_current_pos_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_pos_int + \exp_after:wN \__regex_break_true:w \fi: } -\cs_new_protected_nopar:Npn \regex_b_test: +\cs_new_protected_nopar:Npn \__regex_b_test: { \group_begin: - \int_set_eq:NN \l_regex_current_char_int \l_regex_last_char_int - \regex_prop_w: - \regex_break_point:TF - { \group_end: \regex_item_reverse:n \regex_prop_w: } - { \group_end: \regex_prop_w: } - } -\cs_new_protected_nopar:Npn \regex_command_K: - { - \regex_build_new_state: - \regex_toks_put_right:Nx \l_regex_left_state_int - { - \regex_action_submatch:n { 0< } - \bool_set_true:N \l_regex_fresh_thread_bool - \regex_action_free:n - { \int_eval:n { \l_regex_right_state_int - \l_regex_left_state_int } } - \bool_set_false:N \l_regex_fresh_thread_bool - } - } -\int_new:N \l_regex_min_pos_int -\int_new:N \l_regex_max_pos_int -\int_new:N \l_regex_current_pos_int -\int_new:N \l_regex_start_pos_int -\int_new:N \l_regex_success_pos_int -\int_new:N \l_regex_current_char_int -\int_new:N \l_regex_current_catcode_int -\int_new:N \l_regex_last_char_int -\int_new:N \l_regex_case_changed_char_int -\int_new:N \l_regex_current_state_int -\prop_new:N \l_regex_current_submatches_prop -\prop_new:N \l_regex_success_submatches_prop -\int_new:N \l_regex_step_int -\int_new:N \l_regex_min_active_int -\int_new:N \l_regex_max_active_int -\tl_new:N \l_regex_every_match_tl -\bool_new:N \l_regex_fresh_thread_bool -\bool_new:N \l_regex_empty_success_bool -\cs_new_eq:NN \regex_if_two_empty_matches:F \use:n -\bool_new:N \g_regex_success_bool -\bool_new:N \l_regex_saved_success_bool -\bool_new:N \l_regex_match_success_bool -\cs_new_protected:Npn \regex_match:n #1 - { - \trace_push:nnx { regex } { 1 } { regex_match } + \int_set_eq:NN \l__regex_current_char_int \l__regex_last_char_int + \__regex_prop_w: + \__regex_break_point:TF + { \group_end: \__regex_item_reverse:n \__regex_prop_w: } + { \group_end: \__regex_prop_w: } + } +\cs_new_protected_nopar:Npn \__regex_command_K: + { + \__regex_build_new_state: + \__regex_toks_put_right:Nx \l__regex_left_state_int + { + \__regex_action_submatch:n { 0< } + \bool_set_true:N \l__regex_fresh_thread_bool + \__regex_action_free:n + { \int_eval:n { \l__regex_right_state_int - \l__regex_left_state_int } } + \bool_set_false:N \l__regex_fresh_thread_bool + } + } +\int_new:N \l__regex_min_pos_int +\int_new:N \l__regex_max_pos_int +\int_new:N \l__regex_current_pos_int +\int_new:N \l__regex_start_pos_int +\int_new:N \l__regex_success_pos_int +\int_new:N \l__regex_current_char_int +\int_new:N \l__regex_current_catcode_int +\int_new:N \l__regex_last_char_int +\int_new:N \l__regex_case_changed_char_int +\int_new:N \l__regex_current_state_int +\prop_new:N \l__regex_current_submatches_prop +\prop_new:N \l__regex_success_submatches_prop +\int_new:N \l__regex_step_int +\int_new:N \l__regex_min_active_int +\int_new:N \l__regex_max_active_int +\tl_new:N \l__regex_every_match_tl +\bool_new:N \l__regex_fresh_thread_bool +\bool_new:N \l__regex_empty_success_bool +\cs_new_eq:NN \__regex_if_two_empty_matches:F \use:n +\bool_new:N \g__regex_success_bool +\bool_new:N \l__regex_saved_success_bool +\bool_new:N \l__regex_match_success_bool +\cs_new_protected:Npn \__regex_match:n #1 + { + \trace_push:nnx { regex } { 1 } { @@_match } \trace:nnx { regex } { 1 } { analyzing~query~token~list } - \int_zero:N \l_regex_balance_int - \int_set:Nn \l_regex_current_pos_int { \c_two * \l_regex_max_state_int } - \regex_query_set:nnn { } { -1 } { -2 } - \int_set_eq:NN \l_regex_min_pos_int \l_regex_current_pos_int - \tl_analysis_map_inline:nn {#1} - { \regex_query_set:nnn {##1} {"##2} {##3} } - \int_set_eq:NN \l_regex_max_pos_int \l_regex_current_pos_int - \regex_query_set:nnn { } { -1 } { -2 } + \int_zero:N \l__regex_balance_int + \int_set:Nn \l__regex_current_pos_int { \c_two * \l__regex_max_state_int } + \__regex_query_set:nnn { } { -1 } { -2 } + \int_set_eq:NN \l__regex_min_pos_int \l__regex_current_pos_int + \__tl_analysis_map_inline:nn {#1} + { \__regex_query_set:nnn {##1} {"##2} {##3} } + \int_set_eq:NN \l__regex_max_pos_int \l__regex_current_pos_int + \__regex_query_set:nnn { } { -1 } { -2 } \trace:nnx { regex } { 1 } { initializing } - \bool_gset_false:N \g_regex_success_bool - \prg_stepwise_inline:nnnn - \l_regex_min_state_int \c_one { \l_regex_max_state_int - \c_one } + \bool_gset_false:N \g__regex_success_bool + \int_step_inline:nnnn + \l__regex_min_state_int \c_one { \l__regex_max_state_int - \c_one } { \tex_dimen:D ##1 \c_one sp \scan_stop: } - \int_set_eq:NN \l_regex_min_active_int \l_regex_max_state_int - \int_set_eq:NN \l_regex_step_int \c_zero - \int_set_eq:NN \l_regex_success_pos_int \l_regex_min_pos_int - \int_set:Nn \l_regex_submatch_int - { \c_two * \l_regex_max_state_int } - \bool_set_false:N \l_regex_empty_success_bool - \regex_match_once: - \trace_pop:nnx { regex } { 1 } { regex_match } - } -\cs_new_protected_nopar:Npn \regex_match_once: - { - \if_meaning:w \c_true_bool \l_regex_empty_success_bool - \cs_set_nopar:Npn \regex_if_two_empty_matches:F - { \int_compare:nNnF \l_regex_start_pos_int = \l_regex_current_pos_int } + \int_set_eq:NN \l__regex_min_active_int \l__regex_max_state_int + \int_set_eq:NN \l__regex_step_int \c_zero + \int_set_eq:NN \l__regex_success_pos_int \l__regex_min_pos_int + \int_set:Nn \l__regex_submatch_int + { \c_two * \l__regex_max_state_int } + \bool_set_false:N \l__regex_empty_success_bool + \__regex_match_once: + \trace_pop:nnx { regex } { 1 } { @@_match } + } +\cs_new_protected_nopar:Npn \__regex_match_once: + { + \if_meaning:w \c_true_bool \l__regex_empty_success_bool + \cs_set_nopar:Npn \__regex_if_two_empty_matches:F + { \int_compare:nNnF \l__regex_start_pos_int = \l__regex_current_pos_int } \else: - \cs_set_eq:NN \regex_if_two_empty_matches:F \use:n + \cs_set_eq:NN \__regex_if_two_empty_matches:F \use:n \fi: - \int_set_eq:NN \l_regex_start_pos_int \l_regex_success_pos_int - \bool_set_false:N \l_regex_match_success_bool - \prop_clear:N \l_regex_current_submatches_prop - \int_set_eq:NN \l_regex_max_active_int \l_regex_min_active_int - \regex_store_state:n { \l_regex_min_state_int } - \int_set:Nn \l_regex_current_pos_int - { \l_regex_start_pos_int - \c_one } - \regex_query_get: - \regex_match_loop: - \l_regex_every_match_tl + \int_set_eq:NN \l__regex_start_pos_int \l__regex_success_pos_int + \bool_set_false:N \l__regex_match_success_bool + \prop_clear:N \l__regex_current_submatches_prop + \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int + \__regex_store_state:n { \l__regex_min_state_int } + \int_set:Nn \l__regex_current_pos_int + { \l__regex_start_pos_int - \c_one } + \__regex_query_get: + \__regex_match_loop: + \l__regex_every_match_tl } -\cs_new_protected_nopar:Npn \regex_single_match: +\cs_new_protected_nopar:Npn \__regex_single_match: { - \tl_set:Nn \l_regex_every_match_tl - { \bool_gset_eq:NN \g_regex_success_bool \l_regex_match_success_bool } + \tl_set:Nn \l__regex_every_match_tl + { \bool_gset_eq:NN \g__regex_success_bool \l__regex_match_success_bool } } -\cs_new_protected:Npn \regex_multi_match:n #1 +\cs_new_protected:Npn \__regex_multi_match:n #1 { - \tl_set:Nn \l_regex_every_match_tl + \tl_set:Nn \l__regex_every_match_tl { - \if_meaning:w \c_true_bool \l_regex_match_success_bool - \bool_gset_true:N \g_regex_success_bool + \if_meaning:w \c_true_bool \l__regex_match_success_bool + \bool_gset_true:N \g__regex_success_bool #1 - \exp_after:wN \regex_match_once: + \exp_after:wN \__regex_match_once: \fi: } } -\cs_new_protected_nopar:Npn \regex_match_loop: +\cs_new_protected_nopar:Npn \__regex_match_loop: { - \tex_advance:D \l_regex_step_int \c_two - \int_incr:N \l_regex_current_pos_int - \int_set_eq:NN \l_regex_last_char_int \l_regex_current_char_int - \int_set_eq:NN \l_regex_case_changed_char_int \c_max_int - \regex_query_get: + \tex_advance:D \l__regex_step_int \c_two + \int_incr:N \l__regex_current_pos_int + \int_set_eq:NN \l__regex_last_char_int \l__regex_current_char_int + \int_set_eq:NN \l__regex_case_changed_char_int \c_max_int + \__regex_query_get: \use:x { - \int_set_eq:NN \l_regex_max_active_int \l_regex_min_active_int - \exp_after:wN \regex_match_one_active:w - \int_use:N \l_regex_min_active_int ; + \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int + \exp_after:wN \__regex_match_one_active:w + \int_use:N \l__regex_min_active_int ; } - \prg_break_point:n { \bool_set_false:N \l_regex_fresh_thread_bool } - \if_num:w \l_regex_max_active_int > \l_regex_min_active_int - \if_num:w \l_regex_current_pos_int < \l_regex_max_pos_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_match_loop: + \__prg_break_point: + \bool_set_false:N \l__regex_fresh_thread_bool %^^A was arg of break_point:n + \if_int_compare:w \l__regex_max_active_int > \l__regex_min_active_int + \if_int_compare:w \l__regex_current_pos_int < \l__regex_max_pos_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_match_loop: \fi: \fi: } -\cs_new:Npn \regex_match_one_active:w #1; +\cs_new:Npn \__regex_match_one_active:w #1; { - \if_num:w #1 < \l_regex_max_active_int - \regex_use_state_and_submatches:nn - { \int_value:w \tex_skip:D #1 } + \if_int_compare:w #1 < \l__regex_max_active_int + \__regex_use_state_and_submatches:nn + { \__int_value:w \tex_skip:D #1 } { \tex_the:D \tex_toks:D #1 } - \exp_after:wN \regex_match_one_active:w - \int_use:N \int_eval:w #1 + \c_one \exp_after:wN ; + \exp_after:wN \__regex_match_one_active:w + \int_use:N \__int_eval:w #1 + \c_one \exp_after:wN ; \fi: } -\cs_new_protected:Npn \regex_query_set:nnn #1#2#3 +\cs_new_protected:Npn \__regex_query_set:nnn #1#2#3 { - \tex_muskip:D \l_regex_current_pos_int + \tex_muskip:D \l__regex_current_pos_int = \etex_gluetomu:D #3 sp plus #2 sp - minus \l_regex_balance_int sp + minus \l__regex_balance_int sp \scan_stop: - \tex_toks:D \l_regex_current_pos_int {#1} - \int_incr:N \l_regex_current_pos_int + \tex_toks:D \l__regex_current_pos_int {#1} + \int_incr:N \l__regex_current_pos_int \if_case:w #2 \exp_stop_f: - \or: \int_incr:N \l_regex_balance_int - \or: \int_decr:N \l_regex_balance_int + \or: \int_incr:N \l__regex_balance_int + \or: \int_decr:N \l__regex_balance_int \fi: } -\cs_new_protected_nopar:Npn \regex_query_get: +\cs_new_protected_nopar:Npn \__regex_query_get: { - \l_regex_current_char_int - = \etex_mutoglue:D \tex_muskip:D \l_regex_current_pos_int - \l_regex_current_catcode_int = \etex_gluestretch:D - \etex_mutoglue:D \tex_muskip:D \l_regex_current_pos_int + \l__regex_current_char_int + = \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int + \l__regex_current_catcode_int = \etex_gluestretch:D + \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int } -\cs_new_protected_nopar:Npn \regex_use_state: +\cs_new_protected_nopar:Npn \__regex_use_state: { - \trace:nnx { regex } { 2 } { state~\int_use:N \l_regex_current_state_int } - \tex_dimen:D \l_regex_current_state_int - = \l_regex_step_int sp \scan_stop: - \tex_the:D \tex_toks:D \l_regex_current_state_int - \tex_dimen:D \l_regex_current_state_int - = \int_eval:w \l_regex_step_int + \c_one \int_eval_end: sp \scan_stop: + \trace:nnx { regex } { 2 } { state~\int_use:N \l__regex_current_state_int } + \tex_dimen:D \l__regex_current_state_int + = \l__regex_step_int sp \scan_stop: + \tex_the:D \tex_toks:D \l__regex_current_state_int + \tex_dimen:D \l__regex_current_state_int + = \__int_eval:w \l__regex_step_int + \c_one \__int_eval_end: sp \scan_stop: } -\cs_new_protected:Npn \regex_use_state_and_submatches:nn #1 #2 +\cs_new_protected:Npn \__regex_use_state_and_submatches:nn #1 #2 { - \int_set:Nn \l_regex_current_state_int {#1} - \if_num:w \tex_dimen:D \l_regex_current_state_int < \l_regex_step_int - \tl_set:Nn \l_regex_current_submatches_prop {#2} - \exp_after:wN \regex_use_state: + \int_set:Nn \l__regex_current_state_int {#1} + \if_int_compare:w \tex_dimen:D \l__regex_current_state_int + < \l__regex_step_int + \tl_set:Nn \l__regex_current_submatches_prop {#2} + \exp_after:wN \__regex_use_state: \fi: \scan_stop: } -\cs_new_protected_nopar:Npn \regex_action_start_wildcard: +\cs_new_protected_nopar:Npn \__regex_action_start_wildcard: { - \bool_set_true:N \l_regex_fresh_thread_bool - \regex_action_free:n {1} - \bool_set_false:N \l_regex_fresh_thread_bool - \regex_action_cost:n {0} + \bool_set_true:N \l__regex_fresh_thread_bool + \__regex_action_free:n {1} + \bool_set_false:N \l__regex_fresh_thread_bool + \__regex_action_cost:n {0} } -\cs_new_protected_nopar:Npn \regex_action_free:n - { \regex_action_free_aux:nn { > \l_regex_step_int \else: } } -\cs_new_protected_nopar:Npn \regex_action_free_group:n - { \regex_action_free_aux:nn { < \l_regex_step_int } } -\cs_new_protected:Npn \regex_action_free_aux:nn #1#2 +\cs_new_protected_nopar:Npn \__regex_action_free:n + { \__regex_action_free_aux:nn { > \l__regex_step_int \else: } } +\cs_new_protected_nopar:Npn \__regex_action_free_group:n + { \__regex_action_free_aux:nn { < \l__regex_step_int } } +\cs_new_protected:Npn \__regex_action_free_aux:nn #1#2 { \use:x { - \int_add:Nn \l_regex_current_state_int {#2} + \int_add:Nn \l__regex_current_state_int {#2} \exp_not:n { - \if_num:w \tex_dimen:D \l_regex_current_state_int #1 - \exp_after:wN \regex_use_state: + \if_int_compare:w \tex_dimen:D \l__regex_current_state_int #1 + \exp_after:wN \__regex_use_state: \fi: } - \int_set:Nn \l_regex_current_state_int - { \int_use:N \l_regex_current_state_int } - \tl_set:Nn \exp_not:N \l_regex_current_submatches_prop - { \exp_not:o \l_regex_current_submatches_prop } + \int_set:Nn \l__regex_current_state_int + { \int_use:N \l__regex_current_state_int } + \tl_set:Nn \exp_not:N \l__regex_current_submatches_prop + { \exp_not:o \l__regex_current_submatches_prop } } } -\cs_new_protected:Npn \regex_action_cost:n #1 +\cs_new_protected:Npn \__regex_action_cost:n #1 { - \exp_args:No \regex_store_state:n - { \int_use:N \int_eval:w \l_regex_current_state_int + #1 } + \exp_args:No \__regex_store_state:n + { \int_use:N \__int_eval:w \l__regex_current_state_int + #1 } } -\cs_new_protected:Npn \regex_store_state:n #1 +\cs_new_protected:Npn \__regex_store_state:n #1 { - \regex_store_submatches: - \tex_skip:D \l_regex_max_active_int = #1 sp \scan_stop: - \int_incr:N \l_regex_max_active_int + \__regex_store_submatches: + \tex_skip:D \l__regex_max_active_int = #1 sp \scan_stop: + \int_incr:N \l__regex_max_active_int } -\cs_new_protected_nopar:Npn \regex_store_submatches: +\cs_new_protected_nopar:Npn \__regex_store_submatches: { - \tex_toks:D \l_regex_max_active_int \exp_after:wN - { \l_regex_current_submatches_prop } + \tex_toks:D \l__regex_max_active_int \exp_after:wN + { \l__regex_current_submatches_prop } } -\cs_new_protected_nopar:Npn \regex_disable_submatches: +\cs_new_protected_nopar:Npn \__regex_disable_submatches: { - \cs_set_protected_nopar:Npn \regex_store_submatches: { } - \cs_set_protected:Npn \regex_action_submatch:n ##1 { } + \cs_set_protected_nopar:Npn \__regex_store_submatches: { } + \cs_set_protected:Npn \__regex_action_submatch:n ##1 { } } -\cs_new_protected:Npn \regex_action_submatch:n #1 +\cs_new_protected:Npn \__regex_action_submatch:n #1 { - \prop_put:Nno \l_regex_current_submatches_prop {#1} - { \int_use:N \l_regex_current_pos_int } + \prop_put:Nno \l__regex_current_submatches_prop {#1} + { \int_use:N \l__regex_current_pos_int } } -\cs_new_protected_nopar:Npn \regex_action_success: +\cs_new_protected_nopar:Npn \__regex_action_success: { - \regex_if_two_empty_matches:F + \__regex_if_two_empty_matches:F { - \bool_set_true:N \l_regex_match_success_bool - \bool_set_eq:NN \l_regex_empty_success_bool - \l_regex_fresh_thread_bool - \int_set_eq:NN \l_regex_success_pos_int \l_regex_current_pos_int - \prop_set_eq:NN \l_regex_success_submatches_prop - \l_regex_current_submatches_prop - \prg_map_break: + \bool_set_true:N \l__regex_match_success_bool + \bool_set_eq:NN \l__regex_empty_success_bool + \l__regex_fresh_thread_bool + \int_set_eq:NN \l__regex_success_pos_int \l__regex_current_pos_int + \prop_set_eq:NN \l__regex_success_submatches_prop + \l__regex_current_submatches_prop + \__prg_break: } } -\int_new:N \l_regex_replacement_csnames_int -\tl_new:N \l_regex_balance_tl -\cs_new:Npn \regex_replacement_balance_one_match:n #1 - { - \regex_submatch_balance:n {#1} } -\cs_new:Npn \regex_replacement_do_one_match:n #1 +\int_new:N \l__regex_replacement_csnames_int +\tl_new:N \l__regex_balance_tl +\cs_new:Npn \__regex_replacement_balance_one_match:n #1 + { - \__regex_submatch_balance:n {#1} } +\cs_new:Npn \__regex_replacement_do_one_match:n #1 { - \regex_query_range:nn + \__regex_query_range:nn { \etex_glueshrink:D \tex_skip:D #1 } { \tex_skip:D #1 } } -\cs_new:Npn \regex_replacement_exp_not:N #1 { \exp_not:n {#1} } -\cs_new:Npn \regex_query_range:nn #1#2 +\cs_new:Npn \__regex_replacement_exp_not:N #1 { \exp_not:n {#1} } +\cs_new:Npn \__regex_query_range:nn #1#2 { - \exp_after:wN \regex_query_range_loop:ww - \int_use:N \int_eval:w #1 \exp_after:wN ; - \int_use:N \int_eval:w #2 ; - \prg_break_point:n { } + \exp_after:wN \__regex_query_range_loop:ww + \int_use:N \__int_eval:w #1 \exp_after:wN ; + \int_use:N \__int_eval:w #2 ; + \__prg_break_point: } -\cs_new:Npn \regex_query_range_loop:ww #1 ; #2 ; +\cs_new:Npn \__regex_query_range_loop:ww #1 ; #2 ; { - \if_num:w #1 < #2 \exp_stop_f: + \if_int_compare:w #1 < #2 \exp_stop_f: \else: - \exp_after:wN \prg_map_break: + \exp_after:wN \__prg_break: \fi: \tex_the:D \tex_toks:D #1 \exp_stop_f: - \exp_after:wN \regex_query_range_loop:ww - \int_use:N \int_eval:w #1 + \c_one ; #2 ; + \exp_after:wN \__regex_query_range_loop:ww + \int_use:N \__int_eval:w #1 + \c_one ; #2 ; } -\cs_new:Npn \regex_query_submatch:n #1 +\cs_new:Npn \__regex_query_submatch:n #1 { - \regex_query_range:nn - { \tex_skip:D \int_eval:w #1 } - { \etex_gluestretch:D \tex_skip:D \int_eval:w #1 } + \__regex_query_range:nn + { \tex_skip:D \__int_eval:w #1 } + { \etex_gluestretch:D \tex_skip:D \__int_eval:w #1 } } -\cs_new_protected:Npn \regex_submatch_balance:n #1 +\cs_new_protected:Npn \__regex_submatch_balance:n #1 { \etex_glueshrink:D \etex_mutoglue:D \etex_muexpr:D \tex_muskip:D \etex_gluestretch:D \tex_skip:D #1 - \tex_muskip:D \tex_skip:D #1 \scan_stop: } -\cs_new_protected:Npn \regex_replacement:n #1 +\cs_new_protected:Npn \__regex_replacement:n #1 { - \trace_push:nnn { regex } { 1 } { regex_replacement:n } - \tl_set_build:Nw \l_regex_internal_a_tl - \int_zero:N \l_regex_balance_int - \tl_clear:N \l_regex_balance_tl - \regex_escape_use:nnnn + \trace_push:nnn { regex } { 1 } { @@_replacement:n } + \__tl_build:Nw \l__regex_internal_a_tl + \int_zero:N \l__regex_balance_int + \tl_clear:N \l__regex_balance_tl + \__regex_escape_use:nnnn { \if_charcode:w \c_rbrace_str ##1 - \regex_replacement_rbrace:N \else: \tl_build_one:n \fi: ##1 + \__regex_replacement_rbrace:N \else: \__tl_build_one:n \fi: ##1 } - { \regex_replacement_escaped:N ##1 } - { \tl_build_one:n ##1 } + { \__regex_replacement_escaped:N ##1 } + { \__tl_build_one:n ##1 } {#1} \prg_do_nothing: \prg_do_nothing: - \if_int_compare:w \l_regex_replacement_csnames_int > \c_zero - \msg_kernel_error:nnx { regex } { replacement-missing-rbrace } - { \int_use:N \l_regex_replacement_csnames_int } - \tl_build_one:x - { \prg_replicate:nn \l_regex_replacement_csnames_int \cs_end: } + \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero + \__msg_kernel_error:nnx { regex } { replacement-missing-rbrace } + { \int_use:N \l__regex_replacement_csnames_int } + \__tl_build_one:x + { \prg_replicate:nn \l__regex_replacement_csnames_int \cs_end: } \fi: - \cs_gset:Npx \regex_replacement_balance_one_match:n ##1 + \cs_gset:Npx \__regex_replacement_balance_one_match:n ##1 { - + \int_use:N \l_regex_balance_int - \l_regex_balance_tl - - \regex_submatch_balance:n {##1} + + \int_use:N \l__regex_balance_int + \l__regex_balance_tl + - \__regex_submatch_balance:n {##1} } - \tl_build_end: - \exp_args:No \regex_replacement_aux:n \l_regex_internal_a_tl - \trace_pop:nnn { regex } { 1 } { regex_replacement:n } + \__tl_build_end: + \exp_args:No \__regex_replacement_aux:n \l__regex_internal_a_tl + \trace_pop:nnn { regex } { 1 } { @@_replacement:n } } -\cs_new_protected:Npn \regex_replacement_aux:n #1 +\cs_new_protected:Npn \__regex_replacement_aux:n #1 { - \cs_set:Npn \regex_replacement_do_one_match:n ##1 + \cs_set:Npn \__regex_replacement_do_one_match:n ##1 { - \regex_query_range:nn + \__regex_query_range:nn { \etex_glueshrink:D \tex_skip:D ##1 } { \tex_skip:D ##1 } #1 } } -\cs_new_protected:Npn \regex_replacement_escaped:N #1 +\cs_new_protected:Npn \__regex_replacement_escaped:N #1 { - \cs_if_exist_use:cF { regex_replacement_#1:w } + \cs_if_exist_use:cF { __regex_replacement_#1:w } { - \if_num:w \c_one < 1#1 \exp_stop_f: - \regex_replacement_put_submatch:n {#1} + \if_int_compare:w \c_one < 1#1 \exp_stop_f: + \__regex_replacement_put_submatch:n {#1} \else: - \tl_build_one:n #1 + \__tl_build_one:n #1 \fi: } } -\cs_new_protected:Npn \regex_replacement_put_submatch:n #1 +\cs_new_protected:Npn \__regex_replacement_put_submatch:n #1 { - \if_num:w #1 < \l_regex_capturing_group_int - \tl_build_one:n { \regex_query_submatch:n { #1 + ##1 } } - \if_num:w \l_regex_replacement_csnames_int = \c_zero - \tl_put_right:Nn \l_regex_balance_tl - { + \regex_submatch_balance:n { \int_eval:w #1+##1 \int_eval_end: } } + \if_int_compare:w #1 < \l__regex_capturing_group_int + \__tl_build_one:n { \__regex_query_submatch:n { #1 + ##1 } } + \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero + \tl_put_right:Nn \l__regex_balance_tl + { + \__regex_submatch_balance:n { \__int_eval:w #1+##1 \__int_eval_end: } } \fi: \fi: } -\cs_new_protected:Npn \regex_replacement_g:w #1#2 +\cs_new_protected:Npn \__regex_replacement_g:w #1#2 { - \str_if_eq:xxTF { #1#2 } { \tl_build_one:n \c_lbrace_str } + \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_lbrace_str } { - \int_zero:N \l_regex_internal_a_int - \regex_replacement_g_digits:NN + \int_zero:N \l__regex_internal_a_int + \__regex_replacement_g_digits:NN } - { \regex_replacement_error:NNN g #1 #2 } + { \__regex_replacement_error:NNN g #1 #2 } } -\cs_new_protected:Npn \regex_replacement_g_digits:NN #1#2 +\cs_new_protected:Npn \__regex_replacement_g_digits:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__tl_build_one:n { - \if_num:w \c_one < 1#2 \exp_stop_f: - \int_set:Nn \l_regex_internal_a_int - { \c_ten * \l_regex_internal_a_int + #2 } + \if_int_compare:w \c_one < 1#2 \exp_stop_f: + \int_set:Nn \l__regex_internal_a_int + { \c_ten * \l__regex_internal_a_int + #2 } \exp_after:wN \use_i:nnn - \exp_after:wN \regex_replacement_g_digits:NN + \exp_after:wN \__regex_replacement_g_digits:NN \else: - \exp_after:wN \regex_replacement_error:NNN + \exp_after:wN \__regex_replacement_error:NNN \exp_after:wN g \fi: } { - \if_meaning:w \regex_replacement_rbrace:N #1 - \exp_args:No \regex_replacement_put_submatch:n - { \int_use:N \l_regex_internal_a_int } + \if_meaning:w \__regex_replacement_rbrace:N #1 + \exp_args:No \__regex_replacement_put_submatch:n + { \int_use:N \l__regex_internal_a_int } \exp_after:wN \use_none:nn \else: - \exp_after:wN \regex_replacement_error:NNN + \exp_after:wN \__regex_replacement_error:NNN \exp_after:wN g \fi: } #1 #2 } -\cs_new_protected:Npn \regex_replacement_c:w #1#2 +\cs_new_protected:Npn \__regex_replacement_c:w #1#2 { - \token_if_eq_meaning:NNTF #1 \tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__tl_build_one:n { - \cs_if_exist_use:cF { regex_replacement_c_#2:w } - { \regex_replacement_error:NNN c #1#2 } + \cs_if_exist_use:cF { __regex_replacement_c_#2:w } + { \__regex_replacement_error:NNN c #1#2 } } - { \regex_replacement_error:NNN c #1#2 } + { \__regex_replacement_error:NNN c #1#2 } } -\cs_new_protected_nopar:cpn { regex_replacement_c_ \c_lbrace_str :w } +\cs_new_protected_nopar:cpn { __regex_replacement_c_ \c_lbrace_str :w } { - \if_case:w \l_regex_replacement_csnames_int - \tl_build_one:n - { \exp_not:n { \exp_after:wN \regex_replacement_exp_not:N \cs:w } } + \if_case:w \l__regex_replacement_csnames_int + \__tl_build_one:n + { \exp_not:n { \exp_after:wN \__regex_replacement_exp_not:N \cs:w } } \else: - \tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:N \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:N \cs:w } } \fi: - \int_incr:N \l_regex_replacement_csnames_int + \int_incr:N \l__regex_replacement_csnames_int } -\cs_new_protected:Npn \regex_replacement_u:w #1#2 +\cs_new_protected:Npn \__regex_replacement_u:w #1#2 { - \str_if_eq:xxTF { #1#2 } { \tl_build_one:n \c_lbrace_str } + \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_lbrace_str } { - \if_case:w \l_regex_replacement_csnames_int - \tl_build_one:n { \exp_not:n { \exp_after:wN \exp_not:V \cs:w } } + \if_case:w \l__regex_replacement_csnames_int + \__tl_build_one:n { \exp_not:n { \exp_after:wN \exp_not:V \cs:w } } \else: - \tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } \fi: - \int_incr:N \l_regex_replacement_csnames_int + \int_incr:N \l__regex_replacement_csnames_int } - { \regex_replacement_error:NNN u #1#2 } + { \__regex_replacement_error:NNN u #1#2 } } -\cs_new_protected:Npn \regex_replacement_rbrace:N #1 +\cs_new_protected:Npn \__regex_replacement_rbrace:N #1 { - \if_int_compare:w \l_regex_replacement_csnames_int > \c_zero - \tl_build_one:n \cs_end: - \int_decr:N \l_regex_replacement_csnames_int + \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero + \__tl_build_one:n \cs_end: + \int_decr:N \l__regex_replacement_csnames_int \else: - \tl_build_one:n #1 + \__tl_build_one:n #1 \fi: } \group_begin: - \cs_new_protected:Npn \regex_replacement_char:nNN #1#2#3 + \cs_new_protected:Npn \__regex_replacement_char:nNN #1#2#3 { \if_meaning:w \prg_do_nothing: #3 - \msg_kernel_error:nn { regex } { replacement-catcode-end } + \__msg_kernel_error:nn { regex } { replacement-catcode-end } \else: \tex_lccode:D \c_zero = `#3 \scan_stop: - \tl_to_lowercase:n { \tl_build_one:n {#1} } + \tl_to_lowercase:n { \__tl_build_one:n {#1} } \fi: } \char_set_catcode_active:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_A:w - { \regex_replacement_char:nNN { \exp_not:n { \exp_not:N ^^@ } } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_A:w + { \__regex_replacement_char:nNN { \exp_not:n { \exp_not:N ^^@ } } } \char_set_catcode_group_begin:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_B:w + \cs_new_protected_nopar:Npn \__regex_replacement_c_B:w { - \if_num:w \l_regex_replacement_csnames_int = \c_zero - \int_incr:N \l_regex_balance_int + \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero + \int_incr:N \l__regex_balance_int \fi: - \regex_replacement_char:nNN + \__regex_replacement_char:nNN { \exp_not:n { \exp_after:wN ^^@ \if_false: } \fi: } } } - \cs_new_protected:Npn \regex_replacement_c_C:w #1#2 - { \tl_build_one:n { \exp_not:N \exp_not:N \exp_not:c {#2} } } + \cs_new_protected:Npn \__regex_replacement_c_C:w #1#2 + { \__tl_build_one:n { \exp_not:N \exp_not:N \exp_not:c {#2} } } \char_set_catcode_math_subscript:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_D:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_D:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_group_end:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_E:w + \cs_new_protected_nopar:Npn \__regex_replacement_c_E:w { - \if_num:w \l_regex_replacement_csnames_int = \c_zero - \int_decr:N \l_regex_balance_int + \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero + \int_decr:N \l__regex_balance_int \fi: - \regex_replacement_char:nNN + \__regex_replacement_char:nNN { \exp_not:n { \if_false: { \fi: ^^@ } } } \char_set_catcode_letter:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_L:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_L:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_math_toggle:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_M:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_M:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_other:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_O:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_O:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_parameter:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_P:w + \cs_new_protected_nopar:Npn \__regex_replacement_c_P:w { - \regex_replacement_char:nNN + \__regex_replacement_char:nNN { \exp_not:n { \exp_not:n { ^^@^^@^^@^^@ } } } } - \cs_new_protected:Npn \regex_replacement_c_S:w #1#2 + \cs_new_protected:Npn \__regex_replacement_c_S:w #1#2 { \if_meaning:w \prg_do_nothing: #2 - \msg_kernel_error:nn { regex } { replacement-catcode-end } + \__msg_kernel_error:nn { regex } { replacement-catcode-end } \else: - \if_num:w `#2 = \c_zero - \msg_kernel_error:nn { regex } { replacement-null-space } + \if_int_compare:w `#2 = \c_zero + \__msg_kernel_error:nn { regex } { replacement-null-space } \fi: \tex_lccode:D 32 = `#2 \scan_stop: - \tl_to_lowercase:n { \tl_build_one:n {~} } + \tl_to_lowercase:n { \__tl_build_one:n {~} } \fi: } \char_set_catcode_alignment:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_T:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_T:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_math_superscript:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_U:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_U:w + { \__regex_replacement_char:nNN { ^^@ } } \group_end: -\cs_new_protected:Npn \regex_replacement_error:NNN #1#2#3 +\cs_new_protected:Npn \__regex_replacement_error:NNN #1#2#3 { - \msg_kernel_error:nnx { regex } { replacement-#1 } {#3} + \__msg_kernel_error:nnx { regex } { replacement-#1 } {#3} #2 #3 } \cs_new_protected:Npn \regex_new:N #1 - { \cs_new_eq:NN #1 \c_regex_no_match_regex } + { \cs_new_eq:NN #1 \c__regex_no_match_regex } \cs_new_protected_nopar:Npn \regex_set:Nn #1#2 { - \regex_compile:n {#2} - \tl_set_eq:NN #1 \l_regex_internal_regex + \__regex_compile:n {#2} + \tl_set_eq:NN #1 \l__regex_internal_regex } \cs_new_protected_nopar:Npn \regex_gset:Nn #1#2 { - \regex_compile:n {#2} - \tl_gset_eq:NN #1 \l_regex_internal_regex + \__regex_compile:n {#2} + \tl_gset_eq:NN #1 \l__regex_internal_regex } \cs_new_protected_nopar:Npn \regex_const:Nn #1#2 { - \regex_compile:n {#2} - \tl_const:Nx #1 { \exp_not:o \l_regex_internal_regex } + \__regex_compile:n {#2} + \tl_const:Nx #1 { \exp_not:o \l__regex_internal_regex } } \cs_new_protected:Npn \regex_show:n #1 { - \regex_compile:n {#1} - \regex_show_aux:Nx \l_regex_internal_regex + \__regex_compile:n {#1} + \__regex_show:Nx \l__regex_internal_regex { { \tl_to_str:n {#1} } } } \cs_new_protected:Npn \regex_show:N #1 - { \regex_show_aux:Nx #1 { variable~\token_to_str:N #1 } } + { \__regex_show:Nx #1 { variable~\token_to_str:N #1 } } \prg_new_protected_conditional:Npnn \regex_match:nn #1#2 { T , F , TF } { - \regex_match_aux:nn { \regex_build:n {#1} } {#2} - \regex_aux_return: + \__regex_if_match:nn { \__regex_build:n {#1} } {#2} + \__regex_return: } \prg_new_protected_conditional:Npnn \regex_match:Nn #1#2 { T , F , TF } { - \regex_match_aux:nn { \regex_build:N #1 } {#2} - \regex_aux_return: + \__regex_if_match:nn { \__regex_build:N #1 } {#2} + \__regex_return: } \cs_new_protected:Npn \regex_count:nnN #1 - { \regex_count_aux:nnN { \regex_build:n {#1} } } + { \__regex_count:nnN { \__regex_build:n {#1} } } \cs_new_protected:Npn \regex_count:NnN #1 - { \regex_count_aux:nnN { \regex_build:N #1 } } -\cs_set_protected:Npn \regex_tmp:w #1#2#3 + { \__regex_count:nnN { \__regex_build:N #1 } } +\cs_set_protected:Npn \__regex_tmp:w #1#2#3 { - \cs_new_protected:Npn #2 ##1 { #1 { \regex_build:n {##1} } } - \cs_new_protected:Npn #3 ##1 { #1 { \regex_build:N ##1 } } + \cs_new_protected:Npn #2 ##1 { #1 { \__regex_build:n {##1} } } + \cs_new_protected:Npn #3 ##1 { #1 { \__regex_build:N ##1 } } \prg_new_protected_conditional:Npnn #2 ##1##2##3 { T , F , TF } - { #1 { \regex_build:n {##1} } {##2} ##3 \regex_aux_return: } + { #1 { \__regex_build:n {##1} } {##2} ##3 \__regex_return: } \prg_new_protected_conditional:Npnn #3 ##1##2##3 { T , F , TF } - { #1 { \regex_build:N ##1 } {##2} ##3 \regex_aux_return: } + { #1 { \__regex_build:N ##1 } {##2} ##3 \__regex_return: } } -\regex_tmp:w \regex_extract_once_aux:nnN +\__regex_tmp:w \__regex_extract_once:nnN \regex_extract_once:nnN \regex_extract_once:NnN -\regex_tmp:w \regex_extract_all_aux:nnN +\__regex_tmp:w \__regex_extract_all:nnN \regex_extract_all:nnN \regex_extract_all:NnN -\regex_tmp:w \regex_replace_once_aux:nnN +\__regex_tmp:w \__regex_replace_once:nnN \regex_replace_once:nnN \regex_replace_once:NnN -\regex_tmp:w \regex_replace_all_aux:nnN +\__regex_tmp:w \__regex_replace_all:nnN \regex_replace_all:nnN \regex_replace_all:NnN -\regex_tmp:w \regex_split_aux:nnN \regex_split:nnN \regex_split:NnN -\int_new:N \l_regex_match_count_int -\flag_new:n { regex_begin } -\flag_new:n { regex_end } -\int_new:N \l_regex_submatch_int -\int_new:N \l_regex_zeroth_submatch_int -\cs_new_protected_nopar:Npn \regex_aux_return: - { - \if_meaning:w \c_true_bool \g_regex_success_bool +\__regex_tmp:w \__regex_split:nnN \regex_split:nnN \regex_split:NnN +\int_new:N \l__regex_match_count_int +\flag_new:n { __regex_begin } +\flag_new:n { __regex_end } +\int_new:N \l__regex_submatch_int +\int_new:N \l__regex_zeroth_submatch_int +\cs_new_protected_nopar:Npn \__regex_return: + { + \if_meaning:w \c_true_bool \g__regex_success_bool \prg_return_true: \else: \prg_return_false: \fi: } -\cs_new_protected:Npn \regex_match_aux:nn #1#2 +\cs_new_protected:Npn \__regex_if_match:nn #1#2 { \group_begin: - \regex_disable_submatches: - \regex_single_match: + \__regex_disable_submatches: + \__regex_single_match: #1 - \regex_match:n {#2} + \__regex_match:n {#2} \group_end: } -\cs_new_protected:Npn \regex_count_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_count:nnN #1#2#3 { \group_begin: - \regex_disable_submatches: - \int_zero:N \l_regex_match_count_int - \regex_multi_match:n { \int_incr:N \l_regex_match_count_int } + \__regex_disable_submatches: + \int_zero:N \l__regex_match_count_int + \__regex_multi_match:n { \int_incr:N \l__regex_match_count_int } #1 - \regex_match:n {#2} + \__regex_match:n {#2} \exp_args:NNNo \group_end: - \int_set:Nn #3 { \int_use:N \l_regex_match_count_int } + \int_set:Nn #3 { \int_use:N \l__regex_match_count_int } } -\cs_new_protected:Npn \regex_extract_once_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_extract_once:nnN #1#2#3 { \group_begin: - \regex_single_match: + \__regex_single_match: #1 - \regex_match:n {#2} - \regex_extract: - \regex_group_end_extract_seq:N #3 + \__regex_match:n {#2} + \__regex_extract: + \__regex_group_end_extract_seq:N #3 } -\cs_new_protected:Npn \regex_extract_all_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_extract_all:nnN #1#2#3 { \group_begin: - \regex_multi_match:n { \regex_extract: } + \__regex_multi_match:n { \__regex_extract: } #1 - \regex_match:n {#2} - \regex_group_end_extract_seq:N #3 + \__regex_match:n {#2} + \__regex_group_end_extract_seq:N #3 } -\cs_new_protected:Npn \regex_split_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_split:nnN #1#2#3 { \group_begin: - \regex_multi_match:n + \__regex_multi_match:n { - \if_num:w \l_regex_start_pos_int < \l_regex_success_pos_int - \regex_extract: - \tex_skip:D \l_regex_zeroth_submatch_int - = \l_regex_start_pos_int sp - plus \tex_skip:D \l_regex_zeroth_submatch_int \scan_stop: + \if_int_compare:w \l__regex_start_pos_int < \l__regex_success_pos_int + \__regex_extract: + \tex_skip:D \l__regex_zeroth_submatch_int + = \l__regex_start_pos_int sp + plus \tex_skip:D \l__regex_zeroth_submatch_int \scan_stop: \fi: } #1 - \regex_match:n {#2} - \tex_skip:D \l_regex_submatch_int - = \l_regex_start_pos_int sp plus \l_regex_max_pos_int sp \scan_stop: - \int_incr:N \l_regex_submatch_int - \if_meaning:w \c_true_bool \l_regex_empty_success_bool - \if_num:w \l_regex_start_pos_int = \l_regex_max_pos_int - \int_decr:N \l_regex_submatch_int + \__regex_match:n {#2} + \tex_skip:D \l__regex_submatch_int + = \l__regex_start_pos_int sp plus \l__regex_max_pos_int sp \scan_stop: + \int_incr:N \l__regex_submatch_int + \if_meaning:w \c_true_bool \l__regex_empty_success_bool + \if_int_compare:w \l__regex_start_pos_int = \l__regex_max_pos_int + \int_decr:N \l__regex_submatch_int \fi: \fi: - \regex_group_end_extract_seq:N #3 + \__regex_group_end_extract_seq:N #3 } -\cs_new_protected:Npn \regex_group_end_extract_seq:N #1 +\cs_new_protected:Npn \__regex_group_end_extract_seq:N #1 { - \cs_set_eq:NN \seq_item:n \scan_stop: - \flag_clear:n { regex_begin } - \flag_clear:n { regex_end } - \tl_set:Nx \l_regex_internal_a_tl + \cs_set_eq:NN \__seq_item:n \scan_stop: + \flag_clear:n { __regex_begin } + \flag_clear:n { __regex_end } + \tl_set:Nx \l__regex_internal_a_tl { - \prg_stepwise_function:nnnN - { \c_two * \l_regex_max_state_int } + \int_step_function:nnnN + { \c_two * \l__regex_max_state_int } \c_one - { \l_regex_submatch_int - \c_one } - \regex_extract_seq_aux:n + { \l__regex_submatch_int - \c_one } + \__regex_extract_seq_aux:n } \int_compare:nNnF - { \flag_height:n { regex_begin } + \flag_height:n { regex_end } } + { \flag_height:n { __regex_begin } + \flag_height:n { __regex_end } } = \c_zero { - \msg_kernel_error:nnxxx { regex } { result-unbalanced } + \__msg_kernel_error:nnxxx { regex } { result-unbalanced } { splitting~or~extracting~submatches } - { \flag_height:n { regex_end } } - { \flag_height:n { regex_begin } } + { \flag_height:n { __regex_end } } + { \flag_height:n { __regex_begin } } } \use:x { \group_end: - \tl_set:Nn \exp_not:N #1 { \l_regex_internal_a_tl } + \tl_set:Nn \exp_not:N #1 { \l__regex_internal_a_tl } } } -\cs_new:Npn \regex_extract_seq_aux:n #1 +\cs_new:Npn \__regex_extract_seq_aux:n #1 { - \seq_item:n + \__seq_item:n { - \exp_after:wN \regex_extract_seq_aux:ww - \int_value:w \regex_submatch_balance:n {#1} ; #1; + \exp_after:wN \__regex_extract_seq_aux:ww + \__int_value:w \__regex_submatch_balance:n {#1} ; #1; } } -\cs_new:Npn \regex_extract_seq_aux:ww #1; #2; +\cs_new:Npn \__regex_extract_seq_aux:ww #1; #2; { - \if_num:w #1 < \c_zero - \flag_raise:n { regex_end } + \if_int_compare:w #1 < \c_zero + \flag_raise:n { __regex_end } \prg_replicate:nn {-#1} { \exp_not:n { { \if_false: } \fi: } } \fi: - \regex_query_submatch:n {#2} - \if_num:w #1 > \c_zero - \flag_raise:n { regex_begin } + \__regex_query_submatch:n {#2} + \if_int_compare:w #1 > \c_zero + \flag_raise:n { __regex_begin } \prg_replicate:nn {#1} { \exp_not:n { \if_false: { \fi: } } } \fi: } -\cs_new_protected_nopar:Npn \regex_extract: +\cs_new_protected_nopar:Npn \__regex_extract: { - \if_meaning:w \c_true_bool \g_regex_success_bool - \int_set_eq:NN \l_regex_zeroth_submatch_int \l_regex_submatch_int - \prg_replicate:nn \l_regex_capturing_group_int + \if_meaning:w \c_true_bool \g__regex_success_bool + \int_set_eq:NN \l__regex_zeroth_submatch_int \l__regex_submatch_int + \prg_replicate:nn \l__regex_capturing_group_int { - \tex_skip:D \l_regex_submatch_int \c_zero sp \scan_stop: - \int_incr:N \l_regex_submatch_int + \tex_skip:D \l__regex_submatch_int \c_zero sp \scan_stop: + \int_incr:N \l__regex_submatch_int } - \prop_map_inline:Nn \l_regex_success_submatches_prop + \prop_map_inline:Nn \l__regex_success_submatches_prop { - \if_num:w ##1 \c_minus_one - \exp_after:wN \regex_extract_aux_e:wn \int_value:w + \if_int_compare:w ##1 \c_minus_one + \exp_after:wN \__regex_extract_e:wn \__int_value:w \else: - \exp_after:wN \regex_extract_aux_b:wn \int_value:w + \exp_after:wN \__regex_extract_b:wn \__int_value:w \fi: - \int_eval:w \l_regex_zeroth_submatch_int + ##1 {##2} + \__int_eval:w \l__regex_zeroth_submatch_int + ##1 {##2} } - \tex_skip:D \l_regex_zeroth_submatch_int - = \tex_the:D \tex_skip:D \l_regex_zeroth_submatch_int - minus \l_regex_start_pos_int sp \scan_stop: + \tex_skip:D \l__regex_zeroth_submatch_int + = \tex_the:D \tex_skip:D \l__regex_zeroth_submatch_int + minus \l__regex_start_pos_int sp \scan_stop: \fi: } -\cs_new_protected:Npn \regex_extract_aux_b:wn #1 < #2 +\cs_new_protected:Npn \__regex_extract_b:wn #1 < #2 { \tex_skip:D #1 = #2 sp plus \etex_gluestretch:D \tex_skip:D #1 \scan_stop: } -\cs_new_protected:Npn \regex_extract_aux_e:wn #1 > #2 +\cs_new_protected:Npn \__regex_extract_e:wn #1 > #2 { \tex_skip:D #1 = 1 \tex_skip:D #1 plus #2 sp \scan_stop: } -\cs_new_protected:Npn \regex_replace_once_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_replace_once:nnN #1#2#3 { \group_begin: - \regex_single_match: + \__regex_single_match: #1 - \regex_replacement:n {#2} - \exp_args:No \regex_match:n { #3 } - \if_meaning:w \c_false_bool \g_regex_success_bool + \__regex_replacement:n {#2} + \exp_args:No \__regex_match:n { #3 } + \if_meaning:w \c_false_bool \g__regex_success_bool \group_end: \else: - \regex_extract: - \int_set:Nn \l_regex_balance_int + \__regex_extract: + \int_set:Nn \l__regex_balance_int { - \regex_replacement_balance_one_match:n - { \l_regex_zeroth_submatch_int } + \__regex_replacement_balance_one_match:n + { \l__regex_zeroth_submatch_int } } - \tl_set:Nx \l_regex_internal_a_tl + \tl_set:Nx \l__regex_internal_a_tl { - \regex_replacement_do_one_match:n { \l_regex_zeroth_submatch_int } - \regex_query_range:nn - { \etex_gluestretch:D \tex_skip:D \l_regex_zeroth_submatch_int } - { \l_regex_max_pos_int } + \__regex_replacement_do_one_match:n { \l__regex_zeroth_submatch_int } + \__regex_query_range:nn + { \etex_gluestretch:D \tex_skip:D \l__regex_zeroth_submatch_int } + { \l__regex_max_pos_int } } - \regex_group_end_replace:N #3 + \__regex_group_end_replace:N #3 \fi: } -\cs_new_protected:Npn \regex_replace_all_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_replace_all:nnN #1#2#3 { \group_begin: - \regex_multi_match:n { \regex_extract: } + \__regex_multi_match:n { \__regex_extract: } #1 - \regex_replacement:n {#2} - \exp_args:No \regex_match:n {#3} - \int_set:Nn \l_regex_balance_int + \__regex_replacement:n {#2} + \exp_args:No \__regex_match:n {#3} + \int_set:Nn \l__regex_balance_int { 0 - \prg_stepwise_function:nnnN - { \c_two * \l_regex_max_state_int } - \l_regex_capturing_group_int - { \l_regex_submatch_int - \c_one } - \regex_replacement_balance_one_match:n + \int_step_function:nnnN + { \c_two * \l__regex_max_state_int } + \l__regex_capturing_group_int + { \l__regex_submatch_int - \c_one } + \__regex_replacement_balance_one_match:n } - \tl_set:Nx \l_regex_internal_a_tl + \tl_set:Nx \l__regex_internal_a_tl { - \prg_stepwise_function:nnnN - { \c_two * \l_regex_max_state_int } - \l_regex_capturing_group_int - { \l_regex_submatch_int - \c_one } - \regex_replacement_do_one_match:n - \regex_query_range:nn - \l_regex_start_pos_int \l_regex_max_pos_int + \int_step_function:nnnN + { \c_two * \l__regex_max_state_int } + \l__regex_capturing_group_int + { \l__regex_submatch_int - \c_one } + \__regex_replacement_do_one_match:n + \__regex_query_range:nn + \l__regex_start_pos_int \l__regex_max_pos_int } - \regex_group_end_replace:N #3 + \__regex_group_end_replace:N #3 } -\cs_new_protected_nopar:Npn \regex_group_end_replace:N #1 +\cs_new_protected_nopar:Npn \__regex_group_end_replace:N #1 { - \if_num:w \l_regex_balance_int = \c_zero + \if_int_compare:w \l__regex_balance_int = \c_zero \else: - \msg_kernel_error:nnxxx { regex } { result-unbalanced } + \__msg_kernel_error:nnxxx { regex } { result-unbalanced } { replacing } - { \int_max:nn { - \l_regex_balance_int } { \c_zero } } - { \int_max:nn { \l_regex_balance_int } { \c_zero } } + { \int_max:nn { - \l__regex_balance_int } { \c_zero } } + { \int_max:nn { \l__regex_balance_int } { \c_zero } } \fi: \use:x { \group_end: \tl_set:Nn \exp_not:N #1 { - \if_int_compare:w \l_regex_balance_int < \c_zero - \prg_replicate:nn { - \l_regex_balance_int } + \if_int_compare:w \l__regex_balance_int < \c_zero + \prg_replicate:nn { - \l__regex_balance_int } { { \if_false: } \fi: } \fi: - \l_regex_internal_a_tl - \if_int_compare:w \l_regex_balance_int > \c_zero - \prg_replicate:nn { \l_regex_balance_int } + \l__regex_internal_a_tl + \if_int_compare:w \l__regex_balance_int > \c_zero + \prg_replicate:nn { \l__regex_balance_int } { \if_false: { \fi: } } \fi: } } } -\msg_kernel_new:nnnn { regex } { trailing-backslash } +\__msg_kernel_new:nnnn { regex } { 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. } -\msg_kernel_new:nnnn { regex } { x-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { x-missing-rbrace } { Missing~closing~brace~in~\iow_char:N\\x~hexadecimal~sequence. } { You~wrote~something~like~ `\iow_char:N\\x\{\int_to_hexadecimal:n{#1}'.~ The~closing~brace~is~missing. } -\msg_kernel_new:nnnn { regex } { x-overflow } +\__msg_kernel_new:nnnn { regex } { x-overflow } { Character~code~'#1'~too~large~in~\iow_char:N\\x~hexadecimal~sequence. } { You~wrote~something~like~ `\iow_char:N\\x\{\int_to_hexadecimal:n{#1}\}'.~ The~character~code~'#1'~is~larger~than~\int_use:N \c_max_char_int. } -\msg_kernel_new:nnnn { regex } { invalid-quantifier } +\__msg_kernel_new:nnnn { regex } { invalid-quantifier } { Braced~quantifier~'#1'~may~not~be~followed~by~'#2'. } { The~character~'#2'~is~invalid~in~the~braced~quantifier~'#1'.~ The~only~valid~quantifiers~are~'*',~'?',~'+',~'{<int>}',~ '{<min>,}'~and~'{<min>,<max>}',~followed~or~not~by~'?'. } -\msg_kernel_new:nnnn { regex } { missing-rbrack } +\__msg_kernel_new:nnnn { regex } { missing-rbrack } { Missing~right~bracket~inserted~in~regular~expression. } { LaTeX~was~given~a~regular~expression~where~a~character~class~ was~started~with~'[',~but~the~matching~']'~is~missing. } -\msg_kernel_new:nnnn { regex } { missing-rparen } +\__msg_kernel_new:nnnn { regex } { missing-rparen } { Missing~right~parenthes\int_compare:nTF{#1=1}{i}{e}s~ inserted~in~regular~expression. @@ -2624,44 +2632,44 @@ more~left~parenthes\int_compare:nTF{#1=1}{i}{e}s~than~right~ parenthes\int_compare:nTF{#1=1}{i}{e}s. } -\msg_kernel_new:nnnn { regex } { extra-rparen } +\__msg_kernel_new:nnnn { regex } { extra-rparen } { Extra~right~parenthesis~ignored~in~regular~expression. } { LaTeX~came~across~a~closing~parenthesis~when~no~submatch~group~ was~open.~The~parenthesis~will~be~ignored. } -\msg_kernel_new:nnnn { regex } { bad-escape } +\__msg_kernel_new:nnnn { regex } { bad-escape } { Invalid~escape~\c_backslash_str #1~ - \regex_if_in_cs:TF { within~a~control~sequence. } + \__regex_if_in_cs:TF { within~a~control~sequence. } { - \regex_if_in_class:TF + \__regex_if_in_class:TF { in~a~character~class. } { following~a~category~test. } } } { The~escape~sequence~\iow_char:N\\#1~may~not~appear~ - \regex_if_in_cs:TF + \__regex_if_in_cs:TF { within~a~control~sequence~test~introduced~by~ \iow_char:N\\c\iow_char:N\{. } { - \regex_if_in_class:TF + \__regex_if_in_class:TF { within~a~character~class~ } { following~a~category~test~such~as~\iow_char:N\\cL~ } because~it~does~not~match~exactly~one~character. } } -\msg_kernel_new:nnnn { regex } { range-missing-end } +\__msg_kernel_new:nnnn { regex } { range-missing-end } { Invalid~end-point~for~range~'#1-#2'~in~character~class. } { The~end-point~'#2'~of~the~range~'#1-#2'~may~not~serve~as~an~ end-point~for~a~range:~alphanumeric~characters~should~not~be~ escaped,~and~non-alphanumeric~characters~should~be~escaped. } -\msg_kernel_new:nnnn { regex } { range-backwards } +\__msg_kernel_new:nnnn { regex } { range-backwards } { Range~[#1-#2]~out~of~order~in~character~class. } { In~ranges~of~characters~[x-y]~appearing~in~character~classes,~ @@ -2669,27 +2677,27 @@ Here,~#1~has~character~code~\int_eval:n {`#1},~while~#2~has~ character~code~\int_eval:n {`#2}. } -\msg_kernel_new:nnnn { regex } { c-bad-mode } +\__msg_kernel_new:nnnn { regex } { c-bad-mode } { Invalid~nested~\iow_char:N\\c~escape~in~regular~expression. } { The~\iow_char:N\\c~escape~cannot~be~used~within~ a~control~sequence~test~'\iow_char:N\\c{...}'.~ To~combine~several~category~tests,~use~'\iow_char:N\\c[...]'. } -\msg_kernel_new:nnnn { regex } { c-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { c-missing-rbrace } { Missing~right~brace~inserted~for~\iow_char:N\\c~escape. } { LaTeX~was~given~a~regular~expression~where~a~ '\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ with~a~closing~brace~'\iow_char:N\}'. } -\msg_kernel_new:nnnn { regex } { c-missing-rbrack } +\__msg_kernel_new:nnnn { regex } { c-missing-rbrack } { Missing~right~bracket~inserted~for~\iow_char:N\\c~escape. } { A~construction~'\iow_char:N\\c[...'~appears~in~a~ regular~expression,~but~the~closing~']'~is~not~present. } -\msg_kernel_new:nnnn { regex } { c-missing-category } +\__msg_kernel_new:nnnn { regex } { c-missing-category } { Invalid~character~'#1'~following~\iow_char:N\\c~escape. } { In~regular~expressions,~the~\iow_char:N\\c~escape~sequence~ @@ -2697,29 +2705,29 @@ capital~letter~representing~a~character~category,~namely~ one~of~ABCDELMOPSTU. } -\msg_kernel_new:nnnn { regex } { u-missing-lbrace } +\__msg_kernel_new:nnnn { regex } { u-missing-lbrace } { Missing~left~brace~following~\iow_char:N\\u~escape. } { The~\iow_char:N\\u~escape~sequence~must~be~followed~by~ a~brace~group~with~the~name~of~the~variable~to~use. } -\msg_kernel_new:nnnn { regex } { u-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { u-missing-rbrace } { Missing~right~brace~inserted~for~\iow_char:N\\u~escape. } { LaTeX~ - \tl_if_empty:xTF {#2} + \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. } -\msg_kernel_new:nnnn { regex } { posix-unsupported } +\__msg_kernel_new:nnnn { regex } { posix-unsupported } { POSIX~collating~element~'[#1 ~ #1]'~not~supported. } { The~[.foo.]~and~[=bar=]~syntaxes~have~a~special~meaning~in~POSIX~ regular~expressions.~This~is~not~supported~by~LaTeX.~Maybe~you~ forgot~to~escape~a~left~bracket~in~a~character~class? } -\msg_kernel_new:nnnn { regex } { posix-unknown } +\__msg_kernel_new:nnnn { regex } { posix-unknown } { POSIX~class~[:#1:]~unknown. } { [:#1:]~is~not~among~the~known~POSIX~classes~ @@ -2728,10 +2736,10 @@ [:print:],~[:punct:],~[:space:],~[:upper:],~ [:word:],~and~[:xdigit:]. } -\msg_kernel_new:nnnn { regex } { posix-missing-close } +\__msg_kernel_new:nnnn { regex } { posix-missing-close } { Missing~closing~':]'~for~POSIX~class. } { The~POSIX~syntax~'#1'~must~be~followed~by~':]',~not~'#2'. } -\msg_kernel_new:nnnn { regex } { result-unbalanced } +\__msg_kernel_new:nnnn { regex } { result-unbalanced } { Missing~brace~inserted~when~#1. } { LaTeX~was~asked~to~do~some~regular~expression~operation,~ @@ -2739,34 +2747,34 @@ of~begin-group~and~end-group~tokens.~Braces~were~inserted:~ #2~left,~#3~right. } -\msg_kernel_new:nnnn { regex } { unknown-option } +\__msg_kernel_new:nnnn { regex } { unknown-option } { Unknown~option~`#1'~for~regular~expressions. } { The~only~available~option~is~'case-insensitive',~toggled~by~ '(?i)'~and~'(?-i)'. } -\msg_kernel_new:nnnn { regex } { replacement-c } +\__msg_kernel_new:nnnn { regex } { replacement-c } { Misused~\iow_char:N\\c~command~in~a~replacement~text. } { In~a~replacement~text,~the~\iow_char:N\\c~escape~sequence~ can~be~followed~by~one~of~the~letters~ABCDELMOPSTU~ or~a~brace~group,~not~by~'#1'. } -\msg_kernel_new:nnnn { regex } { replacement-u } +\__msg_kernel_new:nnnn { regex } { replacement-u } { Misused~\iow_char:N\\u~command~in~a~replacement~text. } { In~a~replacement~text,~the~\iow_char:N\\u~escape~sequence~ must~be~~followed~by~a~brace~group~holding~the~name~of~the~ variable~to~use. } -\msg_kernel_new:nnnn { regex } { replacement-g } +\__msg_kernel_new:nnnn { regex } { replacement-g } { Missing~brace~for~the~\iow_char:N\\g~construction~in~a~replacement~text. } { In~the~replacement~text~for~a~regular~expression~search,~ submatches~are~represented~either~as~\iow_char:N \\g{dd..d},~ or~\\d,~where~`d'~are~single~digits.~Here,~a~brace~is~missing. } -\msg_kernel_new:nnnn { regex } { replacement-catcode-end } +\__msg_kernel_new:nnnn { regex } { replacement-catcode-end } { Missing~character~for~the~\iow_char:N\\c<category><character>~ construction~in~a~replacement~text. @@ -2777,7 +2785,7 @@ the~character~category.~Then,~a~character~must~follow.~LaTeX~ reached~the~end~of~the~replacement~when~looking~for~that. } -\msg_kernel_new:nnnn { regex } { replacement-null-space } +\__msg_kernel_new:nnnn { regex } { replacement-null-space } { TeX~cannot~build~a~space~token~with~character~code~0. } { You~asked~for~a~character~token~with~category~'space',~ @@ -2786,18 +2794,18 @@ This~specific~case~is~impossible~and~will~be~replaced~ by~a~normal~space. } -\msg_kernel_new:nnnn { regex } { replacement-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { replacement-missing-rbrace } { Missing~right~brace~inserted~in~replacement~text. } { - There~were~\int_use:N \l_regex_replacement_csnames_int \ + There~were~\int_use:N \l__regex_replacement_csnames_int \ missing~right~braces. } -\cs_new:Npn \regex_msg_repeated:nnN #1#2#3 +\cs_new:Npn \__regex_msg_repeated:nnN #1#2#3 { - \str_if_eq:xxF { #1 #2 } { 1 0 } + \str_if_eq_x:nnF { #1 #2 } { 1 0 } { , ~ repeated ~ - \prg_case_int:nnn {#2} + \int_case:nnn {#2} { { -1 } { #1~or~more~times,~\bool_if:NTF #3 { lazy } { greedy } } { 0 } { #1~times } @@ -2808,12 +2816,12 @@ } } } -\cs_new_protected:Npn \regex_trace_states:n #1 +\cs_new_protected:Npn \__regex_trace_states:n #1 { - \prg_stepwise_inline:nnnn - \l_regex_min_state_int + \int_step_inline:nnnn + \l__regex_min_state_int \c_one - { \l_regex_max_state_int - 1 } + { \l__regex_max_state_int - 1 } { \trace:nnx { regex } { #1 } { \iow_char:N \\toks ##1 = { \tex_the:D \tex_toks:D ##1 } } diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty index d6babc2b1b7..2ba86a82c86 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty @@ -46,446 +46,446 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{expl3} -\GetIdInfo$Id: l3regex.dtx 3488 2012-03-03 19:49:03Z bruno $ - {L3 Experimental Regular Expressions} +\GetIdInfo$Id: l3regex.dtx 3940 2012-07-09 00:41:44Z bruno $ + {L3 Experimental regular expressions} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{l3tl-build, l3tl-analysis, l3flag, l3str} \cs_generate_variant:Nn \tl_to_str:n { V } -\cs_new:Npn \regex_tmp:w { } -\tl_new:N \l_regex_internal_a_tl -\tl_new:N \l_regex_internal_b_tl -\int_new:N \l_regex_internal_a_int -\int_new:N \l_regex_internal_b_int -\int_new:N \l_regex_internal_c_int -\bool_new:N \l_regex_internal_bool -\seq_new:N \l_regex_internal_seq -\tl_new:N \g_regex_internal_tl -\tl_const:Nn \c_regex_no_match_regex - { - \regex_branch:n - { \regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } - } -\int_new:N \l_regex_balance_int -\cs_new_protected:Npn \regex_break_true:w - #1 \regex_break_point:TF #2 #3 {#2} -\cs_new_protected:Npn \regex_break_point:TF #1 #2 { #2 } -\cs_new_protected:Npn \regex_item_reverse:n #1 +\cs_new:Npn \__regex_tmp:w { } +\tl_new:N \l__regex_internal_a_tl +\tl_new:N \l__regex_internal_b_tl +\int_new:N \l__regex_internal_a_int +\int_new:N \l__regex_internal_b_int +\int_new:N \l__regex_internal_c_int +\bool_new:N \l__regex_internal_bool +\seq_new:N \l__regex_internal_seq +\tl_new:N \g__regex_internal_tl +\tl_const:Nn \c__regex_no_match_regex + { + \__regex_branch:n + { \__regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } + } +\int_new:N \l__regex_balance_int +\cs_new_protected:Npn \__regex_break_true:w + #1 \__regex_break_point:TF #2 #3 {#2} +\cs_new_protected:Npn \__regex_break_point:TF #1 #2 { #2 } +\cs_new_protected:Npn \__regex_item_reverse:n #1 { #1 - \regex_break_point:TF { } \regex_break_true:w + \__regex_break_point:TF { } \__regex_break_true:w } -\cs_new_protected:Npn \regex_item_caseful_equal:n #1 +\cs_new_protected:Npn \__regex_item_caseful_equal:n #1 { - \if_num:w #1 = \l_regex_current_char_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_char_int + \exp_after:wN \__regex_break_true:w \fi: } -\cs_new_protected:Npn \regex_item_caseful_range:nn #1 #2 +\cs_new_protected:Npn \__regex_item_caseful_range:nn #1 #2 { - \reverse_if:N \if_num:w #1 > \l_regex_current_char_int - \reverse_if:N \if_num:w #2 < \l_regex_current_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \reverse_if:N \if_int_compare:w #1 > \l__regex_current_char_int + \reverse_if:N \if_int_compare:w #2 < \l__regex_current_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: } -\cs_new_protected:Npn \regex_item_caseless_equal:n #1 +\cs_new_protected:Npn \__regex_item_caseless_equal:n #1 { - \if_num:w #1 = \l_regex_current_char_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_char_int + \exp_after:wN \__regex_break_true:w \fi: - \if_num:w \l_regex_case_changed_char_int = \c_max_int - \regex_compute_case_changed_char: + \if_int_compare:w \l__regex_case_changed_char_int = \c_max_int + \__regex_compute_case_changed_char: \fi: - \if_num:w #1 = \l_regex_case_changed_char_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_case_changed_char_int + \exp_after:wN \__regex_break_true:w \fi: } -\cs_new_protected:Npn \regex_item_caseless_range:nn #1 #2 +\cs_new_protected:Npn \__regex_item_caseless_range:nn #1 #2 { - \reverse_if:N \if_num:w #1 > \l_regex_current_char_int - \reverse_if:N \if_num:w #2 < \l_regex_current_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \reverse_if:N \if_int_compare:w #1 > \l__regex_current_char_int + \reverse_if:N \if_int_compare:w #2 < \l__regex_current_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: - \if_num:w \l_regex_case_changed_char_int = \c_max_int - \regex_compute_case_changed_char: + \if_int_compare:w \l__regex_case_changed_char_int = \c_max_int + \__regex_compute_case_changed_char: \fi: - \reverse_if:N \if_num:w #1 > \l_regex_case_changed_char_int - \reverse_if:N \if_num:w #2 < \l_regex_case_changed_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \reverse_if:N \if_int_compare:w #1 > \l__regex_case_changed_char_int + \reverse_if:N \if_int_compare:w #2 < \l__regex_case_changed_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: } -\cs_new_protected_nopar:Npn \regex_compute_case_changed_char: +\cs_new_protected_nopar:Npn \__regex_compute_case_changed_char: { - \int_set_eq:NN \l_regex_case_changed_char_int \l_regex_current_char_int - \if_num:w \l_regex_current_char_int < \c_ninety_one - \if_num:w \l_regex_current_char_int < \c_sixty_five + \int_set_eq:NN \l__regex_case_changed_char_int \l__regex_current_char_int + \if_int_compare:w \l__regex_current_char_int < \c_ninety_one + \if_int_compare:w \l__regex_current_char_int < \c_sixty_five \else: - \int_add:Nn \l_regex_case_changed_char_int { \c_thirty_two } + \int_add:Nn \l__regex_case_changed_char_int { \c_thirty_two } \fi: \else: - \if_num:w \l_regex_current_char_int < \c_one_hundred_twenty_three - \if_num:w \l_regex_current_char_int < \c_ninety_seven + \if_int_compare:w \l__regex_current_char_int < \c_one_hundred_twenty_three + \if_int_compare:w \l__regex_current_char_int < \c_ninety_seven \else: - \int_sub:Nn \l_regex_case_changed_char_int { \c_thirty_two } + \int_sub:Nn \l__regex_case_changed_char_int { \c_thirty_two } \fi: \fi: \fi: } -\cs_new_eq:NN \regex_item_equal:n ? -\cs_new_eq:NN \regex_item_range:nn ? -\cs_new_protected:Npn \regex_item_catcode_aux: +\cs_new_eq:NN \__regex_item_equal:n ? +\cs_new_eq:NN \__regex_item_range:nn ? +\cs_new_protected:Npn \__regex_item_catcode: { " - \if_case:w \l_regex_current_catcode_int + \if_case:w \l__regex_current_catcode_int 1 \or: 4 \or: 10 \or: 40 \or: 100 \or: \or: 1000 \or: 4000 \or: 10000 \or: \or: 100000 \or: 400000 \or: 1000000 \or: 4000000 \else: 1*\c_zero \fi: } -\cs_new_protected:Npn \regex_item_catcode:nT #1 +\cs_new_protected:Npn \__regex_item_catcode:nT #1 { - \if_int_odd:w \int_eval:w #1 / \regex_item_catcode_aux: \int_eval_end: + \if_int_odd:w \__int_eval:w #1 / \__regex_item_catcode: \__int_eval_end: \exp_after:wN \use:n \else: \exp_after:wN \use_none:n \fi: } -\cs_new_protected:Npn \regex_item_catcode_reverse:nT #1#2 - { \regex_item_catcode:nT {#1} { \regex_item_reverse:n {#2} } } -\cs_new_protected:Npn \regex_item_exact:nn #1#2 +\cs_new_protected:Npn \__regex_item_catcode_reverse:nT #1#2 + { \__regex_item_catcode:nT {#1} { \__regex_item_reverse:n {#2} } } +\cs_new_protected:Npn \__regex_item_exact:nn #1#2 { - \if_num:w #1 = \l_regex_current_catcode_int - \if_num:w #2 = \l_regex_current_char_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_catcode_int + \if_int_compare:w #2 = \l__regex_current_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w \fi: \fi: } -\cs_new_protected:Npn \regex_item_exact_cs:c #1 +\cs_new_protected:Npn \__regex_item_exact_cs:c #1 { - \int_compare:nNnTF \l_regex_current_catcode_int = \c_zero + \int_compare:nNnTF \l__regex_current_catcode_int = \c_zero { - \str_if_eq:xxTF + \str_if_eq_x:nnTF { \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l_regex_current_pos_int + \tex_the:D \tex_toks:D \l__regex_current_pos_int } { #1 } - { \regex_break_true:w } { } + { \__regex_break_true:w } { } } { } } -\cs_new_protected:Npn \regex_item_cs:n #1 +\cs_new_protected:Npn \__regex_item_cs:n #1 { - \int_compare:nNnT \l_regex_current_catcode_int = \c_zero + \int_compare:nNnT \l__regex_current_catcode_int = \c_zero { \group_begin: - \regex_single_match: - \regex_disable_submatches: - \regex_build_for_cs:n {#1} - \bool_set_eq:NN \l_regex_saved_success_bool \g_regex_success_bool - \exp_args:Nx \regex_match:n + \__regex_single_match: + \__regex_disable_submatches: + \__regex_build_for_cs:n {#1} + \bool_set_eq:NN \l__regex_saved_success_bool \g__regex_success_bool + \exp_args:Nx \__regex_match:n { \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l_regex_current_pos_int + \tex_the:D \tex_toks:D \l__regex_current_pos_int } - \if_meaning:w \c_true_bool \g_regex_success_bool - \group_insert_after:N \regex_break_true:w + \if_meaning:w \c_true_bool \g__regex_success_bool + \group_insert_after:N \__regex_break_true:w \fi: - \bool_gset_eq:NN \g_regex_success_bool \l_regex_saved_success_bool + \bool_gset_eq:NN \g__regex_success_bool \l__regex_saved_success_bool \group_end: } } -\cs_new_protected_nopar:Npn \regex_prop_d: - { \regex_item_caseful_range:nn \c_forty_eight { 57 } } % 0--9 -\cs_new_protected_nopar:Npn \regex_prop_h: - { - \regex_item_caseful_equal:n \c_thirty_two % space - \regex_item_caseful_equal:n \c_nine % tab - } -\cs_new_protected_nopar:Npn \regex_prop_s: - { - \regex_item_caseful_equal:n \c_thirty_two % space - \regex_item_caseful_equal:n \c_nine % tab - \regex_item_caseful_equal:n \c_ten % lf - \regex_item_caseful_equal:n \c_twelve % ff - \regex_item_caseful_equal:n \c_thirteen % cr - } -\cs_new_protected_nopar:Npn \regex_prop_v: - { \regex_item_caseful_range:nn \c_ten \c_thirteen } % lf, vtab, ff, cr -\cs_new_protected_nopar:Npn \regex_prop_w: - { - \regex_item_caseful_range:nn \c_ninety_seven { 122 } % a--z - \regex_item_caseful_range:nn \c_sixty_five { 90 } % A--Z - \regex_item_caseful_range:nn \c_forty_eight { 57 } % 0--9 - \regex_item_caseful_equal:n { 95 } % _ - } -\cs_new_protected_nopar:Npn \regex_prop_N: - { \regex_item_reverse:n { \regex_item_caseful_equal:n \c_ten } } -\cs_new_protected_nopar:Npn \regex_posix_alnum: - { \regex_posix_alpha: \regex_posix_digit: } -\cs_new_protected_nopar:Npn \regex_posix_alpha: - { \regex_posix_lower: \regex_posix_upper: } -\cs_new_protected_nopar:Npn \regex_posix_ascii: - { \regex_item_caseful_range:nn \c_zero \c_one_hundred_twenty_seven } -\cs_new_eq:NN \regex_posix_blank: \regex_prop_h: -\cs_new_protected_nopar:Npn \regex_posix_cntrl: - { - \regex_item_caseful_range:nn \c_zero { 31 } - \regex_item_caseful_equal:n \c_one_hundred_twenty_seven - } -\cs_new_eq:NN \regex_posix_digit: \regex_prop_d: -\cs_new_protected_nopar:Npn \regex_posix_graph: - { \regex_item_caseful_range:nn { 33 } { 126 } } -\cs_new_protected_nopar:Npn \regex_posix_lower: - { \regex_item_caseful_range:nn \c_ninety_seven { 122 } } -\cs_new_protected_nopar:Npn \regex_posix_print: - { \regex_item_caseful_range:nn \c_thirty_two { 126 } } -\cs_new_protected_nopar:Npn \regex_posix_punct: - { - \regex_item_caseful_range:nn { 33 } { 47 } - \regex_item_caseful_range:nn { 58 } { 64 } - \regex_item_caseful_range:nn { 91 } { 96 } - \regex_item_caseful_range:nn { 123 } { 126 } - } -\cs_new_protected_nopar:Npn \regex_posix_space: - { - \regex_item_caseful_equal:n \c_thirty_two - \regex_item_caseful_range:nn \c_nine \c_thirteen - } -\cs_new_protected_nopar:Npn \regex_posix_upper: - { \regex_item_caseful_range:nn \c_sixty_five { 90 } } -\cs_new_eq:NN \regex_posix_word: \regex_prop_w: -\cs_new_protected_nopar:Npn \regex_posix_xdigit: - { - \regex_posix_digit: - \regex_item_caseful_range:nn \c_sixty_five { 70 } - \regex_item_caseful_range:nn \c_ninety_seven { 102 } - } -\cs_new_protected:Npn \regex_escape_use:nnnn #1#2#3#4 - { - \tl_set_build:Nw \l_regex_internal_a_tl - \cs_set_nopar:Npn \regex_escape_unescaped:N ##1 { #1 } - \cs_set_nopar:Npn \regex_escape_escaped:N ##1 { #2 } - \cs_set_nopar:Npn \regex_escape_raw:N ##1 { #3 } +\cs_new_protected_nopar:Npn \__regex_prop_d: + { \__regex_item_caseful_range:nn \c_forty_eight { 57 } } % 0--9 +\cs_new_protected_nopar:Npn \__regex_prop_h: + { + \__regex_item_caseful_equal:n \c_thirty_two % space + \__regex_item_caseful_equal:n \c_nine % tab + } +\cs_new_protected_nopar:Npn \__regex_prop_s: + { + \__regex_item_caseful_equal:n \c_thirty_two % space + \__regex_item_caseful_equal:n \c_nine % tab + \__regex_item_caseful_equal:n \c_ten % lf + \__regex_item_caseful_equal:n \c_twelve % ff + \__regex_item_caseful_equal:n \c_thirteen % cr + } +\cs_new_protected_nopar:Npn \__regex_prop_v: + { \__regex_item_caseful_range:nn \c_ten \c_thirteen } % lf, vtab, ff, cr +\cs_new_protected_nopar:Npn \__regex_prop_w: + { + \__regex_item_caseful_range:nn \c_ninety_seven { 122 } % a--z + \__regex_item_caseful_range:nn \c_sixty_five { 90 } % A--Z + \__regex_item_caseful_range:nn \c_forty_eight { 57 } % 0--9 + \__regex_item_caseful_equal:n { 95 } % _ + } +\cs_new_protected_nopar:Npn \__regex_prop_N: + { \__regex_item_reverse:n { \__regex_item_caseful_equal:n \c_ten } } +\cs_new_protected_nopar:Npn \__regex_posix_alnum: + { \__regex_posix_alpha: \__regex_posix_digit: } +\cs_new_protected_nopar:Npn \__regex_posix_alpha: + { \__regex_posix_lower: \__regex_posix_upper: } +\cs_new_protected_nopar:Npn \__regex_posix_ascii: + { \__regex_item_caseful_range:nn \c_zero \c_one_hundred_twenty_seven } +\cs_new_eq:NN \__regex_posix_blank: \__regex_prop_h: +\cs_new_protected_nopar:Npn \__regex_posix_cntrl: + { + \__regex_item_caseful_range:nn \c_zero { 31 } + \__regex_item_caseful_equal:n \c_one_hundred_twenty_seven + } +\cs_new_eq:NN \__regex_posix_digit: \__regex_prop_d: +\cs_new_protected_nopar:Npn \__regex_posix_graph: + { \__regex_item_caseful_range:nn { 33 } { 126 } } +\cs_new_protected_nopar:Npn \__regex_posix_lower: + { \__regex_item_caseful_range:nn \c_ninety_seven { 122 } } +\cs_new_protected_nopar:Npn \__regex_posix_print: + { \__regex_item_caseful_range:nn \c_thirty_two { 126 } } +\cs_new_protected_nopar:Npn \__regex_posix_punct: + { + \__regex_item_caseful_range:nn { 33 } { 47 } + \__regex_item_caseful_range:nn { 58 } { 64 } + \__regex_item_caseful_range:nn { 91 } { 96 } + \__regex_item_caseful_range:nn { 123 } { 126 } + } +\cs_new_protected_nopar:Npn \__regex_posix_space: + { + \__regex_item_caseful_equal:n \c_thirty_two + \__regex_item_caseful_range:nn \c_nine \c_thirteen + } +\cs_new_protected_nopar:Npn \__regex_posix_upper: + { \__regex_item_caseful_range:nn \c_sixty_five { 90 } } +\cs_new_eq:NN \__regex_posix_word: \__regex_prop_w: +\cs_new_protected_nopar:Npn \__regex_posix_xdigit: + { + \__regex_posix_digit: + \__regex_item_caseful_range:nn \c_sixty_five { 70 } + \__regex_item_caseful_range:nn \c_ninety_seven { 102 } + } +\cs_new_protected:Npn \__regex_escape_use:nnnn #1#2#3#4 + { + \__tl_build:Nw \l__regex_internal_a_tl + \cs_set_nopar:Npn \__regex_escape_unescaped:N ##1 { #1 } + \cs_set_nopar:Npn \__regex_escape_escaped:N ##1 { #2 } + \cs_set_nopar:Npn \__regex_escape_raw:N ##1 { #3 } \int_set:Nn \tex_escapechar:D { 92 } - \str_gset_other:Nn \g_regex_internal_tl { #4 } - \tl_set:Nx \l_regex_internal_b_tl + \__str_gset_other:Nn \g__regex_internal_tl { #4 } + \tl_set:Nx \l__regex_internal_b_tl { - \exp_after:wN \regex_escape_loop:N \g_regex_internal_tl - { break } \prg_break_point:n { } + \exp_after:wN \__regex_escape_loop:N \g__regex_internal_tl + { break } \__prg_break_point: } - \tl_build_one:o \l_regex_internal_b_tl - \tl_build_end: - \l_regex_internal_a_tl + \__tl_build_one:o \l__regex_internal_b_tl + \__tl_build_end: + \l__regex_internal_a_tl } -\cs_new:Npn \regex_escape_loop:N #1 +\cs_new:Npn \__regex_escape_loop:N #1 { - \cs_if_exist_use:cF { regex_escape_\token_to_str:N #1:w } - { \regex_escape_unescaped:N #1 } - \regex_escape_loop:N + \cs_if_exist_use:cF { __regex_escape_\token_to_str:N #1:w } + { \__regex_escape_unescaped:N #1 } + \__regex_escape_loop:N } -\cs_new_nopar:cpn { regex_escape_ \c_backslash_str :w } - \regex_escape_loop:N #1 +\cs_new_nopar:cpn { __regex_escape_ \c_backslash_str :w } + \__regex_escape_loop:N #1 { - \cs_if_exist_use:cF { regex_escape_/\token_to_str:N #1:w } - { \regex_escape_escaped:N #1 } - \regex_escape_loop:N + \cs_if_exist_use:cF { __regex_escape_/\token_to_str:N #1:w } + { \__regex_escape_escaped:N #1 } + \__regex_escape_loop:N } -\cs_new_eq:NN \regex_escape_unescaped:N ? -\cs_new_eq:NN \regex_escape_escaped:N ? -\cs_new_eq:NN \regex_escape_raw:N ? -\cs_new_eq:NN \regex_escape_break:w \prg_map_break: -\cs_new_nopar:cpn { regex_escape_/break:w } +\cs_new_eq:NN \__regex_escape_unescaped:N ? +\cs_new_eq:NN \__regex_escape_escaped:N ? +\cs_new_eq:NN \__regex_escape_raw:N ? +\cs_new_eq:NN \__regex_escape_break:w \__prg_break: +\cs_new_nopar:cpn { __regex_escape_/break:w } { \if_false: { \fi: } - \msg_kernel_error:nn { regex } { trailing-backslash } + \__msg_kernel_error:nn { regex } { trailing-backslash } \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi: } -\cs_new_nopar:cpn { regex_escape_~:w } { } -\cs_new_nopar:cpx { regex_escape_/a:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^G } -\cs_new_nopar:cpx { regex_escape_/t:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^I } -\cs_new_nopar:cpx { regex_escape_/n:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^J } -\cs_new_nopar:cpx { regex_escape_/f:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^L } -\cs_new_nopar:cpx { regex_escape_/r:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^M } -\cs_new_nopar:cpx { regex_escape_/e:w } - { \exp_not:N \regex_escape_raw:N \iow_char:N \^^[ } -\cs_new:cpn { regex_escape_/x:w } \regex_escape_loop:N - { - \exp_after:wN \regex_escape_x_end:w - \int_value:w "0 \regex_escape_x_test:N - } -\cs_new:Npn \regex_escape_x_end:w #1 ; +\cs_new_nopar:cpn { __regex_escape_~:w } { } +\cs_new_nopar:cpx { __regex_escape_/a:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^G } +\cs_new_nopar:cpx { __regex_escape_/t:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^I } +\cs_new_nopar:cpx { __regex_escape_/n:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^J } +\cs_new_nopar:cpx { __regex_escape_/f:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^L } +\cs_new_nopar:cpx { __regex_escape_/r:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^M } +\cs_new_nopar:cpx { __regex_escape_/e:w } + { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^[ } +\cs_new:cpn { __regex_escape_/x:w } \__regex_escape_loop:N + { + \exp_after:wN \__regex_escape_x_end:w + \__int_value:w "0 \__regex_escape_x_test:N + } +\cs_new:Npn \__regex_escape_x_end:w #1 ; { \int_compare:nNnTF {#1} < \c_two_hundred_fifty_six { - \exp_last_unbraced:Nf \regex_escape_raw:N - { \str_output_byte:n {#1} } + \exp_last_unbraced:Nf \__regex_escape_raw:N + { \__str_output_byte:n {#1} } } - { \regex_escape_x_large:n {#1} } + { \__regex_escape_x_large:n {#1} } } \group_begin: \char_set_catcode_other:n { 0 } - \cs_new:Npn \regex_escape_x_large:n #1 + \cs_new:Npn \__regex_escape_x_large:n #1 { \if_false: { \fi: } - \tl_build_one:o \l_regex_internal_b_tl + \__tl_build_one:o \l__regex_internal_b_tl \int_compare:nNnTF {#1} > \c_max_char_int { - \msg_kernel_error:nnx { regex } { x-overflow } {#1} - \tl_set:Nx \l_regex_internal_b_tl - { \if_false: } \fi: \regex_escape_loop:N + \__msg_kernel_error:nnx { regex } { x-overflow } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: \__regex_escape_loop:N } { \char_set_lccode:nn { \c_zero } {#1} \tl_to_lowercase:n { - \tl_set:Nx \l_regex_internal_b_tl + \tl_set:Nx \l__regex_internal_b_tl { \if_false: } \fi: - \regex_escape_raw:N ^^@ - \regex_escape_loop:N + \__regex_escape_raw:N ^^@ + \__regex_escape_loop:N } } } \group_end: -\cs_new:Npn \regex_escape_x_test:N #1 +\cs_new:Npn \__regex_escape_x_test:N #1 { - \str_if_eq:xxTF {#1} { break } { ; } + \str_if_eq_x:nnTF {#1} { break } { ; } { \if_charcode:w \c_space_token #1 - \exp_after:wN \regex_escape_x_test:N + \exp_after:wN \__regex_escape_x_test:N \else: - \exp_after:wN \regex_escape_x_test_ii:N + \exp_after:wN \__regex_escape_x_test_ii:N \exp_after:wN #1 \fi: } } -\cs_new:Npn \regex_escape_x_test_ii:N #1 +\cs_new:Npn \__regex_escape_x_test_ii:N #1 { \if_charcode:w \c_lbrace_str #1 - \exp_after:wN \regex_escape_x_loop:N + \exp_after:wN \__regex_escape_x_loop:N \else: - \str_aux_hexadecimal_use:NTF #1 - { \exp_after:wN \regex_escape_x_ii:N } - { ; \exp_after:wN \regex_escape_loop:N \exp_after:wN #1 } + \__str_hexadecimal_use:NTF #1 + { \exp_after:wN \__regex_escape_x_ii:N } + { ; \exp_after:wN \__regex_escape_loop:N \exp_after:wN #1 } \fi: } -\cs_new:Npn \regex_escape_x_ii:N #1 +\cs_new:Npn \__regex_escape_x_ii:N #1 { - \str_if_eq:xxTF {#1} { break } { ; } + \str_if_eq_x:nnTF {#1} { break } { ; } { - \str_aux_hexadecimal_use:NTF #1 - { ; \regex_escape_loop:N } - { ; \regex_escape_loop:N #1 } + \__str_hexadecimal_use:NTF #1 + { ; \__regex_escape_loop:N } + { ; \__regex_escape_loop:N #1 } } } -\cs_new:Npn \regex_escape_x_loop:N #1 +\cs_new:Npn \__regex_escape_x_loop:N #1 { - \str_aux_hexadecimal_use:NTF #1 - { \regex_escape_x_loop:N } + \__str_hexadecimal_use:NTF #1 + { \__regex_escape_x_loop:N } { \token_if_eq_charcode:NNTF \c_space_token #1 - { \regex_escape_x_loop:N } + { \__regex_escape_x_loop:N } { ; \exp_after:wN \token_if_eq_charcode:NNTF \c_rbrace_str #1 - { \regex_escape_loop:N } + { \__regex_escape_loop:N } { \if_false: { \fi: } - \tl_build_one:o \l_regex_internal_b_tl - \msg_kernel_error:nn { regex } { x-missing-rbrace } {#1} - \tl_set:Nx \l_regex_internal_b_tl - { \if_false: } \fi: \regex_escape_loop:N #1 + \__tl_build_one:o \l__regex_internal_b_tl + \__msg_kernel_error:nn { regex } { x-missing-rbrace } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: \__regex_escape_loop:N #1 } } } } -\prg_new_conditional:Npnn \regex_char_if_special:N #1 { TF } +\prg_new_conditional:Npnn \__regex_char_if_special:N #1 { TF } { - \if_num:w `#1 < \c_ninety_one - \if_num:w `#1 < \c_fifty_eight - \if_num:w `#1 < \c_forty_eight - \if_num:w `#1 < \c_thirty_two + \if_int_compare:w `#1 < \c_ninety_one + \if_int_compare:w `#1 < \c_fifty_eight + \if_int_compare:w `#1 < \c_forty_eight + \if_int_compare:w `#1 < \c_thirty_two \prg_return_false: \else: \prg_return_true: \fi: \else: \prg_return_false: \fi: \else: - \if_num:w `#1 < \c_sixty_five + \if_int_compare:w `#1 < \c_sixty_five \prg_return_true: \else: \prg_return_false: \fi: \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_three - \if_num:w `#1 < \c_ninety_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_three + \if_int_compare:w `#1 < \c_ninety_seven \prg_return_true: \else: \prg_return_false: \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_seven \prg_return_true: \else: \prg_return_false: \fi: \fi: \fi: } -\prg_new_conditional:Npnn \regex_char_if_alphanumeric:N #1 { TF } +\prg_new_conditional:Npnn \__regex_char_if_alphanumeric:N #1 { TF } { - \if_num:w `#1 < \c_ninety_one - \if_num:w `#1 < \c_fifty_eight - \if_num:w `#1 < \c_forty_eight + \if_int_compare:w `#1 < \c_ninety_one + \if_int_compare:w `#1 < \c_fifty_eight + \if_int_compare:w `#1 < \c_forty_eight \prg_return_false: \else: \prg_return_true: \fi: \else: - \if_num:w `#1 < \c_sixty_five + \if_int_compare:w `#1 < \c_sixty_five \prg_return_false: \else: \prg_return_true: \fi: \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_three - \if_num:w `#1 < \c_ninety_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_three + \if_int_compare:w `#1 < \c_ninety_seven \prg_return_false: \else: \prg_return_true: \fi: \else: \prg_return_false: \fi: \fi: } -\int_new:N \l_regex_group_level_int -\int_new:N \l_regex_mode_int -\int_new:N \l_regex_catcodes_int -\int_new:N \l_regex_default_catcodes_int -\bool_new:N \l_regex_catcodes_bool -\int_const:Nn \c_regex_catcode_C_int { "1 } -\int_const:Nn \c_regex_catcode_B_int { "4 } -\int_const:Nn \c_regex_catcode_E_int { "10 } -\int_const:Nn \c_regex_catcode_M_int { "40 } -\int_const:Nn \c_regex_catcode_T_int { "100 } -\int_const:Nn \c_regex_catcode_P_int { "1000 } -\int_const:Nn \c_regex_catcode_U_int { "4000 } -\int_const:Nn \c_regex_catcode_D_int { "10000 } -\int_const:Nn \c_regex_catcode_S_int { "100000 } -\int_const:Nn \c_regex_catcode_L_int { "400000 } -\int_const:Nn \c_regex_catcode_O_int { "1000000 } -\int_const:Nn \c_regex_catcode_A_int { "4000000 } -\int_const:Nn \c_regex_all_catcodes_int { "5515155 } -\cs_new_eq:NN \l_regex_internal_regex \c_regex_no_match_regex -\seq_new:N \l_regex_show_prefix_seq -\int_new:N \l_regex_show_lines_int -\cs_new_protected:Npn \regex_get_digits:NTFw #1#2#3#4#5 - { - \regex_if_raw_digit:NNTF #4 #5 - { #1 = #5 \regex_get_digits_loop:nw {#2} } +\int_new:N \l__regex_group_level_int +\int_new:N \l__regex_mode_int +\int_new:N \l__regex_catcodes_int +\int_new:N \l__regex_default_catcodes_int +\bool_new:N \l__regex_catcodes_bool +\int_const:Nn \c__regex_catcode_C_int { "1 } +\int_const:Nn \c__regex_catcode_B_int { "4 } +\int_const:Nn \c__regex_catcode_E_int { "10 } +\int_const:Nn \c__regex_catcode_M_int { "40 } +\int_const:Nn \c__regex_catcode_T_int { "100 } +\int_const:Nn \c__regex_catcode_P_int { "1000 } +\int_const:Nn \c__regex_catcode_U_int { "4000 } +\int_const:Nn \c__regex_catcode_D_int { "10000 } +\int_const:Nn \c__regex_catcode_S_int { "100000 } +\int_const:Nn \c__regex_catcode_L_int { "400000 } +\int_const:Nn \c__regex_catcode_O_int { "1000000 } +\int_const:Nn \c__regex_catcode_A_int { "4000000 } +\int_const:Nn \c__regex_all_catcodes_int { "5515155 } +\cs_new_eq:NN \l__regex_internal_regex \c__regex_no_match_regex +\seq_new:N \l__regex_show_prefix_seq +\int_new:N \l__regex_show_lines_int +\cs_new_protected:Npn \__regex_get_digits:NTFw #1#2#3#4#5 + { + \__regex_if_raw_digit:NNTF #4 #5 + { #1 = #5 \__regex_get_digits_loop:nw {#2} } { #3 #4 #5 } } -\cs_new:Npn \regex_get_digits_loop:nw #1#2#3 +\cs_new:Npn \__regex_get_digits_loop:nw #1#2#3 { - \regex_if_raw_digit:NNTF #2 #3 - { #3 \regex_get_digits_loop:nw {#1} } + \__regex_if_raw_digit:NNTF #2 #3 + { #3 \__regex_get_digits_loop:nw {#1} } { \scan_stop: #1 #2 #3 } } -\prg_new_conditional:Npnn \regex_if_raw_digit:NN #1#2 { TF } +\prg_new_conditional:Npnn \__regex_if_raw_digit:NN #1#2 { TF } { - \if_meaning:w \regex_compile_raw:N #1 + \if_meaning:w \__regex_compile_raw:N #1 \if_int_compare:w \c_one < 1 #2 \exp_stop_f: \prg_return_true: \else: @@ -495,305 +495,305 @@ \prg_return_false: \fi: } -\cs_new_nopar:Npn \regex_if_in_class:TF +\cs_new_nopar:Npn \__regex_if_in_class:TF { - \if_int_odd:w \l_regex_mode_int + \if_int_odd:w \l__regex_mode_int \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: } -\cs_new_nopar:Npn \regex_if_in_cs:TF +\cs_new_nopar:Npn \__regex_if_in_cs:TF { - \if_int_odd:w \l_regex_mode_int + \if_int_odd:w \l__regex_mode_int \exp_after:wN \use_ii:nn \else: - \if_int_compare:w \l_regex_mode_int < \c_zero + \if_int_compare:w \l__regex_mode_int < \c_zero \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn \else: \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn \fi: \fi: } -\cs_new_nopar:Npn \regex_if_in_class_or_catcode:TF +\cs_new_nopar:Npn \__regex_if_in_class_or_catcode:TF { - \if_int_odd:w \l_regex_mode_int + \if_int_odd:w \l__regex_mode_int \exp_after:wN \use_i:nn \else: - \if_int_compare:w \l_regex_mode_int > \c_zero + \if_int_compare:w \l__regex_mode_int > \c_zero \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nn \else: \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn \fi: \fi: } -\cs_new_nopar:Npn \regex_if_within_catcode:TF +\cs_new_nopar:Npn \__regex_if_within_catcode:TF { - \if_int_compare:w \l_regex_mode_int > \c_zero + \if_int_compare:w \l__regex_mode_int > \c_zero \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: } -\cs_new_protected:Npn \regex_chk_c_allowed:T +\cs_new_protected:Npn \__regex_chk_c_allowed:T { - \if_num:w \l_regex_mode_int = \c_zero + \if_int_compare:w \l__regex_mode_int = \c_zero \exp_after:wN \use:n \else: - \if_num:w \l_regex_mode_int = \c_three + \if_int_compare:w \l__regex_mode_int = \c_three \exp_after:wN \exp_after:wN \exp_after:wN \use:n \else: - \msg_kernel_error:nn { regex } { c-bad-mode } + \__msg_kernel_error:nn { regex } { c-bad-mode } \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n \fi: \fi: } -\cs_new_protected:Npn \regex_mode_quit_c: +\cs_new_protected:Npn \__regex_mode_quit_c: { - \if_num:w \l_regex_mode_int = \c_two - \l_regex_mode_int = \c_zero + \if_int_compare:w \l__regex_mode_int = \c_two + \l__regex_mode_int = \c_zero \else: - \if_num:w \l_regex_mode_int = \c_six - \l_regex_mode_int = \c_three + \if_int_compare:w \l__regex_mode_int = \c_six + \l__regex_mode_int = \c_three \fi: \fi: } -\cs_new_protected_nopar:Npn \regex_compile:w +\cs_new_protected_nopar:Npn \__regex_compile:w { - \tl_set_build_x:Nw \l_regex_internal_regex - \int_zero:N \l_regex_group_level_int - \int_set_eq:NN \l_regex_default_catcodes_int \c_regex_all_catcodes_int - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \cs_set_nopar:Npn \regex_item_equal:n { \regex_item_caseful_equal:n } - \cs_set_nopar:Npn \regex_item_range:nn { \regex_item_caseful_range:nn } - \tl_build_one:n { \regex_branch:n { \if_false: } \fi: } + \__tl_build_x:Nw \l__regex_internal_regex + \int_zero:N \l__regex_group_level_int + \int_set_eq:NN \l__regex_default_catcodes_int \c__regex_all_catcodes_int + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \cs_set_nopar:Npn \__regex_item_equal:n { \__regex_item_caseful_equal:n } + \cs_set_nopar:Npn \__regex_item_range:nn { \__regex_item_caseful_range:nn } + \__tl_build_one:n { \__regex_branch:n { \if_false: } \fi: } } -\cs_new_protected_nopar:Npn \regex_compile_end: +\cs_new_protected_nopar:Npn \__regex_compile_end: { - \regex_if_in_class:TF + \__regex_if_in_class:TF { - \msg_kernel_error:nn { regex } { missing-rbrack } - \use:c { regex_compile_]: } + \__msg_kernel_error:nn { regex } { missing-rbrack } + \use:c { __regex_compile_]: } \prg_do_nothing: \prg_do_nothing: } { } - \if_num:w \l_regex_group_level_int > \c_zero - \msg_kernel_error:nnx { regex } { missing-rparen } - { \int_use:N \l_regex_group_level_int } + \if_int_compare:w \l__regex_group_level_int > \c_zero + \__msg_kernel_error:nnx { regex } { missing-rparen } + { \int_use:N \l__regex_group_level_int } \prg_replicate:nn - { \l_regex_group_level_int } + { \l__regex_group_level_int } { - \tl_build_one:n + \__tl_build_one:n { \if_false: { \fi: } \if_false: { \fi: } { 1 } { 0 } \c_true_bool } - \tl_build_end: - \tl_build_one:o \l_regex_internal_regex + \__tl_build_end: + \__tl_build_one:o \l__regex_internal_regex } \fi: - \tl_build_one:n { \if_false: { \fi: } } - \tl_build_end: + \__tl_build_one:n { \if_false: { \fi: } } + \__tl_build_end: } -\cs_new_protected:Npn \regex_compile:n #1 +\cs_new_protected:Npn \__regex_compile:n #1 { - \regex_compile:w + \__regex_compile:w \int_set:Nn \tex_escapechar:D { 92 } - \int_set_eq:NN \l_regex_mode_int \c_zero - \regex_escape_use:nnnn + \int_set_eq:NN \l__regex_mode_int \c_zero + \__regex_escape_use:nnnn { - \regex_char_if_special:NTF ##1 - \regex_compile_special:N \regex_compile_raw:N ##1 + \__regex_char_if_special:NTF ##1 + \__regex_compile_special:N \__regex_compile_raw:N ##1 } { - \regex_char_if_alphanumeric:NTF ##1 - \regex_compile_escaped:N \regex_compile_raw:N ##1 + \__regex_char_if_alphanumeric:NTF ##1 + \__regex_compile_escaped:N \__regex_compile_raw:N ##1 } - { \regex_compile_raw:N ##1 } + { \__regex_compile_raw:N ##1 } { #1 } \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: - \int_compare:nNnT \l_regex_mode_int < \c_zero + \int_compare:nNnT \l__regex_mode_int < \c_zero { - \msg_kernel_error:nn { regex } { c-missing-rbrace } - \regex_compile_end: - \regex_compile_one:x - { \regex_item_cs:n { \exp_not:o \l_regex_internal_regex } } + \__msg_kernel_error:nn { regex } { c-missing-rbrace } + \__regex_compile_end: + \__regex_compile_one:x + { \__regex_item_cs:n { \exp_not:o \l__regex_internal_regex } } \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: } - \regex_compile_end: + \__regex_compile_end: } -\cs_new_protected:Npn \regex_compile_special:N #1 +\cs_new_protected:Npn \__regex_compile_special:N #1 { - \cs_if_exist_use:cF { regex_compile_#1: } - { \regex_compile_raw:N #1 } + \cs_if_exist_use:cF { __regex_compile_#1: } + { \__regex_compile_raw:N #1 } } -\cs_new_protected:Npn \regex_compile_escaped:N #1 +\cs_new_protected:Npn \__regex_compile_escaped:N #1 { - \cs_if_exist_use:cF { regex_compile_/#1: } - { \regex_compile_raw:N #1 } + \cs_if_exist_use:cF { __regex_compile_/#1: } + { \__regex_compile_raw:N #1 } } -\cs_new_protected:Npn \regex_compile_one:x #1 +\cs_new_protected:Npn \__regex_compile_one:x #1 { - \regex_mode_quit_c: - \regex_if_in_class:TF { } + \__regex_mode_quit_c: + \__regex_if_in_class:TF { } { - \tl_build_one:n - { \regex_class:NnnnN \c_true_bool { \if_false: } \fi: } + \__tl_build_one:n + { \__regex_class:NnnnN \c_true_bool { \if_false: } \fi: } } - \tl_build_one:x + \__tl_build_one:x { - \if_num:w \l_regex_catcodes_int < \c_regex_all_catcodes_int - \regex_item_catcode:nT { \int_use:N \l_regex_catcodes_int } + \if_int_compare:w \l__regex_catcodes_int < \c__regex_all_catcodes_int + \__regex_item_catcode:nT { \int_use:N \l__regex_catcodes_int } { \exp_not:N \exp_not:n {#1} } \else: \exp_not:N \exp_not:n {#1} \fi: } - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \regex_if_in_class:TF { } { \regex_compile_quantifier:w } + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \__regex_if_in_class:TF { } { \__regex_compile_quantifier:w } } -\cs_new_protected:Npn \regex_compile_abort_tokens:n #1 +\cs_new_protected:Npn \__regex_compile_abort_tokens:n #1 { \use:x { \exp_args:No \tl_map_function:nN { \tl_to_str:n {#1} } - \regex_compile_raw:N + \__regex_compile_raw:N } } -\cs_generate_variant:Nn \regex_compile_abort_tokens:n { x } -\cs_new_protected:Npn \regex_compile_quantifier:w #1#2 +\cs_generate_variant:Nn \__regex_compile_abort_tokens:n { x } +\cs_new_protected:Npn \__regex_compile_quantifier:w #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_special:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N { - \cs_if_exist_use:cF { regex_compile_quantifier_#2:w } - { \regex_compile_quantifier_none: #1 #2 } + \cs_if_exist_use:cF { __regex_compile_quantifier_#2:w } + { \__regex_compile_quantifier_none: #1 #2 } } - { \regex_compile_quantifier_none: #1 #2 } + { \__regex_compile_quantifier_none: #1 #2 } } -\cs_new_protected:Npn \regex_compile_quantifier_none: - { \tl_build_one:n { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } } -\cs_new_protected:Npn \regex_compile_quantifier_abort:xNN #1#2#3 +\cs_new_protected:Npn \__regex_compile_quantifier_none: + { \__tl_build_one:n { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } } +\cs_new_protected:Npn \__regex_compile_quantifier_abort:xNN #1#2#3 { - \regex_compile_quantifier_none: - \msg_kernel_warning:nnxx { regex } { invalid-quantifier } {#1} {#3} - \regex_compile_abort_tokens:x {#1} + \__regex_compile_quantifier_none: + \__msg_kernel_warning:nnxx { regex } { invalid-quantifier } {#1} {#3} + \__regex_compile_abort_tokens:x {#1} #2 #3 } -\cs_new_protected:Npn \regex_compile_quantifier_lazyness:nnNN #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_quantifier_lazyness:nnNN #1#2#3#4 { - \str_if_eq:nnTF { #3 #4 } { \regex_compile_special:N ? } - { \tl_build_one:n { \if_false: { \fi: } { #1 } { #2 } \c_true_bool } } + \str_if_eq:nnTF { #3 #4 } { \__regex_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_one:n { \if_false: { \fi: } { #1 } { #2 } \c_false_bool } #3 #4 } } -\cs_new_protected_nopar:cpn { regex_compile_quantifier_?:w } - { \regex_compile_quantifier_lazyness:nnNN { 0 } { 1 } } -\cs_new_protected_nopar:cpn { regex_compile_quantifier_*:w } - { \regex_compile_quantifier_lazyness:nnNN { 0 } { -1 } } -\cs_new_protected_nopar:cpn { regex_compile_quantifier_+:w } - { \regex_compile_quantifier_lazyness:nnNN { 1 } { -1 } } -\cs_new_protected:cpn { regex_compile_quantifier_ \c_lbrace_str :w } +\cs_new_protected_nopar:cpn { __regex_compile_quantifier_?:w } + { \__regex_compile_quantifier_lazyness:nnNN { 0 } { 1 } } +\cs_new_protected_nopar:cpn { __regex_compile_quantifier_*:w } + { \__regex_compile_quantifier_lazyness:nnNN { 0 } { -1 } } +\cs_new_protected_nopar:cpn { __regex_compile_quantifier_+:w } + { \__regex_compile_quantifier_lazyness:nnNN { 1 } { -1 } } +\cs_new_protected:cpn { __regex_compile_quantifier_ \c_lbrace_str :w } { - \regex_get_digits:NTFw \l_regex_internal_a_int - { \regex_compile_quantifier_braced_i:w } - { \regex_compile_quantifier_abort:xNN { \c_lbrace_str } } + \__regex_get_digits:NTFw \l__regex_internal_a_int + { \__regex_compile_quantifier_braced_i:w } + { \__regex_compile_quantifier_abort:xNN { \c_lbrace_str } } } -\cs_new_protected:Npn \regex_compile_quantifier_braced_i:w #1#2 +\cs_new_protected:Npn \__regex_compile_quantifier_braced_i:w #1#2 { - \prg_case_str:xxn { #1 #2 } + \str_case_x:nnn { #1 #2 } { - { \regex_compile_special:N \c_rbrace_str } + { \__regex_compile_special:N \c_rbrace_str } { - \exp_args:No \regex_compile_quantifier_lazyness:nnNN - { \int_use:N \l_regex_internal_a_int } { 0 } + \exp_args:No \__regex_compile_quantifier_lazyness:nnNN + { \int_use:N \l__regex_internal_a_int } { 0 } } - { \regex_compile_special:N , } + { \__regex_compile_special:N , } { - \regex_get_digits:NTFw \l_regex_internal_b_int - { \regex_compile_quantifier_braced_iii:w } - { \regex_compile_quantifier_braced_ii:w } + \__regex_get_digits:NTFw \l__regex_internal_b_int + { \__regex_compile_quantifier_braced_iii:w } + { \__regex_compile_quantifier_braced_ii:w } } } { - \regex_compile_quantifier_abort:xNN - { \c_lbrace_str \int_use:N \l_regex_internal_a_int } + \__regex_compile_quantifier_abort:xNN + { \c_lbrace_str \int_use:N \l__regex_internal_a_int } #1 #2 } } -\cs_new_protected:Npn \regex_compile_quantifier_braced_ii:w #1#2 +\cs_new_protected:Npn \__regex_compile_quantifier_braced_ii:w #1#2 { - \str_if_eq:xxTF - { #1 #2 } { \regex_compile_special:N \c_rbrace_str } + \str_if_eq_x:nnTF + { #1 #2 } { \__regex_compile_special:N \c_rbrace_str } { - \exp_args:No \regex_compile_quantifier_lazyness:nnNN - { \int_use:N \l_regex_internal_a_int } { -1 } + \exp_args:No \__regex_compile_quantifier_lazyness:nnNN + { \int_use:N \l__regex_internal_a_int } { -1 } } { - \regex_compile_quantifier_abort:xNN - { \c_lbrace_str \int_use:N \l_regex_internal_a_int , } + \__regex_compile_quantifier_abort:xNN + { \c_lbrace_str \int_use:N \l__regex_internal_a_int , } #1 #2 } } -\cs_new_protected:Npn \regex_compile_quantifier_braced_iii:w #1#2 +\cs_new_protected:Npn \__regex_compile_quantifier_braced_iii:w #1#2 { - \str_if_eq:xxTF - { #1 #2 } { \regex_compile_special:N \c_rbrace_str } + \str_if_eq_x:nnTF + { #1 #2 } { \__regex_compile_special:N \c_rbrace_str } { - \if_num:w \l_regex_internal_a_int > \l_regex_internal_b_int - \msg_kernel_error:nnxx { regex } { backwards-quantifier } - { \int_use:N \l_regex_internal_a_int } - { \int_use:N \l_regex_internal_b_int } - \int_zero:N \l_regex_internal_b_int + \if_int_compare:w \l__regex_internal_a_int > \l__regex_internal_b_int + \__msg_kernel_error:nnxx { regex } { backwards-quantifier } + { \int_use:N \l__regex_internal_a_int } + { \int_use:N \l__regex_internal_b_int } + \int_zero:N \l__regex_internal_b_int \else: - \int_sub:Nn \l_regex_internal_b_int \l_regex_internal_a_int + \int_sub:Nn \l__regex_internal_b_int \l__regex_internal_a_int \fi: - \exp_args:Noo \regex_compile_quantifier_lazyness:nnNN - { \int_use:N \l_regex_internal_a_int } - { \int_use:N \l_regex_internal_b_int } + \exp_args:Noo \__regex_compile_quantifier_lazyness:nnNN + { \int_use:N \l__regex_internal_a_int } + { \int_use:N \l__regex_internal_b_int } } { - \regex_compile_quantifier_abort:xNN + \__regex_compile_quantifier_abort:xNN { \c_lbrace_str - \int_use:N \l_regex_internal_a_int , - \int_use:N \l_regex_internal_b_int + \int_use:N \l__regex_internal_a_int , + \int_use:N \l__regex_internal_b_int } #1 #2 } } -\cs_new_protected:Npn \regex_compile_raw_error:N #1 +\cs_new_protected:Npn \__regex_compile_raw_error:N #1 { - \msg_kernel_error:nnx { regex } { bad-escape } {#1} - \regex_compile_raw:N #1 + \__msg_kernel_error:nnx { regex } { bad-escape } {#1} + \__regex_compile_raw:N #1 } -\cs_new_protected:Npn \regex_compile_raw:N #1#2#3 +\cs_new_protected:Npn \__regex_compile_raw:N #1#2#3 { - \regex_if_in_class:TF + \__regex_if_in_class:TF { - \str_if_eq:nnTF {#2#3} { \regex_compile_special:N - } - { \regex_compile_range:Nw #1 } + \str_if_eq:nnTF {#2#3} { \__regex_compile_special:N - } + { \__regex_compile_range:Nw #1 } { - \regex_compile_one:x - { \regex_item_equal:n { \int_value:w `#1 ~ } } + \__regex_compile_one:x + { \__regex_item_equal:n { \__int_value:w `#1 ~ } } #2 #3 } } { - \regex_compile_one:x - { \regex_item_equal:n { \int_value:w `#1 ~ } } + \__regex_compile_one:x + { \__regex_item_equal:n { \__int_value:w `#1 ~ } } #2 #3 } } -\prg_new_protected_conditional:Npnn \regex_if_end_range:NN #1#2 { TF } +\prg_new_protected_conditional:Npnn \__regex_if_end_range:NN #1#2 { TF } { - \if_meaning:w \regex_compile_raw:N #1 + \if_meaning:w \__regex_compile_raw:N #1 \prg_return_true: \else: - \if_meaning:w \regex_compile_special:N #1 + \if_meaning:w \__regex_compile_special:N #1 \if_charcode:w ] #2 \prg_return_false: \else: @@ -804,1790 +804,1798 @@ \fi: \fi: } -\cs_new_protected:Npn \regex_compile_range:Nw #1#2#3 +\cs_new_protected:Npn \__regex_compile_range:Nw #1#2#3 { - \regex_if_end_range:NNTF #2 #3 + \__regex_if_end_range:NNTF #2 #3 { - \if_num:w `#1 > `#3 \exp_stop_f: - \msg_kernel_error:nnxx { regex } { range-backwards } {#1} {#3} + \if_int_compare:w `#1 > `#3 \exp_stop_f: + \__msg_kernel_error:nnxx { regex } { range-backwards } {#1} {#3} \else: - \tl_build_one:x + \__tl_build_one:x { - \if_num:w `#1 = `#3 \exp_stop_f: - \regex_item_equal:n + \if_int_compare:w `#1 = `#3 \exp_stop_f: + \__regex_item_equal:n \else: - \regex_item_range:nn { \int_value:w `#1 ~ } + \__regex_item_range:nn { \__int_value:w `#1 ~ } \fi: - { \int_value:w `#3 ~ } + { \__int_value:w `#3 ~ } } \fi: } { - \msg_kernel_warning:nnxx { regex } { range-missing-end } + \__msg_kernel_warning:nnxx { regex } { range-missing-end } {#1} { \c_backslash_str #3 } - \tl_build_one:x + \__tl_build_one:x { - \regex_item_equal:n { \int_value:w `#1 ~ } - \regex_item_equal:n { \int_value:w `- ~ } + \__regex_item_equal:n { \__int_value:w `#1 ~ } + \__regex_item_equal:n { \__int_value:w `- ~ } } #2#3 } } -\cs_new_protected_nopar:cpx { regex_compile_.: } +\cs_new_protected_nopar:cpx { __regex_compile_.: } { - \exp_not:N \regex_if_in_class:TF - { \regex_compile_raw:N . } - { \regex_compile_one:x \exp_not:c { regex_prop_.: } } + \exp_not:N \__regex_if_in_class:TF + { \__regex_compile_raw:N . } + { \__regex_compile_one:x \exp_not:c { __regex_prop_.: } } } -\cs_new_protected_nopar:cpn { regex_prop_.: } +\cs_new_protected_nopar:cpn { __regex_prop_.: } { - \if_num:w \l_regex_current_char_int > - \c_two - \exp_after:wN \regex_break_true:w + \if_int_compare:w \l__regex_current_char_int > - \c_two + \exp_after:wN \__regex_break_true:w \fi: } -\cs_set_protected:Npn \regex_tmp:w #1#2 +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \cs_new_protected_nopar:cpx { regex_compile_/#1: } - { \regex_compile_one:x \exp_not:c { regex_prop_#1: } } - \cs_new_protected_nopar:cpx { regex_compile_/#2: } + \cs_new_protected_nopar:cpx { __regex_compile_/#1: } + { \__regex_compile_one:x \exp_not:c { __regex_prop_#1: } } + \cs_new_protected_nopar:cpx { __regex_compile_/#2: } { - \regex_compile_one:x - { \regex_item_reverse:n \exp_not:c { regex_prop_#1: } } + \__regex_compile_one:x + { \__regex_item_reverse:n \exp_not:c { __regex_prop_#1: } } } } -\regex_tmp:w d D -\regex_tmp:w h H -\regex_tmp:w s S -\regex_tmp:w v V -\regex_tmp:w w W -\cs_new_protected_nopar:cpn { regex_compile_/N: } - { \regex_compile_one:x \regex_prop_N: } -\cs_new_protected:Npn \regex_compile_anchor:NF #1#2 +\__regex_tmp:w d D +\__regex_tmp:w h H +\__regex_tmp:w s S +\__regex_tmp:w v V +\__regex_tmp:w w W +\cs_new_protected_nopar:cpn { __regex_compile_/N: } + { \__regex_compile_one:x \__regex_prop_N: } +\cs_new_protected:Npn \__regex_compile_anchor:NF #1#2 { - \regex_if_in_class_or_catcode:TF {#2} + \__regex_if_in_class_or_catcode:TF {#2} { - \tl_build_one:n - { \regex_assertion:Nn \c_true_bool { \regex_anchor:N #1 } } + \__tl_build_one:n + { \__regex_assertion:Nn \c_true_bool { \__regex_anchor:N #1 } } } } -\cs_set_protected:Npn \regex_tmp:w #1#2 +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \cs_new_protected_nopar:cpn { regex_compile_/#1: } - { \regex_compile_anchor:NF #2 { \regex_compile_raw_error:N #1 } } + \cs_new_protected_nopar:cpn { __regex_compile_/#1: } + { \__regex_compile_anchor:NF #2 { \__regex_compile_raw_error:N #1 } } } -\regex_tmp:w A \l_regex_min_pos_int -\regex_tmp:w G \l_regex_start_pos_int -\regex_tmp:w Z \l_regex_max_pos_int -\regex_tmp:w z \l_regex_max_pos_int -\cs_set_protected:Npn \regex_tmp:w #1#2 +\__regex_tmp:w A \l__regex_min_pos_int +\__regex_tmp:w G \l__regex_start_pos_int +\__regex_tmp:w Z \l__regex_max_pos_int +\__regex_tmp:w z \l__regex_max_pos_int +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \cs_new_protected_nopar:cpn { regex_compile_#1: } - { \regex_compile_anchor:NF #2 { \regex_compile_raw:N #1 } } + \cs_new_protected_nopar:cpn { __regex_compile_#1: } + { \__regex_compile_anchor:NF #2 { \__regex_compile_raw:N #1 } } } -\exp_args:Nx \regex_tmp:w { \iow_char:N \^ } \l_regex_min_pos_int -\exp_args:Nx \regex_tmp:w { \iow_char:N \$ } \l_regex_max_pos_int -\cs_new_protected_nopar:cpn { regex_compile_/b: } +\exp_args:Nx \__regex_tmp:w { \iow_char:N \^ } \l__regex_min_pos_int +\exp_args:Nx \__regex_tmp:w { \iow_char:N \$ } \l__regex_max_pos_int +\cs_new_protected_nopar:cpn { __regex_compile_/b: } { - \regex_if_in_class_or_catcode:TF - { \regex_compile_raw_error:N b } + \__regex_if_in_class_or_catcode:TF + { \__regex_compile_raw_error:N b } { - \tl_build_one:n - { \regex_assertion:Nn \c_true_bool { \regex_b_test: } } + \__tl_build_one:n + { \__regex_assertion:Nn \c_true_bool { \__regex_b_test: } } } } -\cs_new_protected_nopar:cpn { regex_compile_/B: } +\cs_new_protected_nopar:cpn { __regex_compile_/B: } { - \regex_if_in_class_or_catcode:TF - { \regex_compile_raw_error:N B } + \__regex_if_in_class_or_catcode:TF + { \__regex_compile_raw_error:N B } { - \tl_build_one:n - { \regex_assertion:Nn \c_false_bool { \regex_b_test: } } + \__tl_build_one:n + { \__regex_assertion:Nn \c_false_bool { \__regex_b_test: } } } } -\cs_new_protected:cpn { regex_compile_]: } +\cs_new_protected:cpn { __regex_compile_]: } { - \regex_if_in_class:TF + \__regex_if_in_class:TF { - \if_num:w \l_regex_mode_int > \c_sixteen - \tl_build_one:n { \if_false: { \fi: } } + \if_int_compare:w \l__regex_mode_int > \c_sixteen + \__tl_build_one:n { \if_false: { \fi: } } \fi: - \tex_advance:D \l_regex_mode_int - \c_fifteen - \tex_divide:D \l_regex_mode_int \c_thirteen - \if_int_odd:w \l_regex_mode_int \else: - \exp_after:wN \regex_compile_quantifier:w + \tex_advance:D \l__regex_mode_int - \c_fifteen + \tex_divide:D \l__regex_mode_int \c_thirteen + \if_int_odd:w \l__regex_mode_int \else: + \exp_after:wN \__regex_compile_quantifier:w \fi: } - { \regex_compile_raw:N ] } + { \__regex_compile_raw:N ] } } -\cs_new_protected_nopar:cpn { regex_compile_[: } +\cs_new_protected_nopar:cpn { __regex_compile_[: } { - \regex_if_in_class:TF - { \regex_compile_class_posix_test:w } + \__regex_if_in_class:TF + { \__regex_compile_class_posix_test:w } { - \regex_if_within_catcode:TF + \__regex_if_within_catcode:TF { - \exp_after:wN \regex_compile_class_catcode:w - \int_use:N \l_regex_catcodes_int ; + \exp_after:wN \__regex_compile_class_catcode:w + \int_use:N \l__regex_catcodes_int ; } - { \regex_compile_class_normal:w } + { \__regex_compile_class_normal:w } } } -\cs_new_protected_nopar:Npn \regex_compile_class_normal:w +\cs_new_protected_nopar:Npn \__regex_compile_class_normal:w { - \regex_compile_class:TFNN - { \regex_class:NnnnN \c_true_bool } - { \regex_class:NnnnN \c_false_bool } + \__regex_compile_class:TFNN + { \__regex_class:NnnnN \c_true_bool } + { \__regex_class:NnnnN \c_false_bool } } -\cs_new_protected:Npn \regex_compile_class_catcode:w #1; +\cs_new_protected:Npn \__regex_compile_class_catcode:w #1; { - \if_int_compare:w \l_regex_mode_int = \c_two - \tl_build_one:n - { \regex_class:NnnnN \c_true_bool { \if_false: } \fi: } + \if_int_compare:w \l__regex_mode_int = \c_two + \__tl_build_one:n + { \__regex_class:NnnnN \c_true_bool { \if_false: } \fi: } \fi: - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \regex_compile_class:TFNN - { \regex_item_catcode:nT {#1} } - { \regex_item_catcode_reverse:nT {#1} } + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \__regex_compile_class:TFNN + { \__regex_item_catcode:nT {#1} } + { \__regex_item_catcode_reverse:nT {#1} } } -\cs_new_protected:Npn \regex_compile_class:TFNN #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_class:TFNN #1#2#3#4 { - \l_regex_mode_int = \int_value:w \l_regex_mode_int 3 \exp_stop_f: - \str_if_eq:nnTF { #3 #4 } { \regex_compile_special:N ^ } + \l__regex_mode_int = \__int_value:w \l__regex_mode_int 3 \exp_stop_f: + \str_if_eq:nnTF { #3 #4 } { \__regex_compile_special:N ^ } { - \tl_build_one:n { #2 { \if_false: } \fi: } - \regex_compile_class_ii:NN + \__tl_build_one:n { #2 { \if_false: } \fi: } + \__regex_compile_class_ii:NN } { - \tl_build_one:n { #1 { \if_false: } \fi: } - \regex_compile_class_ii:NN #3 #4 + \__tl_build_one:n { #1 { \if_false: } \fi: } + \__regex_compile_class_ii:NN #3 #4 } } -\cs_new_protected:Npn \regex_compile_class_ii:NN #1#2 +\cs_new_protected:Npn \__regex_compile_class_ii:NN #1#2 { \token_if_eq_charcode:NNTF #2 ] - { \regex_compile_raw:N #2 } + { \__regex_compile_raw:N #2 } { #1 #2 } } -\cs_new_protected:Npn \regex_compile_class_posix_test:w #1#2 +\cs_new_protected:Npn \__regex_compile_class_posix_test:w #1#2 { - \token_if_eq_meaning:NNT \regex_compile_special:N #1 + \token_if_eq_meaning:NNT \__regex_compile_special:N #1 { - \prg_case_str:nnn { #2 } + \str_case:nnn { #2 } { - : { \regex_compile_class_posix:NNNNw } - = { \msg_kernel_warning:nnx { regex } { posix-unsupported } { = } } - . { \msg_kernel_warning:nnx { regex } { posix-unsupported } { . } } + : { \__regex_compile_class_posix:NNNNw } + = { \__msg_kernel_warning:nnx { regex } { posix-unsupported } { = } } + . { \__msg_kernel_warning:nnx { regex } { posix-unsupported } { . } } } { } } - \regex_compile_raw:N [ #1 #2 + \__regex_compile_raw:N [ #1 #2 } -\cs_new_protected:Npn \regex_compile_class_posix:NNNNw #1#2#3#4#5#6 +\cs_new_protected:Npn \__regex_compile_class_posix:NNNNw #1#2#3#4#5#6 { - \str_if_eq:nnTF { #5 #6 } { \regex_compile_special:N ^ } + \str_if_eq:nnTF { #5 #6 } { \__regex_compile_special:N ^ } { - \bool_set_false:N \l_regex_internal_bool - \tl_set:Nx \l_regex_internal_a_tl { \if_false: } \fi: - \regex_compile_class_posix_loop:w + \bool_set_false:N \l__regex_internal_bool + \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi: + \__regex_compile_class_posix_loop:w } { - \bool_set_true:N \l_regex_internal_bool - \tl_set:Nx \l_regex_internal_a_tl { \if_false: } \fi: - \regex_compile_class_posix_loop:w #5 #6 + \bool_set_true:N \l__regex_internal_bool + \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi: + \__regex_compile_class_posix_loop:w #5 #6 } } -\cs_new:Npn \regex_compile_class_posix_loop:w #1#2 +\cs_new:Npn \__regex_compile_class_posix_loop:w #1#2 { - \token_if_eq_meaning:NNTF \regex_compile_raw:N #1 - { #2 \regex_compile_class_posix_loop:w } - { \if_false: { \fi: } \regex_compile_class_posix_end:w #1 #2 } + \token_if_eq_meaning:NNTF \__regex_compile_raw:N #1 + { #2 \__regex_compile_class_posix_loop:w } + { \if_false: { \fi: } \__regex_compile_class_posix_end:w #1 #2 } } -\cs_new_protected:Npn \regex_compile_class_posix_end:w #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_class_posix_end:w #1#2#3#4 { \str_if_eq:nnTF { #1 #2 #3 #4 } - { \regex_compile_special:N : \regex_compile_special:N ] } + { \__regex_compile_special:N : \__regex_compile_special:N ] } { - \cs_if_exist:cTF { regex_posix_ \l_regex_internal_a_tl : } + \cs_if_exist:cTF { __regex_posix_ \l__regex_internal_a_tl : } { - \regex_compile_one:x + \__regex_compile_one:x { - \bool_if:NF \l_regex_internal_bool \regex_item_reverse:n - \exp_not:c { regex_posix_ \l_regex_internal_a_tl : } + \bool_if:NF \l__regex_internal_bool \__regex_item_reverse:n + \exp_not:c { __regex_posix_ \l__regex_internal_a_tl : } } } { - \msg_kernel_warning:nnx { regex } { posix-unknown } - { \l_regex_internal_a_tl } - \regex_compile_abort_tokens:x + \__msg_kernel_warning:nnx { regex } { posix-unknown } + { \l__regex_internal_a_tl } + \__regex_compile_abort_tokens:x { - [: \bool_if:NF \l_regex_internal_bool { ^ } - \l_regex_internal_a_tl :] + [: \bool_if:NF \l__regex_internal_bool { ^ } + \l__regex_internal_a_tl :] } } } { - \msg_kernel_error:nnxx { regex } { posix-missing-close } - { [: \l_regex_internal_a_tl } { #2 #4 } - \regex_compile_abort_tokens:x { [: \l_regex_internal_a_tl } + \__msg_kernel_error:nnxx { regex } { posix-missing-close } + { [: \l__regex_internal_a_tl } { #2 #4 } + \__regex_compile_abort_tokens:x { [: \l__regex_internal_a_tl } #1 #2 #3 #4 } } -\cs_new_protected:Npn \regex_compile_group_begin:N #1 +\cs_new_protected:Npn \__regex_compile_group_begin:N #1 { - \tl_build_one:n { #1 { \if_false: } \fi: } - \regex_mode_quit_c: - \tl_set_build:Nw \l_regex_internal_regex - \int_set_eq:NN \l_regex_default_catcodes_int \l_regex_catcodes_int - \int_incr:N \l_regex_group_level_int - \tl_build_one:n { \regex_branch:n { \if_false: } \fi: } + \__tl_build_one:n { #1 { \if_false: } \fi: } + \__regex_mode_quit_c: + \__tl_build:Nw \l__regex_internal_regex + \int_set_eq:NN \l__regex_default_catcodes_int \l__regex_catcodes_int + \int_incr:N \l__regex_group_level_int + \__tl_build_one:n { \__regex_branch:n { \if_false: } \fi: } } -\cs_new_protected:Npn \regex_compile_group_end: +\cs_new_protected:Npn \__regex_compile_group_end: { - \if_num:w \l_regex_group_level_int > \c_zero - \tl_build_one:n { \if_false: { \fi: } } - \tl_build_end: - \int_set_eq:NN \l_regex_catcodes_int \l_regex_default_catcodes_int - \tl_build_one:o \l_regex_internal_regex - \exp_after:wN \regex_compile_quantifier:w + \if_int_compare:w \l__regex_group_level_int > \c_zero + \__tl_build_one:n { \if_false: { \fi: } } + \__tl_build_end: + \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int + \__tl_build_one:o \l__regex_internal_regex + \exp_after:wN \__regex_compile_quantifier:w \else: - \msg_kernel_warning:nn { regex } { extra-rparen } - \exp_after:wN \regex_compile_raw:N \exp_after:wN ) + \__msg_kernel_warning:nn { regex } { extra-rparen } + \exp_after:wN \__regex_compile_raw:N \exp_after:wN ) \fi: } -\cs_new_protected_nopar:cpn { regex_compile_(: } +\cs_new_protected_nopar:cpn { __regex_compile_(: } { - \regex_if_in_class:TF { \regex_compile_raw:N ( } - { \regex_compile_lparen:w } + \__regex_if_in_class:TF { \__regex_compile_raw:N ( } + { \__regex_compile_lparen:w } } -\cs_new_protected:Npn \regex_compile_lparen:w #1#2#3#4 +\cs_new_protected:Npn \__regex_compile_lparen:w #1#2#3#4 { - \str_if_eq:nnTF { #1 #2 } { \regex_compile_special:N ? } + \str_if_eq:nnTF { #1 #2 } { \__regex_compile_special:N ? } { \cs_if_exist_use:cF - { regex_compile_special_group_\token_to_str:N #4 :w } + { __regex_compile_special_group_\token_to_str:N #4 :w } { - \msg_kernel_warning:nnx { regex } { special-group-unknown } + \__msg_kernel_warning:nnx { regex } { special-group-unknown } { (? \token_to_str:N #4 } - \regex_compile_group_begin:N \regex_group:nnnN - \regex_compile_raw:N ? #3 #4 + \__regex_compile_group_begin:N \__regex_group:nnnN + \__regex_compile_raw:N ? #3 #4 } } { - \regex_compile_group_begin:N \regex_group:nnnN + \__regex_compile_group_begin:N \__regex_group:nnnN #1 #2 #3 #4 } } -\cs_new_protected_nopar:cpn { regex_compile_|: } +\cs_new_protected_nopar:cpn { __regex_compile_|: } { - \regex_if_in_class:TF { \regex_compile_raw:N | } + \__regex_if_in_class:TF { \__regex_compile_raw:N | } { - \tl_build_one:n - { \if_false: { \fi: } \regex_branch:n { \if_false: } \fi: } + \__tl_build_one:n + { \if_false: { \fi: } \__regex_branch:n { \if_false: } \fi: } } } -\cs_new_protected_nopar:cpn { regex_compile_): } +\cs_new_protected_nopar:cpn { __regex_compile_): } { - \regex_if_in_class:TF { \regex_compile_raw:N ) } - { \regex_compile_group_end: } + \__regex_if_in_class:TF { \__regex_compile_raw:N ) } + { \__regex_compile_group_end: } } -\cs_new_protected_nopar:cpn { regex_compile_special_group_::w } - { \regex_compile_group_begin:N \regex_group_no_capture:nnnN } -\cs_new_protected_nopar:cpn { regex_compile_special_group_|:w } - { \regex_compile_group_begin:N \regex_group_resetting:nnnN } -\cs_new_protected:Npn \regex_compile_special_group_i:w #1#2 +\cs_new_protected_nopar:cpn { __regex_compile_special_group_::w } + { \__regex_compile_group_begin:N \__regex_group_no_capture:nnnN } +\cs_new_protected_nopar:cpn { __regex_compile_special_group_|:w } + { \__regex_compile_group_begin:N \__regex_group_resetting:nnnN } +\cs_new_protected:Npn \__regex_compile_special_group_i:w #1#2 { - \str_if_eq:nnTF { #1 #2 } { \regex_compile_special:N ) } + \str_if_eq:nnTF { #1 #2 } { \__regex_compile_special:N ) } { - \cs_set_nopar:Npn \regex_item_equal:n { \regex_item_caseless_equal:n } - \cs_set_nopar:Npn \regex_item_range:nn { \regex_item_caseless_range:nn } + \cs_set_nopar:Npn \__regex_item_equal:n { \__regex_item_caseless_equal:n } + \cs_set_nopar:Npn \__regex_item_range:nn { \__regex_item_caseless_range:nn } } { - \msg_kernel_warning:nnx { regex } { unknown-option } { (?i #2 } - \regex_compile_raw:N ( - \regex_compile_raw:N ? - \regex_compile_raw:N i + \__msg_kernel_warning:nnx { regex } { unknown-option } { (?i #2 } + \__regex_compile_raw:N ( + \__regex_compile_raw:N ? + \__regex_compile_raw:N i #1 #2 } } -\cs_new_protected_nopar:cpn { regex_compile_special_group_-:w } #1#2#3#4 +\cs_new_protected_nopar:cpn { __regex_compile_special_group_-:w } #1#2#3#4 { \str_if_eq:nnTF { #1 #2 #3 #4 } - { \regex_compile_raw:N i \regex_compile_special:N ) } + { \__regex_compile_raw:N i \__regex_compile_special:N ) } { - \cs_set_nopar:Npn \regex_item_equal:n { \regex_item_caseful_equal:n } - \cs_set_nopar:Npn \regex_item_range:nn { \regex_item_caseful_range:nn } + \cs_set_nopar:Npn \__regex_item_equal:n { \__regex_item_caseful_equal:n } + \cs_set_nopar:Npn \__regex_item_range:nn { \__regex_item_caseful_range:nn } } { - \msg_kernel_warning:nnx { regex } { unknown-option } { (?-#2#4 } - \regex_compile_raw:N ( - \regex_compile_raw:N ? - \regex_compile_raw:N - + \__msg_kernel_warning:nnx { regex } { unknown-option } { (?-#2#4 } + \__regex_compile_raw:N ( + \__regex_compile_raw:N ? + \__regex_compile_raw:N - #1 #2 #3 #4 } } -\cs_new_protected:cpn { regex_compile_/c: } - { \regex_chk_c_allowed:T { \regex_compile_c_test:NN } } -\cs_new_protected:Npn \regex_compile_c_test:NN #1#2 +\cs_new_protected:cpn { __regex_compile_/c: } + { \__regex_chk_c_allowed:T { \__regex_compile_c_test:NN } } +\cs_new_protected:Npn \__regex_compile_c_test:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_raw:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N { - \int_if_exist:cTF { c_regex_catcode_#2_int } + \int_if_exist:cTF { c__regex_catcode_#2_int } { - \int_set_eq:Nc \l_regex_catcodes_int { c_regex_catcode_#2_int } - \l_regex_mode_int - = \if_case:w \l_regex_mode_int \c_two \else: \c_six \fi: + \int_set_eq:Nc \l__regex_catcodes_int { c__regex_catcode_#2_int } + \l__regex_mode_int + = \if_case:w \l__regex_mode_int \c_two \else: \c_six \fi: } } - { \cs_if_exist_use:cF { regex_compile_c_#2:w } } + { \cs_if_exist_use:cF { __regex_compile_c_#2:w } } { - \msg_kernel_error:nnx { regex } { c-missing-category } {#2} + \__msg_kernel_error:nnx { regex } { c-missing-category } {#2} #1 #2 } } -\cs_new_protected:cpn { regex_compile_c_[:w } #1#2 +\cs_new_protected:cpn { __regex_compile_c_[:w } #1#2 { - \l_regex_mode_int - = \if_case:w \l_regex_mode_int \c_two \else: \c_six \fi: - \int_zero:N \l_regex_catcodes_int - \str_if_eq:nnTF { #1 #2 } { \regex_compile_special:N ^ } + \l__regex_mode_int + = \if_case:w \l__regex_mode_int \c_two \else: \c_six \fi: + \int_zero:N \l__regex_catcodes_int + \str_if_eq:nnTF { #1 #2 } { \__regex_compile_special:N ^ } { - \bool_set_false:N \l_regex_catcodes_bool - \regex_compile_c_lbrack_loop:NN + \bool_set_false:N \l__regex_catcodes_bool + \__regex_compile_c_lbrack_loop:NN } { - \bool_set_true:N \l_regex_catcodes_bool - \regex_compile_c_lbrack_loop:NN + \bool_set_true:N \l__regex_catcodes_bool + \__regex_compile_c_lbrack_loop:NN #1 #2 } } -\cs_new_protected:Npn \regex_compile_c_lbrack_loop:NN #1#2 +\cs_new_protected:Npn \__regex_compile_c_lbrack_loop:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_raw:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N { - \int_if_exist:cTF { c_regex_catcode_#2_int } + \int_if_exist:cTF { c__regex_catcode_#2_int } { - \exp_args:Nc \regex_compile_c_lbrack_add:N - { c_regex_catcode_#2_int } - \regex_compile_c_lbrack_loop:NN + \exp_args:Nc \__regex_compile_c_lbrack_add:N + { c__regex_catcode_#2_int } + \__regex_compile_c_lbrack_loop:NN } } { \token_if_eq_charcode:NNTF #2 ] - { \regex_compile_c_lbrack_end: } + { \__regex_compile_c_lbrack_end: } } { - \msg_kernel_error:nnx { regex } { c-missing-rbrack } {#2} - \regex_compile_c_lbrack_end: + \__msg_kernel_error:nnx { regex } { c-missing-rbrack } {#2} + \__regex_compile_c_lbrack_end: #1 #2 } } -\cs_new_protected:Npn \regex_compile_c_lbrack_add:N #1 +\cs_new_protected:Npn \__regex_compile_c_lbrack_add:N #1 { - \if_int_odd:w \int_eval:w \l_regex_catcodes_int / #1 \int_eval_end: + \if_int_odd:w \__int_eval:w \l__regex_catcodes_int / #1 \__int_eval_end: \else: - \tex_advance:D \l_regex_catcodes_int #1 + \tex_advance:D \l__regex_catcodes_int #1 \fi: } -\cs_new_protected_nopar:Npn \regex_compile_c_lbrack_end: +\cs_new_protected_nopar:Npn \__regex_compile_c_lbrack_end: { - \if_meaning:w \c_false_bool \l_regex_catcodes_bool - \int_set:Nn \l_regex_catcodes_int - { \c_regex_all_catcodes_int - \l_regex_catcodes_int } + \if_meaning:w \c_false_bool \l__regex_catcodes_bool + \int_set:Nn \l__regex_catcodes_int + { \c__regex_all_catcodes_int - \l__regex_catcodes_int } \fi: } -\cs_new_protected_nopar:cpn { regex_compile_c_ \c_lbrace_str :w } +\cs_new_protected_nopar:cpn { __regex_compile_c_ \c_lbrace_str :w } { - \regex_compile:w - \regex_disable_submatches: - \l_regex_mode_int - = - \if_case:w \l_regex_mode_int \c_two \else: \c_six \fi: + \__regex_compile:w + \__regex_disable_submatches: + \l__regex_mode_int + = - \if_case:w \l__regex_mode_int \c_two \else: \c_six \fi: } -\cs_new_protected:cpn { regex_compile_ \c_rbrace_str : } +\cs_new_protected:cpn { __regex_compile_ \c_rbrace_str : } { - \regex_if_in_cs:TF + \__regex_if_in_cs:TF { - \regex_compile_end: - \regex_compile_one:x - { \regex_item_cs:n { \exp_not:o \l_regex_internal_regex } } + \__regex_compile_end: + \__regex_compile_one:x + { \__regex_item_cs:n { \exp_not:o \l__regex_internal_regex } } } - { \exp_after:wN \regex_compile_raw:N \c_rbrace_str } + { \exp_after:wN \__regex_compile_raw:N \c_rbrace_str } } -\cs_new_protected:cpn { regex_compile_/u: } #1#2 +\cs_new_protected:cpn { __regex_compile_/u: } #1#2 { - \regex_if_in_class_or_catcode:TF - { \regex_compile_raw_error:N u #1 #2 } + \__regex_if_in_class_or_catcode:TF + { \__regex_compile_raw_error:N u #1 #2 } { - \str_if_eq:xxTF {#1#2} { \regex_compile_special:N \c_lbrace_str } + \str_if_eq_x:nnTF {#1#2} { \__regex_compile_special:N \c_lbrace_str } { - \tl_set:Nx \l_regex_internal_a_tl { \if_false: } \fi: - \regex_compile_u_loop:NN + \tl_set:Nx \l__regex_internal_a_tl { \if_false: } \fi: + \__regex_compile_u_loop:NN } { - \msg_kernel_error:nn { regex } { u-missing-lbrace } - \regex_compile_raw:N u #1 #2 + \__msg_kernel_error:nn { regex } { u-missing-lbrace } + \__regex_compile_raw:N u #1 #2 } } } -\cs_new:Npn \regex_compile_u_loop:NN #1#2 +\cs_new:Npn \__regex_compile_u_loop:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \regex_compile_raw:N - { #2 \regex_compile_u_loop:NN } + \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N + { #2 \__regex_compile_u_loop:NN } { - \token_if_eq_meaning:NNTF #1 \regex_compile_special:N + \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N { \exp_after:wN \token_if_eq_charcode:NNTF \c_rbrace_str #2 - { \if_false: { \fi: } \regex_compile_u_end: } - { #2 \regex_compile_u_loop:NN } + { \if_false: { \fi: } \__regex_compile_u_end: } + { #2 \__regex_compile_u_loop:NN } } { \if_false: { \fi: } - \msg_kernel_error:nnx { regex } { u-missing-rbrace } {#2} - \regex_compile_u_end: + \__msg_kernel_error:nnx { regex } { u-missing-rbrace } {#2} + \__regex_compile_u_end: #1 #2 } } } -\cs_new_protected:Npn \regex_compile_u_end: +\cs_new_protected:Npn \__regex_compile_u_end: { - \tl_set:Nv \l_regex_internal_a_tl { \l_regex_internal_a_tl } - \if_num:w \l_regex_mode_int = \c_zero - \regex_compile_u_not_cs: + \tl_set:Nv \l__regex_internal_a_tl { \l__regex_internal_a_tl } + \if_int_compare:w \l__regex_mode_int = \c_zero + \__regex_compile_u_not_cs: \else: - \regex_compile_u_in_cs: + \__regex_compile_u_in_cs: \fi: } -\cs_new_protected:Npn \regex_compile_u_in_cs: +\cs_new_protected:Npn \__regex_compile_u_in_cs: { - \exp_args:NNo \str_gset_other:Nn \g_regex_internal_tl - { \l_regex_internal_a_tl } - \tl_build_one:x + \exp_args:NNo \__str_gset_other:Nn \g__regex_internal_tl + { \l__regex_internal_a_tl } + \__tl_build_one:x { - \tl_map_function:NN \g_regex_internal_tl - \regex_compile_u_in_cs_aux:n + \tl_map_function:NN \g__regex_internal_tl + \__regex_compile_u_in_cs_aux:n } } -\cs_new:Npn \regex_compile_u_in_cs_aux:n #1 +\cs_new:Npn \__regex_compile_u_in_cs_aux:n #1 { - \regex_class:NnnnN \c_true_bool - { \regex_item_caseful_equal:n { \int_value:w `#1 } } + \__regex_class:NnnnN \c_true_bool + { \__regex_item_caseful_equal:n { \__int_value:w `#1 } } { 1 } { 0 } \c_false_bool } -\cs_new_protected:Npn \regex_compile_u_not_cs: +\cs_new_protected:Npn \__regex_compile_u_not_cs: { - \exp_args:No \tl_analysis_map_inline:nn { \l_regex_internal_a_tl } + \exp_args:No \__tl_analysis_map_inline:nn { \l__regex_internal_a_tl } { - \tl_build_one:n + \__tl_build_one:n { - \regex_class:NnnnN \c_true_bool + \__regex_class:NnnnN \c_true_bool { - \if_num:w "##2 = \c_zero - \regex_item_exact_cs:c { \exp_after:wN \cs_to_str:N ##1 } + \if_int_compare:w "##2 = \c_zero + \__regex_item_exact_cs:c { \exp_after:wN \cs_to_str:N ##1 } \else: - \regex_item_exact:nn { \int_value:w "##2 } { ##3 } + \__regex_item_exact:nn { \__int_value:w "##2 } { ##3 } \fi: } { 1 } { 0 } \c_false_bool } } } -\cs_new_protected_nopar:cpn { regex_compile_/K: } +\cs_new_protected_nopar:cpn { __regex_compile_/K: } { - \int_compare:nNnTF \l_regex_mode_int = \c_zero - { \tl_build_one:n { \regex_command_K: } } - { \regex_compile_raw_error:N K } + \int_compare:nNnTF \l__regex_mode_int = \c_zero + { \__tl_build_one:n { \__regex_command_K: } } + { \__regex_compile_raw_error:N K } } -\cs_new_protected:Npn \regex_show_aux:Nx #1#2 +\cs_new_protected:Npn \__regex_show:Nx #1#2 { - \tl_set_build:Nw \l_regex_internal_a_tl - \cs_set_protected_nopar:Npn \regex_branch:n + \__tl_build:Nw \l__regex_internal_a_tl + \cs_set_protected_nopar:Npn \__regex_branch:n { - \seq_pop_right:NN \l_regex_show_prefix_seq \l_regex_internal_a_tl - \regex_show_one:n { +-branch } - \seq_put_right:No \l_regex_show_prefix_seq \l_regex_internal_a_tl + \seq_pop_right:NN \l__regex_show_prefix_seq \l__regex_internal_a_tl + \__regex_show_one:n { +-branch } + \seq_put_right:No \l__regex_show_prefix_seq \l__regex_internal_a_tl \use:n } - \cs_set_protected_nopar:Npn \regex_group:nnnN - { \regex_show_group_aux:nnnnN { } } - \cs_set_protected_nopar:Npn \regex_group_no_capture:nnnN - { \regex_show_group_aux:nnnnN { ~(no~capture) } } - \cs_set_protected_nopar:Npn \regex_group_resetting:nnnN - { \regex_show_group_aux:nnnnN { ~(resetting) } } - \cs_set_eq:NN \regex_class:NnnnN \regex_show_class:NnnnN - \cs_set_protected_nopar:Npn \regex_command_K: - { \regex_show_one:n { reset~match~start~(\iow_char:N\\K) } } - \cs_set_protected:Npn \regex_assertion:Nn ##1##2 - { \regex_show_one:n { \bool_if:NF ##1 { negative~ } assertion:~##2 } } - \cs_set_nopar:Npn \regex_b_test: { word~boundary } - \cs_set_eq:NN \regex_anchor:N \regex_show_anchor_to_str:N - \cs_set_protected:Npn \regex_item_caseful_equal:n ##1 - { \regex_show_one:n { char~code~\int_eval:n{##1} } } - \cs_set_protected:Npn \regex_item_caseful_range:nn ##1##2 - { \regex_show_one:n { range~[\int_eval:n{##1}, \int_eval:n{##2}] } } - \cs_set_protected:Npn \regex_item_caseless_equal:n ##1 - { \regex_show_one:n { char~code~\int_eval:n{##1}~(caseless) } } - \cs_set_protected:Npn \regex_item_caseless_range:nn ##1##2 + \cs_set_protected_nopar:Npn \__regex_group:nnnN + { \__regex_show_group_aux:nnnnN { } } + \cs_set_protected_nopar:Npn \__regex_group_no_capture:nnnN + { \__regex_show_group_aux:nnnnN { ~(no~capture) } } + \cs_set_protected_nopar:Npn \__regex_group_resetting:nnnN + { \__regex_show_group_aux:nnnnN { ~(resetting) } } + \cs_set_eq:NN \__regex_class:NnnnN \__regex_show_class:NnnnN + \cs_set_protected_nopar:Npn \__regex_command_K: + { \__regex_show_one:n { reset~match~start~(\iow_char:N\\K) } } + \cs_set_protected:Npn \__regex_assertion:Nn ##1##2 + { \__regex_show_one:n { \bool_if:NF ##1 { negative~ } assertion:~##2 } } + \cs_set_nopar:Npn \__regex_b_test: { word~boundary } + \cs_set_eq:NN \__regex_anchor:N \__regex_show_anchor_to_str:N + \cs_set_protected:Npn \__regex_item_caseful_equal:n ##1 + { \__regex_show_one:n { char~code~\int_eval:n{##1} } } + \cs_set_protected:Npn \__regex_item_caseful_range:nn ##1##2 + { \__regex_show_one:n { range~[\int_eval:n{##1}, \int_eval:n{##2}] } } + \cs_set_protected:Npn \__regex_item_caseless_equal:n ##1 + { \__regex_show_one:n { char~code~\int_eval:n{##1}~(caseless) } } + \cs_set_protected:Npn \__regex_item_caseless_range:nn ##1##2 { - \regex_show_one:n + \__regex_show_one:n { Range~[\int_eval:n{##1}, \int_eval:n{##2}]~(caseless) } } - \cs_set_protected:Npn \regex_item_catcode:nT - { \regex_show_item_catcode:NnT \c_true_bool } - \cs_set_protected:Npn \regex_item_catcode_reverse:nT - { \regex_show_item_catcode:NnT \c_false_bool } - \cs_set_protected:Npn \regex_item_reverse:n - { \regex_show_scope:nn { Reversed~match } } - \cs_set_protected:Npn \regex_item_exact:nn ##1##2 - { \regex_show_one:n { char~##2,~catcode~##1 } } - \cs_set_protected:Npn \regex_item_exact_cs:c ##1 - { \regex_show_one:n { control~sequence~\iow_char:N\\##1 } } - \cs_set_protected:Npn \regex_item_cs:n - { \regex_show_scope:nn { control~sequence } } - \cs_set:cpn { regex_prop_.: } { \regex_show_one:n { any~token } } - \seq_clear:N \l_regex_show_prefix_seq - \regex_show_push:n { ~ } + \cs_set_protected:Npn \__regex_item_catcode:nT + { \__regex_show_item_catcode:NnT \c_true_bool } + \cs_set_protected:Npn \__regex_item_catcode_reverse:nT + { \__regex_show_item_catcode:NnT \c_false_bool } + \cs_set_protected:Npn \__regex_item_reverse:n + { \__regex_show_scope:nn { Reversed~match } } + \cs_set_protected:Npn \__regex_item_exact:nn ##1##2 + { \__regex_show_one:n { char~##2,~catcode~##1 } } + \cs_set_protected:Npn \__regex_item_exact_cs:c ##1 + { \__regex_show_one:n { control~sequence~\iow_char:N\\##1 } } + \cs_set_protected:Npn \__regex_item_cs:n + { \__regex_show_scope:nn { control~sequence } } + \cs_set:cpn { __regex_prop_.: } { \__regex_show_one:n { any~token } } + \seq_clear:N \l__regex_show_prefix_seq + \__regex_show_push:n { ~ } #1 - \tl_build_end: - \msg_aux_show:x { > Compiled~regex~#2: \l_regex_internal_a_tl } + \__tl_build_end: + \__msg_show_variable:x { > Compiled~regex~#2: \l__regex_internal_a_tl } } -\cs_new_protected:Npn \regex_show_one:n #1 +\cs_new_protected:Npn \__regex_show_one:n #1 { - \int_incr:N \l_regex_show_lines_int - \tl_build_one:x - { \iow_newline: \seq_use:N \l_regex_show_prefix_seq #1 } + \int_incr:N \l__regex_show_lines_int + \__tl_build_one:x + { + \iow_newline: + \seq_map_function:NN \l__regex_show_prefix_seq \use:n + #1 + } } -\cs_new_protected:Npn \regex_show_push:n #1 - { \seq_put_right:Nx \l_regex_show_prefix_seq { #1 ~ } } -\cs_new_protected:Npn \regex_show_pop: - { \seq_pop_right:NN \l_regex_show_prefix_seq \l_regex_internal_a_tl } -\cs_new_protected:Npn \regex_show_scope:nn #1#2 +\cs_new_protected:Npn \__regex_show_push:n #1 + { \seq_put_right:Nx \l__regex_show_prefix_seq { #1 ~ } } +\cs_new_protected:Npn \__regex_show_pop: + { \seq_pop_right:NN \l__regex_show_prefix_seq \l__regex_internal_a_tl } +\cs_new_protected:Npn \__regex_show_scope:nn #1#2 { - \regex_show_one:n {#1} - \regex_show_push:n { ~ } + \__regex_show_one:n {#1} + \__regex_show_push:n { ~ } #2 - \regex_show_pop: + \__regex_show_pop: } -\cs_new_protected:Npn \regex_show_group_aux:nnnnN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_show_group_aux:nnnnN #1#2#3#4#5 { - \regex_show_one:n { ,-group~begin #1 } - \regex_show_push:n { | } + \__regex_show_one:n { ,-group~begin #1 } + \__regex_show_push:n { | } \use_ii:nn #2 - \regex_show_pop: - \regex_show_one:n - { `-group~end \regex_msg_repeated:nnN {#3} {#4} #5 } + \__regex_show_pop: + \__regex_show_one:n + { `-group~end \__regex_msg_repeated:nnN {#3} {#4} #5 } } -\cs_set:Npn \regex_show_class:NnnnN #1#2#3#4#5 +\cs_set:Npn \__regex_show_class:NnnnN #1#2#3#4#5 { - \tl_set_build:Nw \l_regex_internal_a_tl - \int_zero:N \l_regex_show_lines_int - \regex_show_push:n {~} + \__tl_build:Nw \l__regex_internal_a_tl + \int_zero:N \l__regex_show_lines_int + \__regex_show_push:n {~} #2 \exp_last_unbraced:Nf - \prg_case_int:nnn { \l_regex_show_lines_int } + \int_case:nnn { \l__regex_show_lines_int } { {0} { - \tl_build_end: - \regex_show_one:n { \bool_if:NTF #1 { Fail } { Pass } } + \__tl_build_end: + \__regex_show_one:n { \bool_if:NTF #1 { Fail } { Pass } } } {1} { - \tl_build_end: + \__tl_build_end: \bool_if:NTF #1 { #2 - \tl_build_one:n { \regex_msg_repeated:nnN {#3} {#4} #5 } + \__tl_build_one:n { \__regex_msg_repeated:nnN {#3} {#4} #5 } } { - \regex_show_one:n - { Don't~match~\regex_msg_repeated:nnN {#3} {#4} #5 } - \tl_build_one:o \l_regex_internal_a_tl + \__regex_show_one:n + { Don't~match~\__regex_msg_repeated:nnN {#3} {#4} #5 } + \__tl_build_one:o \l__regex_internal_a_tl } } } { - \tl_build_end: - \regex_show_one:n + \__tl_build_end: + \__regex_show_one:n { \bool_if:NTF #1 { M } { Don't~m } atch - \regex_msg_repeated:nnN {#3} {#4} #5 + \__regex_msg_repeated:nnN {#3} {#4} #5 } - \tl_build_one:o \l_regex_internal_a_tl + \__tl_build_one:o \l__regex_internal_a_tl } } -\cs_new:Npn \regex_show_anchor_to_str:N #1 +\cs_new:Npn \__regex_show_anchor_to_str:N #1 { anchor~at~ - \prg_case_str:nnn { #1 } + \str_case:nnn { #1 } { - { \l_regex_min_pos_int } { start~(\iow_char:N\\A) } - { \l_regex_start_pos_int } { start~of~match~(\iow_char:N\\G) } - { \l_regex_max_pos_int } { end~(\iow_char:N\\Z) } + { \l__regex_min_pos_int } { start~(\iow_char:N\\A) } + { \l__regex_start_pos_int } { start~of~match~(\iow_char:N\\G) } + { \l__regex_max_pos_int } { end~(\iow_char:N\\Z) } } { <error:~'#1'~not~recognized> } } -\cs_new_protected:Npn \regex_show_item_catcode:NnT #1#2 +\cs_new_protected:Npn \__regex_show_item_catcode:NnT #1#2 { - \seq_set_split:Nnn \l_regex_internal_seq { } { CBEMTPUDSLOA } - \seq_set_filter:NNn \l_regex_internal_seq \l_regex_internal_seq - { \int_if_odd_p:n { #2 / \int_use:c { c_regex_catcode_##1_int } } } - \regex_show_scope:nn + \seq_set_split:Nnn \l__regex_internal_seq { } { CBEMTPUDSLOA } + \seq_set_filter:NNn \l__regex_internal_seq \l__regex_internal_seq + { \int_if_odd_p:n { #2 / \int_use:c { c__regex_catcode_##1_int } } } + \__regex_show_scope:nn { - categories~\seq_use:N \l_regex_internal_seq, ~ + categories~ + \seq_map_function:NN \l__regex_internal_seq \use:n + , ~ \bool_if:NF #1 { negative~ } class } } -\int_new:N \l_regex_min_state_int -\int_new:N \l_regex_max_state_int -\int_new:N \l_regex_left_state_int -\int_new:N \l_regex_right_state_int -\seq_new:N \l_regex_left_state_seq -\seq_new:N \l_regex_right_state_seq -\int_new:N \l_regex_capturing_group_int -\cs_new_protected:Npn \regex_build:n #1 +\int_new:N \l__regex_min_state_int +\int_new:N \l__regex_max_state_int +\int_new:N \l__regex_left_state_int +\int_new:N \l__regex_right_state_int +\seq_new:N \l__regex_left_state_seq +\seq_new:N \l__regex_right_state_seq +\int_new:N \l__regex_capturing_group_int +\cs_new_protected:Npn \__regex_build:n #1 { - \regex_compile:n {#1} - \regex_build:N \l_regex_internal_regex + \__regex_compile:n {#1} + \__regex_build:N \l__regex_internal_regex } -\cs_new_protected:Npn \regex_build:N #1 +\cs_new_protected:Npn \__regex_build:N #1 { \int_set:Nn \tex_escapechar:D { 92 } - \int_zero:N \l_regex_capturing_group_int - \int_set_eq:NN \l_regex_max_state_int \l_regex_min_state_int - \regex_build_new_state: - \regex_build_new_state: - \regex_toks_put_right:Nn \l_regex_left_state_int - { \regex_action_start_wildcard: } - \regex_group:nnnN {#1} { 1 } { 0 } \c_false_bool - \regex_toks_put_right:Nn \l_regex_right_state_int - { \regex_action_success: } - } -\cs_new_protected:Npn \regex_build_for_cs:n #1 - { - \int_set_eq:NN \l_regex_max_state_int \l_regex_min_state_int - \regex_build_new_state: - \regex_build_new_state: - \regex_push_lr_states: + \int_zero:N \l__regex_capturing_group_int + \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int + \__regex_build_new_state: + \__regex_build_new_state: + \__regex_toks_put_right:Nn \l__regex_left_state_int + { \__regex_action_start_wildcard: } + \__regex_group:nnnN {#1} { 1 } { 0 } \c_false_bool + \__regex_toks_put_right:Nn \l__regex_right_state_int + { \__regex_action_success: } + } +\cs_new_protected:Npn \__regex_build_for_cs:n #1 + { + \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int + \__regex_build_new_state: + \__regex_build_new_state: + \__regex_push_lr_states: #1 - \regex_pop_lr_states: - \regex_toks_put_right:Nn \l_regex_right_state_int + \__regex_pop_lr_states: + \__regex_toks_put_right:Nn \l__regex_right_state_int { - \if_num:w \l_regex_current_pos_int = \l_regex_max_pos_int - \exp_after:wN \regex_action_success: + \if_int_compare:w \l__regex_current_pos_int = \l__regex_max_pos_int + \exp_after:wN \__regex_action_success: \fi: } } -\cs_new_protected_nopar:Npn \regex_push_lr_states: +\cs_new_protected_nopar:Npn \__regex_push_lr_states: { - \seq_push:No \l_regex_left_state_seq - { \int_use:N \l_regex_left_state_int } - \seq_push:No \l_regex_right_state_seq - { \int_use:N \l_regex_right_state_int } + \seq_push:No \l__regex_left_state_seq + { \int_use:N \l__regex_left_state_int } + \seq_push:No \l__regex_right_state_seq + { \int_use:N \l__regex_right_state_int } } -\cs_new_protected_nopar:Npn \regex_pop_lr_states: +\cs_new_protected_nopar:Npn \__regex_pop_lr_states: { - \seq_pop:NN \l_regex_left_state_seq \l_regex_internal_a_tl - \int_set:Nn \l_regex_left_state_int \l_regex_internal_a_tl - \seq_pop:NN \l_regex_right_state_seq \l_regex_internal_a_tl - \int_set:Nn \l_regex_right_state_int \l_regex_internal_a_tl + \seq_pop:NN \l__regex_left_state_seq \l__regex_internal_a_tl + \int_set:Nn \l__regex_left_state_int \l__regex_internal_a_tl + \seq_pop:NN \l__regex_right_state_seq \l__regex_internal_a_tl + \int_set:Nn \l__regex_right_state_int \l__regex_internal_a_tl } -\cs_new_protected:Npn \regex_toks_put_left:Nx #1#2 +\cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 { - \cs_set_nopar:Npx \regex_tmp:w { #2 } + \cs_set_nopar:Npx \__regex_tmp:w { #2 } \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \regex_tmp:w \tex_the:D \tex_toks:D #1 } + { \exp_after:wN \__regex_tmp:w \tex_the:D \tex_toks:D #1 } } -\cs_new_protected:Npn \regex_toks_put_right:Nx #1#2 +\cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 { - \cs_set_nopar:Npx \regex_tmp:w {#2} + \cs_set_nopar:Npx \__regex_tmp:w {#2} \tex_toks:D #1 \exp_after:wN - { \tex_the:D \tex_toks:D \exp_after:wN #1 \regex_tmp:w } + { \tex_the:D \tex_toks:D \exp_after:wN #1 \__regex_tmp:w } } -\cs_new_protected:Npn \regex_toks_put_right:Nn #1#2 +\cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2 { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } } -\cs_new_protected:Npn \regex_build_transition_left:NNN #1#2#3 - { \regex_toks_put_left:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } -\cs_new_protected:Npn \regex_build_transition_right:nNn #1#2#3 - { \regex_toks_put_right:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } -\cs_new_protected_nopar:Npn \regex_build_new_state: +\cs_new_protected:Npn \__regex_build_transition_left:NNN #1#2#3 + { \__regex_toks_put_left:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } +\cs_new_protected:Npn \__regex_build_transition_right:nNn #1#2#3 + { \__regex_toks_put_right:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } +\cs_new_protected_nopar:Npn \__regex_build_new_state: { - \tex_toks:D \l_regex_max_state_int { } - \int_set_eq:NN \l_regex_left_state_int \l_regex_right_state_int - \int_set_eq:NN \l_regex_right_state_int \l_regex_max_state_int - \int_incr:N \l_regex_max_state_int + \tex_toks:D \l__regex_max_state_int { } + \int_set_eq:NN \l__regex_left_state_int \l__regex_right_state_int + \int_set_eq:NN \l__regex_right_state_int \l__regex_max_state_int + \int_incr:N \l__regex_max_state_int } -\cs_new_protected:Npn \regex_build_transitions_lazyness:NNNNN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_build_transitions_lazyness:NNNNN #1#2#3#4#5 { - \regex_build_new_state: - \regex_toks_put_right:Nx \l_regex_left_state_int + \__regex_build_new_state: + \__regex_toks_put_right:Nx \l__regex_left_state_int { \if_meaning:w \c_true_bool #1 - #2 { \int_eval:n { #3 - \l_regex_left_state_int } } - #4 { \int_eval:n { #5 - \l_regex_left_state_int } } + #2 { \int_eval:n { #3 - \l__regex_left_state_int } } + #4 { \int_eval:n { #5 - \l__regex_left_state_int } } \else: - #4 { \int_eval:n { #5 - \l_regex_left_state_int } } - #2 { \int_eval:n { #3 - \l_regex_left_state_int } } + #4 { \int_eval:n { #5 - \l__regex_left_state_int } } + #2 { \int_eval:n { #3 - \l__regex_left_state_int } } \fi: } } -\cs_new_protected:Npn \regex_class:NnnnN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_class:NnnnN #1#2#3#4#5 { - \cs_set_nopar:Npx \regex_tests_action_cost:n ##1 + \cs_set_nopar:Npx \__regex_tests_action_cost:n ##1 { \exp_not:n { \exp_not:n {#2} } \bool_if:NTF #1 - { \regex_break_point:TF { \regex_action_cost:n {##1} } { } } - { \regex_break_point:TF { } { \regex_action_cost:n {##1} } } + { \__regex_break_point:TF { \__regex_action_cost:n {##1} } { } } + { \__regex_break_point:TF { } { \__regex_action_cost:n {##1} } } } \if_case:w - #4 \exp_stop_f: - \regex_class_repeat:n {#3} - \or: \regex_class_repeat:nN {#3} #5 - \else: \regex_class_repeat:nnN {#3} {#4} #5 + \__regex_class_repeat:n {#3} + \or: \__regex_class_repeat:nN {#3} #5 + \else: \__regex_class_repeat:nnN {#3} {#4} #5 \fi: } -\cs_new:Npn \regex_tests_action_cost:n { \regex_action_cost:n } -\cs_new_protected:Npn \regex_class_repeat:n #1 +\cs_new:Npn \__regex_tests_action_cost:n { \__regex_action_cost:n } +\cs_new_protected:Npn \__regex_class_repeat:n #1 { \prg_replicate:nn {#1} { - \regex_build_new_state: - \regex_build_transition_right:nNn \regex_tests_action_cost:n - \l_regex_left_state_int \l_regex_right_state_int + \__regex_build_new_state: + \__regex_build_transition_right:nNn \__regex_tests_action_cost:n + \l__regex_left_state_int \l__regex_right_state_int } } -\cs_new_protected:Npn \regex_class_repeat:nN #1#2 +\cs_new_protected:Npn \__regex_class_repeat:nN #1#2 { - \if_num:w #1 = \c_zero - \regex_build_transitions_lazyness:NNNNN #2 - \regex_action_free:n \l_regex_right_state_int - \regex_tests_action_cost:n \l_regex_left_state_int + \if_int_compare:w #1 = \c_zero + \__regex_build_transitions_lazyness:NNNNN #2 + \__regex_action_free:n \l__regex_right_state_int + \__regex_tests_action_cost:n \l__regex_left_state_int \else: - \regex_class_repeat:n {#1} - \int_set_eq:NN \l_regex_internal_a_int \l_regex_left_state_int - \regex_build_transitions_lazyness:NNNNN #2 - \regex_action_free:n \l_regex_right_state_int - \regex_action_free:n \l_regex_internal_a_int + \__regex_class_repeat:n {#1} + \int_set_eq:NN \l__regex_internal_a_int \l__regex_left_state_int + \__regex_build_transitions_lazyness:NNNNN #2 + \__regex_action_free:n \l__regex_right_state_int + \__regex_action_free:n \l__regex_internal_a_int \fi: } -\cs_new_protected:Npn \regex_class_repeat:nnN #1#2#3 +\cs_new_protected:Npn \__regex_class_repeat:nnN #1#2#3 { - \regex_class_repeat:n {#1} - \int_set:Nn \l_regex_internal_a_int - { \l_regex_max_state_int + #2 - \c_one } + \__regex_class_repeat:n {#1} + \int_set:Nn \l__regex_internal_a_int + { \l__regex_max_state_int + #2 - \c_one } \prg_replicate:nn { #2 } { - \regex_build_transitions_lazyness:NNNNN #3 - \regex_action_free:n \l_regex_internal_a_int - \regex_tests_action_cost:n \l_regex_right_state_int + \__regex_build_transitions_lazyness:NNNNN #3 + \__regex_action_free:n \l__regex_internal_a_int + \__regex_tests_action_cost:n \l__regex_right_state_int } } -\cs_new_protected:Npn \regex_group_aux:nnnnN #1#2#3#4#5 +\cs_new_protected:Npn \__regex_group_aux:nnnnN #1#2#3#4#5 { - \if_num:w #3 = \c_zero - \regex_build_new_state: - \regex_build_transition_right:nNn \regex_action_free_group:n - \l_regex_left_state_int \l_regex_right_state_int + \if_int_compare:w #3 = \c_zero + \__regex_build_new_state: + \__regex_build_transition_right:nNn \__regex_action_free_group:n + \l__regex_left_state_int \l__regex_right_state_int \fi: - \regex_build_new_state: - \regex_push_lr_states: + \__regex_build_new_state: + \__regex_push_lr_states: #2 - \regex_pop_lr_states: + \__regex_pop_lr_states: \if_case:w - #4 \exp_stop_f: - \regex_group_repeat:nn {#1} {#3} - \or: \regex_group_repeat:nnN {#1} {#3} #5 - \else: \regex_group_repeat:nnnN {#1} {#3} {#4} #5 + \__regex_group_repeat:nn {#1} {#3} + \or: \__regex_group_repeat:nnN {#1} {#3} #5 + \else: \__regex_group_repeat:nnnN {#1} {#3} {#4} #5 \fi: } -\cs_new_protected:Npn \regex_group:nnnN #1 +\cs_new_protected:Npn \__regex_group:nnnN #1 { - \exp_args:No \regex_group_aux:nnnnN - { \int_use:N \l_regex_capturing_group_int } + \exp_args:No \__regex_group_aux:nnnnN + { \int_use:N \l__regex_capturing_group_int } { - \int_incr:N \l_regex_capturing_group_int + \int_incr:N \l__regex_capturing_group_int #1 } } -\cs_new_protected_nopar:Npn \regex_group_no_capture:nnnN - { \regex_group_aux:nnnnN { -1 } } -\cs_new_protected:Npn \regex_group_resetting:nnnN #1 +\cs_new_protected_nopar:Npn \__regex_group_no_capture:nnnN + { \__regex_group_aux:nnnnN { -1 } } +\cs_new_protected:Npn \__regex_group_resetting:nnnN #1 { - \regex_group_aux:nnnnN { -1 } + \__regex_group_aux:nnnnN { -1 } { - \exp_args:Noo \regex_group_resetting_loop:nnNn - { \int_use:N \l_regex_capturing_group_int } - { \int_use:N \l_regex_capturing_group_int } + \exp_args:Noo \__regex_group_resetting_loop:nnNn + { \int_use:N \l__regex_capturing_group_int } + { \int_use:N \l__regex_capturing_group_int } #1 - { ?? \prg_map_break:n } { } - \prg_break_point:n { } + { ?? \__prg_break:n } { } + \__prg_break_point: } } -\cs_new_protected:Npn \regex_group_resetting_loop:nnNn #1#2#3#4 +\cs_new_protected:Npn \__regex_group_resetting_loop:nnNn #1#2#3#4 { - \use_none:nn #3 { \int_set:Nn \l_regex_capturing_group_int {#1} } - \int_set:Nn \l_regex_capturing_group_int {#2} + \use_none:nn #3 { \int_set:Nn \l__regex_capturing_group_int {#1} } + \int_set:Nn \l__regex_capturing_group_int {#2} #3 {#4} - \exp_args:Nf \regex_group_resetting_loop:nnNn - { \int_max:nn {#1} { \l_regex_capturing_group_int } } + \exp_args:Nf \__regex_group_resetting_loop:nnNn + { \int_max:nn {#1} { \l__regex_capturing_group_int } } {#2} } -\cs_new_protected:Npn \regex_branch:n #1 +\cs_new_protected:Npn \__regex_branch:n #1 { - \regex_build_new_state: - \seq_get:NN \l_regex_left_state_seq \l_regex_internal_a_tl - \int_set:Nn \l_regex_left_state_int \l_regex_internal_a_tl - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_left_state_int \l_regex_right_state_int + \__regex_build_new_state: + \seq_get:NN \l__regex_left_state_seq \l__regex_internal_a_tl + \int_set:Nn \l__regex_left_state_int \l__regex_internal_a_tl + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_left_state_int \l__regex_right_state_int #1 - \seq_get:NN \l_regex_right_state_seq \l_regex_internal_a_tl - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_internal_a_tl + \seq_get:NN \l__regex_right_state_seq \l__regex_internal_a_tl + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_internal_a_tl } -\cs_new_protected:Npn \regex_group_repeat:nn #1#2 +\cs_new_protected:Npn \__regex_group_repeat:nn #1#2 { - \if_num:w #2 = \c_zero - \int_set:Nn \l_regex_max_state_int - { \l_regex_left_state_int - \c_one } - \regex_build_new_state: + \if_int_compare:w #2 = \c_zero + \int_set:Nn \l__regex_max_state_int + { \l__regex_left_state_int - \c_one } + \__regex_build_new_state: \else: - \regex_group_repeat_aux:n {#2} - \regex_group_submatches:nNN {#1} - \l_regex_internal_a_int \l_regex_right_state_int - \regex_build_new_state: + \__regex_group_repeat_aux:n {#2} + \__regex_group_submatches:nNN {#1} + \l__regex_internal_a_int \l__regex_right_state_int + \__regex_build_new_state: \fi: } -\cs_new_protected:Npn \regex_group_submatches:nNN #1#2#3 +\cs_new_protected:Npn \__regex_group_submatches:nNN #1#2#3 { - \if_num:w #1 > \c_minus_one - \regex_toks_put_left:Nx #2 { \regex_action_submatch:n { #1 < } } - \regex_toks_put_left:Nx #3 { \regex_action_submatch:n { #1 > } } + \if_int_compare:w #1 > \c_minus_one + \__regex_toks_put_left:Nx #2 { \__regex_action_submatch:n { #1 < } } + \__regex_toks_put_left:Nx #3 { \__regex_action_submatch:n { #1 > } } \fi: } -\cs_new_protected:Npn \regex_group_repeat_aux:n #1 +\cs_new_protected:Npn \__regex_group_repeat_aux:n #1 { - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_max_state_int - \int_set_eq:NN \l_regex_internal_a_int \l_regex_left_state_int - \int_set_eq:NN \l_regex_internal_b_int \l_regex_max_state_int - \if_num:w \int_eval:w #1 > \c_one - \int_set:Nn \l_regex_internal_c_int + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_max_state_int + \int_set_eq:NN \l__regex_internal_a_int \l__regex_left_state_int + \int_set_eq:NN \l__regex_internal_b_int \l__regex_max_state_int + \if_int_compare:w \__int_eval:w #1 > \c_one + \int_set:Nn \l__regex_internal_c_int { ( #1 - \c_one ) - * ( \l_regex_internal_b_int - \l_regex_internal_a_int ) + * ( \l__regex_internal_b_int - \l__regex_internal_a_int ) } - \tex_advance:D \l_regex_right_state_int \l_regex_internal_c_int - \tex_advance:D \l_regex_max_state_int \l_regex_internal_c_int - \prg_replicate:nn \l_regex_internal_c_int + \tex_advance:D \l__regex_right_state_int \l__regex_internal_c_int + \tex_advance:D \l__regex_max_state_int \l__regex_internal_c_int + \prg_replicate:nn \l__regex_internal_c_int { - \tex_toks:D \l_regex_internal_b_int - = \tex_toks:D \l_regex_internal_a_int - \tex_advance:D \l_regex_internal_a_int \c_one - \tex_advance:D \l_regex_internal_b_int \c_one + \tex_toks:D \l__regex_internal_b_int + = \tex_toks:D \l__regex_internal_a_int + \tex_advance:D \l__regex_internal_a_int \c_one + \tex_advance:D \l__regex_internal_b_int \c_one } \fi: } -\cs_new_protected:Npn \regex_group_repeat:nnN #1#2#3 +\cs_new_protected:Npn \__regex_group_repeat:nnN #1#2#3 { - \if_num:w #2 = \c_zero - \regex_group_submatches:nNN {#1} - \l_regex_left_state_int \l_regex_right_state_int - \int_set:Nn \l_regex_internal_a_int - { \l_regex_left_state_int - \c_one } - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_internal_a_int - \regex_build_new_state: + \if_int_compare:w #2 = \c_zero + \__regex_group_submatches:nNN {#1} + \l__regex_left_state_int \l__regex_right_state_int + \int_set:Nn \l__regex_internal_a_int + { \l__regex_left_state_int - \c_one } + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_internal_a_int + \__regex_build_new_state: \if_meaning:w \c_true_bool #3 - \regex_build_transition_left:NNN \regex_action_free:n - \l_regex_internal_a_int \l_regex_right_state_int + \__regex_build_transition_left:NNN \__regex_action_free:n + \l__regex_internal_a_int \l__regex_right_state_int \else: - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_internal_a_int \l_regex_right_state_int + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_internal_a_int \l__regex_right_state_int \fi: \else: - \regex_group_repeat_aux:n {#2} - \regex_group_submatches:nNN {#1} - \l_regex_internal_a_int \l_regex_right_state_int + \__regex_group_repeat_aux:n {#2} + \__regex_group_submatches:nNN {#1} + \l__regex_internal_a_int \l__regex_right_state_int \if_meaning:w \c_true_bool #3 - \regex_build_transition_right:nNn \regex_action_free_group:n - \l_regex_right_state_int \l_regex_internal_a_int + \__regex_build_transition_right:nNn \__regex_action_free_group:n + \l__regex_right_state_int \l__regex_internal_a_int \else: - \regex_build_transition_left:NNN \regex_action_free_group:n - \l_regex_right_state_int \l_regex_internal_a_int + \__regex_build_transition_left:NNN \__regex_action_free_group:n + \l__regex_right_state_int \l__regex_internal_a_int \fi: - \regex_build_new_state: + \__regex_build_new_state: \fi: } -\cs_new_protected:Npn \regex_group_repeat:nnnN #1#2#3#4 +\cs_new_protected:Npn \__regex_group_repeat:nnnN #1#2#3#4 { - \regex_group_submatches:nNN {#1} - \l_regex_left_state_int \l_regex_right_state_int - \regex_group_repeat_aux:n { #2 + #3 } + \__regex_group_submatches:nNN {#1} + \l__regex_left_state_int \l__regex_right_state_int + \__regex_group_repeat_aux:n { #2 + #3 } \if_meaning:w \c_true_bool #4 - \int_set_eq:NN \l_regex_left_state_int \l_regex_max_state_int + \int_set_eq:NN \l__regex_left_state_int \l__regex_max_state_int \prg_replicate:nn { #3 } { - \int_sub:Nn \l_regex_left_state_int - { \l_regex_internal_b_int - \l_regex_internal_a_int } - \regex_build_transition_left:NNN \regex_action_free:n - \l_regex_left_state_int \l_regex_max_state_int + \int_sub:Nn \l__regex_left_state_int + { \l__regex_internal_b_int - \l__regex_internal_a_int } + \__regex_build_transition_left:NNN \__regex_action_free:n + \l__regex_left_state_int \l__regex_max_state_int } \else: \prg_replicate:nn { #3 - \c_one } { - \int_sub:Nn \l_regex_right_state_int - { \l_regex_internal_b_int - \l_regex_internal_a_int } - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_max_state_int + \int_sub:Nn \l__regex_right_state_int + { \l__regex_internal_b_int - \l__regex_internal_a_int } + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_max_state_int } - \if_num:w #2 = \c_zero - \int_set:Nn \l_regex_right_state_int - { \l_regex_left_state_int - \c_one } + \if_int_compare:w #2 = \c_zero + \int_set:Nn \l__regex_right_state_int + { \l__regex_left_state_int - \c_one } \else: - \int_sub:Nn \l_regex_right_state_int - { \l_regex_internal_b_int - \l_regex_internal_a_int } + \int_sub:Nn \l__regex_right_state_int + { \l__regex_internal_b_int - \l__regex_internal_a_int } \fi: - \regex_build_transition_right:nNn \regex_action_free:n - \l_regex_right_state_int \l_regex_max_state_int + \__regex_build_transition_right:nNn \__regex_action_free:n + \l__regex_right_state_int \l__regex_max_state_int \fi: - \regex_build_new_state: + \__regex_build_new_state: } -\cs_new_protected:Npn \regex_assertion:Nn #1#2 +\cs_new_protected:Npn \__regex_assertion:Nn #1#2 { - \regex_build_new_state: - \regex_toks_put_right:Nx \l_regex_left_state_int + \__regex_build_new_state: + \__regex_toks_put_right:Nx \l__regex_left_state_int { \exp_not:n {#2} - \regex_break_point:TF + \__regex_break_point:TF \bool_if:NF #1 { { } } { - \regex_action_free:n + \__regex_action_free:n { \int_eval:n - { \l_regex_right_state_int - \l_regex_left_state_int } + { \l__regex_right_state_int - \l__regex_left_state_int } } } \bool_if:NT #1 { { } } } } -\cs_new_protected:Npn \regex_anchor:N #1 +\cs_new_protected:Npn \__regex_anchor:N #1 { - \if_num:w #1 = \l_regex_current_pos_int - \exp_after:wN \regex_break_true:w + \if_int_compare:w #1 = \l__regex_current_pos_int + \exp_after:wN \__regex_break_true:w \fi: } -\cs_new_protected_nopar:Npn \regex_b_test: +\cs_new_protected_nopar:Npn \__regex_b_test: { \group_begin: - \int_set_eq:NN \l_regex_current_char_int \l_regex_last_char_int - \regex_prop_w: - \regex_break_point:TF - { \group_end: \regex_item_reverse:n \regex_prop_w: } - { \group_end: \regex_prop_w: } - } -\cs_new_protected_nopar:Npn \regex_command_K: - { - \regex_build_new_state: - \regex_toks_put_right:Nx \l_regex_left_state_int - { - \regex_action_submatch:n { 0< } - \bool_set_true:N \l_regex_fresh_thread_bool - \regex_action_free:n - { \int_eval:n { \l_regex_right_state_int - \l_regex_left_state_int } } - \bool_set_false:N \l_regex_fresh_thread_bool - } - } -\int_new:N \l_regex_min_pos_int -\int_new:N \l_regex_max_pos_int -\int_new:N \l_regex_current_pos_int -\int_new:N \l_regex_start_pos_int -\int_new:N \l_regex_success_pos_int -\int_new:N \l_regex_current_char_int -\int_new:N \l_regex_current_catcode_int -\int_new:N \l_regex_last_char_int -\int_new:N \l_regex_case_changed_char_int -\int_new:N \l_regex_current_state_int -\prop_new:N \l_regex_current_submatches_prop -\prop_new:N \l_regex_success_submatches_prop -\int_new:N \l_regex_step_int -\int_new:N \l_regex_min_active_int -\int_new:N \l_regex_max_active_int -\tl_new:N \l_regex_every_match_tl -\bool_new:N \l_regex_fresh_thread_bool -\bool_new:N \l_regex_empty_success_bool -\cs_new_eq:NN \regex_if_two_empty_matches:F \use:n -\bool_new:N \g_regex_success_bool -\bool_new:N \l_regex_saved_success_bool -\bool_new:N \l_regex_match_success_bool -\cs_new_protected:Npn \regex_match:n #1 - { - \int_zero:N \l_regex_balance_int - \int_set:Nn \l_regex_current_pos_int { \c_two * \l_regex_max_state_int } - \regex_query_set:nnn { } { -1 } { -2 } - \int_set_eq:NN \l_regex_min_pos_int \l_regex_current_pos_int - \tl_analysis_map_inline:nn {#1} - { \regex_query_set:nnn {##1} {"##2} {##3} } - \int_set_eq:NN \l_regex_max_pos_int \l_regex_current_pos_int - \regex_query_set:nnn { } { -1 } { -2 } - \bool_gset_false:N \g_regex_success_bool - \prg_stepwise_inline:nnnn - \l_regex_min_state_int \c_one { \l_regex_max_state_int - \c_one } + \int_set_eq:NN \l__regex_current_char_int \l__regex_last_char_int + \__regex_prop_w: + \__regex_break_point:TF + { \group_end: \__regex_item_reverse:n \__regex_prop_w: } + { \group_end: \__regex_prop_w: } + } +\cs_new_protected_nopar:Npn \__regex_command_K: + { + \__regex_build_new_state: + \__regex_toks_put_right:Nx \l__regex_left_state_int + { + \__regex_action_submatch:n { 0< } + \bool_set_true:N \l__regex_fresh_thread_bool + \__regex_action_free:n + { \int_eval:n { \l__regex_right_state_int - \l__regex_left_state_int } } + \bool_set_false:N \l__regex_fresh_thread_bool + } + } +\int_new:N \l__regex_min_pos_int +\int_new:N \l__regex_max_pos_int +\int_new:N \l__regex_current_pos_int +\int_new:N \l__regex_start_pos_int +\int_new:N \l__regex_success_pos_int +\int_new:N \l__regex_current_char_int +\int_new:N \l__regex_current_catcode_int +\int_new:N \l__regex_last_char_int +\int_new:N \l__regex_case_changed_char_int +\int_new:N \l__regex_current_state_int +\prop_new:N \l__regex_current_submatches_prop +\prop_new:N \l__regex_success_submatches_prop +\int_new:N \l__regex_step_int +\int_new:N \l__regex_min_active_int +\int_new:N \l__regex_max_active_int +\tl_new:N \l__regex_every_match_tl +\bool_new:N \l__regex_fresh_thread_bool +\bool_new:N \l__regex_empty_success_bool +\cs_new_eq:NN \__regex_if_two_empty_matches:F \use:n +\bool_new:N \g__regex_success_bool +\bool_new:N \l__regex_saved_success_bool +\bool_new:N \l__regex_match_success_bool +\cs_new_protected:Npn \__regex_match:n #1 + { + \int_zero:N \l__regex_balance_int + \int_set:Nn \l__regex_current_pos_int { \c_two * \l__regex_max_state_int } + \__regex_query_set:nnn { } { -1 } { -2 } + \int_set_eq:NN \l__regex_min_pos_int \l__regex_current_pos_int + \__tl_analysis_map_inline:nn {#1} + { \__regex_query_set:nnn {##1} {"##2} {##3} } + \int_set_eq:NN \l__regex_max_pos_int \l__regex_current_pos_int + \__regex_query_set:nnn { } { -1 } { -2 } + \bool_gset_false:N \g__regex_success_bool + \int_step_inline:nnnn + \l__regex_min_state_int \c_one { \l__regex_max_state_int - \c_one } { \tex_dimen:D ##1 \c_one sp \scan_stop: } - \int_set_eq:NN \l_regex_min_active_int \l_regex_max_state_int - \int_set_eq:NN \l_regex_step_int \c_zero - \int_set_eq:NN \l_regex_success_pos_int \l_regex_min_pos_int - \int_set:Nn \l_regex_submatch_int - { \c_two * \l_regex_max_state_int } - \bool_set_false:N \l_regex_empty_success_bool - \regex_match_once: - } -\cs_new_protected_nopar:Npn \regex_match_once: - { - \if_meaning:w \c_true_bool \l_regex_empty_success_bool - \cs_set_nopar:Npn \regex_if_two_empty_matches:F - { \int_compare:nNnF \l_regex_start_pos_int = \l_regex_current_pos_int } + \int_set_eq:NN \l__regex_min_active_int \l__regex_max_state_int + \int_set_eq:NN \l__regex_step_int \c_zero + \int_set_eq:NN \l__regex_success_pos_int \l__regex_min_pos_int + \int_set:Nn \l__regex_submatch_int + { \c_two * \l__regex_max_state_int } + \bool_set_false:N \l__regex_empty_success_bool + \__regex_match_once: + } +\cs_new_protected_nopar:Npn \__regex_match_once: + { + \if_meaning:w \c_true_bool \l__regex_empty_success_bool + \cs_set_nopar:Npn \__regex_if_two_empty_matches:F + { \int_compare:nNnF \l__regex_start_pos_int = \l__regex_current_pos_int } \else: - \cs_set_eq:NN \regex_if_two_empty_matches:F \use:n + \cs_set_eq:NN \__regex_if_two_empty_matches:F \use:n \fi: - \int_set_eq:NN \l_regex_start_pos_int \l_regex_success_pos_int - \bool_set_false:N \l_regex_match_success_bool - \prop_clear:N \l_regex_current_submatches_prop - \int_set_eq:NN \l_regex_max_active_int \l_regex_min_active_int - \regex_store_state:n { \l_regex_min_state_int } - \int_set:Nn \l_regex_current_pos_int - { \l_regex_start_pos_int - \c_one } - \regex_query_get: - \regex_match_loop: - \l_regex_every_match_tl + \int_set_eq:NN \l__regex_start_pos_int \l__regex_success_pos_int + \bool_set_false:N \l__regex_match_success_bool + \prop_clear:N \l__regex_current_submatches_prop + \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int + \__regex_store_state:n { \l__regex_min_state_int } + \int_set:Nn \l__regex_current_pos_int + { \l__regex_start_pos_int - \c_one } + \__regex_query_get: + \__regex_match_loop: + \l__regex_every_match_tl } -\cs_new_protected_nopar:Npn \regex_single_match: +\cs_new_protected_nopar:Npn \__regex_single_match: { - \tl_set:Nn \l_regex_every_match_tl - { \bool_gset_eq:NN \g_regex_success_bool \l_regex_match_success_bool } + \tl_set:Nn \l__regex_every_match_tl + { \bool_gset_eq:NN \g__regex_success_bool \l__regex_match_success_bool } } -\cs_new_protected:Npn \regex_multi_match:n #1 +\cs_new_protected:Npn \__regex_multi_match:n #1 { - \tl_set:Nn \l_regex_every_match_tl + \tl_set:Nn \l__regex_every_match_tl { - \if_meaning:w \c_true_bool \l_regex_match_success_bool - \bool_gset_true:N \g_regex_success_bool + \if_meaning:w \c_true_bool \l__regex_match_success_bool + \bool_gset_true:N \g__regex_success_bool #1 - \exp_after:wN \regex_match_once: + \exp_after:wN \__regex_match_once: \fi: } } -\cs_new_protected_nopar:Npn \regex_match_loop: +\cs_new_protected_nopar:Npn \__regex_match_loop: { - \tex_advance:D \l_regex_step_int \c_two - \int_incr:N \l_regex_current_pos_int - \int_set_eq:NN \l_regex_last_char_int \l_regex_current_char_int - \int_set_eq:NN \l_regex_case_changed_char_int \c_max_int - \regex_query_get: + \tex_advance:D \l__regex_step_int \c_two + \int_incr:N \l__regex_current_pos_int + \int_set_eq:NN \l__regex_last_char_int \l__regex_current_char_int + \int_set_eq:NN \l__regex_case_changed_char_int \c_max_int + \__regex_query_get: \use:x { - \int_set_eq:NN \l_regex_max_active_int \l_regex_min_active_int - \exp_after:wN \regex_match_one_active:w - \int_use:N \l_regex_min_active_int ; + \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int + \exp_after:wN \__regex_match_one_active:w + \int_use:N \l__regex_min_active_int ; } - \prg_break_point:n { \bool_set_false:N \l_regex_fresh_thread_bool } - \if_num:w \l_regex_max_active_int > \l_regex_min_active_int - \if_num:w \l_regex_current_pos_int < \l_regex_max_pos_int - \exp_after:wN \exp_after:wN \exp_after:wN \regex_match_loop: + \__prg_break_point: + \bool_set_false:N \l__regex_fresh_thread_bool %^^A was arg of break_point:n + \if_int_compare:w \l__regex_max_active_int > \l__regex_min_active_int + \if_int_compare:w \l__regex_current_pos_int < \l__regex_max_pos_int + \exp_after:wN \exp_after:wN \exp_after:wN \__regex_match_loop: \fi: \fi: } -\cs_new:Npn \regex_match_one_active:w #1; +\cs_new:Npn \__regex_match_one_active:w #1; { - \if_num:w #1 < \l_regex_max_active_int - \regex_use_state_and_submatches:nn - { \int_value:w \tex_skip:D #1 } + \if_int_compare:w #1 < \l__regex_max_active_int + \__regex_use_state_and_submatches:nn + { \__int_value:w \tex_skip:D #1 } { \tex_the:D \tex_toks:D #1 } - \exp_after:wN \regex_match_one_active:w - \int_use:N \int_eval:w #1 + \c_one \exp_after:wN ; + \exp_after:wN \__regex_match_one_active:w + \int_use:N \__int_eval:w #1 + \c_one \exp_after:wN ; \fi: } -\cs_new_protected:Npn \regex_query_set:nnn #1#2#3 +\cs_new_protected:Npn \__regex_query_set:nnn #1#2#3 { - \tex_muskip:D \l_regex_current_pos_int + \tex_muskip:D \l__regex_current_pos_int = \etex_gluetomu:D #3 sp plus #2 sp - minus \l_regex_balance_int sp + minus \l__regex_balance_int sp \scan_stop: - \tex_toks:D \l_regex_current_pos_int {#1} - \int_incr:N \l_regex_current_pos_int + \tex_toks:D \l__regex_current_pos_int {#1} + \int_incr:N \l__regex_current_pos_int \if_case:w #2 \exp_stop_f: - \or: \int_incr:N \l_regex_balance_int - \or: \int_decr:N \l_regex_balance_int + \or: \int_incr:N \l__regex_balance_int + \or: \int_decr:N \l__regex_balance_int \fi: } -\cs_new_protected_nopar:Npn \regex_query_get: +\cs_new_protected_nopar:Npn \__regex_query_get: { - \l_regex_current_char_int - = \etex_mutoglue:D \tex_muskip:D \l_regex_current_pos_int - \l_regex_current_catcode_int = \etex_gluestretch:D - \etex_mutoglue:D \tex_muskip:D \l_regex_current_pos_int + \l__regex_current_char_int + = \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int + \l__regex_current_catcode_int = \etex_gluestretch:D + \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int } -\cs_new_protected_nopar:Npn \regex_use_state: +\cs_new_protected_nopar:Npn \__regex_use_state: { - \tex_dimen:D \l_regex_current_state_int - = \l_regex_step_int sp \scan_stop: - \tex_the:D \tex_toks:D \l_regex_current_state_int - \tex_dimen:D \l_regex_current_state_int - = \int_eval:w \l_regex_step_int + \c_one \int_eval_end: sp \scan_stop: + \tex_dimen:D \l__regex_current_state_int + = \l__regex_step_int sp \scan_stop: + \tex_the:D \tex_toks:D \l__regex_current_state_int + \tex_dimen:D \l__regex_current_state_int + = \__int_eval:w \l__regex_step_int + \c_one \__int_eval_end: sp \scan_stop: } -\cs_new_protected:Npn \regex_use_state_and_submatches:nn #1 #2 +\cs_new_protected:Npn \__regex_use_state_and_submatches:nn #1 #2 { - \int_set:Nn \l_regex_current_state_int {#1} - \if_num:w \tex_dimen:D \l_regex_current_state_int < \l_regex_step_int - \tl_set:Nn \l_regex_current_submatches_prop {#2} - \exp_after:wN \regex_use_state: + \int_set:Nn \l__regex_current_state_int {#1} + \if_int_compare:w \tex_dimen:D \l__regex_current_state_int + < \l__regex_step_int + \tl_set:Nn \l__regex_current_submatches_prop {#2} + \exp_after:wN \__regex_use_state: \fi: \scan_stop: } -\cs_new_protected_nopar:Npn \regex_action_start_wildcard: +\cs_new_protected_nopar:Npn \__regex_action_start_wildcard: { - \bool_set_true:N \l_regex_fresh_thread_bool - \regex_action_free:n {1} - \bool_set_false:N \l_regex_fresh_thread_bool - \regex_action_cost:n {0} + \bool_set_true:N \l__regex_fresh_thread_bool + \__regex_action_free:n {1} + \bool_set_false:N \l__regex_fresh_thread_bool + \__regex_action_cost:n {0} } -\cs_new_protected_nopar:Npn \regex_action_free:n - { \regex_action_free_aux:nn { > \l_regex_step_int \else: } } -\cs_new_protected_nopar:Npn \regex_action_free_group:n - { \regex_action_free_aux:nn { < \l_regex_step_int } } -\cs_new_protected:Npn \regex_action_free_aux:nn #1#2 +\cs_new_protected_nopar:Npn \__regex_action_free:n + { \__regex_action_free_aux:nn { > \l__regex_step_int \else: } } +\cs_new_protected_nopar:Npn \__regex_action_free_group:n + { \__regex_action_free_aux:nn { < \l__regex_step_int } } +\cs_new_protected:Npn \__regex_action_free_aux:nn #1#2 { \use:x { - \int_add:Nn \l_regex_current_state_int {#2} + \int_add:Nn \l__regex_current_state_int {#2} \exp_not:n { - \if_num:w \tex_dimen:D \l_regex_current_state_int #1 - \exp_after:wN \regex_use_state: + \if_int_compare:w \tex_dimen:D \l__regex_current_state_int #1 + \exp_after:wN \__regex_use_state: \fi: } - \int_set:Nn \l_regex_current_state_int - { \int_use:N \l_regex_current_state_int } - \tl_set:Nn \exp_not:N \l_regex_current_submatches_prop - { \exp_not:o \l_regex_current_submatches_prop } + \int_set:Nn \l__regex_current_state_int + { \int_use:N \l__regex_current_state_int } + \tl_set:Nn \exp_not:N \l__regex_current_submatches_prop + { \exp_not:o \l__regex_current_submatches_prop } } } -\cs_new_protected:Npn \regex_action_cost:n #1 +\cs_new_protected:Npn \__regex_action_cost:n #1 { - \exp_args:No \regex_store_state:n - { \int_use:N \int_eval:w \l_regex_current_state_int + #1 } + \exp_args:No \__regex_store_state:n + { \int_use:N \__int_eval:w \l__regex_current_state_int + #1 } } -\cs_new_protected:Npn \regex_store_state:n #1 +\cs_new_protected:Npn \__regex_store_state:n #1 { - \regex_store_submatches: - \tex_skip:D \l_regex_max_active_int = #1 sp \scan_stop: - \int_incr:N \l_regex_max_active_int + \__regex_store_submatches: + \tex_skip:D \l__regex_max_active_int = #1 sp \scan_stop: + \int_incr:N \l__regex_max_active_int } -\cs_new_protected_nopar:Npn \regex_store_submatches: +\cs_new_protected_nopar:Npn \__regex_store_submatches: { - \tex_toks:D \l_regex_max_active_int \exp_after:wN - { \l_regex_current_submatches_prop } + \tex_toks:D \l__regex_max_active_int \exp_after:wN + { \l__regex_current_submatches_prop } } -\cs_new_protected_nopar:Npn \regex_disable_submatches: +\cs_new_protected_nopar:Npn \__regex_disable_submatches: { - \cs_set_protected_nopar:Npn \regex_store_submatches: { } - \cs_set_protected:Npn \regex_action_submatch:n ##1 { } + \cs_set_protected_nopar:Npn \__regex_store_submatches: { } + \cs_set_protected:Npn \__regex_action_submatch:n ##1 { } } -\cs_new_protected:Npn \regex_action_submatch:n #1 +\cs_new_protected:Npn \__regex_action_submatch:n #1 { - \prop_put:Nno \l_regex_current_submatches_prop {#1} - { \int_use:N \l_regex_current_pos_int } + \prop_put:Nno \l__regex_current_submatches_prop {#1} + { \int_use:N \l__regex_current_pos_int } } -\cs_new_protected_nopar:Npn \regex_action_success: +\cs_new_protected_nopar:Npn \__regex_action_success: { - \regex_if_two_empty_matches:F + \__regex_if_two_empty_matches:F { - \bool_set_true:N \l_regex_match_success_bool - \bool_set_eq:NN \l_regex_empty_success_bool - \l_regex_fresh_thread_bool - \int_set_eq:NN \l_regex_success_pos_int \l_regex_current_pos_int - \prop_set_eq:NN \l_regex_success_submatches_prop - \l_regex_current_submatches_prop - \prg_map_break: + \bool_set_true:N \l__regex_match_success_bool + \bool_set_eq:NN \l__regex_empty_success_bool + \l__regex_fresh_thread_bool + \int_set_eq:NN \l__regex_success_pos_int \l__regex_current_pos_int + \prop_set_eq:NN \l__regex_success_submatches_prop + \l__regex_current_submatches_prop + \__prg_break: } } -\int_new:N \l_regex_replacement_csnames_int -\tl_new:N \l_regex_balance_tl -\cs_new:Npn \regex_replacement_balance_one_match:n #1 - { - \regex_submatch_balance:n {#1} } -\cs_new:Npn \regex_replacement_do_one_match:n #1 +\int_new:N \l__regex_replacement_csnames_int +\tl_new:N \l__regex_balance_tl +\cs_new:Npn \__regex_replacement_balance_one_match:n #1 + { - \__regex_submatch_balance:n {#1} } +\cs_new:Npn \__regex_replacement_do_one_match:n #1 { - \regex_query_range:nn + \__regex_query_range:nn { \etex_glueshrink:D \tex_skip:D #1 } { \tex_skip:D #1 } } -\cs_new:Npn \regex_replacement_exp_not:N #1 { \exp_not:n {#1} } -\cs_new:Npn \regex_query_range:nn #1#2 +\cs_new:Npn \__regex_replacement_exp_not:N #1 { \exp_not:n {#1} } +\cs_new:Npn \__regex_query_range:nn #1#2 { - \exp_after:wN \regex_query_range_loop:ww - \int_use:N \int_eval:w #1 \exp_after:wN ; - \int_use:N \int_eval:w #2 ; - \prg_break_point:n { } + \exp_after:wN \__regex_query_range_loop:ww + \int_use:N \__int_eval:w #1 \exp_after:wN ; + \int_use:N \__int_eval:w #2 ; + \__prg_break_point: } -\cs_new:Npn \regex_query_range_loop:ww #1 ; #2 ; +\cs_new:Npn \__regex_query_range_loop:ww #1 ; #2 ; { - \if_num:w #1 < #2 \exp_stop_f: + \if_int_compare:w #1 < #2 \exp_stop_f: \else: - \exp_after:wN \prg_map_break: + \exp_after:wN \__prg_break: \fi: \tex_the:D \tex_toks:D #1 \exp_stop_f: - \exp_after:wN \regex_query_range_loop:ww - \int_use:N \int_eval:w #1 + \c_one ; #2 ; + \exp_after:wN \__regex_query_range_loop:ww + \int_use:N \__int_eval:w #1 + \c_one ; #2 ; } -\cs_new:Npn \regex_query_submatch:n #1 +\cs_new:Npn \__regex_query_submatch:n #1 { - \regex_query_range:nn - { \tex_skip:D \int_eval:w #1 } - { \etex_gluestretch:D \tex_skip:D \int_eval:w #1 } + \__regex_query_range:nn + { \tex_skip:D \__int_eval:w #1 } + { \etex_gluestretch:D \tex_skip:D \__int_eval:w #1 } } -\cs_new_protected:Npn \regex_submatch_balance:n #1 +\cs_new_protected:Npn \__regex_submatch_balance:n #1 { \etex_glueshrink:D \etex_mutoglue:D \etex_muexpr:D \tex_muskip:D \etex_gluestretch:D \tex_skip:D #1 - \tex_muskip:D \tex_skip:D #1 \scan_stop: } -\cs_new_protected:Npn \regex_replacement:n #1 +\cs_new_protected:Npn \__regex_replacement:n #1 { - \tl_set_build:Nw \l_regex_internal_a_tl - \int_zero:N \l_regex_balance_int - \tl_clear:N \l_regex_balance_tl - \regex_escape_use:nnnn + \__tl_build:Nw \l__regex_internal_a_tl + \int_zero:N \l__regex_balance_int + \tl_clear:N \l__regex_balance_tl + \__regex_escape_use:nnnn { \if_charcode:w \c_rbrace_str ##1 - \regex_replacement_rbrace:N \else: \tl_build_one:n \fi: ##1 + \__regex_replacement_rbrace:N \else: \__tl_build_one:n \fi: ##1 } - { \regex_replacement_escaped:N ##1 } - { \tl_build_one:n ##1 } + { \__regex_replacement_escaped:N ##1 } + { \__tl_build_one:n ##1 } {#1} \prg_do_nothing: \prg_do_nothing: - \if_int_compare:w \l_regex_replacement_csnames_int > \c_zero - \msg_kernel_error:nnx { regex } { replacement-missing-rbrace } - { \int_use:N \l_regex_replacement_csnames_int } - \tl_build_one:x - { \prg_replicate:nn \l_regex_replacement_csnames_int \cs_end: } + \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero + \__msg_kernel_error:nnx { regex } { replacement-missing-rbrace } + { \int_use:N \l__regex_replacement_csnames_int } + \__tl_build_one:x + { \prg_replicate:nn \l__regex_replacement_csnames_int \cs_end: } \fi: - \cs_gset:Npx \regex_replacement_balance_one_match:n ##1 + \cs_gset:Npx \__regex_replacement_balance_one_match:n ##1 { - + \int_use:N \l_regex_balance_int - \l_regex_balance_tl - - \regex_submatch_balance:n {##1} + + \int_use:N \l__regex_balance_int + \l__regex_balance_tl + - \__regex_submatch_balance:n {##1} } - \tl_build_end: - \exp_args:No \regex_replacement_aux:n \l_regex_internal_a_tl + \__tl_build_end: + \exp_args:No \__regex_replacement_aux:n \l__regex_internal_a_tl } -\cs_new_protected:Npn \regex_replacement_aux:n #1 +\cs_new_protected:Npn \__regex_replacement_aux:n #1 { - \cs_set:Npn \regex_replacement_do_one_match:n ##1 + \cs_set:Npn \__regex_replacement_do_one_match:n ##1 { - \regex_query_range:nn + \__regex_query_range:nn { \etex_glueshrink:D \tex_skip:D ##1 } { \tex_skip:D ##1 } #1 } } -\cs_new_protected:Npn \regex_replacement_escaped:N #1 +\cs_new_protected:Npn \__regex_replacement_escaped:N #1 { - \cs_if_exist_use:cF { regex_replacement_#1:w } + \cs_if_exist_use:cF { __regex_replacement_#1:w } { - \if_num:w \c_one < 1#1 \exp_stop_f: - \regex_replacement_put_submatch:n {#1} + \if_int_compare:w \c_one < 1#1 \exp_stop_f: + \__regex_replacement_put_submatch:n {#1} \else: - \tl_build_one:n #1 + \__tl_build_one:n #1 \fi: } } -\cs_new_protected:Npn \regex_replacement_put_submatch:n #1 +\cs_new_protected:Npn \__regex_replacement_put_submatch:n #1 { - \if_num:w #1 < \l_regex_capturing_group_int - \tl_build_one:n { \regex_query_submatch:n { #1 + ##1 } } - \if_num:w \l_regex_replacement_csnames_int = \c_zero - \tl_put_right:Nn \l_regex_balance_tl - { + \regex_submatch_balance:n { \int_eval:w #1+##1 \int_eval_end: } } + \if_int_compare:w #1 < \l__regex_capturing_group_int + \__tl_build_one:n { \__regex_query_submatch:n { #1 + ##1 } } + \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero + \tl_put_right:Nn \l__regex_balance_tl + { + \__regex_submatch_balance:n { \__int_eval:w #1+##1 \__int_eval_end: } } \fi: \fi: } -\cs_new_protected:Npn \regex_replacement_g:w #1#2 +\cs_new_protected:Npn \__regex_replacement_g:w #1#2 { - \str_if_eq:xxTF { #1#2 } { \tl_build_one:n \c_lbrace_str } + \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_lbrace_str } { - \int_zero:N \l_regex_internal_a_int - \regex_replacement_g_digits:NN + \int_zero:N \l__regex_internal_a_int + \__regex_replacement_g_digits:NN } - { \regex_replacement_error:NNN g #1 #2 } + { \__regex_replacement_error:NNN g #1 #2 } } -\cs_new_protected:Npn \regex_replacement_g_digits:NN #1#2 +\cs_new_protected:Npn \__regex_replacement_g_digits:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__tl_build_one:n { - \if_num:w \c_one < 1#2 \exp_stop_f: - \int_set:Nn \l_regex_internal_a_int - { \c_ten * \l_regex_internal_a_int + #2 } + \if_int_compare:w \c_one < 1#2 \exp_stop_f: + \int_set:Nn \l__regex_internal_a_int + { \c_ten * \l__regex_internal_a_int + #2 } \exp_after:wN \use_i:nnn - \exp_after:wN \regex_replacement_g_digits:NN + \exp_after:wN \__regex_replacement_g_digits:NN \else: - \exp_after:wN \regex_replacement_error:NNN + \exp_after:wN \__regex_replacement_error:NNN \exp_after:wN g \fi: } { - \if_meaning:w \regex_replacement_rbrace:N #1 - \exp_args:No \regex_replacement_put_submatch:n - { \int_use:N \l_regex_internal_a_int } + \if_meaning:w \__regex_replacement_rbrace:N #1 + \exp_args:No \__regex_replacement_put_submatch:n + { \int_use:N \l__regex_internal_a_int } \exp_after:wN \use_none:nn \else: - \exp_after:wN \regex_replacement_error:NNN + \exp_after:wN \__regex_replacement_error:NNN \exp_after:wN g \fi: } #1 #2 } -\cs_new_protected:Npn \regex_replacement_c:w #1#2 +\cs_new_protected:Npn \__regex_replacement_c:w #1#2 { - \token_if_eq_meaning:NNTF #1 \tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__tl_build_one:n { - \cs_if_exist_use:cF { regex_replacement_c_#2:w } - { \regex_replacement_error:NNN c #1#2 } + \cs_if_exist_use:cF { __regex_replacement_c_#2:w } + { \__regex_replacement_error:NNN c #1#2 } } - { \regex_replacement_error:NNN c #1#2 } + { \__regex_replacement_error:NNN c #1#2 } } -\cs_new_protected_nopar:cpn { regex_replacement_c_ \c_lbrace_str :w } +\cs_new_protected_nopar:cpn { __regex_replacement_c_ \c_lbrace_str :w } { - \if_case:w \l_regex_replacement_csnames_int - \tl_build_one:n - { \exp_not:n { \exp_after:wN \regex_replacement_exp_not:N \cs:w } } + \if_case:w \l__regex_replacement_csnames_int + \__tl_build_one:n + { \exp_not:n { \exp_after:wN \__regex_replacement_exp_not:N \cs:w } } \else: - \tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:N \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:N \cs:w } } \fi: - \int_incr:N \l_regex_replacement_csnames_int + \int_incr:N \l__regex_replacement_csnames_int } -\cs_new_protected:Npn \regex_replacement_u:w #1#2 +\cs_new_protected:Npn \__regex_replacement_u:w #1#2 { - \str_if_eq:xxTF { #1#2 } { \tl_build_one:n \c_lbrace_str } + \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_lbrace_str } { - \if_case:w \l_regex_replacement_csnames_int - \tl_build_one:n { \exp_not:n { \exp_after:wN \exp_not:V \cs:w } } + \if_case:w \l__regex_replacement_csnames_int + \__tl_build_one:n { \exp_not:n { \exp_after:wN \exp_not:V \cs:w } } \else: - \tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } \fi: - \int_incr:N \l_regex_replacement_csnames_int + \int_incr:N \l__regex_replacement_csnames_int } - { \regex_replacement_error:NNN u #1#2 } + { \__regex_replacement_error:NNN u #1#2 } } -\cs_new_protected:Npn \regex_replacement_rbrace:N #1 +\cs_new_protected:Npn \__regex_replacement_rbrace:N #1 { - \if_int_compare:w \l_regex_replacement_csnames_int > \c_zero - \tl_build_one:n \cs_end: - \int_decr:N \l_regex_replacement_csnames_int + \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero + \__tl_build_one:n \cs_end: + \int_decr:N \l__regex_replacement_csnames_int \else: - \tl_build_one:n #1 + \__tl_build_one:n #1 \fi: } \group_begin: - \cs_new_protected:Npn \regex_replacement_char:nNN #1#2#3 + \cs_new_protected:Npn \__regex_replacement_char:nNN #1#2#3 { \if_meaning:w \prg_do_nothing: #3 - \msg_kernel_error:nn { regex } { replacement-catcode-end } + \__msg_kernel_error:nn { regex } { replacement-catcode-end } \else: \tex_lccode:D \c_zero = `#3 \scan_stop: - \tl_to_lowercase:n { \tl_build_one:n {#1} } + \tl_to_lowercase:n { \__tl_build_one:n {#1} } \fi: } \char_set_catcode_active:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_A:w - { \regex_replacement_char:nNN { \exp_not:n { \exp_not:N ^^@ } } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_A:w + { \__regex_replacement_char:nNN { \exp_not:n { \exp_not:N ^^@ } } } \char_set_catcode_group_begin:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_B:w + \cs_new_protected_nopar:Npn \__regex_replacement_c_B:w { - \if_num:w \l_regex_replacement_csnames_int = \c_zero - \int_incr:N \l_regex_balance_int + \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero + \int_incr:N \l__regex_balance_int \fi: - \regex_replacement_char:nNN + \__regex_replacement_char:nNN { \exp_not:n { \exp_after:wN ^^@ \if_false: } \fi: } } } - \cs_new_protected:Npn \regex_replacement_c_C:w #1#2 - { \tl_build_one:n { \exp_not:N \exp_not:N \exp_not:c {#2} } } + \cs_new_protected:Npn \__regex_replacement_c_C:w #1#2 + { \__tl_build_one:n { \exp_not:N \exp_not:N \exp_not:c {#2} } } \char_set_catcode_math_subscript:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_D:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_D:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_group_end:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_E:w + \cs_new_protected_nopar:Npn \__regex_replacement_c_E:w { - \if_num:w \l_regex_replacement_csnames_int = \c_zero - \int_decr:N \l_regex_balance_int + \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero + \int_decr:N \l__regex_balance_int \fi: - \regex_replacement_char:nNN + \__regex_replacement_char:nNN { \exp_not:n { \if_false: { \fi: ^^@ } } } \char_set_catcode_letter:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_L:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_L:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_math_toggle:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_M:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_M:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_other:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_O:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_O:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_parameter:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_P:w + \cs_new_protected_nopar:Npn \__regex_replacement_c_P:w { - \regex_replacement_char:nNN + \__regex_replacement_char:nNN { \exp_not:n { \exp_not:n { ^^@^^@^^@^^@ } } } } - \cs_new_protected:Npn \regex_replacement_c_S:w #1#2 + \cs_new_protected:Npn \__regex_replacement_c_S:w #1#2 { \if_meaning:w \prg_do_nothing: #2 - \msg_kernel_error:nn { regex } { replacement-catcode-end } + \__msg_kernel_error:nn { regex } { replacement-catcode-end } \else: - \if_num:w `#2 = \c_zero - \msg_kernel_error:nn { regex } { replacement-null-space } + \if_int_compare:w `#2 = \c_zero + \__msg_kernel_error:nn { regex } { replacement-null-space } \fi: \tex_lccode:D 32 = `#2 \scan_stop: - \tl_to_lowercase:n { \tl_build_one:n {~} } + \tl_to_lowercase:n { \__tl_build_one:n {~} } \fi: } \char_set_catcode_alignment:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_T:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_T:w + { \__regex_replacement_char:nNN { ^^@ } } \char_set_catcode_math_superscript:N \^^@ - \cs_new_protected_nopar:Npn \regex_replacement_c_U:w - { \regex_replacement_char:nNN { ^^@ } } + \cs_new_protected_nopar:Npn \__regex_replacement_c_U:w + { \__regex_replacement_char:nNN { ^^@ } } \group_end: -\cs_new_protected:Npn \regex_replacement_error:NNN #1#2#3 +\cs_new_protected:Npn \__regex_replacement_error:NNN #1#2#3 { - \msg_kernel_error:nnx { regex } { replacement-#1 } {#3} + \__msg_kernel_error:nnx { regex } { replacement-#1 } {#3} #2 #3 } \cs_new_protected:Npn \regex_new:N #1 - { \cs_new_eq:NN #1 \c_regex_no_match_regex } + { \cs_new_eq:NN #1 \c__regex_no_match_regex } \cs_new_protected_nopar:Npn \regex_set:Nn #1#2 { - \regex_compile:n {#2} - \tl_set_eq:NN #1 \l_regex_internal_regex + \__regex_compile:n {#2} + \tl_set_eq:NN #1 \l__regex_internal_regex } \cs_new_protected_nopar:Npn \regex_gset:Nn #1#2 { - \regex_compile:n {#2} - \tl_gset_eq:NN #1 \l_regex_internal_regex + \__regex_compile:n {#2} + \tl_gset_eq:NN #1 \l__regex_internal_regex } \cs_new_protected_nopar:Npn \regex_const:Nn #1#2 { - \regex_compile:n {#2} - \tl_const:Nx #1 { \exp_not:o \l_regex_internal_regex } + \__regex_compile:n {#2} + \tl_const:Nx #1 { \exp_not:o \l__regex_internal_regex } } \cs_new_protected:Npn \regex_show:n #1 { - \regex_compile:n {#1} - \regex_show_aux:Nx \l_regex_internal_regex + \__regex_compile:n {#1} + \__regex_show:Nx \l__regex_internal_regex { { \tl_to_str:n {#1} } } } \cs_new_protected:Npn \regex_show:N #1 - { \regex_show_aux:Nx #1 { variable~\token_to_str:N #1 } } + { \__regex_show:Nx #1 { variable~\token_to_str:N #1 } } \prg_new_protected_conditional:Npnn \regex_match:nn #1#2 { T , F , TF } { - \regex_match_aux:nn { \regex_build:n {#1} } {#2} - \regex_aux_return: + \__regex_if_match:nn { \__regex_build:n {#1} } {#2} + \__regex_return: } \prg_new_protected_conditional:Npnn \regex_match:Nn #1#2 { T , F , TF } { - \regex_match_aux:nn { \regex_build:N #1 } {#2} - \regex_aux_return: + \__regex_if_match:nn { \__regex_build:N #1 } {#2} + \__regex_return: } \cs_new_protected:Npn \regex_count:nnN #1 - { \regex_count_aux:nnN { \regex_build:n {#1} } } + { \__regex_count:nnN { \__regex_build:n {#1} } } \cs_new_protected:Npn \regex_count:NnN #1 - { \regex_count_aux:nnN { \regex_build:N #1 } } -\cs_set_protected:Npn \regex_tmp:w #1#2#3 + { \__regex_count:nnN { \__regex_build:N #1 } } +\cs_set_protected:Npn \__regex_tmp:w #1#2#3 { - \cs_new_protected:Npn #2 ##1 { #1 { \regex_build:n {##1} } } - \cs_new_protected:Npn #3 ##1 { #1 { \regex_build:N ##1 } } + \cs_new_protected:Npn #2 ##1 { #1 { \__regex_build:n {##1} } } + \cs_new_protected:Npn #3 ##1 { #1 { \__regex_build:N ##1 } } \prg_new_protected_conditional:Npnn #2 ##1##2##3 { T , F , TF } - { #1 { \regex_build:n {##1} } {##2} ##3 \regex_aux_return: } + { #1 { \__regex_build:n {##1} } {##2} ##3 \__regex_return: } \prg_new_protected_conditional:Npnn #3 ##1##2##3 { T , F , TF } - { #1 { \regex_build:N ##1 } {##2} ##3 \regex_aux_return: } + { #1 { \__regex_build:N ##1 } {##2} ##3 \__regex_return: } } -\regex_tmp:w \regex_extract_once_aux:nnN +\__regex_tmp:w \__regex_extract_once:nnN \regex_extract_once:nnN \regex_extract_once:NnN -\regex_tmp:w \regex_extract_all_aux:nnN +\__regex_tmp:w \__regex_extract_all:nnN \regex_extract_all:nnN \regex_extract_all:NnN -\regex_tmp:w \regex_replace_once_aux:nnN +\__regex_tmp:w \__regex_replace_once:nnN \regex_replace_once:nnN \regex_replace_once:NnN -\regex_tmp:w \regex_replace_all_aux:nnN +\__regex_tmp:w \__regex_replace_all:nnN \regex_replace_all:nnN \regex_replace_all:NnN -\regex_tmp:w \regex_split_aux:nnN \regex_split:nnN \regex_split:NnN -\int_new:N \l_regex_match_count_int -\flag_new:n { regex_begin } -\flag_new:n { regex_end } -\int_new:N \l_regex_submatch_int -\int_new:N \l_regex_zeroth_submatch_int -\cs_new_protected_nopar:Npn \regex_aux_return: - { - \if_meaning:w \c_true_bool \g_regex_success_bool +\__regex_tmp:w \__regex_split:nnN \regex_split:nnN \regex_split:NnN +\int_new:N \l__regex_match_count_int +\flag_new:n { __regex_begin } +\flag_new:n { __regex_end } +\int_new:N \l__regex_submatch_int +\int_new:N \l__regex_zeroth_submatch_int +\cs_new_protected_nopar:Npn \__regex_return: + { + \if_meaning:w \c_true_bool \g__regex_success_bool \prg_return_true: \else: \prg_return_false: \fi: } -\cs_new_protected:Npn \regex_match_aux:nn #1#2 +\cs_new_protected:Npn \__regex_if_match:nn #1#2 { \group_begin: - \regex_disable_submatches: - \regex_single_match: + \__regex_disable_submatches: + \__regex_single_match: #1 - \regex_match:n {#2} + \__regex_match:n {#2} \group_end: } -\cs_new_protected:Npn \regex_count_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_count:nnN #1#2#3 { \group_begin: - \regex_disable_submatches: - \int_zero:N \l_regex_match_count_int - \regex_multi_match:n { \int_incr:N \l_regex_match_count_int } + \__regex_disable_submatches: + \int_zero:N \l__regex_match_count_int + \__regex_multi_match:n { \int_incr:N \l__regex_match_count_int } #1 - \regex_match:n {#2} + \__regex_match:n {#2} \exp_args:NNNo \group_end: - \int_set:Nn #3 { \int_use:N \l_regex_match_count_int } + \int_set:Nn #3 { \int_use:N \l__regex_match_count_int } } -\cs_new_protected:Npn \regex_extract_once_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_extract_once:nnN #1#2#3 { \group_begin: - \regex_single_match: + \__regex_single_match: #1 - \regex_match:n {#2} - \regex_extract: - \regex_group_end_extract_seq:N #3 + \__regex_match:n {#2} + \__regex_extract: + \__regex_group_end_extract_seq:N #3 } -\cs_new_protected:Npn \regex_extract_all_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_extract_all:nnN #1#2#3 { \group_begin: - \regex_multi_match:n { \regex_extract: } + \__regex_multi_match:n { \__regex_extract: } #1 - \regex_match:n {#2} - \regex_group_end_extract_seq:N #3 + \__regex_match:n {#2} + \__regex_group_end_extract_seq:N #3 } -\cs_new_protected:Npn \regex_split_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_split:nnN #1#2#3 { \group_begin: - \regex_multi_match:n + \__regex_multi_match:n { - \if_num:w \l_regex_start_pos_int < \l_regex_success_pos_int - \regex_extract: - \tex_skip:D \l_regex_zeroth_submatch_int - = \l_regex_start_pos_int sp - plus \tex_skip:D \l_regex_zeroth_submatch_int \scan_stop: + \if_int_compare:w \l__regex_start_pos_int < \l__regex_success_pos_int + \__regex_extract: + \tex_skip:D \l__regex_zeroth_submatch_int + = \l__regex_start_pos_int sp + plus \tex_skip:D \l__regex_zeroth_submatch_int \scan_stop: \fi: } #1 - \regex_match:n {#2} - \tex_skip:D \l_regex_submatch_int - = \l_regex_start_pos_int sp plus \l_regex_max_pos_int sp \scan_stop: - \int_incr:N \l_regex_submatch_int - \if_meaning:w \c_true_bool \l_regex_empty_success_bool - \if_num:w \l_regex_start_pos_int = \l_regex_max_pos_int - \int_decr:N \l_regex_submatch_int + \__regex_match:n {#2} + \tex_skip:D \l__regex_submatch_int + = \l__regex_start_pos_int sp plus \l__regex_max_pos_int sp \scan_stop: + \int_incr:N \l__regex_submatch_int + \if_meaning:w \c_true_bool \l__regex_empty_success_bool + \if_int_compare:w \l__regex_start_pos_int = \l__regex_max_pos_int + \int_decr:N \l__regex_submatch_int \fi: \fi: - \regex_group_end_extract_seq:N #3 + \__regex_group_end_extract_seq:N #3 } -\cs_new_protected:Npn \regex_group_end_extract_seq:N #1 +\cs_new_protected:Npn \__regex_group_end_extract_seq:N #1 { - \cs_set_eq:NN \seq_item:n \scan_stop: - \flag_clear:n { regex_begin } - \flag_clear:n { regex_end } - \tl_set:Nx \l_regex_internal_a_tl + \cs_set_eq:NN \__seq_item:n \scan_stop: + \flag_clear:n { __regex_begin } + \flag_clear:n { __regex_end } + \tl_set:Nx \l__regex_internal_a_tl { - \prg_stepwise_function:nnnN - { \c_two * \l_regex_max_state_int } + \int_step_function:nnnN + { \c_two * \l__regex_max_state_int } \c_one - { \l_regex_submatch_int - \c_one } - \regex_extract_seq_aux:n + { \l__regex_submatch_int - \c_one } + \__regex_extract_seq_aux:n } \int_compare:nNnF - { \flag_height:n { regex_begin } + \flag_height:n { regex_end } } + { \flag_height:n { __regex_begin } + \flag_height:n { __regex_end } } = \c_zero { - \msg_kernel_error:nnxxx { regex } { result-unbalanced } + \__msg_kernel_error:nnxxx { regex } { result-unbalanced } { splitting~or~extracting~submatches } - { \flag_height:n { regex_end } } - { \flag_height:n { regex_begin } } + { \flag_height:n { __regex_end } } + { \flag_height:n { __regex_begin } } } \use:x { \group_end: - \tl_set:Nn \exp_not:N #1 { \l_regex_internal_a_tl } + \tl_set:Nn \exp_not:N #1 { \l__regex_internal_a_tl } } } -\cs_new:Npn \regex_extract_seq_aux:n #1 +\cs_new:Npn \__regex_extract_seq_aux:n #1 { - \seq_item:n + \__seq_item:n { - \exp_after:wN \regex_extract_seq_aux:ww - \int_value:w \regex_submatch_balance:n {#1} ; #1; + \exp_after:wN \__regex_extract_seq_aux:ww + \__int_value:w \__regex_submatch_balance:n {#1} ; #1; } } -\cs_new:Npn \regex_extract_seq_aux:ww #1; #2; +\cs_new:Npn \__regex_extract_seq_aux:ww #1; #2; { - \if_num:w #1 < \c_zero - \flag_raise:n { regex_end } + \if_int_compare:w #1 < \c_zero + \flag_raise:n { __regex_end } \prg_replicate:nn {-#1} { \exp_not:n { { \if_false: } \fi: } } \fi: - \regex_query_submatch:n {#2} - \if_num:w #1 > \c_zero - \flag_raise:n { regex_begin } + \__regex_query_submatch:n {#2} + \if_int_compare:w #1 > \c_zero + \flag_raise:n { __regex_begin } \prg_replicate:nn {#1} { \exp_not:n { \if_false: { \fi: } } } \fi: } -\cs_new_protected_nopar:Npn \regex_extract: +\cs_new_protected_nopar:Npn \__regex_extract: { - \if_meaning:w \c_true_bool \g_regex_success_bool - \int_set_eq:NN \l_regex_zeroth_submatch_int \l_regex_submatch_int - \prg_replicate:nn \l_regex_capturing_group_int + \if_meaning:w \c_true_bool \g__regex_success_bool + \int_set_eq:NN \l__regex_zeroth_submatch_int \l__regex_submatch_int + \prg_replicate:nn \l__regex_capturing_group_int { - \tex_skip:D \l_regex_submatch_int \c_zero sp \scan_stop: - \int_incr:N \l_regex_submatch_int + \tex_skip:D \l__regex_submatch_int \c_zero sp \scan_stop: + \int_incr:N \l__regex_submatch_int } - \prop_map_inline:Nn \l_regex_success_submatches_prop + \prop_map_inline:Nn \l__regex_success_submatches_prop { - \if_num:w ##1 \c_minus_one - \exp_after:wN \regex_extract_aux_e:wn \int_value:w + \if_int_compare:w ##1 \c_minus_one + \exp_after:wN \__regex_extract_e:wn \__int_value:w \else: - \exp_after:wN \regex_extract_aux_b:wn \int_value:w + \exp_after:wN \__regex_extract_b:wn \__int_value:w \fi: - \int_eval:w \l_regex_zeroth_submatch_int + ##1 {##2} + \__int_eval:w \l__regex_zeroth_submatch_int + ##1 {##2} } - \tex_skip:D \l_regex_zeroth_submatch_int - = \tex_the:D \tex_skip:D \l_regex_zeroth_submatch_int - minus \l_regex_start_pos_int sp \scan_stop: + \tex_skip:D \l__regex_zeroth_submatch_int + = \tex_the:D \tex_skip:D \l__regex_zeroth_submatch_int + minus \l__regex_start_pos_int sp \scan_stop: \fi: } -\cs_new_protected:Npn \regex_extract_aux_b:wn #1 < #2 +\cs_new_protected:Npn \__regex_extract_b:wn #1 < #2 { \tex_skip:D #1 = #2 sp plus \etex_gluestretch:D \tex_skip:D #1 \scan_stop: } -\cs_new_protected:Npn \regex_extract_aux_e:wn #1 > #2 +\cs_new_protected:Npn \__regex_extract_e:wn #1 > #2 { \tex_skip:D #1 = 1 \tex_skip:D #1 plus #2 sp \scan_stop: } -\cs_new_protected:Npn \regex_replace_once_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_replace_once:nnN #1#2#3 { \group_begin: - \regex_single_match: + \__regex_single_match: #1 - \regex_replacement:n {#2} - \exp_args:No \regex_match:n { #3 } - \if_meaning:w \c_false_bool \g_regex_success_bool + \__regex_replacement:n {#2} + \exp_args:No \__regex_match:n { #3 } + \if_meaning:w \c_false_bool \g__regex_success_bool \group_end: \else: - \regex_extract: - \int_set:Nn \l_regex_balance_int + \__regex_extract: + \int_set:Nn \l__regex_balance_int { - \regex_replacement_balance_one_match:n - { \l_regex_zeroth_submatch_int } + \__regex_replacement_balance_one_match:n + { \l__regex_zeroth_submatch_int } } - \tl_set:Nx \l_regex_internal_a_tl + \tl_set:Nx \l__regex_internal_a_tl { - \regex_replacement_do_one_match:n { \l_regex_zeroth_submatch_int } - \regex_query_range:nn - { \etex_gluestretch:D \tex_skip:D \l_regex_zeroth_submatch_int } - { \l_regex_max_pos_int } + \__regex_replacement_do_one_match:n { \l__regex_zeroth_submatch_int } + \__regex_query_range:nn + { \etex_gluestretch:D \tex_skip:D \l__regex_zeroth_submatch_int } + { \l__regex_max_pos_int } } - \regex_group_end_replace:N #3 + \__regex_group_end_replace:N #3 \fi: } -\cs_new_protected:Npn \regex_replace_all_aux:nnN #1#2#3 +\cs_new_protected:Npn \__regex_replace_all:nnN #1#2#3 { \group_begin: - \regex_multi_match:n { \regex_extract: } + \__regex_multi_match:n { \__regex_extract: } #1 - \regex_replacement:n {#2} - \exp_args:No \regex_match:n {#3} - \int_set:Nn \l_regex_balance_int + \__regex_replacement:n {#2} + \exp_args:No \__regex_match:n {#3} + \int_set:Nn \l__regex_balance_int { 0 - \prg_stepwise_function:nnnN - { \c_two * \l_regex_max_state_int } - \l_regex_capturing_group_int - { \l_regex_submatch_int - \c_one } - \regex_replacement_balance_one_match:n + \int_step_function:nnnN + { \c_two * \l__regex_max_state_int } + \l__regex_capturing_group_int + { \l__regex_submatch_int - \c_one } + \__regex_replacement_balance_one_match:n } - \tl_set:Nx \l_regex_internal_a_tl + \tl_set:Nx \l__regex_internal_a_tl { - \prg_stepwise_function:nnnN - { \c_two * \l_regex_max_state_int } - \l_regex_capturing_group_int - { \l_regex_submatch_int - \c_one } - \regex_replacement_do_one_match:n - \regex_query_range:nn - \l_regex_start_pos_int \l_regex_max_pos_int + \int_step_function:nnnN + { \c_two * \l__regex_max_state_int } + \l__regex_capturing_group_int + { \l__regex_submatch_int - \c_one } + \__regex_replacement_do_one_match:n + \__regex_query_range:nn + \l__regex_start_pos_int \l__regex_max_pos_int } - \regex_group_end_replace:N #3 + \__regex_group_end_replace:N #3 } -\cs_new_protected_nopar:Npn \regex_group_end_replace:N #1 +\cs_new_protected_nopar:Npn \__regex_group_end_replace:N #1 { - \if_num:w \l_regex_balance_int = \c_zero + \if_int_compare:w \l__regex_balance_int = \c_zero \else: - \msg_kernel_error:nnxxx { regex } { result-unbalanced } + \__msg_kernel_error:nnxxx { regex } { result-unbalanced } { replacing } - { \int_max:nn { - \l_regex_balance_int } { \c_zero } } - { \int_max:nn { \l_regex_balance_int } { \c_zero } } + { \int_max:nn { - \l__regex_balance_int } { \c_zero } } + { \int_max:nn { \l__regex_balance_int } { \c_zero } } \fi: \use:x { \group_end: \tl_set:Nn \exp_not:N #1 { - \if_int_compare:w \l_regex_balance_int < \c_zero - \prg_replicate:nn { - \l_regex_balance_int } + \if_int_compare:w \l__regex_balance_int < \c_zero + \prg_replicate:nn { - \l__regex_balance_int } { { \if_false: } \fi: } \fi: - \l_regex_internal_a_tl - \if_int_compare:w \l_regex_balance_int > \c_zero - \prg_replicate:nn { \l_regex_balance_int } + \l__regex_internal_a_tl + \if_int_compare:w \l__regex_balance_int > \c_zero + \prg_replicate:nn { \l__regex_balance_int } { \if_false: { \fi: } } \fi: } } } -\msg_kernel_new:nnnn { regex } { trailing-backslash } +\__msg_kernel_new:nnnn { regex } { 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. } -\msg_kernel_new:nnnn { regex } { x-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { x-missing-rbrace } { Missing~closing~brace~in~\iow_char:N\\x~hexadecimal~sequence. } { You~wrote~something~like~ `\iow_char:N\\x\{\int_to_hexadecimal:n{#1}'.~ The~closing~brace~is~missing. } -\msg_kernel_new:nnnn { regex } { x-overflow } +\__msg_kernel_new:nnnn { regex } { x-overflow } { Character~code~'#1'~too~large~in~\iow_char:N\\x~hexadecimal~sequence. } { You~wrote~something~like~ `\iow_char:N\\x\{\int_to_hexadecimal:n{#1}\}'.~ The~character~code~'#1'~is~larger~than~\int_use:N \c_max_char_int. } -\msg_kernel_new:nnnn { regex } { invalid-quantifier } +\__msg_kernel_new:nnnn { regex } { invalid-quantifier } { Braced~quantifier~'#1'~may~not~be~followed~by~'#2'. } { The~character~'#2'~is~invalid~in~the~braced~quantifier~'#1'.~ The~only~valid~quantifiers~are~'*',~'?',~'+',~'{<int>}',~ '{<min>,}'~and~'{<min>,<max>}',~followed~or~not~by~'?'. } -\msg_kernel_new:nnnn { regex } { missing-rbrack } +\__msg_kernel_new:nnnn { regex } { missing-rbrack } { Missing~right~bracket~inserted~in~regular~expression. } { LaTeX~was~given~a~regular~expression~where~a~character~class~ was~started~with~'[',~but~the~matching~']'~is~missing. } -\msg_kernel_new:nnnn { regex } { missing-rparen } +\__msg_kernel_new:nnnn { regex } { missing-rparen } { Missing~right~parenthes\int_compare:nTF{#1=1}{i}{e}s~ inserted~in~regular~expression. @@ -2597,44 +2605,44 @@ more~left~parenthes\int_compare:nTF{#1=1}{i}{e}s~than~right~ parenthes\int_compare:nTF{#1=1}{i}{e}s. } -\msg_kernel_new:nnnn { regex } { extra-rparen } +\__msg_kernel_new:nnnn { regex } { extra-rparen } { Extra~right~parenthesis~ignored~in~regular~expression. } { LaTeX~came~across~a~closing~parenthesis~when~no~submatch~group~ was~open.~The~parenthesis~will~be~ignored. } -\msg_kernel_new:nnnn { regex } { bad-escape } +\__msg_kernel_new:nnnn { regex } { bad-escape } { Invalid~escape~\c_backslash_str #1~ - \regex_if_in_cs:TF { within~a~control~sequence. } + \__regex_if_in_cs:TF { within~a~control~sequence. } { - \regex_if_in_class:TF + \__regex_if_in_class:TF { in~a~character~class. } { following~a~category~test. } } } { The~escape~sequence~\iow_char:N\\#1~may~not~appear~ - \regex_if_in_cs:TF + \__regex_if_in_cs:TF { within~a~control~sequence~test~introduced~by~ \iow_char:N\\c\iow_char:N\{. } { - \regex_if_in_class:TF + \__regex_if_in_class:TF { within~a~character~class~ } { following~a~category~test~such~as~\iow_char:N\\cL~ } because~it~does~not~match~exactly~one~character. } } -\msg_kernel_new:nnnn { regex } { range-missing-end } +\__msg_kernel_new:nnnn { regex } { range-missing-end } { Invalid~end-point~for~range~'#1-#2'~in~character~class. } { The~end-point~'#2'~of~the~range~'#1-#2'~may~not~serve~as~an~ end-point~for~a~range:~alphanumeric~characters~should~not~be~ escaped,~and~non-alphanumeric~characters~should~be~escaped. } -\msg_kernel_new:nnnn { regex } { range-backwards } +\__msg_kernel_new:nnnn { regex } { range-backwards } { Range~[#1-#2]~out~of~order~in~character~class. } { In~ranges~of~characters~[x-y]~appearing~in~character~classes,~ @@ -2642,27 +2650,27 @@ Here,~#1~has~character~code~\int_eval:n {`#1},~while~#2~has~ character~code~\int_eval:n {`#2}. } -\msg_kernel_new:nnnn { regex } { c-bad-mode } +\__msg_kernel_new:nnnn { regex } { c-bad-mode } { Invalid~nested~\iow_char:N\\c~escape~in~regular~expression. } { The~\iow_char:N\\c~escape~cannot~be~used~within~ a~control~sequence~test~'\iow_char:N\\c{...}'.~ To~combine~several~category~tests,~use~'\iow_char:N\\c[...]'. } -\msg_kernel_new:nnnn { regex } { c-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { c-missing-rbrace } { Missing~right~brace~inserted~for~\iow_char:N\\c~escape. } { LaTeX~was~given~a~regular~expression~where~a~ '\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ with~a~closing~brace~'\iow_char:N\}'. } -\msg_kernel_new:nnnn { regex } { c-missing-rbrack } +\__msg_kernel_new:nnnn { regex } { c-missing-rbrack } { Missing~right~bracket~inserted~for~\iow_char:N\\c~escape. } { A~construction~'\iow_char:N\\c[...'~appears~in~a~ regular~expression,~but~the~closing~']'~is~not~present. } -\msg_kernel_new:nnnn { regex } { c-missing-category } +\__msg_kernel_new:nnnn { regex } { c-missing-category } { Invalid~character~'#1'~following~\iow_char:N\\c~escape. } { In~regular~expressions,~the~\iow_char:N\\c~escape~sequence~ @@ -2670,29 +2678,29 @@ capital~letter~representing~a~character~category,~namely~ one~of~ABCDELMOPSTU. } -\msg_kernel_new:nnnn { regex } { u-missing-lbrace } +\__msg_kernel_new:nnnn { regex } { u-missing-lbrace } { Missing~left~brace~following~\iow_char:N\\u~escape. } { The~\iow_char:N\\u~escape~sequence~must~be~followed~by~ a~brace~group~with~the~name~of~the~variable~to~use. } -\msg_kernel_new:nnnn { regex } { u-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { u-missing-rbrace } { Missing~right~brace~inserted~for~\iow_char:N\\u~escape. } { LaTeX~ - \tl_if_empty:xTF {#2} + \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. } -\msg_kernel_new:nnnn { regex } { posix-unsupported } +\__msg_kernel_new:nnnn { regex } { posix-unsupported } { POSIX~collating~element~'[#1 ~ #1]'~not~supported. } { The~[.foo.]~and~[=bar=]~syntaxes~have~a~special~meaning~in~POSIX~ regular~expressions.~This~is~not~supported~by~LaTeX.~Maybe~you~ forgot~to~escape~a~left~bracket~in~a~character~class? } -\msg_kernel_new:nnnn { regex } { posix-unknown } +\__msg_kernel_new:nnnn { regex } { posix-unknown } { POSIX~class~[:#1:]~unknown. } { [:#1:]~is~not~among~the~known~POSIX~classes~ @@ -2701,10 +2709,10 @@ [:print:],~[:punct:],~[:space:],~[:upper:],~ [:word:],~and~[:xdigit:]. } -\msg_kernel_new:nnnn { regex } { posix-missing-close } +\__msg_kernel_new:nnnn { regex } { posix-missing-close } { Missing~closing~':]'~for~POSIX~class. } { The~POSIX~syntax~'#1'~must~be~followed~by~':]',~not~'#2'. } -\msg_kernel_new:nnnn { regex } { result-unbalanced } +\__msg_kernel_new:nnnn { regex } { result-unbalanced } { Missing~brace~inserted~when~#1. } { LaTeX~was~asked~to~do~some~regular~expression~operation,~ @@ -2712,34 +2720,34 @@ of~begin-group~and~end-group~tokens.~Braces~were~inserted:~ #2~left,~#3~right. } -\msg_kernel_new:nnnn { regex } { unknown-option } +\__msg_kernel_new:nnnn { regex } { unknown-option } { Unknown~option~`#1'~for~regular~expressions. } { The~only~available~option~is~'case-insensitive',~toggled~by~ '(?i)'~and~'(?-i)'. } -\msg_kernel_new:nnnn { regex } { replacement-c } +\__msg_kernel_new:nnnn { regex } { replacement-c } { Misused~\iow_char:N\\c~command~in~a~replacement~text. } { In~a~replacement~text,~the~\iow_char:N\\c~escape~sequence~ can~be~followed~by~one~of~the~letters~ABCDELMOPSTU~ or~a~brace~group,~not~by~'#1'. } -\msg_kernel_new:nnnn { regex } { replacement-u } +\__msg_kernel_new:nnnn { regex } { replacement-u } { Misused~\iow_char:N\\u~command~in~a~replacement~text. } { In~a~replacement~text,~the~\iow_char:N\\u~escape~sequence~ must~be~~followed~by~a~brace~group~holding~the~name~of~the~ variable~to~use. } -\msg_kernel_new:nnnn { regex } { replacement-g } +\__msg_kernel_new:nnnn { regex } { replacement-g } { Missing~brace~for~the~\iow_char:N\\g~construction~in~a~replacement~text. } { In~the~replacement~text~for~a~regular~expression~search,~ submatches~are~represented~either~as~\iow_char:N \\g{dd..d},~ or~\\d,~where~`d'~are~single~digits.~Here,~a~brace~is~missing. } -\msg_kernel_new:nnnn { regex } { replacement-catcode-end } +\__msg_kernel_new:nnnn { regex } { replacement-catcode-end } { Missing~character~for~the~\iow_char:N\\c<category><character>~ construction~in~a~replacement~text. @@ -2750,7 +2758,7 @@ the~character~category.~Then,~a~character~must~follow.~LaTeX~ reached~the~end~of~the~replacement~when~looking~for~that. } -\msg_kernel_new:nnnn { regex } { replacement-null-space } +\__msg_kernel_new:nnnn { regex } { replacement-null-space } { TeX~cannot~build~a~space~token~with~character~code~0. } { You~asked~for~a~character~token~with~category~'space',~ @@ -2759,18 +2767,18 @@ This~specific~case~is~impossible~and~will~be~replaced~ by~a~normal~space. } -\msg_kernel_new:nnnn { regex } { replacement-missing-rbrace } +\__msg_kernel_new:nnnn { regex } { replacement-missing-rbrace } { Missing~right~brace~inserted~in~replacement~text. } { - There~were~\int_use:N \l_regex_replacement_csnames_int \ + There~were~\int_use:N \l__regex_replacement_csnames_int \ missing~right~braces. } -\cs_new:Npn \regex_msg_repeated:nnN #1#2#3 +\cs_new:Npn \__regex_msg_repeated:nnN #1#2#3 { - \str_if_eq:xxF { #1 #2 } { 1 0 } + \str_if_eq_x:nnF { #1 #2 } { 1 0 } { , ~ repeated ~ - \prg_case_int:nnn {#2} + \int_case:nnn {#2} { { -1 } { #1~or~more~times,~\bool_if:NTF #3 { lazy } { greedy } } { 0 } { #1~times } diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str.sty index 88042a5337d..3ad97283e3b 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str.sty @@ -46,8 +46,8 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{expl3} -\GetIdInfo$Id: l3str.dtx 3460 2012-02-26 12:16:41Z will $ - {L3 Experimental Strings} +\GetIdInfo$Id: l3str.dtx 3940 2012-07-09 00:41:44Z bruno $ + {L3 Experimental strings} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{l3tl-analysis,l3tl-build,l3flag} @@ -70,10 +70,10 @@ { \exp_not:c { tl_ #1 :Nx } ##1 { \exp_not:N \tl_to_str:n {##2} } } \exp_args:Nc \cs_generate_variant:Nn { str_ #1 :Nn } { Nx , cn , cx } } -\cs_new_protected_nopar:Npn \str_tmp:w { } -\tl_new:N \l_str_internal_tl -\int_new:N \l_str_internal_int -\tl_new:N \g_str_result_tl +\cs_new_protected_nopar:Npn \__str_tmp:w { } +\tl_new:N \l__str_internal_tl +\int_new:N \l__str_internal_int +\tl_new:N \g__str_result_tl \int_const:Nn \c_forty_eight { 48 } \int_const:Nn \c_fifty_eight { 58 } \int_const:Nn \c_sixty_five { 65 } @@ -83,30 +83,30 @@ \int_const:Nn \c_one_hundred_twenty_seven { 127 } \int_const:Nn \c_max_char_int { \pdftex_if_engine:TF { "FF } { "10FFFF } } -\int_const:Nn \c_str_replacement_char_int { "FFFD } +\int_const:Nn \c__str_replacement_char_int { "FFFD } \tl_const:Nx \c_backslash_str { \cs_to_str:N \\ } \tl_const:Nx \c_lbrace_str { \cs_to_str:N \{ } \tl_const:Nx \c_rbrace_str { \cs_to_str:N \} } \tl_const:Nx \c_hash_str { \cs_to_str:N \# } \tl_const:Nx \c_tilde_str { \cs_to_str:N \~ } \tl_const:Nx \c_percent_str { \cs_to_str:N \% } -\prop_new:N \g_str_file_prop -\prop_gput:Nnn \g_str_file_prop { latin1 } { iso88591 } -\prop_gput:Nnn \g_str_file_prop { latin2 } { iso88592 } -\prop_gput:Nnn \g_str_file_prop { latin3 } { iso88593 } -\prop_gput:Nnn \g_str_file_prop { latin4 } { iso88594 } -\prop_gput:Nnn \g_str_file_prop { latin5 } { iso88599 } -\prop_gput:Nnn \g_str_file_prop { latin6 } { iso885910 } -\prop_gput:Nnn \g_str_file_prop { latin7 } { iso885913 } -\prop_gput:Nnn \g_str_file_prop { latin8 } { iso885914 } -\prop_gput:Nnn \g_str_file_prop { latin9 } { iso885915 } -\prop_gput:Nnn \g_str_file_prop { latin10 } { iso885916 } -\prop_gput:Nnn \g_str_file_prop { utf16le } { utf16 } -\prop_gput:Nnn \g_str_file_prop { utf16be } { utf16 } -\prop_gput:Nnn \g_str_file_prop { utf32le } { utf32 } -\prop_gput:Nnn \g_str_file_prop { utf32be } { utf32 } -\prop_gput:Nnn \g_str_file_prop { hexadecimal } { hex } -\bool_new:N \g_str_error_bool +\prop_new:N \g__str_alias_prop +\prop_gput:Nnn \g__str_alias_prop { latin1 } { iso88591 } +\prop_gput:Nnn \g__str_alias_prop { latin2 } { iso88592 } +\prop_gput:Nnn \g__str_alias_prop { latin3 } { iso88593 } +\prop_gput:Nnn \g__str_alias_prop { latin4 } { iso88594 } +\prop_gput:Nnn \g__str_alias_prop { latin5 } { iso88599 } +\prop_gput:Nnn \g__str_alias_prop { latin6 } { iso885910 } +\prop_gput:Nnn \g__str_alias_prop { latin7 } { iso885913 } +\prop_gput:Nnn \g__str_alias_prop { latin8 } { iso885914 } +\prop_gput:Nnn \g__str_alias_prop { latin9 } { iso885915 } +\prop_gput:Nnn \g__str_alias_prop { latin10 } { iso885916 } +\prop_gput:Nnn \g__str_alias_prop { utf16le } { utf16 } +\prop_gput:Nnn \g__str_alias_prop { utf16be } { utf16 } +\prop_gput:Nnn \g__str_alias_prop { utf32le } { utf32 } +\prop_gput:Nnn \g__str_alias_prop { utf32be } { utf32 } +\prop_gput:Nnn \g__str_alias_prop { hexadecimal } { hex } +\bool_new:N \g__str_error_bool \flag_new:n { str_byte } \flag_new:n { str_error } \group_begin: @@ -115,21 +115,21 @@ \tl_to_lowercase:n { \group_end: - \cs_new:Npn \tl_to_other_str:n #1 + \cs_new:Npn \__str_to_other:n #1 { - \exp_after:wN \tl_to_other_str_loop:w \tl_to_str:n {#1} ~ % + \exp_after:wN \__str_to_other_loop:w \tl_to_str:n {#1} ~ % A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ \q_mark \q_stop } - \cs_new:Npn \tl_to_other_str_loop:w + \cs_new:Npn \__str_to_other_loop:w #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 ~ #7 ~ #8 ~ #9 \q_stop { \if_meaning:w A #8 - \tl_to_other_str_end:w + \__str_to_other_end:w \fi: - \tl_to_other_str_loop:w + \__str_to_other_loop:w #9 #1 * #2 * #3 * #4 * #5 * #6 * #7 * #8 * \q_stop } - \cs_new:Npn \tl_to_other_str_end:w \fi: #1 \q_mark #2 * A #3 \q_stop + \cs_new:Npn \__str_to_other_end:w \fi: #1 \q_mark #2 * A #3 \q_stop { \fi: #2 } } \group_begin: @@ -138,24 +138,24 @@ \tl_to_lowercase:n { \group_end: - \cs_new_protected:Npn \str_gset_other:Nn #1#2 + \cs_new_protected:Npn \__str_gset_other:Nn #1#2 { \tl_gset:Nx #1 { - \exp_after:wN \str_gset_other_loop:w \tl_to_str:n {#2} ~ % + \exp_after:wN \__str_gset_other_loop:w \tl_to_str:n {#2} ~ % A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ \q_stop } } - \cs_new:Npn \str_gset_other_loop:w + \cs_new:Npn \__str_gset_other_loop:w #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 ~ #7 ~ #8 ~ #9 ~ { \if_meaning:w A #9 - \str_gset_other_end:w + \__str_gset_other_end:w \fi: #1 * #2 * #3 * #4 * #5 * #6 * #7 * #8 * #9 - \str_gset_other_loop:w * + \__str_gset_other_loop:w * } - \cs_new:Npn \str_gset_other_end:w \fi: #1 * A #2 \q_stop + \cs_new:Npn \__str_gset_other_end:w \fi: #1 * A #2 \q_stop { \fi: #1 } } \cs_new:Npn \str_count_spaces:N @@ -164,39 +164,39 @@ { \int_eval:n { - \exp_after:wN \str_count_spaces_loop:wwwwwwwww + \exp_after:wN \__str_count_spaces_loop:wwwwwwwww \tl_to_str:n {#1} ~ X 7 ~ X 6 ~ X 5 ~ X 4 ~ X 3 ~ X 2 ~ X 1 ~ X 0 ~ X -1 ~ \q_stop } } -\cs_new:Npn \str_count_spaces_loop:wwwwwwwww #1~#2~#3~#4~#5~#6~#7~#8~#9~ +\cs_new:Npn \__str_count_spaces_loop:wwwwwwwww #1~#2~#3~#4~#5~#6~#7~#8~#9~ { \if_meaning:w X #9 \exp_after:wN \use_none_delimit_by_q_stop:w \fi: - \c_nine + \str_count_spaces_loop:wwwwwwwww + \c_nine + \__str_count_spaces_loop:wwwwwwwww } -\cs_new_nopar:Npn \str_length:N { \exp_args:No \str_length:n } -\cs_new:Npn \str_length:n #1 +\cs_new_nopar:Npn \str_count:N { \exp_args:No \str_count:n } +\cs_new:Npn \str_count:n #1 { - \str_length_aux:n + \__str_count:n { \str_count_spaces:n {#1} - + \exp_after:wN \str_length_loop:NNNNNNNNN \tl_to_str:n {#1} + + \exp_after:wN \__str_count_loop:NNNNNNNNN \tl_to_str:n {#1} } } -\cs_new:Npn \str_length_unsafe:n #1 +\cs_new:Npn \__str_count_unsafe:n #1 { - \str_length_aux:n - { \str_length_loop:NNNNNNNNN #1 } + \__str_count:n + { \__str_count_loop:NNNNNNNNN #1 } } -\cs_new:Npn \str_length_ignore_spaces:n #1 +\cs_new:Npn \str_count_ignore_spaces:n #1 { - \str_length_aux:n - { \exp_after:wN \str_length_loop:NNNNNNNNN \tl_to_str:n {#1} } + \__str_count:n + { \exp_after:wN \__str_count_loop:NNNNNNNNN \tl_to_str:n {#1} } } -\cs_new:Npn \str_length_aux:n #1 +\cs_new:Npn \__str_count:n #1 { \int_eval:n { @@ -207,21 +207,21 @@ \q_stop } } -\cs_set:Npn \str_length_loop:NNNNNNNNN #1#2#3#4#5#6#7#8#9 +\cs_set:Npn \__str_count_loop:NNNNNNNNN #1#2#3#4#5#6#7#8#9 { \if_meaning:w X #9 \exp_after:wN \use_none_delimit_by_q_stop:w \fi: - \c_nine + \str_length_loop:NNNNNNNNN + \c_nine + \__str_count_loop:NNNNNNNNN } \cs_new_nopar:Npn \str_head:N { \exp_args:No \str_head:n } \cs_set:Npn \str_head:n #1 { - \exp_after:wN \str_head_aux:w + \exp_after:wN \__str_head:w \tl_to_str:n {#1} { { } } ~ \q_stop } -\cs_set:Npn \str_head_aux:w #1 ~ % +\cs_set:Npn \__str_head:w #1 ~ % { \use_i_delimit_by_q_stop:nw #1 { ~ } } \cs_new:Npn \str_head_ignore_spaces:n #1 { @@ -231,82 +231,85 @@ \cs_new_nopar:Npn \str_tail:N { \exp_args:No \str_tail:n } \cs_set:Npn \str_tail:n #1 { - \exp_after:wN \str_tail_aux:w + \exp_after:wN \__str_tail:w \reverse_if:N \if_charcode:w \scan_stop: \tl_to_str:n {#1} X X \q_stop } -\cs_set:Npn \str_tail_aux:w #1 X #2 \q_stop { \fi: #1 } +\cs_set:Npn \__str_tail:w #1 X #2 \q_stop { \fi: #1 } \cs_new:Npn \str_tail_ignore_spaces:n #1 { - \exp_after:wN \str_tail_aux_ii:w + \exp_after:wN \__str_tail_ii:w \tl_to_str:n {#1} X X \q_stop } -\cs_new:Npn \str_tail_aux_ii:w #1 #2 X #3 \q_stop { #2 } -\cs_new:Npn \str_skip_c_zero:w #1; +\cs_new:Npn \__str_tail_ii:w #1 #2 X #3 \q_stop { #2 } +\cs_new:Npn \__str_skip_c_zero:w #1; { - \if_num:w \int_eval:w #1 > \c_eight - \exp_after:wN \str_skip_aux:wNNNNNNNN + \if_int_compare:w \__int_eval:w #1 > \c_eight + \exp_after:wN \__str_skip_loop:wNNNNNNNN \else: - \exp_after:wN \str_skip_end:w - \int_use:N \int_eval:w + \exp_after:wN \__str_skip_end:w + \int_use:N \__int_eval:w \fi: #1 ; } -\cs_new:Npn \str_skip_aux:wNNNNNNNN #1; #2#3#4#5#6#7#8#9 - { \exp_after:wN \str_skip_c_zero:w \int_use:N \int_eval:w #1 - \c_eight ; } -\cs_new:Npn \str_skip_end:w #1 ; +\cs_new:Npn \__str_skip_loop:wNNNNNNNN #1; #2#3#4#5#6#7#8#9 + { \exp_after:wN \__str_skip_c_zero:w \int_use:N \__int_eval:w #1 - \c_eight ; } +\cs_new:Npn \__str_skip_end:w #1 ; { - \exp_after:wN \str_skip_end_ii:NNNNNNNN - \if_case:w \if_num:w #1 > \c_zero #1 \else: 0 \fi: \exp_stop_f: + \exp_after:wN \__str_skip_end_ii:NNNNNNNN + \if_case:w \if_int_compare:w #1 > \c_zero #1 \else: 0 \fi: \exp_stop_f: \or: \or: \or: \or: \or: \or: \or: \or: } -\cs_new:Npn \str_skip_end_ii:NNNNNNNN #1#2#3#4#5#6#7#8 { \fi: \c_zero } -\cs_new:Npn \str_collect_delimit_by_q_stop:w #1; +\cs_new:Npn \__str_skip_end_ii:NNNNNNNN #1#2#3#4#5#6#7#8 { \fi: \c_zero } +\cs_new:Npn \__str_collect_delimit_by_q_stop:w #1; { - \exp_after:wN \str_collect_aux:wn - \int_use:N \int_eval:w #1 ; + \exp_after:wN \__str_collect_loop:wn + \int_use:N \__int_eval:w #1 ; { } } -\cs_new:Npn \str_collect_aux:wn #1 ; +\cs_new:Npn \__str_collect_loop:wn #1 ; { - \if_num:w #1 > \c_seven - \exp_after:wN \str_collect_aux:wnNNNNNNN + \if_int_compare:w #1 > \c_seven + \exp_after:wN \__str_collect_loop_ii:wnNNNNNNN \else: - \exp_after:wN \str_collect_end:wn + \exp_after:wN \__str_collect_end:wn \fi: #1 ; } -\cs_new:Npn \str_collect_aux:wnNNNNNNN #1; #2 #3#4#5#6#7#8#9 +\cs_new:Npn \__str_collect_loop_ii:wnNNNNNNN #1; #2 #3#4#5#6#7#8#9 { - \exp_after:wN \str_collect_aux:wn - \int_use:N \int_eval:w #1 - \c_seven ; + \exp_after:wN \__str_collect_loop:wn + \int_use:N \__int_eval:w #1 - \c_seven ; { #2 #3#4#5#6#7#8#9 } } -\cs_new:Npn \str_collect_end:wn #1 ; +\cs_new:Npn \__str_collect_end:wn #1 ; { - \exp_after:wN \str_collect_end_ii:nnnnnnnnw - \if_case:w \if_num:w #1 > \c_zero #1 \else: 0 \fi: \exp_stop_f: + \exp_after:wN \__str_collect_end_ii:nnnnnnnnw + \if_case:w \if_int_compare:w #1 > \c_zero #1 \else: 0 \fi: \exp_stop_f: \or: \or: \or: \or: \or: \or: \fi: } -\cs_new:Npn \str_collect_end_ii:nnnnnnnnw #1#2#3#4#5#6#7#8 #9 \q_stop +\cs_new:Npn \__str_collect_end_ii:nnnnnnnnw #1#2#3#4#5#6#7#8 #9 \q_stop { #1#2#3#4#5#6#7#8 } \cs_new_nopar:Npn \str_item:Nn { \exp_args:No \str_item:nn } -\cs_new:Npn \str_item:nn #1 +\cs_new:Npn \str_item:nn #1#2 { - \exp_last_unbraced:Nf \token_to_str:N - \exp_args:Nf \str_item_unsafe:nn { \tl_to_other_str:n {#1} } + \exp_args:Nf \tl_to_str:n + { + \exp_args:Nf \__str_item_unsafe:nn + { \__str_to_other:n {#1} } {#2} + } } \cs_new:Npn \str_item_ignore_spaces:nn #1 - { \exp_args:No \str_item_unsafe:nn { \tl_to_str:n {#1} } } -\cs_new:Npn \str_item_unsafe:nn #1#2 + { \exp_args:No \__str_item_unsafe:nn { \tl_to_str:n {#1} } } +\cs_new:Npn \__str_item_unsafe:nn #1#2 { - \exp_after:wN \str_item_aux:ww - \int_use:N \int_eval:w #2 \exp_after:wN ; - \int_value:w \str_length_unsafe:n {#1} ; - #1 + \exp_after:wN \__str_item:ww + \int_use:N \__int_eval:w #2 \exp_after:wN ; + \__int_value:w \__str_count_unsafe:n {#1} ; + { } #1 \q_stop } -\cs_new:Npn \str_item_aux:ww #1; #2; +\cs_new:Npn \__str_item:ww #1; #2; { \int_compare:nNnTF {#1} < \c_zero { @@ -314,16 +317,16 @@ { \use_none_delimit_by_q_stop:w } { \exp_after:wN \use_i_delimit_by_q_stop:nw - \tex_romannumeral:D \str_skip_c_zero:w #1 + #2 ; + \tex_romannumeral:D \__str_skip_c_zero:w #1 + #2 + \c_one ; } } { - \int_compare:nNnTF {#1} < {#2} + \int_compare:nNnTF {#1} > {#2} + { \use_none_delimit_by_q_stop:w } { \exp_after:wN \use_i_delimit_by_q_stop:nw - \tex_romannumeral:D \str_skip_c_zero:w #1 ; + \tex_romannumeral:D \__str_skip_c_zero:w #1 ; } - { \use_none_delimit_by_q_stop:w } } } \cs_new_nopar:Npn \str_substr:Nnn { \exp_args:No \str_substr:nnn } @@ -331,51 +334,51 @@ { \exp_args:Nf \tl_to_str:n { - \exp_args:Nf \str_substr_unsafe:nnn - { \tl_to_other_str:n {#1} } {#2} {#3} + \exp_args:Nf \__str_substr_unsafe:nnn + { \__str_to_other:n {#1} } {#2} {#3} } } \cs_new:Npn \str_substr_ignore_spaces:nnn #1 - { \exp_args:No \str_substr_unsafe:nnn { \tl_to_str:n {#1} } } -\cs_new:Npn \str_substr_unsafe:nnn #1#2#3 - { - \exp_after:wN \str_substr_aux:www - \int_value:w \str_length_unsafe:n {#1} \exp_after:wN ; - \int_use:N \int_eval:w #2 + \c_zero \exp_after:wN ; - \int_use:N \int_eval:w - \exp_args:Nf \str_substr_aux:nN {#3} \c_max_int ; - #1 + { \exp_args:No \__str_substr_unsafe:nnn { \tl_to_str:n {#1} } } +\cs_new:Npn \__str_substr_unsafe:nnn #1#2#3 + { + \exp_after:wN \__str_substr_ii:www + \__int_value:w \__str_count_unsafe:n {#1} \exp_after:wN ; + \int_use:N \__int_eval:w #2 + \c_zero \exp_after:wN ; + \int_use:N \__int_eval:w + \exp_args:Nf \__str_substr_i:nN {#3} \c_max_int ; + { } #1 \q_stop } -\cs_new:Npn \str_substr_aux:nN #1 #2 +\cs_new:Npn \__str_substr_i:nN #1 #2 { \tl_if_empty:nTF {#1} {#2} {#1} } -\cs_new:Npn \str_substr_aux:www #1; #2; #3; +\cs_new:Npn \__str_substr_ii:www #1; #2; #3; { - \exp_args:Nf \str_substr_aux:nnw - { \str_substr_normalize_range:nn {#2} {#1} } - { \str_substr_normalize_range:nn {#3} {#1} } + \exp_args:Nf \__str_substr_iii:nnw + { \__str_substr_normalize_range:nn {#2} {#1} } + { \__str_substr_normalize_range:nn {#3} {#1} } } -\cs_new:Npn \str_substr_aux:nnw #1#2 +\cs_new:Npn \__str_substr_iii:nnw #1#2 { - \exp_after:wN \str_collect_delimit_by_q_stop:w - \int_use:N \int_eval:w #2 - #1 \exp_after:wN ; - \tex_romannumeral:D \str_skip_c_zero:w #1 ; + \exp_after:wN \__str_collect_delimit_by_q_stop:w + \int_use:N \__int_eval:w #2 + \c_one - #1 \exp_after:wN ; + \tex_romannumeral:D \__str_skip_c_zero:w #1 ; } -\cs_new:Npn \str_substr_normalize_range:nn #1#2 +\cs_new:Npn \__str_substr_normalize_range:nn #1#2 { \int_eval:n { - \if_num:w #1 < \c_zero - \if_num:w #1 < - #2 \exp_stop_f: + \if_int_compare:w #1 < \c_zero + \if_int_compare:w #1 < - #2 \exp_stop_f: \c_zero \else: - #1 + #2 + #1 + #2 + \c_one \fi: \else: - \if_num:w #1 < #2 \exp_stop_f: - #1 - \else: + \if_int_compare:w #1 > #2 \exp_stop_f: #2 + \else: + #1 \fi: \fi: } @@ -385,45 +388,45 @@ \if_int_compare:w \pdftex_strcmp:D { \tl_to_str:N #1 } { \tl_to_str:N #2 } = \c_zero \prg_return_true: \else: \prg_return_false: \fi: } -\prg_new_conditional:Npnn \str_if_contains_char:NN #1#2 { T , TF } +\prg_new_conditional:Npnn \__str_if_contains_char:NN #1#2 { T , TF } { - \exp_after:wN \str_if_contains_char_aux:NN \exp_after:wN #2 - \tl_to_str:n \exp_after:wN {#1} { \prg_map_break:n { ? \fi: } } - \prg_break_point:n { } + \exp_after:wN \__str_if_contains_char_aux:NN \exp_after:wN #2 + \etex_detokenize:D \exp_after:wN {#1} { \__prg_break:n { ? \fi: } } + \__prg_break_point: \prg_return_false: } -\prg_new_conditional:Npnn \str_if_contains_char:nN #1#2 { TF } +\prg_new_conditional:Npnn \__str_if_contains_char:nN #1#2 { TF } { - \exp_after:wN \str_if_contains_char_aux:NN \exp_after:wN #2 - \tl_to_str:n {#1} { \prg_map_break:n { ? \fi: } } - \prg_break_point:n { } + \exp_after:wN \__str_if_contains_char_aux:NN \exp_after:wN #2 + \tl_to_str:n {#1} { \__prg_break:n { ? \fi: } } + \__prg_break_point: \prg_return_false: } -\cs_new:Npn \str_if_contains_char_aux:NN #1#2 +\cs_new:Npn \__str_if_contains_char_aux:NN #1#2 { \if_charcode:w #1 #2 - \exp_after:wN \str_if_contains_char_true: + \exp_after:wN \__str_if_contains_char_true: \fi: - \str_if_contains_char_aux:NN #1 + \__str_if_contains_char_aux:NN #1 } -\cs_new_nopar:Npn \str_if_contains_char_true: - { \prg_map_break:n { \prg_return_true: \use_none:n } } -\prg_new_conditional:Npnn \str_aux_octal_use:N #1 { TF } +\cs_new_nopar:Npn \__str_if_contains_char_true: + { \__prg_break:n { \prg_return_true: \use_none:n } } +\prg_new_conditional:Npnn \__str_octal_use:N #1 { TF } { - \if_num:w \c_one < '1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w \c_one < '1 \token_to_str:N #1 \exp_stop_f: #1 \prg_return_true: \else: \prg_return_false: \fi: } -\prg_new_conditional:Npnn \str_aux_hexadecimal_use:N #1 { TF } +\prg_new_conditional:Npnn \__str_hexadecimal_use:N #1 { TF } { - \if_num:w \c_two < "1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w \c_two < "1 \token_to_str:N #1 \exp_stop_f: #1 \prg_return_true: \else: - \if_case:w \int_eval:w + \if_case:w \__int_eval:w \exp_after:wN ` \token_to_str:N #1 - `a - \int_eval_end: + \__int_eval_end: A \or: B \or: C @@ -442,223 +445,223 @@ \cs_generate_variant:Nn \str_show:N { c } \group_begin: \char_set_catcode_other:n { \c_zero } - \tl_set:Nx \l_str_internal_tl { \tl_to_str:n { 0123456789ABCDEF } } - \exp_args:No \tl_map_inline:nn { \l_str_internal_tl " } + \tl_set:Nx \l__str_internal_tl { \tl_to_str:n { 0123456789ABCDEF } } + \exp_args:No \tl_map_inline:nn { \l__str_internal_tl " } { \char_set_lccode:nn {`#1} { \c_zero } } - \tl_map_inline:Nn \l_str_internal_tl + \tl_map_inline:Nn \l__str_internal_tl { - \tl_map_inline:Nn \l_str_internal_tl + \tl_map_inline:Nn \l__str_internal_tl { \char_set_lccode:nn { \c_zero } {"#1##1} \tl_to_lowercase:n { \tl_const:cx - { c_str_byte_ \int_eval:n {"#1##1} _tl } + { c__str_byte_ \int_eval:n {"#1##1} _tl } { ^^@ #1 ##1 } } } } \group_end: -\tl_const:cn { c_str_byte_-1_tl } { { } \use_none:n { } } -\cs_new:Npn \str_output_byte:n #1 - { \str_output_byte:w #1 \str_output_end: } -\cs_new_nopar:Npn \str_output_byte:w +\tl_const:cn { c__str_byte_-1_tl } { { } \use_none:n { } } +\cs_new:Npn \__str_output_byte:n #1 + { \__str_output_byte:w #1 \__str_output_end: } +\cs_new_nopar:Npn \__str_output_byte:w { \exp_after:wN \exp_after:wN \exp_after:wN \use_i:nnn - \cs:w c_str_byte_ \int_use:N \int_eval:w + \cs:w c__str_byte_ \int_use:N \__int_eval:w } -\cs_new:Npn \str_output_hexadecimal:n #1 - { \str_output_hexadecimal:w #1 \str_output_end: } -\cs_new_nopar:Npn \str_output_hexadecimal:w +\cs_new:Npn \__str_output_hexadecimal:n #1 + { \__str_output_hexadecimal:w #1 \__str_output_end: } +\cs_new_nopar:Npn \__str_output_hexadecimal:w { \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n - \cs:w c_str_byte_ \int_use:N \int_eval:w + \cs:w c__str_byte_ \int_use:N \__int_eval:w } -\cs_new_nopar:Npn \str_output_end: - { \int_eval_end: _tl \cs_end: } -\cs_new:Npn \str_output_byte_pair_be:n #1 +\cs_new_nopar:Npn \__str_output_end: + { \__int_eval_end: _tl \cs_end: } +\cs_new:Npn \__str_output_byte_pair_be:n #1 { - \exp_args:Nf \str_output_byte_pair_aux:nnN + \exp_args:Nf \__str_output_byte_pair:nnN { \int_div_truncate:nn { #1 } { "100 } } {#1} \use:nn } -\cs_new:Npn \str_output_byte_pair_le:n #1 +\cs_new:Npn \__str_output_byte_pair_le:n #1 { - \exp_args:Nf \str_output_byte_pair_aux:nnN + \exp_args:Nf \__str_output_byte_pair:nnN { \int_div_truncate:nn { #1 } { "100 } } {#1} \use_ii_i:nn } -\cs_new:Npn \str_output_byte_pair_aux:nnN #1#2#3 +\cs_new:Npn \__str_output_byte_pair:nnN #1#2#3 { #3 - { \str_output_byte:n { #1 } } - { \str_output_byte:n { #2 - #1 * "100 } } + { \__str_output_byte:n { #1 } } + { \__str_output_byte:n { #2 - #1 * "100 } } } -\cs_new_protected:Npn \str_convert_gmap:N #1 +\cs_new_protected:Npn \__str_convert_gmap:N #1 { - \tl_gset:Nx \g_str_result_tl + \tl_gset:Nx \g__str_result_tl { - \exp_after:wN \str_convert_gmap_loop:NN + \exp_after:wN \__str_convert_gmap_loop:NN \exp_after:wN #1 - \g_str_result_tl { ? \prg_map_break: } - \prg_break_point:n { } + \g__str_result_tl { ? \__prg_break: } + \__prg_break_point: } } -\cs_new:Npn \str_convert_gmap_loop:NN #1#2 +\cs_new:Npn \__str_convert_gmap_loop:NN #1#2 { \use_none:n #2 #1#2 - \str_convert_gmap_loop:NN #1 + \__str_convert_gmap_loop:NN #1 } -\cs_new_protected:Npn \str_convert_gmap_internal:N #1 +\cs_new_protected:Npn \__str_convert_gmap_internal:N #1 { - \tl_gset:Nx \g_str_result_tl + \tl_gset:Nx \g__str_result_tl { - \exp_after:wN \str_convert_gmap_internal_loop:Nww + \exp_after:wN \__str_convert_gmap_internal_loop:Nww \exp_after:wN #1 - \g_str_result_tl \s_tl \q_stop \prg_map_break: \s_tl - \prg_break_point:n { } + \g__str_result_tl \s__tl \q_stop \__prg_break: \s__tl + \__prg_break_point: } } -\cs_new:Npn \str_convert_gmap_internal_loop:Nww #1 #2 \s_tl #3 \s_tl +\cs_new:Npn \__str_convert_gmap_internal_loop:Nww #1 #2 \s__tl #3 \s__tl { \use_none_delimit_by_q_stop:w #3 \q_stop #1 {#3} - \str_convert_gmap_internal_loop:Nww #1 + \__str_convert_gmap_internal_loop:Nww #1 } -\cs_new_protected:Npn \str_if_flag_error:nnx #1 +\cs_new_protected:Npn \__str_if_flag_error:nnx #1 { \flag_if_raised:nTF {#1} - { \msg_kernel_error:nnx { str } } + { \__msg_kernel_error:nnx { str } } { \use_none:nn } } -\cs_new_protected:Npn \str_if_flag_no_error:nnx #1#2#3 - { \flag_if_raised:nT {#1} { \bool_gset_true:N \g_str_error_bool } } -\cs_new_protected:Npn \str_if_flag_times:nT #1#2 +\cs_new_protected:Npn \__str_if_flag_no_error:nnx #1#2#3 + { \flag_if_raised:nT {#1} { \bool_gset_true:N \g__str_error_bool } } +\cs_new_protected:Npn \__str_if_flag_times:nT #1#2 { \flag_if_raised:nT {#1} { #2~(x \flag_height:n {#1} ) } } \cs_new_protected_nopar:Npn \str_set_convert:Nnnn - { \str_convert_aux_i:nNNnnn { } \tl_set_eq:NN } + { \__str_convert_i:nNNnnn { } \tl_set_eq:NN } \cs_new_protected_nopar:Npn \str_gset_convert:Nnnn - { \str_convert_aux_i:nNNnnn { } \tl_gset_eq:NN } + { \__str_convert_i:nNNnnn { } \tl_gset_eq:NN } \prg_new_protected_conditional:Npnn \str_set_convert:Nnnn #1#2#3#4 { T , F , TF } { - \bool_gset_false:N \g_str_error_bool - \str_convert_aux_i:nNNnnn - { \cs_set_eq:NN \str_if_flag_error:nnx \str_if_flag_no_error:nnx } + \bool_gset_false:N \g__str_error_bool + \__str_convert_i:nNNnnn + { \cs_set_eq:NN \__str_if_flag_error:nnx \__str_if_flag_no_error:nnx } \tl_set_eq:NN #1 {#2} {#3} {#4} - \bool_if:NTF \g_str_error_bool \prg_return_false: \prg_return_true: + \bool_if:NTF \g__str_error_bool \prg_return_false: \prg_return_true: } \prg_new_protected_conditional:Npnn \str_gset_convert:Nnnn #1#2#3#4 { T , F , TF } { - \bool_gset_false:N \g_str_error_bool - \str_convert_aux_i:nNNnnn - { \cs_set_eq:NN \str_if_flag_error:nnx \str_if_flag_no_error:nnx } + \bool_gset_false:N \g__str_error_bool + \__str_convert_i:nNNnnn + { \cs_set_eq:NN \__str_if_flag_error:nnx \__str_if_flag_no_error:nnx } \tl_gset_eq:NN #1 {#2} {#3} {#4} - \bool_if:NTF \g_str_error_bool \prg_return_false: \prg_return_true: + \bool_if:NTF \g__str_error_bool \prg_return_false: \prg_return_true: } -\cs_new_protected:Npn \str_convert_aux_i:nNNnnn #1#2#3#4#5#6 +\cs_new_protected:Npn \__str_convert_i:nNNnnn #1#2#3#4#5#6 { \group_begin: #1 - \str_gset_other:Nn \g_str_result_tl {#4} - \exp_after:wN \str_convert_aux_ii:wwwnn + \__str_gset_other:Nn \g__str_result_tl {#4} + \exp_after:wN \__str_convert_ii:wwwnn \tl_to_str:n {#5} /// \q_stop { decode } { unescape } \prg_do_nothing: - \str_convert_decode_: - \exp_after:wN \str_convert_aux_ii:wwwnn + \__str_convert_decode_: + \exp_after:wN \__str_convert_ii:wwwnn \tl_to_str:n {#6} /// \q_stop { encode } { escape } \use_ii_i:nn - \str_convert_encode_: + \__str_convert_encode_: \group_end: - #2 #3 \g_str_result_tl + #2 #3 \g__str_result_tl } -\cs_new_protected:Npn \str_convert_aux_ii:wwwnn +\cs_new_protected:Npn \__str_convert_ii:wwwnn #1 / #2 // #3 \q_stop #4#5 { - \str_convert_aux_iv:nnn {enc} {#4} {#1} - \str_convert_aux_iv:nnn {esc} {#5} {#2} - \exp_args:Ncc \str_convert_aux_iii:NNnNN - { str_convert_#4_#1: } { str_convert_#5_#2: } {#2} + \__str_convert_iv:nnn {enc} {#4} {#1} + \__str_convert_iv:nnn {esc} {#5} {#2} + \exp_args:Ncc \__str_convert_iii:NNnNN + { __str_convert_#4_#1: } { __str_convert_#5_#2: } {#2} } -\cs_new_protected:Npn \str_convert_aux_iii:NNnNN #1#2#3#4#5 +\cs_new_protected:Npn \__str_convert_iii:NNnNN #1#2#3#4#5 { \if_meaning:w #1 #5 \tl_if_empty:nF {#3} - { \msg_kernel_error:nnx { str } { native-escaping } {#3} } + { \__msg_kernel_error:nnx { str } { native-escaping } {#3} } #1 \else: #4 #2 #1 \fi: } -\cs_new_protected:Npn \str_convert_aux_iv:nnn #1#2#3 +\cs_new_protected:Npn \__str_convert_iv:nnn #1#2#3 { - \cs_if_exist:cF { str_convert_#2_#3: } + \cs_if_exist:cF { __str_convert_#2_#3: } { - \exp_args:Nx \str_convert_aux_v:nnnn - { \str_convert_lowercase_alphanum:n {#3} } + \exp_args:Nx \__str_convert_v:nnnn + { \__str_convert_lowercase_alphanum:n {#3} } {#1} {#2} {#3} } } -\cs_new_protected:Npn \str_convert_aux_v:nnnn #1#2#3#4 +\cs_new_protected:Npn \__str_convert_v:nnnn #1#2#3#4 { - \cs_if_exist:cF { str_convert_#3_#1: } + \cs_if_exist:cF { __str_convert_#3_#1: } { - \prop_get:NnNF \g_str_file_prop {#1} \l_str_internal_tl - { \tl_set:Nn \l_str_internal_tl {#1} } - \cs_if_exist:cF { str_convert_#3_ \l_str_internal_tl : } + \prop_get:NnNF \g__str_alias_prop {#1} \l__str_internal_tl + { \tl_set:Nn \l__str_internal_tl {#1} } + \cs_if_exist:cF { __str_convert_#3_ \l__str_internal_tl : } { - \file_if_exist:nTF { l3str-#2- \l_str_internal_tl .def } + \file_if_exist:nTF { l3str-#2- \l__str_internal_tl .def } { \group_begin: - \str_load_catcodes: - \file_input:n { l3str-#2- \l_str_internal_tl .def } + \__str_load_catcodes: + \file_input:n { l3str-#2- \l__str_internal_tl .def } \group_end: } { - \tl_clear:N \l_str_internal_tl - \msg_kernel_error:nnxx { str } { unknown-#2 } {#4} {#1} + \tl_clear:N \l__str_internal_tl + \__msg_kernel_error:nnxx { str } { unknown-#2 } {#4} {#1} } } - \cs_if_exist:cF { str_convert_#3_#1: } + \cs_if_exist:cF { __str_convert_#3_#1: } { - \cs_gset_eq:cc { str_convert_#3_#1: } - { str_convert_#3_ \l_str_internal_tl : } + \cs_gset_eq:cc { __str_convert_#3_#1: } + { __str_convert_#3_ \l__str_internal_tl : } } } - \cs_gset_eq:cc { str_convert_#3_#4: } { str_convert_#3_#1: } + \cs_gset_eq:cc { __str_convert_#3_#4: } { __str_convert_#3_#1: } } -\cs_new:Npn \str_convert_lowercase_alphanum:n #1 +\cs_new:Npn \__str_convert_lowercase_alphanum:n #1 { - \exp_after:wN \str_convert_lowercase_alphanum_loop:N - \tl_to_str:n {#1} { ? \prg_map_break: } - \prg_break_point:n { } + \exp_after:wN \__str_convert_lowercase_alphanum_loop:N + \tl_to_str:n {#1} { ? \__prg_break: } + \__prg_break_point: } -\cs_new:Npn \str_convert_lowercase_alphanum_loop:N #1 +\cs_new:Npn \__str_convert_lowercase_alphanum_loop:N #1 { \use_none:n #1 - \if_num:w `#1 < \c_ninety_one - \if_num:w `#1 < \c_sixty_five - \if_num:w \c_one < 1#1 \exp_stop_f: + \if_int_compare:w `#1 < \c_ninety_one + \if_int_compare:w `#1 < \c_sixty_five + \if_int_compare:w \c_one < 1#1 \exp_stop_f: #1 \fi: \else: - \str_output_byte:n { `#1 + \c_thirty_two } + \__str_output_byte:n { `#1 + \c_thirty_two } \fi: \else: - \if_num:w `#1 < \c_one_hundred_twenty_three - \if_num:w `#1 < \c_ninety_seven + \if_int_compare:w `#1 < \c_one_hundred_twenty_three + \if_int_compare:w `#1 < \c_ninety_seven \else: #1 \fi: \fi: \fi: - \str_convert_lowercase_alphanum_loop:N + \__str_convert_lowercase_alphanum_loop:N } -\cs_new_protected:Npn \str_load_catcodes: +\cs_new_protected:Npn \__str_load_catcodes: { \char_set_catcode_escape:N \\ \char_set_catcode_group_begin:N \{ @@ -677,64 +680,64 @@ \int_set:Nn \tex_endlinechar:D {32} } \pdftex_if_engine:TF - { \cs_new_eq:NN \str_filter_bytes:n \use:n } + { \cs_new_eq:NN \__str_filter_bytes:n \use:n } { - \cs_new:Npn \str_filter_bytes:n #1 + \cs_new:Npn \__str_filter_bytes:n #1 { - \str_filter_bytes_aux:N #1 - { ? \prg_map_break: } - \prg_break_point:n { } + \__str_filter_bytes_aux:N #1 + { ? \__prg_break: } + \__prg_break_point: } - \cs_new:Npn \str_filter_bytes_aux:N #1 + \cs_new:Npn \__str_filter_bytes_aux:N #1 { \use_none:n #1 - \if_num:w `#1 < 256 \exp_stop_f: + \if_int_compare:w `#1 < 256 \exp_stop_f: #1 \else: \flag_raise:n { str_byte } \fi: - \str_filter_bytes_aux:N + \__str_filter_bytes_aux:N } } \pdftex_if_engine:TF - { \cs_new_protected_nopar:Npn \str_convert_unescape_: { } } + { \cs_new_protected_nopar:Npn \__str_convert_unescape_: { } } { - \cs_new_protected_nopar:Npn \str_convert_unescape_: + \cs_new_protected_nopar:Npn \__str_convert_unescape_: { \flag_clear:n { str_byte } - \tl_gset:Nx \g_str_result_tl - { \exp_args:No \str_filter_bytes:n \g_str_result_tl } - \str_if_flag_error:nnx { str_byte } { non-byte } { bytes } + \tl_gset:Nx \g__str_result_tl + { \exp_args:No \__str_filter_bytes:n \g__str_result_tl } + \__str_if_flag_error:nnx { str_byte } { non-byte } { bytes } } } -\cs_new_eq:NN \str_convert_unescape_bytes: \str_convert_unescape_: -\cs_new_protected_nopar:Npn \str_convert_escape_: { } -\cs_new_eq:NN \str_convert_escape_bytes: \str_convert_escape_: -\cs_new_protected_nopar:Npn \str_convert_decode_: - { \str_convert_gmap:N \str_decode_native_char:N } -\cs_new:Npn \str_decode_native_char:N #1 - { #1 \s_tl \int_value:w `#1 \s_tl } +\cs_new_eq:NN \__str_convert_unescape_bytes: \__str_convert_unescape_: +\cs_new_protected_nopar:Npn \__str_convert_escape_: { } +\cs_new_eq:NN \__str_convert_escape_bytes: \__str_convert_escape_: +\cs_new_protected_nopar:Npn \__str_convert_decode_: + { \__str_convert_gmap:N \__str_decode_native_char:N } +\cs_new:Npn \__str_decode_native_char:N #1 + { #1 \s__tl \__int_value:w `#1 \s__tl } \group_begin: \char_set_catcode_other:n { 0 } \pdftex_if_engine:TF { - \cs_new_protected_nopar:Npn \str_convert_encode_: + \cs_new_protected_nopar:Npn \__str_convert_encode_: { \flag_clear:n { str_error } - \str_convert_gmap_internal:N \str_encode_native_char:n - \str_if_flag_error:nnx { str_error } + \__str_convert_gmap_internal:N \__str_encode_native_char:n + \__str_if_flag_error:nnx { str_error } { pdfTeX-native-overflow } { } } - \cs_new:Npn \str_encode_native_char:n #1 + \cs_new:Npn \__str_encode_native_char:n #1 { - \if_num:w #1 < \c_two_hundred_fifty_six - \str_output_byte:n {#1} + \if_int_compare:w #1 < \c_two_hundred_fifty_six + \__str_output_byte:n {#1} \else: \flag_raise:n { str_error } ? \fi: } - \msg_kernel_new:nnnn { str } { pdfTeX-native-overflow } + \__msg_kernel_new:nnnn { str } { pdfTeX-native-overflow } { Character~code~too~large~for~pdfTeX. } { The~pdfTeX~engine~only~supports~8-bit~characters:~ @@ -743,141 +746,141 @@ } } { - \cs_new_protected_nopar:Npn \str_convert_encode_: + \cs_new_protected_nopar:Npn \__str_convert_encode_: { - \int_zero:N \l_tl_build_offset_int - \tl_gset_build_x:Nw \g_str_result_tl - \exp_after:wN \str_encode_native_loop:w - \g_str_result_tl \s_tl { \q_stop \prg_map_break: } \s_tl - \prg_break_point:n { } - \tl_build_end: + \int_zero:N \l__tl_build_offset_int + \__tl_gbuild_x:Nw \g__str_result_tl + \exp_after:wN \__str_encode_native_loop:w + \g__str_result_tl \s__tl { \q_stop \__prg_break: } \s__tl + \__prg_break_point: + \__tl_build_end: } - \cs_new_protected:Npn \str_encode_native_loop:w #1 \s_tl #2 \s_tl + \cs_new_protected:Npn \__str_encode_native_loop:w #1 \s__tl #2 \s__tl { \use_none_delimit_by_q_stop:w #2 \q_stop - \tex_lccode:D \l_str_internal_int \int_eval:w #2 \int_eval_end: - \tl_to_lowercase:n { \tl_build_one:n { ^^@ } } - \str_encode_native_loop:w + \tex_lccode:D \l__str_internal_int \__int_eval:w #2 \__int_eval_end: + \tl_to_lowercase:n { \__tl_build_one:n { ^^@ } } + \__str_encode_native_loop:w } } \group_end: -\cs_new_protected:Npn \str_declare_eight_bit_encoding:nnn #1#2#3 +\cs_new_protected:Npn \__str_declare_eight_bit_encoding:nnn #1#2#3 { - \tl_set:Nn \l_str_internal_tl {#1} - \cs_new_protected_nopar:cpn { str_convert_decode_#1: } - { \str_convert_decode_eight_bit:n {#1} } - \cs_new_protected_nopar:cpn { str_convert_encode_#1: } - { \str_convert_encode_eight_bit:n {#1} } - \tl_const:cn { c_str_encoding_#1_tl } {#2} - \tl_const:cn { c_str_encoding_#1_missing_tl } {#3} + \tl_set:Nn \l__str_internal_tl {#1} + \cs_new_protected_nopar:cpn { __str_convert_decode_#1: } + { \__str_convert_decode_eight_bit:n {#1} } + \cs_new_protected_nopar:cpn { __str_convert_encode_#1: } + { \__str_convert_encode_eight_bit:n {#1} } + \tl_const:cn { c__str_encoding_#1_tl } {#2} + \tl_const:cn { c__str_encoding_#1_missing_tl } {#3} } -\cs_new_protected:Npn \str_convert_decode_eight_bit:n #1 +\cs_new_protected:Npn \__str_convert_decode_eight_bit:n #1 { \group_begin: - \int_zero:N \l_str_internal_int - \exp_last_unbraced:Nx \str_decode_eight_bit_load:nn - { \tl_use:c { c_str_encoding_#1_tl } } - { \q_stop \prg_map_break: } { } - \prg_break_point:n { } - \exp_last_unbraced:Nx \str_decode_eight_bit_load_missing:n - { \tl_use:c { c_str_encoding_#1_missing_tl } } - { \q_stop \prg_map_break: } - \prg_break_point:n { } + \int_zero:N \l__str_internal_int + \exp_last_unbraced:Nx \__str_decode_eight_bit_load:nn + { \tl_use:c { c__str_encoding_#1_tl } } + { \q_stop \__prg_break: } { } + \__prg_break_point: + \exp_last_unbraced:Nx \__str_decode_eight_bit_load_missing:n + { \tl_use:c { c__str_encoding_#1_missing_tl } } + { \q_stop \__prg_break: } + \__prg_break_point: \flag_clear:n { str_error } - \str_convert_gmap:N \str_decode_eight_bit_char:N - \str_if_flag_error:nnx { str_error } { decode-8-bit } {#1} + \__str_convert_gmap:N \__str_decode_eight_bit_char:N + \__str_if_flag_error:nnx { str_error } { decode-8-bit } {#1} \group_end: } -\cs_new_protected:Npn \str_decode_eight_bit_load:nn #1#2 +\cs_new_protected:Npn \__str_decode_eight_bit_load:nn #1#2 { \use_none_delimit_by_q_stop:w #1 \q_stop - \tex_dimen:D "#1 = \l_str_internal_int sp \scan_stop: - \tex_skip:D \l_str_internal_int = "#1 sp \scan_stop: - \tex_toks:D \l_str_internal_int \exp_after:wN { \int_value:w "#2 } - \tex_advance:D \l_str_internal_int \c_one - \str_decode_eight_bit_load:nn + \tex_dimen:D "#1 = \l__str_internal_int sp \scan_stop: + \tex_skip:D \l__str_internal_int = "#1 sp \scan_stop: + \tex_toks:D \l__str_internal_int \exp_after:wN { \__int_value:w "#2 } + \tex_advance:D \l__str_internal_int \c_one + \__str_decode_eight_bit_load:nn } -\cs_new_protected:Npn \str_decode_eight_bit_load_missing:n #1 +\cs_new_protected:Npn \__str_decode_eight_bit_load_missing:n #1 { \use_none_delimit_by_q_stop:w #1 \q_stop - \tex_dimen:D "#1 = \l_str_internal_int sp \scan_stop: - \tex_skip:D \l_str_internal_int = "#1 sp \scan_stop: - \tex_toks:D \l_str_internal_int \exp_after:wN - { \int_use:N \c_str_replacement_char_int } - \tex_advance:D \l_str_internal_int \c_one - \str_decode_eight_bit_load_missing:n - } -\cs_new:Npn \str_decode_eight_bit_char:N #1 - { - #1 \s_tl - \if_num:w \tex_dimen:D `#1 < \l_str_internal_int - \if_num:w \tex_skip:D \tex_dimen:D `#1 = `#1 \exp_stop_f: + \tex_dimen:D "#1 = \l__str_internal_int sp \scan_stop: + \tex_skip:D \l__str_internal_int = "#1 sp \scan_stop: + \tex_toks:D \l__str_internal_int \exp_after:wN + { \int_use:N \c__str_replacement_char_int } + \tex_advance:D \l__str_internal_int \c_one + \__str_decode_eight_bit_load_missing:n + } +\cs_new:Npn \__str_decode_eight_bit_char:N #1 + { + #1 \s__tl + \if_int_compare:w \tex_dimen:D `#1 < \l__str_internal_int + \if_int_compare:w \tex_skip:D \tex_dimen:D `#1 = `#1 \exp_stop_f: \tex_the:D \tex_toks:D \tex_dimen:D \fi: \fi: - \int_value:w `#1 \s_tl + \__int_value:w `#1 \s__tl } -\cs_new_protected:Npn \str_convert_encode_eight_bit:n #1 +\cs_new_protected:Npn \__str_convert_encode_eight_bit:n #1 { \group_begin: - \int_zero:N \l_str_internal_int - \exp_last_unbraced:Nx \str_encode_eight_bit_load:nn - { \tl_use:c { c_str_encoding_#1_tl } } - { \q_stop \prg_map_break: } { } - \prg_break_point:n { } + \int_zero:N \l__str_internal_int + \exp_last_unbraced:Nx \__str_encode_eight_bit_load:nn + { \tl_use:c { c__str_encoding_#1_tl } } + { \q_stop \__prg_break: } { } + \__prg_break_point: \flag_clear:n { str_error } - \str_convert_gmap_internal:N \str_encode_eight_bit_char:n - \str_if_flag_error:nnx { str_error } { encode-8-bit } {#1} + \__str_convert_gmap_internal:N \__str_encode_eight_bit_char:n + \__str_if_flag_error:nnx { str_error } { encode-8-bit } {#1} \group_end: } -\cs_new_protected:Npn \str_encode_eight_bit_load:nn #1#2 +\cs_new_protected:Npn \__str_encode_eight_bit_load:nn #1#2 { \use_none_delimit_by_q_stop:w #1 \q_stop - \tex_dimen:D "#2 = \l_str_internal_int sp \scan_stop: - \tex_skip:D \l_str_internal_int = "#2 sp \scan_stop: - \exp_args:NNf \tex_toks:D \l_str_internal_int - { \str_output_byte:n { "#1 } } - \tex_advance:D \l_str_internal_int \c_one - \str_encode_eight_bit_load:nn + \tex_dimen:D "#2 = \l__str_internal_int sp \scan_stop: + \tex_skip:D \l__str_internal_int = "#2 sp \scan_stop: + \exp_args:NNf \tex_toks:D \l__str_internal_int + { \__str_output_byte:n { "#1 } } + \tex_advance:D \l__str_internal_int \c_one + \__str_encode_eight_bit_load:nn } -\cs_new:Npn \str_encode_eight_bit_char:n #1 +\cs_new:Npn \__str_encode_eight_bit_char:n #1 { - \if_num:w #1 > \c_max_register_int + \if_int_compare:w #1 > \c_max_register_int \flag_raise:n { str_error } \else: - \if_num:w \tex_dimen:D #1 < \l_str_internal_int - \if_num:w \tex_skip:D \tex_dimen:D #1 = #1 \exp_stop_f: + \if_int_compare:w \tex_dimen:D #1 < \l__str_internal_int + \if_int_compare:w \tex_skip:D \tex_dimen:D #1 = #1 \exp_stop_f: \tex_the:D \tex_toks:D \tex_dimen:D #1 \exp_stop_f: \exp_after:wN \exp_after:wN \exp_after:wN \use_none:nn \fi: \fi: - \str_encode_eight_bit_char_aux:n {#1} + \__str_encode_eight_bit_char_aux:n {#1} \fi: } -\cs_new:Npn \str_encode_eight_bit_char_aux:n #1 +\cs_new:Npn \__str_encode_eight_bit_char_aux:n #1 { - \if_num:w #1 < \c_two_hundred_fifty_six - \str_output_byte:n {#1} + \if_int_compare:w #1 < \c_two_hundred_fifty_six + \__str_output_byte:n {#1} \else: \flag_raise:n { str_error } \fi: } -\msg_kernel_new:nnn { str } { unknown-esc } +\__msg_kernel_new:nnn { str } { unknown-esc } { Escaping~scheme~'#1'~(filtered:~'#2')~unknown. } -\msg_kernel_new:nnn { str } { unknown-enc } +\__msg_kernel_new:nnn { str } { unknown-enc } { Encoding~scheme~'#1'~(filtered:~'#2')~unknown. } -\msg_kernel_new:nnnn { str } { native-escaping } +\__msg_kernel_new:nnnn { str } { native-escaping } { The~'native'~encoding~scheme~does~not~support~any~escaping. } { Since~native~strings~do~not~consist~in~bytes,~ none~of~the~escaping~methods~make~sense.~ The~specified~escaping,~'#1',~will be ignored. } -\msg_kernel_new:nnn { str } { file-not-found } +\__msg_kernel_new:nnn { str } { file-not-found } { File~'l3str-#1.def'~not~found. } \pdftex_if_engine:F { - \msg_kernel_new:nnnn { str } { non-byte } + \__msg_kernel_new:nnnn { str } { non-byte } { String~invalid~in~escaping~'#1':~it~may~only~contain~bytes. } { Some~characters~in~the~string~you~asked~to~convert~are~not~ @@ -891,22 +894,22 @@ } } } -\msg_kernel_new:nnnn { str } { decode-8-bit } +\__msg_kernel_new:nnnn { str } { decode-8-bit } { Invalid~string~in~encoding~'#1'. } { LaTeX~came~across~a~byte~which~is~not~defined~to~represent~ any~character~in~the~encoding~'#1'. } -\msg_kernel_new:nnnn { str } { encode-8-bit } +\__msg_kernel_new:nnnn { str } { encode-8-bit } { Unicode~string~cannot~be~converted~to~encoding~'#1'. } { The~encoding~'#1'~only~contains~a~subset~of~all~Unicode~characters.~ LaTeX~was~asked~to~convert~a~string~to~that~encoding,~but~that~ string~contains~a~character~that~'#1'~does~not~support. } -\cs_set:Npn \str_length_skip_spaces:N - { \exp_args:No \str_length_skip_spaces:n } -\cs_set_eq:NN \str_length_skip_spaces:n \str_length_ignore_spaces:n +\cs_new_eq:NN \str_length:N \str_count:N +\cs_new_eq:NN \str_length:n \str_count:n +\cs_new_eq:NN \str_length_ignore_spaces:n \str_count_ignore_spaces:n %% %% %% End of file `l3str.sty'. diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty index 545d7ce7069..8b90db9c751 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty @@ -47,216 +47,216 @@ %% ----------------------------------------------------------------------- \RequirePackage{expl3} \GetIdInfo$Id: l3tl-analysis.dtx 3039 2011-12-08 09:22:35Z bruno $ - {L3 Experimental Analysis of Token lists} + {L3 Experimental token lists analysis} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{l3str} -\scan_new:N \s_tl -\tl_new:N \l_tl_analysis_internal_tl -\cs_new_eq:NN \l_tl_analysis_token ? -\cs_new_eq:NN \l_tl_analysis_char_token ? -\int_new:N \l_tl_analysis_normal_int -\int_new:N \l_tl_analysis_index_int -\int_new:N \l_tl_analysis_nesting_int -\int_new:N \l_tl_analysis_type_int -\tl_new:N \g_tl_analysis_result_tl -\cs_new_nopar:Npn \tl_analysis_extract_charcode: - { - \exp_after:wN \tl_analysis_extract_charcode_aux:w - \token_to_meaning:N \l_tl_analysis_token - } -\cs_new:Npn \tl_analysis_extract_charcode_aux:w #1 ~ #2 ~ { ` } -\cs_new:Npn \tl_analysis_cs_space_count:NN #1 #2 +\__scan_new:N \s__tl +\tl_new:N \l__tl_analysis_internal_tl +\cs_new_eq:NN \l__tl_analysis_token ? +\cs_new_eq:NN \l__tl_analysis_char_token ? +\int_new:N \l__tl_analysis_normal_int +\int_new:N \l__tl_analysis_index_int +\int_new:N \l__tl_analysis_nesting_int +\int_new:N \l__tl_analysis_type_int +\tl_new:N \g__tl_analysis_result_tl +\cs_new_nopar:Npn \__tl_analysis_extract_charcode: + { + \exp_after:wN \__tl_analysis_extract_charcode_aux:w + \token_to_meaning:N \l__tl_analysis_token + } +\cs_new:Npn \__tl_analysis_extract_charcode_aux:w #1 ~ #2 ~ { ` } +\cs_new:Npn \__tl_analysis_cs_space_count:NN #1 #2 { \exp_after:wN #1 - \int_value:w \int_eval:w \c_zero - \exp_after:wN \tl_analysis_cs_space_count:w + \__int_value:w \__int_eval:w \c_zero + \exp_after:wN \__tl_analysis_cs_space_count:w \token_to_str:N #2 - \fi: \tl_analysis_cs_space_count_end:w ; ~ ! + \fi: \__tl_analysis_cs_space_count_end:w ; ~ ! } -\cs_new:Npn \tl_analysis_cs_space_count:w #1 ~ +\cs_new:Npn \__tl_analysis_cs_space_count:w #1 ~ { \if_false: #1 #1 \fi: + \c_one - \tl_analysis_cs_space_count:w + \__tl_analysis_cs_space_count:w } -\cs_new:Npn \tl_analysis_cs_space_count_end:w ; #1 \fi: #2 ! - { \exp_after:wN ; \int_value:w \str_length_ignore_spaces:n {#1} ; } -\cs_new_protected:Npn \tl_analysis:n #1 +\cs_new:Npn \__tl_analysis_cs_space_count_end:w ; #1 \fi: #2 ! + { \exp_after:wN ; \__int_value:w \str_count_ignore_spaces:n {#1} ; } +\cs_new_protected:Npn \__tl_analysis:n #1 { \group_begin: \group_align_safe_begin: - \tl_analysis_setup:n {#1} - \tl_analysis_i:n {#1} - \tl_analysis_ii:n {#1} + \__tl_analysis_setup:n {#1} + \__tl_analysis_i:n {#1} + \__tl_analysis_ii:n {#1} \group_align_safe_end: \group_end: } -\cs_new_protected:Npn \tl_analysis_setup:n #1 +\cs_new_protected:Npn \__tl_analysis_setup:n #1 { \int_set_eq:NN \tex_escapechar:D \c_minus_one - \exp_after:wN \tl_analysis_disable_loop:N - \tl_to_str:n {#1} { ~ } { ? ~ \prg_map_break: } - \prg_break_point:n { } + \exp_after:wN \__tl_analysis_disable_loop:N + \tl_to_str:n {#1} { ~ } { ? ~ \__prg_break: } + \__prg_break_point: } \group_begin: \char_set_catcode_active:N \^^@ - \cs_new_protected:Npn \tl_analysis_disable_loop:N #1 + \cs_new_protected:Npn \__tl_analysis_disable_loop:N #1 { \tex_lccode:D \c_zero `#1 ~ \tl_to_lowercase:n { \tex_let:D ^^@ } \c_undefined:D - \tl_analysis_disable_loop:N + \__tl_analysis_disable_loop:N } \group_end: -\cs_new_protected:Npn \tl_analysis_i:n #1 +\cs_new_protected:Npn \__tl_analysis_i:n #1 { \int_set:Nn \tex_escapechar:D { 92 } - \int_zero:N \l_tl_analysis_normal_int - \int_zero:N \l_tl_analysis_index_int - \int_zero:N \l_tl_analysis_nesting_int - \if_false: { \fi: \tl_analysis_i_loop:w #1 } - \int_decr:N \l_tl_analysis_index_int - } -\cs_new_protected_nopar:Npn \tl_analysis_i_loop:w - { \tex_futurelet:D \l_tl_analysis_token \tl_analysis_i_type:w } -\cs_new_protected_nopar:Npn \tl_analysis_i_type:w - { - \l_tl_analysis_type_int = - \if_meaning:w \l_tl_analysis_token \c_space_token + \int_zero:N \l__tl_analysis_normal_int + \int_zero:N \l__tl_analysis_index_int + \int_zero:N \l__tl_analysis_nesting_int + \if_false: { \fi: \__tl_analysis_i_loop:w #1 } + \int_decr:N \l__tl_analysis_index_int + } +\cs_new_protected_nopar:Npn \__tl_analysis_i_loop:w + { \tex_futurelet:D \l__tl_analysis_token \__tl_analysis_i_type:w } +\cs_new_protected_nopar:Npn \__tl_analysis_i_type:w + { + \l__tl_analysis_type_int = + \if_meaning:w \l__tl_analysis_token \c_space_token \c_zero \else: - \if_catcode:w \exp_not:N \l_tl_analysis_token \c_group_begin_token + \if_catcode:w \exp_not:N \l__tl_analysis_token \c_group_begin_token \c_one \else: - \if_catcode:w \exp_not:N \l_tl_analysis_token \c_group_end_token + \if_catcode:w \exp_not:N \l__tl_analysis_token \c_group_end_token \c_minus_one \else: \c_two \fi: \fi: \fi: - \if_case:w \l_tl_analysis_type_int - \exp_after:wN \tl_analysis_i_space:w - \or: \exp_after:wN \tl_analysis_i_bgroup:w - \or: \exp_after:wN \tl_analysis_i_safe:N - \else: \exp_after:wN \tl_analysis_i_egroup:w + \if_case:w \l__tl_analysis_type_int + \exp_after:wN \__tl_analysis_i_space:w + \or: \exp_after:wN \__tl_analysis_i_bgroup:w + \or: \exp_after:wN \__tl_analysis_i_safe:N + \else: \exp_after:wN \__tl_analysis_i_egroup:w \fi: } -\cs_new_protected_nopar:Npn \tl_analysis_i_space:w +\cs_new_protected_nopar:Npn \__tl_analysis_i_space:w { - \tex_afterassignment:D \tl_analysis_i_space_test:w + \tex_afterassignment:D \__tl_analysis_i_space_test:w \exp_after:wN \cs_set_eq:NN - \exp_after:wN \l_tl_analysis_char_token + \exp_after:wN \l__tl_analysis_char_token \token_to_str:N } -\cs_new_protected_nopar:Npn \tl_analysis_i_space_test:w +\cs_new_protected_nopar:Npn \__tl_analysis_i_space_test:w { - \if_meaning:w \l_tl_analysis_char_token \c_space_token - \tex_toks:D \l_tl_analysis_index_int { \exp_not:n { ~ } } - \tl_analysis_i_store: + \if_meaning:w \l__tl_analysis_char_token \c_space_token + \tex_toks:D \l__tl_analysis_index_int { \exp_not:n { ~ } } + \__tl_analysis_i_store: \else: - \int_incr:N \l_tl_analysis_normal_int + \int_incr:N \l__tl_analysis_normal_int \fi: - \tl_analysis_i_loop:w + \__tl_analysis_i_loop:w } \group_begin: \char_set_catcode_group_begin:N \^^@ \char_set_catcode_group_end:N \^^E - \cs_new_protected_nopar:Npn \tl_analysis_i_bgroup:w - { \tl_analysis_i_group:nw { \exp_after:wN ^^@ \if_false: ^^E \fi: } } + \cs_new_protected_nopar:Npn \__tl_analysis_i_bgroup:w + { \__tl_analysis_i_group:nw { \exp_after:wN ^^@ \if_false: ^^E \fi: } } \char_set_catcode_group_begin:N \^^B \char_set_catcode_group_end:N \^^@ - \cs_new_protected_nopar:Npn \tl_analysis_i_egroup:w - { \tl_analysis_i_group:nw { \if_false: ^^B \fi: ^^@ } } + \cs_new_protected_nopar:Npn \__tl_analysis_i_egroup:w + { \__tl_analysis_i_group:nw { \if_false: ^^B \fi: ^^@ } } \group_end: -\cs_new_protected:Npn \tl_analysis_i_group:nw #1 +\cs_new_protected:Npn \__tl_analysis_i_group:nw #1 { - \tex_lccode:D \c_zero = \tl_analysis_extract_charcode: \scan_stop: - \tl_to_lowercase:n { \tex_toks:D \l_tl_analysis_index_int {#1} } - \if_num:w \tex_lccode:D \c_zero = \tex_escapechar:D + \tex_lccode:D \c_zero = \__tl_analysis_extract_charcode: \scan_stop: + \tl_to_lowercase:n { \tex_toks:D \l__tl_analysis_index_int {#1} } + \if_int_compare:w \tex_lccode:D \c_zero = \tex_escapechar:D \int_set:Nn \tex_escapechar:D { 139 - \tex_escapechar:D } \fi: - \tex_afterassignment:D \tl_analysis_i_group_test:w + \tex_afterassignment:D \__tl_analysis_i_group_test:w \exp_after:wN \cs_set_eq:NN - \exp_after:wN \l_tl_analysis_char_token + \exp_after:wN \l__tl_analysis_char_token \token_to_str:N } -\cs_new_protected_nopar:Npn \tl_analysis_i_group_test:w +\cs_new_protected_nopar:Npn \__tl_analysis_i_group_test:w { - \if_charcode:w \l_tl_analysis_token \l_tl_analysis_char_token - \tl_analysis_i_store: + \if_charcode:w \l__tl_analysis_token \l__tl_analysis_char_token + \__tl_analysis_i_store: \else: - \int_incr:N \l_tl_analysis_normal_int + \int_incr:N \l__tl_analysis_normal_int \fi: - \tl_analysis_i_loop:w + \__tl_analysis_i_loop:w } -\cs_new_protected_nopar:Npn \tl_analysis_i_store: +\cs_new_protected_nopar:Npn \__tl_analysis_i_store: { - \tex_advance:D \l_tl_analysis_nesting_int \l_tl_analysis_type_int - \if_num:w \tex_lccode:D \c_zero = \c_thirty_two - \tex_multiply:D \l_tl_analysis_type_int \c_two + \tex_advance:D \l__tl_analysis_nesting_int \l__tl_analysis_type_int + \if_int_compare:w \tex_lccode:D \c_zero = \c_thirty_two + \tex_multiply:D \l__tl_analysis_type_int \c_two \fi: - \tex_skip:D \l_tl_analysis_index_int - = \l_tl_analysis_normal_int sp plus \l_tl_analysis_type_int sp \scan_stop: - \int_incr:N \l_tl_analysis_index_int - \int_zero:N \l_tl_analysis_normal_int - \if_num:w \l_tl_analysis_nesting_int = \c_minus_one - \cs_set_eq:NN \tl_analysis_i_loop:w \scan_stop: + \tex_skip:D \l__tl_analysis_index_int + = \l__tl_analysis_normal_int sp plus \l__tl_analysis_type_int sp \scan_stop: + \int_incr:N \l__tl_analysis_index_int + \int_zero:N \l__tl_analysis_normal_int + \if_int_compare:w \l__tl_analysis_nesting_int = \c_minus_one + \cs_set_eq:NN \__tl_analysis_i_loop:w \scan_stop: \fi: } -\cs_new_protected:Npn \tl_analysis_i_safe:N #1 +\cs_new_protected:Npn \__tl_analysis_i_safe:N #1 { \if_charcode:w \scan_stop: \exp_after:wN \use_none:n \token_to_str:N #1 \prg_do_nothing: \scan_stop: - \int_incr:N \l_tl_analysis_normal_int + \int_incr:N \l__tl_analysis_normal_int \else: - \tl_analysis_cs_space_count:NN \tl_analysis_i_cs:ww #1 + \__tl_analysis_cs_space_count:NN \__tl_analysis_i_cs:ww #1 \fi: - \tl_analysis_i_loop:w + \__tl_analysis_i_loop:w } -\cs_new_protected:Npn \tl_analysis_i_cs:ww #1; #2; +\cs_new_protected:Npn \__tl_analysis_i_cs:ww #1; #2; { - \if_num:w #1 > \c_zero - \tex_skip:D \l_tl_analysis_index_int - = \int_eval:w \l_tl_analysis_normal_int + \c_one sp \scan_stop: - \tex_advance:D \l_tl_analysis_index_int #1 \exp_stop_f: - \l_tl_analysis_normal_int #2 \exp_stop_f: + \if_int_compare:w #1 > \c_zero + \tex_skip:D \l__tl_analysis_index_int + = \__int_eval:w \l__tl_analysis_normal_int + \c_one sp \scan_stop: + \tex_advance:D \l__tl_analysis_index_int #1 \exp_stop_f: + \l__tl_analysis_normal_int #2 \exp_stop_f: \else: - \tex_advance:D \l_tl_analysis_normal_int #2 \exp_stop_f: + \tex_advance:D \l__tl_analysis_normal_int #2 \exp_stop_f: \fi: } -\cs_new_protected:Npn \tl_analysis_ii:n #1 +\cs_new_protected:Npn \__tl_analysis_ii:n #1 { - \tl_gset:Nx \g_tl_analysis_result_tl + \tl_gset:Nx \g__tl_analysis_result_tl { - \tl_analysis_ii_loop:w 0; #1 - \prg_break_point:n { } + \__tl_analysis_ii_loop:w 0; #1 + \__prg_break_point: } } -\cs_new:Npn \tl_analysis_ii_loop:w #1; +\cs_new:Npn \__tl_analysis_ii_loop:w #1; { - \exp_after:wN \tl_analysis_ii_normals:ww - \int_value:w \tex_skip:D #1 ; #1 ; + \exp_after:wN \__tl_analysis_ii_normals:ww + \__int_value:w \tex_skip:D #1 ; #1 ; } -\cs_new:Npn \tl_analysis_ii_normals:ww #1; +\cs_new:Npn \__tl_analysis_ii_normals:ww #1; { - \if_num:w #1 = \c_zero - \tl_analysis_ii_special:w + \if_int_compare:w #1 = \c_zero + \__tl_analysis_ii_special:w \fi: - \tl_analysis_ii_normal:wwN #1; + \__tl_analysis_ii_normal:wwN #1; } -\cs_new:Npn \tl_analysis_ii_normal:wwN #1; #2; #3 +\cs_new:Npn \__tl_analysis_ii_normal:wwN #1; #2; #3 { - \exp_not:n { \exp_not:n { #3 } } \s_tl + \exp_not:n { \exp_not:n { #3 } } \s__tl \if_charcode:w \scan_stop: \exp_after:wN \use_none:n \token_to_str:N #3 \prg_do_nothing: \scan_stop: - \exp_after:wN \tl_analysis_ii_char:Nww + \exp_after:wN \__tl_analysis_ii_char:Nww \else: - \exp_after:wN \tl_analysis_ii_cs:Nww + \exp_after:wN \__tl_analysis_ii_cs:Nww \fi: #3 #1; #2; } @@ -267,7 +267,7 @@ \char_set_uccode:nn { `? } { `D } \tl_to_uppercase:n { - \cs_new:Npn \tl_analysis_ii_char:Nww #1 + \cs_new:Npn \__tl_analysis_ii_char:Nww #1 { \if_meaning:w #1 \c_undefined:D ? \else: \if_catcode:w #1 \c_catcode_other_token C \else: @@ -279,40 +279,40 @@ \if_catcode:w #1 \c_space_token A \else: 6 \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: - \int_value:w `#1 \s_tl - \exp_after:wN \tl_analysis_ii_normals:ww - \int_use:N \int_eval:w \c_minus_one + + \__int_value:w `#1 \s__tl + \exp_after:wN \__tl_analysis_ii_normals:ww + \int_use:N \__int_eval:w \c_minus_one + } } \group_end: -\cs_new:Npn \tl_analysis_ii_cs:Nww #1 +\cs_new:Npn \__tl_analysis_ii_cs:Nww #1 { - 0 -1 \s_tl - \tl_analysis_cs_space_count:NN \tl_analysis_ii_cs_test:ww #1 + 0 -1 \s__tl + \__tl_analysis_cs_space_count:NN \__tl_analysis_ii_cs_test:ww #1 } -\cs_new:Npn \tl_analysis_ii_cs_test:ww #1 ; #2 ; #3 ; #4 ; +\cs_new:Npn \__tl_analysis_ii_cs_test:ww #1 ; #2 ; #3 ; #4 ; { - \exp_after:wN \tl_analysis_ii_normals:ww - \int_use:N \int_eval:w - \if_num:w #1 = \c_zero + \exp_after:wN \__tl_analysis_ii_normals:ww + \int_use:N \__int_eval:w + \if_int_compare:w #1 = \c_zero #3 \else: - \tex_skip:D \int_eval:w #4 + #1 \int_eval_end: + \tex_skip:D \__int_eval:w #4 + #1 \__int_eval_end: \fi: - #2 \exp_after:wN ; - \int_use:N \int_eval:w #4 + #1 ; + \int_use:N \__int_eval:w #4 + #1 ; } \group_begin: \char_set_catcode_other:N A - \cs_new:Npn \tl_analysis_ii_special:w - \fi: \tl_analysis_ii_normal:wwN 0 ; #1 ; + \cs_new:Npn \__tl_analysis_ii_special:w + \fi: \__tl_analysis_ii_normal:wwN 0 ; #1 ; { \fi: - \if_num:w #1 = \l_tl_analysis_index_int - \exp_after:wN \prg_map_break: + \if_int_compare:w #1 = \l__tl_analysis_index_int + \exp_after:wN \__prg_break: \fi: - \tex_the:D \tex_toks:D #1 \s_tl + \tex_the:D \tex_toks:D #1 \s__tl \if_case:w \etex_gluestretch:D \tex_skip:D #1 \exp_stop_f: A \or: 1 @@ -320,131 +320,131 @@ \else: 2 \fi: \if_int_odd:w \etex_gluestretch:D \tex_skip:D #1 \exp_stop_f: - \exp_after:wN \tl_analysis_ii_special_char:wN \int_use:N + \exp_after:wN \__tl_analysis_ii_special_char:wN \int_use:N \else: - \exp_after:wN \tl_analysis_ii_special_space:w \int_use:N + \exp_after:wN \__tl_analysis_ii_special_space:w \int_use:N \fi: - \int_eval:w \c_one + #1 \exp_after:wN ; + \__int_eval:w \c_one + #1 \exp_after:wN ; \token_to_str:N } \group_end: -\cs_new:Npn \tl_analysis_ii_special_char:wN #1 ; #2 +\cs_new:Npn \__tl_analysis_ii_special_char:wN #1 ; #2 { - \int_value:w `#2 \s_tl - \tl_analysis_ii_loop:w #1 ; + \__int_value:w `#2 \s__tl + \__tl_analysis_ii_loop:w #1 ; } -\cs_new:Npn \tl_analysis_ii_special_space:w #1 ; ~ +\cs_new:Npn \__tl_analysis_ii_special_space:w #1 ; ~ { - 32 \s_tl - \tl_analysis_ii_loop:w #1 ; + 32 \s__tl + \__tl_analysis_ii_loop:w #1 ; } -\cs_new_protected:Npn \tl_analysis_map_inline:nn #1 +\cs_new_protected:Npn \__tl_analysis_map_inline:nn #1 { - \tl_analysis:n {#1} - \int_gincr:N \g_prg_map_int - \exp_args:Nc \tl_analysis_map_inline_aux:Nn - { tl_analysis_map_inline_ \int_use:N \g_prg_map_int :wNw } + \__tl_analysis:n {#1} + \int_gincr:N \g__prg_map_int + \exp_args:Nc \__tl_analysis_map_inline_aux:Nn + { __tl_analysis_map_inline_ \int_use:N \g__prg_map_int :wNw } } -\cs_new_protected:Npn \tl_analysis_map_inline_aux:Nn #1#2 +\cs_new_protected:Npn \__tl_analysis_map_inline_aux:Nn #1#2 { - \cs_gset_protected:Npn #1 ##1 \s_tl ##2 ##3 \s_tl + \cs_gset_protected:Npn #1 ##1 \s__tl ##2 ##3 \s__tl { \use_none:n ##2 #2 #1 } \exp_after:wN #1 - \g_tl_analysis_result_tl - \s_tl { ? \prg_map_break: } \s_tl - \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + \g__tl_analysis_result_tl + \s__tl { ? \tl_map_break: } \s__tl + \__prg_break_point:Nn \tl_map_break: { \int_gdecr:N \g__prg_map_int } } \cs_new_protected:Npn \tl_show_analysis:N #1 { - \exp_args:No \tl_analysis:n {#1} - \msg_aux_show:Nnx #1 + \exp_args:No \__tl_analysis:n {#1} + \__msg_show_variable:Nnn #1 { tl-analysis } { - \exp_after:wN \tl_show_analysis_loop:wNw \g_tl_analysis_result_tl - \s_tl { ? \prg_map_break: } \s_tl - \prg_break_point:n { } + \exp_after:wN \__tl_analysis_show_loop:wNw \g__tl_analysis_result_tl + \s__tl { ? \__prg_break: } \s__tl + \__prg_break_point: } } \cs_new_protected:Npn \tl_show_analysis:n #1 { - \tl_set:Nn \l_tl_analysis_internal_tl {#1} - \tl_show_analysis:N \l_tl_analysis_internal_tl + \tl_set:Nn \l__tl_analysis_internal_tl {#1} + \tl_show_analysis:N \l__tl_analysis_internal_tl } -\cs_new:Npn \tl_show_analysis_loop:wNw #1 \s_tl #2 #3 \s_tl +\cs_new:Npn \__tl_analysis_show_loop:wNw #1 \s__tl #2 #3 \s__tl { \use_none:n #2 \iow_newline: > \c_space_tl \c_space_tl - \if_num:w "#2 = \c_zero - \exp_after:wN \tl_show_analysis_cs:n + \if_int_compare:w "#2 = \c_zero + \exp_after:wN \__tl_analysis_show_cs:n \else: - \if_num:w "#2 = \c_thirteen + \if_int_compare:w "#2 = \c_thirteen \exp_after:wN \exp_after:wN - \exp_after:wN \tl_show_analysis_active:n + \exp_after:wN \__tl_analysis_show_active:n \else: \exp_after:wN \exp_after:wN - \exp_after:wN \tl_show_analysis_normal:n + \exp_after:wN \__tl_analysis_show_normal:n \fi: \fi: {#1} - \tl_show_analysis_loop:wNw + \__tl_analysis_show_loop:wNw } -\cs_new:Npn \tl_show_analysis_normal:n #1 +\cs_new:Npn \__tl_analysis_show_normal:n #1 { \exp_after:wN \token_to_str:N #1 ~ ( \exp_after:wN \token_to_meaning:N #1 ) } -\cs_new:Npn \tl_show_analysis_value:N #1 +\cs_new:Npn \__tl_analysis_show_value:N #1 { \token_if_expandable:NF #1 { - \token_if_chardef:NTF #1 \prg_map_break: { } - \token_if_mathchardef:NTF #1 \prg_map_break: { } - \token_if_dim_register:NTF #1 \prg_map_break: { } - \token_if_int_register:NTF #1 \prg_map_break: { } - \token_if_skip_register:NTF #1 \prg_map_break: { } - \token_if_toks_register:NTF #1 \prg_map_break: { } - \use_none:nnnn - \prg_break_point:n { } + \token_if_chardef:NTF #1 \__prg_break: { } + \token_if_mathchardef:NTF #1 \__prg_break: { } + \token_if_dim_register:NTF #1 \__prg_break: { } + \token_if_int_register:NTF #1 \__prg_break: { } + \token_if_skip_register:NTF #1 \__prg_break: { } + \token_if_toks_register:NTF #1 \__prg_break: { } + \use_none:nnn + \__prg_break_point: \use:n { = \tex_the:D #1 } } } -\cs_new:Npn \tl_show_analysis_cs:n #1 - { \exp_args:No \tl_show_analysis_long:nn {#1} { control~sequence= } } -\cs_new:Npn \tl_show_analysis_active:n #1 - { \exp_args:No \tl_show_analysis_long:nn {#1} { active~character= } } -\cs_new:Npn \tl_show_analysis_long:nn #1 +\cs_new:Npn \__tl_analysis_show_cs:n #1 + { \exp_args:No \__tl_analysis_show_long:nn {#1} { control~sequence= } } +\cs_new:Npn \__tl_analysis_show_active:n #1 + { \exp_args:No \__tl_analysis_show_long:nn {#1} { active~character= } } +\cs_new:Npn \__tl_analysis_show_long:nn #1 { - \tl_show_analysis_long_aux:oofn + \__tl_analysis_show_long_aux:oofn { \token_to_str:N #1 } { \token_to_meaning:N #1 } - { \tl_show_analysis_value:N #1 } + { \__tl_analysis_show_value:N #1 } } -\cs_new:Npn \tl_show_analysis_long_aux:nnnn #1#2#3#4 +\cs_new:Npn \__tl_analysis_show_long_aux:nnnn #1#2#3#4 { \int_compare:nNnTF - { \str_length:n { #1 ~ ( #4 #2 #3 ) } } - > { \l_iow_line_length_int - \c_three } + { \str_count:n { #1 ~ ( #4 #2 #3 ) } } + > { \l_iow_line_count_int - \c_three } { - \str_substr:nnn { #1 ~ ( #4 #2 #3 ) } \c_zero + \str_substr:nnn { #1 ~ ( #4 #2 #3 ) } \c_one { - \l_iow_line_length_int - \c_three - - \str_length:N \c_tl_show_analysis_etc_str + \l_iow_line_count_int - \c_three + - \str_count:N \c__tl_analysis_show_etc_str } - \c_tl_show_analysis_etc_str + \c__tl_analysis_show_etc_str } { #1 ~ ( #4 #2 #3 ) } } -\cs_generate_variant:Nn \tl_show_analysis_long_aux:nnnn { oof } -\tl_const:Nx \c_tl_show_analysis_etc_str % ( +\cs_generate_variant:Nn \__tl_analysis_show_long_aux:nnnn { oof } +\tl_const:Nx \c__tl_analysis_show_etc_str % ( { \token_to_str:N \ETC.) } -\msg_kernel_new:nnn { tl-analysis } { show } +\__msg_kernel_new:nnn { kernel } { show-tl-analysis } { The~token~list~ - \str_if_eq:nnF {#1} { \l_tl_analysis_internal_tl } + \str_if_eq:nnF {#1} { \l__tl_analysis_internal_tl } { \token_to_str:N #1 ~ } \tl_if_empty:NTF #1 { is~empty } diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty index 415a89f4897..1ad40197bab 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty @@ -47,74 +47,74 @@ %% ----------------------------------------------------------------------- \RequirePackage{expl3} \GetIdInfo$Id: l3tl-build.dtx 3039 2011-12-08 09:22:35Z bruno $ - {L3 Experimental Build of Token lists} + {L3 Experimental token list construction} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} -\int_new:N \l_tl_build_start_index_int -\int_new:N \l_tl_build_index_int -\tl_new:N \l_tl_build_result_tl -\cs_new_protected_nopar:Npn \tl_build_unpack: +\int_new:N \l__tl_build_start_index_int +\int_new:N \l__tl_build_index_int +\tl_new:N \l__tl_build_result_tl +\cs_new_protected_nopar:Npn \__tl_build_unpack: { - \tl_put_right:Nx \l_tl_build_result_tl + \tl_put_right:Nx \l__tl_build_result_tl { - \exp_after:wN \tl_build_unpack_loop:w - \int_use:N \l_tl_build_start_index_int ; - \prg_break_point:n { } + \exp_after:wN \__tl_build_unpack_loop:w + \int_use:N \l__tl_build_start_index_int ; + \__prg_break_point: } } -\cs_new:Npn \tl_build_unpack_loop:w #1 ; +\cs_new:Npn \__tl_build_unpack_loop:w #1 ; { - \if_num:w #1 = \l_tl_build_index_int - \exp_after:wN \prg_map_break: + \if_int_compare:w #1 = \l__tl_build_index_int + \exp_after:wN \__prg_break: \fi: \tex_the:D \tex_toks:D #1 \exp_stop_f: - \exp_after:wN \tl_build_unpack_loop:w - \int_use:N \int_eval:w #1 + \c_one ; + \exp_after:wN \__tl_build_unpack_loop:w + \int_use:N \__int_eval:w #1 + \c_one ; } -\cs_new_protected_nopar:Npn \tl_set_build:Nw - { \tl_set_build_aux:NNw \tl_set:Nn } -\cs_new_protected_nopar:Npn \tl_set_build_x:Nw - { \tl_set_build_aux:NNw \tl_set:Nx } -\cs_new_protected_nopar:Npn \tl_gset_build:Nw - { \tl_set_build_aux:NNw \tl_gset:Nn } -\cs_new_protected_nopar:Npn \tl_gset_build_x:Nw - { \tl_set_build_aux:NNw \tl_gset:Nx } -\cs_new_protected:Npn \tl_set_build_aux:NNw #1#2 +\cs_new_protected_nopar:Npn \__tl_build:Nw + { \__tl_build_aux:NNw \tl_set:Nn } +\cs_new_protected_nopar:Npn \__tl_build_x:Nw + { \__tl_build_aux:NNw \tl_set:Nx } +\cs_new_protected_nopar:Npn \__tl_gbuild:Nw + { \__tl_build_aux:NNw \tl_gset:Nn } +\cs_new_protected_nopar:Npn \__tl_gbuild_x:Nw + { \__tl_build_aux:NNw \tl_gset:Nx } +\cs_new_protected:Npn \__tl_build_aux:NNw #1#2 { \group_begin: - \cs_set_nopar:Npn \tl_build_end_assignment:n + \cs_set_nopar:Npn \__tl_build_end_assignment:n { \group_end: #1 #2 } - \int_zero:N \l_tl_build_start_index_int - \int_zero:N \l_tl_build_index_int - \tl_clear:N \l_tl_build_result_tl + \int_zero:N \l__tl_build_start_index_int + \int_zero:N \l__tl_build_index_int + \tl_clear:N \l__tl_build_result_tl } -\cs_new_protected_nopar:Npn \tl_build_end: +\cs_new_protected_nopar:Npn \__tl_build_end: { - \tl_build_unpack: + \__tl_build_unpack: \exp_args:No - \tl_build_end_assignment:n \l_tl_build_result_tl + \__tl_build_end_assignment:n \l__tl_build_result_tl } -\cs_new_eq:NN \tl_build_end_assignment:n \use_none:n -\cs_new_protected:Npn \tl_build_one:n #1 +\cs_new_eq:NN \__tl_build_end_assignment:n \use_none:n +\cs_new_protected:Npn \__tl_build_one:n #1 { - \tex_toks:D \l_tl_build_index_int {#1} - \tex_advance:D \l_tl_build_index_int \c_one - \if_num:w \l_tl_build_index_int > \c_max_register_int - \tl_build_unpack: - \l_tl_build_index_int \l_tl_build_start_index_int + \tex_toks:D \l__tl_build_index_int {#1} + \tex_advance:D \l__tl_build_index_int \c_one + \if_int_compare:w \l__tl_build_index_int > \c_max_register_int + \__tl_build_unpack: + \l__tl_build_index_int \l__tl_build_start_index_int \fi: } -\cs_new_protected:Npn \tl_build_one:o #1 +\cs_new_protected:Npn \__tl_build_one:o #1 { - \tex_toks:D \l_tl_build_index_int \exp_after:wN {#1} - \tex_advance:D \l_tl_build_index_int \c_one - \if_num:w \l_tl_build_index_int > \c_max_register_int - \tl_build_unpack: - \l_tl_build_index_int \l_tl_build_start_index_int + \tex_toks:D \l__tl_build_index_int \exp_after:wN {#1} + \tex_advance:D \l__tl_build_index_int \c_one + \if_int_compare:w \l__tl_build_index_int > \c_max_register_int + \__tl_build_unpack: + \l__tl_build_index_int \l__tl_build_start_index_int \fi: } -\cs_new_protected:Npn \tl_build_one:x #1 - { \use:x { \tl_build_one:n {#1} } } +\cs_new_protected:Npn \__tl_build_one:x #1 + { \use:x { \__tl_build_one:n {#1} } } %% %% %% End of file `l3tl-build.sty'. diff --git a/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty b/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty index 0c88f04de5e..2eeee54d1ab 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty @@ -47,25 +47,25 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{xparse} -\GetIdInfo$Id: xcoffins.dtx 3483 2012-03-03 18:56:29Z bruno $ +\GetIdInfo$Id: xcoffins.dtx 3876 2012-06-30 15:35:39Z joseph $ {L3 Experimental design-level coffins} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \keys_define:nn { coffin } { - coffin1-hpole .tl_set:N = \l_coffin_A_hpole_tl , + coffin1-hpole .tl_set:N = \l__coffin_A_hpole_tl , coffin1-hpole .value_required: , - coffin1-vpole .tl_set:N = \l_coffin_A_vpole_tl , + coffin1-vpole .tl_set:N = \l__coffin_A_vpole_tl , coffin1-vpole .value_required: , - coffin2-hpole .tl_set:N = \l_coffin_B_hpole_tl , + coffin2-hpole .tl_set:N = \l__coffin_B_hpole_tl , coffin2-hpole .value_required: , - coffin2-vpole .tl_set:N = \l_coffin_B_vpole_tl , + coffin2-vpole .tl_set:N = \l__coffin_B_vpole_tl , coffin2-vpole .value_required: , - grow-bounding-box .bool_set:N = \l_coffin_bound_box_grow_bool , + grow-bounding-box .bool_set:N = \l__coffin_bound_box_grow_bool , grow-bounding-box .default:n = true , - hoffset .dim_set:N = \l_coffin_hoffset_dim , + hoffset .dim_set:N = \l__coffin_hoffset_dim , hoffset .value_required: , - voffset .dim_set:N = \l_coffin_voffset_dim , + voffset .dim_set:N = \l__coffin_voffset_dim , voffset .value_required: } \keys_set:nn { coffin } @@ -82,10 +82,10 @@ { \coffin_new:N #1 } \NewDocumentCommand \BoxToCoffin { m } { - \prop_clear_new:c { l_coffin_corners_ \int_value:w #1 _prop } - \prop_clear_new:c { l_coffin_poles_ \int_value:w #1 _prop } - \coffin_update_corners:N #1 - \coffin_update_poles:N #1 + \prop_clear_new:c { l__coffin_corners_ \__int_value:w #1 _prop } + \prop_clear_new:c { l__coffin_poles_ \__int_value:w #1 _prop } + \__coffin_update_corners:N #1 + \__coffin_update_poles:N #1 } \NewDocumentCommand \SetHorizontalCoffin { m +m } { \hcoffin_set:Nn #1 {#2} } @@ -115,22 +115,22 @@ { \group_begin: \keys_set:nn { coffin } {#1} - \tl_set:Nx \l_coffin_tmp_tl + \tl_set:Nx \l__coffin_tmp_tl { \group_end: - \bool_if:NTF \l_coffin_bound_box_grow_bool + \bool_if:NTF \l__coffin_bound_box_grow_bool { \coffin_join:NnnNnnnn } { \coffin_attach:NnnNnnnn } \exp_not:N #3 - { \exp_not:o { \l_coffin_A_hpole_tl } } - { \exp_not:o { \l_coffin_A_vpole_tl } } + { \exp_not:o { \l__coffin_A_hpole_tl } } + { \exp_not:o { \l__coffin_A_vpole_tl } } \exp_not:N #5 - { \exp_not:o { \l_coffin_B_hpole_tl } } - { \exp_not:o { \l_coffin_B_vpole_tl } } - { \dim_use:N \l_coffin_hoffset_dim } - { \dim_use:N \l_coffin_voffset_dim } + { \exp_not:o { \l__coffin_B_hpole_tl } } + { \exp_not:o { \l__coffin_B_vpole_tl } } + { \dim_use:N \l__coffin_hoffset_dim } + { \dim_use:N \l__coffin_voffset_dim } } - \l_coffin_tmp_tl + \l__coffin_tmp_tl } } \NewDocumentCommand \TypesetCoffin @@ -151,7 +151,7 @@ \NewDocumentCommand \CoffinHeight { m } { \coffin_ht:N #1 } \NewDocumentCommand \CoffinTotalHeight { m } - { \dim_eval:w \coffin_ht:N #1 + \coffin_dp:N #1 \dim_eval_end: } + { \__dim_eval:w \coffin_ht:N #1 + \coffin_dp:N #1 \__dim_eval_end: } \NewDocumentCommand \CoffinWidth { m } { \coffin_wd:N #1 } \NewDocumentCommand \DisplayCoffinHandles { m m } diff --git a/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty b/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty index cb77ed14d8f..dcf3c5871fc 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty @@ -48,18 +48,15 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{xparse} -\GetIdInfo$Id: l3galley.dtx 3325 2012-02-06 22:07:00Z joseph $ +\GetIdInfo$Id: l3galley.dtx 3918 2012-07-05 00:32:37Z bruno $ {L3 Experimental galley code} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} -\package_check_loaded_expl: -\cs_new_protected_nopar:Npn \galley_leave_vmode: - { \hbox_unpack:N \c_empty_box } -\clist_new:N \l_galley_parshape_left_indent_clist -\clist_new:N \l_galley_parshape_right_indent_clist -\bool_new:N \l_galley_parshape_multipar_bool -\bool_new:N \l_galley_parshape_resume_std_bool -\bool_new:N \l_galley_parshape_fixed_lines_bool +\clist_new:N \l__galley_parshape_left_indent_clist +\clist_new:N \l__galley_parshape_right_indent_clist +\bool_new:N \l__galley_parshape_multipar_bool +\bool_new:N \l__galley_parshape_resume_std_bool +\bool_new:N \l__galley_parshape_fixed_lines_bool \int_new:N \l_galley_parshape_std_lines_int \cs_new_eq:NN \l_galley_text_width_dim \linewidth \cs_new_eq:NN \l_galley_total_left_margin_dim \@totalleftmargin @@ -67,154 +64,154 @@ \int_new:N \l_galley_interpar_penalty_int \skip_new:N \l_galley_interpar_vspace_skip \cs_new_eq:NN \l_galley_width_dim \tex_hsize:D -\bool_new:N \g_galley_begin_level_bool -\bool_new:N \l_galley_begin_level_bool +\bool_new:N \g__galley_begin_level_bool +\bool_new:N \l__galley_begin_level_bool \bool_new:N \g_galley_omit_next_indent_bool -\bool_new:N \l_galley_omit_next_indent_bool -\bool_new:N \g_galley_parshape_set_bool -\bool_new:N \l_galley_parshape_set_bool -\bool_new:N \g_galley_nobreak_next_bool -\bool_new:N \l_galley_nobreak_next_bool +\bool_new:N \l__galley_omit_next_indent_bool +\bool_new:N \g__galley_parshape_set_bool +\bool_new:N \l__galley_parshape_set_bool +\bool_new:N \g_galley_no_break_next_bool +\bool_new:N \l__galley_no_break_next_bool \tl_new:N \g_galley_par_begin_hook_tl -\tl_new:N \l_galley_par_begin_hook_tl +\tl_new:N \l__galley_galley_par_begin_hook_tl \tl_new:N \g_galley_par_end_hook_tl -\tl_new:N \l_galley_par_end_hook_tl +\tl_new:N \l__galley_galley_par_end_hook_tl \tl_new:N \g_galley_par_after_hook_tl -\tl_new:N \l_galley_par_after_hook_tl +\tl_new:N \l__galley_par_after_hook_tl \int_new:N \g_galley_previous_par_lines_int -\int_new:N \l_galley_previous_par_lines_int +\int_new:N \l__galley_previous_par_lines_int \tl_new:N \g_galley_restore_running_tl -\tl_new:N \l_galley_restore_running_tl +\tl_new:N \l__galley_restore_running_tl \tl_new:N \g_galley_whatsit_next_tl -\tl_new:N \l_galley_whatsit_next_tl +\tl_new:N \l__galley_whatsit_next_tl \tl_new:N \g_galley_whatsit_previous_tl -\tl_new:N \l_galley_whatsit_previous_tl -\tl_new:N \g_galley_interpar_penalty_user_tl -\tl_new:N \l_galley_interpar_penalty_user_tl -\tl_new:N \g_galley_interpar_vspace_user_tl -\tl_new:N \l_galley_interpar_vspace_user_tl -\cs_new_protected_nopar:Npn \galley_initialise_variables: - { - \bool_gset_true:N \g_galley_begin_level_bool - \tl_gclear:N \g_galley_interpar_penalty_user_tl - \tl_gclear:N \g_galley_interpar_vspace_user_tl +\tl_new:N \l__galley_whatsit_previous_tl +\tl_new:N \g__galley_interpar_penalty_user_tl +\tl_new:N \l__galley_interpar_penalty_user_tl +\tl_new:N \g__galley_interpar_vspace_user_tl +\tl_new:N \l__galley_interpar_vspace_user_tl +\cs_new_protected_nopar:Npn \__galley_initialise_variables: + { + \bool_gset_true:N \g__galley_begin_level_bool + \tl_gclear:N \g__galley_interpar_penalty_user_tl + \tl_gclear:N \g__galley_interpar_vspace_user_tl \bool_gset_true:N \g_galley_omit_next_indent_bool - \bool_gset_false:N \g_galley_nobreak_next_bool + \bool_gset_false:N \g_galley_no_break_next_bool \tl_gclear:N \g_galley_par_begin_hook_tl \tl_gclear:N \g_galley_par_end_hook_tl \tl_gclear:N \g_galley_par_after_hook_tl - \bool_gset_false:N \g_galley_parshape_set_bool + \bool_gset_false:N \g__galley_parshape_set_bool \int_gzero:N \g_galley_previous_par_lines_int \tl_gclear:N \g_galley_restore_running_tl \tl_gclear:N \g_galley_whatsit_previous_tl \tl_gclear:N \g_galley_whatsit_next_tl } -\galley_initialise_variables: -\cs_new_protected_nopar:Npn \galley_initialise_settings: +\__galley_initialise_variables: +\cs_new_protected_nopar:Npn \__galley_initialise_settings: { \dim_set_eq:NN \l_galley_text_width_dim \l_galley_width_dim \dim_zero:N \l_galley_total_left_margin_dim \dim_zero:N \l_galley_total_right_margin_dim } -\cs_new_protected_nopar:Npn \galley_save_parameters: +\cs_new_protected_nopar:Npn \__galley_save_parameters: { - \bool_set_eq:NN \l_galley_begin_level_bool - \g_galley_begin_level_bool - \tl_set_eq:NN \l_galley_interpar_penalty_user_tl - \g_galley_interpar_penalty_user_tl - \tl_set_eq:NN \l_galley_interpar_vspace_user_tl - \g_galley_interpar_vspace_user_tl - \bool_set_eq:NN \l_galley_omit_next_indent_bool + \bool_set_eq:NN \l__galley_begin_level_bool + \g__galley_begin_level_bool + \tl_set_eq:NN \l__galley_interpar_penalty_user_tl + \g__galley_interpar_penalty_user_tl + \tl_set_eq:NN \l__galley_interpar_vspace_user_tl + \g__galley_interpar_vspace_user_tl + \bool_set_eq:NN \l__galley_omit_next_indent_bool \g_galley_omit_next_indent_bool - \bool_set_eq:NN \l_galley_nobreak_next_bool - \g_galley_nobreak_next_bool - \tl_set_eq:NN \l_galley_par_begin_hook_tl + \bool_set_eq:NN \l__galley_no_break_next_bool + \g_galley_no_break_next_bool + \tl_set_eq:NN \l__galley_galley_par_begin_hook_tl \g_galley_par_begin_hook_tl - \tl_set_eq:NN \l_galley_par_end_hook_tl + \tl_set_eq:NN \l__galley_galley_par_end_hook_tl \g_galley_par_end_hook_tl - \tl_set_eq:NN \l_galley_par_after_hook_tl + \tl_set_eq:NN \l__galley_par_after_hook_tl \g_galley_par_after_hook_tl - \bool_set_eq:NN \l_galley_parshape_set_bool - \g_galley_parshape_set_bool - \int_set_eq:NN \l_galley_previous_par_lines_int + \bool_set_eq:NN \l__galley_parshape_set_bool + \g__galley_parshape_set_bool + \int_set_eq:NN \l__galley_previous_par_lines_int \g_galley_previous_par_lines_int - \tl_set_eq:NN \l_galley_restore_running_tl + \tl_set_eq:NN \l__galley_restore_running_tl \g_galley_restore_running_tl - \tl_set_eq:NN \l_galley_whatsit_previous_tl + \tl_set_eq:NN \l__galley_whatsit_previous_tl \g_galley_whatsit_previous_tl - \tl_set_eq:NN \l_galley_whatsit_next_tl + \tl_set_eq:NN \l__galley_whatsit_next_tl \g_galley_whatsit_next_tl } -\cs_new_protected_nopar:Npn \galley_restore_parameters: +\cs_new_protected_nopar:Npn \__galley_restore_parameters: { - \bool_gset_eq:NN \g_galley_begin_level_bool - \l_galley_begin_level_bool - \tl_gset_eq:NN \g_galley_interpar_penalty_user_tl - \l_galley_interpar_penalty_user_tl - \tl_gset_eq:NN \g_galley_interpar_vspace_user_tl - \l_galley_interpar_vspace_user_tl + \bool_gset_eq:NN \g__galley_begin_level_bool + \l__galley_begin_level_bool + \tl_gset_eq:NN \g__galley_interpar_penalty_user_tl + \l__galley_interpar_penalty_user_tl + \tl_gset_eq:NN \g__galley_interpar_vspace_user_tl + \l__galley_interpar_vspace_user_tl \bool_gset_eq:NN \g_galley_omit_next_indent_bool - \l_galley_omit_next_indent_bool - \bool_gset_eq:NN \g_galley_nobreak_next_bool - \l_galley_nobreak_next_bool + \l__galley_omit_next_indent_bool + \bool_gset_eq:NN \g_galley_no_break_next_bool + \l__galley_no_break_next_bool \tl_gset_eq:NN \g_galley_par_begin_hook_tl - \l_galley_par_begin_hook_tl + \l__galley_galley_par_begin_hook_tl \tl_gset_eq:NN \g_galley_par_end_hook_tl - \l_galley_par_end_hook_tl + \l__galley_galley_par_end_hook_tl \tl_gset_eq:NN \g_galley_par_after_hook_tl - \l_galley_par_after_hook_tl - \bool_gset_eq:NN \g_galley_parshape_set_bool - \l_galley_parshape_set_bool + \l__galley_par_after_hook_tl + \bool_gset_eq:NN \g__galley_parshape_set_bool + \l__galley_parshape_set_bool \int_gset_eq:NN \g_galley_previous_par_lines_int - \l_galley_previous_par_lines_int + \l__galley_previous_par_lines_int \tl_gset_eq:NN \g_galley_restore_running_tl - \l_galley_restore_running_tl + \l__galley_restore_running_tl \tl_gset_eq:NN \g_galley_whatsit_previous_tl - \l_galley_whatsit_previous_tl + \l__galley_whatsit_previous_tl \tl_gset_eq:NN \g_galley_whatsit_next_tl - \l_galley_whatsit_next_tl + \l__galley_whatsit_next_tl } \cs_new_protected_nopar:Npn \galley_level: { - \galley_save_parameters: + \__galley_save_parameters: \group_begin: - \galley_initialise_variables: - \galley_initialise_settings: - \group_insert_after:N \galley_level_end: + \__galley_initialise_variables: + \__galley_initialise_settings: + \group_insert_after:N \__galley_level_end: } -\cs_new_protected_nopar:Npn \galley_level_end: +\cs_new_protected_nopar:Npn \__galley_level_end: { \par - \galley_restore_parameters: + \__galley_restore_parameters: \group_end: } -\scan_new:N \s_par_omit -\cs_new_protected_nopar:Npn \galley_std_par: +\__scan_new:N \s__par_omit +\cs_new_protected_nopar:Npn \__galley_std_par: { - \s_par_omit - \exp_after:wN \galley_std_par_aux_i: \tex_romannumeral:D - `0 + \s__par_omit + \exp_after:wN \__galley_std_par_aux_i: \tex_romannumeral:D - `0 } -\cs_new_protected:Npn \galley_std_par_aux_i: +\cs_new_protected:Npn \__galley_std_par_aux_i: { - \peek_meaning:NTF \s_par_omit - { \galley_std_par_aux:N } - { \galley_std_par_aux_ii: } + \peek_meaning:NTF \s__par_omit + { \__galley_std_par_aux:N } + { \__galley_std_par_aux_ii: } } -\cs_new_protected:Npn \galley_std_par_aux:N #1 +\cs_new_protected:Npn \__galley_std_par_aux:N #1 { - \str_if_eq:xxF {#1} { \s_par_omit } + \str_if_eq_x:nnF {#1} { \s__par_omit } { - \galley_std_par_aux_ii: + \__galley_std_par_aux_ii: #1 } } -\cs_new_protected_nopar:Npn \galley_std_par_aux_ii: +\cs_new_protected_nopar:Npn \__galley_std_par_aux_ii: { \mode_if_vertical:TF { \tex_par:D } { \g_galley_par_end_hook_tl - \galley_set_measure_and_parshape: + \__galley_set_measure_and_parshape: \group_begin: \tex_par:D \group_end: @@ -224,33 +221,33 @@ \tl_gclear:N \g_galley_par_after_hook_tl \tex_penalty:D \c_ten_thousand } -\cs_new_protected:Npn \galley_end_par:n #1 +\cs_new_protected:Npn \__galley_end_par:n #1 { - \s_par_omit - \bool_if:nF \g_galley_begin_level_bool + \s__par_omit + \bool_if:nF \g__galley_begin_level_bool { #1 - \galley_std_par: + \__galley_std_par: } } -\cs_set_protected_nopar:Npn \par { \galley_std_par: } -\tl_set:Nn \@par { \galley_std_par: } +\cs_set_protected_nopar:Npn \par { \__galley_std_par: } +\tl_set:Nn \@par { \__galley_std_par: } \cs_new_protected_nopar:Npn \galley_display_begin: { \group_begin: - \galley_save_parameters: + \__galley_save_parameters: \mode_if_vertical:TF { - \galley_display_penalty:N \l_galley_display_begin_par_penalty_tl - \galley_display_vspace:N \l_galley_display_begin_par_vspace_tl + \__galley_display_penalty:N \l_galley_display_begin_par_penalty_tl + \__galley_display_vspace:N \l_galley_display_begin_par_vspace_tl } { - \galley_display_penalty:N \l_galley_display_begin_penalty_tl - \galley_display_vspace:N \l_galley_display_begin_vspace_tl + \__galley_display_penalty:N \l_galley_display_begin_penalty_tl + \__galley_display_vspace:N \l_galley_display_begin_vspace_tl } \par } -\cs_new_protected:Npn \galley_display_penalty:N #1 +\cs_new_protected:Npn \__galley_display_penalty:N #1 { \tl_if_empty:NF #1 { @@ -262,7 +259,7 @@ \int_gset:Nn \g_galley_penalty_int {#1} } } -\cs_new_protected:Npn \galley_display_vspace:N #1 +\cs_new_protected:Npn \__galley_display_vspace:N #1 { \tl_if_empty:NF #1 { @@ -277,34 +274,34 @@ \cs_new_protected_nopar:Npn \galley_display_end: { \par - \galley_restore_parameters: + \__galley_restore_parameters: \group_end: \group_insert_after:N \group_insert_after:N - \group_insert_after:N \galley_display_par_setup: + \group_insert_after:N \__galley_display_par_setup: } -\cs_new_protected_nopar:Npn \galley_display_par_setup: +\cs_new_protected_nopar:Npn \__galley_display_par_setup: { \bool_gset_false:N \g_galley_omit_next_indent_bool - \cs_set_eq:NN \par \galley_display_par: + \cs_set_eq:NN \par \__galley_display_par: } -\cs_new_protected_nopar:Npn \galley_display_par: +\cs_new_protected_nopar:Npn \__galley_display_par: { - \cs_set_eq:NN \par \galley_std_par: + \cs_set_eq:NN \par \__galley_std_par: \mode_if_vertical:TF { \par \bool_gset_false:N \g_galley_omit_next_indent_bool - \galley_display_penalty:N \l_galley_display_end_par_penalty_tl - \galley_display_vspace:N \l_galley_display_end_par_vspace_tl + \__galley_display_penalty:N \l_galley_display_end_par_penalty_tl + \__galley_display_vspace:N \l_galley_display_end_par_vspace_tl } { - \galley_set_measure_and_parshape: + \__galley_set_measure_and_parshape: \group_begin: \tex_par:D \group_end: \int_gadd:Nn \g_galley_previous_par_lines_int \tex_prevgraf:D - \galley_display_penalty:N \l_galley_display_end_penalty_tl - \galley_display_vspace:N \l_galley_display_end_vspace_tl + \__galley_display_penalty:N \l_galley_display_end_penalty_tl + \__galley_display_vspace:N \l_galley_display_end_vspace_tl } } \cs_undefine:N \everypar @@ -313,84 +310,84 @@ { \tex_everypar:D { - \bool_if:NTF \g_galley_begin_level_bool - { \galley_start_paragraph_first: } - { \galley_start_paragraph_std: } + \bool_if:NTF \g__galley_begin_level_bool + { \__galley_start_paragraph_first: } + { \__galley_start_paragraph_std: } \tex_the:D \everypar } } -\box_new:N \g_galley_last_box -\cs_new_protected_nopar:Npn \galley_start_paragraph_std: +\box_new:N \g__galley_last_box +\cs_new_protected_nopar:Npn \__galley_start_paragraph_std: { \group_begin: - \box_gset_to_last:N \g_galley_last_box + \box_gset_to_last:N \g__galley_last_box \tex_par:D - \galley_insert_vertical_items: + \__galley_insert_vertical_items: \tex_everypar:D { } \tex_noindent:D \group_end: \int_gzero:N \g_galley_previous_par_lines_int - \galley_insert_horizontal_items: - \galley_restore_running_parameters: + \__galley_insert_horizontal_items: + \__galley_restore_running_parameters: } -\cs_new_protected_nopar:Npn \galley_start_paragraph_first: +\cs_new_protected_nopar:Npn \__galley_start_paragraph_first: { - \bool_gset_false:N \g_galley_begin_level_bool + \bool_gset_false:N \g__galley_begin_level_bool \mode_if_horizontal:TF { \group_begin: - \box_gset_to_last:N \g_galley_last_box + \box_gset_to_last:N \g__galley_last_box \tex_par:D - \galley_insert_vspace: + \__galley_insert_vspace: \tex_everypar:D { } \tex_noindent:D \group_end: } - { \galley_insert_vspace: } - \galley_insert_horizontal_items: - \galley_restore_running_parameters: + { \__galley_insert_vspace: } + \__galley_insert_horizontal_items: + \__galley_restore_running_parameters: } -\cs_new_protected_nopar:Npn \galley_insert_vertical_items: +\cs_new_protected_nopar:Npn \__galley_insert_vertical_items: { \g_galley_whatsit_previous_tl \tl_gclear:N \g_galley_whatsit_previous_tl - \tl_if_empty:NTF \g_galley_interpar_penalty_user_tl + \tl_if_empty:NTF \g__galley_interpar_penalty_user_tl { - \bool_if:NTF \g_galley_nobreak_next_bool + \bool_if:NTF \g_galley_no_break_next_bool { \tex_penalty:D \c_ten_thousand } { \tex_penalty:D \l_galley_interpar_penalty_int } } { \tex_penalty:D - \int_eval:w \g_galley_interpar_penalty_user_tl \int_eval_end: - \tl_gclear:N \g_galley_interpar_penalty_user_tl + \__int_eval:w \g__galley_interpar_penalty_user_tl \__int_eval_end: + \tl_gclear:N \g__galley_interpar_penalty_user_tl } - \bool_gset_false:N \g_galley_nobreak_next_bool - \galley_insert_vspace: + \bool_gset_false:N \g_galley_no_break_next_bool + \__galley_insert_vspace: } -\cs_new_protected_nopar:Npn \galley_insert_vspace: +\cs_new_protected_nopar:Npn \__galley_insert_vspace: { - \tl_if_empty:NTF \g_galley_interpar_vspace_user_tl + \tl_if_empty:NTF \g__galley_interpar_vspace_user_tl { \skip_vertical:N \l_galley_interpar_vspace_skip } { - \skip_vertical:n { \g_galley_interpar_vspace_user_tl } - \tl_gclear:N \g_galley_interpar_vspace_user_tl + \skip_vertical:n { \g__galley_interpar_vspace_user_tl } + \tl_gclear:N \g__galley_interpar_vspace_user_tl } } -\cs_new_protected_nopar:Npn \galley_insert_horizontal_items: +\cs_new_protected_nopar:Npn \__galley_insert_horizontal_items: { \g_galley_whatsit_next_tl \tl_gclear:N \g_galley_whatsit_next_tl \bool_if:NF \g_galley_omit_next_indent_bool { - \box_if_empty:NF \g_galley_last_box + \box_if_empty:NF \g__galley_last_box { \hbox_to_wd:nn \l_galley_par_indent_dim { } } } \skip_horizontal:N \l_galley_par_begin_skip \g_galley_par_begin_hook_tl \bool_gset_false:N \g_galley_omit_next_indent_bool } -\cs_new_protected_nopar:Npn \galley_restore_running_parameters: +\cs_new_protected_nopar:Npn \__galley_restore_running_parameters: { \g_galley_restore_running_tl \tl_gclear:N \g_galley_restore_running_tl @@ -419,50 +416,50 @@ } \cs_new_protected:Npn \galley_parshape_fixed_lines:nnn #1#2#3 { - \bool_gset_true:N \g_galley_parshape_set_bool - \bool_set_true:N \l_galley_parshape_fixed_lines_bool + \bool_gset_true:N \g__galley_parshape_set_bool + \bool_set_true:N \l__galley_parshape_fixed_lines_bool \int_set:Nn \l_galley_parshape_std_lines_int {#1} - \clist_set:Nn \l_galley_parshape_left_indent_clist {#2} - \clist_set:Nn \l_galley_parshape_right_indent_clist {#3} - \bool_set_true:N \l_galley_parshape_resume_std_bool + \clist_set:Nn \l__galley_parshape_left_indent_clist {#2} + \clist_set:Nn \l__galley_parshape_right_indent_clist {#3} + \bool_set_true:N \l__galley_parshape_resume_std_bool } \cs_new_protected:Npn \galley_parshape_multi_par:nnnN #1#2#3#4 { - \bool_gset_true:N \g_galley_parshape_set_bool - \bool_set_true:N \l_galley_parshape_multipar_bool - \bool_set_false:N \l_galley_parshape_fixed_lines_bool + \bool_gset_true:N \g__galley_parshape_set_bool + \bool_set_true:N \l__galley_parshape_multipar_bool + \bool_set_false:N \l__galley_parshape_fixed_lines_bool \int_set:Nn \l_galley_parshape_std_lines_int {#1} - \clist_set:Nn \l_galley_parshape_left_indent_clist {#2} - \clist_set:Nn \l_galley_parshape_right_indent_clist {#3} - \bool_set_eq:NN \l_galley_parshape_resume_std_bool #4 + \clist_set:Nn \l__galley_parshape_left_indent_clist {#2} + \clist_set:Nn \l__galley_parshape_right_indent_clist {#3} + \bool_set_eq:NN \l__galley_parshape_resume_std_bool #4 } \cs_new_protected:Npn \galley_parshape_single_par:nnnN #1#2#3#4 { - \bool_gset_true:N \g_galley_parshape_set_bool - \bool_set_false:N \l_galley_parshape_multipar_bool - \bool_set_false:N \l_galley_parshape_fixed_lines_bool + \bool_gset_true:N \g__galley_parshape_set_bool + \bool_set_false:N \l__galley_parshape_multipar_bool + \bool_set_false:N \l__galley_parshape_fixed_lines_bool \int_set:Nn \l_galley_parshape_std_lines_int {#1} - \clist_set:Nn \l_galley_parshape_left_indent_clist {#2} - \clist_set:Nn \l_galley_parshape_right_indent_clist {#3} - \bool_set_eq:NN \l_galley_parshape_resume_std_bool #4 + \clist_set:Nn \l__galley_parshape_left_indent_clist {#2} + \clist_set:Nn \l__galley_parshape_right_indent_clist {#3} + \bool_set_eq:NN \l__galley_parshape_resume_std_bool #4 } \cs_generate_variant:Nn \galley_parshape_fixed_lines:nnn { nVV } \cs_generate_variant:Nn \galley_parshape_multi_par:nnnN { nVV } \cs_generate_variant:Nn \galley_parshape_single_par:nnnN { nVV } -\cs_new_protected_nopar:Npn \galley_set_measure_and_parshape: +\cs_new_protected_nopar:Npn \__galley_set_measure_and_parshape: { - \bool_if:NTF \g_galley_parshape_set_bool + \bool_if:NTF \g__galley_parshape_set_bool { - \bool_if:NTF \l_galley_parshape_fixed_lines_bool + \bool_if:NTF \l__galley_parshape_fixed_lines_bool { \int_compare:nNnTF \g_galley_previous_par_lines_int > \c_zero - { \galley_generate_parshape_lines: } - { \galley_generate_parshape: } + { \__galley_generate_parshape_lines: } + { \__galley_generate_parshape: } } { - \bool_gset_eq:NN \g_galley_parshape_set_bool - \l_galley_parshape_multipar_bool - \galley_generate_parshape: + \bool_gset_eq:NN \g__galley_parshape_set_bool + \l__galley_parshape_multipar_bool + \__galley_generate_parshape: } } { @@ -473,16 +470,16 @@ \dim_use:N \l_galley_text_width_dim } } -\cs_new_protected_nopar:Npn \galley_generate_parshape: +\cs_new_protected_nopar:Npn \__galley_generate_parshape: { \tex_global:D \tex_parshape:D - \int_eval:w + \__int_eval:w \l_galley_parshape_std_lines_int + \int_min:nn - { \clist_length:N \l_galley_parshape_left_indent_clist } - { \clist_length:N \l_galley_parshape_right_indent_clist } - \bool_if:NT \l_galley_parshape_resume_std_bool { + 1 } - \int_eval_end: + { \clist_count:N \l__galley_parshape_left_indent_clist } + { \clist_count:N \l__galley_parshape_right_indent_clist } + \bool_if:NT \l__galley_parshape_resume_std_bool { + 1 } + \__int_eval_end: \prg_replicate:nn \l_galley_parshape_std_lines_int { \dim_use:N \l_galley_total_left_margin_dim @@ -490,10 +487,10 @@ \dim_use:N \l_galley_text_width_dim \c_space_tl } - \galley_set_parshape_map:oo - \l_galley_parshape_left_indent_clist - \l_galley_parshape_right_indent_clist - \bool_if:NT \l_galley_parshape_resume_std_bool + \__galley_set_parshape_map:oo + \l__galley_parshape_left_indent_clist + \l__galley_parshape_right_indent_clist + \bool_if:NT \l__galley_parshape_resume_std_bool { \c_space_tl \dim_use:N \l_galley_total_left_margin_dim @@ -501,10 +498,10 @@ \dim_use:N \l_galley_text_width_dim } } -\cs_new:Npn \galley_set_parshape_map:nn #1#2 - { \galley_set_parshape_map_aux:nw { } #1 , \q_mark #2 , \q_stop } -\cs_generate_variant:Nn \galley_set_parshape_map:nn { oo } -\cs_new:Npn \galley_set_parshape_map_aux:nw #1#2 , #3 \q_mark #4 , #5 \q_stop +\cs_new:Npn \__galley_set_parshape_map:nn #1#2 + { \__galley_set_parshape_map_aux:nw { } #1 , \q_mark #2 , \q_stop } +\cs_generate_variant:Nn \__galley_set_parshape_map:nn { oo } +\cs_new:Npn \__galley_set_parshape_map_aux:nw #1#2 , #3 \q_mark #4 , #5 \q_stop { \bool_if:nTF { \tl_if_empty_p:n {#3} || \tl_if_empty_p:n {#5} } { @@ -514,7 +511,7 @@ \dim_eval:n { \l_galley_text_width_dim - ( ( #2 ) + ( #4 ) ) } } { - \galley_set_parshape_map_aux:nw + \__galley_set_parshape_map_aux:nw { #1 \dim_eval:n { \l_galley_total_left_margin_dim + ( #2 ) } @@ -525,19 +522,19 @@ #3 \q_mark #5 \q_stop } } -\cs_new_protected_nopar:Npn \galley_generate_parshape_lines: +\cs_new_protected_nopar:Npn \__galley_generate_parshape_lines: { \int_compare:nNnTF \tex_parshape:D > \g_galley_previous_par_lines_int { \tex_global:D \tex_parshape:D - \int_eval:w \tex_parshape:D - \g_galley_previous_par_lines_int - \int_eval_end: - \prg_stepwise_function:nnnN + \__int_eval:w \tex_parshape:D - \g_galley_previous_par_lines_int + \__int_eval_end: + \int_step_function:nnnN { \g_galley_previous_par_lines_int + \c_one } - \c_one \tex_parshape:D \galley_generate_parshape_lines_aux:n + \c_one \tex_parshape:D \__galley_generate_parshape_lines:n } { - \bool_gset_false:N \g_galley_parshape_set_bool + \bool_gset_false:N \g__galley_parshape_set_bool \tex_global:D \tex_parshape:D \c_one \dim_use:N \l_galley_total_left_margin_dim @@ -545,16 +542,16 @@ \dim_use:N \l_galley_text_width_dim } } -\cs_new:Npn \galley_generate_parshape_lines_aux:n #1 +\cs_new:Npn \__galley_generate_parshape_lines:n #1 { \etex_parshapeindent:D #1 ~ \etex_parshapelength:D #1 } \cs_new_protected:Npn \galley_set_user_penalty:n #1 - { \tl_gset:Nx \g_galley_interpar_penalty_user_tl { \int_eval:n {#1} } } + { \tl_gset:Nx \g__galley_interpar_penalty_user_tl { \int_eval:n {#1} } } \cs_new_protected:Npn \galley_set_user_vspace:n #1 - { \tl_gset:Nx \g_galley_interpar_vspace_user_tl { \skip_eval:n {#1} } } + { \tl_gset:Nx \g__galley_interpar_vspace_user_tl { \skip_eval:n {#1} } } \dim_set:Nn \parskip \c_zero_dim \cs_undefine:N \parskip \skip_new:N \parskip @@ -591,7 +588,7 @@ \cs_new_protected:Npn \galley_break_line:Nn #1#2 { \mode_if_vertical:TF - { \msg_kernel_error:nn { galley } { no-line-to-end } } + { \__msg_kernel_error:nn { galley } { no-line-to-end } } { \tex_unskip:D \bool_if:NF #1 @@ -614,7 +611,7 @@ \cs_new_protected:Npn \galley_set_display_widow_penalties:n #1 { \etex_displaywidowpenalties:D - \int_eval:w \clist_length:n {#1} + \c_one \int_eval_end: + \__int_eval:w \clist_count:n {#1} + \c_one \__int_eval_end: \clist_map_function:nN {#1} \galley_set_aux:n \c_zero } @@ -622,7 +619,7 @@ \cs_new_protected:Npn \galley_set_widow_penalties:n #1 { \etex_widowpenalties:D - \int_eval:w \clist_length:n {#1} + \c_one \int_eval_end: + \__int_eval:w \clist_count:n {#1} + \c_one \__int_eval_end: \clist_map_function:nN {#1} \galley_set_aux:n \c_zero } @@ -631,107 +628,105 @@ \cs_new_protected:Npn \galley_set_club_penalties:n #1 { \clist_set:Nn \l_galley_club_penalties_clist {#1} - \galley_calc_interline_penalties: + \__galley_calc_interline_penalties: } \cs_generate_variant:Nn \galley_set_club_penalties:n { V , v } \cs_new_protected:Npn \galley_set_interline_penalties:n #1 { \clist_set:Nn \l_galley_line_penalties_clist {#1} - \galley_calc_interline_penalties: + \__galley_calc_interline_penalties: } \cs_generate_variant:Nn \galley_set_interline_penalties:n { V , v } \cs_new_protected:Npn \galley_set_display_club_penalties:n #1 { \etex_clubpenalties:D - \int_eval:w \clist_length:n {#1} + \c_one \int_eval_end: + \__int_eval:w \clist_count:n {#1} + \c_one \__int_eval_end: \clist_map_function:nN {#1} \galley_set_aux:n \c_zero - \galley_calc_interline_penalties: + \__galley_calc_interline_penalties: } \cs_generate_variant:Nn \galley_set_display_club_penalties:n { V , v } \cs_new_protected:Npn \galley_set_interline_penalty:n #1 { \int_compare:nNnTF { \etex_interlinepenalties:D \c_zero } = \c_zero { - \etex_interlinepenalties:D \c_one \int_eval:w #1 \int_eval_end: - \galley_calc_interline_penalties: + \etex_interlinepenalties:D \c_one \__int_eval:w #1 \__int_eval_end: + \__galley_calc_interline_penalties: } { - \cs_set:Npn \galley_set_interline_penalty_aux_ii:n ##1 + \cs_set:Npn \__galley_set_interline_penalty_ii:n ##1 { - \int_eval:w + \__int_eval:w \etex_interlinepenalties:D ##1 - \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero + #1 - \int_eval_end: + \__int_eval_end: } - \exp_args:Nf \galley_set_interline_penalty_aux:nn - { \clist_length:N \l_galley_line_penalties_clist } {#1} + \exp_args:Nf \__galley_set_interline_penalty:nn + { \clist_count:N \l_galley_line_penalties_clist } {#1} } } -\cs_new_protected:Npn \galley_set_interline_penalty_aux:nn #1#2 +\cs_new_protected:Npn \__galley_set_interline_penalty:nn #1#2 { \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero - \prg_stepwise_function:nnnN \c_one \c_one {#1} - \galley_set_interline_penalty_aux_i:n - \prg_stepwise_function:nnnN { #1 + \c_one } \c_one + \int_step_function:nnnN \c_one \c_one {#1} + \__galley_set_interline_penalty_i:n + \int_step_function:nnnN { #1 + \c_one } \c_one { \etex_interlinepenalties:D \c_zero - \c_one } - \galley_set_interline_penalty_aux_ii:n - \int_eval:w #2 \int_eval_end: + \__galley_set_interline_penalty_ii:n + \__int_eval:w #2 \__int_eval_end: } -\cs_new:Npn \galley_set_interline_penalty_aux_i:n #1 - { \etex_interlinepenalties:D \int_eval:w #1 \int_eval_end: } -\cs_new:Npn \galley_set_interline_penalty_aux_ii:n #1 { } -\cs_new_protected_nopar:Npn \galley_calc_interline_penalties: +\cs_new:Npn \__galley_set_interline_penalty_i:n #1 + { \etex_interlinepenalties:D \__int_eval:w #1 \__int_eval_end: } +\cs_new:Npn \__galley_set_interline_penalty_ii:n #1 { } +\cs_new_protected_nopar:Npn \__galley_calc_interline_penalties: { - \exp_args:Nff \galley_calc_interline_penalties_aux:nn + \exp_args:Nff \__galley_calc_interline_penalties:nn { \int_eval:n { \int_max:nn { - \clist_length:N \l_galley_club_penalties_clist + \clist_count:N \l_galley_club_penalties_clist + \c_one } { \int_max:nn { - \clist_length:N \l_galley_line_penalties_clist + \clist_count:N \l_galley_line_penalties_clist + \c_one } { \etex_clubpenalties:D \c_zero } } } } - { \clist_length:N \l_galley_line_penalties_clist } + { \clist_count:N \l_galley_line_penalties_clist } } -\cs_new_protected:Npn \galley_calc_interline_penalties_aux:nn #1#2 +\cs_new_protected:Npn \__galley_calc_interline_penalties:nn #1#2 { \etex_interlinepenalties:D #1 ~ - \prg_stepwise_function:nnnN \c_one \c_one {#2} - \galley_calc_interline_penalties_aux_i:n - \prg_stepwise_function:nnnN { #2 + \c_one } \c_one { #1 - \c_one } - \galley_calc_interline_penalties_aux_ii:n + \int_step_function:nnnN \c_one \c_one {#2} + \__galley_calc_interline_penalties_i:n + \int_step_function:nnnN { #2 + \c_one } \c_one { #1 - \c_one } + \__galley_calc_interline_penalties_ii:n \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero } -\cs_new:Npn \galley_calc_interline_penalties_aux_i:n #1 +\cs_new:Npn \__galley_calc_interline_penalties_i:n #1 { - \int_eval:w - \clist_item:Nn \l_galley_line_penalties_clist { #1 - \c_one } - + 0 \clist_item:Nn \l_galley_club_penalties_clist - { #1 - \c_one } + \__int_eval:w + \clist_item:Nn \l_galley_line_penalties_clist {#1} + + 0 \clist_item:Nn \l_galley_club_penalties_clist {#1} - \etex_clubpenalties:D #1 ~ - \int_eval_end: + \__int_eval_end: } -\cs_new:Npn \galley_calc_interline_penalties_aux_ii:n #1 +\cs_new:Npn \__galley_calc_interline_penalties_ii:n #1 { - \int_eval:w + \__int_eval:w \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero - + 0 \clist_item:Nn \l_galley_club_penalties_clist - { #1 - \c_one } + + 0 \clist_item:Nn \l_galley_club_penalties_clist {#1} - \etex_clubpenalties:D #1 ~ - \int_eval_end: + \__int_eval_end: } \cs_new_protected:Npn \galley_save_club_penalties:N #1 { \clist_set_eq:NN #1 \l_galley_club_penalties_clist } @@ -741,38 +736,38 @@ { \clist_set:Nx #1 { - \prg_stepwise_function:nnnN \c_one \c_one + \int_step_function:nnnN \c_one \c_one { \etex_clubpenalties:D \c_zero - \c_one } \galley_save_display_club_penalties:_aux:n } } \cs_new:Npn \galley_save_display_club_penalties:_aux:n #1 - { \int_use:N \etex_clubpenaltes:D \int_eval:w #1 \int_eval_end: , } + { \int_use:N \etex_clubpenaltes:D \__int_eval:w #1 \__int_eval_end: , } \cs_new_protected:Npn \galley_save_display_widow_penalties:N #1 { \clist_set:Nx #1 { - \prg_stepwise_function:nnnN \c_one \c_one + \int_step_function:nnnN \c_one \c_one { \etex_displaywidowpenalties:D \c_zero - \c_one } \galley_save_display_widow_penalties:_aux:n } } \cs_new:Npn \galley_save_display_widow_penalties:_aux:n #1 - { \int_use:N \etex_displaywidowpenalties:D \int_eval:w #1 \int_eval_end: , } + { \int_use:N \etex_displaywidowpenalties:D \__int_eval:w #1 \__int_eval_end: , } \cs_new_protected:Npn \galley_save_widow_penalties:N #1 { \clist_set:Nx #1 { - \prg_stepwise_function:nnnN \c_one \c_one + \int_step_function:nnnN \c_one \c_one { \etex_widowpenalties:D \c_zero - \c_one } \galley_save_widow_penalties:_aux:n } } \cs_new:Npn \galley_save_widow_penalties:_aux:n #1 - { \int_use:N \etex_widowpenalties:D \int_eval:w #1 \int_eval_end: , } + { \int_use:N \etex_widowpenalties:D \__int_eval:w #1 \__int_eval_end: , } \cs_new_protected_nopar:Npn \galley_interline_penalty: { \int_use:N \etex_interlinepenalties:D \etex_interlinepenalties:D \c_zero } -\msg_kernel_new:nnn { galley } { no-line-to-end } +\__msg_kernel_new:nnn { galley } { no-line-to-end } { There's~no~line~here~to~end. } \RenewDocumentCommand \clearpage { } { @@ -807,7 +802,7 @@ { \galley_break_line:Nn #1 {#2} } \RenewDocumentCommand \newline { } { \galley_break_line:Nn \c_true_bool { 0 pt } } -\cs_set_eq:NN \@@par \galley_std_par: +\cs_set_eq:NN \__galleypar \__galley_std_par: \cs_set_protected_nopar:Npn \@afterheading { \bool_gset_true:N \g_galley_no_break_next_bool diff --git a/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty b/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty index 3e3d251791a..31fe465cef3 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty @@ -48,13 +48,13 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{l3names} -\GetIdInfo$Id: xgalley.dtx 3253 2012-01-28 14:59:55Z joseph $ +\GetIdInfo$Id: xgalley.dtx 3879 2012-07-01 09:17:47Z joseph $ {L3 Experimental galley} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{xparse,xtemplate,l3galley} -\clist_new:N \l_galley_tmpa_clist -\clist_new:N \l_galley_tmpb_clist +\clist_new:N \l__galley_tmpa_clist +\clist_new:N \l__galley_tmpb_clist \DeclareObjectType { measure } { 0 } \DeclareTemplateInterface { measure } { absolute } { 0 } { @@ -66,27 +66,27 @@ left-margin : length = 0 pt , right-margin : length = 0 pt } -\cs_new_eq:NN \l_galley_left_margin_dim \leftmargin -\cs_new_eq:NN \l_galley_right_margin_dim \rightmargin +\cs_new_eq:NN \l__galley_left_margin_dim \leftmargin +\cs_new_eq:NN \l__galley_right_margin_dim \rightmargin \DeclareTemplateCode { measure } { absolute } { 0 } { - left-margin = \l_galley_left_margin_dim , - right-margin = \l_galley_right_margin_dim + left-margin = \l__galley_left_margin_dim , + right-margin = \l__galley_right_margin_dim } { \AssignTemplateKeys - \galley_margins_set_absolute:nn \l_galley_left_margin_dim - \l_galley_right_margin_dim + \galley_margins_set_absolute:nn \l__galley_left_margin_dim + \l__galley_right_margin_dim } \DeclareTemplateCode { measure } { relative } { 0 } { - left-margin = \l_galley_left_margin_dim , - right-margin = \l_galley_right_margin_dim + left-margin = \l__galley_left_margin_dim , + right-margin = \l__galley_right_margin_dim } { \AssignTemplateKeys - \galley_margins_set_relative:nn \l_galley_left_margin_dim - \l_galley_right_margin_dim + \galley_margins_set_relative:nn \l__galley_left_margin_dim + \l__galley_right_margin_dim } \DeclareObjectType { parshape } { 0 } \DeclareTemplateInterface { parshape } { hang } { 0 } @@ -103,58 +103,58 @@ } \DeclareTemplateCode { parshape } { hang } { 0 } { - indent = \l_galley_parshape_indent_dim , - on-left-side = \l_galley_parshape_on_left_bool , - lines = \l_galley_parshape_lines_int + indent = \l__galley_parshape_indent_dim , + on-left-side = \l__galley_parshape_on_left_bool , + lines = \l__galley_parshape_lines_int } { \AssignTemplateKeys - \bool_if:NTF \l_galley_parshape_on_left_bool + \bool_if:NTF \l__galley_parshape_on_left_bool { \galley_parshape_single_par:nVVN - \l_galley_parshape_lines_int - \l_galley_parshape_indent_dim + \l__galley_parshape_lines_int + \l__galley_parshape_indent_dim \c_zero_dim \c_false_bool } { \galley_parshape_single_par:nVVN - \l_galley_parshape_lines_int + \l__galley_parshape_lines_int \c_zero_dim - \l_galley_parshape_indent_dim + \l__galley_parshape_indent_dim \c_false_bool } } \DeclareTemplateCode { parshape } { initial } { 0 } { - indent = \l_galley_parshape_indent_dim , - on-left-side = \l_galley_parshape_on_left_bool , - lines = \l_galley_parshape_lines_int + indent = \l__galley_parshape_indent_dim , + on-left-side = \l__galley_parshape_on_left_bool , + lines = \l__galley_parshape_lines_int } { \AssignTemplateKeys - \clist_clear:N \l_galley_tmpa_clist - \clist_clear:N \l_galley_tmpb_clist - \prg_replicate:nn { \l_galley_parshape_lines_int } + \clist_clear:N \l__galley_tmpa_clist + \clist_clear:N \l__galley_tmpb_clist + \prg_replicate:nn { \l__galley_parshape_lines_int } { - \clist_put_right:Nn \l_galley_tmpa_clist - { \l_galley_parshape_indent_dim } - \clist_put_right:Nn \l_galley_tmpb_clist + \clist_put_right:Nn \l__galley_tmpa_clist + { \l__galley_parshape_indent_dim } + \clist_put_right:Nn \l__galley_tmpb_clist { \c_zero_dim } } - \bool_if:NTF \l_galley_parshape_on_left_bool + \bool_if:NTF \l__galley_parshape_on_left_bool { \galley_parshape_single_par:nVVN \c_zero - \l_galley_tmpa_clist - \l_galley_tmpb_clist + \l__galley_tmpa_clist + \l__galley_tmpb_clist \c_true_bool } { \galley_parshape_single_par:nVVN \c_zero - \l_galley_tmpb_clist - \l_galley_tmpa_clist + \l__galley_tmpb_clist + \l__galley_tmpa_clist \c_true_bool } } @@ -207,7 +207,7 @@ } \UseTemplate { hyphenation } { std } { } \tex_defaulthyphenchar:D 45 \scan_stop: -\tl_new:N \l_galley_justification_other_tl +\tl_new:N \l__galley_justification_other_tl \DeclareObjectType { justification } { 0 } \DeclareTemplateInterface { justification } { std } { 0 } { @@ -241,7 +241,7 @@ } { \AssignTemplateKeys - \tl_clear:N \l_galley_justification_other_tl + \tl_clear:N \l__galley_justification_other_tl \galley_set_interword_spacing:N \l_galley_fixed_spacing_bool \bool_if:NTF \l_galley_par_stretch_last_bool { \int_set_eq:NN \l_galley_last_line_fit_int \c_one_thousand } @@ -259,7 +259,7 @@ stretch-last-line = \l_galley_par_stretch_last_bool } { - \tl_put_left:Nx \l_galley_justification_other_tl + \tl_put_left:Nx \l__galley_justification_other_tl { \skip_set:Nn \exp_not:N \l_galley_par_end_skip { \skip_use:N \l_galley_par_end_skip } @@ -282,7 +282,7 @@ { \skip_use:N \l_galley_line_right_skip } } \tl_gput_right:Nn \g_galley_restore_running_tl - { \l_galley_justification_other_tl } + { \l__galley_justification_other_tl } \AssignTemplateKeys \galley_set_interword_spacing:N \l_galley_fixed_spacing_bool \bool_if:NTF \l_galley_par_stretch_last_bool @@ -337,16 +337,16 @@ } \DeclareTemplateCode { justification } { compound } { 0 } { - first-paragraph = \galley_justification_first: , - other-paragraphs = \galley_justification_other: + first-paragraph = \__galley_justification_first: , + other-paragraphs = \__galley_justification_other: } { \AssignTemplateKeys - \galley_justification_first: - \tl_set:Nn \l_galley_justification_other_tl - { \galley_justification_other: } + \__galley_justification_first: + \tl_set:Nn \l__galley_justification_other_tl + { \__galley_justification_other: } \tl_gput_right:Nn \g_galley_restore_running_tl - { \l_galley_justification_other_tl } + { \l__galley_justification_other_tl } } \DeclareObjectType { line-breaking } { 0 } \DeclareTemplateInterface { line-breaking } { std } { 0 } @@ -366,15 +366,15 @@ \DeclareTemplateCode{ line-breaking } { std } { 0 } { badness = \l_galley_linebreak_badness_int , - binop-penalty = \l_galley_binop_penalty_int , + binop-penalty = \l__galley_binop_penalty_int , double-hyphen-demerits = \l_galley_double_hyphen_demerits_int , emergency-stretch = \l_galley_emergency_stretch_skip , final-hyphen-demerits = \l_galley_final_hyphen_demerits_int , fuzz = \l_galley_linebreak_fuzz_dim , - line-penalty = \l_galley_linebreak_penalty_int , + line-penalty = \l__galley_linebreak_penalty_int , mismatch-demerits = \l_galley_mismatch_demerits_int , pretolerance = \l_galley_linebreak_pretolerance_int , - relation-penalty = \l_galley_relation_penalty_int , + relation-penalty = \l__galley_relation_penalty_int , tolerance = \l_galley_linebreak_tolerance_int } { \AssignTemplateKeys } @@ -397,23 +397,23 @@ \DeclareTemplateCode { paragraph-breaking } { std } { 0 } { badness = \l_galley_parbreak_badness_int , - broken-penalty = \l_galley_broken_penalty_int , - club-penalty = \l_galley_club_penalty_int , - display-club-penalty = \l_galley_display_club_penalty_int , - display-widow-penalty = \l_galley_display_widow_penalty_int , + broken-penalty = \l__galley_broken_penalty_int , + club-penalty = \l__galley_club_penalty_int , + display-club-penalty = \l__galley_display_club_penalty_int , + display-widow-penalty = \l__galley_display_widow_penalty_int , fuzz = \l_galley_parbreak_fuzz_dim , - interline-penalty = \l_galley_interline_penalty_int , - post-display-penalty = \l_galley_post_display_penalty_int , - pre-display-penalty = \l_galley_pre_display_penalty_int , - widow-penalty = \l_galley_widow_penalty_int + interline-penalty = \l__galley_interline_penalty_int , + post-display-penalty = \l__galley_post_display_penalty_int , + pre-display-penalty = \l__galley_pre_display_penalty_int , + widow-penalty = \l__galley_widow_penalty_int } { \AssignTemplateKeys - \galley_set_club_penalties:V \l_galley_club_penalty_int - \galley_set_display_club_penalties:V \l_galley_display_club_penalty_int - \galley_set_display_widow_penalties:V \l_galley_display_widow_penalty_int - \galley_set_interline_penalty:n \l_galley_interline_penalty_int - \galley_set_widow_penalties:V \l_galley_widow_penalty_int + \galley_set_club_penalties:V \l__galley_club_penalty_int + \galley_set_display_club_penalties:V \l__galley_display_club_penalty_int + \galley_set_display_widow_penalties:V \l__galley_display_widow_penalty_int + \galley_set_interline_penalty:n \l__galley_interline_penalty_int + \galley_set_widow_penalties:V \l__galley_widow_penalty_int } \DeclareInstance { paragraph-breaking } { std } { std } { } \UseInstance { paragraph-breaking } { std } @@ -444,39 +444,39 @@ } \DeclareTemplateCode { paragraph-breaking } { single } { 0 } { - badness = \l_galley_parbreak_badness_tl , - broken-penalty = \l_galley_broken_penalty_tl , - club-penalty = \l_galley_club_penalties_tl , - display-club-penalty = \l_galley_display_club_penalties_tl , - display-widow-penalty = \l_galley_display_widow_penalties_tl , - fuzz = \l_galley_parbreak_fuzz_tl , - interline-penalty = \l_galley_interline_penalty_tl , - post-display-penalty = \l_galley_post_display_penalty_tl , - pre-display-penalty = \l_galley_pre_display_penalty_tl , - widow-penalty = \l_galley_widow_penalties_tl + badness = \l__galley_parbreak_badness_tl , + broken-penalty = \l__galley_broken_penalty_tl , + club-penalty = \l__galley_club_penalties_tl , + display-club-penalty = \l__galley_display_club_penalties_tl , + display-widow-penalty = \l__galley_display_widow_penalties_tl , + fuzz = \l__galley_parbreak_fuzz_tl , + interline-penalty = \l__galley_interline_penalty_tl , + post-display-penalty = \l__galley_post_display_penalty_tl , + pre-display-penalty = \l__galley_pre_display_penalty_tl , + widow-penalty = \l__galley_widow_penalties_tl } { \AssignTemplateKeys - \tl_if_empty:NF \l_galley_interline_penalty_tl + \tl_if_empty:NF \l__galley_interline_penalty_tl { \tl_gput_right:Nx \g_galley_par_after_hook_tl { - \int_set:Nn \exp_not:N \l_galley_interline_penalty_int + \int_set:Nn \exp_not:N \l__galley_interline_penalty_int { \galley_interline_penalty: } } - \int_set:Nn \l_galley_interline_penalty_int - { \l_galley_interline_penalty_tl } + \int_set:Nn \l__galley_interline_penalty_int + { \l__galley_interline_penalty_tl } } - \tl_if_empty:NF \l_galley_parbreak_fuzz_tl + \tl_if_empty:NF \l__galley_parbreak_fuzz_tl { \tl_gput_right:Nx \g_galley_par_after_hook_tl { \dim_set:Nn \exp_not:N \l_galley_parbreak_fuzz_dim { \dim_use:N \l_galley_parbreak_fuzz_dim } } - \dim_set:Nn \l_galley_parbreak_fuzz_dim { \l_galley_parbreak_fuzz_tl } + \dim_set:Nn \l_galley_parbreak_fuzz_dim { \l__galley_parbreak_fuzz_tl } } - \seq_map_inline:Nn \c_galley_parbreak_single_seq + \seq_map_inline:Nn \c__galley_parbreak_single_seq { \tl_if_empty:cF { l_galley_ ##1 _tl } { @@ -489,30 +489,30 @@ { \tl_use:c { l_galley_ ##1 _tl } } } } - \seq_map_inline:Nn \c_galley_parbreak_multi_seq + \seq_map_inline:Nn \c__galley_parbreak_multi_seq { \tl_if_empty:cF { l_galley_ ##1 _tl } { - \use:c { galley_save_ ##1 :N } \l_galley_tmpa_clist + \use:c { galley_save_ ##1 :N } \l__galley_tmpa_clist \tl_gput_right:Nx \g_galley_par_after_hook_tl { \exp_not:c { galley_set_ ##1 :n } - { \exp_not:o \l_galley_tmpa_clist } + { \exp_not:o \l__galley_tmpa_clist } } \use:c { galley_set_ ##1 :v } { l_galley_ ##1 _tl } } } } -\seq_new:N \c_galley_parbreak_multi_seq -\seq_gput_right:Nn \c_galley_parbreak_multi_seq { club_penalties } -\seq_gput_right:Nn \c_galley_parbreak_multi_seq { display_club_penalties } -\seq_gput_right:Nn \c_galley_parbreak_multi_seq { display_widow_penalties } -\seq_gput_right:Nn \c_galley_parbreak_multi_seq { widow_penalties } -\seq_new:N \c_galley_parbreak_single_seq -\seq_gput_right:Nn \c_galley_parbreak_single_seq { parbreak_badness } -\seq_gput_right:Nn \c_galley_parbreak_single_seq { broken_penalty } -\seq_gput_right:Nn \c_galley_parbreak_single_seq { post_display_penalty } -\seq_gput_right:Nn \c_galley_parbreak_single_seq { pre_display_penalty } +\seq_new:N \c__galley_parbreak_multi_seq +\seq_gput_right:Nn \c__galley_parbreak_multi_seq { club_penalties } +\seq_gput_right:Nn \c__galley_parbreak_multi_seq { display_club_penalties } +\seq_gput_right:Nn \c__galley_parbreak_multi_seq { display_widow_penalties } +\seq_gput_right:Nn \c__galley_parbreak_multi_seq { widow_penalties } +\seq_new:N \c__galley_parbreak_single_seq +\seq_gput_right:Nn \c__galley_parbreak_single_seq { parbreak_badness } +\seq_gput_right:Nn \c__galley_parbreak_single_seq { broken_penalty } +\seq_gput_right:Nn \c__galley_parbreak_single_seq { post_display_penalty } +\seq_gput_right:Nn \c__galley_parbreak_single_seq { pre_display_penalty } \DeclareInstance { paragraph-breaking } { single-std } { single } { } \DeclareInstance { paragraph-breaking } { single-nobreak } { single } { |