summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty95
1 files changed, 72 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 79d2c8402d2..4686bf73d70 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 2828 2011-09-15 20:04:53Z joseph $
+\GetIdInfo$Id: xparse.dtx 2900 2011-10-09 21:22:46Z joseph $
{L3 Experimental document command parser}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\RequirePackage{expl3}
-\@ifpackagelater { expl3 } { 2011/09/15 }
+\@ifpackagelater { expl3 } { 2011/10/09 }
{ }
{
\PackageError { xparse } { Support~package~l3kernel~too~old. }
@@ -716,26 +716,39 @@
}
\cs_new_protected:Npn \xparse_grab_v_aux:w #1 \l_xparse_args_tl
{
+ \tl_set:Nn \l_xparse_v_rest_of_signature_tl {#1}
\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: }
+ {
+ \peek_meaning_remove:NTF \c_group_begin_token
+ {
+ \group_align_safe_end:
+ \xparse_grab_v_bgroup:
+ }
+ { \xparse_grab_v_aux_abort: }
+ }
+ }
+\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_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_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_catcodes:
\xparse_grab_v_aux_loop:N #1
}
{ \xparse_grab_v_aux_abort: }
@@ -766,6 +779,52 @@
{ \exp_args:No \str_tail:n { \l_xparse_v_arg_tl } }
\l_xparse_v_rest_of_signature_tl \l_xparse_args_tl
}
+\int_new:N \l_xparse_v_nesting_int
+\cs_new_protected_nopar:Npn \xparse_grab_v_bgroup:
+ {
+ \xparse_grab_v_aux_catcodes:
+ \int_set_eq:NN \l_xparse_v_nesting_int \c_one
+ \tl_set:Nx \l_xparse_v_arg_tl { \iow_char:N \{ }
+ \xparse_grab_v_bgroup_loop:
+ }
+\cs_new_protected:Npn \xparse_grab_v_bgroup_loop:
+ {
+ \peek_N_type:TF
+ { \xparse_grab_v_bgroup_loop_ii:N }
+ { \xparse_grab_v_aux_abort: }
+ }
+\cs_new_protected:Npn \xparse_grab_v_bgroup_loop_ii:N #1
+ {
+ \xparse_grab_v_token_if_char:NTF #1
+ {
+ \token_if_eq_charcode:NNTF \c_group_end_token #1
+ {
+ \int_decr:N \l_xparse_v_nesting_int
+ \int_compare:nNnTF \l_xparse_v_nesting_int > \c_zero
+ {
+ \tl_put_right:Nn \l_xparse_v_arg_tl { #1 }
+ \xparse_grab_v_bgroup_loop:
+ }
+ { \xparse_grab_v_aux_loop_end: }
+ }
+ {
+ \token_if_eq_charcode:NNT \c_group_begin_token #1
+ { \int_incr:N \l_xparse_v_nesting_int }
+ \tl_put_right:Nn \l_xparse_v_arg_tl { #1 }
+ \xparse_grab_v_bgroup_loop:
+ }
+ }
+ { \xparse_grab_v_aux_abort: #1 }
+ }
+\cs_new_protected_nopar:Npn \xparse_grab_v_aux_catcodes:
+ {
+ \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 } }
+ }
\cs_new_protected_nopar:Npn \xparse_grab_v_aux_abort:
{
\xparse_grab_v_group_end:
@@ -791,19 +850,6 @@
\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
@@ -894,6 +940,8 @@
}
\group_end:
\cs_new_protected:Npn \xparse_split_list_aux:w { }
+\cs_new_protected:Npn \xparse_trim_spaces:n #1
+ { \tl_set:Nx \ProcessedArgument { \tl_trim_spaces:n {#1} } }
\cs_new_protected:Npn \xparse_exp_add_type_d:w #1#2
{ \xparse_exp_add_type_D:w #1 #2 { \NoValue } }
\cs_new_protected:Npn \xparse_exp_add_type_D:w #1#2#3
@@ -1395,6 +1443,7 @@
\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 \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