diff options
author | Karl Berry <karl@freefriends.org> | 2023-06-05 20:31:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-06-05 20:31:01 +0000 |
commit | 820b8d08dcfc28a785decaedae8f19a7d2e4fdb5 (patch) | |
tree | c987499218a002f8e86c5a69d51b39a4fcf0084e /Master | |
parent | 91a45e4c0fde4de5bc9a4549322a95ad9df390aa (diff) |
starray (5jun23)
git-svn-id: svn://tug.org/texlive/trunk@67286 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/starray/README.md | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/starray/starray.pdf | bin | 266666 -> 266418 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/starray/starray.tex | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/starray/starray.sty | 220 |
4 files changed, 152 insertions, 77 deletions
diff --git a/Master/texmf-dist/doc/latex/starray/README.md b/Master/texmf-dist/doc/latex/starray/README.md index 3e5aec2fea8..e00db9e4a15 100644 --- a/Master/texmf-dist/doc/latex/starray/README.md +++ b/Master/texmf-dist/doc/latex/starray/README.md @@ -73,7 +73,10 @@ The Current Maintainer of this work is Alceu Frigeri ## Changelog -* Version 1.2 (this) +* Version 1.3 (this) + - Fixed issue #4, where (in some instances) _set_from_keyval could render a quark loop. + +* Version 1.2 - Issues #3 - added expandable versions of some commands (see manual) - documentation diff --git a/Master/texmf-dist/doc/latex/starray/starray.pdf b/Master/texmf-dist/doc/latex/starray/starray.pdf Binary files differindex 5fef74c7312..9523653f0a7 100644 --- a/Master/texmf-dist/doc/latex/starray/starray.pdf +++ b/Master/texmf-dist/doc/latex/starray/starray.pdf diff --git a/Master/texmf-dist/doc/latex/starray/starray.tex b/Master/texmf-dist/doc/latex/starray/starray.tex index d52e6ec1014..5837d2308fd 100644 --- a/Master/texmf-dist/doc/latex/starray/starray.tex +++ b/Master/texmf-dist/doc/latex/starray/starray.tex @@ -15,7 +15,7 @@ %% %% The Current Maintainer of this work is Alceu Frigeri %% -%% This is version 1.2 (2023/05/20) +%% This is version 1.3 (2023/06/04) %% %% The list of files that compose this work can be found in the README.md file at %% https://ctan.org/pkg/starray @@ -611,7 +611,7 @@ This can be used after any command which 'parses a term', for instance \tsobj{\s The \tsmacro{\starray_if_in:nnTF}{starray-ref,key,\ldots,\ldots} tests if a given \tsobj[marg]{key} is present, whilst \tsmacro{\starray_term_syntax:nTF}{starray-ref,if-true,if-false} just verifies if the \tsobj[marg]{starray-ref} syntax is valid or not, branching accordly. \end{codedescribe} -\begin{codedescribe}{\starray_term_syntax:n} +\begin{codedescribe}[code,new=2023/05/20]{\starray_term_syntax:n} \begin{codesyntax}% \tsmacro{\starray_term_syntax:n}{starray-ref} \end{codesyntax} diff --git a/Master/texmf-dist/tex/latex/starray/starray.sty b/Master/texmf-dist/tex/latex/starray/starray.sty index a475c3d0985..0bfe015ab24 100644 --- a/Master/texmf-dist/tex/latex/starray/starray.sty +++ b/Master/texmf-dist/tex/latex/starray/starray.sty @@ -12,7 +12,7 @@ %% %% The Current Maintainer of this work is Alceu Frigeri %% -%% This is version 1.2 (2023/05/20) +%% This is version 1.3 (2023/06/04) %% %% The list of files that compose this work can be found in the README.md file at %% https://ctan.org/pkg/starray @@ -24,8 +24,8 @@ \ProvidesExplPackage {starray} - {2023/05/20} - {1.2} + {2023/06/04} + {1.3} {A structured array/hash of properties} %%%%%%% @@ -38,8 +38,8 @@ { name .code:n = starray , prefix .code:n = starray , - date .code:n = 2023/05/20 , - version .code:n = 1.2 , + date .code:n = 2023/06/04, + version .code:n = 1.3 , description .code:n = A~structured~array/hash~of~properties } \cs_if_exist:NF \__codedesc_pkg_info:nn @@ -68,51 +68,61 @@ \keys_define:nn { starray } -{ - prefix .tl_set:N = \l__starray_prefix_tl , - prefix .value_required:n = true , - prefix .initial:n = l__starray_ , - prefix .usage:n = load , - - msg-err .choice: , - msg-err / none .code:n = { - % \msg_redirect_module:nnn { starray } { warning } { none } - }, - msg-err / default .code:n = {} , - msg-err / strict .code:n = { + { + prefix .tl_set:N = \l__starray_prefix_tl , + prefix .value_required:n = true , + prefix .initial:n = l__starray_ , + prefix .usage:n = load , + + msg-err .choice: , + msg-err / none .code:n = { }, + msg-err / default .code:n = {} , + msg-err / strict .code:n = + { \msg_redirect_module:nnn { starray / strict } { warning } { error } - }, - msg-err / syntax .code:n = { + } , + msg-err / syntax .code:n = + { \msg_redirect_module:nnn { starray / strict } { warning } { error } \msg_redirect_module:nnn { starray / syntax } { warning } { error } } , - msg-err / reference .code:n = { + msg-err / reference .code:n = + { \msg_redirect_module:nnn { starray / strict } { warning } { error } \msg_redirect_module:nnn { starray / syntax } { warning } { error } \msg_redirect_module:nnn { starray / reference } { warning } { error } } , - msg-err / all .code:n = \msg_redirect_module:nnn { starray } { warning } { error } , - msg-err . usage:n = load , - - msg-supress .choice: , - msg-supress / none .code:n = {} , - msg-supress / reference .code:n = { - \msg_redirect_module:nnn { starray / reference } { warning } { none } - }, - msg-supress / syntax .code:n = { - \msg_redirect_module:nnn { starray / strict } { warning } { none } - \msg_redirect_module:nnn { starray / syntax } { warning } { none } - } , - msg-supress / strict .code:n = { - \msg_redirect_module:nnn { starray / strict } { warning } { none } - \msg_redirect_module:nnn { starray / syntax } { warning } { none } - \msg_redirect_module:nnn { starray / reference } { warning } { none } - } , - msg-supress / all .code:n = \msg_redirect_module:nnn { starray } { warning } { none } , - msg-supress . usage:n = load , - - -} + msg-err / all .code:n = + { + \msg_redirect_module:nnn { starray } { warning } { error } + } , + msg-err . usage:n = load , + + msg-supress .choice: , + msg-supress / none .code:n = {} , + msg-supress / reference .code:n = + { + \msg_redirect_module:nnn { starray / reference } { warning } { none } + } , + msg-supress / syntax .code:n = + { + \msg_redirect_module:nnn { starray / strict } { warning } { none } + \msg_redirect_module:nnn { starray / syntax } { warning } { none } + } , + msg-supress / strict .code:n = + { + \msg_redirect_module:nnn { starray / strict } { warning } { none } + \msg_redirect_module:nnn { starray / syntax } { warning } { none } + \msg_redirect_module:nnn { starray / reference } { warning } { none } + } , + msg-supress / all .code:n = + { + \msg_redirect_module:nnn { starray } { warning } { none } + } , + msg-supress . usage:n = load , + + + } \ProcessKeyOptions [ starray ] @@ -363,7 +373,7 @@ %%%% parser related ones %%%% \bool_const:Nn \c__starray_no_idx_ending_bool \c_true_bool -\bool_const:Nn \c__starray_idx_ending_bool \c_false_bool +\bool_const:Nn \c__starray_idx_ending_bool \c_false_bool %%%% @@ -371,9 +381,9 @@ %%%% \tl_new:N \l__starray_parsed_tl \tl_new:N \l__starray_parsed_ref_tl +\tl_new:N \l__starray_parsed_ref_no_idx_ending_tl \tl_new:N \l__starray_parsed_base_ref_tl \tl_new:N \l__starray_parsed_root_ref_tl -\tl_new:N \l__starray_parsed_ref_no_idx_ending_tl \tl_new:N \l__starray_parsing_term_tl @@ -452,7 +462,10 @@ %%%% %%%%%%%%%%%%%%% %%%%%%%%%%%%%%% - +%%% +%%% TODO: to add another property list mapping hash/idx -> iter +%%% intend: \__starray_set_iter_hash ! +%%% % needs protection. \cs_new_protected:Npn \__starray_base_new:nn #1#2 { @@ -489,6 +502,11 @@ { \l__starray_prefix_tl #2 _base_prop } { idx_hash } \c_empty_prop + + \prop_gput:cnV + { \l__starray_prefix_tl #2 _base_prop } + { iter_hash } + \c_empty_prop } \cs_generate_variant:Nn \__starray_base_new:nn { ee } @@ -843,7 +861,6 @@ \cs_new_protected:Npn \starray_def_from_keyval:nn #1#2 { -% \bool_set_true:N \l__starray_rtn_bool \__starray_if_valid:nTF { \l__starray_prefix_tl #1 _def_prop} { \keyval_parse:nnn @@ -882,6 +899,10 @@ %%%% %%%%%%%%%%%%%%% %%%%%%%%%%%%%%% +%%% +%%% TODO: to add {_iter_from_hash} property {hash} -> iter (integer!) +%%% +%%% \cs_new_protected:Npn \__starray_new_term:nn #1#2 { @@ -895,20 +916,30 @@ % idx_hash Update. \prop_get:cnN {\l__starray_prefix_tl #1 _base_prop} {idx_hash} \l_tmpa_prop + \prop_get:cnN {\l__starray_prefix_tl #1 _base_prop} {iter_hash} \l_tmpb_prop \prop_put:Nee \l_tmpa_prop { \int_use:N \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } { \int_to_Alph:e { \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } } + \prop_put:Nee \l_tmpb_prop + { \int_use:N \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } + { \int_use:N \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } + \tl_if_blank:nF {#2} { \prop_put:Nee \l_tmpa_prop { #2 } { \int_to_Alph:e { \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } } + \prop_put:Nee \l_tmpb_prop + { #2 } + { \int_use:N \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } } \prop_gput:cnV {\l__starray_prefix_tl #1 _base_prop} {idx_hash} \l_tmpa_prop + \prop_gput:cnV {\l__starray_prefix_tl #1 _base_prop} {iter_hash} \l_tmpb_prop + % creating the 'new property list' (aka. term) \tl_set:Ne \l_tmpa_tl { \int_to_Alph:e { \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt} } } @@ -980,13 +1011,13 @@ \cs_new_protected:Npn \__starray_incr_iter:n #1 { \int_compare:nNnTF - {\prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {iter}} < - {\prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt}} + {\prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {iter}} < + {\prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {cnt}} { \int_gincr:N { \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {iter} } } { - % TODO: should it be a potential 'warning' ??? + % TODO: validade _rtn_bool for end user??? \bool_set_false:N \l__starray_rtn_bool } } @@ -1105,6 +1136,7 @@ {\prg_return_false:} } { + \bool_set_false:N \l__starray_rtn_bool \seq_clear:N \l__starray_msg_seq \prg_return_false: } @@ -1158,7 +1190,7 @@ \cs_new_protected:Npn \starray_next_iter:n #1 { -% \bool_set_true:N \l__starray_rtn_bool + \bool_set_true:N \l__starray_rtn_bool \seq_clear:N \l__starray_msg_seq \__starray_parser:nnTF {\c__starray_no_idx_ending_bool}{#1} @@ -1168,7 +1200,7 @@ } { \__starray_msg_dispatch: -% \bool_set_false:N \l__starray_rtn_bool + \bool_set_false:N \l__starray_rtn_bool \msg_warning:nnnn {starray} {syntax / iter} {iter:5} {#1} } % returns nothing by default } @@ -1188,7 +1220,10 @@ {\prg_return_true:} {\prg_return_false:} } - { \prg_return_false: } + { + \bool_set_false:N \l__starray_rtn_bool + \prg_return_false: + } } %%%%%%%%%%%%%%% @@ -1564,12 +1599,12 @@ -\cs_new_protected:Npn \__starray_set_from_keyval_parse:nnnn #1#2#3#4 +\cs_new:Npn \__starray_set_from_keyval_parse:nnnn #1#2#3#4 { \__starray_set_prop:nnn {#3}{#4}{} } -\cs_generate_variant:Nn \__starray_set_from_keyval_parse:nnnn {nnen} +\cs_generate_variant:Nn \__starray_set_from_keyval_parse:nnnn {neen} %%%%%%%%%%%%%%% %%%%%%%%%%%%%%% @@ -1581,21 +1616,41 @@ %%%%%%%%%%%%%%% %%%%%%%%%%%%%%% - -\cs_new_protected:Npn \__starray_set_from_keyval_parse:nnnnn #1#2#3#4#5 +%%% what a mess. :( +%%% #1 => tmp series A, AA, AAA +%%% #2 => no_idx_ending ref +%%% #3 => idx_ending ref !!! +%%% #4 => prop/struct(key from keyval) +%%% #5 => val/keyval (val from keyval) +%%% +\cs_new:Npn \__starray_set_from_keyval_parse:nnnnn #1#2#3#4#5 { \tl_clear:c {l__starray_tmp #1 _tl} + \__starray_set_parse_begin:wTF {#1}#4 [ \q_nil \q_stop { \tl_if_blank:eTF {\tl_use:c{l__starray_tmp #1 :A_tl}} { + % + % what should be here: + % get #2_base_prop -> _def_prop -> @st_seq + % _base_prop comes from (parser) _no_idx_ending_tl + % + % from there #3.<#4> => {}{...} 'next #2' + % #3.<#4>_[<#4>] (idx construct from #4) 'next #3' + % + \prop_get:cnc + {\l__starray_prefix_tl #2 _base_prop} + {def_ref} + {l__starray_tmp #1 _def_prop} + \prop_get:cnc - {\l__starray_prefix_tl #2 _def_prop} + {\l__starray_prefix_tl \tl_use:c {l__starray_tmp #1 _def_prop} _def_prop} {@st_seq} {l__starray_tmp #1 _seq} - + \seq_if_in:cnTF {l__starray_tmp #1 _seq}{#4} - { + { \prop_get:cnc { \l__starray_prefix_tl #3 .#4 _base_prop } { idx_hash } @@ -1614,17 +1669,18 @@ \tl_set:ce { l__starray_tmp #1 _tl } { #3.#4 _ \int_to_Alph:e {\int_use:c {l__starray_tmp #1 _int}} } + \keyval_parse:nnn { - \__starray_set_from_keyval_parse:nnen + \__starray_set_from_keyval_parse:neen { #1 A } - { #2.#4 } + { #3.#4 } { \tl_use:c { l__starray_tmp #1 _tl } } } { - \__starray_set_from_keyval_parse:nnenn + \__starray_set_from_keyval_parse:neenn { #1 A } - { #2.#4 } + { #3.#4 } { \tl_use:c { l__starray_tmp #1 _tl } } } { #5 } @@ -1636,10 +1692,15 @@ } } { + \prop_get:cnc + {\l__starray_prefix_tl #2 _base_prop} + {def_ref} + {l__starray_tmp #1 _def_prop} + \prop_get:cnc - { \l__starray_prefix_tl #2 _def_prop } - { @st_seq } - { l__starray_tmp #1 _seq } + {\l__starray_prefix_tl \tl_use:c {l__starray_tmp #1 _def_prop} _def_prop} + {@st_seq} + {l__starray_tmp #1 _seq} \seq_if_in:ceTF { l__starray_tmp #1 _seq } { \tl_use:c{l__starray_tmp #1 :B_tl} } @@ -1656,20 +1717,20 @@ { l__starray_tmp #1 _hash_prop } { \tl_use:c{ l__starray_tmp #1 :A_tl } } } - \tl_put_left:cn { l__starray_tmp #1 :B_tl } { #2 . } + \tl_put_left:cn { l__starray_tmp #1 :B_tl } { #3 . } \prop_if_in:ceTF { l__starray_tmp #1 _hash_prop } { \tl_use:c{l__starray_tmp #1 :A_tl}} { \keyval_parse:nnn { - \__starray_set_from_keyval_parse:nnen + \__starray_set_from_keyval_parse:neen { #1 A } { \tl_use:c{l__starray_tmp #1 :B_tl} } { \tl_use:c { l__starray_tmp #1 _idx_tl } } } { - \__starray_set_from_keyval_parse:nnenn + \__starray_set_from_keyval_parse:neenn { #1 A } { \tl_use:c{l__starray_tmp #1 :B_tl} } { \tl_use:c { l__starray_tmp #1 _idx_tl } } @@ -1697,7 +1758,7 @@ } } -\cs_generate_variant:Nn \__starray_set_from_keyval_parse:nnnnn {nnenn} +\cs_generate_variant:Nn \__starray_set_from_keyval_parse:nnnnn {neenn} %%%%%%%%%%%%%%% @@ -1706,15 +1767,20 @@ %%%% %%%%%%%%%%%%%%% +\tl_new:N \l__starray_from_keyval_orgref_tl \cs_new_protected:Npn \__starray_set_from_keyval:nn #1#2 { \bool_set_true:N \l__starray_rtn_bool + + %%% just in case, for msg_err messages + \tl_set:Nn \l__starray_from_keyval_orgref_tl {#1} + \__starray_parser:nnTF {\c__starray_idx_ending_bool}{#1} { \keyval_parse:nnn - {\__starray_set_from_keyval_parse:nnen {A}{#1}{\l__starray_parsed_ref_tl}} - {\__starray_set_from_keyval_parse:nnenn {A}{#1}{\l__starray_parsed_ref_tl}} + {\__starray_set_from_keyval_parse:neen {A}{\l__starray_parsed_ref_no_idx_ending_tl}{\l__starray_parsed_ref_tl}} + {\__starray_set_from_keyval_parse:neenn {A}{\l__starray_parsed_ref_no_idx_ending_tl}{\l__starray_parsed_ref_tl}} { #2 } \bool_if:NF \l__starray_rtn_bool { \__starray_msg_dispatch: } @@ -1745,11 +1811,15 @@ \cs_new_protected:Npn \__starray_set_from_keyvalTF:nn #1#2 { \bool_set_true:N \l__starray_rtn_bool + + %%% just in case, for msg_err messages + \tl_set:Nn \l__starray_from_keyval_orgref_tl {#1} + \__starray_parser:nnTF {\c__starray_idx_ending_bool}{#1} { \keyval_parse:nnn - {\__starray_set_from_keyval_parse:nnen {A}{#1}{\l__starray_parsed_ref_tl}} - {\__starray_set_from_keyval_parse:nnenn {A}{#1}{\l__starray_parsed_ref_tl}} + {\__starray_set_from_keyval_parse:neen {A}{\l__starray_parsed_ref_no_idx_ending_tl}{\l__starray_parsed_ref_tl}} + {\__starray_set_from_keyval_parse:neenn {A}{\l__starray_parsed_ref_no_idx_ending_tl}{\l__starray_parsed_ref_tl}} { #2 } \bool_if:NTF \l__starray_rtn_bool {\prg_return_true:} @@ -1962,6 +2032,7 @@ %%%% %%%% parser 'true' returns: %%%% \l__starray_parsed_ref_tl +%%%% \l__starray_parsed_ref_no_idx_ending_tl %%%% \l__starray_parsed_base_ref_tl %%%% \l__starray_parsed_root_ref_tl %%%% parser 'false' returns: @@ -1977,6 +2048,7 @@ \tl_clear:N \l__starray_parsed_tl \tl_clear:N \l__starray_parsed_ref_tl + \tl_clear:N \l__starray_parsed_ref_no_idx_ending_tl \tl_clear:N \l__starray_parsed_base_ref_tl \tl_clear:N \l__starray_parsed_root_ref_tl |