Debian Codegraph @

texmf-dist/tex/latex/l3packages/xparse/xparse-2018-04-12.sty

raw
1 %%
2 %% This is file `xparse-2018-04-12.sty', generated from
3 %% xparse.dtx (with options: `core,package', on 2021-01-20)
4 %% then adapted and frozen for compatibility. Development of
5 %% xparse.dtx will continue in the LaTeX2e kernel as ltcmd.dtx.
6 %%
7 %% Copyright (C) 2009-2021 The LaTeX Project
8 %%
9 %% It may be distributed and/or modified under the conditions of
10 %% the LaTeX Project Public License (LPPL), either version 1.3c of
11 %% this license or (at your option) any later version. The latest
12 %% version of this license is in the file:
13 %%
14 %% http://www.latex-project.org/lppl.txt
15 %%
16 %% This file is part of the "l3packages bundle" (The Work in LPPL)
17 %% and all files in that bundle must be distributed together.
18 %%
19 %% File: xparse.dtx
20 \RequirePackage{expl3}[2018-04-12]
21 \@ifpackagelater{expl3}{2018-04-12}
22 {}
23 {%
24 \PackageError{xparse}{Support package l3kernel too old}
25 {%
26 Please install an up to date version of l3kernel\MessageBreak
27 using your TeX package manager or from CTAN.\MessageBreak
28 \MessageBreak
29 Loading xparse will abort!%
30 }%
31 \endinput
32 }
33 % \ProvidesExplPackage{xparse}{2021-01-09}{}
34 % {L3 Experimental document command parser}
35 \expandafter\protected@xdef\csname [email protected]\endcsname
36 {2021-01-09 L3 Experimental document command parser}
37 \ExplSyntaxOn
38 \clist_new:N \l__xparse_options_clist
39 \DeclareOption* { \clist_put_right:NV \l__xparse_options_clist \CurrentOption }
40 \ProcessOptions \relax
41 \keys_define:nn { xparse }
42 {
43 log-declarations .bool_set:N = \l__xparse_log_bool ,
44 log-declarations .initial:n = false
45 }
46 \keys_set:nV { xparse } \l__xparse_options_clist
47 \bool_if:NF \l__xparse_log_bool
48 { \msg_redirect_module:nnn { LaTeX / xparse } { info } { none } }
49 \tl_new:N \l__xparse_arg_spec_tl
50 \tl_new:N \l__xparse_args_tl
51 \tl_new:N \l__xparse_args_i_tl
52 \tl_new:N \l__xparse_args_ii_tl
53 \int_new:N \l__xparse_current_arg_int
54 \bool_new:N \l__xparse_defaults_bool
55 \tl_new:N \l__xparse_defaults_tl
56 \bool_new:N \l__xparse_environment_bool
57 \str_new:N \l__xparse_environment_str
58 \bool_new:N \l__xparse_expandable_bool
59 \tl_new:N \l__xparse_expandable_aux_name_tl
60 \tl_set:Nn \l__xparse_expandable_aux_name_tl
61 {
62 \l__xparse_function_tl \c_space_tl
63 ( arg~ \int_use:N \l__xparse_current_arg_int )
64 }
65 \int_new:N \g__xparse_grabber_int
66 \tl_new:N \l__xparse_fn_tl
67 \tl_new:N \l__xparse_fn_code_tl
68 \tl_new:N \l__xparse_function_tl
69 \bool_new:N \l__xparse_grab_expandably_bool
70 \bool_new:N \l__xparse_obey_spaces_bool
71 \tl_new:N \l__xparse_last_delimiters_tl
72 \bool_new:N \l__xparse_long_bool
73 \int_new:N \l__xparse_m_args_int
74 \bool_new:N \l__xparse_prefixed_bool
75 \tl_new:N \l__xparse_process_all_tl
76 \tl_new:N \l__xparse_process_one_tl
77 \bool_new:N \l__xparse_process_some_bool
78 \tl_new:N \l__xparse_saved_args_tl
79 \tl_new:N \l__xparse_signature_tl
80 \bool_new:N \l__xparse_some_obey_spaces_bool
81 \bool_new:N \l__xparse_some_long_bool
82 \bool_new:N \l__xparse_some_short_bool
83 \prop_new:N \l__xparse_tmp_prop
84 \tl_new:N \l__xparse_tmpa_tl
85 \tl_new:N \l__xparse_tmpb_tl
86 \cs_new_eq:NN \__xparse_tmp:w ?
87 \cs_new_protected:Npn \__xparse_declare_cmd:Nnn
88 {
89 \bool_set_false:N \l__xparse_expandable_bool
90 \__xparse_declare_cmd_aux:Nnn
91 }
92 \cs_new_protected:Npn \__xparse_declare_expandable_cmd:Nnn
93 {
94 \bool_set_true:N \l__xparse_expandable_bool
95 \__xparse_declare_cmd_aux:Nnn
96 }
97 \cs_new_protected:Npn \__xparse_declare_cmd_aux:Nnn #1#2#3
98 {
99 \cs_if_exist:NTF #1
100 {
101 \__kernel_msg_info:nnxx { xparse } { redefine-command }
102 { \token_to_str:N #1 } { \tl_to_str:n {#2} }
103 }
104 {
105 \bool_lazy_or:nnT
106 { \cs_if_exist_p:c { \cs_to_str:N #1 ~ code } }
107 { \cs_if_exist_p:c { \cs_to_str:N #1 ~ defaults } }
108 {
109 \__kernel_msg_warning:nnx { xparse } { unsupported-let }
110 { \token_to_str:N #1 }
111 }
112 \__kernel_msg_info:nnxx { xparse } { define-command }
113 { \token_to_str:N #1 } { \tl_to_str:n {#2} }
114 }
115 \bool_set_false:N \l__xparse_environment_bool
116 \__xparse_declare_cmd_internal:Nnnn #1 {#2} {#3} { }
117 }
118 \cs_new_protected:Npn \__xparse_declare_cmd_internal:Nnnn #1#2#3#4
119 {
120 \tl_set:Nx \l__xparse_function_tl { \cs_to_str:N #1 }
121 \tl_set:Nx \l__xparse_fn_tl
122 { \exp_not:c { \l__xparse_function_tl \c_space_tl } }
123 \__xparse_normalize_arg_spec:n {#2}
124 \exp_args:No \__xparse_prepare_signature:n \l__xparse_arg_spec_tl
125 \__xparse_declare_cmd_code:Nnn #1 {#2} {#3}
126 #4
127 \__xparse_break_point:n {#2}
128 }
129 \cs_generate_variant:Nn \__xparse_declare_cmd_internal:Nnnn { cnx }
130 \cs_new_eq:NN \__xparse_break_point:n \use_none:n
131 \cs_new_protected:Npn \__xparse_declare_cmd_code:Nnn
132 {
133 \bool_if:NTF \l__xparse_grab_expandably_bool
134 { \__xparse_declare_cmd_code_expandable:Nnn }
135 { \__xparse_declare_cmd_code_aux:Nnn }
136 }
137 \cs_new_protected:Npn \__xparse_declare_cmd_code_aux:Nnn #1#2#3
138 {
139 \cs_generate_from_arg_count:cNnn
140 { \l__xparse_function_tl \c_space_tl code }
141 \cs_set_protected:Npn \l__xparse_current_arg_int {#3}
142 \cs_set_protected_nopar:Npx #1
143 {
144 \bool_if:NTF \l__xparse_environment_bool
145 {
146 \__xparse_start_env:nnnnn { \exp_not:n {#2} }
147 { \l__xparse_environment_str }
148 }
149 {
150 \__xparse_start:nNNnnn { \exp_not:n {#2} }
151 \exp_not:c { \l__xparse_function_tl \c_space_tl }
152 \exp_not:c { \l__xparse_function_tl \c_space_tl code }
153 }
154 { \exp_not:o \l__xparse_signature_tl }
155 {
156 \bool_if:NT \l__xparse_defaults_bool
157 { \exp_not:o \l__xparse_defaults_tl }
158 }
159 {
160 \bool_if:NT \l__xparse_process_some_bool
161 { \exp_not:o \l__xparse_process_all_tl }
162 }
163 }
164 }
165 \cs_new_protected:Npn \__xparse_declare_cmd_code_expandable:Nnn #1#2#3
166 {
167 \exp_args:Ncc \cs_generate_from_arg_count:NNnn
168 { \l__xparse_function_tl \c_space_tl code }
169 { cs_set \bool_if:NF \l__xparse_expandable_bool { _protected } :Npn }
170 \l__xparse_current_arg_int {#3}
171 \bool_if:NT \l__xparse_defaults_bool
172 {
173 \use:x
174 {
175 \cs_generate_from_arg_count:cNnn
176 { \l__xparse_function_tl \c_space_tl defaults }
177 \cs_set:Npn \l__xparse_current_arg_int
178 { \exp_not:o \l__xparse_defaults_tl }
179 }
180 }
181 \bool_if:NTF \l__xparse_expandable_bool
182 { \cs_set_nopar:Npx } { \cs_set_protected_nopar:Npx } #1
183 {
184 \exp_not:N \__xparse_start_expandable:nNNNNn
185 { \exp_not:n {#2} }
186 \exp_not:c { \l__xparse_function_tl \c_space_tl }
187 \exp_not:c
188 {
189 \l__xparse_function_tl \c_space_tl
190 \bool_if:NT \l__xparse_some_short_bool
191 { \bool_if:NT \l__xparse_some_long_bool { \c_space_tl } }
192 }
193 \exp_not:c { \l__xparse_function_tl \c_space_tl code }
194 \bool_if:NTF \l__xparse_defaults_bool
195 { \exp_not:c { \l__xparse_function_tl \c_space_tl defaults } }
196 { ? }
197 { \exp_not:o \l__xparse_signature_tl }
198 }
199 \bool_if:NTF \l__xparse_some_long_bool
200 {
201 \bool_if:NT \l__xparse_some_short_bool
202 {
203 \cs_set_nopar:cpx { \l__xparse_function_tl \c_space_tl \c_space_tl }
204 ##1##2 { ##1 {##2} }
205 }
206 \cs_set:cpx
207 }
208 { \cs_set_nopar:cpx }
209 { \l__xparse_function_tl \c_space_tl } ##1##2 { ##1 {##2} }
210 }
211 \cs_new_protected:Npn \__xparse_declare_env:nnnn #1#2
212 {
213 \str_set:Nx \l__xparse_environment_str {#1}
214 \str_set:Nx \l__xparse_environment_str
215 { \tl_trim_spaces:o { \l__xparse_environment_str } }
216 \cs_if_exist:cTF { \l__xparse_environment_str }
217 {
218 \__kernel_msg_info:nnxx { xparse } { redefine-environment }
219 { \l__xparse_environment_str } { \tl_to_str:n {#2} }
220 }
221 {
222 \__kernel_msg_info:nnxx { xparse } { define-environment }
223 { \l__xparse_environment_str } { \tl_to_str:n {#2} }
224 }
225 \bool_set_false:N \l__xparse_expandable_bool
226 \bool_set_true:N \l__xparse_environment_bool
227 \exp_args:NV \__xparse_declare_env_internal:nnnn
228 \l__xparse_environment_str {#2}
229 }
230 \cs_new_protected:Npn \__xparse_declare_env_internal:nnnn #1#2#3#4
231 {
232 \__xparse_declare_cmd_internal:cnxn { environment~ #1 } {#2}
233 {
234 \cs_set_nopar:Npx \exp_not:c { environment~ #1 ~end~aux }
235 {
236 \exp_not:N \exp_not:N \exp_not:c { environment~ #1~end~aux~ }
237 \exp_not:n { \exp_not:o \l__xparse_args_tl }
238 }
239 \exp_not:n {#3}
240 }
241 {
242 \cs_set_nopar:cpx { environment~ #1 ~end }
243 { \exp_not:c { environment~ #1 ~end~aux } }
244 \cs_generate_from_arg_count:cNnn
245 { environment~ #1 ~end~aux~ } \cs_set:Npn
246 \l__xparse_current_arg_int {#4}
247 \cs_set_eq:cc {#1} { environment~ #1 }
248 \cs_set_eq:cc { end #1 } { environment~ #1 ~end }
249 }
250 }
251 \cs_new_protected:Npn \__xparse_start_env:nnnnn #1#2
252 {
253 \cs_if_exist_use:N \conditionally@traceoff
254 \group_align_safe_begin:
255 \str_set:Nn \l__xparse_environment_str {#2}
256 \bool_set_true:N \l__xparse_environment_bool
257 \__xparse_start_aux:ccnnnn
258 { environment~ \l__xparse_environment_str \c_space_tl }
259 { environment~ \l__xparse_environment_str \c_space_tl code }
260 {#1}
261 }
262 \cs_new_protected:Npx \__xparse_start:nNNnnn #1#2#3
263 {
264 \exp_not:c { xparse~function~is~not~expandable }
265 \exp_not:n { \cs_if_exist_use:N \conditionally@traceoff }
266 \exp_not:N \group_align_safe_begin:
267 \exp_not:n { \bool_set_false:N \l__xparse_environment_bool }
268 \exp_not:N \__xparse_start_aux:NNnnnn
269 #2 #3 {#1}
270 }
271 \cs_new_protected:Npn \__xparse_start_aux:NNnnnn #1#2#3#4#5#6
272 {
273 \tl_clear:N \l__xparse_args_tl
274 \tl_set:Nn \l__xparse_fn_tl {#1}
275 \tl_set:Nn \l__xparse_fn_code_tl {#2}
276 \tl_set:Nn \l__xparse_defaults_tl {#5}
277 \tl_set:Nn \l__xparse_process_all_tl {#6}
278 #4 \__xparse_run_code:
279 }
280 \cs_generate_variant:Nn \__xparse_start_aux:NNnnnn { cc }
281 \cs_new_protected:Npn \__xparse_run_code:
282 {
283 \tl_if_empty:NF \l__xparse_defaults_tl { \__xparse_defaults: }
284 \tl_if_empty:NF \l__xparse_process_all_tl { \__xparse_args_process: }
285 \group_align_safe_end:
286 \cs_if_exist_use:N \conditionally@traceon
287 \exp_after:wN \l__xparse_fn_code_tl \l__xparse_args_tl
288 }
289 \cs_new_protected:Npn \__xparse_defaults:
290 {
291 \__xparse_defaults_def:
292 \tl_set_eq:NN \l__xparse_args_i_tl \l__xparse_args_tl
293 \__xparse_defaults_aux: \__xparse_defaults_aux: \__xparse_defaults_aux:
294 \__xparse_defaults_aux: \__xparse_defaults_aux: \__xparse_defaults_aux:
295 \__xparse_defaults_aux: \__xparse_defaults_aux: \__xparse_defaults_aux:
296 \__xparse_defaults_error:w
297 \q_recursion_stop
298 \tl_set_eq:NN \l__xparse_args_tl \l__xparse_args_i_tl
299 }
300 \cs_new_protected:Npn \__xparse_defaults_aux:
301 {
302 \tl_set:Nx \l__xparse_args_ii_tl
303 { \exp_after:wN \__xparse_tmp:w \l__xparse_args_i_tl }
304 \tl_if_eq:NNT \l__xparse_args_ii_tl \l__xparse_args_i_tl
305 { \use_none_delimit_by_q_recursion_stop:w }
306 \tl_set_eq:NN \l__xparse_args_i_tl \l__xparse_args_ii_tl
307 }
308 \cs_new_protected:Npn \__xparse_defaults_error:w \q_recursion_stop
309 {
310 \__kernel_msg_error:nnx { xparse } { loop-in-defaults }
311 { \__xparse_environment_or_command: }
312 }
313 \cs_new_protected:Npn \__xparse_defaults_def:
314 {
315 \tl_clear:N \l__xparse_tmpa_tl
316 \int_zero:N \l__xparse_current_arg_int
317 \__xparse_tl_mapthread_function:NNN \l__xparse_args_tl \l__xparse_defaults_tl
318 \__xparse_defaults_def:nn
319 \cs_generate_from_arg_count:NNVo \__xparse_tmp:w \cs_set:Npn
320 \l__xparse_current_arg_int \l__xparse_tmpa_tl
321 }
322 \cs_generate_variant:Nn \cs_generate_from_arg_count:NNnn { NNVo }
323 \cs_new_protected:Npn \__xparse_defaults_def:nn
324 {
325 \int_incr:N \l__xparse_current_arg_int
326 \exp_args:NV \__xparse_defaults_def:nnn \l__xparse_current_arg_int
327 }
328 \cs_new_protected:Npn \__xparse_defaults_def:nnn #1#2#3
329 {
330 \tl_put_right:Nx \l__xparse_tmpa_tl
331 {
332 {
333 \exp_not:N \exp_not:n
334 {
335 \tl_if_novalue:nTF {#2}
336 { \exp_not:o {#3} }
337 { \exp_not:n { ## #1 } }
338 }
339 }
340 }
341 }
342 \cs_new_protected:Npn \__xparse_args_process:
343 {
344 \tl_clear:N \l__xparse_args_ii_tl
345 \__xparse_tl_mapthread_function:NNN
346 \l__xparse_args_tl
347 \l__xparse_process_all_tl
348 \__xparse_args_process_loop:nn
349 \tl_set_eq:NN \l__xparse_args_tl \l__xparse_args_ii_tl
350 }
351 \cs_new_protected:Npn \__xparse_args_process_loop:nn #1#2
352 {
353 \tl_set:Nn \ProcessedArgument {#1}
354 \tl_if_novalue:nF {#1}
355 { \tl_map_function:nN {#2} \__xparse_args_process_aux:n }
356 \tl_put_right:No \l__xparse_args_ii_tl
357 { \exp_after:wN { \ProcessedArgument } }
358 }
359 \cs_new_protected:Npn \__xparse_args_process_aux:n #1
360 {
361 \cs_generate_from_arg_count:NNnn \__xparse_tmp:w \cs_set:Npn
362 { \tl_count:N \l__xparse_args_tl } {#1}
363 \exp_args:NNNo \exp_after:wN \__xparse_tmp:w \l__xparse_args_tl
364 { \ProcessedArgument }
365 }
366 \cs_new:Npn \__xparse_start_expandable:nNNNNn #1#2#3#4#5#6
367 {
368 \group_align_safe_begin:
369 #6 \__xparse_end_expandable:NNw #5 #4 \q__xparse #2#3
370 }
371 \cs_new:Npn \__xparse_end_expandable:NNw #1#2
372 { \__xparse_end_expandable_aux:w #1#2 \prg_do_nothing: }
373 \cs_new:Npn \__xparse_end_expandable_aux:w #1#2#3 \q__xparse
374 { \exp_args:No \__xparse_end_expandable_aux:nNNNN {#3} #1 #2 }
375 \cs_new:Npn \__xparse_end_expandable_aux:nNNNN #1#2#3#4#5
376 {
377 \token_if_eq_charcode:NNT ? #2 { \exp_after:wN \use_iv:nnnn }
378 \__xparse_end_expandable_defaults:nnnNNn {#1} { } {#1} #2#3
379 { } { } { } { } { } { } { } { } { } { }
380 {
381 \__kernel_msg_expandable_error:nnf
382 { xparse } { loop-in-defaults }
383 { \exp_args:Nf \tl_trim_spaces:n { \token_to_str:N #4 } }
384 \use_iv:nnnn
385 }
386 \q_stop
387 }
388 \cs_new:Npn \__xparse_end_expandable_defaults:nnnNNn #1#2#3#4#5#6
389 {
390 #6
391 \str_if_eq:nnTF {#1} {#2}
392 { \use_i_delimit_by_q_stop:nw { \group_align_safe_end: #5 #1 } }
393 {
394 \exp_args:No \__xparse_tl_mapthread_function:nnN
395 { #4 #1 } {#3}
396 \__xparse_end_expandable_defaults:nnw
397 \__xparse_end_expandable_defaults:nnnNNn { } {#1} {#3} #4 #5
398 }
399 }
400 \cs_new:Npn \__xparse_end_expandable_defaults:nnw #1#2
401 {
402 \tl_if_novalue:nTF {#2}
403 { \exp_args:No \__xparse_end_expandable_defaults:nw {#1} }
404 { \__xparse_end_expandable_defaults:nw {#2} }
405 }
406 \cs_new:Npn \__xparse_end_expandable_defaults:nw
407 #1#2 \__xparse_end_expandable_defaults:nnnNNn #3
408 { #2 \__xparse_end_expandable_defaults:nnnNNn { #3 {#1} } }
409 \cs_new_protected:Npn \__xparse_normalize_arg_spec:n #1
410 {
411 \int_zero:N \l__xparse_current_arg_int
412 \tl_clear:N \l__xparse_last_delimiters_tl
413 \tl_clear:N \l__xparse_arg_spec_tl
414 \bool_set_true:N \l__xparse_grab_expandably_bool
415 \bool_set_false:N \l__xparse_obey_spaces_bool
416 \bool_set_false:N \l__xparse_long_bool
417 \bool_set_false:N \l__xparse_some_obey_spaces_bool
418 \bool_set_false:N \l__xparse_some_long_bool
419 \bool_set_false:N \l__xparse_some_short_bool
420 \__xparse_normalize_arg_spec_loop:n #1
421 \q_recursion_tail \q_recursion_tail \q_recursion_tail \q_recursion_stop
422 \int_compare:nNnT \l__xparse_current_arg_int > 9
423 {
424 \__kernel_msg_error:nnxx { xparse } { too-many-arguments }
425 { \__xparse_environment_or_command: } { \tl_to_str:n {#1} }
426 \__xparse_bad_def:wn
427 }
428 \bool_if:NT \l__xparse_expandable_bool
429 {
430 \tl_if_empty:NF \l__xparse_last_delimiters_tl
431 {
432 \__kernel_msg_error:nnxx { xparse } { expandable-ending-optional }
433 { \iow_char:N \\ \l__xparse_function_tl } { \tl_to_str:n {#1} }
434 \__xparse_bad_def:wn
435 }
436 }
437 \bool_if:NT \l__xparse_expandable_bool
438 { \bool_set_true:N \l__xparse_grab_expandably_bool }
439 \bool_if:NT \l__xparse_environment_bool
440 { \bool_set_false:N \l__xparse_grab_expandably_bool }
441 }
442 \cs_new_protected:Npn \__xparse_normalize_arg_spec_loop:n #1
443 {
444 \quark_if_recursion_tail_stop:n {#1}
445 \int_incr:N \l__xparse_current_arg_int
446 \cs_if_exist_use:cF { __xparse_normalize_type_ \tl_to_str:n {#1} :w }
447 {
448 \__kernel_msg_error:nnxx { xparse } { unknown-argument-type }
449 { \__xparse_environment_or_command: } { \tl_to_str:n {#1} }
450 \__xparse_bad_def:wn
451 }
452 }
453 \cs_set_protected:Npn \__xparse_tmp:w #1
454 {
455 \cs_new_protected:Npn \__xparse_normalize_type_d:w ##1##2
456 {
457 \quark_if_recursion_tail_stop_do:nn {##2} { \__xparse_bad_arg_spec:wn }
458 \__xparse_normalize_type_D:w {##1} {##2} {#1}
459 }
460 \cs_new_protected:Npn \__xparse_normalize_type_e:w ##1
461 {
462 \quark_if_recursion_tail_stop_do:nn {##1} { \__xparse_bad_arg_spec:wn }
463 \__xparse_normalize_type_E:w {##1} { }
464 }
465 \cs_new_protected:Npn \__xparse_normalize_type_o:w
466 { \__xparse_normalize_type_D:w [ ] {#1} }
467 \cs_new_protected:Npn \__xparse_normalize_type_O:w
468 { \__xparse_normalize_type_D:w [ ] }
469 \cs_new_protected:Npn \__xparse_normalize_type_r:w ##1##2
470 {
471 \quark_if_recursion_tail_stop_do:nn {##2} { \__xparse_bad_arg_spec:wn }
472 \__xparse_normalize_type_R:w {##1} {##2} {#1}
473 }
474 \cs_new_protected:Npn \__xparse_normalize_type_s:w
475 { \__xparse_normalize_type_t:w * }
476 }
477 \exp_args:No \__xparse_tmp:w { \c_novalue_tl }
478 \cs_new_protected:Npx \__xparse_normalize_type_g:w
479 { \exp_not:N \__xparse_normalize_type_G:w { \exp_not:V \c_novalue_tl } }
480 \cs_new_protected:cpn { __xparse_normalize_type_>:w } #1#2
481 {
482 \quark_if_recursion_tail_stop_do:nn {#2} { \__xparse_bad_arg_spec:wn }
483 \bool_if:NT \l__xparse_expandable_bool
484 {
485 \__kernel_msg_error:nnxx { xparse } { processor-in-expandable }
486 { \iow_char:N \\ \l__xparse_function_tl } { \tl_to_str:n {#1} }
487 \__xparse_bad_def:wn
488 }
489 \tl_put_right:Nx \l__xparse_arg_spec_tl { > { \tl_trim_spaces:n {#1} } }
490 \int_decr:N \l__xparse_current_arg_int
491 \bool_set_false:N \l__xparse_grab_expandably_bool
492 \__xparse_normalize_arg_spec_loop:n {#2}
493 }
494 \cs_new_protected:cpn { __xparse_normalize_type_+:w } #1
495 {
496 \quark_if_recursion_tail_stop_do:nn {#1} { \__xparse_bad_arg_spec:wn }
497 \bool_if:NT \l__xparse_long_bool
498 {
499 \__kernel_msg_error:nnxx { xparse } { two-markers }
500 { \__xparse_environment_or_command: } { + }
501 \__xparse_bad_def:wn
502 }
503 \bool_set_true:N \l__xparse_long_bool
504 \int_decr:N \l__xparse_current_arg_int
505 \__xparse_normalize_arg_spec_loop:n {#1}
506 }
507 \cs_new_protected:cpn { __xparse_normalize_type_!:w } #1
508 {
509 \quark_if_recursion_tail_stop_do:nn {#1} { \__xparse_bad_arg_spec:wn }
510 \bool_if:NT \l__xparse_obey_spaces_bool
511 {
512 \__kernel_msg_error:nnxx { xparse } { two-markers }
513 { \__xparse_environment_or_command: } { ! }
514 \__xparse_bad_def:wn
515 }
516 \bool_set_true:N \l__xparse_obey_spaces_bool
517 \bool_set_true:N \l__xparse_some_obey_spaces_bool
518 \int_decr:N \l__xparse_current_arg_int
519 \__xparse_normalize_arg_spec_loop:n {#1}
520 }
521 \cs_new_protected:Npn \__xparse_normalize_type_D:w #1#2#3
522 {
523 \quark_if_recursion_tail_stop_do:nn {#3} { \__xparse_bad_arg_spec:wn }
524 \__xparse_single_token_check:n {#1} \__xparse_allowed_token_check:N #1
525 \__xparse_single_token_check:n {#2}
526 \__xparse_add_arg_spec:n { D #1 #2 {#3} }
527 \tl_put_right:Nn \l__xparse_last_delimiters_tl {#1}
528 \bool_set_false:N \l__xparse_grab_expandably_bool
529 \__xparse_normalize_arg_spec_loop:n
530 }
531 \cs_new_protected:Npn \__xparse_normalize_type_E:w #1#2
532 {
533 \quark_if_recursion_tail_stop_do:nn {#2} { \__xparse_bad_arg_spec:wn }
534 \tl_if_blank:nT {#1} { \__xparse_bad_arg_spec:wn }
535 \tl_map_function:nN {#1} \__xparse_single_token_check:n
536 \tl_map_function:nN {#1} \__xparse_allowed_token_check:N
537 \__xparse_normalize_E_unique_check:w #1 \q_nil \q_stop
538 \int_compare:nNnT { \tl_count:n {#2} } > { \tl_count:n {#1} }
539 { \__xparse_bad_arg_spec:wn }
540 \__xparse_add_arg_spec:n { E {#1} {#2} }
541 \tl_put_right:Nn \l__xparse_last_delimiters_tl {#1}
542 \bool_set_false:N \l__xparse_grab_expandably_bool
543 \int_add:Nn \l__xparse_current_arg_int { \tl_count:n {#1} - 1 }
544 \__xparse_normalize_arg_spec_loop:n
545 }
546 \cs_new_protected:Npn \__xparse_normalize_E_unique_check:w #1#2 \q_stop
547 {
548 \quark_if_nil:NF #1
549 {
550 \tl_if_in:nnT {#2} {#1} { \__xparse_bad_arg_spec:wn }
551 \__xparse_normalize_E_unique_check:w #2 \q_stop
552 }
553 }
554 \cs_new_protected:Npn \__xparse_normalize_type_G:w #1
555 {
556 \quark_if_recursion_tail_stop_do:nn {#1} { \__xparse_bad_arg_spec:wn }
557 \__xparse_normalize_check_gv:N G
558 \__xparse_add_arg_spec:n { G {#1} }
559 \tl_put_right:Nn \l__xparse_last_delimiters_tl { { } }
560 \__xparse_normalize_arg_spec_loop:n
561 }
562 \cs_new_protected:Npn \__xparse_normalize_type_t:w #1
563 {
564 \quark_if_recursion_tail_stop_do:Nn #1 { \__xparse_bad_arg_spec:wn }
565 \__xparse_single_token_check:n {#1} \__xparse_allowed_token_check:N #1
566 \tl_put_right:Nx \l__xparse_arg_spec_tl
567 {
568 \bool_if:NT \l__xparse_obey_spaces_bool { ! }
569 t \exp_not:n {#1}
570 }
571 \tl_put_right:Nn \l__xparse_last_delimiters_tl {#1}
572 \bool_set_false:N \l__xparse_grab_expandably_bool
573 \bool_set_false:N \l__xparse_obey_spaces_bool
574 \bool_set_false:N \l__xparse_long_bool
575 \__xparse_normalize_arg_spec_loop:n
576 }
577 \cs_new_protected:Npn \__xparse_normalize_type_l:w
578 {
579 \__xparse_normalize_check_lu:N l
580 \__xparse_add_arg_spec_mandatory:n { l }
581 \__xparse_normalize_arg_spec_loop:n
582 }
583 \cs_new_protected:Npn \__xparse_normalize_type_m:w
584 {
585 \__xparse_delimiter_check:nnn { } { m } { \iow_char:N \{ }
586 \__xparse_add_arg_spec_mandatory:n { m }
587 \__xparse_normalize_arg_spec_loop:n
588 }
589 \cs_new_protected:Npn \__xparse_normalize_type_R:w #1#2#3
590 {
591 \quark_if_recursion_tail_stop_do:nn {#3} { \__xparse_bad_arg_spec:wn }
592 \__xparse_single_token_check:n {#1} \__xparse_allowed_token_check:N #1
593 \__xparse_single_token_check:n {#2}
594 \__xparse_delimiter_check:nnn {#1} { R/r } { \tl_to_str:n {#1} }
595 \bool_set_false:N \l__xparse_grab_expandably_bool
596 \__xparse_add_arg_spec_mandatory:n { R #1 #2 {#3} }
597 \__xparse_normalize_arg_spec_loop:n
598 }
599 \cs_new_protected:Npn \__xparse_normalize_type_u:w #1
600 {
601 \quark_if_recursion_tail_stop_do:nn {#1} { \__xparse_bad_arg_spec:wn }
602 \__xparse_normalize_check_lu:N u
603 \__xparse_add_arg_spec_mandatory:n { u {#1} }
604 \__xparse_normalize_arg_spec_loop:n
605 }
606 \cs_new_protected:Npn \__xparse_normalize_type_v:w
607 {
608 \__xparse_normalize_check_gv:N v
609 \__xparse_add_arg_spec_mandatory:n { v }
610 \__xparse_normalize_arg_spec_loop:n
611 }
612 \cs_new_protected:Npn \__xparse_normalize_type_b:w #1
613 {
614 \bool_if:NF \l__xparse_environment_bool
615 {
616 \__kernel_msg_error:nnxx
617 { xparse } { invalid-command-arg }
618 { \__xparse_environment_or_command: } { b }
619 \__xparse_bad_def:wn
620 }
621 \tl_clear:N \l__xparse_last_delimiters_tl
622 \__xparse_add_arg_spec:n { b }
623 \quark_if_recursion_tail_stop:n {#1}
624 \__kernel_msg_error:nnxx { xparse } { arg-after-body }
625 { \__xparse_environment_or_command: }
626 { \tl_to_str:n {#1} }
627 \__xparse_bad_def:wn
628 }
629 \cs_new_protected:Npn \__xparse_single_token_check:n #1
630 {
631 \tl_trim_spaces_apply:nN {#1} \tl_if_single_token:nF
632 {
633 \__kernel_msg_error:nnxx { xparse } { not-single-token }
634 { \__xparse_environment_or_command: } { \tl_to_str:n {#1} }
635 \__xparse_bad_def:wn
636 }
637 }
638 \cs_new_protected:Npn \__xparse_allowed_token_check:N #1
639 {
640 \token_if_eq_meaning:NNTF #1 \c_group_begin_token
641 { \use:n }
642 {
643 \token_if_eq_meaning:NNTF #1 \c_group_end_token
644 { \use:n }
645 { \use_none:n }
646 }
647 {
648 \__kernel_msg_error:nnxxx
649 { xparse } { forbidden-implicit-group-token }
650 { \__xparse_environment_or_command: } { \tl_to_str:n {#1} }
651 {
652 \token_if_eq_meaning:NNTF #1 \c_group_begin_token
653 { begin } { end }
654 }
655 \__xparse_bad_def:wn
656 }
657 }
658 \cs_new_protected:Npn \__xparse_normalize_check_gv:N #1
659 {
660 \bool_if:NT \l__xparse_expandable_bool
661 {
662 \__kernel_msg_error:nnxx
663 { xparse } { invalid-expandable-argument-type }
664 { \iow_char:N \\ \l__xparse_function_tl } { \tl_to_str:n {#1} }
665 \__xparse_bad_def:wn
666 }
667 \bool_set_false:N \l__xparse_grab_expandably_bool
668 }
669 \cs_new_protected:Npn \__xparse_normalize_check_lu:N #1
670 {
671 \bool_if:NT \l__xparse_expandable_bool
672 {
673 \tl_if_empty:NF \l__xparse_last_delimiters_tl
674 {
675 \__kernel_msg_error:nnxx
676 { xparse } { invalid-after-optional-expandably }
677 { \iow_char:N \\ \l__xparse_function_tl } { \tl_to_str:n {#1} }
678 \__xparse_bad_def:wn
679 }
680 }
681 }
682 \cs_new_protected:Npn \__xparse_delimiter_check:nnn #1#2#3
683 {
684 \tl_map_inline:Nn \l__xparse_last_delimiters_tl
685 {
686 \tl_if_eq:nnT {##1} {#1}
687 {
688 \__kernel_msg_warning:nnxx { xparse } { optional-mandatory }
689 {#2} {#3}
690 }
691 }
692 }
693 \cs_new_protected:Npn \__xparse_bad_arg_spec:wn #1 \__xparse_break_point:n #2
694 {
695 \__kernel_msg_error:nnxx { xparse } { bad-arg-spec }
696 { \__xparse_environment_or_command: } { \tl_to_str:n {#2} }
697 }
698 \cs_new_protected:Npn \__xparse_bad_def:wn #1 \__xparse_break_point:n #2 { }
699 \cs_new_protected:Npn \__xparse_add_arg_spec:n #1
700 {
701 \bool_lazy_and:nnT
702 { ! \l__xparse_long_bool }
703 { \l__xparse_some_long_bool }
704 {
705 \bool_if:NT \l__xparse_expandable_bool
706 {
707 \__kernel_msg_error:nnx { xparse } { inconsistent-long }
708 { \iow_char:N \\ \l__xparse_function_tl }
709 \__xparse_bad_def:wn
710 }
711 \bool_set_false:N \l__xparse_grab_expandably_bool
712 }
713 \bool_if:NTF \l__xparse_long_bool
714 { \bool_set_true:N \l__xparse_some_long_bool }
715 { \bool_set_true:N \l__xparse_some_short_bool }
716 \tl_put_right:Nx \l__xparse_arg_spec_tl
717 {
718 \bool_if:NT \l__xparse_long_bool { + }
719 \bool_if:NT \l__xparse_obey_spaces_bool { ! }
720 \exp_not:n {#1}
721 }
722 \bool_set_false:N \l__xparse_long_bool
723 \bool_set_false:N \l__xparse_obey_spaces_bool
724 }
725 \cs_new_protected:Npn \__xparse_add_arg_spec_mandatory:n #1
726 {
727 \bool_if:NT \l__xparse_some_obey_spaces_bool
728 {
729 \__kernel_msg_error:nnxx { xparse } { non-trailing-obey-spaces }
730 { \__xparse_environment_or_command: } { \tl_to_str:n {#1} }
731 \__xparse_bad_def:wn
732 }
733 \tl_clear:N \l__xparse_last_delimiters_tl
734 \__xparse_add_arg_spec:n {#1}
735 }
736 \cs_new_protected:Npn \__xparse_prepare_signature:n #1
737 {
738 \int_zero:N \l__xparse_current_arg_int
739 \bool_set_false:N \l__xparse_long_bool
740 \bool_set_false:N \l__xparse_obey_spaces_bool
741 \int_zero:N \l__xparse_m_args_int
742 \bool_set_false:N \l__xparse_defaults_bool
743 \tl_clear:N \l__xparse_defaults_tl
744 \tl_clear:N \l__xparse_process_all_tl
745 \tl_clear:N \l__xparse_process_one_tl
746 \bool_set_false:N \l__xparse_process_some_bool
747 \tl_clear:N \l__xparse_signature_tl
748 \__xparse_prepare_signature:N #1 \q_recursion_tail \q_recursion_stop
749 \bool_if:NF \l__xparse_expandable_bool { \__xparse_flush_m_args: }
750 }
751 \cs_new_protected:Npn \__xparse_prepare_signature:N
752 {
753 \bool_set_false:N \l__xparse_prefixed_bool
754 \__xparse_prepare_signature_bypass:N
755 }
756 \cs_new_protected:Npn \__xparse_prepare_signature_bypass:N #1
757 {
758 \quark_if_recursion_tail_stop:N #1
759 \use:c
760 {
761 __xparse_add
762 \bool_if:NT \l__xparse_grab_expandably_bool { _expandable }
763 _type_ \token_to_str:N #1 :w
764 }
765 }
766 \cs_new_protected:cpn { __xparse_add_type_+:w }
767 {
768 \__xparse_flush_m_args:
769 \bool_set_true:N \l__xparse_long_bool
770 \bool_set_true:N \l__xparse_prefixed_bool
771 \__xparse_prepare_signature_bypass:N
772 }
773 \cs_new_protected:cpn { __xparse_add_type_!:w }
774 {
775 \__xparse_flush_m_args:
776 \bool_set_true:N \l__xparse_obey_spaces_bool
777 \bool_set_true:N \l__xparse_prefixed_bool
778 \__xparse_prepare_signature_bypass:N
779 }
780 \cs_new_protected:cpn { __xparse_add_type_>:w } #1
781 {
782 \__xparse_flush_m_args:
783 \bool_set_true:N \l__xparse_prefixed_bool
784 \bool_set_true:N \l__xparse_process_some_bool
785 \tl_put_left:Nn \l__xparse_process_one_tl { {#1} }
786 \__xparse_prepare_signature_bypass:N
787 }
788 \cs_new_protected:Npn \__xparse_add_type_b:w
789 {
790 \__xparse_flush_m_args:
791 \__xparse_add_default:
792 \__xparse_add_grabber:N b
793 \__xparse_prepare_signature:N
794 }
795 \cs_new_protected:Npn \__xparse_add_type_D:w #1#2#3
796 {
797 \__xparse_flush_m_args:
798 \__xparse_add_default:n {#3}
799 \__xparse_add_grabber:N D
800 \tl_put_right:Nn \l__xparse_signature_tl { #1 #2 }
801 \__xparse_prepare_signature:N
802 }
803 \cs_new_protected:Npn \__xparse_add_type_E:w #1#2
804 {
805 \__xparse_flush_m_args:
806 \__xparse_add_default_E:nn {#1} {#2}
807 \__xparse_add_grabber:N E
808 \tl_put_right:Nn \l__xparse_signature_tl { {#1} }
809 \__xparse_prepare_signature:N
810 }
811 \cs_new_protected:Npn \__xparse_add_type_G:w #1
812 {
813 \__xparse_flush_m_args:
814 \__xparse_add_default:n {#1}
815 \__xparse_add_grabber:N G
816 \__xparse_prepare_signature:N
817 }
818 \cs_new_protected:Npn \__xparse_add_type_l:w
819 {
820 \__xparse_flush_m_args:
821 \__xparse_add_default:
822 \__xparse_add_grabber:N l
823 \__xparse_prepare_signature:N
824 }
825 \cs_new_protected:Npn \__xparse_add_type_m:w
826 {
827 \__xparse_add_default:
828 \bool_if:NTF \l__xparse_prefixed_bool
829 { \__xparse_add_grabber:N m }
830 { \int_incr:N \l__xparse_m_args_int }
831 \__xparse_prepare_signature:N
832 }
833 \cs_new_protected:Npn \__xparse_add_type_R:w #1#2#3
834 {
835 \__xparse_flush_m_args:
836 \__xparse_add_default:n {#3}
837 \__xparse_add_grabber:N R
838 \tl_put_right:Nn \l__xparse_signature_tl { #1 #2 }
839 \__xparse_prepare_signature:N
840 }
841 \cs_new_protected:Npn \__xparse_add_type_t:w #1
842 {
843 \__xparse_flush_m_args:
844 \__xparse_add_default:
845 \__xparse_add_grabber:N t
846 \tl_put_right:Nn \l__xparse_signature_tl {#1}
847 \__xparse_prepare_signature:N
848 }
849 \cs_new_protected:Npn \__xparse_add_type_u:w #1
850 {
851 \__xparse_flush_m_args:
852 \__xparse_add_default:
853 \__xparse_add_grabber:N u
854 \tl_put_right:Nn \l__xparse_signature_tl { {#1} }
855 \__xparse_prepare_signature:N
856 }
857 \cs_new_protected:Npn \__xparse_add_type_v:w
858 {
859 \__xparse_flush_m_args:
860 \exp_args:No \__xparse_add_default:n \c_novalue_tl
861 \__xparse_add_grabber:N v
862 \__xparse_prepare_signature:N
863 }
864 \cs_new_protected:Npn \__xparse_flush_m_args:
865 {
866 \int_compare:nNnT \l__xparse_m_args_int > 0
867 {
868 \tl_put_right:Nx \l__xparse_signature_tl
869 { \exp_not:c { __xparse_grab_m_ \int_use:N \l__xparse_m_args_int :w } }
870 \tl_put_right:Nx \l__xparse_process_all_tl
871 { \prg_replicate:nn { \l__xparse_m_args_int } { { } } }
872 }
873 \int_zero:N \l__xparse_m_args_int
874 }
875 \cs_new_protected:Npn \__xparse_add_grabber:N #1
876 {
877 \tl_put_right:Nx \l__xparse_signature_tl
878 {
879 \exp_not:c
880 {
881 __xparse_grab_ #1
882 \bool_if:NT \l__xparse_long_bool { _long }
883 \bool_if:NT \l__xparse_obey_spaces_bool { _obey_spaces }
884 :w
885 }
886 }
887 \bool_set_false:N \l__xparse_long_bool
888 \bool_set_false:N \l__xparse_obey_spaces_bool
889 \tl_put_right:Nx \l__xparse_process_all_tl
890 { { \exp_not:o \l__xparse_process_one_tl } }
891 \tl_clear:N \l__xparse_process_one_tl
892 }
893 \cs_new_protected:Npn \__xparse_add_default:n #1
894 {
895 \tl_if_novalue:nTF {#1}
896 { \__xparse_add_default: }
897 {
898 \int_incr:N \l__xparse_current_arg_int
899 \bool_set_true:N \l__xparse_defaults_bool
900 \tl_put_right:Nn \l__xparse_defaults_tl { { \prg_do_nothing: #1 } }
901 }
902 }
903 \cs_new_protected:Npn \__xparse_add_default:
904 {
905 \int_incr:N \l__xparse_current_arg_int
906 \tl_put_right:Nn \l__xparse_defaults_tl { \c_novalue_tl }
907 }
908 \cs_new_protected:Npn \__xparse_add_default_E:nn #1#2
909 {
910 \tl_map_function:nN {#2} \__xparse_add_default:n
911 \prg_replicate:nn
912 { \tl_count:n {#1} - \tl_count:n {#2} }
913 { \__xparse_add_default: }
914 }
915 \cs_new_protected:cpn { __xparse_add_expandable_type_+:w }
916 {
917 \bool_set_true:N \l__xparse_long_bool
918 \__xparse_prepare_signature:N
919 }
920 \cs_new_protected:Npn \__xparse_add_expandable_type_D:w
921 { \__xparse_add_expandable_type_D_aux:NNNn D }
922 \cs_new_protected:Npn \__xparse_add_expandable_type_D_aux:NNNn #1#2#3#4
923 {
924 \__xparse_add_default:n {#4}
925 \tl_if_eq:nnTF {#2} {#3}
926 { \__xparse_add_expandable_type_D_aux:NN #1 #2 }
927 { \__xparse_add_expandable_type_D_aux:NNN #1 #2 #3 }
928 \__xparse_prepare_signature:N
929 }
930 \cs_new_protected:Npn \__xparse_add_expandable_type_D_aux:NNN #1#2#3
931 {
932 \bool_if:NTF \l__xparse_long_bool
933 { \cs_set:cpx }
934 { \cs_set_nopar:cpx }
935 { \l__xparse_expandable_aux_name_tl } ##1 ##2 #2 ##3 \q__xparse ##4 #3
936 { ##1 {##2} {##3} {##4} }
937 \__xparse_add_expandable_grabber:nn {#1}
938 {
939 \exp_not:c { \l__xparse_expandable_aux_name_tl }
940 \exp_not:n { #2 #3 }
941 }
942 }
943 \cs_new_protected:Npn \__xparse_add_expandable_type_D_aux:NN #1#2
944 {
945 \bool_if:NTF \l__xparse_long_bool
946 { \cs_set:cpx }
947 { \cs_set_nopar:cpx }
948 { \l__xparse_expandable_aux_name_tl } ##1 #2 ##2 #2
949 { ##1 {##2} }
950 \__xparse_add_expandable_grabber:nn { #1_alt }
951 {
952 \exp_not:c { \l__xparse_expandable_aux_name_tl }
953 \exp_not:n {#2}
954 }
955 }
956 \cs_new_protected:Npn \__xparse_add_expandable_type_E:w #1#2
957 {
958 \__xparse_add_default_E:nn {#1} {#2}
959 \tl_clear:N \l__xparse_tmpb_tl
960 \tl_map_function:nN {#1} \__xparse_add_expandable_type_E_aux:n
961 \__xparse_add_expandable_grabber:nn
962 { E \bool_if:NT \l__xparse_long_bool { _long } }
963 {
964 { \exp_not:o \l__xparse_tmpb_tl }
965 {
966 \prg_replicate:nn { \tl_count:n {#1} }
967 { { \c_novalue_tl } }
968 }
969 }
970 \__xparse_prepare_signature:N
971 }
972 \cs_new_protected:Npn \__xparse_add_expandable_type_E_aux:n #1
973 {
974 \__xparse_get_grabber:NN #1 \l__xparse_tmpa_tl
975 \tl_put_right:Nx \l__xparse_tmpb_tl
976 { \exp_not:o \l__xparse_tmpa_tl \exp_not:N #1 }
977 }
978 \cs_new_protected:Npn \__xparse_add_expandable_type_l:w
979 { \__xparse_add_expandable_type_u:w ## }
980 \cs_new_protected:Npn \__xparse_add_expandable_type_m:w
981 {
982 \__xparse_add_default:
983 \__xparse_add_expandable_grabber:nn
984 { m \bool_if:NT \l__xparse_long_bool { _long } } { }
985 \__xparse_prepare_signature:N
986 }
987 \cs_new_protected:Npn \__xparse_add_expandable_type_R:w
988 { \__xparse_add_expandable_type_D_aux:NNNn R }
989 \cs_new_protected:Npn \__xparse_add_expandable_type_t:w #1
990 {
991 \__xparse_add_default:
992 \__xparse_get_grabber:NN #1 \l__xparse_tmpa_tl
993 \__xparse_add_expandable_grabber:nn { t }
994 {
995 \exp_not:o \l__xparse_tmpa_tl
996 \exp_not:N #1
997 }
998 \__xparse_prepare_signature:N
999 }
1000 \cs_new_protected:Npn \__xparse_add_expandable_type_u:w #1
1001 {
1002 \__xparse_add_default:
1003 \bool_if:NTF \l__xparse_long_bool
1004 { \cs_set:cpn }
1005 { \cs_set_nopar:cpn }
1006 { \l__xparse_expandable_aux_name_tl } ##1 \q__xparse ##2 ##3 ##4 #1
1007 { ##1 {##4} \q__xparse ##2 ##3 }
1008 \__xparse_add_expandable_grabber:nn { u }
1009 { \exp_not:c { \l__xparse_expandable_aux_name_tl } }
1010 \__xparse_prepare_signature:N
1011 }
1012 \cs_new_protected:Npn \__xparse_add_expandable_grabber:nn #1#2
1013 {
1014 \tl_put_right:Nx \l__xparse_signature_tl
1015 { \exp_not:c { __xparse_expandable_grab_ #1 :w } #2 }
1016 }
1017 \cs_new_protected:Npn \__xparse_get_grabber:NN #1#2
1018 {
1019 \cs_set:Npn \__xparse_tmp:w ##1 #1 {##1}
1020 \exp_args:Nc \__xparse_get_grabber_auxi:NN
1021 { __xparse_grabber_ \token_to_str:N #1 :w } #2
1022 }
1023 \cs_new_protected:Npn \__xparse_get_grabber_auxi:NN #1#2
1024 {
1025 \cs_if_eq:NNTF \__xparse_tmp:w #1
1026 { \tl_set:Nn #2 {#1} }
1027 {
1028 \cs_if_exist:NTF #1
1029 {
1030 \int_gincr:N \g__xparse_grabber_int
1031 \exp_args:Nc \__xparse_get_grabber_auxi:NN
1032 {
1033 __xparse_grabber_
1034 - \int_use:N \g__xparse_grabber_int :w
1035 }
1036 #2
1037 }
1038 { \__xparse_get_grabber_auxii:NN #1 #2 }
1039 }
1040 }
1041 \cs_new_protected:Npn \__xparse_get_grabber_auxii:NN #1#2
1042 {
1043 \cs_set_eq:NN #1 \__xparse_tmp:w
1044 \tl_set:Nn #2 {#1}
1045 }
1046 \cs_new_protected:Npn \__xparse_grab_b:w
1047 { \__xparse_grab_b_aux:NNw \cs_set_protected_nopar:Npn \tl_trim_spaces:n }
1048 \cs_new_protected:Npn \__xparse_grab_b_long:w
1049 { \__xparse_grab_b_aux:NNw \cs_set_protected:Npn \tl_trim_spaces:n }
1050 \cs_new_protected:Npn \__xparse_grab_b_obey_spaces:w
1051 { \__xparse_grab_b_aux:NNw \cs_set_protected_nopar:Npn \exp_not:n }
1052 \cs_new_protected:Npn \__xparse_grab_b_long_obey_spaces:w
1053 { \__xparse_grab_b_aux:NNw \cs_set_protected:Npn \exp_not:n }
1054 \cs_new_protected:Npn \__xparse_grab_b_aux:NNw #1#2#3 \__xparse_run_code:
1055 {
1056 \__xparse_grab_D_aux:NNnN \begin \end {#3} #1
1057 \tl_put_left:Nn \l__xparse_signature_tl { \__xparse_grab_b_end:Nw #2 }
1058 \tl_set_eq:NN \l__xparse_saved_args_tl \l__xparse_args_tl
1059 \tl_clear:N \l__xparse_args_tl
1060 \exp_args:Nc \l__xparse_fn_tl { begin ~ }
1061 }
1062 \cs_new_protected:Npn \__xparse_grab_b_end:Nw #1#2 \__xparse_run_code:
1063 {
1064 \tl_set:Nx \l__xparse_args_tl
1065 {
1066 \exp_not:V \l__xparse_saved_args_tl
1067 { \exp_after:wN #1 \l__xparse_args_tl }
1068 }
1069 #2
1070 \__xparse_run_code:
1071 \end
1072 }
1073 \cs_new_protected:Npn \__xparse_grab_D:w #1#2#3 \__xparse_run_code:
1074 {
1075 \__xparse_grab_D_aux:NNnNN #1 #2 {#3} \cs_set_protected_nopar:Npn
1076 \__xparse_peek_nonspace_remove:NTF
1077 }
1078 \cs_new_protected:Npn \__xparse_grab_D_long:w #1#2#3 \__xparse_run_code:
1079 {
1080 \__xparse_grab_D_aux:NNnNN #1 #2 {#3} \cs_set_protected:Npn
1081 \__xparse_peek_nonspace_remove:NTF
1082 }
1083 \cs_new_protected:Npn \__xparse_grab_D_obey_spaces:w #1#2#3 \__xparse_run_code:
1084 {
1085 \__xparse_grab_D_aux:NNnNN #1 #2 {#3} \cs_set_protected_nopar:Npn
1086 \__xparse_peek_meaning_remove:NTF
1087 }
1088 \cs_new_protected:Npn \__xparse_grab_D_long_obey_spaces:w #1#2#3 \__xparse_run_code:
1089 {
1090 \__xparse_grab_D_aux:NNnNN #1 #2 {#3} \cs_set_protected:Npn
1091 \__xparse_peek_meaning_remove:NTF
1092 }
1093 \cs_new_protected:Npn \__xparse_grab_D_aux:NNnNN #1#2#3#4#5
1094 {
1095 \__xparse_grab_D_aux:NNnN #1#2 {#3} #4
1096 #5 #1
1097 { \__xparse_grab_D_call:Nw #1 }
1098 { \__xparse_add_arg:o \c_novalue_tl }
1099 }
1100 \cs_new_protected:Npn \__xparse_grab_D_aux:NNnN #1#2#3#4
1101 {
1102 \tl_set:Nn \l__xparse_signature_tl {#3}
1103 \exp_after:wN #4 \l__xparse_fn_tl ##1 #2
1104 {
1105 \tl_if_in:nnTF {##1} {#1}
1106 { \__xparse_grab_D_nested:NNnN #1 #2 {##1} #4 }
1107 {
1108 \tl_if_blank:oTF { \use_none:n ##1 }
1109 { \__xparse_add_arg:o { \use_none:n ##1 } }
1110 {
1111 \str_if_eq:eeTF
1112 { \exp_not:o { \use_none:n ##1 } }
1113 { { \exp_not:o { \use_ii:nnn ##1 \q_nil } } }
1114 { \__xparse_add_arg:o { \use_ii:nn ##1 } }
1115 { \__xparse_add_arg:o { \use_none:n ##1 } }
1116 }
1117 }
1118 }
1119 }
1120 \tl_new:N \l__xparse_nesting_a_tl
1121 \tl_new:N \l__xparse_nesting_b_tl
1122 \quark_new:N \q__xparse
1123 \cs_new_protected:Npn \__xparse_grab_D_nested:NNnN #1#2#3#4
1124 {
1125 \tl_clear:N \l__xparse_nesting_a_tl
1126 \tl_clear:N \l__xparse_nesting_b_tl
1127 \exp_after:wN #4 \l__xparse_fn_tl ##1 #1 ##2 \q__xparse ##3 #2
1128 {
1129 \tl_put_right:No \l__xparse_nesting_a_tl { \use_none:n ##1 #1 }
1130 \tl_put_right:No \l__xparse_nesting_b_tl { \use_i:nn #2 ##3 }
1131 \tl_if_in:nnTF {##2} {#1}
1132 {
1133 \l__xparse_fn_tl
1134 \q_nil ##2 \q__xparse \ERROR
1135 }
1136 {
1137 \tl_put_right:Nx \l__xparse_nesting_a_tl
1138 { \__xparse_grab_D_nested:w \q_nil ##2 \q_stop }
1139 \tl_if_in:NnTF \l__xparse_nesting_b_tl {#1}
1140 {
1141 \tl_set_eq:NN \l__xparse_tmpa_tl \l__xparse_nesting_b_tl
1142 \tl_clear:N \l__xparse_nesting_b_tl
1143 \exp_after:wN \l__xparse_fn_tl \exp_after:wN
1144 \q_nil \l__xparse_tmpa_tl \q_nil \q__xparse \ERROR
1145 }
1146 {
1147 \tl_put_right:No \l__xparse_nesting_a_tl
1148 \l__xparse_nesting_b_tl
1149 \__xparse_add_arg:V \l__xparse_nesting_a_tl
1150 }
1151 }
1152 }
1153 \l__xparse_fn_tl #3 \q_nil \q__xparse \ERROR
1154 }
1155 \cs_new:Npn \__xparse_grab_D_nested:w #1 \q_nil \q_stop
1156 { \exp_not:o { \use_none:n #1 } }
1157 \cs_new_protected_nopar:Npn \__xparse_grab_D_call:Nw #1
1158 {
1159 \token_if_eq_catcode:NNTF + #1
1160 {
1161 \exp_after:wN \exp_after:wN \exp_after:wN
1162 \l__xparse_fn_tl \char_generate:nn { `#1 } { 11 }
1163 }
1164 {
1165 \__xparse_token_if_cs:NTF #1
1166 {
1167 \exp_after:wN \l__xparse_fn_tl
1168 \cs:w \cs_to_str:N #1 ~ \cs_end:
1169 }
1170 {
1171 \exp_after:wN \l__xparse_fn_tl
1172 \token_to_str:N #1
1173 }
1174 }
1175 }
1176 \cs_new_protected:Npn \__xparse_grab_E:w #1#2 \__xparse_run_code:
1177 {
1178 \__xparse_grab_E:nnNN {#1} {#2}
1179 \cs_set_protected_nopar:Npn
1180 \__xparse_peek_nonspace_remove:NTF
1181 }
1182 \cs_new_protected:Npn \__xparse_grab_E_long:w #1#2 \__xparse_run_code:
1183 {
1184 \__xparse_grab_E:nnNN {#1} {#2}
1185 \cs_set_protected:Npn
1186 \__xparse_peek_nonspace_remove:NTF
1187 }
1188 \cs_new_protected:Npn \__xparse_grab_E_obey_spaces:w #1#2 \__xparse_run_code:
1189 {
1190 \__xparse_grab_E:nnNN {#1} {#2}
1191 \cs_set_protected_nopar:Npn
1192 \__xparse_peek_meaning_remove:NTF
1193 }
1194 \cs_new_protected:Npn \__xparse_grab_E_long_obey_spaces:w #1#2 \__xparse_run_code:
1195 {
1196 \__xparse_grab_E:nnNN {#1} {#2}
1197 \cs_set_protected:Npn
1198 \__xparse_peek_meaning_remove:NTF
1199 }
1200 \cs_new_protected:Npn \__xparse_grab_E:nnNN #1#2#3#4
1201 {
1202 \exp_after:wN #3 \l__xparse_fn_tl ##1##2##3
1203 {
1204 \prop_put:Nnn \l__xparse_tmp_prop {##1} {##3}
1205 \__xparse_grab_E_loop:NnN #4 { } ##2 \q_recursion_stop
1206 }
1207 \prop_clear:N \l__xparse_tmp_prop
1208 \tl_set:Nn \l__xparse_signature_tl {#2}
1209 \cs_set_protected:Npn \__xparse_grab_E_finalise:
1210 {
1211 \tl_map_inline:nn {#1}
1212 {
1213 \prop_get:NnNF \l__xparse_tmp_prop {####1} \l__xparse_tmpb_tl
1214 { \tl_set_eq:NN \l__xparse_tmpb_tl \c_novalue_tl }
1215 \tl_put_right:Nx \l__xparse_args_tl
1216 { { \exp_not:V \l__xparse_tmpb_tl } }
1217 }
1218 \l__xparse_signature_tl \__xparse_run_code:
1219 }
1220 \__xparse_grab_E_loop:NnN #4 { } #1 \q_recursion_tail \q_recursion_stop
1221 }
1222 \cs_new_protected:Npn \__xparse_grab_E_loop:NnN #1#2#3#4 \q_recursion_stop
1223 {
1224 \cs_if_eq:NNTF #3 \q_recursion_tail
1225 { \__xparse_grab_E_finalise: }
1226 {
1227 #1 #3
1228 { \l__xparse_fn_tl #3 {#2#4} }
1229 { \__xparse_grab_E_loop:NnN #1 {#2#3} #4 \q_recursion_stop }
1230 }
1231 }
1232 \cs_new_protected:Npn \__xparse_grab_E_finalise: { }
1233 \cs_new_protected:Npn \__xparse_grab_G:w #1 \__xparse_run_code:
1234 {
1235 \__xparse_grab_G_aux:nNN {#1} \cs_set_protected_nopar:Npn
1236 \__xparse_peek_nonspace:NTF
1237 }
1238 \cs_new_protected:Npn \__xparse_grab_G_long:w #1 \__xparse_run_code:
1239 {
1240 \__xparse_grab_G_aux:nNN {#1} \cs_set_protected:Npn
1241 \__xparse_peek_nonspace:NTF
1242 }
1243 \cs_new_protected:Npn \__xparse_grab_G_obey_spaces:w #1 \__xparse_run_code:
1244 {
1245 \__xparse_grab_G_aux:nNN {#1} \cs_set_protected_nopar:Npn
1246 \peek_meaning:NTF
1247 }
1248 \cs_new_protected:Npn \__xparse_grab_G_long_obey_spaces:w #1 \__xparse_run_code:
1249 {
1250 \__xparse_grab_G_aux:nNN {#1} \cs_set_protected:Npn
1251 \peek_meaning:NTF
1252 }
1253 \cs_new_protected:Npn \__xparse_grab_G_aux:nNN #1#2#3
1254 {
1255 \tl_set:Nn \l__xparse_signature_tl {#1}
1256 \exp_after:wN #2 \l__xparse_fn_tl ##1
1257 { \__xparse_add_arg:n {##1} }
1258 #3 \c_group_begin_token
1259 { \l__xparse_fn_tl }
1260 { \__xparse_add_arg:o \c_novalue_tl }
1261 }
1262 \cs_new_protected:Npn \__xparse_grab_l:w #1 \__xparse_run_code:
1263 { \__xparse_grab_l_aux:nN {#1} \cs_set_protected_nopar:Npn }
1264 \cs_new_protected:Npn \__xparse_grab_l_long:w #1 \__xparse_run_code:
1265 { \__xparse_grab_l_aux:nN {#1} \cs_set_protected:Npn }
1266 \cs_new_protected:Npn \__xparse_grab_l_aux:nN #1#2
1267 {
1268 \tl_set:Nn \l__xparse_signature_tl {#1}
1269 \exp_after:wN #2 \l__xparse_fn_tl ##1##
1270 { \__xparse_add_arg:n {##1} }
1271 \l__xparse_fn_tl
1272 }
1273 \cs_new_protected:Npn \__xparse_grab_m:w #1 \__xparse_run_code:
1274 {
1275 \tl_set:Nn \l__xparse_signature_tl {#1}
1276 \exp_after:wN \cs_set_protected_nopar:Npn \l__xparse_fn_tl ##1
1277 { \__xparse_add_arg:n {##1} }
1278 \l__xparse_fn_tl
1279 }
1280 \cs_new_protected:Npn \__xparse_grab_m_long:w #1 \__xparse_run_code:
1281 {
1282 \tl_set:Nn \l__xparse_signature_tl {#1}
1283 \exp_after:wN \cs_set_protected:Npn \l__xparse_fn_tl ##1
1284 { \__xparse_add_arg:n {##1} }
1285 \l__xparse_fn_tl
1286 }
1287 \cs_new_protected_nopar:Npn \__xparse_grab_m_aux:Nnnnnnnnn #1#2#3#4#5#6#7#8#9
1288 {
1289 \tl_put_right:No \l__xparse_args_tl
1290 { #1 {#2} {#3} {#4} {#5} {#6} {#7} {#8} {#9} }
1291 \l__xparse_signature_tl \__xparse_run_code:
1292 }
1293 \cs_new_protected:cpn { __xparse_grab_m_1:w } #1 \__xparse_run_code:
1294 {
1295 \tl_set:Nn \l__xparse_signature_tl {#1}
1296 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1297 \l__xparse_fn_tl \use_none:nnnnnnn { } { } { } { } { } { } { }
1298 }
1299 \cs_new_protected:cpn { __xparse_grab_m_2:w } #1 \__xparse_run_code:
1300 {
1301 \tl_set:Nn \l__xparse_signature_tl {#1}
1302 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1303 \l__xparse_fn_tl \use_none:nnnnnn { } { } { } { } { } { }
1304 }
1305 \cs_new_protected:cpn { __xparse_grab_m_3:w } #1 \__xparse_run_code:
1306 {
1307 \tl_set:Nn \l__xparse_signature_tl {#1}
1308 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1309 \l__xparse_fn_tl \use_none:nnnnn { } { } { } { } { }
1310 }
1311 \cs_new_protected:cpn { __xparse_grab_m_4:w } #1 \__xparse_run_code:
1312 {
1313 \tl_set:Nn \l__xparse_signature_tl {#1}
1314 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1315 \l__xparse_fn_tl \use_none:nnnn { } { } { } { }
1316 }
1317 \cs_new_protected:cpn { __xparse_grab_m_5:w } #1 \__xparse_run_code:
1318 {
1319 \tl_set:Nn \l__xparse_signature_tl {#1}
1320 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1321 \l__xparse_fn_tl \use_none:nnn { } { } { }
1322 }
1323 \cs_new_protected:cpn { __xparse_grab_m_6:w } #1 \__xparse_run_code:
1324 {
1325 \tl_set:Nn \l__xparse_signature_tl {#1}
1326 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1327 \l__xparse_fn_tl \use_none:nn { } { }
1328 }
1329 \cs_new_protected:cpn { __xparse_grab_m_7:w } #1 \__xparse_run_code:
1330 {
1331 \tl_set:Nn \l__xparse_signature_tl {#1}
1332 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1333 \l__xparse_fn_tl \use_none:n { }
1334 }
1335 \cs_new_protected:cpn { __xparse_grab_m_8:w } #1 \__xparse_run_code:
1336 {
1337 \tl_set:Nn \l__xparse_signature_tl {#1}
1338 \exp_after:wN \cs_set_eq:NN \l__xparse_fn_tl \__xparse_grab_m_aux:Nnnnnnnnn
1339 \l__xparse_fn_tl \prg_do_nothing:
1340 }
1341 \cs_new_protected:cpx { __xparse_grab_m_9:w }
1342 {
1343 \exp_not:c { __xparse_grab_m_5:w }
1344 \exp_not:c { __xparse_grab_m_4:w }
1345 }
1346 \cs_new_protected:Npn \__xparse_grab_R:w #1#2#3 \__xparse_run_code:
1347 { \__xparse_grab_R_aux:NNnN #1 #2 {#3} \cs_set_protected_nopar:Npn }
1348 \cs_new_protected:Npn \__xparse_grab_R_long:w #1#2#3 \__xparse_run_code:
1349 { \__xparse_grab_R_aux:NNnN #1 #2 {#3} \cs_set_protected:Npn }
1350 \cs_new_protected:Npn \__xparse_grab_R_aux:NNnN #1#2#3#4
1351 {
1352 \__xparse_grab_D_aux:NNnN #1 #2 {#3} #4
1353 \__xparse_peek_nonspace_remove:NTF #1
1354 { \__xparse_grab_D_call:Nw #1 }
1355 {
1356 \__kernel_msg_error:nnxx { xparse } { missing-required }
1357 { \__xparse_environment_or_command: }
1358 { \token_to_str:N #1 }
1359 \__xparse_add_arg:o \c_novalue_tl
1360 }
1361 }
1362 \cs_new_protected:Npn \__xparse_grab_t:w
1363 { \__xparse_grab_t_aux:NNw \__xparse_peek_nonspace_remove:NTF }
1364 \cs_new_protected:Npn \__xparse_grab_t_obey_spaces:w
1365 { \__xparse_grab_t_aux:NNw \__xparse_peek_meaning_remove:NTF }
1366 \cs_new_protected:Npn \__xparse_grab_t_aux:NNw #1#2#3 \__xparse_run_code:
1367 {
1368 \tl_set:Nn \l__xparse_signature_tl {#3}
1369 \exp_after:wN \cs_set_protected:Npn \l__xparse_fn_tl
1370 {
1371 #1 #2
1372 { \__xparse_add_arg:n { \BooleanTrue } }
1373 { \__xparse_add_arg:n { \BooleanFalse } }
1374 }
1375 \l__xparse_fn_tl
1376 }
1377 \cs_new_protected:Npn \__xparse_grab_u:w #1#2 \__xparse_run_code:
1378 { \__xparse_grab_u_aux:nnN {#1} {#2} \cs_set_protected_nopar:Npn }
1379 \cs_new_protected:Npn \__xparse_grab_u_long:w #1#2 \__xparse_run_code:
1380 { \__xparse_grab_u_aux:nnN {#1} {#2} \cs_set_protected:Npn }
1381 \cs_new_protected:Npn \__xparse_grab_u_aux:nnN #1#2#3
1382 {
1383 \tl_set:Nn \l__xparse_signature_tl {#2}
1384 \exp_after:wN #3 \l__xparse_fn_tl ##1 #1
1385 { \__xparse_add_arg:n {##1} }
1386 \l__xparse_fn_tl
1387 }
1388 \tl_new:N \l__xparse_v_arg_tl
1389 \cs_new_protected:Npn \__xparse_grab_v:w
1390 {
1391 \bool_set_false:N \l__xparse_long_bool
1392 \__xparse_grab_v_aux:w
1393 }
1394 \cs_new_protected:Npn \__xparse_grab_v_long:w
1395 {
1396 \bool_set_true:N \l__xparse_long_bool
1397 \__xparse_grab_v_aux:w
1398 }
1399 \cs_new_protected:Npn \__xparse_grab_v_aux:w #1 \__xparse_run_code:
1400 {
1401 \tl_set:Nn \l__xparse_signature_tl {#1}
1402 \group_begin:
1403 \tex_escapechar:D = 92 \scan_stop:
1404 \tl_clear:N \l__xparse_v_arg_tl
1405 \peek_remove_spaces:n
1406 {
1407 \peek_meaning_remove:NTF \c_group_begin_token
1408 {
1409 \group_align_safe_end:
1410 \__xparse_grab_v_bgroup:
1411 }
1412 {
1413 \peek_N_type:TF
1414 { \__xparse_grab_v_aux_test:N }
1415 { \__xparse_grab_v_aux_abort:n { } }
1416 }
1417 }
1418 }
1419 \cs_new_protected:Npn \__xparse_grab_v_group_end:
1420 {
1421 \exp_args:NNNo
1422 \group_end:
1423 \tl_set:Nn \l__xparse_v_arg_tl { \l__xparse_v_arg_tl }
1424 }
1425 \cs_new_protected:Npn \__xparse_grab_v_aux_test:N #1
1426 {
1427 \__xparse_grab_v_token_if_char:NTF #1
1428 {
1429 \__xparse_grab_v_aux_put:N #1
1430 \__xparse_grab_v_aux_catcodes:
1431 \__xparse_grab_v_aux_loop:N #1
1432 }
1433 { \__xparse_grab_v_aux_abort:n {#1} #1 }
1434 }
1435 \cs_new_protected:Npn \__xparse_grab_v_aux_loop:N #1
1436 {
1437 \peek_N_type:TF
1438 { \__xparse_grab_v_aux_loop:NN #1 }
1439 { \__xparse_grab_v_aux_abort:n { } }
1440 }
1441 \cs_new_protected:Npn \__xparse_grab_v_aux_loop:NN #1#2
1442 {
1443 \__xparse_grab_v_token_if_char:NTF #2
1444 {
1445 \token_if_eq_charcode:NNTF #1 #2
1446 { \__xparse_grab_v_aux_loop_end: }
1447 {
1448 \__xparse_grab_v_aux_put:N #2
1449 \__xparse_grab_v_aux_loop:N #1
1450 }
1451 }
1452 { \__xparse_grab_v_aux_abort:n {#2} #2 }
1453 }
1454 \cs_new_protected:Npn \__xparse_grab_v_aux_loop_end:
1455 {
1456 \__xparse_grab_v_group_end:
1457 \__xparse_add_arg:x { \tl_tail:N \l__xparse_v_arg_tl }
1458 }
1459 \int_new:N \l__xparse_v_nesting_int
1460 \cs_new_protected:Npx \__xparse_grab_v_bgroup:
1461 {
1462 \exp_not:N \__xparse_grab_v_aux_catcodes:
1463 \exp_not:n { \int_set:Nn \l__xparse_v_nesting_int { 1 } }
1464 \exp_not:N \__xparse_grab_v_aux_put:N \iow_char:N \{
1465 \exp_not:N \__xparse_grab_v_bgroup_loop:
1466 }
1467 \cs_new_protected:Npn \__xparse_grab_v_bgroup_loop:
1468 {
1469 \peek_N_type:TF
1470 { \__xparse_grab_v_bgroup_loop:N }
1471 { \__xparse_grab_v_aux_abort:n { } }
1472 }
1473 \cs_new_protected:Npn \__xparse_grab_v_bgroup_loop:N #1
1474 {
1475 \__xparse_grab_v_token_if_char:NTF #1
1476 {
1477 \token_if_eq_charcode:NNTF \c_group_end_token #1
1478 {
1479 \int_decr:N \l__xparse_v_nesting_int
1480 \int_compare:nNnTF \l__xparse_v_nesting_int > 0
1481 {
1482 \__xparse_grab_v_aux_put:N #1
1483 \__xparse_grab_v_bgroup_loop:
1484 }
1485 { \__xparse_grab_v_aux_loop_end: }
1486 }
1487 {
1488 \token_if_eq_charcode:NNT \c_group_begin_token #1
1489 { \int_incr:N \l__xparse_v_nesting_int }
1490 \__xparse_grab_v_aux_put:N #1
1491 \__xparse_grab_v_bgroup_loop:
1492 }
1493 }
1494 { \__xparse_grab_v_aux_abort:n {#1} #1 }
1495 }
1496 \cs_new_protected:Npn \__xparse_grab_v_aux_catcodes:
1497 {
1498 \cs_set_eq:NN \do \char_set_catcode_other:N
1499 \dospecials
1500 \tex_endlinechar:D = `\^^M \scan_stop:
1501 \bool_if:NTF \l__xparse_long_bool
1502 { \char_set_catcode_other:n { \tex_endlinechar:D } }
1503 { \char_set_catcode_parameter:n { \tex_endlinechar:D } }
1504 }
1505 \cs_new_protected:Npn \__xparse_grab_v_aux_abort:n #1
1506 {
1507 \__xparse_grab_v_group_end:
1508 \exp_after:wN \exp_after:wN \exp_after:wN
1509 \peek_meaning_remove:NTF \char_generate:nn { \tex_endlinechar:D } { 6 }
1510 {
1511 \__kernel_msg_error:nnxxx { xparse } { verbatim-newline }
1512 { \__xparse_environment_or_command: }
1513 { \tl_to_str:N \l__xparse_v_arg_tl }
1514 { \tl_to_str:n {#1} }
1515 \__xparse_add_arg:o \c_novalue_tl
1516 }
1517 {
1518 \__kernel_msg_error:nnxxx { xparse } { verbatim-tokenized }
1519 { \__xparse_environment_or_command: }
1520 { \tl_to_str:N \l__xparse_v_arg_tl }
1521 { \tl_to_str:n {#1} }
1522 \__xparse_add_arg:o \c_novalue_tl
1523 }
1524 }
1525 \cs_new_protected:Npn \__xparse_grab_v_aux_put:N #1
1526 {
1527 \tl_put_right:Nx \l__xparse_v_arg_tl
1528 {
1529 \token_if_active:NTF #1
1530 { \exp_not:N #1 } { \token_to_str:N #1 }
1531 }
1532 }
1533 \cs_new_protected:Npn \__xparse_grab_v_token_if_char:NTF #1
1534 { \str_if_eq:eeTF { } { \str_tail:n {#1} } }
1535 \cs_new_protected:Npn \__xparse_add_arg:n #1
1536 {
1537 \tl_put_right:Nn \l__xparse_args_tl { {#1} }
1538 \l__xparse_signature_tl \__xparse_run_code:
1539 }
1540 \cs_generate_variant:Nn \__xparse_add_arg:n { V , o , x }
1541 \cs_new:Npn \__xparse_expandable_grab_D:w #1 \q__xparse #2#3
1542 { #2 { \__xparse_expandable_grab_D:NNNwNNn #1 \q__xparse #2 #3 } }
1543 \cs_set_protected:Npn \__xparse_tmp:w #1
1544 {
1545 \cs_new:Npn \__xparse_expandable_grab_D:NNNwNNn ##1##2##3##4 \q__xparse ##5##6##7
1546 {
1547 \str_if_eq:nnTF {##2} {##7}
1548 {
1549 \str_if_eq:onTF
1550 { ##1 { } { } ##7 ##2 \q__xparse ##3 }
1551 { { } {##2} { } }
1552 }
1553 { \use_ii:nn }
1554 {
1555 ##1
1556 { \__xparse_expandable_grab_D:NNNwNNnnn ##1##2##3##4 \q__xparse ##5##6 }
1557 \q_nil { } ##2 \ERROR \q__xparse \ERROR
1558 }
1559 { ##4 {#1} \q__xparse ##5 ##6 {##7} }
1560 }
1561 }
1562 \exp_args:No \__xparse_tmp:w { \c_novalue_tl }
1563 \cs_new:Npn \__xparse_expandable_grab_D:NNNwNNnnn #1#2#3#4 \q__xparse #5#6#7#8#9
1564 {
1565 \exp_args:Nof \__xparse_expandable_grab_D:nnNNNwNN
1566 { \use_ii:nn #7 #2 }
1567 { \__xparse_expandable_grab_D:Nw #3 \exp_stop_f: #8 #9 }
1568 #1#2#3 #4 \q__xparse #5 #6
1569 }
1570 \cs_new:Npn \__xparse_expandable_grab_D:Nw #1#2 \ERROR \ERROR { #2 #1 }
1571 \cs_new:Npn \__xparse_expandable_grab_D:nnNNNwNN #1#2#3#4#5#6 \q__xparse #7#8
1572 {
1573 \exp_args:No \tl_if_empty:oTF
1574 { #3 { \use_none:nnn } #2 \q__xparse #5 #4 \q__xparse #5 }
1575 {
1576 \tl_if_blank:oTF { \use_none:nn #1#2 }
1577 { \__xparse_put_arg_expandable:ow { \use_none:nn #1#2 } }
1578 {
1579 \str_if_eq:eeTF
1580 { \exp_not:o { \use_none:nn #1#2 } }
1581 { { \exp_not:o { \use_iii:nnnn #1#2 \q_nil } } }
1582 { \__xparse_put_arg_expandable:ow { \use_iii:nnn #1#2 } }
1583 { \__xparse_put_arg_expandable:ow { \use_none:nn #1#2 } }
1584 }
1585 #6 \q__xparse #7 #8
1586 }
1587 {
1588 #3
1589 { \__xparse_expandable_grab_D:NNNwNNnnn #3#4#5#6 \q__xparse #7 #8 }
1590 \q_nil {#1} #2 \ERROR \q__xparse \ERROR
1591 }
1592 }
1593 \cs_new:Npn \__xparse_expandable_grab_D_alt:w #1 \q__xparse #2#3
1594 { #2 { \__xparse_expandable_grab_D_alt:NNwNNn #1 \q__xparse #2 #3 } }
1595 \cs_set_protected:Npn \__xparse_tmp:w #1
1596 {
1597 \cs_new:Npn \__xparse_expandable_grab_D_alt:NNwNNn ##1##2##3 \q__xparse ##4##5##6
1598 {
1599 \str_if_eq:nnTF {##6} {##2}
1600 {
1601 \str_if_eq:onTF
1602 { ##1 { } ##6 ##2 ##2 }
1603 { { } ##2 }
1604 }
1605 { \use_ii:nn }
1606 {
1607 ##1
1608 { \__xparse_expandable_grab_D_alt:NNwn ##4 ##5 ##3 \q__xparse }
1609 ##6 \ERROR
1610 }
1611 { ##3 {#1} \q__xparse ##4 ##5 {##6} }
1612 }
1613 }
1614 \exp_args:No \__xparse_tmp:w { \c_novalue_tl }
1615 \cs_new:Npn \__xparse_expandable_grab_D_alt:NNwn #1#2#3 \q__xparse #4
1616 {
1617 \tl_if_blank:oTF { \use_none:n #4 }
1618 { \__xparse_put_arg_expandable:ow { \use_none:n #4 } }
1619 {
1620 \str_if_eq:eeTF
1621 { \exp_not:o { \use_none:n #4 } }
1622 { { \exp_not:o { \use_ii:nnn #4 \q_nil } } }
1623 { \__xparse_put_arg_expandable:ow { \use_ii:nn #4 } }
1624 { \__xparse_put_arg_expandable:ow { \use_none:n #4 } }
1625 }
1626 #3 \q__xparse #1 #2
1627 }
1628 \cs_new:Npn \__xparse_expandable_grab_E:w #1 \q__xparse #2#3
1629 { \__xparse_expandable_grab_E_aux:w #1 \q__xparse #2 #3 #3 }
1630 \cs_new:Npn \__xparse_expandable_grab_E_long:w #1 \q__xparse #2#3
1631 { \__xparse_expandable_grab_E_aux:w #1 \q__xparse #2 #3 #2 }
1632 \cs_new:Npn \__xparse_expandable_grab_E_aux:w #1 \q__xparse #2#3#4
1633 { #2 { \__xparse_expandable_grab_E_test:nnw #1 \q__xparse #2 #3 #4 } }
1634 \cs_new:Npn \__xparse_expandable_grab_E_test:nnw #1#2#3 \q__xparse #4#5#6#7
1635 {
1636 \__xparse_expandable_grab_E_loop:nnnNNw {#7} { } { }
1637 #1 \q_nil \q_nil \q_nil \q_mark #2 \q_nil
1638 #3 \q__xparse #4 #5 #6
1639 }
1640 \cs_new:Npn \__xparse_expandable_grab_E_loop:nnnNNw
1641 #1#2#3#4#5#6 \q_nil #7 \q_mark #8
1642 {
1643 \quark_if_nil:NTF #4
1644 { \__xparse_expandable_grab_E_end:nnw {#1} {#3} }
1645 {
1646 \tl_if_novalue:nTF {#8}
1647 { \str_if_eq:onTF { #4 { } #1 #5 } {#5} }
1648 { \use_ii:nn }
1649 { \__xparse_expandable_grab_E_find:w { #2 #4 #5 #6 } {#3} ~ }
1650 {
1651 \__xparse_expandable_grab_E_loop:nnnNNw
1652 {#1} { #2 #4 #5 } { #3 {#8} }
1653 #6 \q_nil #7 \q_mark
1654 }
1655 }
1656 }
1657 \cs_new:Npn \__xparse_expandable_grab_E_find:w #1 \q__xparse #2#3#4
1658 { #4 { \__xparse_expandable_grab_E_find:nnw #1 \q__xparse #2 #3 #4 } }
1659 \cs_new:Npn \__xparse_expandable_grab_E_find:nnw #1#2#3 \q_nil #4 \q__xparse #5#6#7#8
1660 { \__xparse_expandable_grab_E_aux:w {#1} { #2 {#8} #3 } #4 \q__xparse #5 #6 #7 }
1661 \cs_new:Npn \__xparse_expandable_grab_E_end:nnw #1#2#3 \q__xparse #4#5#6
1662 { #3 #2 \q__xparse #4 #5 {#1} }
1663 \cs_new:Npn \__xparse_expandable_grab_m:w #1 \q__xparse #2#3
1664 { #3 { \__xparse_expandable_grab_m_aux:wNn #1 \q__xparse #2 #3 } }
1665 \cs_new:Npn \__xparse_expandable_grab_m_long:w #1 \q__xparse #2#3
1666 { #2 { \__xparse_expandable_grab_m_aux:wNn #1 \q__xparse #2 #3 } }
1667 \cs_new:Npn \__xparse_expandable_grab_m_aux:wNn #1 \q__xparse #2#3#4
1668 { #1 {#4} \q__xparse #2 #3 }
1669 \cs_new:Npn \__xparse_expandable_grab_R:w #1 \q__xparse #2#3
1670 { #2 { \__xparse_expandable_grab_R_aux:NNNwNNn #1 \q__xparse #2#3 } }
1671 \cs_set_protected:Npn \__xparse_tmp:w #1
1672 {
1673 \cs_new:Npn \__xparse_expandable_grab_R_aux:NNNwNNn ##1##2##3##4 \q__xparse ##5##6##7
1674 {
1675 \str_if_eq:nnTF {##7} {##2}
1676 {
1677 \str_if_eq:onTF
1678 { ##1 { } { } ##7 ##2 \q__xparse ##3 }
1679 { { } {##2} { } }
1680 }
1681 { \use_ii:nn }
1682 {
1683 ##1
1684 { \__xparse_expandable_grab_D:NNNwNNnnn ##1##2##3##4 \q__xparse ##5##6 }
1685 \q_nil { } ##2 \ERROR \q__xparse \ERROR
1686 }
1687 {
1688 \__kernel_msg_expandable_error:nnff
1689 { xparse } { missing-required }
1690 { \exp_args:Nf \tl_trim_spaces:n { \token_to_str:N ##5 } }
1691 { \tl_to_str:n {##2} }
1692 ##4 {#1} \q__xparse ##5 ##6 {##7}
1693 }
1694 }
1695 }
1696 \exp_args:No \__xparse_tmp:w { \c_novalue_tl }
1697 \cs_new:Npn \__xparse_expandable_grab_R_alt:w #1 \q__xparse #2#3
1698 { #2 { \__xparse_expandable_grab_R_alt_aux:NNwNNn #1 \q__xparse #2#3 } }
1699 \cs_set_protected:Npn \__xparse_tmp:w #1
1700 {
1701 \cs_new:Npn \__xparse_expandable_grab_R_alt_aux:NNwNNn ##1##2##3 \q__xparse ##4##5##6
1702 {
1703 \str_if_eq:nnTF {##6} {##2}
1704 {
1705 \str_if_eq:onTF
1706 { ##1 { } ##6 ##2 ##2 }
1707 { { } ##2 }
1708 }
1709 { \use_ii:nn }
1710 {
1711 ##1
1712 { \__xparse_expandable_grab_D_alt:NNwn ##4 ##5 ##3 \q__xparse }
1713 ##6 \ERROR
1714 }
1715 {
1716 \__kernel_msg_expandable_error:nnff
1717 { xparse } { missing-required }
1718 { \exp_args:Nf \tl_trim_spaces:n { \token_to_str:N ##4 } }
1719 { \tl_to_str:n {##2} }
1720 ##3 {#1} \q__xparse ##4 ##5 {##6}
1721 }
1722 }
1723 }
1724 \exp_args:No \__xparse_tmp:w { \c_novalue_tl }
1725 \cs_new:Npn \__xparse_expandable_grab_t:w #1 \q__xparse #2#3
1726 { #2 { \__xparse_expandable_grab_t_aux:NNwn #1 \q__xparse #2 #3 } }
1727 \cs_new:Npn \__xparse_expandable_grab_t_aux:NNwn #1#2#3 \q__xparse #4#5#6
1728 {
1729 \str_if_eq:onTF { #1 { } #6 #2 } {#2}
1730 { #3 { \BooleanTrue } \q__xparse #4 #5 }
1731 { #3 { \BooleanFalse } \q__xparse #4 #5 {#6} }
1732 }
1733 \cs_new_eq:NN \__xparse_expandable_grab_u:w \prg_do_nothing:
1734 \cs_new:Npn \__xparse_put_arg_expandable:nw #1#2 \q__xparse { #2 {#1} \q__xparse }
1735 \cs_generate_variant:Nn \__xparse_put_arg_expandable:nw { o }
1736 \cs_new_protected:Npn \__xparse_bool_reverse:N #1
1737 {
1738 \bool_if:NTF #1
1739 { \tl_set:Nn \ProcessedArgument { \c_false_bool } }
1740 { \tl_set:Nn \ProcessedArgument { \c_true_bool } }
1741 }
1742 \seq_new:N \l__xparse_split_list_seq
1743 \tl_new:N \l__xparse_split_list_tl
1744 \cs_new_protected:Npn \__xparse_split_list:nn #1#2
1745 {
1746 \tl_if_single:nTF {#1}
1747 {
1748 \token_if_cs:NTF #1
1749 { \__xparse_split_list_multi:nn {#1} {#2} }
1750 { \__xparse_split_list_single:Nn #1 {#2} }
1751 }
1752 { \__xparse_split_list_multi:nn {#1} {#2} }
1753 }
1754 \cs_new_protected:Npn \__xparse_split_list_multi:nn #1#2
1755 {
1756 \seq_set_split:Nnn \l__xparse_split_list_seq {#1} {#2}
1757 \tl_clear:N \ProcessedArgument
1758 \seq_map_inline:Nn \l__xparse_split_list_seq
1759 { \tl_put_right:Nn \ProcessedArgument { {##1} } }
1760 }
1761 \cs_generate_variant:Nn \__xparse_split_list_multi:nn { nV }
1762 \group_begin:
1763 \char_set_catcode_active:N \^^@
1764 \cs_new_protected:Npn \__xparse_split_list_single:Nn #1#2
1765 {
1766 \tl_set:Nn \l__xparse_split_list_tl {#2}
1767 \group_begin:
1768 \char_set_lccode:nn { `\^^@ } { `#1 }
1769 \tex_lowercase:D
1770 {
1771 \group_end:
1772 \tl_replace_all:Nnn \l__xparse_split_list_tl { ^^@ }
1773 } {#1}
1774 \__xparse_split_list_multi:nV {#1} \l__xparse_split_list_tl
1775 }
1776 \group_end:
1777 \cs_new_protected:Npn \__xparse_split_argument:nnn #1#2#3
1778 {
1779 \__xparse_split_list:nn {#2} {#3}
1780 \exp_args:Nf \__xparse_split_argument_aux:nnnn
1781 { \tl_count:N \ProcessedArgument }
1782 {#1} {#2} {#3}
1783 }
1784 \cs_new_protected:Npn \__xparse_split_argument_aux:nnnn #1#2#3#4
1785 {
1786 \int_compare:nNnF {#1} = { #2 + 1 }
1787 {
1788 \int_compare:nNnTF {#1} > { #2 + 1 }
1789 {
1790 \tl_set:Nx \ProcessedArgument
1791 {
1792 \exp_last_unbraced:NnNo
1793 \__xparse_split_argument_aux:n
1794 { #2 + 1 }
1795 \use_none_delimit_by_q_stop:w
1796 \ProcessedArgument
1797 \q_stop
1798 }
1799 \__kernel_msg_error:nnxxx { xparse } { split-excess-tokens }
1800 { \tl_to_str:n {#3} } { \int_eval:n { #2 + 1 } }
1801 { \tl_to_str:n {#4} }
1802 }
1803 {
1804 \tl_put_right:Nx \ProcessedArgument
1805 {
1806 \prg_replicate:nn { #2 + 1 - (#1) }
1807 { { \exp_not:V \c_novalue_tl } }
1808 }
1809 }
1810 }
1811 }
1812 \cs_new:Npn \__xparse_split_argument_aux:n #1
1813 { \prg_replicate:nn {#1} { \__xparse_split_argument_aux:wn } }
1814 \cs_new:Npn \__xparse_split_argument_aux:wn #1 \use_none_delimit_by_q_stop:w #2
1815 {
1816 \exp_not:n { {#2} }
1817 #1
1818 \use_none_delimit_by_q_stop:w
1819 }
1820 \cs_new_protected:Npn \__xparse_trim_spaces:n #1
1821 { \tl_set:Nx \ProcessedArgument { \tl_trim_spaces:n {#1} } }
1822 \cs_new_protected:Npn \__xparse_get_arg_spec_error:N #1
1823 {
1824 \bool_set_false:N \l__xparse_environment_bool
1825 \tl_set:Nn \l__xparse_fn_tl {#1}
1826 \__xparse_get_arg_spec_error_aux:n { \cs_if_exist:NTF #1 }
1827 }
1828 \cs_new_protected:Npn \__xparse_get_arg_spec_error:n #1
1829 {
1830 \bool_set_true:N \l__xparse_environment_bool
1831 \str_set:Nx \l__xparse_environment_str {#1}
1832 \__xparse_get_arg_spec_error_aux:n
1833 { \cs_if_exist:cTF { \l__xparse_environment_str } }
1834 }
1835 \cs_new_protected:Npn \__xparse_get_arg_spec_error_aux:n #1
1836 {
1837 #1
1838 {
1839 \__kernel_msg_error:nnx { xparse } { non-xparse }
1840 { \__xparse_environment_or_command: }
1841 }
1842 {
1843 \__kernel_msg_error:nnx { xparse } { unknown }
1844 { \__xparse_environment_or_command: }
1845 }
1846 }
1847 \cs_new_protected:Npn \__xparse_get_arg_spec:NTF #1#2#3
1848 {
1849 \__xparse_cmd_if_xparse:NTF #1
1850 {
1851 \tl_set:Nx \ArgumentSpecification { \tl_item:Nn #1 { 2 } }
1852 #2
1853 }
1854 {#3}
1855 }
1856 \cs_new_protected:Npn \__xparse_get_arg_spec:N #1
1857 {
1858 \__xparse_get_arg_spec:NTF #1 { }
1859 { \__xparse_get_arg_spec_error:N #1 }
1860 }
1861 \cs_new_protected:Npn \__xparse_get_arg_spec:n #1
1862 {
1863 \exp_args:Nc \__xparse_get_arg_spec:NTF
1864 { environment~ \tl_to_str:n {#1} }
1865 { }
1866 { \__xparse_get_arg_spec_error:n {#1} }
1867 }
1868 \tl_new:N \ArgumentSpecification
1869 \cs_new_protected:Npn \__xparse_show_arg_spec:N #1
1870 {
1871 \__xparse_get_arg_spec:NTF #1
1872 { \tl_show:N \ArgumentSpecification }
1873 { \__xparse_get_arg_spec_error:N #1 }
1874 }
1875 \cs_new_protected:Npn \__xparse_show_arg_spec:n #1
1876 {
1877 \exp_args:Nc \__xparse_get_arg_spec:NTF
1878 { environment~ \tl_to_str:n {#1} }
1879 { \tl_show:N \ArgumentSpecification }
1880 { \__xparse_get_arg_spec_error:n {#1} }
1881 }
1882 \cs_new_protected:Npn \__xparse_check_definable:nNT #1
1883 { \tl_trim_spaces_apply:nN {#1} \__xparse_check_definable_aux:nN }
1884 \group_begin:
1885 \char_set_catcode_active:n { `? }
1886 \cs_new_protected:Npn \__xparse_check_definable_aux:nN #1#2
1887 {
1888 \group_begin:
1889 \tl_if_single_token:nTF {#1}
1890 {
1891 \int_set:Nn \tex_escapechar:D { 92 }
1892 \exp_args:Nx \tl_if_empty:nTF
1893 { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
1894 {
1895 \exp_args:Nx \char_set_lccode:nn
1896 { ` \str_head:n {#1} } { `? }
1897 \tex_lowercase:D { \tl_if_eq:nnTF {#1} } { ? }
1898 { \group_end: \use_iii:nnn }
1899 { \group_end: \use_i:nnn }
1900 }
1901 { \group_end: \use_iii:nnn }
1902 }
1903 { \group_end: \use_ii:nnn }
1904 {
1905 \__kernel_msg_error:nnxx { xparse } { not-definable }
1906 { \tl_to_str:n {#1} } { \token_to_str:N #2 }
1907 }
1908 {
1909 \__kernel_msg_error:nnxx { xparse } { not-one-token }
1910 { \tl_to_str:n {#1} } { \token_to_str:N #2 }
1911 }
1912 }
1913 \group_end:
1914 \cs_new_protected:Npn \__xparse_token_if_cs:NTF #1
1915 {
1916 \group_begin:
1917 \int_set:Nn \tex_escapechar:D { 92 }
1918 \exp_args:Nx \tl_if_empty:nTF
1919 { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
1920 { \group_end: \use_ii:nn }
1921 { \group_end: \use_i:nn }
1922 }
1923 \cs_new:Npn \__xparse_tl_mapthread_function:NNN #1#2#3
1924 {
1925 \exp_after:wN \exp_after:wN
1926 \exp_after:wN \__xparse_tl_mapthread_loop:w
1927 \exp_after:wN \exp_after:wN
1928 \exp_after:wN #3
1929 \exp_after:wN #1
1930 \exp_after:wN \q_recursion_tail
1931 \exp_after:wN \q_mark
1932 #2
1933 \q_recursion_tail
1934 \q_recursion_stop
1935 }
1936 \cs_new:Npn \__xparse_tl_mapthread_function:nnN #1#2#3
1937 {
1938 \__xparse_tl_mapthread_loop:w #3
1939 #1 \q_recursion_tail \q_mark
1940 #2 \q_recursion_tail \q_recursion_stop
1941 }
1942 \cs_new:Npn \__xparse_tl_mapthread_loop:w #1#2#3 \q_mark #4
1943 {
1944 \quark_if_recursion_tail_stop:n {#2}
1945 \quark_if_recursion_tail_stop:n {#4}
1946 #1 {#2} {#4}
1947 \__xparse_tl_mapthread_loop:w #1#3 \q_mark
1948 }
1949 \cs_new_protected:Npn \__xparse_cmd_if_xparse:NTF #1
1950 {
1951 \exp_args:Nf \str_case_e:nnTF
1952 {
1953 \exp_args:Nf \tl_if_empty:nT { \cs_argument_spec:N #1 }
1954 {
1955 \exp_last_unbraced:Nf \__xparse_cmd_if_xparse_aux:w
1956 { \cs_replacement_spec:N #1 } ~ \q_stop
1957 }
1958 }
1959 {
1960 { \token_to_str:N \__xparse_start:nNNnnn } { }
1961 { \token_to_str:N \__xparse_start_expandable:nNNNNn } { }
1962 { \token_to_str:N \__xparse_start_env:nnnnn } { }
1963 }
1964 }
1965 \cs_new:Npn \__xparse_cmd_if_xparse_aux:w #1 ~ #2 \q_stop {#1}
1966 \cs_new_protected:Npn \__xparse_peek_nonspace:NTF
1967 { \__xparse_peek_nonspace_aux:nNNTF { } \__xparse_peek_meaning:NTF }
1968 \cs_new_protected:Npn \__xparse_peek_nonspace_remove:NTF
1969 { \__xparse_peek_nonspace_aux:nNNTF { } \__xparse_peek_meaning_remove:NTF }
1970 \cs_new_protected:Npn \__xparse_peek_nonspace_aux:nNNTF #1#2#3#4#5
1971 {
1972 \peek_meaning_remove:NTF \c_space_token
1973 { \__xparse_peek_nonspace_aux:nNNTF { #1 ~ } #2 #3 {#4} {#5} }
1974 { #2 #3 { #4 } { #5 #1 } }
1975 }
1976 \cs_new_protected:Npn \__xparse_peek_meaning:NTF
1977 { \__xparse_peek_meaning_aux:NNTF \c_false_bool }
1978 \cs_new_protected:Npn \__xparse_peek_meaning_remove:NTF
1979 { \__xparse_peek_meaning_aux:NNTF \c_true_bool }
1980 \cs_new_protected:Npn \__xparse_peek_meaning_aux:NNTF #1#2#3#4
1981 {
1982 \tl_set:Nn \l__xparse_tmpa_tl {#3}
1983 \tl_set:Nn \l__xparse_tmpb_tl {#4}
1984 \peek_meaning:NTF #2
1985 {
1986 \token_if_eq_meaning:NNTF #2 \c_group_begin_token
1987 { \__xparse_peek_true_remove:Nw #1 }
1988 {
1989 \__xparse_token_if_cs:NTF #2
1990 { \__xparse_peek_cs_check_equal:NNN #1 #2 }
1991 { \__xparse_peek_true_remove:Nw #1 }
1992 }
1993 }
1994 { \l__xparse_tmpb_tl }
1995 }
1996 \cs_new_protected:Npn \__xparse_peek_cs_check_equal:NNN #1#2#3
1997 {
1998 \str_if_eq:nnTF {#2} {#3}
1999 { \__xparse_peek_true_remove:Nw #1 }
2000 { \l__xparse_tmpb_tl }
2001 #3
2002 }
2003 \cs_new_protected:Npn \__xparse_peek_true_remove:Nw #1
2004 {
2005 \bool_if:NTF #1
2006 {
2007 \tex_afterassignment:D \l__xparse_tmpa_tl
2008 \cs_set_eq:NN \__xparse_tmp:w
2009 }
2010 { \l__xparse_tmpa_tl }
2011 }
2012 \cs_new:Npn \__xparse_environment_or_command:
2013 {
2014 \bool_if:NTF \l__xparse_environment_bool
2015 { environment ~ ' \l__xparse_environment_str ' }
2016 {
2017 command ~ '
2018 \exp_args:Nf \tl_trim_spaces:n
2019 { \exp_after:wN \token_to_str:N \l__xparse_fn_tl }
2020 '
2021 }
2022 }
2023 \tl_const:Nn \c__xparse_ignore_def_tl
2024 { \\ \\ LaTeX~will~ignore~this~entire~definition. }
2025 \__kernel_msg_new:nnnn { xparse } { arg-after-body }
2026 { In~the~definition~of~#1,~b~(body)~argument~must~be~last. }
2027 {
2028 The~'body'~argument~type~is~followed~by~'#2'~in~the~argument~
2029 specification~of~the~#1.~This~is~not~allowed.
2030 \c__xparse_ignore_def_tl
2031 }
2032 \__kernel_msg_new:nnnn { xparse } { bad-arg-spec }
2033 { Bad~argument~specification~'#2'~for~#1. }
2034 {
2035 The~argument~specification~provided~was~not~valid:~
2036 one~or~more~mandatory~pieces~of~information~were~missing.
2037 \c__xparse_ignore_def_tl
2038 }
2039 \__kernel_msg_new:nnnn { xparse } { command-already-defined }
2040 { Command~'#1'~already~defined! }
2041 {
2042 You~have~used~#2~
2043 with~a~command~that~already~has~a~definition. \\ \\
2044 The~existing~definition~of~'#1'~will~not~be~altered.
2045 }
2046 \__kernel_msg_new:nnnn { xparse } { command-not-yet-defined }
2047 { Command ~'#1'~not~yet~defined! }
2048 {
2049 You~have~used~#2~
2050 with~a~command~that~was~never~defined.
2051 \c__xparse_ignore_def_tl
2052 }
2053 \__kernel_msg_new:nnnn { xparse } { environment-already-defined }
2054 { Environment~'#1'~already~defined! }
2055 {
2056 You~have~used~\NewDocumentEnvironment
2057 with~an~environment~that~already~has~a~definition. \\ \\
2058 The~existing~definition~of~'#1'~will~not~be~altered.
2059 }
2060 \__kernel_msg_new:nnnn { xparse } { environment-not-yet-defined }
2061 { Environment~'#1'~not~yet~defined! }
2062 {
2063 You~have~used~\RenewDocumentEnvironment
2064 with~an~environment~that~was~never~defined.
2065 \c__xparse_ignore_def_tl
2066 }
2067 \__kernel_msg_new:nnnn { xparse } { expandable-ending-optional }
2068 {
2069 Argument~specification~'#2'~for~expandable~command~'#1'~
2070 ends~with~optional~argument.
2071 }
2072 {
2073 Expandable~commands~must~have~a~final~mandatory~argument~
2074 (or~no~arguments~at~all).~You~cannot~have~a~terminal~optional~
2075 argument~with~expandable~commands.
2076 }
2077 \__kernel_msg_new:nnnn { xparse } { inconsistent-long }
2078 { Inconsistent~long~arguments~for~expandable~command~'#1'. }
2079 {
2080 The~arguments~for~an~expandable~command~must~not~involve~short~
2081 arguments~after~long~arguments.~You~have~tried~to~mix~the~two~types.
2082 }
2083 \__kernel_msg_new:nnnn { xparse } { invalid-command-arg }
2084 { Argument~type~'#2'~not~available~for~#1. }
2085 {
2086 The~letter~'#2'~can~only~be~used~in~environment~argument~
2087 specifications,~not~for~commands.
2088 \\ \\
2089 LaTeX~will~ignore~this~entire~definition.
2090 }
2091 \__kernel_msg_new:nnnn { xparse } { invalid-expandable-argument-type }
2092 { Argument~type~'#2'~not~available~for~expandable~command~'#1'. }
2093 {
2094 The~letter~'#2'~specifies~an~argument~type~which~cannot~be~used~
2095 in~an~expandable~command.
2096 \c__xparse_ignore_def_tl
2097 }
2098 \__kernel_msg_new:nnnn { xparse } { invalid-after-optional-expandably }
2099 {
2100 Argument~type~'#2'~not~available~after~optional~argument~
2101 for~expandable~command~'#1'.
2102 }
2103 {
2104 The~letter~'#2'~specifies~an~argument~type~which~cannot~be~used~
2105 in~an~expandable~command~after~an~optional~argument.
2106 \c__xparse_ignore_def_tl
2107 }
2108 \__kernel_msg_new:nnnn { xparse } { non-trailing-obey-spaces }
2109 { Prefix~'!'~used~before~mandatory~argument~'#2'~of~#1. }
2110 {
2111 The~prefix~'!'~can~only~apply~to~trailing~optional~arguments.
2112 \c__xparse_ignore_def_tl
2113 }
2114 \__kernel_msg_new:nnnn { xparse } { not-definable }
2115 { First~argument~of~'#2'~must~be~a~command. }
2116 {
2117 The~first~argument~of~'#2'~should~be~the~document~command~that~will~
2118 be~defined.~The~provided~argument~'#1'~is~a~character.~Perhaps~a~
2119 backslash~is~missing?
2120 \c__xparse_ignore_def_tl
2121 }
2122 \__kernel_msg_new:nnnn { xparse } { not-one-token }
2123 { First~argument~of~'#2'~must~be~a~command. }
2124 {
2125 The~first~argument~of~'#2'~should~be~the~document~command~that~will~
2126 be~defined.~The~provided~argument~'#1'~contains~more~than~one~
2127 token.~Perhaps~a~backslash~is~missing?
2128 \c__xparse_ignore_def_tl
2129 }
2130 \__kernel_msg_new:nnnn { xparse } { not-single-token }
2131 {
2132 Argument~delimiter~'#2'~for~the~#1~should~be~
2133 a~single~non-space~token.
2134 }
2135 {
2136 The~argument~specification~provided~was~not~valid:~in~a~place~
2137 where~a~single~token~is~required,~LaTeX~found~'#2'.
2138 \c__xparse_ignore_def_tl
2139 }
2140 \__kernel_msg_new:nnnn { xparse } { forbidden-implicit-group-token }
2141 { Argument~delimiter~'#2'~for~the~#1~is~not~allowed. }
2142 {
2143 The~argument~specification~provided~was~not~valid:~the~implicit~
2144 #3-group~token~'#2'~is~not~allowed~as~an~argument~delimiter.
2145 \c__xparse_ignore_def_tl
2146 }
2147 \__kernel_msg_new:nnnn { xparse } { processor-in-expandable }
2148 { Argument~processor~'>{#2}'~cannot~be~used~for~the~expandable~command~'#1'. }
2149 {
2150 The~argument~specification~for~#1~contains~a~processor~function:~
2151 this~is~only~supported~for~standard~robust~commands.
2152 \c__xparse_ignore_def_tl
2153 }
2154 \__kernel_msg_new:nnnn { xparse } { too-many-arguments }
2155 { Too~many~arguments~in~argument~specification~'#2'~of~#1. }
2156 {
2157 The~argument~specification~provided~has~more~than~9~arguments.~
2158 This~cannot~be~implemented.
2159 \c__xparse_ignore_def_tl
2160 }
2161 \__kernel_msg_new:nnnn { xparse } { two-markers }
2162 { Two~'#2'~apply~to~the~same~argument~in~argument~specification~of~#1. }
2163 {
2164 The~argument~specification~provided~has~two~markers~'#2'~applying~
2165 to~the~same~argument;~these~are~redundant.
2166 }
2167 \__kernel_msg_new:nnnn { xparse } { unknown-argument-type }
2168 { Unknown~argument~type~'#2'~for~the~#1. }
2169 {
2170 The~letter~'#2'~does~not~specify~a~known~argument~type.
2171 \c__xparse_ignore_def_tl
2172 }
2173 \__kernel_msg_new:nnnn { xparse } { xparse-argument-type }
2174 { Deprecated~argument~type~'#2'~for~the~#1~requires~xparse. }
2175 {
2176 The~letter~'#2'~specifies~a~known~argument~type~that~requires~
2177 the~xparse~package.
2178 \c__xparse_ignore_def_tl
2179 }
2180 \__kernel_msg_new:nnn { xparse } { if-boolean }
2181 { Invalid~use~\iow_char:N\\IfBooleanTF~{#1} }
2182 \__kernel_msg_new:nnnn { xparse } { loop-in-defaults }
2183 { Defaults~of~#1~have~circular~dependency. }
2184 {
2185 The~default~values~of~two~or~more~arguments~of~the~#1~
2186 depend~on~each~other~in~a~way~that~cannot~be~resolved.
2187 }
2188 \__kernel_msg_new:nnnn { xparse } { missing-required }
2189 { Missing~required~argument~for~#1. }
2190 {
2191 The~current~#1~expects~an~argument~starting~with~'#2'.~
2192 LaTeX~did~not~find~it,~and~will~insert~a~default~value~to~be~processed.
2193 }
2194 \__kernel_msg_new:nnnn { xparse } { non-xparse }
2195 { \str_uppercase:n #1~not~defined~using~xparse. }
2196 {
2197 You~have~asked~for~the~argument~specification~for~the~#1,~
2198 but~this~was~not~defined~using~xparse.
2199 }
2200 \__kernel_msg_new:nnnn { xparse } { split-excess-tokens }
2201 { Too~many~'#1'~tokens~when~trying~to~split~argument. }
2202 {
2203 LaTeX~was~asked~to~split~the~input~'#3'~
2204 at~each~occurrence~of~the~token~'#1',~up~to~a~maximum~of~#2~parts.~
2205 There~were~too~many~'#1'~tokens.
2206 }
2207 \__kernel_msg_new:nnnn { xparse } { unknown }
2208 { Unknown~document~#1. }
2209 {
2210 You~have~asked~for~the~argument~specification~for~the~#1,~
2211 but~it~is~not~defined.
2212 }
2213 \__kernel_msg_new:nnnn { xparse } { verbatim-newline }
2214 { Verbatim~argument~of~#1~ended~by~end~of~line. }
2215 {
2216 The~verbatim~argument~of~the~#1~cannot~contain~more~than~one~line,~
2217 but~the~end~
2218 of~the~current~line~has~been~reached.~You~may~have~forgotten~the~
2219 closing~delimiter.
2220 \\ \\
2221 LaTeX~will~ignore~'#2'.
2222 }
2223 \__kernel_msg_new:nnnn { xparse } { verbatim-tokenized }
2224 { The~verbatim~#1~cannot~be~used~inside~an~argument. }
2225 {
2226 The~#1~takes~a~verbatim~argument.~
2227 It~may~not~appear~within~the~argument~of~another~function.~
2228 It~received~an~illegal~token \tl_if_empty:nF {#3} { ~'#3' } .
2229 \\ \\
2230 LaTeX~will~ignore~'#2'.
2231 }
2232 \__kernel_msg_new:nnn { xparse } { define-command }
2233 {
2234 Defining~command~#1~
2235 with~sig.~'#2'~\msg_line_context:.
2236 }
2237 \__kernel_msg_new:nnn { xparse } { define-environment }
2238 {
2239 Defining~environment~'#1'~
2240 with~sig.~'#2'~\msg_line_context:.
2241 }
2242 \__kernel_msg_new:nnn { xparse } { redefine-command }
2243 {
2244 Redefining~command~#1~
2245 with~sig.~'#2'~\msg_line_context:.
2246 }
2247 \__kernel_msg_new:nnn { xparse } { redefine-environment }
2248 {
2249 Redefining~environment~'#1'~
2250 with~sig.~'#2'~\msg_line_context:.
2251 }
2252 \__kernel_msg_new:nnn { xparse } { optional-mandatory }
2253 {
2254 Since~the~mandatory~argument~'#1'~has~the~same~delimiter~'#2'~
2255 as~a~previous~optional~argument,~it~will~not~be~possible~to~
2256 omit~all~optional~arguments~when~calling~this~command.
2257 }
2258 \__kernel_msg_new:nnn { xparse } { unsupported-let }
2259 {
2260 The~command~'#1'~was~undefined~but~not~the~associated~commands~
2261 '#1~code'~and/or~'#1~defaults'.~Maybe~you~tried~using~
2262 \iow_char:N\\let.~This~may~lead~to~an~infinite~loop.
2263 }
2264 \cs_new_eq:NN \BooleanFalse \c_false_bool
2265 \cs_new_eq:NN \BooleanTrue \c_true_bool
2266 \cs_new_protected:Npn \NewDocumentCommand #1#2#3
2267 {
2268 \__xparse_check_definable:nNT {#1} \NewDocumentCommand
2269 {
2270 \cs_if_exist:NTF #1
2271 {
2272 \__kernel_msg_error:nnxx { xparse } { command-already-defined }
2273 { \use:nnn \token_to_str:N #1 { } }
2274 { \token_to_str:N \NewDocumentCommand }
2275 }
2276 { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
2277 }
2278 }
2279 \cs_new_protected:Npn \RenewDocumentCommand #1#2#3
2280 {
2281 \__xparse_check_definable:nNT {#1} \RenewDocumentCommand
2282 {
2283 \cs_if_exist:NTF #1
2284 { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
2285 {
2286 \__kernel_msg_error:nnxx { xparse } { command-not-yet-defined }
2287 { \use:nnn \token_to_str:N #1 { } }
2288 { \token_to_str:N \RenewDocumentCommand }
2289 }
2290 }
2291 }
2292 \cs_new_protected:Npn \ProvideDocumentCommand #1#2#3
2293 {
2294 \__xparse_check_definable:nNT {#1} \ProvideDocumentCommand
2295 { \cs_if_exist:NF #1 { \__xparse_declare_cmd:Nnn #1 {#2} {#3} } }
2296 }
2297 \cs_new_protected:Npn \DeclareDocumentCommand #1#2#3
2298 {
2299 \__xparse_check_definable:nNT {#1} \DeclareDocumentCommand
2300 { \__xparse_declare_cmd:Nnn #1 {#2} {#3} }
2301 }
2302 \cs_new_protected:Npn \NewDocumentEnvironment #1#2#3#4
2303 {
2304 \cs_if_exist:cTF {#1}
2305 { \__kernel_msg_error:nnx { xparse } { environment-already-defined } {#1} }
2306 { \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} }
2307 }
2308 \cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4
2309 {
2310 \cs_if_exist:cTF {#1}
2311 { \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} }
2312 { \__kernel_msg_error:nnx { xparse } { environment-not-yet-defined } {#1} }
2313 }
2314 \cs_new_protected:Npn \ProvideDocumentEnvironment #1#2#3#4
2315 { \cs_if_exist:cF {#1} { \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} } }
2316 \cs_new_protected:Npn \DeclareDocumentEnvironment #1#2#3#4
2317 { \__xparse_declare_env:nnnn {#1} {#2} {#3} {#4} }
2318 \cs_new_protected:Npn \NewExpandableDocumentCommand #1#2#3
2319 {
2320 \__xparse_check_definable:nNT {#1} \NewExpandableDocumentCommand
2321 {
2322 \cs_if_exist:NTF #1
2323 {
2324 \__kernel_msg_error:nnxx { xparse } { command-already-defined }
2325 { \use:nnn \token_to_str:N #1 { } }
2326 { \token_to_str:N \NewExpandableDocumentCommand }
2327 }
2328 { \__xparse_declare_expandable_cmd:Nnn #1 {#2} {#3} }
2329 }
2330 }
2331 \cs_new_protected:Npn \RenewExpandableDocumentCommand #1#2#3
2332 {
2333 \__xparse_check_definable:nNT {#1} \RenewExpandableDocumentCommand
2334 {
2335 \cs_if_exist:NTF #1
2336 { \__xparse_declare_expandable_cmd:Nnn #1 {#2} {#3} }
2337 {
2338 \__kernel_msg_error:nnxx { xparse } { command-not-yet-defined }
2339 { \use:nnn \token_to_str:N #1 { } }
2340 { \token_to_str:N \RenewExpandableDocumentCommand }
2341 }
2342 }
2343 }
2344 \cs_new_protected:Npn \ProvideExpandableDocumentCommand #1#2#3
2345 {
2346 \__xparse_check_definable:nNT {#1} \ProvideExpandableDocumentCommand
2347 {
2348 \cs_if_exist:NF #1
2349 { \__xparse_declare_expandable_cmd:Nnn #1 {#2} {#3} }
2350 }
2351 }
2352 \cs_new_protected:Npn \DeclareExpandableDocumentCommand #1#2#3
2353 {
2354 \__xparse_check_definable:nNT {#1} \DeclareExpandableDocumentCommand
2355 { \__xparse_declare_expandable_cmd:Nnn #1 {#2} {#3} }
2356 }
2357 \cs_new:Npn \IfBooleanTF #1
2358 {
2359 \tl_if_single:nF {#1}
2360 { \prg_break:n { \use:n } }
2361 \tl_if_single_token:nF #1
2362 { \prg_break:n { \use:n } }
2363 \token_if_eq_meaning:NNT #1 \c_true_bool
2364 { \prg_break:n { \use_ii:nnn } }
2365 \token_if_eq_meaning:NNT #1 \c_false_bool
2366 { \prg_break:n { \use_iii:nnn } }
2367 \prg_break:n { \use:n }
2368 \prg_break_point:
2369 {
2370 \__kernel_msg_expandable_error:nnn { xparse } { if-boolean } {#1}
2371 \use_ii:nn
2372 }
2373 }
2374 \cs_new:Npn \IfBooleanT #1#2 { \IfBooleanTF {#1} {#2} { } }
2375 \cs_new:Npn \IfBooleanF #1 { \IfBooleanTF {#1} { } }
2376 \cs_new_eq:NN \IfNoValueF \tl_if_novalue:nF
2377 \cs_new_eq:NN \IfNoValueT \tl_if_novalue:nT
2378 \cs_new_eq:NN \IfNoValueTF \tl_if_novalue:nTF
2379 \cs_new:Npn \IfValueF { \tl_if_novalue:nT }
2380 \cs_new:Npn \IfValueT { \tl_if_novalue:nF }
2381 \cs_new:Npn \IfValueTF #1#2#3 { \tl_if_novalue:nTF {#1} {#3} {#2} }
2382 \tl_new:N \ProcessedArgument
2383 \cs_new_eq:NN \ReverseBoolean \__xparse_bool_reverse:N
2384 \cs_new_eq:NN \SplitArgument \__xparse_split_argument:nnn
2385 \cs_new_eq:NN \SplitList \__xparse_split_list:nn
2386 \cs_new_eq:NN \TrimSpaces \__xparse_trim_spaces:n
2387 \cs_new_eq:NN \ProcessList \tl_map_function:nN
2388 \cs_new_protected:Npn \GetDocumentCommandArgSpec #1
2389 {
2390 \__xparse_check_definable:nNT {#1} \GetDocumentCommandArgSpec
2391 { \__xparse_get_arg_spec:N #1 }
2392 }
2393 \cs_new_eq:NN \GetDocumentEnvironmentArgSpec \__xparse_get_arg_spec:n
2394 \cs_new_protected:Npn \ShowDocumentCommandArgSpec #1
2395 {
2396 \__xparse_check_definable:nNT {#1} \ShowDocumentCommandArgSpec
2397 { \__xparse_show_arg_spec:N #1 }
2398 }
2399 \cs_new_eq:NN \ShowDocumentEnvironmentArgSpec \__xparse_show_arg_spec:n
2400 %%
2401 %%
2402 %% End of file `xparse-2018-04-12.sty'.