Debian Codegraph @

texmf-dist/tex/latex/l3packages/xparse/xparse-generic.tex

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