diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty | 180 |
1 files changed, 157 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty index d76b157392b..22172e020c6 100644 --- a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty +++ b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty @@ -51,12 +51,12 @@ %% ----------------------------------------------------------------------- %% \RequirePackage{expl3} -\GetIdInfo$Id: xparse.dtx 2535 2011-08-10 18:26:57Z joseph $ +\GetIdInfo$Id: xparse.dtx 2607 2011-08-17 16:43:25Z joseph $ {L3 Experimental document command parser} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{expl3} -\@ifpackagelater { expl3 } { 2011/08/13 } +\@ifpackagelater { expl3 } { 2011/08/17 } { } { \PackageError { xparse } { Support~package~l3kernel~too~old. } @@ -71,7 +71,6 @@ \prop_put:Nnn \c_xparse_shorthands_prop { o } { d[] } \prop_put:Nnn \c_xparse_shorthands_prop { O } { D[] } \prop_put:Nnn \c_xparse_shorthands_prop { s } { t* } - %\end{variable} \tl_new:N \l_xparse_arg_tl \tl_new:N \l_xparse_args_tl \bool_new:N \l_xparse_environment_bool @@ -176,6 +175,12 @@ \tl_put_right:Nn \l_xparse_signature_tl { {#1} } \xparse_prepare_signature:N } +\cs_new_protected_nopar:Npn \xparse_add_type_v:w + { + \xparse_flush_m_args: + \xparse_add_grabber_mandatory:N v + \xparse_prepare_signature:N + } \cs_new_protected_nopar:Npn \xparse_check_and_add:N #1 { \cs_if_free:cTF { xparse_add_type_ #1 :w } @@ -195,11 +200,8 @@ { \quark_if_nil:NF #1 { - \prop_if_in:NnTF \c_xparse_shorthands_prop {#1} - { - \prop_get:NnN \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl - \exp_last_unbraced:NV \xparse_count_mandatory:N \l_xparse_tmp_tl - } + \prop_get:NnNTF \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl + { \exp_last_unbraced:NV \xparse_count_mandatory:N \l_xparse_tmp_tl } { \xparse_count_mandatory_aux:N #1 } } } @@ -238,6 +240,11 @@ \int_incr:N \l_xparse_mandatory_args_int \xparse_count_mandatory:N } +\cs_new_protected_nopar:Npn \xparse_count_type_v:w + { + \int_incr:N \l_xparse_mandatory_args_int + \xparse_count_mandatory:N + } \cs_new_protected:Npn \xparse_declare_cmd:Nnn #1#2 { \cs_if_exist:NTF #1 @@ -395,11 +402,8 @@ \quark_if_nil:NTF #1 { \bool_if:NF \l_xparse_m_only_bool { \xparse_flush_m_args: } } { - \prop_if_in:NnTF \c_xparse_shorthands_prop {#1} - { - \prop_get:NnN \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl - \exp_after:wN \xparse_prepare_signature:N \l_xparse_tmp_tl - } + \prop_get:NnNTF \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl + { \exp_after:wN \xparse_prepare_signature:N \l_xparse_tmp_tl } { \int_incr:N \l_xparse_total_args_int \xparse_check_and_add:N #1 @@ -678,10 +682,10 @@ \xparse_grab_arg:w } \cs_new_protected:Npn \xparse_grab_u:w #1#2 \l_xparse_args_tl - { \xparse_grab_u_aux:NnN {#1} {#2} \cs_set_protected_nopar:Npn } + { \xparse_grab_u_aux:nnN {#1} {#2} \cs_set_protected_nopar:Npn } \cs_new_protected:Npn \xparse_grab_u_long:w #1#2 \l_xparse_args_tl - { \xparse_grab_u_aux:NnN {#1} {#2} \cs_set_protected:Npn } -\cs_new_protected:Npn \xparse_grab_u_aux:NnN #1#2#3 + { \xparse_grab_u_aux:nnN {#1} {#2} \cs_set_protected:Npn } +\cs_new_protected:Npn \xparse_grab_u_aux:nnN #1#2#3 { #3 \xparse_grab_arg:w ##1 #1 { @@ -690,6 +694,110 @@ } \xparse_grab_arg:w } +\tl_new:N \l_xparse_v_rest_of_signature_tl +\tl_new:N \l_xparse_v_arg_tl +\cs_new_protected_nopar:Npn \xparse_grab_v:w + { + \bool_set_false:N \l_xparse_long_bool + \xparse_grab_v_aux:w + } +\cs_new_protected_nopar:Npn \xparse_grab_v_long:w + { + \bool_set_true:N \l_xparse_long_bool + \xparse_grab_v_aux:w + } +\cs_new_protected:Npn \xparse_grab_v_aux:w #1 \l_xparse_args_tl + { + \group_begin: + \group_align_safe_begin: + \tex_escapechar:D = 92 \scan_stop: + \tl_set:Nn \l_xparse_v_rest_of_signature_tl {#1} + \tl_clear:N \l_xparse_v_arg_tl + \peek_N_type:TF + { \xparse_grab_v_aux_test:N } + { \xparse_grab_v_aux_abort: } + } +\cs_new_protected:Npn \xparse_grab_v_aux_test:N #1 + { + \tl_put_right:Nn \l_xparse_v_arg_tl {#1} + \xparse_grab_v_token_if_char:NTF #1 + { + \cs_set_eq:NN \do \char_set_catcode_other:N + \dospecials + \tex_endlinechar:D = `\^^M \scan_stop: + \bool_if:NTF \l_xparse_long_bool + { \char_set_catcode_other:n { \tex_endlinechar:D } } + { \char_set_catcode_parameter:n { \tex_endlinechar:D } } + \xparse_grab_v_aux_loop:N #1 + } + { \xparse_grab_v_aux_abort: } + } +\cs_new_protected:Npn \xparse_grab_v_aux_loop:N #1 + { + \peek_N_type:TF + { \xparse_grab_v_aux_loop_ii:NN #1 } + { \xparse_grab_v_aux_abort: } + } +\cs_new_protected:Npn \xparse_grab_v_aux_loop_ii:NN #1 #2 + { + \xparse_grab_v_token_if_char:NTF #2 + { + \token_if_eq_charcode:NNTF #1 #2 + { \xparse_grab_v_aux_loop_end: } + { + \tl_put_right:Nn \l_xparse_v_arg_tl { #2 } + \xparse_grab_v_aux_loop:N #1 + } + } + { \xparse_grab_v_aux_abort: #2 } + } +\cs_new_protected_nopar:Npn \xparse_grab_v_aux_loop_end: + { + \xparse_grab_v_group_end: + \exp_args:Nx \xparse_add_arg:n + { \exp_args:No \str_tail:n { \l_xparse_v_arg_tl } } + \l_xparse_v_rest_of_signature_tl \l_xparse_args_tl + } +\cs_new_protected_nopar:Npn \xparse_grab_v_aux_abort: + { + \xparse_grab_v_group_end: + \xparse_add_arg:n { \NoValue } + \exp_after:wN \xparse_grab_v_aux_abort_ii:w \l_xparse_args_tl \q_stop + } +\cs_new_protected:Npn \xparse_grab_v_aux_abort_ii:w #1 #2 \q_stop + { + \group_begin: + \char_set_lccode:nn { `\# } { \tex_endlinechar:D } + \tl_to_lowercase:n + { \group_end: \peek_meaning_remove:NTF ## } + { + \msg_error:nnxx { xparse } { verbatim-newline } + { \cs_to_str:N #1 } + { \tl_to_str:N \l_xparse_v_arg_tl } + \l_xparse_v_rest_of_signature_tl \l_xparse_args_tl + } + { + \msg_error:nnxx { xparse } { verbatim-already-tokenized } + { \cs_to_str:N #1 } + { \tl_to_str:N \l_xparse_v_arg_tl } + \l_xparse_v_rest_of_signature_tl \l_xparse_args_tl + } + } +\cs_new_protected_nopar:Npn \xparse_grab_v_group_end: + { + \tl_set:Nx \l_xparse_tmp_tl + { + \tl_set:Nn \exp_not:N \l_xparse_v_rest_of_signature_tl + { \exp_not:o \l_xparse_v_rest_of_signature_tl } + \tl_set:Nn \exp_not:N \l_xparse_v_arg_tl + { \exp_not:o \l_xparse_v_arg_tl } + } + \exp_after:wN \group_align_safe_end: + \exp_after:wN \group_end: + \l_xparse_tmp_tl + } +\cs_new_protected:Npn \xparse_grab_v_token_if_char:NTF #1 + { \str_if_eq:xxTF { } { \str_tail:n {#1} } } \cs_new_protected:Npn \xparse_process_to_str:n #1 { \tl_set:Nx \ProcessedArgument { \tl_to_str:n {#1} } } \cs_new_protected:Npn \xparse_bool_reverse:N #1 @@ -709,7 +817,7 @@ \tl_to_lowercase:n { \group_end: - \tl_replace_all_in:Nnn \l_xparse_split_argument_tl { @ } {#2} + \tl_replace_all:Nnn \l_xparse_split_argument_tl { @ } {#2} } \cs_set_protected:Npn \xparse_split_argument_aux_i:w ##1 \q_mark ##2 #2 ##3 \q_stop @@ -759,7 +867,7 @@ \tl_to_lowercase:n { \group_end: - \tl_replace_all_in:Nnn \l_xparse_split_list_tl { @ } {#1} + \tl_replace_all:Nnn \l_xparse_split_list_tl { @ } {#1} } \cs_set:Npn \xparse_split_list_aux:w ##1 #1 { @@ -960,22 +1068,28 @@ \bool_set_false:N \l_xparse_error_bool \tl_if_in:nnT {#1} { > } { - \msg_error:nnx { xparse } { processor-in-expandable } + \msg_error:nnxx { xparse } { processor-in-expandable } { \tl_to_str:n {#1} } \bool_set_true:N \l_xparse_error_bool } \tl_if_in:nnT {#1} { g } { - \msg_error:nnx { xparse } { grouped-in-expandable } + \msg_error:nnxx { xparse } { grouped-in-expandable } { g } { \tl_to_str:n {#1} } \bool_set_true:N \l_xparse_error_bool } \tl_if_in:nnT {#1} { G } { - \msg_error:nnx { xparse } { grouped-in-expandable } + \msg_error:nnxx { xparse } { grouped-in-expandable } { G } { \tl_to_str:n {#1} } \bool_set_true:N \l_xparse_error_bool } + \tl_if_in:nnT {#1} { v } + { + \msg_error:nnxx { xparse } { verbatim-in-expandable } + { v } { \tl_to_str:n {#1} } + \bool_set_true:N \l_xparse_error_bool + } \bool_if:NF \l_xparse_error_bool { \xparse_exp_prepare_function_aux:n {#1} } } @@ -1015,9 +1129,8 @@ { \quark_if_nil:NF #1 { - \prop_if_in:NnTF \c_xparse_shorthands_prop {#1} + \prop_get:NnNTF \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl { - \prop_get:NnN \c_xparse_shorthands_prop {#1} \l_xparse_tmp_tl \bool_if:NT \l_xparse_long_bool { \tl_put_left:Nn \l_xparse_tmp_tl { + } } \exp_after:wN \xparse_exp_prepare_function:N \l_xparse_tmp_tl @@ -1173,6 +1286,27 @@ You~have~asked~for~the~argument~specification~for~a~command~'#1',~ but~this~is~not~a~document~environment. } +\msg_new:nnnn { xparse } { verbatim-newline } + { Verbatim~argument~of~#1~ended~by~end~of~line. } + { + Short~verbatim~arguments~cannot~contain~newlines.~ + I~suspect~you've~forgotten~the~closing~delimiter~of~#1. + I~will~ignore~'#2'. + } +\msg_new:nnnn { xparse } { verbatim-already-tokenized } + { Verbatim~command~#1~illegal~in~command~argument. } + { + The~command~#1~takes~a~verbatim~argument.~It~may~not~appear~within~ + the~argument~of~another~function.~I~will~ignore~'#2'. + } + +\msg_new:nnnn { xparse } { verbatim-in-expandable } + { Argument~specifier~'#1'~forbidden~in~expandable~commands. } + { + \c_msg_coding_error_text_tl + Argument~specification~'#2'~contains~the~verbatim~argument~'#1':~ + this~is only~supported~for~standard~robust~functions. + } \msg_new:nnn { xparse } { define-command } { Defining~document~command~#1~ |