diff options
author | Karl Berry <karl@freefriends.org> | 2015-09-22 22:26:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-09-22 22:26:04 +0000 |
commit | f1f4767bbed8d529512166e9ebc17c398bf22888 (patch) | |
tree | f30d0120390ea88ad9977aadb443354ca0cb05d4 /Master/texmf-dist/tex | |
parent | fb3db65044ad57f73474204792b8df34ee59d9e7 (diff) |
gtl (22sep15)
git-svn-id: svn://tug.org/texlive/trunk@38434 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/gtl/gtl.sty | 120 |
1 files changed, 64 insertions, 56 deletions
diff --git a/Master/texmf-dist/tex/latex/gtl/gtl.sty b/Master/texmf-dist/tex/latex/gtl/gtl.sty index 8bd342609b0..113686781c5 100644 --- a/Master/texmf-dist/tex/latex/gtl/gtl.sty +++ b/Master/texmf-dist/tex/latex/gtl/gtl.sty @@ -11,7 +11,7 @@ %% Communicate any suggestions for changing this package %% to Bruno Le Floch (blflatex@gmail.com). %% -%% File: gtl.dtx Copyright (C) 2013 Bruno Le Floch +%% File: gtl.dtx Copyright (C) 2013,2015 Bruno Le Floch %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -21,9 +21,9 @@ %% http://www.latex-project.org/lppl.txt %% %% ----------------------------------------------------------------------- -\RequirePackage{expl3}[2013/07/01] +\RequirePackage{expl3}[2015/09/11] \ProvidesExplPackage - {gtl} {2013/07/28} {0.0a} {Manipulate unbalanced lists of tokens} + {gtl} {2015/09/21} {0.1} {Manipulate unbalanced lists of tokens} \cs_generate_variant:Nn \use:nn { no } \cs_new:Npn \__gtl_exp_not_n:N #1 { \exp_not:n {#1} } \cs_new:Npn \__gtl_brace:nn #1#2 { { #1 #2 } } @@ -32,7 +32,7 @@ { \__gtl_strip_nil_mark_aux:w \prg_do_nothing: } \cs_new:Npn \__gtl_strip_nil_mark_aux:w #1 \q_nil \q_mark { \exp_not:o {#1} } -\__scan_new:N \s__gtl +\cs_new_eq:NN \s__gtl \scan_stop: \cs_new_protected_nopar:Npn \gtl_set:Nn { \__gtl_set:NNn \tl_set:Nn } \cs_new_protected_nopar:Npn \gtl_gset:Nn { \__gtl_set:NNn \tl_gset:Nn } \cs_new_protected_nopar:Npn \gtl_const:Nn { \__gtl_set:NNn \tl_const:Nn } @@ -40,10 +40,10 @@ \cs_new_protected_nopar:Npn \gtl_gset:Nx { \__gtl_set:NNn \tl_gset:Nx } \cs_new_protected_nopar:Npn \gtl_const:Nx { \__gtl_set:NNn \tl_const:Nx } \cs_new_protected:Npn \__gtl_set:NNn #1#2#3 - { #1 #2 { \s__gtl { } {#3} { } \s__stop } } + { #1 #2 { \s__gtl { } {#3} { } } } \gtl_const:Nn \c_empty_gtl { } -\tl_const:Nn \c_group_end_gtl { \s__gtl { { } } { } { } \s__stop } -\tl_const:Nn \c_group_begin_gtl { \s__gtl { } { } { { } } \s__stop } +\tl_const:Nn \c_group_end_gtl { \s__gtl { { } } { } { } } +\tl_const:Nn \c_group_begin_gtl { \s__gtl { } { } { { } } } \cs_new_protected:Npn \gtl_new:N #1 { \cs_new_eq:NN #1 \c_empty_gtl } \cs_new_eq:NN \gtl_set_eq:NN \tl_set_eq:NN @@ -62,39 +62,37 @@ { \tl_set:Nx #1 { \exp_after:wN \__gtl_put_left:wn #1 {#2} } } \cs_new_protected:Npn \gtl_gput_left:Nn #1#2 { \tl_gset:Nx #1 { \exp_after:wN \__gtl_put_left:wn #1 {#2} } } -\cs_new:Npn \__gtl_put_left:wn \s__gtl #1#2#3 \s__stop #4 +\cs_new:Npn \__gtl_put_left:wn \s__gtl #1#2#3 #4 { \tl_if_empty:nTF {#1} - { \exp_not:n { \s__gtl { } { #4 #2 } {#3} \s__stop } } + { \exp_not:n { \s__gtl { } { #4 #2 } {#3} } } { \s__gtl { \exp_not:o { \__gtl_brace:nn {#4} #1 } } { \exp_not:n {#2} } { \exp_not:n {#3} } - \s__stop } } \cs_new_protected:Npn \gtl_put_right:Nn #1#2 { \tl_set:Nx #1 { \exp_after:wN \__gtl_put_right:wn #1 {#2} } } \cs_new_protected:Npn \gtl_gput_right:Nn #1#2 { \tl_gset:Nx #1 { \exp_after:wN \__gtl_put_right:wn #1 {#2} } } -\cs_new:Npn \__gtl_put_right:wn \s__gtl #1#2#3 \s__stop #4 +\cs_new:Npn \__gtl_put_right:wn \s__gtl #1#2#3 #4 { \tl_if_empty:nTF {#3} - { \exp_not:n { \s__gtl {#1} { #2 #4 } { } \s__stop } } + { \exp_not:n { \s__gtl {#1} { #2 #4 } { } } } { \s__gtl { \exp_not:n {#1} } { \exp_not:n {#2} } { \exp_not:o { \__gtl_brace_swap:nn {#4} #3 } } - \s__stop } } \cs_new_protected:Npn \gtl_concat:NNN #1#2#3 { \tl_set:Nx #1 { \exp_last_two_unbraced:Noo \__gtl_concat:ww #2 #3 } } \cs_new_protected:Npn \gtl_gconcat:NNN #1#2#3 { \tl_gset:Nx #1 { \exp_last_two_unbraced:Noo \__gtl_concat:ww #2 #3 } } -\cs_new:Npn \__gtl_concat:ww \s__gtl #1#2#3 \s__stop \s__gtl #4#5#6 \s__stop +\cs_new:Npn \__gtl_concat:ww \s__gtl #1#2#3 \s__gtl #4#5#6 { \tl_if_blank:nTF {#3} { @@ -108,7 +106,6 @@ { \__gtl_concat_auxiv:nnnn } } {#1} {#2} {#3} {#4} {#5} {#6} - \s__stop } \cs_new:Npn \__gtl_concat_aux:nnnnnn #1#2#3#4#5#6 { \exp_not:n { \s__gtl {#1} { #2 #5 } {#6} } } @@ -146,19 +143,18 @@ #1#2 \q_mark #3#4 \q_mark #5#6 { \__gtl_concat:ww - \s__gtl {#5} { #6 { #1 #3 } } { } \s__stop + \s__gtl {#5} { #6 { #1 #3 } } { } \s__gtl {#4} } \cs_new:Npn \__gtl_concat_auxvi:nnwnwnn #1#2#3 \q_mark #4#5 \q_mark #6#7 { \__gtl_concat:ww - \s__gtl {#6} {#7} { { #2 { #1 #4 } } #3 } \s__stop + \s__gtl {#6} {#7} { { #2 { #1 #4 } } #3 } \s__gtl {#5} } \cs_new:Npn \gtl_to_str:N #1 { \exp_after:wN \__gtl_to_str:w #1 } -\cs_new:Npn \gtl_to_str:n #1 { \__gtl_to_str:w #1 } -\cs_new:Npn \__gtl_to_str:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_to_str:w \s__gtl #1#2#3 { \__gtl_to_str_loopi:nnw { } #1 \q_nil \q_mark {#2} {#3} } \cs_new:Npx \__gtl_to_str_loopi:nnw #1#2 { @@ -192,10 +188,18 @@ { #2 \iow_char:N \{ #1 } #3 \exp_not:N \q_stop } } -\cs_new_protected:Npn \gtl_show:N #1 - { \exp_args:Nx \tl_show:n { \token_to_str:N #1 = \gtl_to_str:N #1 } } -\prg_new_conditional:Npnn \gtl_if_eq:NN #1#2 { p , T , F , TF } - { \tl_if_eq:NNTF #1 #2 { \prg_return_true: } { \prg_return_false: } } +\cs_new_protected_nopar:Npn \gtl_show:N + { \__gtl_show:NNN \tl_show:n \tl_show:N } +\cs_new_protected_nopar:Npn \gtl_log:N + { \__gtl_show:NNN \tl_log:n \tl_log:N } +\cs_new_protected:Npn \__gtl_show:NNN #1#2#3 + { + \gtl_if_exist:NTF #3 + { \exp_args:Nx #1 { \token_to_str:N #3 = \gtl_to_str:N #3 } } + { #2 #3 } + } +\prg_new_eq_conditional:NNn \gtl_if_eq:NN \tl_if_eq:NN + { p , T , F , TF } \prg_new_conditional:Npnn \gtl_if_empty:N #1 { p , T , F , TF } { \tl_if_eq:NNTF #1 \c_empty_gtl @@ -203,30 +207,34 @@ } \prg_new_conditional:Npnn \gtl_if_tl:N #1 { p , T , F , TF } { \exp_after:wN \__gtl_if_tl_return:w #1 } -\cs_new:Npn \__gtl_if_tl_return:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_if_tl_return:w \s__gtl #1#2#3 { \tl_if_empty:nTF { #1 #3 } { \prg_return_true: } { \prg_return_false: } } \prg_new_conditional:Npnn \gtl_if_single_token:N #1 { p , T , F , TF } - { \exp_after:wN \__gtl_if_single_token_return:w #1 } -\cs_new:Npn \__gtl_if_single_token_return:w \s__gtl #1#2#3 \s__stop + { \exp_after:wN \__gtl_if_single_token_return:w #1 #1 } +\cs_new:Npn \__gtl_if_single_token_return:w \s__gtl #1#2#3 #4 { - \bool_if:nTF + \tl_if_empty:nTF { #1 #3 } { - \tl_if_empty_p:n {#2} - && \tl_if_single_p:n { #1 #3 } - && \tl_if_empty_p:o { \use:n #1 #3 } - || - \tl_if_single_token_p:n {#2} - && \tl_if_empty_p:n { #1 #3 } + \tl_if_single_token:nTF {#2} + { \prg_return_true: } + { \prg_return_false: } + } + { + \gtl_if_eq:NNTF #4 \c_group_begin_gtl + { \prg_return_true: } + { + \gtl_if_eq:NNTF #4 \c_group_end_gtl + { \prg_return_true: } + { \prg_return_false: } + } } - { \prg_return_true: } - { \prg_return_false: } } \prg_new_conditional:Npnn \gtl_if_blank:N #1 { p , T , F , TF } { \exp_after:wN \__gtl_if_blank_return:w #1 } -\cs_new:Npn \__gtl_if_blank_return:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_if_blank_return:w \s__gtl #1#2#3 { \tl_if_blank:nTF { #1 #2 #3 } { \prg_return_true: } @@ -309,7 +317,7 @@ \prg_return_false: \fi: } -\cs_new:Npn \__gtl_head:wnnnnn \s__gtl #1#2#3 \s__stop #4#5#6#7#8 +\cs_new:Npn \__gtl_head:wnnnnn \s__gtl #1#2#3 #4#5#6#7#8 { \tl_if_empty:nTF {#1} { @@ -365,10 +373,16 @@ { \gtl_set:Nn #2 } } \cs_new_protected:Npn \gtl_pop_left:N #1 - { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left:w #1 } } + { + \gtl_if_empty:NF #1 + { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left:w #1 } } + } \cs_new_protected:Npn \gtl_gpop_left:N #1 - { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left:w #1 } } -\cs_new:Npn \__gtl_pop_left:w \s__gtl #1#2#3 \s__stop + { + \gtl_if_empty:NF #1 + { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left:w #1 } } + } +\cs_new:Npn \__gtl_pop_left:w \s__gtl #1#2#3 { \tl_if_empty:nTF {#1} { @@ -383,7 +397,6 @@ \s__gtl { } \__gtl_pop_left_auxii:nnnw { } { } #1 \q_nil \q_stop - \s__stop } \cs_new:Npn \__gtl_pop_left_auxii:nnnw #1#2#3 { @@ -403,7 +416,6 @@ { \tl_if_head_is_group:nT {#1} { { \tl_head:n {#1} } } } { \tl_if_head_is_space:nTF {#1} { \exp_not:f } { \tl_tail:n } {#1} } { \exp_not:n {#2} } - \s__stop } \cs_new:Npn \__gtl_pop_left_auxv:nnn #1#2#3 { @@ -411,7 +423,6 @@ { \if_false: { \fi: \__gtl_pop_left_auxvi:n #1 } } { \exp_not:n {#2} } { \exp_not:n {#3} } - \s__stop } \cs_new:Npn \__gtl_pop_left_auxvi:n #1 { @@ -437,13 +448,13 @@ } \cs_new:Npn \gtl_left_tl:N #1 { \exp_after:wN \__gtl_left_tl:w #1 } -\cs_new:Npn \__gtl_left_tl:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_left_tl:w \s__gtl #1#2#3 { \tl_if_empty:nTF {#1} { \exp_not:n {#2} } { \tl_head:n {#1} } } \cs_new_protected:Npn \gtl_pop_left_tl:N #1 { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left_tl:w #1 } } \cs_new_protected:Npn \gtl_gpop_left_tl:N #1 { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left_tl:w #1 } } -\cs_new:Npn \__gtl_pop_left_tl:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_pop_left_tl:w \s__gtl #1#2#3 { \s__gtl \tl_if_empty:nTF {#1} @@ -453,11 +464,10 @@ { \exp_not:n {#2} } } { \exp_not:n {#3} } - \s__stop } \cs_new:Npn \gtl_left_item:NF #1 { \exp_after:wN \__gtl_left_item:wF #1 } -\cs_new:Npn \__gtl_left_item:wF \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_left_item:wF \s__gtl #1#2#3 { \__gtl_left_item_auxi:nwF #1 {#2} \q_stop } \cs_new:Npn \__gtl_left_item_auxi:nwF #1#2 \q_stop #3 { \tl_if_blank:nTF {#1} {#3} { \tl_head:n {#1} } } @@ -466,7 +476,7 @@ \prg_new_protected_conditional:Npnn \gtl_gpop_left_item:NN #1#2 { TF , T , F } { \exp_after:wN \__gtl_pop_left_item:wNNN #1#2 \tl_gset:Nx #1 } \cs_new_protected:Npn \__gtl_pop_left_item:wNNN - \s__gtl #1#2#3 \s__stop #4#5#6 + \s__gtl #1#2#3 #4#5#6 { \tl_if_empty:nTF {#1} { @@ -476,7 +486,7 @@ #5 #6 { \s__gtl { } { \tl_tail:n {#2} } - { \exp_not:n {#3} } \s__stop + { \exp_not:n {#3} } } \prg_return_true: } @@ -498,14 +508,13 @@ { { \tl_tail:n {#1} } \__gtl_strip_nil_mark:w #2 \q_mark } { \exp_not:n {#3} } { \exp_not:n {#4} } - \s__stop } \prg_return_true: } } \cs_new:Npn \gtl_left_text:NF #1 { \exp_after:wN \__gtl_left_text:wF #1 } -\cs_new:Npn \__gtl_left_text:wF \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_left_text:wF \s__gtl #1#2#3 { \tl_if_empty:nTF {#1} { \__gtl_left_text_auxi:nwF {#2} \q_stop } @@ -521,7 +530,7 @@ { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left_text:w #1 } } \cs_new_protected:Npn \gtl_gpop_left_text:N #1 { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left_text:w #1 } } -\cs_new:Npn \__gtl_pop_left_text:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_pop_left_text:w \s__gtl #1#2#3 { \s__gtl \tl_if_empty:nTF {#1} @@ -534,7 +543,6 @@ { \exp_not:n {#2} } } { \exp_not:n {#3} } - \s__stop } \cs_new:Npn \__gtl_pop_left_text_auxi:n #1 { @@ -566,15 +574,15 @@ { \tl_if_empty:nF {#1} { + \c_one \__gtl_tl_count_loop:n #1 \q_stop } } \cs_new:Npn \gtl_extra_end:N #1 { \exp_after:wN \__gtl_extra_end:w #1 } -\cs_new:Npn \__gtl_extra_end:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_extra_end:w \s__gtl #1#2#3 { \__gtl_tl_count:n {#1} } \cs_new:Npn \gtl_extra_begin:N #1 { \exp_after:wN \__gtl_extra_begin:w #1 } -\cs_new:Npn \__gtl_extra_begin:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_extra_begin:w \s__gtl #1#2#3 { \__gtl_tl_count:n {#3} } \cs_new:Npn \gtl_count_tokens:N #1 { \exp_after:wN \__gtl_count_tokens:w #1 } -\cs_new:Npn \__gtl_count_tokens:w \s__gtl #1#2#3 \s__stop +\cs_new:Npn \__gtl_count_tokens:w \s__gtl #1#2#3 { \int_eval:n { \c_minus_one \__gtl_count_auxi:nw #1 {#2} #3 \q_nil \q_stop } |