diff options
author | Karl Berry <karl@freefriends.org> | 2020-12-04 22:23:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-12-04 22:23:08 +0000 |
commit | 308fffa9446e3b5d28b6e48b89be81575b565c70 (patch) | |
tree | b33f5e1cf009bf510dd974451299d08dc0ffab2a /Master/texmf-dist/tex/latex/l3kernel | |
parent | c4c23071af2870bf72f421f1aae5c9544ff3a87d (diff) |
l3kernel (4dec20)
git-svn-id: svn://tug.org/texlive/trunk@57066 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex | 1006 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex | 11 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/expl3.ltx | 11 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/expl3.sty | 2 |
4 files changed, 778 insertions, 252 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex index ef1d0a3732c..616bc6dddff 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex @@ -69,7 +69,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2020-10-27}% +\def\ExplFileDate{2020-12-03}% \begingroup \def\next{\endgroup}% \expandafter\ifx\csname PackageError\endcsname\relax @@ -8682,6 +8682,7 @@ { \tl_to_str:n {#2} } } \tl_const:Nx \c_catcode_other_space_tl { \char_generate:nn { `\ } { 12 } } +\scan_new:N \s__token_mark \scan_new:N \s__token_stop \group_begin: \__kernel_chk_if_free_cs:N \c_group_begin_token @@ -8951,6 +8952,45 @@ \fi: } } +\cs_new:Npn \token_case_catcode:Nn #1#2 + { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF #1 {#2} { } { } } +\cs_new:Npn \token_case_catcode:NnT #1#2#3 + { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF #1 {#2} {#3} { } } +\cs_new:Npn \token_case_catcode:NnF #1#2 + { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF #1 {#2} { } } +\cs_new:Npn \token_case_catcode:NnTF + { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF } +\cs_new:Npn \token_case_charcode:Nn #1#2 + { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF #1 {#2} { } { } } +\cs_new:Npn \token_case_charcode:NnT #1#2#3 + { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF #1 {#2} {#3} { } } +\cs_new:Npn \token_case_charcode:NnF #1#2 + { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF #1 {#2} { } } +\cs_new:Npn \token_case_charcode:NnTF + { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF } +\cs_new:Npn \token_case_meaning:Nn #1#2 + { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF #1 {#2} { } { } } +\cs_new:Npn \token_case_meaning:NnT #1#2#3 + { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF #1 {#2} {#3} { } } +\cs_new:Npn \token_case_meaning:NnF #1#2 + { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF #1 {#2} { } } +\cs_new:Npn \token_case_meaning:NnTF + { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF } +\cs_new:Npn \__token_case:NNnTF #1#2#3#4#5 + { + \__token_case:NNw #1 #2 #3 #2 { } + \s__token_mark {#4} + \s__token_mark {#5} + \s__token_stop + } +\cs_new:Npn \__token_case:NNw #1#2#3#4 + { + #1 #2 #3 + { \__token_case_end:nw {#4} } + { \__token_case:NNw #1 #2 } + } +\cs_new:Npn \__token_case_end:nw #1#2#3 \s__token_mark #4#5 \s__token_stop + { \exp_end: #1 #4 } \cs_new_eq:NN \l_peek_token ? \cs_new_eq:NN \g_peek_token ? \cs_new_eq:NN \l__peek_search_token ? @@ -13830,6 +13870,39 @@ \exp_after:wN \__intarray_to_clist:w \int_value:w \int_eval:w #1 + \c_one_int ; #2 {#3} } +\cs_new:Npn \__kernel_intarray_range_to_clist:Nnn #1#2#3 + { + \exp_last_unbraced:Nf \use_none:n + { + \exp_after:wN \__intarray_range_to_clist:ww + \int_value:w \int_eval:w #2 \exp_after:wN ; + \int_value:w \int_eval:w #3 ; + #1 \prg_break_point: + } + } +\cs_new:Npn \__intarray_range_to_clist:ww #1 ; #2 ; #3 + { + \if_int_compare:w #1 > #2 \exp_stop_f: + \prg_break:n + \fi: + , \__kernel_intarray_item:Nn #3 {#1} + \exp_after:wN \__intarray_range_to_clist:ww + \int_value:w \int_eval:w #1 + \c_one_int ; #2 ; #3 + } +\cs_new_protected:Npn \__kernel_intarray_gset_range_from_clist:Nnn #1#2#3 + { + \int_set:Nn \l__intarray_loop_int {#2} + \__intarray_gset_range:Nw #1 #3 , , \prg_break_point: + } +\cs_new_protected:Npn \__intarray_gset_range:Nw #1 #2 , + { + \if_catcode:w \scan_stop: \tl_to_str:n {#2} \scan_stop: + \prg_break:n + \fi: + \__kernel_intarray_gset:Nnn #1 \l__intarray_loop_int {#2} + \int_incr:N \l__intarray_loop_int + \__intarray_gset_range:Nw #1 + } \cs_new_protected:Npn \intarray_show:N { \__intarray_show:NN \msg_show:nnxxxx } \cs_generate_variant:Nn \intarray_show:N { c } \cs_new_protected:Npn \intarray_log:N { \__intarray_show:NN \msg_log:nnxxxx } @@ -22376,6 +22449,23 @@ \scan_new:N \s__tl \cs_new_eq:NN \l__tl_analysis_token ? \cs_new_eq:NN \l__tl_analysis_char_token ? +\cs_new_eq:NN \l__tl_analysis_next_token ? +\tl_new:N \l__tl_peek_code_tl +\group_begin: +\char_set_active_eq:NN \ \scan_stop: +\tl_const:Nx \c__tl_peek_catcodes_tl + { + \char_generate:nn { 32 } { 3 } 3 + \char_generate:nn { 32 } { 4 } 4 + # \char_generate:nn { 32 } { 6 } 6 + \char_generate:nn { 32 } { 7 } 7 + \char_generate:nn { 32 } { 8 } 8 + \c_space_tl \token_to_str:N A + \char_generate:nn { 32 } { 11 } \token_to_str:N B + \char_generate:nn { 32 } { 12 } \token_to_str:N C + \char_generate:nn { 32 } { 13 } \token_to_str:N D + } +\group_end: \int_new:N \l__tl_analysis_normal_int \int_new:N \l__tl_analysis_index_int \int_new:N \l__tl_analysis_nesting_int @@ -22794,6 +22884,216 @@ { #1 ~ ( #4 #2 #3 ) } } \cs_generate_variant:Nn \__tl_analysis_show_long_aux:nnnn { oof } +\cs_new:Npn \peek_analysis_map_break: + { \prg_map_break:Nn \peek_analysis_map_break: { } } +\cs_new:Npn \peek_analysis_map_break:n + { \prg_map_break:Nn \peek_analysis_map_break: } +\int_new:N \l__tl_peek_charcode_int +\cs_new:Npn \__tl_analysis_char_arg:Nw + { + \if_meaning:w \l__tl_analysis_token \c_space_token + \exp_after:wN \__tl_analysis_char_arg_aux:Nw + \fi: + } +\cs_new:Npn \__tl_analysis_char_arg_aux:Nw #1 ~ { #1 { ~ } } +\cs_new_protected:Npn \peek_analysis_map_inline:n #1 + { + \int_gincr:N \g__kernel_prg_map_int + \cs_set_protected:cpn + { __tl_analysis_map_ \int_use:N \g__kernel_prg_map_int :nnN } + ##1##2##3 + { + \group_end: + #1 + \__tl_peek_analysis_loop:NNn + \prg_break_point:Nn \peek_analysis_map_break: { } + } + \__tl_peek_analysis_loop:NNn ? ? ? + } +\cs_new_protected:Npn \__tl_peek_analysis_loop:NNn #1#2#3 + { + \group_begin: + \tl_set:Nx \l__tl_peek_code_tl + { + \exp_not:c + { __tl_analysis_map_ \int_use:N \g__kernel_prg_map_int :nnN } + } + \int_set:Nn \tex_escapechar:D { `\\ } + \peek_after:Nw \__tl_peek_analysis_test: + } +\cs_new_protected:Npn \__tl_peek_analysis_test: + { + \if_int_odd:w + \if_catcode:w \exp_not:N \l_peek_token { 1 \exp_stop_f: \fi: + \if_catcode:w \exp_not:N \l_peek_token } 1 \exp_stop_f: \fi: + \if_meaning:w \l_peek_token \c_space_token 1 \exp_stop_f: \fi: + 0 \exp_stop_f: + \exp_after:wN \__tl_peek_analysis_special: + \else: + \exp_after:wN \exp_after:wN + \exp_after:wN \__tl_peek_analysis_normal:N + \exp_after:wN \exp_not:N + \fi: + } +\cs_new_protected:Npn \__tl_peek_analysis_normal:N #1 + { + \exp_after:wN \reverse_if:N \exp_after:wN \if_meaning:w + \exp_not:N #1 #1 + \tex_let:D #1 \scan_stop: + \tl_put_right:Nn \l__tl_peek_code_tl { { \exp_not:N #1 } } + \else: + \tl_put_right:Nn \l__tl_peek_code_tl { { \exp_not:n {#1} } } + \fi: + \if_charcode:w + \scan_stop: + \exp_after:wN \use_none:n \token_to_str:N #1 \prg_do_nothing: + \scan_stop: + \exp_after:wN \__tl_peek_analysis_char:N + \exp_after:wN #1 + \else: + \exp_after:wN \__tl_peek_analysis_cs: + \fi: + } +\cs_new_protected:Npn \__tl_peek_analysis_cs: + { \l__tl_peek_code_tl { -1 } 0 } +\cs_new_protected:Npn \__tl_peek_analysis_char:N #1 + { + \char_set_lccode:nn { `#1 } { 32 } + \tex_lowercase:D { \__tl_peek_analysis_char:nN {#1} } #1 + } +\cs_new_protected:Npn \__tl_peek_analysis_char:nN #1#2 + { + \cs_set_protected:Npn \__tl_tmp:w ##1 #1 ##2 ##3 \scan_stop: + { \exp_args:No \l__tl_peek_code_tl { \int_value:w `#2 } ##2 } + \exp_after:wN \__tl_tmp:w \c__tl_peek_catcodes_tl \scan_stop: + } +\cs_new_protected:Npn \__tl_peek_analysis_special: + { + \tex_let:D \l__tl_analysis_token = ~ \l_peek_token + \int_set:Nn \l__tl_peek_charcode_int + { \__tl_analysis_extract_charcode: } + \if_int_compare:w \l__tl_peek_charcode_int = \tex_escapechar:D + \int_set:Nn \tex_escapechar:D { `\/ } + \fi: + \char_set_active_eq:nN { \l__tl_peek_charcode_int } \scan_stop: + \char_set_active_eq:nN { \tex_escapechar:D } \scan_stop: + \cs_set_eq:cN { } \scan_stop: + \tex_futurelet:D \l__tl_analysis_token + \__tl_peek_analysis_retest: + } +\cs_new_protected:Npn \__tl_peek_analysis_retest: + { + \if_meaning:w \l__tl_analysis_token \scan_stop: + \exp_after:wN \__tl_peek_analysis_normal:N + \else: + \exp_after:wN \__tl_peek_analysis_next: + \fi: + } +\cs_new_protected:Npn \__tl_peek_analysis_next: + { + \tl_if_empty:oT { \tex_the:D \tex_everyeof:D } + { \tex_everyeof:D { \scan_stop: } } + \tex_afterassignment:D \__tl_peek_analysis_str: + \tex_futurelet:D \l__tl_analysis_next_token + } +\cs_new_protected:Npn \__tl_peek_analysis_str: + { + \exp_after:wN \tex_futurelet:D + \exp_after:wN \l__tl_analysis_token + \exp_after:wN \__tl_peek_analysis_str:w + \token_to_str:N + } +\cs_new_protected:Npn \__tl_peek_analysis_str:w + { \__tl_analysis_char_arg:Nw \__tl_peek_analysis_str:n } +\cs_new_protected:Npn \__tl_peek_analysis_str:n #1 + { + \int_case:nnF { `#1 } + { + { \l__tl_peek_charcode_int } + { \__tl_peek_analysis_explicit:n {#1} } + { \tex_escapechar:D } { \__tl_peek_analysis_escape: } + } + { \__tl_peek_analysis_active_str:n {#1} } + } +\cs_new_protected:Npn \__tl_peek_analysis_active_str:n #1 + { + \tl_put_right:Nx \l__tl_peek_code_tl + { + { \char_generate:nn { `#1 } { 13 } } + { \int_value:w `#1 } + \token_to_str:N D + } + \l__tl_peek_code_tl + } +\cs_new_protected:Npn \__tl_peek_analysis_explicit:n #1 + { + \tl_put_right:Nx \l__tl_peek_code_tl + { + \if_meaning:w \l_peek_token \c_space_token + { ~ } { 32 } \token_to_str:N A + \else: + \if_catcode:w \l_peek_token \c_group_begin_token + { + \exp_not:N \exp_after:wN + \char_generate:nn { `#1 } { 1 } + \exp_not:N \if_false: + \if_false: { \fi: } + \exp_not:N \fi: + } + { \int_value:w `#1 } + 1 + \else: + { + \exp_not:N \if_false: + { \if_false: } \fi: + \exp_not:N \fi: + \char_generate:nn { `#1 } { 2 } + } + { \int_value:w `#1 } + 2 + \fi: + \fi: + } + \l__tl_peek_code_tl + } +\cs_new_protected:Npn \__tl_peek_analysis_escape: + { + \tl_clear:N \l__tl_internal_a_tl + \tex_futurelet:D \l__tl_analysis_token + \__tl_peek_analysis_collect:w + } +\cs_new_protected:Npn \__tl_peek_analysis_collect:w + { \__tl_analysis_char_arg:Nw \__tl_peek_analysis_collect:n } +\cs_new_protected:Npn \__tl_peek_analysis_collect:n #1 + { + \tl_put_right:Nn \l__tl_internal_a_tl {#1} + \__tl_peek_analysis_collect_loop: + } +\cs_new_protected:Npn \__tl_peek_analysis_collect_loop: + { + \tex_futurelet:D \l__tl_analysis_token + \__tl_peek_analysis_collect_test: + } +\cs_new_protected:Npn \__tl_peek_analysis_collect_test: + { + \if_meaning:w \l__tl_analysis_token \l__tl_analysis_next_token + \exp_after:wN \if_meaning:w \cs:w \l__tl_internal_a_tl \cs_end: \l_peek_token + \__tl_peek_analysis_collect_end:NNN + \fi: + \fi: + \__tl_peek_analysis_collect:w + } +\cs_new_protected:Npn \__tl_peek_analysis_collect_end:NNN #1#2#3 + { + #1 #2 + \tl_put_right:Nx \l__tl_peek_code_tl + { + { \exp_not:N \exp_not:n { \exp_not:c { \l__tl_internal_a_tl } } } + { -1 } + 0 + } + \l__tl_peek_code_tl + } \tl_const:Nx \c__tl_analysis_show_etc_str % ( { \token_to_str:N \ETC.) } \__kernel_msg_new:nnn { kernel } { show-tl-analysis } @@ -22812,7 +23112,7 @@ { \__regex_toks_set:Nn #1 { } } \cs_new_eq:NN \__regex_toks_set:Nn \tex_toks:D \cs_new_protected:Npn \__regex_toks_set:No #1 - { \__regex_toks_set:Nn #1 \exp_after:wN } + { \tex_toks:D #1 \exp_after:wN } \cs_new_protected:Npn \__regex_toks_memcpy:NNn #1#2#3 { \prg_replicate:nn {#3} @@ -22824,13 +23124,13 @@ } \cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 { - \cs_set: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 } } \cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 { - \cs_set: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 } } @@ -22839,8 +23139,21 @@ \cs_new:Npn \__regex_curr_cs_to_str: { \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l__regex_curr_pos_int + \l__regex_curr_token_tl } +\cs_new:Npn \__regex_intarray_item:NnF #1#2 + { \exp_args:Nf \__regex_intarray_item_aux:nNF { \int_eval:n {#2} } #1 } +\cs_new:Npn \__regex_intarray_item_aux:nNF #1#2 + { + \if_int_compare:w #1 > \c_zero_int + \exp_after:wN \use_i:nn + \else: + \exp_after:wN \use_ii:nn + \fi: + { \__kernel_intarray_item:Nn #2 {#1} } + } +\cs_new:Npn \__regex_maplike_break: + { \prg_map_break:Nn \__regex_maplike_break: { } } \cs_new:Npn \__regex_tmp:w { } \tl_new:N \l__regex_internal_a_tl \tl_new:N \l__regex_internal_b_tl @@ -22856,11 +23169,7 @@ \__regex_branch:n { \__regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } } -\intarray_new:Nn \g__regex_charcode_intarray { 65536 } -\intarray_new:Nn \g__regex_catcode_intarray { 65536 } -\intarray_new:Nn \g__regex_balance_intarray { 65536 } \int_new:N \l__regex_balance_int -\tl_new:N \l__regex_cs_name_tl \int_const:Nn \c__regex_ascii_min_int { 0 } \int_const:Nn \c__regex_ascii_max_control_int { 31 } \int_const:Nn \c__regex_ascii_max_int { 127 } @@ -22986,13 +23295,12 @@ \int_compare:nNnT \l__regex_curr_catcode_int = 0 { \group_begin: - \__kernel_tl_set:Nx \l__regex_cs_name_tl { \__regex_curr_cs_to_str: } \__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:NV \__regex_match_cs:n \l__regex_cs_name_tl + \exp_args:Nx \__regex_match_cs:n { \__regex_curr_cs_to_str: } \if_meaning:w \c_true_bool \g__regex_success_bool \group_insert_after:N \__regex_break_true:w \fi: @@ -23711,48 +24019,39 @@ \__regex_tmp:w w W \cs_new_protected:cpn { __regex_compile_/N: } { \__regex_compile_one:n \__regex_prop_N: } -\cs_new_protected:Npn \__regex_compile_anchor:NF #1#2 +\cs_new_protected:Npn \__regex_compile_anchor_letter:NNN #1#2#3 { - \__regex_if_in_class_or_catcode:TF {#2} + \__regex_if_in_class_or_catcode:TF { \__regex_compile_raw_error:N #1 } { \tl_build_put_right:Nn \l__regex_build_tl - { \__regex_assertion:Nn \c_true_bool { \__regex_anchor:N #1 } } + { \__regex_assertion:Nn #2 {#3} } } } -\cs_set_protected:Npn \__regex_tmp:w #1#2 - { - \cs_new_protected: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 - { - \cs_new_protected: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:cpn { __regex_compile_/A: } + { \__regex_compile_anchor_letter:NNN A \c_true_bool \__regex_A_test: } +\cs_new_protected:cpn { __regex_compile_/G: } + { \__regex_compile_anchor_letter:NNN G \c_true_bool \__regex_G_test: } +\cs_new_protected:cpn { __regex_compile_/Z: } + { \__regex_compile_anchor_letter:NNN Z \c_true_bool \__regex_Z_test: } +\cs_new_protected:cpn { __regex_compile_/z: } + { \__regex_compile_anchor_letter:NNN z \c_true_bool \__regex_Z_test: } \cs_new_protected:cpn { __regex_compile_/b: } - { - \__regex_if_in_class_or_catcode:TF - { \__regex_compile_raw_error:N b } - { - \tl_build_put_right:Nn \l__regex_build_tl - { \__regex_assertion:Nn \c_true_bool { \__regex_b_test: } } - } - } + { \__regex_compile_anchor_letter:NNN b \c_true_bool \__regex_b_test: } \cs_new_protected:cpn { __regex_compile_/B: } + { \__regex_compile_anchor_letter:NNN B \c_false_bool \__regex_b_test: } +\cs_set_protected:Npn \__regex_tmp:w #1#2 { - \__regex_if_in_class_or_catcode:TF - { \__regex_compile_raw_error:N B } + \cs_new_protected:cpn { __regex_compile_#1: } { - \tl_build_put_right:Nn \l__regex_build_tl - { \__regex_assertion:Nn \c_false_bool { \__regex_b_test: } } + \__regex_if_in_class_or_catcode:TF { \__regex_compile_raw:N #1 } + { + \tl_build_put_right:Nn \l__regex_build_tl + { \__regex_assertion:Nn \c_true_bool {#2} } + } } } +\exp_args:Nx \__regex_tmp:w { \iow_char:N \^ } { \__regex_A_test: } +\exp_args:Nx \__regex_tmp:w { \iow_char:N \$ } { \__regex_Z_test: } \cs_new_protected:cpn { __regex_compile_]: } { \__regex_if_in_class:TF @@ -24282,7 +24581,9 @@ { \bool_if:NF ##1 { negative~ } assertion:~##2 } } \cs_set:Npn \__regex_b_test: { word~boundary } - \cs_set_eq:NN \__regex_anchor:N \__regex_show_anchor_to_str:N + \cs_set:Npn \__regex_Z_test: { anchor~at~end~(\iow_char:N\\Z) } + \cs_set:Npn \__regex_A_test: { anchor~at~start~(\iow_char:N\\A) } + \cs_set:Npn \__regex_G_test: { anchor~at~start~of~match~(\iow_char:N\\G) } \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 @@ -24383,17 +24684,6 @@ } } } -\cs_new:Npn \__regex_show_anchor_to_str:N #1 - { - anchor~at~ - \str_case:nnF { #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) } - } - { <error:~'#1'~not~recognized> } - } \cs_new_protected:Npn \__regex_show_item_catcode:NnT #1#2 { \seq_set_split:Nnn \l__regex_internal_seq { } { CBEMTPUDSLOA } @@ -24423,12 +24713,16 @@ \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 +\cs_new_protected:Npn \__regex_build:n + { \__regex_build_aux:Nn \c_true_bool } +\cs_new_protected:Npn \__regex_build:N + { \__regex_build_aux:NN \c_true_bool } +\cs_new_protected:Npn \__regex_build_aux:Nn #1#2 { - \__regex_compile:n {#1} - \__regex_build:N \l__regex_internal_regex + \__regex_compile:n {#2} + \__regex_build_aux:NN #1 \l__regex_internal_regex } -\cs_new_protected:Npn \__regex_build:N #1 +\cs_new_protected:Npn \__regex_build_aux:NN #1#2 { \__regex_standard_escapechar: \int_zero:N \l__regex_capturing_group_int @@ -24436,15 +24730,14 @@ \__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_action_start_wildcard:N #1 } + \__regex_group:nnnN {#2} { 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_min_state_int \l__regex_max_active_int - \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int + \int_set_eq:NN \l__regex_min_state_int \l__regex_max_state_int \__regex_build_new_state: \__regex_build_new_state: \__regex_push_lr_states: @@ -24452,7 +24745,7 @@ \__regex_pop_lr_states: \__regex_toks_put_right:Nn \l__regex_right_state_int { - \if_int_compare:w \l__regex_curr_pos_int = \l__regex_max_pos_int + \if_int_compare:w -2 = \l__regex_curr_char_int \exp_after:wN \__regex_action_success: \fi: } @@ -24624,8 +24917,8 @@ \cs_new_protected:Npn \__regex_group_submatches:nNN #1#2#3 { \if_int_compare:w #1 > - 1 \exp_stop_f: - \__regex_toks_put_left:Nx #2 { \__regex_action_submatch:n { #1 < } } - \__regex_toks_put_left:Nx #3 { \__regex_action_submatch:n { #1 > } } + \__regex_toks_put_left:Nx #2 { \__regex_action_submatch:nN {#1} < } + \__regex_toks_put_left:Nx #3 { \__regex_action_submatch:nN {#1} > } \fi: } \cs_new_protected:Npn \__regex_group_repeat_aux:n #1 @@ -24731,12 +25024,6 @@ \bool_if:NT #1 { { } } } } -\cs_new_protected:Npn \__regex_anchor:N #1 - { - \if_int_compare:w #1 = \l__regex_curr_pos_int - \exp_after:wN \__regex_break_true:w - \fi: - } \cs_new_protected:Npn \__regex_b_test: { \group_begin: @@ -24746,12 +25033,30 @@ { \group_end: \__regex_item_reverse:n \__regex_prop_w: } { \group_end: \__regex_prop_w: } } +\cs_new_protected:Npn \__regex_Z_test: + { + \if_int_compare:w -2 = \l__regex_curr_char_int + \exp_after:wN \__regex_break_true:w + \fi: + } +\cs_new_protected:Npn \__regex_A_test: + { + \if_int_compare:w -2 = \l__regex_last_char_int + \exp_after:wN \__regex_break_true:w + \fi: + } +\cs_new_protected:Npn \__regex_G_test: + { + \if_int_compare:w \l__regex_curr_pos_int = \l__regex_start_pos_int + \exp_after:wN \__regex_break_true:w + \fi: + } \cs_new_protected:Npn \__regex_command_K: { \__regex_build_new_state: \__regex_toks_put_right:Nx \l__regex_left_state_int { - \__regex_action_submatch:n { 0< } + \__regex_action_submatch:nN { 0 } < \bool_set_true:N \l__regex_fresh_thread_bool \__regex_action_free:n { @@ -24768,16 +25073,20 @@ \int_new:N \l__regex_success_pos_int \int_new:N \l__regex_curr_char_int \int_new:N \l__regex_curr_catcode_int +\tl_new:N \l__regex_curr_token_tl \int_new:N \l__regex_last_char_int +\int_new:N \l__regex_last_char_success_int \int_new:N \l__regex_case_changed_char_int \int_new:N \l__regex_curr_state_int -\prop_new:N \l__regex_curr_submatches_prop -\prop_new:N \l__regex_success_submatches_prop +\tl_new:N \l__regex_curr_submatches_tl +\tl_new:N \l__regex_success_submatches_tl \int_new:N \l__regex_step_int -\int_new:N \l__regex_min_active_int -\int_new:N \l__regex_max_active_int +\int_new:N \l__regex_min_thread_int +\int_new:N \l__regex_max_thread_int \intarray_new:Nn \g__regex_state_active_intarray { 65536 } -\intarray_new:Nn \g__regex_thread_state_intarray { 65536 } +\intarray_new:Nn \g__regex_thread_info_intarray { 65536 } +\tl_new:N \l__regex_matched_analysis_tl +\tl_new:N \l__regex_curr_analysis_tl \tl_new:N \l__regex_every_match_tl \bool_new:N \l__regex_fresh_thread_bool \bool_new:N \l__regex_empty_success_bool @@ -24787,38 +25096,26 @@ \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_curr_pos_int { 2 * \l__regex_max_state_int } - \__regex_query_set:nnn { } { -1 } { -2 } - \int_set_eq:NN \l__regex_min_pos_int \l__regex_curr_pos_int - \tl_analysis_map_inline:nn {#1} - { \__regex_query_set:nnn {##1} {"##3} {##2} } - \int_set_eq:NN \l__regex_max_pos_int \l__regex_curr_pos_int - \__regex_query_set:nnn { } { -1 } { -2 } \__regex_match_init: - \__regex_match_once: + \__regex_match_once_init: + \tl_analysis_map_inline:nn {#1} + { \__regex_match_one_token:nnN {##1} {##2} ##3 } + \__regex_match_one_token:nnN { } { -2 } F + \prg_break_point:Nn \__regex_maplike_break: { } } \cs_new_protected:Npn \__regex_match_cs:n #1 { - \int_zero:N \l__regex_balance_int - \int_set:Nn \l__regex_curr_pos_int - { - \int_max:nn { 2 * \l__regex_max_state_int - \l__regex_min_state_int } - { \l__regex_max_pos_int } - + 1 - } - \__regex_query_set:nnn { } { -1 } { -2 } - \int_set_eq:NN \l__regex_min_pos_int \l__regex_curr_pos_int + \int_set_eq:NN \l__regex_min_thread_int \l__regex_max_thread_int + \__regex_match_init: + \__regex_match_once_init: \str_map_inline:nn {#1} { - \__regex_query_set:nnn { \exp_not:n {##1} } - { \tl_if_blank:nTF {##1} { 10 } { 12 } } - { `##1 } + \tl_if_blank:nTF {##1} + { \__regex_match_one_token:nnN {##1} {`##1} A } + { \__regex_match_one_token:nnN {##1} {`##1} C } } - \int_set_eq:NN \l__regex_max_pos_int \l__regex_curr_pos_int - \__regex_query_set:nnn { } { -1 } { -2 } - \__regex_match_init: - \__regex_match_once: + \__regex_match_one_token:nnN { } { -2 } F + \prg_break_point:Nn \__regex_maplike_break: { } } \cs_new_protected:Npn \__regex_match_init: { @@ -24829,15 +25126,17 @@ \__kernel_intarray_gset:Nnn \g__regex_state_active_intarray {##1} { 1 } } - \int_set_eq:NN \l__regex_min_active_int \l__regex_max_state_int \int_zero:N \l__regex_step_int + \int_set:Nn \l__regex_min_pos_int { 2 } \int_set_eq:NN \l__regex_success_pos_int \l__regex_min_pos_int - \int_set:Nn \l__regex_min_submatch_int - { 2 * \l__regex_max_state_int } + \int_set:Nn \l__regex_last_char_success_int { -2 } + \tl_build_begin:N \l__regex_matched_analysis_tl + \tl_clear:N \l__regex_curr_analysis_tl + \int_set:Nn \l__regex_min_submatch_int { 1 } \int_set_eq:NN \l__regex_submatch_int \l__regex_min_submatch_int \bool_set_false:N \l__regex_empty_success_bool } -\cs_new_protected:Npn \__regex_match_once: +\cs_new_protected:Npn \__regex_match_once_init: { \if_meaning:w \c_true_bool \l__regex_empty_success_bool \cs_set:Npn \__regex_if_two_empty_matches:F @@ -24850,14 +25149,24 @@ \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_curr_submatches_prop - \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int + \tl_set:Nx \l__regex_curr_submatches_tl + { \prg_replicate:nn { 2 * \l__regex_capturing_group_int } { 0 , } } + \int_set_eq:NN \l__regex_max_thread_int \l__regex_min_thread_int \__regex_store_state:n { \l__regex_min_state_int } \int_set:Nn \l__regex_curr_pos_int { \l__regex_start_pos_int - 1 } - \__regex_query_get: - \__regex_match_loop: - \l__regex_every_match_tl + \int_set_eq:NN \l__regex_curr_char_int \l__regex_last_char_success_int + \tl_build_get:NN \l__regex_matched_analysis_tl \l__regex_internal_a_tl + \exp_args:NNf \__regex_match_once_init_aux: + \tl_map_inline:nn + { \exp_after:wN \l__regex_internal_a_tl \l__regex_curr_analysis_tl } + { \__regex_match_one_token:nnN ##1 } + \prg_break_point:Nn \__regex_maplike_break: { } + } +\cs_new_protected:Npn \__regex_match_once_init_aux: + { + \tl_build_clear:N \l__regex_matched_analysis_tl + \tl_clear:N \l__regex_curr_analysis_tl } \cs_new_protected:Npn \__regex_single_match: { @@ -24866,71 +25175,58 @@ \bool_gset_eq:NN \g__regex_success_bool \l__regex_match_success_bool + \__regex_maplike_break: } } \cs_new_protected:Npn \__regex_multi_match:n #1 { \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 - #1 - \exp_after:wN \__regex_match_once: + \if_meaning:w \c_false_bool \l__regex_match_success_bool + \exp_after:wN \__regex_maplike_break: \fi: + \bool_gset_true:N \g__regex_success_bool + #1 + \__regex_match_once_init: } } -\cs_new_protected:Npn \__regex_match_loop: +\cs_new_protected:Npn \__regex_match_one_token:nnN #1#2#3 { \int_add:Nn \l__regex_step_int { 2 } \int_incr:N \l__regex_curr_pos_int \int_set_eq:NN \l__regex_last_char_int \l__regex_curr_char_int \int_set_eq:NN \l__regex_case_changed_char_int \c_max_int - \__regex_query_get: + \tl_set:Nn \l__regex_curr_token_tl {#1} + \int_set:Nn \l__regex_curr_char_int {#2} + \int_set:Nn \l__regex_curr_catcode_int { "#3 } + \tl_build_put_right:Nx \l__regex_matched_analysis_tl + { \exp_not:o \l__regex_curr_analysis_tl } + \tl_set:Nn \l__regex_curr_analysis_tl { { {#1} {#2} #3 } } \use:x { - \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int + \int_set_eq:NN \l__regex_max_thread_int \l__regex_min_thread_int \int_step_function:nnN - { \l__regex_min_active_int } - { \l__regex_max_active_int - 1 } + { \l__regex_min_thread_int } + { \l__regex_max_thread_int - 1 } \__regex_match_one_active:n } \prg_break_point: \bool_set_false:N \l__regex_fresh_thread_bool - \if_int_compare:w \l__regex_max_active_int > \l__regex_min_active_int - \if_int_compare:w \l__regex_curr_pos_int < \l__regex_max_pos_int - \exp_after:wN \exp_after:wN \exp_after:wN \__regex_match_loop: + \if_int_compare:w \l__regex_max_thread_int > \l__regex_min_thread_int + \if_int_compare:w -2 < \l__regex_curr_char_int + \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n \fi: \fi: + \l__regex_every_match_tl } \cs_new:Npn \__regex_match_one_active:n #1 { - \__regex_use_state_and_submatches:nn - { \__kernel_intarray_item:Nn \g__regex_thread_state_intarray {#1} } - { \__regex_toks_use:w #1 } - } -\cs_new_protected:Npn \__regex_query_set:nnn #1#2#3 - { - \__kernel_intarray_gset:Nnn \g__regex_charcode_intarray - { \l__regex_curr_pos_int } {#3} - \__kernel_intarray_gset:Nnn \g__regex_catcode_intarray - { \l__regex_curr_pos_int } {#2} - \__kernel_intarray_gset:Nnn \g__regex_balance_intarray - { \l__regex_curr_pos_int } { \l__regex_balance_int } - \__regex_toks_set:Nn \l__regex_curr_pos_int {#1} - \int_incr:N \l__regex_curr_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 - \fi: - } -\cs_new_protected:Npn \__regex_query_get: - { - \l__regex_curr_char_int - = \__kernel_intarray_item:Nn \g__regex_charcode_intarray - { \l__regex_curr_pos_int } \scan_stop: - \l__regex_curr_catcode_int - = \__kernel_intarray_item:Nn \g__regex_catcode_intarray - { \l__regex_curr_pos_int } \scan_stop: + \__regex_use_state_and_submatches:w + \__kernel_intarray_range_to_clist:Nnn + \g__regex_thread_info_intarray + { 1 + #1 * (\l__regex_capturing_group_int * 2 + 1) } + { (1 + #1) * (\l__regex_capturing_group_int * 2 + 1) } + ; } \cs_new_protected:Npn \__regex_use_state: { @@ -24941,24 +25237,24 @@ { \l__regex_curr_state_int } { \int_eval:n { \l__regex_step_int + 1 } } } -\cs_new_protected:Npn \__regex_use_state_and_submatches:nn #1 #2 +\cs_new_protected:Npn \__regex_use_state_and_submatches:w #1 , #2 ; { \int_set:Nn \l__regex_curr_state_int {#1} \if_int_compare:w \__kernel_intarray_item:Nn \g__regex_state_active_intarray { \l__regex_curr_state_int } < \l__regex_step_int - \tl_set:Nn \l__regex_curr_submatches_prop {#2} + \tl_set:Nn \l__regex_curr_submatches_tl { #2 , } \exp_after:wN \__regex_use_state: \fi: \scan_stop: } -\cs_new_protected:Npn \__regex_action_start_wildcard: +\cs_new_protected:Npn \__regex_action_start_wildcard:N #1 { \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_if:NT #1 { \__regex_action_cost:n {0} } } \cs_new_protected:Npn \__regex_action_free:n { \__regex_action_free_aux:nn { > \l__regex_step_int \else: } } @@ -24980,8 +25276,8 @@ } \int_set:Nn \l__regex_curr_state_int { \int_use:N \l__regex_curr_state_int } - \tl_set:Nn \exp_not:N \l__regex_curr_submatches_prop - { \exp_not:o \l__regex_curr_submatches_prop } + \tl_set:Nn \exp_not:N \l__regex_curr_submatches_tl + { \exp_not:o \l__regex_curr_submatches_tl } } } \cs_new_protected:Npn \__regex_action_cost:n #1 @@ -24991,26 +25287,47 @@ } \cs_new_protected:Npn \__regex_store_state:n #1 { - \__regex_store_submatches: - \__kernel_intarray_gset:Nnn \g__regex_thread_state_intarray - { \l__regex_max_active_int } {#1} - \int_incr:N \l__regex_max_active_int + \exp_args:No \__regex_store_submatches:nn + \l__regex_curr_submatches_tl {#1} + \int_incr:N \l__regex_max_thread_int } -\cs_new_protected:Npn \__regex_store_submatches: +\cs_new_protected:Npn \__regex_store_submatches:nn #1#2 { - \__regex_toks_set:No \l__regex_max_active_int - { \l__regex_curr_submatches_prop } + \__kernel_intarray_gset_range_from_clist:Nnn + \g__regex_thread_info_intarray + { + \__regex_int_eval:w + 1 + \l__regex_max_thread_int * + (\l__regex_capturing_group_int * 2 + 1) + } + { #2 , #1 } } \cs_new_protected:Npn \__regex_disable_submatches: { - \cs_set_protected:Npn \__regex_store_submatches: { } - \cs_set_protected:Npn \__regex_action_submatch:n ##1 { } + \cs_set_protected:Npn \__regex_store_submatches:n ##1 { } + \cs_set_protected:Npn \__regex_action_submatch:nN ##1##2 { } } -\cs_new_protected:Npn \__regex_action_submatch:n #1 +\cs_new_protected:Npn \__regex_action_submatch:nN #1#2 { - \prop_put:Nno \l__regex_curr_submatches_prop {#1} - { \int_use:N \l__regex_curr_pos_int } + \exp_after:wN \__regex_action_submatch_aux:w + \l__regex_curr_submatches_tl ; {#1} #2 } +\cs_new_protected:Npn \__regex_action_submatch_aux:w #1 ; #2#3 + { + \tl_set:Nx \l__regex_curr_submatches_tl + { + \prg_replicate:nn + { #2 \if_meaning:w > #3 + \l__regex_capturing_group_int \fi: } + { \__regex_action_submatch_auxii:w } + \__regex_action_submatch_auxiii:w + #1 + } + } +\cs_new:Npn \__regex_action_submatch_auxii:w + #1 \__regex_action_submatch_auxiii:w #2 , + { #2 , #1 \__regex_action_submatch_auxiii:w } +\cs_new:Npn \__regex_action_submatch_auxiii:w #1 , + { \int_use:N \l__regex_curr_pos_int , } \cs_new_protected:Npn \__regex_action_success: { \__regex_if_two_empty_matches:F @@ -25019,8 +25336,10 @@ \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_curr_pos_int - \prop_set_eq:NN \l__regex_success_submatches_prop - \l__regex_curr_submatches_prop + \int_set_eq:NN \l__regex_last_char_success_int \l__regex_last_char_int + \tl_build_clear:N \l__regex_matched_analysis_tl + \tl_set_eq:NN \l__regex_success_submatches_tl + \l__regex_curr_submatches_tl \prg_break: } } @@ -25037,6 +25356,7 @@ { \__kernel_intarray_item:Nn \g__regex_submatch_begin_intarray {#1} } } \cs_new:Npn \__regex_replacement_exp_not:N #1 { \exp_not:n {#1} } +\cs_new_eq:NN \__regex_replacement_exp_not:V \exp_not:V \cs_new:Npn \__regex_query_range:nn #1#2 { \exp_after:wN \__regex_query_range_loop:ww @@ -25063,37 +25383,21 @@ \cs_new_protected:Npn \__regex_submatch_balance:n #1 { \int_eval:n - { - \int_compare:nNnTF - { - \__kernel_intarray_item:Nn - \g__regex_submatch_end_intarray {#1} - } - = 0 - { 0 } - { - \__kernel_intarray_item:Nn \g__regex_balance_intarray - { - \__kernel_intarray_item:Nn - \g__regex_submatch_end_intarray {#1} - } - } - - - \int_compare:nNnTF - { - \__kernel_intarray_item:Nn - \g__regex_submatch_begin_intarray {#1} - } - = 0 - { 0 } - { - \__kernel_intarray_item:Nn \g__regex_balance_intarray - { - \__kernel_intarray_item:Nn - \g__regex_submatch_begin_intarray {#1} - } - } - } + { + \__regex_intarray_item:NnF \g__regex_balance_intarray + { + \__kernel_intarray_item:Nn + \g__regex_submatch_end_intarray {#1} + } + { 0 } + - + \__regex_intarray_item:NnF \g__regex_balance_intarray + { + \__kernel_intarray_item:Nn + \g__regex_submatch_begin_intarray {#1} + } + { 0 } + } } \cs_new_protected:Npn \__regex_replacement:n #1 { @@ -25153,10 +25457,12 @@ #1 } } +\cs_new_protected:Npn \__regex_replacement_put:n + { \tl_build_put_right:Nn \l__regex_build_tl } \cs_new_protected:Npn \__regex_replacement_normal:n #1 { \tl_if_empty:NTF \l__regex_replacement_category_tl - { \tl_build_put_right:Nn \l__regex_build_tl {#1} } + { \__regex_replacement_put:n {#1} } { % ( \token_if_eq_charcode:NNTF #1 ) { @@ -25188,15 +25494,19 @@ \cs_new_protected:Npn \__regex_replacement_put_submatch:n #1 { \if_int_compare:w #1 < \l__regex_capturing_group_int - \tl_build_put_right:Nn \l__regex_build_tl - { \__regex_query_submatch:n { \int_eval:n { #1 + ##1 } } } - \if_int_compare:w \l__regex_replacement_csnames_int = 0 \exp_stop_f: - \tl_put_right:Nn \l__regex_balance_tl - { - + \__regex_submatch_balance:n - { \exp_not:N \int_eval:n { #1 + ##1 } } - } - \fi: + \__regex_replacement_put_submatch_aux:n {#1} + \fi: + } +\cs_new_protected:Npn \__regex_replacement_put_submatch_aux:n #1 + { + \tl_build_put_right:Nn \l__regex_build_tl + { \__regex_query_submatch:n { \int_eval:n { #1 + ##1 } } } + \if_int_compare:w \l__regex_replacement_csnames_int = 0 \exp_stop_f: + \tl_put_right:Nn \l__regex_balance_tl + { + + \__regex_submatch_balance:n + { \exp_not:N \int_eval:n { #1 + ##1 } } + } \fi: } \cs_new_protected:Npn \__regex_replacement_g:w #1#2 @@ -25262,7 +25572,7 @@ { \__regex_two_if_eq:NNNNTF #1 #2 \__regex_replacement_normal:n \c_left_brace_str - { \__regex_replacement_cu_aux:Nw \exp_not:V } + { \__regex_replacement_cu_aux:Nw \__regex_replacement_exp_not:V } { \__regex_replacement_error:NNN u #1#2 } } \cs_new_protected:Npn \__regex_replacement_rbrace:N #1 @@ -25312,7 +25622,7 @@ \cs_new_protected:Npn \__regex_replacement_char:nNN #1#2#3 { \tex_lccode:D 0 = `#3 \scan_stop: - \tex_lowercase:D { \tl_build_put_right:Nn \l__regex_build_tl {#1} } + \tex_lowercase:D { \__regex_replacement_put:n {#1} } } \char_set_catcode_active:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_A:w @@ -25329,7 +25639,7 @@ \cs_new_protected:Npn \__regex_replacement_c_C:w #1#2 { \tl_build_put_right:Nn \l__regex_build_tl - { \exp_not:N \exp_not:N \exp_not:c {#2} } + { \exp_not:N \__regex_replacement_exp_not:N \exp_not:c {#2} } } \char_set_catcode_math_subscript:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_D:w @@ -25364,7 +25674,7 @@ \__kernel_msg_error:nn { kernel } { replacement-null-space } \fi: \tex_lccode:D `\ = `#2 \scan_stop: - \tex_lowercase:D { \tl_build_put_right:Nn \l__regex_build_tl {~} } + \tex_lowercase:D { \__regex_replacement_put:n {~} } } \char_set_catcode_alignment:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_T:w @@ -25458,6 +25768,7 @@ \intarray_new:Nn \g__regex_submatch_prev_intarray { 65536 } \intarray_new:Nn \g__regex_submatch_begin_intarray { 65536 } \intarray_new:Nn \g__regex_submatch_end_intarray { 65536 } +\intarray_new:Nn \g__regex_balance_intarray { 65536 } \cs_new_protected:Npn \__regex_return: { \if_meaning:w \c_true_bool \g__regex_success_bool @@ -25466,6 +25777,27 @@ \prg_return_false: \fi: } +\cs_new_protected:Npn \__regex_query_set:n #1 + { + \int_zero:N \l__regex_balance_int + \int_zero:N \l__regex_curr_pos_int + \__regex_query_set_aux:nN { } F + \tl_analysis_map_inline:nn {#1} + { \__regex_query_set_aux:nN {##1} ##3 } + \__regex_query_set_aux:nN { } F + \int_set_eq:NN \l__regex_max_pos_int \l__regex_curr_pos_int + } +\cs_new_protected:Npn \__regex_query_set_aux:nN #1#2 + { + \int_incr:N \l__regex_curr_pos_int + \__regex_toks_set:Nn \l__regex_curr_pos_int {#1} + \__kernel_intarray_gset:Nnn \g__regex_balance_intarray + { \l__regex_curr_pos_int } { \l__regex_balance_int } + \if_case:w "#2 \exp_stop_f: + \or: \int_incr:N \l__regex_balance_int + \or: \int_decr:N \l__regex_balance_int + \fi: + } \cs_new_protected:Npn \__regex_if_match:nn #1#2 { \group_begin: @@ -25494,6 +25826,7 @@ #1 \__regex_match:n {#2} \__regex_extract: + \__regex_query_set:n {#2} \__regex_group_end_extract_seq:N #3 } \cs_new_protected:Npn \__regex_extract_all:nnN #1#2#3 @@ -25502,6 +25835,7 @@ \__regex_multi_match:n { \__regex_extract: } #1 \__regex_match:n {#2} + \__regex_query_set:n {#2} \__regex_group_end_extract_seq:N #3 } \cs_new_protected:Npn \__regex_split:nnN #1#2#3 @@ -25527,6 +25861,7 @@ } #1 \__regex_match:n {#2} + \__regex_query_set:n {#2} \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray { \l__regex_submatch_int } { 0 } \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray @@ -25593,45 +25928,38 @@ \int_set_eq:NN \l__regex_zeroth_submatch_int \l__regex_submatch_int \prg_replicate:nn \l__regex_capturing_group_int { - \__kernel_intarray_gset:Nnn \g__regex_submatch_begin_intarray - { \l__regex_submatch_int } { 0 } - \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray - { \l__regex_submatch_int } { 0 } \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray { \l__regex_submatch_int } { 0 } \int_incr:N \l__regex_submatch_int } - \prop_map_inline:Nn \l__regex_success_submatches_prop + \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray + { \l__regex_zeroth_submatch_int } { \l__regex_start_pos_int } + \int_zero:N \l__regex_internal_a_int + \clist_map_inline:Nn \l__regex_success_submatches_tl { - \if_int_compare:w ##1 - 1 \exp_stop_f: - \exp_after:wN \__regex_extract_e:wn \int_value:w + \if_int_compare:w \l__regex_internal_a_int < \l__regex_capturing_group_int + \__kernel_intarray_gset:Nnn \g__regex_submatch_begin_intarray + { \__regex_int_eval:w \l__regex_zeroth_submatch_int + \l__regex_internal_a_int } {##1} \else: - \exp_after:wN \__regex_extract_b:wn \int_value:w + \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray + { \__regex_int_eval:w \l__regex_zeroth_submatch_int + \l__regex_internal_a_int - \l__regex_capturing_group_int } {##1} \fi: - \__regex_int_eval:w \l__regex_zeroth_submatch_int + ##1 {##2} + \int_incr:N \l__regex_internal_a_int } - \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray - { \l__regex_zeroth_submatch_int } { \l__regex_start_pos_int } \fi: } -\cs_new_protected:Npn \__regex_extract_b:wn #1 < #2 - { - \__kernel_intarray_gset:Nnn - \g__regex_submatch_begin_intarray {#1} {#2} - } -\cs_new_protected:Npn \__regex_extract_e:wn #1 > #2 - { \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray {#1} {#2} } \cs_new_protected:Npn \__regex_replace_once:nnN #1#2#3 { \group_begin: \__regex_single_match: #1 - \__regex_replacement:n {#2} - \exp_args:No \__regex_match:n { #3 } + \exp_args:No \__regex_match:n {#3} \if_meaning:w \c_false_bool \g__regex_success_bool \group_end: \else: \__regex_extract: + \exp_args:No \__regex_query_set:n {#3} + \__regex_replacement:n {#2} \int_set:Nn \l__regex_balance_int { \__regex_replacement_balance_one_match:n @@ -25656,8 +25984,9 @@ \group_begin: \__regex_multi_match:n { \__regex_extract: } #1 - \__regex_replacement:n {#2} \exp_args:No \__regex_match:n {#3} + \exp_args:No \__regex_query_set:n {#3} + \__regex_replacement:n {#2} \int_set:Nn \l__regex_balance_int { 0 @@ -25705,6 +26034,196 @@ } } } +\tl_new:N \l__regex_peek_true_tl +\tl_new:N \l__regex_peek_false_tl +\tl_new:N \l__regex_replacement_tl +\tl_new:N \l__regex_input_tl +\cs_new_eq:NN \__regex_input_item:n ? +\cs_new_protected:Npn \peek_regex:nTF #1 + { + \__regex_peek:nnTF + { \__regex_build_aux:Nn \c_false_bool {#1} } + { \__regex_peek_end: } + } +\cs_new_protected:Npn \peek_regex:nT #1#2 + { \peek_regex:nTF {#1} {#2} { } } +\cs_new_protected:Npn \peek_regex:nF #1 { \peek_regex:nTF {#1} { } } +\cs_new_protected:Npn \peek_regex:NTF #1 + { + \__regex_peek:nnTF + { \__regex_build_aux:NN \c_false_bool #1 } + { \__regex_peek_end: } + } +\cs_new_protected:Npn \peek_regex:NT #1#2 + { \peek_regex:NTF #1 {#2} { } } +\cs_new_protected:Npn \peek_regex:NF #1 { \peek_regex:NTF {#1} { } } +\cs_new_protected:Npn \peek_regex_remove_once:nTF #1 + { + \__regex_peek:nnTF + { \__regex_build_aux:Nn \c_false_bool {#1} } + { \__regex_peek_remove_end:n {##1} } + } +\cs_new_protected:Npn \peek_regex_remove_once:nT #1#2 + { \peek_regex_remove_once:nTF {#1} {#2} { } } +\cs_new_protected:Npn \peek_regex_remove_once:nF #1 + { \peek_regex_remove_once:nTF {#1} { } } +\cs_new_protected:Npn \peek_regex_remove_once:NTF #1 + { + \__regex_peek:nnTF + { \__regex_build_aux:NN \c_false_bool #1 } + { \__regex_peek_remove_end:n {##1} } + } +\cs_new_protected:Npn \peek_regex_remove_once:NT #1#2 + { \peek_regex_remove_once:NTF #1 {#2} { } } +\cs_new_protected:Npn \peek_regex_remove_once:NF #1 + { \peek_regex_remove_once:NTF #1 { } } +\cs_new_protected:Npn \__regex_peek:nnTF #1 + { + \__regex_peek_aux:nnTF + { + \__regex_disable_submatches: + #1 + } + } +\cs_new_protected:Npn \__regex_peek_aux:nnTF #1#2#3#4 + { + \group_begin: + \tl_set:Nn \l__regex_peek_true_tl { \group_end: #3 } + \tl_set:Nn \l__regex_peek_false_tl { \group_end: #4 } + \__regex_single_match: + #1 + \__regex_match_init: + \tl_build_clear:N \l__regex_input_tl + \__regex_match_once_init: + \peek_analysis_map_inline:n + { + \tl_build_put_right:Nn \l__regex_input_tl + { \__regex_input_item:n {##1} } + \__regex_match_one_token:nnN {##1} {##2} ##3 + \use_none:nnn + \prg_break_point:Nn \__regex_maplike_break: + { \peek_analysis_map_break:n {#2} } + } + } +\cs_new_protected:Npn \__regex_peek_end: + { + \bool_if:NTF \g__regex_success_bool + { \__regex_peek_reinsert:N \l__regex_peek_true_tl } + { \__regex_peek_reinsert:N \l__regex_peek_false_tl } + } +\cs_new_protected:Npn \__regex_peek_remove_end:n #1 + { + \bool_if:NTF \g__regex_success_bool + { \exp_after:wN \l__regex_peek_true_tl #1 } + { \__regex_peek_reinsert:N \l__regex_peek_false_tl } + } +\cs_new_protected:Npn \__regex_peek_reinsert:N #1 + { + \tl_build_end:N \l__regex_input_tl + \cs_set_eq:NN \__regex_input_item:n \__regex_reinsert_item:n + \exp_after:wN #1 \exp:w \l__regex_input_tl \exp_end: + } +\cs_new_protected:Npn \__regex_reinsert_item:n #1 + { + \exp_after:wN \exp_after:wN + \exp_after:wN \exp_end: + \exp_after:wN \exp_after:wN + #1 + \exp:w + } +\cs_new_protected:Npn \peek_regex_replace_once:nnTF #1 + { \__regex_peek_replace:nnTF { \__regex_build_aux:Nn \c_false_bool {#1} } } +\cs_new_protected:Npn \peek_regex_replace_once:nnT #1#2#3 + { \peek_regex_replace_once:nnTF {#1} {#2} {#3} { } } +\cs_new_protected:Npn \peek_regex_replace_once:nnF #1#2 + { \peek_regex_replace_once:nnTF {#1} {#2} { } } +\cs_new_protected:Npn \peek_regex_replace_once:nn #1#2 + { \peek_regex_replace_once:nnTF {#1} {#2} { } { } } +\cs_new_protected:Npn \peek_regex_replace_once:NnTF #1 + { \__regex_peek_replace:nnTF { \__regex_build_aux:NN \c_false_bool #1 } } +\cs_new_protected:Npn \peek_regex_replace_once:NnT #1#2#3 + { \peek_regex_replace_once:NnTF #1 {#2} {#3} { } } +\cs_new_protected:Npn \peek_regex_replace_once:NnF #1#2 + { \peek_regex_replace_once:NnTF #1 {#2} { } } +\cs_new_protected:Npn \peek_regex_replace_once:Nn #1#2 + { \peek_regex_replace_once:NnTF #1 {#2} { } { } } +\cs_new_protected:Npn \__regex_peek_replace:nnTF #1#2 + { + \tl_set:Nn \l__regex_replacement_tl {#2} + \__regex_peek_aux:nnTF {#1} { \__regex_peek_replace_end: } + } +\cs_new_protected:Npn \__regex_peek_replace_end: + { + \bool_if:NTF \g__regex_success_bool + { + \__regex_extract: + \__regex_query_set_from_input_tl: + \cs_set_eq:NN \__regex_replacement_put:n \__regex_peek_replacement_put:n + \cs_set_eq:NN \__regex_replacement_put_submatch_aux:n + \__regex_peek_replacement_put_submatch_aux:n + \cs_set_eq:NN \__regex_input_item:n \__regex_reinsert_item:n + \cs_set_eq:NN \__regex_replacement_exp_not:N \__regex_peek_replacement_token:n + \cs_set_eq:NN \__regex_replacement_exp_not:V \__regex_peek_replacement_var:N + \exp_args:No \__regex_replacement:n { \l__regex_replacement_tl } + \use:x + { + \exp_not:n { \exp_after:wN \l__regex_peek_true_tl \exp:w } + \__regex_replacement_do_one_match:n + { \l__regex_zeroth_submatch_int } + \__regex_query_range:nn + { + \__kernel_intarray_item:Nn \g__regex_submatch_end_intarray + { \l__regex_zeroth_submatch_int } + } + { \l__regex_max_pos_int } + \exp_end: + } + } + { \__regex_peek_reinsert:N \l__regex_peek_false_tl } + } +\cs_new_protected:Npn \__regex_query_set_from_input_tl: + { + \tl_build_end:N \l__regex_input_tl + \int_zero:N \l__regex_curr_pos_int + \cs_set_eq:NN \__regex_input_item:n \__regex_query_set_item:n + \__regex_query_set_item:n { } + \l__regex_input_tl + \__regex_query_set_item:n { } + \int_set_eq:NN \l__regex_max_pos_int \l__regex_curr_pos_int + } +\cs_new_protected:Npn \__regex_query_set_item:n #1 + { + \int_incr:N \l__regex_curr_pos_int + \__regex_toks_set:Nn \l__regex_curr_pos_int { \__regex_input_item:n {#1} } + } +\cs_new_protected:Npn \__regex_peek_replacement_put:n #1 + { + \if_case:w \l__regex_replacement_csnames_int + \tl_build_put_right:Nn \l__regex_build_tl + { \exp_not:N \__regex_reinsert_item:n {#1} } + \else: + \tl_build_put_right:Nn \l__regex_build_tl {#1} + \fi: + } +\cs_new_protected:Npn \__regex_peek_replacement_token:n #1 + { \exp_after:wN \exp_end: \exp_after:wN #1 \exp:w } +\cs_new_protected:Npn \__regex_peek_replacement_put_submatch_aux:n #1 + { + \if_case:w \l__regex_replacement_csnames_int + \tl_build_put_right:Nn \l__regex_build_tl + { \__regex_query_submatch:n { \int_eval:n { #1 + ##1 } } } + \else: + \tl_build_put_right:Nn \l__regex_build_tl + { \exp:w \__regex_query_submatch:n { \int_eval:n { #1 + ##1 } } \exp_end: } + \fi: + } +\cs_new_protected:Npn \__regex_peek_replacement_var:N #1 + { + \exp_after:wN \exp_last_unbraced:NV + \exp_after:wN \exp_end: + \exp_after:wN #1 + \exp:w + } \use:x { \__kernel_msg_new:nnn { kernel } { trailing-backslash } @@ -28555,7 +29074,7 @@ \bool_lazy_and:nnTF { \cs_if_exist_p:N \fmtname } { \str_if_eq_p:Vn \fmtname { LaTeX2e } } - { \exp_not:N \__text_expand_encoding:N #1 } + { \exp_not:N \__text_expand_testopt:N #1 } { \exp_not:N \__text_expand_replace:N #1 } } } @@ -28577,6 +29096,17 @@ { \__text_expand_store:n { \protect #1 } } \__text_expand_loop:w } +\cs_new:Npn \__text_expand_testopt:N #1 + { + \str_if_eq:nnTF {#1} { \@protected@testopt } + { \__text_expand_testopt:NNn } + { \__text_expand_encoding:N #1 } + } +\cs_new:Npn \__text_expand_testopt:NNn #1#2#3 + { + \__text_expand_store:n {#1} + \__text_expand_loop:w + } \cs_new:Npn \__text_expand_encoding:N #1 { \bool_lazy_or:nnTF @@ -30414,6 +30944,8 @@ \tiny } { \text_declare_purify_equivalent:Nn #1 { } } +\exp_args:Nc \text_declare_purify_equivalent:Nn + { @protected@testopt } { \use_none:nnn } \text_declare_purify_equivalent:Nn \begin { \use:c } \text_declare_purify_equivalent:Nn \end { \__text_end_env:n } \cs_new:Npn \__text_end_env:n #1 { \cs:w end #1 \cs_end: } diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex index e0982301866..9c3bef2d7a8 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex @@ -19,16 +19,13 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2020-10-27}% +\def\ExplFileDate{2020-12-03}% \let\ExplLoaderFileDate\ExplFileDate \begingroup - \catcode`\>=12 - \def\aux#1>{} - \def\auxi{c__kernel_expl_date_tl}% - \edef\auxi{\expandafter\aux\meaning\auxi}% + \catcode`\_=11 \expandafter - \ifx\csname\auxi\endcsname\relax - \global\expandafter\let\csname\auxi\endcsname\ExplFileDate + \ifx\csname c__kernel_expl_date_tl\endcsname\relax + \global\let\c__kernel_expl_date_tl\ExplFileDate \fi \endgroup \begingroup diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3.ltx b/Master/texmf-dist/tex/latex/l3kernel/expl3.ltx index f5bfc4c3b21..475abcb68b7 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3.ltx +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3.ltx @@ -19,16 +19,13 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2020-10-27}% +\def\ExplFileDate{2020-12-03}% \let\ExplLoaderFileDate\ExplFileDate \begingroup - \catcode`\>=12 - \def\aux#1>{} - \def\auxi{c__kernel_expl_date_tl}% - \edef\auxi{\expandafter\aux\meaning\auxi}% + \catcode`\_=11 \expandafter - \ifx\csname\auxi\endcsname\relax - \global\expandafter\let\csname\auxi\endcsname\ExplFileDate + \ifx\csname c__kernel_expl_date_tl\endcsname\relax + \global\let\c__kernel_expl_date_tl\ExplFileDate \fi \endgroup \everyjob\expandafter{\the\everyjob diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3.sty b/Master/texmf-dist/tex/latex/l3kernel/expl3.sty index dc3c7398072..a825a362e44 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3.sty @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx -\def\ExplFileDate{2020-10-27}% +\def\ExplFileDate{2020-12-03}% \let\ExplLoaderFileDate\ExplFileDate \ProvidesPackage{expl3} [% |