summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-12-21 23:28:17 +0000
committerKarl Berry <karl@freefriends.org>2015-12-21 23:28:17 +0000
commitc50b7eaa45c94a09e1087c6c31f144b497057444 (patch)
tree1a7690810029c971e4e952cdfb611420ef994909 /Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
parent9cca1577af3f3b749d81d88982ade41fb6f60db1 (diff)
l3 (21dec15)
git-svn-id: svn://tug.org/texlive/trunk@39162 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty378
1 files changed, 281 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 983e184e387..db91163ba0c 100644
--- a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
+++ b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
@@ -50,8 +50,8 @@
%%
%% -----------------------------------------------------------------------
%%
-\RequirePackage{expl3}[2015/11/04]
-\@ifpackagelater{expl3}{2015/11/04}
+\RequirePackage{expl3}[2015/12/20]
+\@ifpackagelater{expl3}{2015/12/20}
{}
{%
\PackageError{xparse}{Support package l3kernel too old}
@@ -65,8 +65,8 @@
}
\def\ExplFileName{xparse}
\def\ExplFileDescription{L3 Experimental document command parser}
-\def\ExplFileDate{2015/11/04}
-\def\ExplFileVersion{6224}
+\def\ExplFileDate{2015/12/20}
+\def\ExplFileVersion{6326}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\tl_const:Nx \c__xparse_no_value_tl
@@ -240,17 +240,19 @@
}
\cs_new_protected:Npn \__xparse_count_mandatory_aux:N #1
{
- \cs_if_free:cTF { __xparse_count_type_ \token_to_str:N #1 :w }
+ \cs_if_exist_use:cF { __xparse_count_type_ \token_to_str:N #1 :w }
{ \__xparse_count_type_m:w }
- { \use:c { __xparse_count_type_ \token_to_str:N #1 :w } }
}
-\cs_new_protected:cpn { __xparse_count_type_>:w } #1
+\cs_new_protected:cpn { __xparse_count_type_>:w } #1#2
+ {
+ \quark_if_recursion_tail_stop_do:nn {#2} { \__xparse_bad_arg_spec:wn }
+ \__xparse_count_mandatory:N #2
+ }
+\cs_new_protected:cpn { __xparse_count_type_+:w } #1
{
\quark_if_recursion_tail_stop_do:nn {#1} { \__xparse_bad_arg_spec:wn }
- \__xparse_count_mandatory:N
+ \__xparse_count_mandatory:N #1
}
-\cs_new_protected_nopar:cpn { __xparse_count_type_+:w }
- { \__xparse_count_mandatory:N }
\cs_new_protected:Npn \__xparse_count_type_d:w #1#2
{
\__xparse_single_token_check:n {#1}
@@ -272,6 +274,18 @@
\quark_if_recursion_tail_stop_do:nn {#1} { \__xparse_bad_arg_spec:wn }
\__xparse_count_mandatory:N
}
+\cs_new_protected:Npn \__xparse_count_type_k:w #1
+ {
+ \__xparse_single_token_check:n {#1}
+ \quark_if_recursion_tail_stop_do:Nn #1 { \__xparse_bad_arg_spec:wn }
+ \__xparse_count_mandatory:N
+ }
+\cs_new_protected:Npn \__xparse_count_type_K:w #1#2
+ {
+ \__xparse_single_token_check:n {#1}
+ \quark_if_recursion_tail_stop_do:nn {#2} { \__xparse_bad_arg_spec:wn }
+ \__xparse_count_mandatory:N
+ }
\cs_new_protected_nopar:Npn \__xparse_count_type_m:w
{
\int_incr:N \l__xparse_mandatory_args_int
@@ -307,7 +321,7 @@
}
\cs_new_protected:Npn \__xparse_single_token_check:n #1
{
- \tl_if_single:nF {#1}
+ \exp_args:Nx \tl_if_single_token:nF { \tl_trim_spaces:n {#1} }
{ \__xparse_single_token_check_aux:nwn {#1} }
}
\cs_new_protected:Npn \__xparse_single_token_check_aux:nwn
@@ -368,8 +382,8 @@
}
\cs_new_protected:cpn { __xparse_add_type_>:w } #1
{
- \bool_set_true:N \l__xparse_processor_bool
\__xparse_flush_m_args:
+ \bool_set_true:N \l__xparse_processor_bool
\int_decr:N \l__xparse_current_arg_int
\tl_put_right:Nn \l__xparse_signature_tl { \__xparse_process_arg:n {#1} }
\__xparse_prepare_signature_bypass:N
@@ -392,6 +406,15 @@
\tl_put_right:Nn \l__xparse_signature_tl { {#1} }
\__xparse_prepare_signature:N
}
+\cs_new_protected:Npn \__xparse_add_type_k:w #1
+ { \exp_args:NNo \__xparse_add_type_K:w #1 \c__xparse_no_value_tl }
+\cs_new_protected:Npn \__xparse_add_type_K:w #1#2
+ {
+ \__xparse_flush_m_args:
+ \__xparse_add_grabber_optional:N K
+ \tl_put_right:Nn \l__xparse_signature_tl { #1 {#2} }
+ \__xparse_prepare_signature:N
+ }
\cs_new_protected_nopar:Npn \__xparse_add_type_l:w
{
\__xparse_flush_m_args:
@@ -421,7 +444,7 @@
{
\__xparse_flush_m_args:
\__xparse_add_grabber_optional:N t
- \tl_put_right:Nn \l__xparse_signature_tl { #1 }
+ \tl_put_right:Nn \l__xparse_signature_tl {#1}
\__xparse_prepare_signature:N
}
\cs_new_protected:Npn \__xparse_add_type_u:w #1
@@ -442,9 +465,8 @@
\int_compare:nNnT \l__xparse_m_args_int > \c_zero
{
\tl_put_right:Nx \l__xparse_signature_tl
- { \exp_not:c { __xparse_grab_m_ \int_use:N \l__xparse_m_args_int :w } }
- \int_set:Nn \l__xparse_mandatory_args_int
- { \l__xparse_mandatory_args_int - \l__xparse_m_args_int }
+ { \exp_not:c { __xparse_grab_m_ \int_use:N \l__xparse_m_args_int :w } }
+ \int_sub:Nn \l__xparse_mandatory_args_int { \l__xparse_m_args_int }
}
\int_zero:N \l__xparse_m_args_int
}
@@ -499,7 +521,7 @@
}
\cs_new_protected:Npn \__xparse_add_expandable_type_D:w #1#2
{
- \token_if_eq_meaning:NNTF #1 #2
+ \tl_if_eq:nnTF {#1} {#2}
{
\__xparse_add_expandable_grabber_optional:n { D_alt }
\__xparse_add_expandable_type_D_aux:Nn #1
@@ -551,6 +573,27 @@
{ G }
\__xparse_add_expandable_type_m:w
}
+\cs_new_protected_nopar:Npn \__xparse_add_expandable_type_k:w #1
+ {
+ \exp_args:NNo
+ \__xparse_add_expandable_type_K:w #1 \c__xparse_no_value_tl
+ }
+\cs_new_protected_nopar:Npn \__xparse_add_expandable_type_K:w #1#2
+ {
+ \__xparse_add_expandable_grabber_optional:n { K }
+ \bool_if:NTF \l__xparse_all_long_bool
+ { \cs_set:cpx }
+ { \cs_set_nopar:cpx }
+ { \l__xparse_expandable_aux_name_tl } ##1 #1 ##2
+ { ##1 {##2} }
+ \tl_put_right:Nx \l__xparse_signature_tl
+ {
+ \exp_not:c { \l__xparse_expandable_aux_name_tl }
+ \exp_not:n { #1 {#2} }
+ }
+ \bool_set_false:N \l__xparse_long_bool
+ \__xparse_prepare_signature:N
+ }
\cs_new_protected_nopar:Npn \__xparse_add_expandable_type_l:w
{
\__msg_kernel_error:nnx { xparse } { invalid-expandable-argument-type }
@@ -571,13 +614,13 @@
}
\cs_new_protected:Npn \__xparse_add_expandable_type_R:w #1#2
{
- \token_if_eq_meaning:NNTF #1 #2
+ \tl_if_eq:nnTF {#1} {#2}
{
- \__xparse_add_expandable_grabber_optional:n { R_alt }
+ \__xparse_add_expandable_grabber_mandatory:n { R_alt }
\__xparse_add_expandable_type_D_aux:Nn #1
}
{
- \__xparse_add_expandable_grabber_optional:n { R }
+ \__xparse_add_expandable_grabber_mandatory:n { R }
\__xparse_add_expandable_type_D_aux:NNn #1#2
}
}
@@ -590,7 +633,7 @@
{ \l__xparse_expandable_aux_name_tl } ##1 #1 {##1}
\tl_put_right:Nx \l__xparse_signature_tl
{
- \exp_not:c { \l__xparse_expandable_aux_name_tl }
+ \exp_not:c { \l__xparse_expandable_aux_name_tl }
\exp_not:N #1
}
\bool_set_false:N \l__xparse_long_bool
@@ -627,7 +670,7 @@
}
\cs_new_protected_nopar:Npn \__xparse_add_expandable_long_check:
{
- \bool_if:nT { \l__xparse_all_long_bool && ! ( \l__xparse_long_bool ) }
+ \bool_if:nT { \l__xparse_all_long_bool && ! \l__xparse_long_bool }
{ \__msg_kernel_error:nn { xparse } { inconsistent-long } }
}
\cs_new_protected:Npn \__xparse_grab_arg:w { }
@@ -759,6 +802,48 @@
#2 \l__xparse_args_tl
}
}
+\cs_new_protected:Npn \__xparse_grab_K:w #1#2#3 \l__xparse_args_tl
+ {
+ \__xparse_grab_K_aux:nnnNn
+ {#1} {#2} {#3}
+ \cs_set_protected_nopar:Npn
+ { _ignore_spaces }
+ }
+\cs_new_protected:Npn \__xparse_grab_K_long:w #1#2#3 \l__xparse_args_tl
+ {
+ \__xparse_grab_K_aux:nnnNn
+ {#1} {#2} {#3}
+ \cs_set_protected:Npn
+ { _ignore_spaces }
+ }
+\cs_new_protected:Npn \__xparse_grab_K_trailing:w #1#2#3 \l__xparse_args_tl
+ {
+ \__xparse_grab_K_aux:nnnNn
+ {#1} {#2} {#3}
+ \cs_set_protected_nopar:Npn
+ { }
+ }
+\cs_new_protected:Npn \__xparse_grab_K_long_trailing:w #1#2#3 \l__xparse_args_tl
+ {
+ \__xparse_grab_K_aux:nnnNn
+ {#1} {#2} {#3}
+ \cs_set_protected:Npn
+ { }
+ }
+\cs_new_protected:Npn \__xparse_grab_K_aux:nnnNn #1#2#3#4#5
+ {
+ \exp_after:wN #4 \l__xparse_fn_tl ##1
+ {
+ \__xparse_add_arg:n {##1}
+ #3 \l__xparse_args_tl
+ }
+ \use:c { peek_meaning_remove #5 :NTF } #1
+ { \l__xparse_fn_tl }
+ {
+ \__xparse_add_arg:n {#2}
+ #3 \l__xparse_args_tl
+ }
+ }
\cs_new_protected:Npn \__xparse_grab_l:w #1 \l__xparse_args_tl
{ \__xparse_grab_l_aux:nN {#1} \cs_set_protected_nopar:Npn }
\cs_new_protected:Npn \__xparse_grab_l_long:w #1 \l__xparse_args_tl
@@ -981,7 +1066,7 @@
{ \__xparse_grab_v_aux_loop:NN #1 }
{ \__xparse_grab_v_aux_abort:n { } }
}
-\cs_new_protected:Npn \__xparse_grab_v_aux_loop:NN #1 #2
+\cs_new_protected:Npn \__xparse_grab_v_aux_loop:NN #1#2
{
\__xparse_grab_v_token_if_char:NTF #2
{
@@ -1112,7 +1197,7 @@
{
\str_if_eq:onTF
{ #1 { } { } #7 #2 \q__xparse #3 }
- { { } { #2 } { } }
+ { { } {#2} { } }
{
#1
{ \__xparse_expandable_grab_D:NNNwNnnn #1#2#3#5 \q__xparse #6 }
@@ -1134,7 +1219,7 @@
{ #3 { \use_none:nnn } #2 \q__xparse #5 #4 \q__xparse #5 }
{
\tl_if_blank:oTF { \use_none:nn #1#2 }
- { \__xparse_put_arg_expandable:ow { } }
+ { \__xparse_put_arg_expandable:ow { \use_none:nn #1#2 } }
{
\str_if_eq_x:nnTF
{ \exp_not:o { \use_none:nn #1#2 } }
@@ -1142,7 +1227,7 @@
{ \__xparse_put_arg_expandable:ow { \use_iii:nnn #1#2 } }
{ \__xparse_put_arg_expandable:ow { \use_none:nn #1#2 } }
}
- #6 \q__xparse #7
+ #6 \q__xparse #7
}
{
#3
@@ -1166,8 +1251,8 @@
}
\cs_new:Npn \__xparse_expandable_grab_D_alt:Nwn #1#2 \q__xparse #3
{
- \tl_if_blank:oTF { \use_none:nn #1#2 }
- { \__xparse_put_arg_expandable:ow { } }
+ \tl_if_blank:oTF { \use_none:n #3 }
+ { \__xparse_put_arg_expandable:ow { \use_none:n #3 } }
{
\str_if_eq_x:nnTF
{ \exp_not:o { \use_none:n #3 } }
@@ -1175,8 +1260,22 @@
{ \__xparse_put_arg_expandable:ow { \use_ii:nn #3 } }
{ \__xparse_put_arg_expandable:ow { \use_none:n #3 } }
}
- #2 \q__xparse #1
+ #2 \q__xparse #1
+ }
+\cs_new:Npn \__xparse_expandable_grab_K:w #1 \q__xparse #2
+ { #2 { \__xparse_expandable_grab_K_aux:NNwn #1 \q__xparse #2 } }
+\cs_new:Npn \__xparse_expandable_grab_K_aux:NNwn #1#2#3#4 \q__xparse #5#6
+ {
+ \str_if_eq:onTF { #1 { } #6 { } #2 { } } { { } #2 { } }
+ {
+ #1
+ { \__xparse_expandable_grab_K_aux:Nwn #5 #4 \q__xparse }
+ #6
+ }
+ { #4 {#3} \q__xparse #5 {#6} }
}
+\cs_new:Npn \__xparse_expandable_grab_K_aux:Nwn #1#2 \q__xparse #3
+ { #2 {#3} \q__xparse #1 }
\cs_new:Npn \__xparse_expandable_grab_m:w #1 \q__xparse #2
{ #2 { \__xparse_expandable_grab_m_aux:wNn #1 \q__xparse #2 } }
\cs_new:Npn \__xparse_expandable_grab_m_aux:wNn #1 \q__xparse #2#3
@@ -1187,7 +1286,7 @@
{
\str_if_eq:onTF
{ #1 { } { } #7 #2 \q__xparse #3 }
- { { } { #2 } { } }
+ { { } {#2} { } }
{
#1
{ \__xparse_expandable_grab_D:NNNwNnnn #1#2#3#5 \q__xparse #6 }
@@ -1221,7 +1320,7 @@
{ #2 { \__xparse_expandable_grab_t_aux:NNwn #1 \q__xparse #2 } }
\cs_new:Npn \__xparse_expandable_grab_t_aux:NNwn #1#2#3 \q__xparse #4#5
{
- \str_if_eq:onTF { #1 { } #5 #2 } { #2 }
+ \str_if_eq:onTF { #1 { } #5 #2 } {#2}
{ #3 { \BooleanTrue } \q__xparse #4 }
{ #3 { \BooleanFalse } \q__xparse #4 {#5} }
}
@@ -1231,11 +1330,10 @@
\cs_new_protected:Npn \__xparse_process_arg:n #1
{
\int_incr:N \l__xparse_processor_int
- \cs_set:cpn { __xparse_processor_ \int_use:N \l__xparse_processor_int :n } ##1
- { #1 {##1} }
+ \cs_set_protected:cpx
+ { __xparse_processor_ \int_use:N \l__xparse_processor_int :n } ##1
+ { \exp_not:n {#1} {##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
{
\bool_if:NTF #1
@@ -1246,15 +1344,15 @@
\tl_new:N \l__xparse_split_list_tl
\cs_new_protected:Npn \__xparse_split_list:nn #1#2
{
- \bool_if:nTF
+ \tl_if_single:nTF {#1}
{
- \tl_if_single_p:n {#1} &&
- ! ( \token_if_cs_p:N #1 )
+ \token_if_cs:NTF #1
+ { \__xparse_split_list_multi:nn {#1} {#2} }
+ { \__xparse_split_list_single:Nn #1 {#2} }
}
- { \__xparse_split_list_single:Nn #1 {#2} }
{ \__xparse_split_list_multi:nn {#1} {#2} }
- }
-\cs_set_protected:Npn \__xparse_split_list_multi:nn #1#2
+ }
+\cs_new_protected:Npn \__xparse_split_list_multi:nn #1#2
{
\seq_set_split:Nnn \l__xparse_split_list_seq {#1} {#2}
\tl_clear:N \ProcessedArgument
@@ -1263,16 +1361,16 @@
}
\cs_generate_variant:Nn \__xparse_split_list_multi:nn { nV }
\group_begin:
-\char_set_catcode_active:N \@
+\char_set_catcode_active:N \^^@
\cs_new_protected:Npn \__xparse_split_list_single:Nn #1#2
{
\tl_set:Nn \l__xparse_split_list_tl {#2}
\group_begin:
- \char_set_lccode:nn { `\@ } { `#1 }
+ \char_set_lccode:nn { `\^^@ } { `#1 }
\tex_lowercase:D
{
\group_end:
- \tl_replace_all:Nnn \l__xparse_split_list_tl { @ }
+ \tl_replace_all:Nnn \l__xparse_split_list_tl { ^^@ }
} {#1}
\__xparse_split_list_multi:nV {#1} \l__xparse_split_list_tl
}
@@ -1322,44 +1420,56 @@
}
\cs_new_protected:Npn \__xparse_trim_spaces:n #1
{ \tl_set:Nx \ProcessedArgument { \tl_trim_spaces:n {#1} } }
-\cs_new_protected:Npn \__xparse_get_arg_spec:N #1
+\cs_new_protected:Npn \__xparse_get_arg_spec_error:N #1
{
- \prop_get:NnNF \l__xparse_command_arg_specs_prop {#1}
- \ArgumentSpecification
+ \cs_if_exist:NTF #1
+ {
+ \__msg_kernel_error:nnx { xparse } { non-xparse-command }
+ { \token_to_str:N #1 }
+ }
{
- \__msg_kernel_error:nnx { xparse } { unknown-document-command }
+ \__msg_kernel_error:nnx { xparse } { unknown-command }
{ \token_to_str:N #1 }
}
}
-\cs_new_protected:Npn \__xparse_get_arg_spec:n #1
+\cs_new_protected:Npn \__xparse_get_arg_spec_error:n #1
{
- \prop_get:NnNF \l__xparse_environment_arg_specs_prop {#1}
- \ArgumentSpecification
+ \cs_if_exist:cTF {#1}
+ {
+ \__msg_kernel_error:nnx { xparse } { non-xparse-environment }
+ { \tl_to_str:n {#1} }
+ }
{
- \__msg_kernel_error:nnx { xparse } { unknown-document-environment }
+ \__msg_kernel_error:nnx { xparse } { unknown-environment }
{ \tl_to_str:n {#1} }
}
}
+\cs_new_protected:Npn \__xparse_get_arg_spec:N #1
+ {
+ \prop_get:NnNF \l__xparse_command_arg_specs_prop {#1}
+ \ArgumentSpecification
+ { \__xparse_get_arg_spec_error:N #1 }
+ }
+\cs_new_protected:Npn \__xparse_get_arg_spec:n #1
+ {
+ \prop_get:NnNF \l__xparse_environment_arg_specs_prop {#1}
+ \ArgumentSpecification
+ { \__xparse_get_arg_spec_error:n {#1} }
+ }
\tl_new:N \ArgumentSpecification
\cs_new_protected:Npn \__xparse_show_arg_spec:N #1
{
\prop_get:NnNTF \l__xparse_command_arg_specs_prop {#1}
\ArgumentSpecification
{ \tl_show:N \ArgumentSpecification }
- {
- \__msg_kernel_error:nnx { xparse } { unknown-document-command }
- { \token_to_str:N #1 }
- }
+ { \__xparse_get_arg_spec_error:N #1 }
}
\cs_new_protected:Npn \__xparse_show_arg_spec:n #1
{
\prop_get:NnNTF \l__xparse_environment_arg_specs_prop {#1}
\ArgumentSpecification
{ \tl_show:N \ArgumentSpecification }
- {
- \__msg_kernel_error:nnx { xparse } { unknown-document-environment }
- { \tl_to_str:n {#1} }
- }
+ { \__xparse_get_arg_spec_error:n {#1} }
}
\use:x
{
@@ -1376,8 +1486,40 @@
{ \exp_not:N \prg_return_false: }
}
\cs_new:Npn \exp_not:N \__xparse_if_value_aux:w ##1 \c__xparse_no_value_tl
- { ##1 }
+ {##1}
}
+\cs_new_protected:Npn \__xparse_check_definable:nNT #1
+ { \exp_args:Nx \__xparse_check_definable_aux:nN { \tl_trim_spaces:n {#1} } }
+\group_begin:
+ \char_set_catcode_active:n { `? }
+ \cs_new_protected:Npn \__xparse_check_definable_aux:nN #1#2
+ {
+ \group_begin:
+ \tl_if_single_token:nTF {#1}
+ {
+ \int_set:Nn \tex_escapechar:D { 92 }
+ \exp_args:Nx \tl_if_empty:nTF
+ { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
+ {
+ \exp_args:Nx \char_set_lccode:nn
+ { ` \str_head:n {#1} } { `? }
+ \tex_lowercase:D { \tl_if_eq:nnTF {#1} } { ? }
+ { \group_end: \use_iii:nnn }
+ { \group_end: \use_i:nnn }
+ }
+ { \group_end: \use_iii:nnn }
+ }
+ { \group_end: \use_ii:nnn }
+ {
+ \__msg_kernel_error:nnxx { xparse } { not-definable }
+ { \tl_to_str:n {#1} } { \token_to_str:N #2 }
+ }
+ {
+ \__msg_kernel_error:nnxx { xparse } { not-one-token }
+ { \tl_to_str:n {#1} } { \token_to_str:N #2 }
+ }
+ }
+\group_end:
\__msg_kernel_new:nnnn { xparse } { bad-arg-spec }
{ Bad~argument~specification~'#1'. }
{
@@ -1407,12 +1549,6 @@
with~an~environment~that~already~has~a~definition. \\
The~existing~definition~of~'#1'~will~be~overwritten.
}
-\__msg_kernel_new:nnnn { xparse } { environment-mismatch }
- { Mismatch~between~start~and~end~of~environment. }
- {
- The~current~environment~is~called~'#1',~but~you~have~tried~to~
- end~one~called~'#2'.~Environments~have~to~be~properly~nested.
- }
\__msg_kernel_new:nnnn { xparse } { environment-not-yet-defined }
{ Environment~'#1'~not~yet~defined! }
{
@@ -1420,13 +1556,6 @@
with~an~environment~that~was~never~defined. \\
A~new~environment~'#1'~will~be~created.
}
-\__msg_kernel_new:nnnn { xparse } { environment-unknown }
- { Environment~'#1'~undefined. }
- {
- You~have~tried~to~start~an~environment~called~'#1',~
- but~this~has~never~been~defined. \\
- The~command~will~be~ignored.
- }
\__msg_kernel_new:nnnn { xparse } { expandable-ending-optional }
{
Argument~specification~for~expandable~command~ends~with~optional~argument.
@@ -1460,6 +1589,38 @@
'#1'.~LaTeX~did~not~find~it,~and~will~insert~'#2'~as~the~value~to~be~
processed.
}
+\__msg_kernel_new:nnnn { xparse } { non-xparse-command }
+ { Command~'#1'~not~defined~using~xparse. }
+ {
+ You~have~asked~for~the~argument~specification~for~a~command~'#1',~
+ but~this~is~not~a~command~defined~using~xparse.
+ }
+\__msg_kernel_new:nnnn { xparse } { non-xparse-environment }
+ { Environment~'#1'~not~defined~using~xparse. }
+ {
+ You~have~asked~for~the~argument~specification~for~an~environment~'#1',~
+ but~this~is~not~an~environment~defined~using~xparse.
+ }
+\__msg_kernel_new:nnnn { xparse } { not-definable }
+ { First~argument~of~'#2'~must~be~a~command. }
+ {
+ \c__msg_coding_error_text_tl
+ The~first~argument~of~'#2'~should~be~the~document~command~that~will~
+ be~defined.~The~provided~argument~'#1'~is~a~character.~Perhaps~a~
+ backslash~is~missing?
+ \\ \\
+ LaTeX~will~ignore~this~entire~definition.
+ }
+\__msg_kernel_new:nnnn { xparse } { not-one-token }
+ { First~argument~of~'#2'~must~be~a~command. }
+ {
+ \c__msg_coding_error_text_tl
+ The~first~argument~of~'#2'~should~be~the~document~command~that~will~
+ be~defined.~The~provided~argument~'#1'~contains~more~than~one~
+ token.
+ \\ \\
+ LaTeX~will~ignore~this~entire~definition.
+ }
\__msg_kernel_new:nnnn { xparse } { not-single-token }
{ Argument~delimiter~should~be~a~single~token:~'#1'. }
{
@@ -1489,17 +1650,17 @@
The~letter~'#1'~does~not~specify~a~known~argument~type.~
LaTeX~will~assume~you~want~a~standard~mandatory~argument~(type~'m').
}
-\__msg_kernel_new:nnnn { xparse } { unknown-document-command }
+\__msg_kernel_new:nnnn { xparse } { unknown-command }
{ Unknown~document~command~'#1'. }
{
You~have~asked~for~the~argument~specification~for~a~command~'#1',~
- but~this~is~not~a~document~command.
+ but~it~is~not~defined.
}
-\__msg_kernel_new:nnnn { xparse } { unknown-document-environment }
+\__msg_kernel_new:nnnn { xparse } { unknown-environment }
{ Unknown~document~environment~'#1'. }
{
- You~have~asked~for~the~argument~specification~for~a~command~'#1',~
- but~this~is~not~a~document~environment.
+ You~have~asked~for~the~argument~specification~for~an~environment~'#1',~
+ but~it~is~not~defined.
}
\__msg_kernel_new:nnnn { xparse } { verbatim-newline }
{ Verbatim~argument~of~'#1'~ended~by~end~of~line. }
@@ -1545,27 +1706,39 @@
\cs_new_eq:NN \BooleanFalse \c_false_bool
\cs_new_eq:NN \BooleanTrue \c_true_bool
\cs_new_protected:Npn \DeclareDocumentCommand #1#2#3
- { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
+ {
+ \__xparse_check_definable:nNT {#1} \DeclareDocumentCommand
+ { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
+ }
\cs_new_protected:Npn \NewDocumentCommand #1#2#3
{
- \cs_if_exist:NTF #1
+ \__xparse_check_definable:nNT {#1} \NewDocumentCommand
{
- \__msg_kernel_error:nnx { xparse } { command-already-defined }
- { \token_to_str:N #1 }
+ \cs_if_exist:NTF #1
+ {
+ \__msg_kernel_error:nnx { xparse } { command-already-defined }
+ { \token_to_str:N #1 }
+ }
+ { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
}
- { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
}
\cs_new_protected:Npn \RenewDocumentCommand #1#2#3
{
- \cs_if_exist:NTF #1
- { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
+ \__xparse_check_definable:nNT {#1} \RenewDocumentCommand
{
- \__msg_kernel_error:nnx { xparse } { command-not-yet-defined }
- { \token_to_str:N #1 }
+ \cs_if_exist:NTF #1
+ { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
+ {
+ \__msg_kernel_error:nnx { xparse } { command-not-yet-defined }
+ { \token_to_str:N #1 }
+ }
}
}
\cs_new_protected:Npn \ProvideDocumentCommand #1#2#3
- { \cs_if_exist:NF #1 { \__xparse_declare_cmd:Nnn #1 {#2} {#3} } }
+ {
+ \__xparse_check_definable:nNT {#1} \ProvideDocumentCommand
+ { \cs_if_exist:NF #1 { \__xparse_declare_cmd:Nnn #1 {#2} {#3} } }
+ }
\cs_new_protected:Npn \DeclareDocumentEnvironment #1#2#3#4
{ \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} }
\cs_new_protected:Npn \NewDocumentEnvironment #1#2#3#4
@@ -1581,27 +1754,38 @@
{ \__msg_kernel_error:nnx { xparse } { environment-not-yet-defined } {#1} }
}
\cs_new_protected:Npn \ProvideDocumentEnvironment #1#2#3#4
- { \cs_if_exist:cF { #1 } { \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } }
+ { \cs_if_exist:cF {#1} { \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } }
\cs_new_protected:Npn \DeclareExpandableDocumentCommand #1#2#3
- { \__xparse_declare_expandable_cmd:Nnn #1 {#2} {#3} }
+ {
+ \__xparse_check_definable:nNT {#1} \DeclareExpandableDocumentCommand
+ { \__xparse_declare_expandable_cmd:Nnn #1 {#2} {#3} }
+ }
\cs_new_eq:NN \IfBooleanTF \bool_if:NTF
\cs_new_eq:NN \IfBooleanT \bool_if:NT
\cs_new_eq:NN \IfBooleanF \bool_if:NF
\cs_new_eq:NN \IfNoValueF \__xparse_if_no_value:nF
\cs_new_eq:NN \IfNoValueT \__xparse_if_no_value:nT
\cs_new_eq:NN \IfNoValueTF \__xparse_if_no_value:nTF
-\cs_set:Npn \IfValueF { \__xparse_if_no_value:nT }
-\cs_set:Npn \IfValueT { \__xparse_if_no_value:nF }
-\cs_set:Npn \IfValueTF #1#2#3 { \__xparse_if_no_value:nTF {#1} {#3} {#2} }
+\cs_new_nopar:Npn \IfValueF { \__xparse_if_no_value:nT }
+\cs_new_nopar:Npn \IfValueT { \__xparse_if_no_value:nF }
+\cs_new:Npn \IfValueTF #1#2#3 { \__xparse_if_no_value:nTF {#1} {#3} {#2} }
\tl_new:N \ProcessedArgument
\cs_new_eq:NN \ReverseBoolean \__xparse_bool_reverse:N
\cs_new_eq:NN \SplitArgument \__xparse_split_argument:nnn
\cs_new_eq:NN \SplitList \__xparse_split_list:nn
\cs_new_eq:NN \TrimSpaces \__xparse_trim_spaces:n
\cs_new_eq:NN \ProcessList \tl_map_function:nN
-\cs_new_eq:NN \GetDocumentCommandArgSpec \__xparse_get_arg_spec:N
-\cs_new_eq:NN \GetDocumentEnvironmmentArgSpec \__xparse_get_arg_spec:n
-\cs_new_eq:NN \ShowDocumentCommandArgSpec \__xparse_show_arg_spec:N
+\cs_new_protected:Npn \GetDocumentCommandArgSpec #1
+ {
+ \__xparse_check_definable:nNT {#1} \GetDocumentCommandArgSpec
+ { \__xparse_get_arg_spec:N #1 }
+ }
+\cs_new_eq:NN \GetDocumentEnvironmentArgSpec \__xparse_get_arg_spec:n
+\cs_new_protected:Npn \ShowDocumentCommandArgSpec #1
+ {
+ \__xparse_check_definable:nNT {#1} \ShowDocumentCommandArgSpec
+ { \__xparse_show_arg_spec:N #1 }
+ }
\cs_new_eq:NN \ShowDocumentEnvironmentArgSpec \__xparse_show_arg_spec:n
\clist_new:N \l__xparse_options_clist
\DeclareOption* { \clist_put_right:NV \l__xparse_options_clist \CurrentOption }