diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3tl.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3tl.sty | 562 |
1 files changed, 238 insertions, 324 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty index 763eba4d8a7..166552a8a71 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty @@ -46,25 +46,25 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3tl.dtx 3490 2012-03-04 01:00:53Z bruno $ - {L3 Experimental token lists} +\GetIdInfo$Id: l3tl.dtx 3986 2012-07-15 19:23:51Z joseph $ + {L3 Token lists} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} -\package_check_loaded_expl: +\__expl_package_check: \cs_new_protected:Npn \tl_new:N #1 { - \chk_if_free_cs:N #1 + \__chk_if_free_cs:N #1 \cs_gset_eq:NN #1 \c_empty_tl } \cs_generate_variant:Nn \tl_new:N { c } \cs_new_protected:Npn \tl_const:Nn #1#2 { - \chk_if_free_cs:N #1 + \__chk_if_free_cs:N #1 \cs_gset_nopar:Npx #1 { \exp_not:n {#2} } } \cs_new_protected:Npn \tl_const:Nx #1#2 { - \chk_if_free_cs:N #1 + \__chk_if_free_cs:N #1 \cs_gset_nopar:Npx #1 {#2} } \cs_generate_variant:Nn \tl_const:Nn { c } @@ -90,6 +90,12 @@ \cs_new_eq:NN \tl_gset_eq:cN \cs_gset_eq:cN \cs_new_eq:NN \tl_gset_eq:Nc \cs_gset_eq:Nc \cs_new_eq:NN \tl_gset_eq:cc \cs_gset_eq:cc +\cs_new_protected:Npn \tl_concat:NNN #1#2#3 + { \tl_set:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } } +\cs_new_protected:Npn \tl_gconcat:NNN #1#2#3 + { \tl_gset:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } } +\cs_generate_variant:Nn \tl_concat:NNN { ccc } +\cs_generate_variant:Nn \tl_gconcat:NNN { ccc } \cs_new_eq:NN \tl_if_exist:NTF \cs_if_exist:NTF \cs_new_eq:NN \tl_if_exist:NT \cs_if_exist:NT \cs_new_eq:NN \tl_if_exist:NF \cs_if_exist:NF @@ -98,6 +104,8 @@ \cs_new_eq:NN \tl_if_exist:cT \cs_if_exist:cT \cs_new_eq:NN \tl_if_exist:cF \cs_if_exist:cF \cs_new_eq:NN \tl_if_exist_p:c \cs_if_exist_p:c +\tl_const:Nx \c_job_name_tl { \tex_jobname:D } +\tl_const:Nn \c_space_tl { ~ } \cs_new_protected:Npn \tl_set:Nn #1#2 { \cs_set_nopar:Npx #1 { \exp_not:n {#2} } } \cs_new_protected:Npn \tl_set:No #1#2 @@ -172,18 +180,18 @@ \tex_lowercase:D { \group_end: - \tl_const:Nn \c_tl_rescan_marker_tl { A B } + \tl_const:Nn \c__tl_rescan_marker_tl { A B } } \cs_new_protected_nopar:Npn \tl_set_rescan:Nnn - { \tl_set_rescan_aux:NNnn \tl_set:Nn } + { \__tl_set_rescan:NNnn \tl_set:Nn } \cs_new_protected_nopar:Npn \tl_gset_rescan:Nnn - { \tl_set_rescan_aux:NNnn \tl_gset:Nn } + { \__tl_set_rescan:NNnn \tl_gset:Nn } \cs_new_protected_nopar:Npn \tl_rescan:nn - { \tl_set_rescan_aux:NNnn \prg_do_nothing: \use:n } -\cs_new_protected:Npn \tl_set_rescan_aux:NNnn #1#2#3#4 + { \__tl_set_rescan:NNnn \prg_do_nothing: \use:n } +\cs_new_protected:Npn \__tl_set_rescan:NNnn #1#2#3#4 { \group_begin: - \exp_args:No \etex_everyeof:D { \c_tl_rescan_marker_tl \exp_not:N } + \exp_args:No \etex_everyeof:D { \c__tl_rescan_marker_tl \exp_not:N } \tex_endlinechar:D \c_minus_one \tex_newlinechar:D \c_minus_one #3 @@ -192,7 +200,7 @@ \group_end: #1 \exp_not:N #2 { - \exp_after:wN \tl_rescan_aux:w + \exp_after:wN \__tl_rescan:w \exp_after:wN \prg_do_nothing: \etex_scantokens:D {#4} } @@ -200,8 +208,8 @@ } \use:x { - \cs_new:Npn \exp_not:N \tl_rescan_aux:w ##1 - \c_tl_rescan_marker_tl + \cs_new:Npn \exp_not:N \__tl_rescan:w ##1 + \c__tl_rescan_marker_tl { \exp_not:N \exp_not:o { ##1 } } } \cs_generate_variant:Nn \tl_set_rescan:Nnn { Nno , Nnx } @@ -211,27 +219,27 @@ \cs_new_eq:NN \tl_to_lowercase:n \tex_lowercase:D \cs_new_eq:NN \tl_to_uppercase:n \tex_uppercase:D \cs_new_protected_nopar:Npn \tl_replace_once:Nnn - { \tl_replace_aux:NNNnn \tl_replace_once_aux: \tl_set:Nx } + { \__tl_replace:NNNnn \__tl_replace_once: \tl_set:Nx } \cs_new_protected_nopar:Npn \tl_greplace_once:Nnn - { \tl_replace_aux:NNNnn \tl_replace_once_aux: \tl_gset:Nx } + { \__tl_replace:NNNnn \__tl_replace_once: \tl_gset:Nx } \cs_new_protected_nopar:Npn \tl_replace_all:Nnn - { \tl_replace_aux:NNNnn \tl_replace_all_aux: \tl_set:Nx } + { \__tl_replace:NNNnn \__tl_replace_all: \tl_set:Nx } \cs_new_protected_nopar:Npn \tl_greplace_all:Nnn - { \tl_replace_aux:NNNnn \tl_replace_all_aux: \tl_gset:Nx } + { \__tl_replace:NNNnn \__tl_replace_all: \tl_gset:Nx } \cs_generate_variant:Nn \tl_replace_once:Nnn { c } \cs_generate_variant:Nn \tl_greplace_once:Nnn { c } \cs_generate_variant:Nn \tl_replace_all:Nnn { c } \cs_generate_variant:Nn \tl_greplace_all:Nnn { c } -\cs_new_protected:Npn \tl_replace_aux:NNNnn #1#2#3#4#5 +\cs_new_protected:Npn \__tl_replace:NNNnn #1#2#3#4#5 { \tl_if_empty:nTF {#4} { - \msg_kernel_error:nnx { tl } { empty-search-pattern } + \__msg_kernel_error:nnx { kernel } { empty-search-pattern } { \tl_to_str:n {#5} } } { \group_align_safe_begin: - \cs_set:Npx \tl_tmp:w ##1##2 #4 + \cs_set:Npx \__tl_tmp:w ##1##2 #4 { ##2 \exp_not:N \q_mark @@ -247,18 +255,18 @@ } } } -\cs_new:Npn \tl_replace_aux_ii:w #1 \q_mark #2 { \exp_not:o {#1} } -\cs_new:Npn \tl_replace_all_aux: +\cs_new:Npn \__tl_replace:w #1 \q_mark #2 { \exp_not:o {#1} } +\cs_new_nopar:Npn \__tl_replace_all: { - \exp_after:wN \tl_replace_aux_ii:w - \tl_tmp:w \tl_replace_all_aux: \prg_do_nothing: + \exp_after:wN \__tl_replace:w + \__tl_tmp:w \__tl_replace_all: \prg_do_nothing: } -\cs_new_nopar:Npn \tl_replace_once_aux: +\cs_new_nopar:Npn \__tl_replace_once: { - \exp_after:wN \tl_replace_aux_ii:w - \tl_tmp:w { \tl_replace_once_aux_end:w \prg_do_nothing: } \prg_do_nothing: + \exp_after:wN \__tl_replace:w + \__tl_tmp:w { \__tl_replace_once_end:w \prg_do_nothing: } \prg_do_nothing: } -\cs_new:Npn \tl_replace_once_aux_end:w #1 \q_mark #2 \q_stop +\cs_new:Npn \__tl_replace_once_end:w #1 \q_mark #2 \q_stop { \exp_not:o {#1} } \cs_new_protected:Npn \tl_remove_once:Nn #1#2 { \tl_replace_once:Nnn #1 {#2} { } } @@ -273,7 +281,7 @@ \cs_generate_variant:Nn \tl_remove_all:Nn { c } \cs_generate_variant:Nn \tl_gremove_all:Nn { c } \prg_new_conditional:Npnn \tl_if_blank:n #1 { p , T , F , TF } - { \tl_if_empty_return:o { \use_none:n #1 ? } } + { \__tl_if_empty_return:o { \use_none:n #1 ? } } \cs_generate_variant:Nn \tl_if_blank_p:n { V } \cs_generate_variant:Nn \tl_if_blank:nT { V } \cs_generate_variant:Nn \tl_if_blank:nF { V } @@ -306,7 +314,7 @@ \cs_generate_variant:Nn \tl_if_empty:nTF { V } \cs_generate_variant:Nn \tl_if_empty:nT { V } \cs_generate_variant:Nn \tl_if_empty:nF { V } -\cs_new:Npn \tl_if_empty_return:o #1 +\cs_new:Npn \__tl_if_empty_return:o #1 { \exp_after:wN \if_meaning:w \exp_after:wN \q_nil \tl_to_str:n \exp_after:wN {#1} \q_nil @@ -316,7 +324,7 @@ \fi: } \prg_new_conditional:Npnn \tl_if_empty:o #1 { p , TF , T , F } - { \tl_if_empty_return:o {#1} } + { \__tl_if_empty_return:o {#1} } \prg_new_conditional:Npnn \tl_if_eq:NN #1#2 { p , T , F , TF } { \if_meaning:w #1 #2 @@ -352,173 +360,269 @@ \cs_generate_variant:Nn \tl_if_in:NnTF { c } \prg_new_protected_conditional:Npnn \tl_if_in:nn #1#2 { T , F , TF } { - \cs_set:Npn \tl_tmp:w ##1 #2 { } - \tl_if_empty:oTF { \tl_tmp:w #1 {} {} #2 } + \cs_set:Npn \__tl_tmp:w ##1 #2 { } + \tl_if_empty:oTF { \__tl_tmp:w #1 {} {} #2 } { \prg_return_false: } { \prg_return_true: } } \cs_generate_variant:Nn \tl_if_in:nnT { V , o , no } \cs_generate_variant:Nn \tl_if_in:nnF { V , o , no } \cs_generate_variant:Nn \tl_if_in:nnTF { V , o , no } +\cs_new:Npn \tl_if_single_p:N { \exp_args:No \tl_if_single_p:n } +\cs_new:Npn \tl_if_single:NT { \exp_args:No \tl_if_single:nT } +\cs_new:Npn \tl_if_single:NF { \exp_args:No \tl_if_single:nF } +\cs_new:Npn \tl_if_single:NTF { \exp_args:No \tl_if_single:nTF } +\prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF } + { \__str_if_eq_x_return:nn { \exp_not:o { \use_none:nn #1 ?? } } {?} } +\cs_new:Npn \tl_case:Nnn #1#2#3 + { + \tex_romannumeral:D + \__tl_case:Nw #1 #2 #1 {#3} \q_recursion_stop + } +\cs_new:Npn \__tl_case:Nw #1#2#3 + { + \tl_if_eq:NNTF #1 #2 + { \__tl_case_end:nw {#3} } + { \__tl_case:Nw #1 } + } +\cs_generate_variant:Nn \tl_case:Nnn { c } +\cs_new_eq:NN \__tl_case_end:nw \__prg_case_end:nw \cs_new:Npn \tl_map_function:nN #1#2 { - \tl_map_function_aux:Nn #2 #1 + \__tl_map_function:Nn #2 #1 \q_recursion_tail - \prg_break_point:n { } + \__prg_break_point:Nn \tl_map_break: { } } \cs_new_nopar:Npn \tl_map_function:NN { \exp_args:No \tl_map_function:nN } -\cs_new:Npn \tl_map_function_aux:Nn #1#2 +\cs_new:Npn \__tl_map_function:Nn #1#2 { - \quark_if_recursion_tail_break:n {#2} - #1 {#2} \tl_map_function_aux:Nn #1 + \__quark_if_recursion_tail_break:nN {#2} \tl_map_break: + #1 {#2} \__tl_map_function:Nn #1 } \cs_generate_variant:Nn \tl_map_function:NN { c } \cs_new_protected:Npn \tl_map_inline:nn #1#2 { - \int_gincr:N \g_prg_map_int - \cs_gset:cpn { tl_map_inline_ \int_use:N \g_prg_map_int :n } - ##1 {#2} - \exp_args:Nc \tl_map_function_aux:Nn - { tl_map_inline_ \int_use:N \g_prg_map_int :n } + \int_gincr:N \g__prg_map_int + \cs_gset:cpn { __prg_map_ \int_use:N \g__prg_map_int :w } ##1 {#2} + \exp_args:Nc \__tl_map_function:Nn + { __prg_map_ \int_use:N \g__prg_map_int :w } #1 \q_recursion_tail - \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + \__prg_break_point:Nn \tl_map_break: { \int_gdecr:N \g__prg_map_int } } \cs_new_protected:Npn \tl_map_inline:Nn { \exp_args:No \tl_map_inline:nn } \cs_generate_variant:Nn \tl_map_inline:Nn { c } \cs_new_protected:Npn \tl_map_variable:nNn #1#2#3 { - \tl_map_variable_aux:Nnn #2 {#3} #1 + \__tl_map_variable:Nnn #2 {#3} #1 \q_recursion_tail - \prg_break_point:n { } + \__prg_break_point:Nn \tl_map_break: { } } \cs_new_protected_nopar:Npn \tl_map_variable:NNn { \exp_args:No \tl_map_variable:nNn } -\cs_new_protected:Npn \tl_map_variable_aux:Nnn #1#2#3 +\cs_new_protected:Npn \__tl_map_variable:Nnn #1#2#3 { \tl_set:Nn #1 {#3} - \quark_if_recursion_tail_break:N #1 + \__quark_if_recursion_tail_break:NN #1 \tl_map_break: \use:n {#2} - \tl_map_variable_aux:Nnn #1 {#2} + \__tl_map_variable:Nnn #1 {#2} } \cs_generate_variant:Nn \tl_map_variable:NNn { c } -\cs_new_eq:NN \tl_map_break: \prg_map_break: -\cs_new_eq:NN \tl_map_break:n \prg_map_break:n +\cs_new_nopar:Npn \tl_map_break: + { \__prg_map_break:Nn \tl_map_break: { } } +\cs_new_nopar:Npn \tl_map_break:n + { \__prg_map_break:Nn \tl_map_break: } \cs_new_eq:NN \tl_to_str:n \etex_detokenize:D \cs_new:Npn \tl_to_str:N #1 { \etex_detokenize:D \exp_after:wN {#1} } \cs_generate_variant:Nn \tl_to_str:N { c } \cs_new:Npn \tl_use:N #1 { \tl_if_exist:NTF #1 {#1} - { \msg_expandable_kernel_error:nnn { kernel } { bad-var } {#1} } + { \__msg_kernel_expandable_error:nnn { kernel } { bad-variable } {#1} } } \cs_generate_variant:Nn \tl_use:N { c } -\cs_new:Npn \tl_length:n #1 +\cs_new:Npn \tl_count:n #1 { \int_eval:n - { 0 \tl_map_function:nN {#1} \tl_length_aux:n } + { 0 \tl_map_function:nN {#1} \__tl_count:n } } -\cs_new:Npn \tl_length:N #1 +\cs_new:Npn \tl_count:N #1 { \int_eval:n - { 0 \tl_map_function:NN #1 \tl_length_aux:n } + { 0 \tl_map_function:NN #1 \__tl_count:n } } -\cs_new:Npn \tl_length_aux:n #1 { + \c_one } -\cs_generate_variant:Nn \tl_length:n { V , o } -\cs_generate_variant:Nn \tl_length:N { c } +\cs_new:Npn \__tl_count:n #1 { + \c_one } +\cs_generate_variant:Nn \tl_count:n { V , o } +\cs_generate_variant:Nn \tl_count:N { c } \cs_new:Npn \tl_reverse_items:n #1 { - \tl_reverse_items_aux:nwNwn #1 ? - \q_mark \tl_reverse_items_aux:nwNwn - \q_mark \tl_reverse_items_aux:wn + \__tl_reverse_items:nwNwn #1 ? + \q_mark \__tl_reverse_items:nwNwn + \q_mark \__tl_reverse_items:wn \q_stop { } } -\cs_new:Npn \tl_reverse_items_aux:nwNwn #1 #2 \q_mark #3 #4 \q_stop #5 +\cs_new:Npn \__tl_reverse_items:nwNwn #1 #2 \q_mark #3 #4 \q_stop #5 { #3 #2 - \q_mark \tl_reverse_items_aux:nwNwn - \q_mark \tl_reverse_items_aux:wn + \q_mark \__tl_reverse_items:nwNwn + \q_mark \__tl_reverse_items:wn \q_stop { {#1} #5 } } -\cs_new:Npn \tl_reverse_items_aux:wn #1 \q_stop #2 +\cs_new:Npn \__tl_reverse_items:wn #1 \q_stop #2 { \exp_not:o { \use_none:nn #2 } } -\cs_set:Npn \tl_tmp:w #1 +\cs_new:Npn \tl_trim_spaces:n #1 + { \__tl_trim_spaces:nn { \q_mark #1 } \exp_not:o } +\cs_new_protected:Npn \tl_trim_spaces:N #1 + { \tl_set:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } } +\cs_new_protected:Npn \tl_gtrim_spaces:N #1 + { \tl_gset:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } } +\cs_generate_variant:Nn \tl_trim_spaces:N { c } +\cs_generate_variant:Nn \tl_gtrim_spaces:N { c } +\cs_set:Npn \__tl_tmp:w #1 { - \cs_new:Npn \tl_trim_spaces:n ##1 + \cs_new:Npn \__tl_trim_spaces:nn ##1 { - \etex_unexpanded:D - \tl_trim_spaces_aux_i:w - \q_mark + \__tl_trim_spaces_i:w ##1 \q_nil \q_mark #1 { } - \q_mark \tl_trim_spaces_aux_ii:w - \tl_trim_spaces_aux_iii:w + \q_mark \__tl_trim_spaces_ii:w + \__tl_trim_spaces_iii:w #1 \q_nil - \tl_trim_spaces_aux_iv:w - \q_stop + \__tl_trim_spaces_iv:w + \q_stop } - \cs_new:Npn \tl_trim_spaces_aux_i:w ##1 \q_mark #1 ##2 \q_mark ##3 + \cs_new:Npn \__tl_trim_spaces_i:w ##1 \q_mark #1 ##2 \q_mark ##3 { ##3 - \tl_trim_spaces_aux_i:w + \__tl_trim_spaces_i:w \q_mark ##2 \q_mark #1 {##1} } - \cs_new:Npn \tl_trim_spaces_aux_ii:w ##1 \q_mark \q_mark ##2 + \cs_new:Npn \__tl_trim_spaces_ii:w + \__tl_trim_spaces_i:w \q_mark \q_mark ##1 { - \tl_trim_spaces_aux_iii:w - ##2 + \__tl_trim_spaces_iii:w + ##1 } - \cs_new:Npn \tl_trim_spaces_aux_iii:w ##1 #1 \q_nil ##2 + \cs_new:Npn \__tl_trim_spaces_iii:w ##1 #1 \q_nil ##2 { ##2 ##1 \q_nil - \tl_trim_spaces_aux_iii:w + \__tl_trim_spaces_iii:w } - \cs_new:Npn \tl_trim_spaces_aux_iv:w ##1 \q_nil ##2 \q_stop - { \exp_after:wN { \use_none:n ##1 } } + \cs_new:Npn \__tl_trim_spaces_iv:w ##1 \q_nil ##2 \q_stop ##3 + { ##3 { \use_none:n ##1 } } } -\tl_tmp:w { ~ } -\cs_new_protected:Npn \tl_trim_spaces:N #1 - { \tl_set:Nx #1 { \exp_after:wN \tl_trim_spaces:n \exp_after:wN {#1} } } -\cs_new_protected:Npn \tl_gtrim_spaces:N #1 - { \tl_gset:Nx #1 { \exp_after:wN \tl_trim_spaces:n \exp_after:wN {#1} } } -\cs_generate_variant:Nn \tl_trim_spaces:N { c } -\cs_generate_variant:Nn \tl_gtrim_spaces:N { c } +\__tl_tmp:w { ~ } +\cs_new:Npn \__tl_act:NNNnn #1#2#3#4#5 + { + \group_align_safe_begin: + \__tl_act_loop:w #5 \q__tl_act_mark \q__tl_act_stop + {#4} #1 #2 #3 + \__tl_act_result:n { } + } +\cs_new:Npn \__tl_act_loop:w #1 \q__tl_act_stop + { + \tl_if_head_is_N_type:nTF {#1} + { \__tl_act_normal:NwnNNN } + { + \tl_if_head_is_group:nTF {#1} + { \__tl_act_group:nwnNNN } + { \__tl_act_space:wwnNNN } + } + #1 \q__tl_act_stop + } +\cs_new:Npn \__tl_act_normal:NwnNNN #1 #2 \q__tl_act_stop #3#4 + { + \if_meaning:w \q__tl_act_mark #1 + \exp_after:wN \__tl_act_end:wn + \fi: + #4 {#3} #1 + \__tl_act_loop:w #2 \q__tl_act_stop + {#3} #4 + } +\cs_new:Npn \__tl_act_end:wn #1 \__tl_act_result:n #2 + { \group_align_safe_end: \c_zero #2 } +\cs_new:Npn \__tl_act_group:nwnNNN #1 #2 \q__tl_act_stop #3#4#5 + { + #5 {#3} {#1} + \__tl_act_loop:w #2 \q__tl_act_stop + {#3} #4 #5 + } +\exp_last_unbraced:NNo + \cs_new:Npn \__tl_act_space:wwnNNN \c_space_tl #1 \q__tl_act_stop #2#3#4#5 + { + #5 {#2} + \__tl_act_loop:w #1 \q__tl_act_stop + {#2} #3 #4 #5 + } +\cs_new:Npn \__tl_act_output:n #1 #2 \__tl_act_result:n #3 + { #2 \__tl_act_result:n { #3 #1 } } +\cs_new:Npn \__tl_act_reverse_output:n #1 #2 \__tl_act_result:n #3 + { #2 \__tl_act_result:n { #1 #3 } } +\cs_new:Npn \tl_reverse:n #1 + { + \etex_unexpanded:D \exp_after:wN + { + \tex_romannumeral:D + \__tl_act:NNNnn + \__tl_reverse_normal:nN + \__tl_reverse_group_preserve:nn + \__tl_reverse_space:n + { } + {#1} + } + } +\cs_generate_variant:Nn \tl_reverse:n { o , V } +\cs_new:Npn \__tl_reverse_normal:nN #1#2 + { \__tl_act_reverse_output:n {#2} } +\cs_new:Npn \__tl_reverse_group_preserve:nn #1#2 + { \__tl_act_reverse_output:n { {#2} } } +\cs_new:Npn \__tl_reverse_space:n #1 + { \__tl_act_reverse_output:n { ~ } } +\cs_new_protected:Npn \tl_reverse:N #1 + { \tl_set:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } } +\cs_new_protected:Npn \tl_greverse:N #1 + { \tl_gset:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } } +\cs_generate_variant:Nn \tl_reverse:N { c } +\cs_generate_variant:Nn \tl_greverse:N { c } \cs_new:Npn \tl_head:w #1#2 \q_stop {#1} \cs_new:Npn \tl_tail:w #1#2 \q_stop {#2} \cs_new:Npn \tl_head:n #1 { \etex_unexpanded:D \exp_after:wN { \tl_head:w #1 { } \q_stop } } \cs_new:Npn \tl_tail:n #1 - { \etex_unexpanded:D \tl_tail_aux:w #1 \q_mark { } \q_mark \q_stop } -\cs_new:Npn \tl_tail_aux:w #1 #2 \q_mark #3 \q_stop { {#2} } + { \etex_unexpanded:D \__tl_tail:w #1 \q_mark { } \q_mark \q_stop } +\cs_new:Npn \__tl_tail:w #1 #2 \q_mark #3 \q_stop { {#2} } \cs_new_nopar:Npn \tl_head:N { \exp_args:No \tl_head:n } \cs_generate_variant:Nn \tl_head:n { V , v , f } \cs_new_nopar:Npn \tl_tail:N { \exp_args:No \tl_tail:n } \cs_generate_variant:Nn \tl_tail:n { V , v , f } \cs_new: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_new:Npn \str_head_aux:w #1 ~ % +\cs_new:Npn \__str_head:w #1 ~ % { \tl_head:w #1 { ~ } } \cs_new: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_new:Npn \str_tail_aux:w #1 X #2 \q_stop { \fi: #1 } +\cs_new:Npn \__str_tail:w #1 X #2 \q_stop { \fi: #1 } \prg_new_conditional:Npnn \tl_if_head_eq_charcode:nN #1#2 { p , T , F , TF } { \if_charcode:w \exp_not:N #2 - \tl_if_head_N_type:nTF { #1 ? } - { \exp_after:wN \exp_not:N \tl_head:w #1 \q_nil \q_stop } + \tl_if_head_is_N_type:nTF { #1 ? } + { + \exp_after:wN \exp_not:N + \tl_head:w #1 { ? \use_none:nn } \q_stop + } { \str_head:n {#1} } \prg_return_true: \else: @@ -533,10 +637,13 @@ { \if_catcode:w \exp_not:N #2 - \tl_if_head_N_type:nTF { #1 ? } - { \exp_after:wN \exp_not:N \tl_head:w #1 \q_nil \q_stop } + \tl_if_head_is_N_type:nTF { #1 ? } + { + \exp_after:wN \exp_not:N + \tl_head:w #1 { ? \use_none:nn } \q_stop + } { - \tl_if_head_group:nTF {#1} + \tl_if_head_is_group:nTF {#1} { \c_group_begin_token } { \c_space_token } } @@ -547,20 +654,21 @@ } \prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 { p , T , F , TF } { - \tl_if_head_N_type:nTF { #1 ? } - { \tl_if_head_eq_meaning_aux_normal:nN } - { \tl_if_head_eq_meaning_aux_special:nN } + \tl_if_head_is_N_type:nTF { #1 ? } + { \__tl_if_head_eq_meaning_normal:nN } + { \__tl_if_head_eq_meaning_special:nN } {#1} #2 } -\cs_new:Npn \tl_if_head_eq_meaning_aux_normal:nN #1 #2 +\cs_new:Npn \__tl_if_head_eq_meaning_normal:nN #1 #2 { - \exp_after:wN \if_meaning:w \tl_head:w #1 \q_nil \q_stop #2 + \exp_after:wN \if_meaning:w + \tl_head:w #1 { ?? \use_none:nnn } \q_stop #2 \prg_return_true: \else: \prg_return_false: \fi: } -\cs_new:Npn \tl_if_head_eq_meaning_aux_special:nN #1 #2 +\cs_new:Npn \__tl_if_head_eq_meaning_special:nN #1 #2 { \if_charcode:w \str_head:n {#1} \exp_not:N #2 \exp_after:wN \use:n @@ -570,7 +678,7 @@ \fi: { \if_catcode:w \exp_not:N #2 - \tl_if_head_group:nTF {#1} + \tl_if_head_is_group:nTF {#1} { \c_group_begin_token } { \c_space_token } \prg_return_true: @@ -579,13 +687,13 @@ \fi: } } -\prg_new_conditional:Npnn \tl_if_head_N_type:n #1 { p , T , F , TF } +\prg_new_conditional:Npnn \tl_if_head_is_N_type:n #1 { p , T , F , TF } { - \str_if_eq_return:xx + \__str_if_eq_x_return:nn { \exp_not:o { \use:n #1 { } } } { \exp_not:n { #1 { } } } } -\prg_new_conditional:Npnn \tl_if_head_group:n #1 { p , T , F , TF } +\prg_new_conditional:Npnn \tl_if_head_is_group:n #1 { p , T , F , TF } { \if_catcode:w * \exp_after:wN \use_none:n @@ -600,12 +708,12 @@ \prg_return_true: \fi: } -\prg_new_conditional:Npnn \tl_if_head_space:n #1 { p , T , F , TF } +\prg_new_conditional:Npnn \tl_if_head_is_space:n #1 { p , T , F , TF } { \tex_romannumeral:D \if_false: { \fi: - \tl_if_head_space_aux:w ? #1 ? ~ } + \__tl_if_head_is_space:w ? #1 ? ~ } } -\cs_new:Npn \tl_if_head_space_aux:w #1 ~ +\cs_new:Npn \__tl_if_head_is_space:w #1 ~ { \tl_if_empty:oTF { \use_none:n #1 } { \exp_after:wN \c_zero \exp_after:wN \prg_return_true: } @@ -615,218 +723,24 @@ \cs_new_protected:Npn \tl_show:N #1 { \cs_show:N #1 } \cs_generate_variant:Nn \tl_show:N { c } \cs_new_eq:NN \tl_show:n \etex_showtokens:D -\tl_const:Nx \c_job_name_tl { \tex_jobname:D } -\tl_const:Nn \c_space_tl { ~ } \tl_new:N \g_tmpa_tl \tl_new:N \g_tmpb_tl \tl_new:N \l_tmpa_tl \tl_new:N \l_tmpb_tl -\cs_new:Npn \str_if_eq_return:xx #1 #2 - { - \if_int_compare:w \pdftex_strcmp:D {#1} {#2} = \c_zero - \prg_return_true: - \else: - \prg_return_false: - \fi: - } -\cs_new:Npn \tl_if_single_p:N { \exp_args:No \tl_if_single_p:n } -\cs_new:Npn \tl_if_single:NT { \exp_args:No \tl_if_single:nT } -\cs_new:Npn \tl_if_single:NF { \exp_args:No \tl_if_single:nF } -\cs_new:Npn \tl_if_single:NTF { \exp_args:No \tl_if_single:nTF } -\prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF } - { \str_if_eq_return:xx { \exp_not:o { \use_none:nn #1 ?? } } {?} } -\prg_new_conditional:Npnn \tl_if_single_token:n #1 { p , T , F , TF } - { - \tl_if_head_N_type:nTF {#1} - { \str_if_eq_return:xx { \exp_not:o { \use_none:n #1 } } { } } - { \str_if_eq_return:xx { \exp_not:n {#1} } { ~ } } - } -\cs_new:Npn \tl_act:NNNnn { \tex_romannumeral:D \tl_act_aux:NNNnn } -\cs_new:Npn \tl_act_aux:NNNnn #1 #2 #3 #4 #5 - { - \group_align_safe_begin: - \tl_act_loop:w #5 \q_tl_act_mark \q_tl_act_stop - {#4} #1 #2 #3 - \tl_act_result:n { } - } -\cs_new:Npn \tl_act_loop:w #1 \q_tl_act_stop - { - \tl_if_head_N_type:nTF {#1} - { \tl_act_normal:NwnNNN } - { - \tl_if_head_group:nTF {#1} - { \tl_act_group:nwnNNN } - { \tl_act_space:wwnNNN } - } - #1 \q_tl_act_stop - } -\cs_new:Npn \tl_act_normal:NwnNNN #1 #2 \q_tl_act_stop #3#4 - { - \if_meaning:w \q_tl_act_mark #1 - \exp_after:wN \tl_act_end:wn - \fi: - #4 {#3} #1 - \tl_act_loop:w #2 \q_tl_act_stop - {#3} #4 - } -\cs_new:Npn \tl_act_end:wn #1 \tl_act_result:n #2 - { \group_align_safe_end: \c_zero #2 } -\cs_new:Npn \tl_act_group:nwnNNN #1 #2 \q_tl_act_stop #3#4#5 - { - #5 {#3} {#1} - \tl_act_loop:w #2 \q_tl_act_stop - {#3} #4 #5 - } -\exp_last_unbraced:NNo - \cs_new:Npn \tl_act_space:wwnNNN \c_space_tl #1 \q_tl_act_stop #2#3#4#5 - { - #5 {#2} - \tl_act_loop:w #1 \q_tl_act_stop - {#2} #3 #4 #5 - } -\cs_new:Npn \tl_act_output:n #1 #2 \tl_act_result:n #3 - { #2 \tl_act_result:n { #3 #1 } } -\cs_new:Npn \tl_act_reverse_output:n #1 #2 \tl_act_result:n #3 - { #2 \tl_act_result:n { #1 #3 } } -\cs_new:Npn \tl_act_group_recurse:Nnn #1#2#3 - { - \exp_args:Nf #1 - { \exp_after:wN \exp_after:wN \exp_after:wN { #2 {#3} } } - } -\cs_new:Npn \tl_reverse_tokens:n #1 - { - \etex_unexpanded:D \exp_after:wN - { - \tex_romannumeral:D - \tl_act_aux:NNNnn - \tl_act_reverse_normal:nN - \tl_act_reverse_group:nn - \tl_act_reverse_space:n - { } - {#1} - } - } -\cs_new:Npn \tl_act_reverse_space:n #1 - { \tl_act_reverse_output:n {~} } -\cs_new:Npn \tl_act_reverse_normal:nN #1 #2 - { \tl_act_reverse_output:n {#2} } -\cs_new:Npn \tl_act_reverse_group:nn #1 - { - \tl_act_group_recurse:Nnn - \tl_act_reverse_output:n - { \tl_reverse_tokens:n } - } -\cs_new:Npn \tl_reverse:n #1 - { - \etex_unexpanded:D \exp_after:wN - { - \tex_romannumeral:D - \tl_act_aux:NNNnn - \tl_act_reverse_normal:nN - \tl_act_reverse_group_preserve:nn - \tl_act_reverse_space:n - { } - {#1} - } - } -\cs_new:Npn \tl_act_reverse_group_preserve:nn #1 #2 - { \tl_act_reverse_output:n { {#2} } } -\cs_generate_variant:Nn \tl_reverse:n { o , V } -\cs_new_protected:Npn \tl_reverse:N #1 - { \tl_set:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } } -\cs_new_protected:Npn \tl_greverse:N #1 - { \tl_gset:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } } -\cs_generate_variant:Nn \tl_reverse:N { c } -\cs_generate_variant:Nn \tl_greverse:N { c } -\cs_new:Npn \tl_length_tokens:n #1 - { - \int_eval:n - { - \tl_act_aux:NNNnn - \tl_act_length_normal:nN - \tl_act_length_group:nn - \tl_act_length_space:n - { } - {#1} - } - } -\cs_new:Npn \tl_act_length_normal:nN #1 #2 { 1 + } -\cs_new:Npn \tl_act_length_space:n #1 { 1 + } -\cs_new:Npn \tl_act_length_group:nn #1 #2 - { 2 + \tl_length_tokens:n {#2} + } -\tl_const:Nn \c_tl_act_uppercase_tl - { - aA bB cC dD eE fF gG hH iI jJ kK lL mM - nN oO pP qQ rR sS tT uU vV wW xX yY zZ - } -\tl_const:Nn \c_tl_act_lowercase_tl - { - Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm - Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz - } -\cs_new:Npn \tl_expandable_uppercase:n #1 - { - \etex_unexpanded:D \exp_after:wN - { - \tex_romannumeral:D - \tl_act_case_aux:nn { \c_tl_act_uppercase_tl } {#1} - } - } -\cs_new:Npn \tl_expandable_lowercase:n #1 - { - \etex_unexpanded:D \exp_after:wN - { - \tex_romannumeral:D - \tl_act_case_aux:nn { \c_tl_act_lowercase_tl } {#1} - } - } -\cs_new:Npn \tl_act_case_aux:nn - { - \tl_act_aux:NNNnn - \tl_act_case_normal:nN - \tl_act_case_group:nn - \tl_act_case_space:n - } -\cs_new:Npn \tl_act_case_space:n #1 { \tl_act_output:n {~} } -\cs_new:Npn \tl_act_case_normal:nN #1 #2 - { - \exp_args:Nf \tl_act_output:n - { - \exp_args:NNo \prg_case_str:nnn #2 {#1} - { \exp_stop_f: #2 } - } - } -\cs_new:Npn \tl_act_case_group:nn #1 #2 - { - \exp_after:wN \tl_act_output:n \exp_after:wN - { \exp_after:wN { \tex_romannumeral:D \tl_act_case_aux:nn {#1} {#2} } } - } -\cs_new:Npn \tl_item:nn #1#2 - { - \exp_args:Nf \tl_item_aux:nn - { - \int_eval:n - { - \int_compare:nNnT {#2} < \c_zero - { \tl_length:n {#1} + } - #2 - } - } - #1 - \q_recursion_tail - \prg_break_point:n { } - } -\cs_new:Npn \tl_item_aux:nn #1#2 - { - \quark_if_recursion_tail_break:n {#2} - \int_compare:nNnTF {#1} = \c_zero - { \tl_map_break:n { \exp_not:n {#2} } } - { \exp_args:Nf \tl_item_aux:nn { \int_eval:n { #1 - 1 } } } - } -\cs_new_nopar:Npn \tl_item:Nn { \exp_args:No \tl_item:nn } -\cs_generate_variant:Nn \tl_item:Nn { c } +\cs_new_eq:NN \tl_length_tokens:n \tl_count_tokens:n +\cs_new_eq:NN \tl_length:N \tl_count:N +\cs_new_eq:NN \tl_length:c \tl_count:c +\cs_new_eq:NN \tl_length:n \tl_count:n +\cs_new_eq:NN \tl_length:V \tl_count:V +\cs_new_eq:NN \tl_length:o \tl_count:o \prg_new_conditional:Npnn \tl_if_empty:x #1 { p , T , F , TF } - { \str_if_eq_return:xx { } {#1} } + { \__str_if_eq_x_return:nn { } {#1} } +\prg_new_eq_conditional:NNn \tl_if_head_group:n \tl_if_head_is_group:n + { p , T , F , TF } +\prg_new_eq_conditional:NNn \tl_if_head_N_type:n \tl_if_head_is_N_type:n + { p , T , F , TF } +\prg_new_eq_conditional:NNn \tl_if_head_space:n \tl_if_head_is_space:n + { p , T , F , TF } %% %% %% End of file `l3tl.sty'. |