| 1 |
%% |
| 2 |
%% This is file `xparse.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% xparse.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2009-2025 The LaTeX Project |
| 10 |
%% |
| 11 |
%% It may be distributed and/or modified under the conditions of |
| 12 |
%% the LaTeX Project Public License (LPPL), either version 1.3c of |
| 13 |
%% this license or (at your option) any later version. The latest |
| 14 |
%% version of this license is in the file: |
| 15 |
%% |
| 16 |
%% http://www.latex-project.org/lppl.txt |
| 17 |
%% |
| 18 |
%% This file is part of the "l3packages bundle" (The Work in LPPL) |
| 19 |
%% and all files in that bundle must be distributed together. |
| 20 |
%% |
| 21 |
%% File: xparse.dtx |
| 22 |
\RequirePackage{expl3}[2018-04-12] |
| 23 |
\@ifpackagelater{expl3}{2018-04-12} |
| 24 |
{} |
| 25 |
{% |
| 26 |
\PackageError{xparse}{Support package l3kernel too old} |
| 27 |
{% |
| 28 |
Please install an up to date version of l3kernel\MessageBreak |
| 29 |
using your TeX package manager or from CTAN.\MessageBreak |
| 30 |
\MessageBreak |
| 31 |
Loading xparse will abort!% |
| 32 |
}% |
| 33 |
\endinput |
| 34 |
} |
| 35 |
\ExplSyntaxOn |
| 36 |
\cs_set_protected:Npn \__cmd_tmp:w #1 |
| 37 |
{ |
| 38 |
\DeclareOption* { \PassOptionsToPackage { \CurrentOption } {#1} } |
| 39 |
\ProcessOptions \relax |
| 40 |
\RequirePackage {#1} |
| 41 |
} |
| 42 |
\cs_if_free:NTF \NewDocumentCommand |
| 43 |
{ |
| 44 |
\ExplSyntaxOff |
| 45 |
\ifnum\expandafter |
| 46 |
\@parse@version\fmtversion//00\@nil < |
| 47 |
\@parse@version 2020-10-01//00\@nil |
| 48 |
\__cmd_tmp:w { xparse-2018-04-12 } |
| 49 |
\else |
| 50 |
\__cmd_tmp:w { xparse-2020-10-01 } |
| 51 |
\fi |
| 52 |
\file_input_stop: |
| 53 |
} |
| 54 |
{ |
| 55 |
\ExplSyntaxOff |
| 56 |
\cs_if_exist:NF \__cmd_start:nNNnnn |
| 57 |
{ |
| 58 |
\__cmd_tmp:w { xparse-2020-10-01 } |
| 59 |
\file_input_stop: |
| 60 |
} |
| 61 |
} |
| 62 |
\ExplSyntaxOff |
| 63 |
\ProvidesExplPackage{xparse}{2025-10-09}{} |
| 64 |
{L3 Experimental document command parser} |
| 65 |
\clist_new:N \l__cmd_options_clist |
| 66 |
\DeclareOption* { \clist_put_right:NV \l__cmd_options_clist \CurrentOption } |
| 67 |
\ProcessOptions \relax |
| 68 |
\cs_set_protected:Npn \__cmd_tmp:w #1 |
| 69 |
{ |
| 70 |
\keys_define:nn {#1} |
| 71 |
{ |
| 72 |
log-declarations .bool_set:N = \l__cmd_log_bool , |
| 73 |
log-declarations .initial:n = false |
| 74 |
} |
| 75 |
\keys_set:nV {#1} \l__cmd_options_clist |
| 76 |
\bool_if:NTF \l__cmd_log_bool |
| 77 |
{ \msg_redirect_module:nnn {#1} { info } { } } |
| 78 |
{ \msg_redirect_module:nnn {#1} { info } { none } } |
| 79 |
\cs_new_protected:Npn \__cmd_unknown_argument_type_error:n ##1 |
| 80 |
{ |
| 81 |
\msg_error:nnee {#1} { unknown-argument-type } |
| 82 |
{ \__cmd_environment_or_command: } { \tl_to_str:n {##1} } |
| 83 |
} |
| 84 |
} |
| 85 |
\msg_if_exist:nnTF { cmd } { define-command } |
| 86 |
{ \__cmd_tmp:w { cmd } } |
| 87 |
{ \__cmd_tmp:w { ltcmd } } |
| 88 |
\cs_gset_protected:Npn \__cmd_normalize_arg_spec_loop:n #1 |
| 89 |
{ |
| 90 |
\quark_if_recursion_tail_stop:n {#1} |
| 91 |
\int_incr:N \l__cmd_current_arg_int |
| 92 |
\cs_if_exist_use:cF { __cmd_normalize_type_ \tl_to_str:n {#1} :w } |
| 93 |
{ |
| 94 |
\__cmd_unknown_argument_type_error:n {#1} |
| 95 |
\__cmd_bad_def:wn |
| 96 |
} |
| 97 |
} |
| 98 |
\cs_new_protected:Npe \__cmd_normalize_type_g:w |
| 99 |
{ \exp_not:N \__cmd_normalize_type_G:w { \exp_not:V \c_novalue_tl } } |
| 100 |
\cs_new_protected:Npn \__cmd_normalize_type_G:w #1 |
| 101 |
{ |
| 102 |
\quark_if_recursion_tail_stop_do:nn {#1} { \__cmd_bad_arg_spec:wn } |
| 103 |
\__cmd_normalize_check_gv:N G |
| 104 |
\__cmd_add_arg_spec:n { G {#1} } |
| 105 |
\tl_put_right:Nn \l__cmd_last_delimiters_tl { { } } |
| 106 |
\__cmd_normalize_arg_spec_loop:n |
| 107 |
} |
| 108 |
\cs_new_protected:Npn \__cmd_normalize_type_l:w |
| 109 |
{ |
| 110 |
\__cmd_normalize_check_lu:N l |
| 111 |
\__cmd_add_arg_spec_mandatory:n { l } |
| 112 |
\__cmd_normalize_arg_spec_loop:n |
| 113 |
} |
| 114 |
\cs_new_protected:Npn \__cmd_normalize_type_u:w #1 |
| 115 |
{ |
| 116 |
\quark_if_recursion_tail_stop_do:nn {#1} { \__cmd_bad_arg_spec:wn } |
| 117 |
\__cmd_normalize_check_lu:N u |
| 118 |
\__cmd_add_arg_spec_mandatory:n { u {#1} } |
| 119 |
\__cmd_normalize_arg_spec_loop:n |
| 120 |
} |
| 121 |
\cs_new_protected:Npn \__cmd_add_type_G:w #1 |
| 122 |
{ |
| 123 |
\__cmd_flush_m_args: |
| 124 |
\__cmd_add_default:n {#1} |
| 125 |
\__cmd_add_grabber:N G |
| 126 |
\__cmd_prepare_signature:N |
| 127 |
} |
| 128 |
\cs_new_protected:Npn \__cmd_add_type_l:w |
| 129 |
{ |
| 130 |
\__cmd_flush_m_args: |
| 131 |
\__cmd_add_default: |
| 132 |
\__cmd_add_grabber:N l |
| 133 |
\__cmd_prepare_signature:N |
| 134 |
} |
| 135 |
\cs_new_protected:Npn \__cmd_add_type_u:w #1 |
| 136 |
{ |
| 137 |
\__cmd_flush_m_args: |
| 138 |
\__cmd_add_default: |
| 139 |
\__cmd_add_grabber:N u |
| 140 |
\tl_put_right:Nn \l__cmd_signature_tl { {#1} } |
| 141 |
\__cmd_prepare_signature:N |
| 142 |
} |
| 143 |
\cs_new_protected:Npn \__cmd_add_expandable_type_l:w |
| 144 |
{ \__cmd_add_expandable_type_u:w ## } |
| 145 |
\cs_new_protected:Npn \__cmd_add_expandable_type_u:w #1 |
| 146 |
{ |
| 147 |
\__cmd_add_default: |
| 148 |
\bool_if:NTF \l__cmd_long_bool |
| 149 |
{ \cs_set:cpn } |
| 150 |
{ \cs_set_nopar:cpn } |
| 151 |
{ \l__cmd_expandable_aux_name_tl } ##1 \q__cmd ##2 ##3 ##4 #1 |
| 152 |
{ ##1 {##4} \q__cmd ##2 ##3 } |
| 153 |
\__cmd_add_expandable_grabber:nn { u } |
| 154 |
{ \exp_not:c { \l__cmd_expandable_aux_name_tl } } |
| 155 |
\__cmd_prepare_signature:N |
| 156 |
} |
| 157 |
\cs_new_protected:Npn \__cmd_copy_grabber_u:w #1 #2 #3 |
| 158 |
{ \__cmd_copy_grabber_D:w {#1} {#2} {#3} { } { } } |
| 159 |
\tl_const:Nn \c__cmd_show_type_u_tl { 3 } |
| 160 |
\tl_const:Nn \c__cmd_show_type_G_tl { 3 } |
| 161 |
\cs_new_protected:Npn \__cmd_grab_G:w #1 \__cmd_run_code: |
| 162 |
{ |
| 163 |
\__cmd_grab_G_aux:nNN {#1} \cs_set_protected_nopar:Npn |
| 164 |
\__cmd_peek_nonspace:NTF |
| 165 |
} |
| 166 |
\cs_new_protected:Npn \__cmd_grab_G_long:w #1 \__cmd_run_code: |
| 167 |
{ |
| 168 |
\__cmd_grab_G_aux:nNN {#1} \cs_set_protected:Npn |
| 169 |
\__cmd_peek_nonspace:NTF |
| 170 |
} |
| 171 |
\cs_new_protected:Npn \__cmd_grab_G_obey_spaces:w #1 \__cmd_run_code: |
| 172 |
{ |
| 173 |
\__cmd_grab_G_aux:nNN {#1} \cs_set_protected_nopar:Npn |
| 174 |
\peek_meaning:NTF |
| 175 |
} |
| 176 |
\cs_new_protected:Npn \__cmd_grab_G_long_obey_spaces:w #1 \__cmd_run_code: |
| 177 |
{ |
| 178 |
\__cmd_grab_G_aux:nNN {#1} \cs_set_protected:Npn |
| 179 |
\peek_meaning:NTF |
| 180 |
} |
| 181 |
\cs_new_protected:Npn \__cmd_grab_G_aux:nNN #1#2#3 |
| 182 |
{ |
| 183 |
\tl_set:Nn \l__cmd_signature_tl {#1} |
| 184 |
\exp_after:wN #2 \l__cmd_fn_tl ##1 |
| 185 |
{ \__cmd_add_arg:n {##1} } |
| 186 |
#3 \c_group_begin_token |
| 187 |
{ \l__cmd_fn_tl } |
| 188 |
{ \__cmd_add_arg:o \c_novalue_tl } |
| 189 |
} |
| 190 |
\cs_new_protected:Npn \__cmd_grab_l:w #1 \__cmd_run_code: |
| 191 |
{ \__cmd_grab_l_aux:nN {#1} \cs_set_protected_nopar:Npn } |
| 192 |
\cs_new_protected:Npn \__cmd_grab_l_long:w #1 \__cmd_run_code: |
| 193 |
{ \__cmd_grab_l_aux:nN {#1} \cs_set_protected:Npn } |
| 194 |
\cs_new_protected:Npn \__cmd_grab_l_aux:nN #1#2 |
| 195 |
{ |
| 196 |
\tl_set:Nn \l__cmd_signature_tl {#1} |
| 197 |
\exp_after:wN #2 \l__cmd_fn_tl ##1## |
| 198 |
{ \__cmd_add_arg:n {##1} } |
| 199 |
\l__cmd_fn_tl |
| 200 |
} |
| 201 |
\cs_new_protected:Npn \__cmd_grab_u:w #1#2 \__cmd_run_code: |
| 202 |
{ \__cmd_grab_u_aux:nnN {#1} {#2} \cs_set_protected_nopar:Npn } |
| 203 |
\cs_new_protected:Npn \__cmd_grab_u_long:w #1#2 \__cmd_run_code: |
| 204 |
{ \__cmd_grab_u_aux:nnN {#1} {#2} \cs_set_protected:Npn } |
| 205 |
\cs_new_protected:Npn \__cmd_grab_u_aux:nnN #1#2#3 |
| 206 |
{ |
| 207 |
\tl_set:Nn \l__cmd_signature_tl {#2} |
| 208 |
\exp_after:wN #3 \l__cmd_fn_tl ##1 #1 |
| 209 |
{ \__cmd_add_arg:n {##1} } |
| 210 |
\l__cmd_fn_tl |
| 211 |
} |
| 212 |
\cs_new_eq:NN \__cmd_expandable_grab_u:w \prg_do_nothing: |
| 213 |
\cs_gset_protected:Npn \__cmd_get_arg_spec_error:N #1 |
| 214 |
{ |
| 215 |
\bool_set_false:N \l__cmd_environment_bool |
| 216 |
\tl_set:Nn \l__cmd_fn_tl {#1} |
| 217 |
\__cmd_get_arg_spec_error_aux:n { \cs_if_exist:NTF #1 } |
| 218 |
} |
| 219 |
\cs_gset_protected:Npn \__cmd_get_arg_spec_error:n #1 |
| 220 |
{ |
| 221 |
\bool_set_true:N \l__cmd_environment_bool |
| 222 |
\str_set:Ne \l__cmd_environment_str {#1} |
| 223 |
\__cmd_get_arg_spec_error_aux:n |
| 224 |
{ \cs_if_exist:cTF { \l__cmd_environment_str } } |
| 225 |
} |
| 226 |
\cs_gset_protected:Npn \__cmd_get_arg_spec_error_aux:n #1 |
| 227 |
{ |
| 228 |
#1 |
| 229 |
{ |
| 230 |
\msg_error:nne { cmd } { non-xparse } |
| 231 |
{ \__cmd_environment_or_command: } |
| 232 |
} |
| 233 |
{ |
| 234 |
\msg_error:nne { cmd } { unknown } |
| 235 |
{ \__cmd_environment_or_command: } |
| 236 |
} |
| 237 |
} |
| 238 |
\cs_gset_protected:Npn \__cmd_get_arg_spec:NTF #1#2#3 |
| 239 |
{ |
| 240 |
\__kernel_cmd_if_xparse:NTF #1 |
| 241 |
{ |
| 242 |
\tl_set:Ne \ArgumentSpecification |
| 243 |
{ |
| 244 |
\exp_args:No \tl_if_head_eq_meaning:nNTF {#1} \__cmd_start_optimized: |
| 245 |
{ |
| 246 |
\prg_replicate:nn |
| 247 |
{ |
| 248 |
\str_count:e |
| 249 |
{ |
| 250 |
\exp_args:Nc \cs_parameter_spec:N |
| 251 |
{ \cs_to_str:N #1 \c_space_tl code } |
| 252 |
} / 2 |
| 253 |
} |
| 254 |
{ |
| 255 |
\exp_args:Nc \token_if_protected_long_macro:NTF |
| 256 |
{ \cs_to_str:N #1 \c_space_tl code } |
| 257 |
{ + } |
| 258 |
{ |
| 259 |
\exp_args:Nc \token_if_long_macro:NT |
| 260 |
{ \cs_to_str:N #1 \c_space_tl code } |
| 261 |
{ + } |
| 262 |
} |
| 263 |
m |
| 264 |
} |
| 265 |
} |
| 266 |
{ \tl_item:Nn #1 { 2 } } |
| 267 |
} |
| 268 |
#2 |
| 269 |
} |
| 270 |
{#3} |
| 271 |
} |
| 272 |
\tl_clear_new:N \ArgumentSpecification |
| 273 |
\cs_gset_protected:Npn \__cmd_get_arg_spec:N #1 |
| 274 |
{ |
| 275 |
\__cmd_get_arg_spec:NTF #1 { } |
| 276 |
{ \__cmd_get_arg_spec_error:N #1 } |
| 277 |
} |
| 278 |
\cs_gset_protected:Npn \__cmd_get_arg_spec:n #1 |
| 279 |
{ |
| 280 |
\exp_args:Nc \__cmd_get_arg_spec:NTF |
| 281 |
{ environment~ \tl_to_str:n {#1} } |
| 282 |
{ } |
| 283 |
{ \__cmd_get_arg_spec_error:n {#1} } |
| 284 |
} |
| 285 |
\cs_gset_protected:Npn \__cmd_show_arg_spec:N #1 |
| 286 |
{ |
| 287 |
\__cmd_get_arg_spec:NTF #1 |
| 288 |
{ \tl_show:N \ArgumentSpecification } |
| 289 |
{ \__cmd_get_arg_spec_error:N #1 } |
| 290 |
} |
| 291 |
\cs_gset_protected:Npn \__cmd_show_arg_spec:n #1 |
| 292 |
{ |
| 293 |
\exp_args:Nc \__cmd_get_arg_spec:NTF |
| 294 |
{ environment~ \tl_to_str:n {#1} } |
| 295 |
{ \tl_show:N \ArgumentSpecification } |
| 296 |
{ \__cmd_get_arg_spec_error:n {#1} } |
| 297 |
} |
| 298 |
\cs_gset_protected:Npn \GetDocumentCommandArgSpec #1 |
| 299 |
{ |
| 300 |
\__cmd_check_definable:nNT {#1} \GetDocumentCommandArgSpec |
| 301 |
{ \__cmd_get_arg_spec:N #1 } |
| 302 |
} |
| 303 |
\cs_gset_eq:NN \GetDocumentEnvironmentArgSpec \__cmd_get_arg_spec:n |
| 304 |
\cs_gset_protected:Npn \ShowDocumentCommandArgSpec #1 |
| 305 |
{ |
| 306 |
\__cmd_check_definable:nNT {#1} \ShowDocumentCommandArgSpec |
| 307 |
{ \__cmd_show_arg_spec:N #1 } |
| 308 |
} |
| 309 |
\cs_gset_eq:NN \ShowDocumentEnvironmentArgSpec \__cmd_show_arg_spec:n |
| 310 |
\msg_set:nnnn { cmd } { non-xparse } |
| 311 |
{ \str_uppercase:n #1~not~defined~using~xparse. } |
| 312 |
{ |
| 313 |
You~have~asked~for~the~argument~specification~for~the~#1,~ |
| 314 |
but~this~was~not~defined~using~xparse. |
| 315 |
} |
| 316 |
\msg_set:nnnn { cmd } { unknown } |
| 317 |
{ Unknown~document~#1. } |
| 318 |
{ |
| 319 |
You~have~asked~for~the~argument~specification~for~the~#1,~ |
| 320 |
but~it~is~not~defined. |
| 321 |
} |
| 322 |
%% |
| 323 |
%% |
| 324 |
%% End of file `xparse.sty'. |