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 | 200 |
1 files changed, 103 insertions, 97 deletions
diff --git a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty index ceb28c984f4..a73d9f7cd52 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 3036 2011-12-07 19:29:18Z joseph $ +\GetIdInfo$Id: xparse.dtx 3109 2011-12-29 10:42:27Z joseph $ {L3 Experimental document command parser} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{expl3} -\@ifpackagelater { expl3 } { 2011/12/07 } +\@ifpackagelater { expl3 } { 2011/12/29 } { } { \PackageError { xparse } { Support~package~l3kernel~too~old. } @@ -74,7 +74,6 @@ \tl_new:N \l_xparse_arg_tl \tl_new:N \l_xparse_args_tl \bool_new:N \l_xparse_environment_bool -\bool_new:N \l_xparse_error_bool \tl_new:N \l_xparse_function_tl \tl_new:N \l_xparse_last_arg_tl \bool_new:N \l_xparse_long_bool @@ -951,93 +950,117 @@ { \xparse_exp_add_type_D:w #1 #2 { \NoValue } } \cs_new_protected:Npn \xparse_exp_add_type_D:w #1#2#3 { - \tl_set:Nx \l_xparse_tmp_tl + \exp_args:NVV \xparse_exp_add_type_D_aux:nnNNn + \l_xparse_function_tl \l_xparse_total_args_int #1 #2 {#3} + \xparse_exp_prepare_function:N + } +\cs_new_protected:Npn \xparse_exp_add_type_D_aux:nnNNn #1#2#3#4#5 + { + \xparse_exp_set:cpx { #1 _arg_ #2 :w } ##1 \q_xparse ##2 { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_use:N \l_xparse_total_args_int + \exp_not:N \str_if_eq:nnTF {##2} {#3} + { \exp_not:c { #1 _arg_ #2 _aux:w } ##1 \exp_not:N \q_xparse } + { + \exp_not:c { #1 _arg_ \int_eval:n { #2 + \c_one } :w } + ##1 {#5} \exp_not:N \q_xparse {##2} + } } - \xparse_exp_set:cpx { \l_xparse_tmp_tl } ##1 \q_xparse ##2 + \xparse_exp_set:cpx { #1 _arg_ #2 _aux:w } ##1 \q_xparse ##2 #4 { - \exp_not:N \tl_if_head_eq_charcode:nNTF {##2} #1 + \exp_not:N \tl_if_empty:oTF + { \exp_not:c { #1 _arg_ #2 _open_check:w } ##2 { } { } #3 } { - \exp_not:c { \l_xparse_tmp_tl aux } - ##1 \exp_not:N \q_xparse + \exp_not:c { #1 _arg_ \int_eval:n { #2 + \c_one } :w } + ##1 {##2} \exp_not:N \q_xparse } { - \exp_not:c { \l_xparse_tmp_tl aux } - ##1 \exp_not:N \q_xparse #3 #2 {##2} + \exp_not:c { #1 _arg_ #2 _nested:wnnw } ##1 \exp_not:N \q_xparse + { } { } ##2 \exp_not:N \q_xparse } } - \xparse_exp_set:cpx { \l_xparse_tmp_tl aux} ##1 \q_xparse ##2 #2 + \cs_set:cpn { #1 _arg_ #2 _open_check:w } ##1 #3 { } + \xparse_exp_set:cpx { #1 _arg_ #2 _nested:wnnw } + ##1 \q_xparse ##2##3 ##4 #3 ##5 \q_xparse ##6 #4 { - \exp_not:c + \exp_not:N \tl_if_empty:oTF + { \exp_not:c { #1 _arg_ #2 _open_check:w } ##5 { } { } #3 } { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_eval:n { \l_xparse_total_args_int + 1 } + \exp_not:N \tl_if_empty:oTF + { + \exp_not:c { #1 _arg_ #2 _open_check:w } ##3 #4 ##6 { } { } #3 + } + { + \exp_not:c { #1 _arg_ \int_eval:n { #2 + \c_one } :w } + ##1 { ##2 ##4 #3 ##5 ##3 #4 ##6 } \exp_not:N \q_xparse + } + { + \exp_not:c { #1 _arg_ #2 _nested:wnnw } + ##1 \exp_not:N \q_xparse { ##2 ##4 #3 ##5 } { } + ##3 #4 ##6 \exp_not:N \q_xparse + } } - ##1 {##2} \exp_not:N \q_xparse - } - \xparse_exp_prepare_function:N - } -\cs_new_protected_nopar:Npn \xparse_exp_add_type_l:w - { - \xparse_exp_set:cpx - { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_use:N \l_xparse_total_args_int - } - ##1 \q_xparse ##2## - { - \exp_not:c { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_eval:n { \l_xparse_total_args_int + 1 } + \exp_not:c { #1 _arg_ #2 _nested:w } ##1 \exp_not:N \q_xparse + { ##2 ##4 #3 } + { ##3 #4 ##6 } + ##5 \exp_not:N \q_xparse } - ##1 {##2} \exp_not:N \q_xparse } - \xparse_exp_prepare_function:N } \cs_new_protected_nopar:Npn \xparse_exp_add_type_m:w { \int_incr:N \l_xparse_m_args_int \xparse_exp_set:cpx { - \exp_after:wN \token_to_str:N \l_xparse_function_tl + \l_xparse_function_tl + _arg_ \int_use:N \l_xparse_total_args_int + :w } ##1 \q_xparse ##2 { \exp_not:c { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_eval:n { \l_xparse_total_args_int + 1 } + \l_xparse_function_tl + _arg_ + \int_eval:n { \l_xparse_total_args_int + \c_one } + :w } - ##1 {##2} \exp_not:N \q_xparse + ##1 {##2} \exp_not:N \q_xparse } \xparse_exp_prepare_function:N } \cs_new_protected:Npn \xparse_exp_add_type_t:w #1 { - \tl_set:Nx \l_xparse_tmp_tl - { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_eval:n { \l_xparse_total_args_int + 1 } - } \xparse_exp_set:cpx { - \exp_after:wN \token_to_str:N \l_xparse_function_tl + \l_xparse_function_tl + _arg_ \int_use:N \l_xparse_total_args_int + :w } ##1 \q_xparse ##2 { - \exp_not:N \tl_if_head_eq_charcode:nNTF {##2} #1 + \exp_not:N \str_if_eq:nnTF {##2} {#1} { - \exp_not:c { \l_xparse_tmp_tl } + \exp_not:c + { + \l_xparse_function_tl + _arg_ + \int_eval:n { \l_xparse_total_args_int + \c_one } + :w + } ##1 \exp_not:n { { \BooleanTrue } \q_xparse } } { - \exp_not:c { \l_xparse_tmp_tl } - ##1 \exp_not:n { { \BooleanFalse } \q_xparse {##2} } + \exp_not:c + { + \l_xparse_function_tl + _arg_ + \int_eval:n { \l_xparse_total_args_int + \c_one } + :w + } + ##1 \exp_not:n { { \BooleanFalse } \q_xparse } {##2} } } \xparse_exp_prepare_function:N @@ -1046,15 +1069,19 @@ { \xparse_exp_set:cpx { - \exp_after:wN \token_to_str:N \l_xparse_function_tl + \l_xparse_function_tl + _arg_ \int_use:N \l_xparse_total_args_int + :w } ##1 \q_xparse ##2 #1 { \exp_not:c { - \exp_after:wN \token_to_str:N \l_xparse_function_tl - \int_eval:n { \l_xparse_total_args_int + 1 } + \l_xparse_function_tl + _arg_ + \int_eval:n { \l_xparse_total_args_int + \c_one } + :w } ##1 {##2} \exp_not:N \q_xparse } @@ -1064,7 +1091,8 @@ { \cs_if_free:cTF { xparse_exp_add_type_ #1 :w } { - \msg_error:nnx { xparse } { unknown-argument-type } + \msg_error:nnx { xparse } + { unknown-expandable-argument-type } { \tl_to_str:n {#1} } \tl_set:Nn \l_xparse_last_arg_tl { m } \xparse_exp_add_type_m:w @@ -1087,9 +1115,9 @@ } \group_begin: \tex_escapechar:D 92 \scan_stop: - \tl_set:Nx \l_xparse_function_tl { \token_to_str:N #1} - \exp_args:NNNo \group_end: - \tl_set:Nn \l_xparse_function_tl { \l_xparse_function_tl } + \tl_set:Nx \l_xparse_function_tl { \token_to_str:N #1 } + \exp_args:NNNV \group_end: + \tl_set:Nn \l_xparse_function_tl \l_xparse_function_tl \xparse_exp_prepare_function:n {#2} \int_compare:nNnTF \l_xparse_total_args_int = \l_xparse_m_args_int { \xparse_exp_declare_cmd_all_m:Nn #1 {#3} } @@ -1116,42 +1144,28 @@ \cs_new_protected:Npn \xparse_exp_declare_cmd_mixed_aux:Nn #1#2 { \cs_set_nopar:Npx #1 - { \exp_not:c { \token_to_str:N #1 1 } x \exp_not:N \q_xparse } + { + \exp_not:c { \l_xparse_function_tl _arg_ 1 :w } x \exp_not:N \q_xparse + } \cs_set_nopar:cpx - { \token_to_str:N #1 \int_eval:n { \l_xparse_total_args_int + 1 } } + { + \l_xparse_function_tl + _arg_ + \int_eval:n { \l_xparse_total_args_int + \c_one } + :w + } x ##1 \q_xparse - { \exp_not:c { \token_to_str:N #1 } ##1 } + { \exp_not:c { \l_xparse_function_tl } ##1 } \cs_generate_from_arg_count:cNnn - { \token_to_str:N #1 } \cs_set:Npn \l_xparse_total_args_int {#2} + { \l_xparse_function_tl } \cs_set:Npn \l_xparse_total_args_int {#2} } \cs_new_protected:Npn \xparse_exp_prepare_function:n #1 { - \bool_set_false:N \l_xparse_error_bool - \tl_if_in:nnT {#1} { > } + \tl_if_in:nnTF {#1} { > } { \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: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: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} } } \cs_new_protected:Npn \xparse_exp_prepare_function_aux:n #1 @@ -1299,14 +1313,6 @@ (or~no~arguments~at~all).~You~cannot~have~a~terminal~optional~ argument~with~expandable~commands. } -\msg_new:nnnn { xparse } { grouped-in-expandable } - { Argument~specifier~'#1'~forbidden~in~expandable~commands. } - { - \c_msg_coding_error_text_tl - Argument~specification~'#2'~contains~the~optional~grouped~ - argument~'#1':~ - this~is only~supported~for~standard~robust~functions. - } \msg_new:nnnn { xparse } { inconsistent-long } { Inconsistent~long~arguments~for~expandable~command. } { @@ -1347,6 +1353,14 @@ You~have~asked~for~the~argument~specification~for~a~command~'#1',~ but~this~is~not~a~document~environment. } +\msg_new:nnnn { xparse } { unknown-expandable-argument-type } + { Unknown~argument~type~'#1'~replaced~by~'m'. } + { + \c_msg_coding_error_text_tl + The~letter~'#1'~does~not~specify~an~argument~type~which~can~be~used~ + in~an~expandable~function. + LaTeX~will~assume~you~want~a~standard~mandatory~argument~(type~'m'). + } \msg_new:nnnn { xparse } { verbatim-newline } { Verbatim~argument~of~#1~ended~by~end~of~line. } { @@ -1360,14 +1374,6 @@ 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~ |