diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/xpackages/xparse.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/xpackages/xparse.sty | 345 |
1 files changed, 172 insertions, 173 deletions
diff --git a/Master/texmf-dist/tex/latex/xpackages/xparse.sty b/Master/texmf-dist/tex/latex/xpackages/xparse.sty index c2a3e0785ab..b268d7b0957 100644 --- a/Master/texmf-dist/tex/latex/xpackages/xparse.sty +++ b/Master/texmf-dist/tex/latex/xpackages/xparse.sty @@ -53,203 +53,199 @@ %% %% ----------------------------------------------------------------------- %% -\RequirePackage{l3names} -\GetIdInfo$Id: xparse.dtx 748 2008-08-03 19:00:50Z morten $ +\RequirePackage{expl3} +\GetIdInfo$Id: xparse.dtx 1365 2009-05-31 17:26:17Z mittelba $ {generic document command parser} \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} -\RequirePackage{l3tlp,l3num,l3toks,l3prg,l3int,l3seq,l3token} -\def_new:NNn \xparse_already_defined_error_msg:N 1 { +\RequirePackage{expl3} +\cs_new_nopar:Nn \xparse_already_defined_error_msg:N { \xparse_error:x { - Command~name~`\token_to_string:N #1'~ already~defined! + Command~name~`\token_to_str:N #1'~ already~defined! } } -\def_new:NNn \xparse_not_yet_defined_error_msg:N 1 { +\cs_new_nopar:Nn \xparse_not_yet_defined_error_msg:N { \xparse_error:x { - Command~`\token_to_string:N #1'~ not~ yet~defined! + Command~`\token_to_str:N #1'~ not~ yet~defined! } } -\def_new:NNn \xparse_begins_with_end_error_msg:N 1 { +\cs_new_nopar:Nn \xparse_begins_with_end_error_msg:N { \xparse_error:x { - Command~`\token_to_string:N #1'~begins~with~ - `\token_to_string:N \end'! + Command~`\token_to_str:N #1'~begins~with~ + `\token_to_str:N \end'! } } -\def_new:NNn \xparse_unknown_arg_type_error_msg:N 1{ +\cs_new_nopar:Nn \xparse_unknown_arg_type_error_msg:N { \xparse_error:x { Unknown~ argument~ type~ `#1'~ I'll~ substitute~ it~ with~ `m'~ for~ now.~ Fingers~ crossed... } } -\def_new:NNn \xparse_no_command_implementation_warning:n 1 { +\cs_new_nopar:Nn \xparse_no_command_implementation_warning:n { \xparse_warning:x {No~ implementation~ for~ `#1'~ defined} } -\def_new:NNn \xparse_error:x 1{\tex_errmessage:D {xparse~error:~#1}} -\def_new:NNn \xparse_warning:x 1{\io_put_term:x{xparse~warning:~#1}} -\def_new:NNn \xparse_if_definable:NTF 1 { - \cs_free:NTF #1 +\cs_new_nopar:Nn \xparse_error:x {\tex_errmessage:D {xparse~error:~#1}} +\cs_new_nopar:Nn \xparse_warning:x {\iow_term:x{xparse~warning:~#1}} +\cs_new_nopar:Npn \xparse_if_definable:NTF #1 { + \cs_if_free:NTF #1 { \xparse_begins_with_end:NTF #1 - { \xparse_begins_with_end_error_msg:N #1 \use_arg_ii:nn } - \use_arg_i:nn + { \xparse_begins_with_end_error_msg:N #1 \use_ii:nn } + \use_i:nn } - { \xparse_already_defined_error_msg:N #1 \use_arg_ii:nn } + { \xparse_already_defined_error_msg:N #1 \use_ii:nn } } -\def_new:NNn \xparse_if_definable:cTF 0 { - \exp_args:Nc \xparse_if_definable:NTF -} -\def_new:NNn \xparse_if_redefinable:NTF 1 { - \cs_free:NTF #1 - { \xparse_not_yet_defined_error_msg:N #1 \use_arg_ii:nn } +\cs_generate_variant:Nn \xparse_if_definable:NTF {c} +\cs_new_nopar:Npn \xparse_if_redefinable:NTF #1 { + \cs_if_free:NTF #1 + { \xparse_not_yet_defined_error_msg:N #1 \use_ii:nn } { \xparse_begins_with_end:NTF #1 - { \xparse_begins_with_end_error_msg:N #1 \use_arg_ii:nn } - \use_arg_i:nn + { \xparse_begins_with_end_error_msg:N #1 \use_ii:nn } + \use_i:nn } } -\def_new:NNn \xparse_if_redefinable:cTF 0 { - \exp_args:Nc \xparse_if_redefinable:NTF -} -\def_new:NNn \xparse_begins_with_end:NTF 1 { +\cs_generate_variant:Nn \xparse_if_redefinable:NTF {c} +\cs_new_nopar:Npn \xparse_begins_with_end:NTF #1 { \group_begin: \exp_args:Nc \xparse_begins_with_end_aux:N { - \tlist_head_iii:f { \cs_to_str:N #1 ??} + \tl_head_iii:f { \cs_to_str:N #1 ??} } } -\def_new:NNn \xparse_begins_with_end_aux:N 1 { - \if:w \cs_if_eq_name_p:NN #1 \end +\cs_new_nopar:Nn \xparse_begins_with_end_aux:N { + \if_predicate:w \cs_if_eq_name_p:NN #1 \end \group_end: - \exp_after:NN \use_arg_i:nn + \exp_after:wN \use_i:nn \else: \group_end: - \exp_after:NN \use_arg_ii:nn + \exp_after:wN \use_ii:nn \fi: } \toks_new:N \l_xparse_grabbed_args_toks \toks_new:N \l_xparse_end_environment_args_toks \int_new:N \l_xparse_mandatory_args_int \int_new:N \l_xparse_total_args_int -\def_long:NNn \xparse_declare_document_command:Nnn 3{ +\cs_set:Nn \xparse_declare_document_command:Nnn { \xparse_prepare_signature:n {#2} - \def_protected:Npx #1 { + \cs_set_protected_nopar:Npx #1 { \exp_not:n { \toks_set:Nn \l_xparse_grabbed_args_toks } - {\exp_not:c {\token_to_string:N #1}} + {\exp_not:c {\token_to_str:N #1}} \toks_use:N \l_xparse_grabbed_args_toks \exp_not:n{ \toks_use:N \l_xparse_grabbed_args_toks} } - \def_long:cNn {\token_to_string:N #1}\l_xparse_total_args_int{#3} -} -\def_new:Npn \xparse_declare_document_command:cnn { - \exp_args:Nc \xparse_declare_document_command:Nnn + \cs_generate_from_arg_count:cNnn {\token_to_str:N #1}\cs_set:Npn + \l_xparse_total_args_int{#3} } -\def_long_new:NNn \xparse_declare_document_environment:nnnn 4 { +\cs_generate_variant:Nn \xparse_declare_document_command:Nnn {cnn} +\cs_new:Nn \xparse_declare_document_environment:nnnn { \xparse_declare_document_command:cnn {#1}{#2} { \group_begin: \toks_set_eq:NN \l_xparse_end_environment_args_toks \l_xparse_grabbed_args_toks #3 } - \let:cN {end #1} \xparse_parsed_end_environment: - \def_long:cNn {end \token_to_string:N \\ #1} - \l_xparse_total_args_int{#4} + \cs_set_eq:cN {end #1} \xparse_parsed_end_environment: + \cs_generate_from_arg_count:cNnn {end \token_to_str:N \\ #1}\cs_set:Npn + \l_xparse_total_args_int{#4} } -\def_protected_new:NNn \xparse_parsed_end_environment: 0{ - \exp_after:NN \xparse_parsed_end_environment_aux:N +\cs_new_protected_nopar:Nn \xparse_parsed_end_environment: { + \exp_after:wN \xparse_parsed_end_environment_aux:N \toks_use:N \l_xparse_end_environment_args_toks \group_end: } -\def_new:NNn \xparse_parsed_end_environment_aux:N 1{ - \cs_use:c {end \token_to_string:N #1 } +\cs_new_nopar:Nn \xparse_parsed_end_environment_aux:N { + \use:c {end \token_to_str:N #1 } } -\let_new:NN \DeclareDocumentCommand \xparse_declare_document_command:Nnn -\def_new:NNn \NewDocumentCommand 1 { +\cs_new_eq:NN \DeclareDocumentCommand \xparse_declare_document_command:Nnn +\cs_new_nopar:Npn \NewDocumentCommand #1 { \xparse_if_definable:NTF #1 { \xparse_declare_document_command:Nnn #1 } \use_none:nn } -\def_new:NNn \RenewDocumentCommand 1 { +\cs_new_nopar:Npn \RenewDocumentCommand #1 { \xparse_if_redefinable:NTF #1 { \xparse_declare_document_command:Nnn #1 } \use_none:nn } -\let_new:NN \DeclareDocumentEnvironment +\cs_new_eq:NN \DeclareDocumentEnvironment \xparse_declare_document_environment:nnnn -\def_new:NNn \NewDocumentEnvironment 1 { +\cs_new_nopar:Npn \NewDocumentEnvironment #1 { \xparse_if_definable:cTF {#1} { \xparse_declare_document_environment:nnnn {#1} } \use_none:nnn } -\def_new:NNn \RenewDocumentEnvironment 1 { +\cs_new_nopar:Npn \RenewDocumentEnvironment #1 { \xparse_if_redefinable:cTF {#1} { \xparse_declare_document_environment:nnnn {#1} } \use_none:nnn } -\def_new:NNn \ProvideDocumentCommand 1{ - \cs_free:NTF #1 +\cs_new_nopar:Npn \ProvideDocumentCommand #1{ + \cs_if_free:NTF #1 { \DeclareDocumentCommand #1} \use_none:nn } -\def_new:NNn \ProvideDocumentEnvironment 1{ - \cs_free:cTF {#1} +\cs_new_nopar:Npn \ProvideDocumentEnvironment #1{ + \cs_if_free:cTF {#1} { \DeclareDocumentEnvironment {#1} } \use_none:nnn } -\def_long_new:NNn \DeclareDocumentCommandInterface 3{ +\cs_new:Npn \DeclareDocumentCommandInterface #1#2#3{ \xparse_prepare_signature:n {#3} - \def_protected:Npx #1 { + \cs_set_protected_nopar:Npx #1 { \exp_not:n { \toks_set:Nn \l_xparse_grabbed_args_toks } {\exp_not:c {impl-#2}} \toks_use:N\l_xparse_grabbed_args_toks \exp_not:n{ \toks_use:N \l_xparse_grabbed_args_toks} } - \def_long:cNn {impl-#2} \l_xparse_total_args_int + \cs_generate_from_arg_count:cNnn {impl-#2} \cs_set:Npn + \l_xparse_total_args_int {\xparse_undefined_command_implementation:n{#2}} } -\def_new:NNn \xparse_undefined_command_implementation:n 1{ +\cs_new_nopar:Nn \xparse_undefined_command_implementation:n { ``#1'' \xparse_no_command_implementation_warning:n {#1} } -\def_long_new:NNn \DeclareDocumentCommandImplementation 3{ - \def_long:cNn {impl-#1}#2{#3} +\cs_new:Npn \DeclareDocumentCommandImplementation #1#2#3{ + \cs_generate_from_arg_count:cNnn {impl-#1}\cs_set:Npn {#2}{#3} } -\def_new:NNn \xparse_prepare_signature:n 1 { +\cs_new_nopar:Nn \xparse_prepare_signature:n { \int_zero:N \l_xparse_total_args_int \toks_clear:N \l_xparse_grabbed_args_toks \int_zero:N \l_xparse_mandatory_args_int \bool_gset_false:N \g_xparse_insert_marker_bool \bool_gset_false:N \g_xparse_allow_par_bool - \tlp_gset_eq:NN \g_xparse_ignore_marker_tlp - \g_xparse_ignore_spaces_marker_tlp + \tl_gset_eq:NN \g_xparse_ignore_marker_tl + \g_xparse_ignore_spaces_marker_tl \xparse_parse_signature:n #1 \q_nil } -\tlp_new:Nn \g_xparse_ignore_marker_tlp {} +\tl_new:Nn \g_xparse_ignore_marker_tl {} \seq_new:N \g_xparse_ignore_marker_seq \bool_new:N \g_xparse_insert_marker_bool -\def_new:cpn {xparse_add_arg_type_>:} #1 +\cs_new_nopar:cpn {xparse_add_arg_type_>:} #1 \xparse_read_arg_type_or_grab_default:n #2{ \xparse_add_remaining_m_args: \bool_gset_true:N \g_xparse_insert_marker_bool \int_decr:N \l_xparse_total_args_int - \tlist_map_inline:nn{#2}{ + \tl_map_inline:nn{#2}{ \xparse_check_and_add_argument_type:N ##1 } \xparse_parse_signature:n } -\def_new:NNn \xparse_add_ignore_marker:Nnn 3{ - \tlp_new:cn {g_xparse #2 _marker_tlp}{#3} - \seq_gpush:NC \g_xparse_ignore_marker_seq {g_xparse #2 _marker_tlp} - \def_new:cpn {xparse_add_arg_type_#1:}{ - \tlp_gset_eq:Nc \g_xparse_ignore_marker_tlp {g_xparse #2 _marker_tlp} +\cs_new_nopar:Nn \xparse_add_ignore_marker:Nnn { + \tl_new:cn {g_xparse #2 _marker_tl}{#3} + \seq_gpush:Nv \g_xparse_ignore_marker_seq {g_xparse #2 _marker_tl} + \cs_new_nopar:cpn {xparse_add_arg_type_#1:}{ + \tl_gset_eq:Nc \g_xparse_ignore_marker_tl {g_xparse #2 _marker_tl} } } \xparse_add_ignore_marker:Nnn W{_ignore_nothing}{} \xparse_add_ignore_marker:Nnn i{_ignore_spaces}{_ignore_spaces} \xparse_add_ignore_marker:Nnn I{_ignore_pars}{_ignore_pars} -\def_new:NNn \xparse_add_arg_type_P: 0{ +\cs_new_nopar:Nn \xparse_add_arg_type_P: { \bool_gset_true:N \g_xparse_allow_par_bool } \bool_new:N \g_xparse_allow_par_bool -\def_new:NNn \xparse_parse_signature:n 1{ +\cs_new_nopar:Nn \xparse_parse_signature:n { \quark_if_nil:NTF #1 { \xparse_add_remaining_m_args: @@ -261,42 +257,42 @@ { \bool_gset_false:N \g_xparse_insert_marker_bool \bool_gset_false:N \g_xparse_allow_par_bool - \tlp_gset_eq:NN \g_xparse_ignore_marker_tlp - \g_xparse_ignore_spaces_marker_tlp + \tl_gset_eq:NN \g_xparse_ignore_marker_tl + \g_xparse_ignore_spaces_marker_tl } \xparse_read_arg_type_or_grab_default:n } } -\def_new:NNn \xparse_check_and_add_argument_type:N 1 { - \cs_free:cTF {xparse_add_arg_type_#1:} +\cs_new_nopar:Nn \xparse_check_and_add_argument_type:N { + \cs_if_free:cTF {xparse_add_arg_type_#1:} { \xparse_unknown_arg_type_error_msg:N #1 \int_incr:N \l_xparse_mandatory_args_int } - { \cs_use:c {xparse_add_arg_type_#1:} } + { \use:c {xparse_add_arg_type_#1:} } } -\let_new:NN \xparse_read_arg_type_or_grab_default:n +\cs_new_eq:NN \xparse_read_arg_type_or_grab_default:n \xparse_parse_signature:n -\def_new:NNn \xparse_grab_default_arg:n 1{ +\cs_new_nopar:Nn \xparse_grab_default_arg:n { \toks_put_right:Nn \l_xparse_grabbed_args_toks {{#1}} - \let:NN \xparse_read_arg_type_or_grab_default:n + \cs_set_eq:NN \xparse_read_arg_type_or_grab_default:n \xparse_parse_signature:n \xparse_parse_signature:n } -\def_long_new:NNn \xparse_grab_default_arg_allow_par:n 1{ +\cs_new:Nn \xparse_grab_default_arg_allow_par:n { \toks_put_right:Nn \l_xparse_grabbed_args_toks {{#1}} - \let:NN \xparse_read_arg_type_or_grab_default:n + \cs_set_eq:NN \xparse_read_arg_type_or_grab_default:n \xparse_parse_signature:n \xparse_parse_signature:n } -\def_new:Npn \xparse_add_arg_type_m: { +\cs_new_nopar:Nn \xparse_add_arg_type_m: { \bool_if:NTF \g_xparse_allow_par_bool { \toks_put_right:Nn \l_xparse_grabbed_args_toks {\xparse_allow_par_m:w} } { \int_incr:N \l_xparse_mandatory_args_int } } -\def_new:Npn \xparse_add_remaining_m_args: { - \int_compare:nNnF \l_xparse_mandatory_args_int = \c_zero +\cs_new_nopar:Nn \xparse_add_remaining_m_args: { + \intexpr_compare:nNnF \l_xparse_mandatory_args_int = \c_zero { \toks_put_right:Nx \l_xparse_grabbed_args_toks { \exp_not:c{xparse_m @@ -306,53 +302,53 @@ \int_zero:N \l_xparse_mandatory_args_int } } -\def_new:cpn {xparse_m1:w} #1 \l_xparse_grabbed_args_toks#2{ +\cs_new_nopar:cpn {xparse_m1:w} #1 \l_xparse_grabbed_args_toks#2{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m2:w} #1 \l_xparse_grabbed_args_toks #2#3{ +\cs_new_nopar:cpn {xparse_m2:w} #1 \l_xparse_grabbed_args_toks #2#3{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}{#3}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m3:w} #1 \l_xparse_grabbed_args_toks #2#3#4{ +\cs_new_nopar:cpn {xparse_m3:w} #1 \l_xparse_grabbed_args_toks #2#3#4{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}{#3}{#4}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m4:w} #1 \l_xparse_grabbed_args_toks #2#3#4#5{ +\cs_new_nopar:cpn {xparse_m4:w} #1 \l_xparse_grabbed_args_toks #2#3#4#5{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}{#3}{#4}{#5}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m5:w} #1 \l_xparse_grabbed_args_toks #2#3#4#5#6{ +\cs_new_nopar:cpn {xparse_m5:w} #1 \l_xparse_grabbed_args_toks #2#3#4#5#6{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}{#3}{#4}{#5}{#6}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m6:w} #1 \l_xparse_grabbed_args_toks #2#3#4#5#6#7{ +\cs_new_nopar:cpn {xparse_m6:w} #1 \l_xparse_grabbed_args_toks #2#3#4#5#6#7{ \toks_put_right:Nn \l_xparse_grabbed_args_toks {{#2}{#3}{#4}{#5}{#6}{#7}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m7:w} #1 \l_xparse_grabbed_args_toks#2#3#4#5#6#7#8{ +\cs_new_nopar:cpn {xparse_m7:w} #1 \l_xparse_grabbed_args_toks#2#3#4#5#6#7#8{ \toks_put_right:Nn \l_xparse_grabbed_args_toks {{#2}{#3}{#4}{#5}{#6}{#7}{#8}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m8:w} #1\l_xparse_grabbed_args_toks +\cs_new_nopar:cpn {xparse_m8:w} #1\l_xparse_grabbed_args_toks #2#3#4#5#6#7#8#9{ \toks_put_right:Nn \l_xparse_grabbed_args_toks {{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}} #1 \l_xparse_grabbed_args_toks } -\def_new:cpn {xparse_m9:w} \toks_use:N \l_xparse_grabbed_args_toks +\cs_new_nopar:cpn {xparse_m9:w} \toks_use:N \l_xparse_grabbed_args_toks #1#2#3#4#5#6#7#8#9{ \toks_put_right:Nn \l_xparse_grabbed_args_toks {{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}} \toks_use:N \l_xparse_grabbed_args_toks } -\def_long_new:Npn \xparse_allow_par_m:w #1 \l_xparse_grabbed_args_toks#2{ +\cs_new:Npn \xparse_allow_par_m:w #1 \l_xparse_grabbed_args_toks#2{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}} #1 \l_xparse_grabbed_args_toks } -\def_new:Npn \xparse_add_arg_type_l: { +\cs_new_nopar:Nn \xparse_add_arg_type_l: { \xparse_add_remaining_m_args: \bool_if:NTF \g_xparse_allow_par_bool { @@ -360,42 +356,44 @@ } { \toks_put_right:Nn \l_xparse_grabbed_args_toks {\xparse_l:w} } } -\def_new:Npn \xparse_l:w #1 \l_xparse_grabbed_args_toks#2#{ +\cs_new_nopar:Npn \xparse_l:w #1 \l_xparse_grabbed_args_toks#2#{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}} #1 \l_xparse_grabbed_args_toks } -\def_long_new:Npn \xparse_allow_par_l:w #1 \l_xparse_grabbed_args_toks#2#{ +\cs_new:Npn \xparse_allow_par_l:w #1 \l_xparse_grabbed_args_toks#2#{ \toks_put_right:Nn \l_xparse_grabbed_args_toks{{#2}} #1 \l_xparse_grabbed_args_toks } -\def_new:NNn \DeclareSymbolArgument 2{ - \seq_map_variable:NNn \g_xparse_ignore_marker_seq \l_tmpa_tlp { - \def:cpx {xparse \l_tmpa_tlp _#1:w}##1##2\l_xparse_grabbed_args_toks{ - \exp_not:c{peek_ #2 _remove \l_tmpa_tlp :NTF} ##1 +\cs_new_nopar:Npn \DeclareSymbolArgument #1#2{ + \seq_map_variable:NNn \g_xparse_ignore_marker_seq \l_tmpa_tl { + \cs_set_nopar:cpx {xparse \l_tmpa_tl _#1:w}##1##2 + \l_xparse_grabbed_args_toks{ + \exp_not:c{peek_ #2 _remove \l_tmpa_tl :NTF} ##1 { \exp_not:N \toks_put_right:Nn \exp_not:N - \l_xparse_grabbed_args_toks \exp_not:N \c_true + \l_xparse_grabbed_args_toks \exp_not:N \c_true_bool ##2 \exp_not:N\l_xparse_grabbed_args_toks } { \exp_not:N \toks_put_right:Nn \exp_not:N - \l_xparse_grabbed_args_toks \exp_not:N \c_false + \l_xparse_grabbed_args_toks \exp_not:N \c_false_bool ##2 \exp_not:N\l_xparse_grabbed_args_toks } } } - \def:cpn {xparse_add_arg_type_#1:} { + \cs_set_nopar:cpn {xparse_add_arg_type_#1:} { \xparse_add_remaining_m_args: \toks_put_right:Nx \l_xparse_grabbed_args_toks - { \exp_not:c {xparse \g_xparse_ignore_marker_tlp _#1:w } } - \let:NN \xparse_read_arg_type_or_grab_default:n \xparse_grab_default_arg:n + { \exp_not:c {xparse \g_xparse_ignore_marker_tl _#1:w } } + \cs_set_eq:NN \xparse_read_arg_type_or_grab_default:n + \xparse_grab_default_arg:n } } \DeclareSymbolArgument S{meaning} -\def_new:NNn \DeclareArgumentType 7{ - \seq_map_variable:NNn \g_xparse_ignore_marker_seq \l_tmpa_tlp { - \def:cpx {xparse \l_tmpa_tlp _#1:w}##1\l_xparse_grabbed_args_toks{ - \exp_not:c{peek_#3 \l_tmpa_tlp :NTF} \exp_not:N #2 +\cs_new_nopar:Npn \DeclareArgumentType #1#2#3#4#5#6#7{ + \seq_map_variable:NNn \g_xparse_ignore_marker_seq \l_tmpa_tl { + \cs_set_nopar:cpx {xparse \l_tmpa_tl _#1:w}##1\l_xparse_grabbed_args_toks{ + \exp_not:c{peek_#3 \l_tmpa_tl :NTF} \exp_not:N #2 { \exp_not:c{xparse_#1_#3_help:nw}{##1} } { \exp_not:n { @@ -404,9 +402,9 @@ ##1 \exp_not:N\l_xparse_grabbed_args_toks } } - \def_long:cpx {xparse_allow_par \l_tmpa_tlp _#1:w}##1 + \cs_set:cpx {xparse_allow_par \l_tmpa_tl _#1:w}##1 \l_xparse_grabbed_args_toks{ - \exp_not:c{peek_#3 \l_tmpa_tlp :NTF} \exp_not:N #2 + \exp_not:c{peek_#3 \l_tmpa_tl :NTF} \exp_not:N #2 { \exp_not:c{xparse_allow_par_#1_#3_help:nw}{##1} } { \exp_not:n { @@ -416,23 +414,23 @@ } } } - \def:cpn {xparse_add_arg_type_#1:} { + \cs_set_nopar:cpn {xparse_add_arg_type_#1:} { \xparse_add_remaining_m_args: \toks_put_right:Nx \l_xparse_grabbed_args_toks { \exp_not:c {xparse \bool_if:NT \g_xparse_allow_par_bool {_allow_par} - \g_xparse_ignore_marker_tlp + \g_xparse_ignore_marker_tl _#1:w } } - \let:NN \xparse_read_arg_type_or_grab_default:n \xparse_parse_signature:n + \cs_set_eq:NN \xparse_read_arg_type_or_grab_default:n \xparse_parse_signature:n } \xparse_define_helper:Nnnn #1{#3}{#6}{#7} } -\def_new:NNn \DeclareArgumentTypeDefaultValue 5{ - \seq_map_variable:NNn \g_xparse_ignore_marker_seq \l_tmpa_tlp { - \def:cpx {xparse \l_tmpa_tlp _#1:w}##1##2\l_xparse_grabbed_args_toks{ - \exp_not:c{peek_#3 \l_tmpa_tlp :NTF} \exp_not:N #2 +\cs_new_nopar:Npn \DeclareArgumentTypeDefaultValue #1#2#3#4#5{ + \seq_map_variable:NNn \g_xparse_ignore_marker_seq \l_tmpa_tl { + \cs_set_nopar:cpx {xparse \l_tmpa_tl _#1:w}##1##2\l_xparse_grabbed_args_toks{ + \exp_not:c{peek_#3 \l_tmpa_tl :NTF} \exp_not:N #2 { \exp_not:c{xparse_#1_#3_help:nw}{##2} } { \exp_not:N \toks_put_right:Nn @@ -440,9 +438,9 @@ ##2 \exp_not:N \l_xparse_grabbed_args_toks } } - \def_long:cpx {xparse_allow_par \l_tmpa_tlp _#1:w}##1##2 + \cs_set:cpx {xparse_allow_par \l_tmpa_tl _#1:w}##1##2 \l_xparse_grabbed_args_toks{ - \exp_not:c{peek_#3 \l_tmpa_tlp :NTF} \exp_not:N #2 + \exp_not:c{peek_#3 \l_tmpa_tl :NTF} \exp_not:N #2 { \exp_not:c{xparse_allow_par_#1_#3_help:nw}{##2} } { \exp_not:N \toks_put_right:Nn @@ -451,16 +449,16 @@ } } } - \def:cpn {xparse_add_arg_type_#1:} { + \cs_set_nopar:cpn {xparse_add_arg_type_#1:} { \xparse_add_remaining_m_args: \toks_put_right:Nx \l_xparse_grabbed_args_toks { \exp_not:c {xparse \bool_if:NT \g_xparse_allow_par_bool {_allow_par} - \g_xparse_ignore_marker_tlp + \g_xparse_ignore_marker_tl _#1:w } } - \let:Nc \xparse_read_arg_type_or_grab_default:n + \cs_set_eq:Nc \xparse_read_arg_type_or_grab_default:n {xparse_grab_default_arg \bool_if:NT \g_xparse_allow_par_bool {_allow_par} :n @@ -468,7 +466,7 @@ } \xparse_define_helper:Nnnn #1{#3}{#4}{#5} } -\def_new:NNn \xparse_define_helper:Nnnn 4{ +\cs_new_nopar:Nn \xparse_define_helper:Nnnn { \toks_set:Nn \l_tmpa_toks { #3 @@ -478,9 +476,9 @@ } } \toks_set:Nx \l_tmpa_toks { - \exp_not:n {\def:cpn{xparse_#1_#2_help:nw}} + \exp_not:n {\cs_set_nopar:cpn{xparse_#1_#2_help:nw}} \toks_use:N \l_tmpa_toks - \exp_not:n {\def:cpn{xparse_allow_par_#1_#2_help:nw}} + \exp_not:n {\cs_set_nopar:cpn{xparse_allow_par_#1_#2_help:nw}} \toks_use:N\l_tmpa_toks } \toks_use:N \l_tmpa_toks @@ -494,63 +492,64 @@ {#1(#2,#3)}{{#2}{#3}} \DeclareArgumentTypeDefaultValue O[{meaning}{#1[#2]}{#2} \DeclareArgumentTypeDefaultValue C({meaning}{#1(#2,#3)}{{#2}{#3}} -\def_new:NNn \DeclareArgumentTypeShorthand 2{ - \def_new:cpn {xparse_add_arg_type_#1:} +\cs_new_nopar:Npn \DeclareArgumentTypeShorthand #1#2{ + \cs_new_nopar:cpn {xparse_add_arg_type_#1:} ##1 \xparse_read_arg_type_or_grab_default:n { \int_decr:N \l_xparse_total_args_int \xparse_read_arg_type_or_grab_default:n #2 } } \DeclareArgumentTypeShorthand s {S{*}} -\let_new:NN \IfBooleanTF \bool_if:NTF -\let_new:NN \IfBooleanT \bool_if:NT -\let_new:NN \IfBooleanF \bool_if:NF -\tlp_new:Nn \NoValue {-NoValue-} -\tlp_new:Nn \c_xparse_hidden_no_value_tlp {\NoValue} -\def_long_new:Npn \xparse_if_no_value:nTF #1{ - \tlp_set:Nx \l_tmpa_tlp{\exp_not:n{#1}} - \tlp_if_eq:NNTF \l_tmpa_tlp \c_xparse_hidden_no_value_tlp - { \use_arg_i:nn } - { \tlist_if_blank:nTF {#1} - { \use_arg_ii:nn } +\cs_new_eq:NN \IfBooleanTF \bool_if:NTF +\cs_new_eq:NN \IfBooleanT \bool_if:NT +\cs_new_eq:NN \IfBooleanF \bool_if:NF +\tl_new:Nn \NoValue {-NoValue-} +\tl_new:Nn \c_xparse_hidden_no_value_tl {\NoValue} +\cs_new:Npn \xparse_if_no_value:nTF #1{ + \tl_set:Nx \l_tmpa_tl{\exp_not:n{#1}} + \tl_if_eq:NNTF \l_tmpa_tl \c_xparse_hidden_no_value_tl + { \use_i:nn } + { \tl_if_blank:nTF {#1} + { \use_ii:nn } {\peek_after:NN \xparse_if_no_value_aux: #1 \q_nil {#1} } } } -\def_long_new:Npn \xparse_if_no_value_aux: { - \tlp_set:Nx \l_tmpa_tlp{\token_get_arg_spec:N \l_peek_token } - \tlp_if_empty:NTF \l_tmpa_tlp - {\use_arg_i_delimit_by_q_nil:nw {\exp_args:No\xparse_if_no_value:nTF}} - {\use_arg_i_delimit_by_q_nil:nw {\use_arg_iii:nnn}} -} -\let_new:NN \IfNoValueTF \xparse_if_no_value:nTF -\def_long_new:NNn \IfNoValueT 2 {\xparse_if_no_value:nTF{#1}{#2}{}} -\def_long_new:NNn \IfNoValueF 1 {\xparse_if_no_value:nTF {#1}{}} -\def_long_new:NNn \IfValueTF 3{\xparse_if_no_value:nTF {#1}{#3}{#2}} -\let_new:NN \IfValueT \IfNoValueF -\let_new:NN \IfValueF \IfNoValueT -\tlp_new:Nn \l_xparse_pseudo_post_arg_tlp {} -\def_long_new:NNn \DeclarePseudoArgument 4{ - \def_long:cNn {xparse_pseudo_pre_arg_#1:\prg_replicate:nn{#2}{n}}#2{#3} - \def_long:cNn {xparse_pseudo_post_arg_#1:\prg_replicate:nn{#2}{n}}#2{#4} - \def:cNn {xparse_pseudo_nobrace_arg_#1:N} 1 { - ##1 \l_xparse_pseudo_post_arg_tlp +\cs_new:Nn \xparse_if_no_value_aux: { + \tl_set:Nx \l_tmpa_tl{\token_get_arg_spec:N \l_peek_token } + \tl_if_empty:NTF \l_tmpa_tl + {\use_i_delimit_by_q_nil:nw {\exp_args:No\xparse_if_no_value:nTF}} + {\use_i_delimit_by_q_nil:nw {\use_iii:nnn}} +} +\cs_new_eq:NN \IfNoValueTF \xparse_if_no_value:nTF +\cs_new:Npn \IfNoValueT #1#2 {\xparse_if_no_value:nTF{#1}{#2}{}} +\cs_new:Npn \IfNoValueF #1 {\xparse_if_no_value:nTF {#1}{}} +\cs_new:Npn \IfValueTF #1#2#3{\xparse_if_no_value:nTF {#1}{#3}{#2}} +\cs_new_eq:NN \IfValueT \IfNoValueF +\cs_new_eq:NN \IfValueF \IfNoValueT +\tl_new:Nn \l_xparse_pseudo_post_arg_tl {} +\cs_new:Npn \DeclarePseudoArgument #1#2#3#4{ + \cs_set:cn {xparse_pseudo_pre_arg_#1:\prg_replicate:nn{#2}{n}} {#3} + \cs_set:cn {xparse_pseudo_post_arg_#1:\prg_replicate:nn{#2}{n}} {#4} + \cs_set_nopar:cn {xparse_pseudo_nobrace_arg_#1:N} { + ##1 \l_xparse_pseudo_post_arg_tl } - \def_long:cNx {xparse_pseudo_arg_#1:w} #2 + \cs_generate_from_arg_count:cNnn {xparse_pseudo_arg_#1:w} + \cs_set:Npx {#2} { \exp_not:c { xparse_pseudo_pre_arg_#1: \prg_replicate:nn{#2}{n} } - \cs_use:c{def_aux_use_\int_use:N \int_eval:n{#2}_parameter:} - \exp_not:n {\tlp_set:Nn \l_xparse_pseudo_post_arg_tlp} + \use:c{use_ \intexpr_eval:n{#2} _parameter:} + \exp_not:n {\tl_set:Nn \l_xparse_pseudo_post_arg_tl} { \exp_not:c {xparse_pseudo_post_arg_#1:\prg_replicate:nn{#2}{n}} - \cs_use:c{def_aux_use_\int_use:N \int_eval:n{#2}_parameter:} + \use:c{use_ \intexpr_eval:n{#2}_parameter:} } \exp_not:n{ \peek_catcode_remove_ignore_spaces:NTF \c_group_begin_token } { \exp_not:n { \c_group_begin_token - \group_execute_after:N \l_xparse_pseudo_post_arg_tlp + \group_execute_after:N \l_xparse_pseudo_post_arg_tl } } { @@ -558,7 +557,7 @@ } } } -\def_new:NNn \UsePseudoArgument 1{\cs_use:c{xparse_pseudo_arg_#1:w}} +\cs_new_nopar:Npn \UsePseudoArgument #1{\use:c{xparse_pseudo_arg_#1:w}} \endinput %% %% End of file `xparse.sty'. |