| 1 |
% \iffalse meta-comment |
| 2 |
% !TEX program = pdfLaTeX |
| 3 |
%<*internal> |
| 4 |
\iffalse |
| 5 |
%</internal> |
| 6 |
%<*readme> |
| 7 |
----------------------------------------------------------------- |
| 8 |
##### Comma separated list partition, differentiated mapping |
| 9 |
- Source repository: https://github.com/rogard/clistmap |
| 10 |
- Released under the LaTeX Project Public License v1.3c or later |
| 11 |
- See http://www.latex-project.org/lppl.txt |
| 12 |
----------------------------------------------------------------- |
| 13 |
%</readme> |
| 14 |
%<*internal> |
| 15 |
\fi |
| 16 |
\def\nameofplainTeX{plain} |
| 17 |
\ifx\fmtname\nameofplainTeX\else |
| 18 |
\expandafter\begingroup |
| 19 |
\fi |
| 20 |
%</internal> |
| 21 |
%<*install> |
| 22 |
\input l3docstrip.tex |
| 23 |
\keepsilent |
| 24 |
\askforoverwritefalse |
| 25 |
\preamble |
| 26 |
---------------------------------------------------------------------------- |
| 27 |
clistmap --- Partition a comma separated list, map differentiatedly across |
| 28 |
components |
| 29 |
Released under the LaTeX Project Public License v1.3c or later |
| 30 |
See http://www.latex-project.org/lppl.txt |
| 31 |
---------------------------------------------------------------------------- |
| 32 |
|
| 33 |
\endpreamble |
| 34 |
\postamble |
| 35 |
|
| 36 |
Copyright (C) 2022 by Erwann Rogard |
| 37 |
|
| 38 |
This work may be distributed and/or modified under the |
| 39 |
conditions of the LaTeX Project Public License (LPPL), either |
| 40 |
version 1.3c of this license or (at your option) any later |
| 41 |
version. The latest version of this license is in the file: |
| 42 |
|
| 43 |
http://www.latex-project.org/lppl.txt |
| 44 |
|
| 45 |
This work is "maintained" (as per LPPL maintenance status) by |
| 46 |
Erwann Rogard. |
| 47 |
|
| 48 |
This work consists of the file clistmap.dtx and the derived files: |
| 49 |
clistmap.sty, and clistmap.pdf. |
| 50 |
|
| 51 |
\endpostamble |
| 52 |
\generate{ |
| 53 |
\file{\jobname.sty}{\from{\jobname.dtx}{package}} |
| 54 |
} |
| 55 |
%</install> |
| 56 |
%<install> \endbatchfile |
| 57 |
%<*internal> |
| 58 |
\generate{ |
| 59 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 60 |
} |
| 61 |
\nopreamble\nopostamble |
| 62 |
\generate{ |
| 63 |
\file{README.md}{\from{\jobname.dtx}{readme}} |
| 64 |
} |
| 65 |
\ifx\fmtname\nameofplainTeX |
| 66 |
\expandafter\endbatchfile |
| 67 |
\else |
| 68 |
\expandafter\endgroup |
| 69 |
\fi |
| 70 |
%</internal> |
| 71 |
%<package> \NeedsTeXFormat{LaTeX2e}[2021-06-01] |
| 72 |
%<package> \RequirePackage{xparse, xtemplate, l3keys2e}[2021-06-01] |
| 73 |
%<package> \RequirePackage{erw-l3}[2022-01-28] |
| 74 |
%<package> \ProvidesExplPackage |
| 75 |
%<package> {clistmap} %^^A Package name |
| 76 |
%<package> {2022-01-29} %^^A Release date |
| 77 |
%<package> {1.2} %^^A Release version |
| 78 |
%<package> {Partition a comma separated list, %^^A Description |
| 79 |
%<package> map differentiatedly across components} |
| 80 |
%<*driver> |
| 81 |
\documentclass{l3doc} |
| 82 |
\EnableCrossrefs |
| 83 |
\CodelineIndex |
| 84 |
\RecordChanges |
| 85 |
% ^^A\documentclass[full, show-notes]{l3doc} |
| 86 |
% ^^A \listfiles |
| 87 |
\usepackage{amsmath, amssymb, bookmark, enumitem, mathtools, microtype, tcolorbox, xparse, clistmap} |
| 88 |
\usepackage[bibencoding=auto, backend=biber, sorting=ynt]{biblatex} |
| 89 |
\begin{filecontents*}{\jobname.bib} |
| 90 |
@manual{interface3, |
| 91 |
title = {The \LaTeX3 interfaces}, |
| 92 |
author = {The \LaTeX3 Project Team}, |
| 93 |
year = {2019}, |
| 94 |
note = {\url{https://ctan.math.washington.edu/tex-archive/macros/latex/contrib/l3kernel/expl3.pdf}}, |
| 95 |
annote = {} } |
| 96 |
\end{filecontents*} |
| 97 |
\addbibresource{\jobname.bib} |
| 98 |
\usepackage[french, german, english]{babel} |
| 99 |
\usepackage[T1]{fontenc} |
| 100 |
\newlist{descr}{description}{3} |
| 101 |
\setlist[descr]{nosep, align=left, itemindent=0pt, font=\sffamily\tiny} |
| 102 |
\ProvideDocumentCommand{\docfillblank}{}{\begin{minipage}[t]{\linewidth}\end{minipage}} |
| 103 |
\ProvideDocumentCommand{\docpipe}{}{\textbar} |
| 104 |
\ProvideDocumentCommand{\docexp}{}{\texttt{e}\docpipe{}\texttt{f}\docpipe{}\texttt{x}} |
| 105 |
\ExplSyntaxOn |
| 106 |
% ^^A *** Kernel |
| 107 |
\cs_generate_variant:Nn\tl_map_inline:nn{e} |
| 108 |
% ^^A *** Sectioning |
| 109 |
\tl_gset:Nn \partname {Part}%^^A allows to test w/o babel |
| 110 |
\ExplSyntaxOff |
| 111 |
% ^^A *** Listing |
| 112 |
\tcbuselibrary{listings, breakable} |
| 113 |
\newtcblisting[auto counter] |
| 114 |
{listing}[2][]{ |
| 115 |
noparskip, |
| 116 |
breakable, |
| 117 |
colback=white, |
| 118 |
colframe=black, |
| 119 |
opacitybacktitle=.8,% |
| 120 |
fonttitle=\bfseries, |
| 121 |
title={Listing~\thetcbcounter. #1}, |
| 122 |
arc=0pt, |
| 123 |
outer arc=0pt, |
| 124 |
boxrule=1pt, |
| 125 |
listing and text, |
| 126 |
#2} |
| 127 |
\usepackage{hyperref} %^^A comes last |
| 128 |
\begin{document} |
| 129 |
\DocInput{\jobname.dtx} |
| 130 |
\end{document} |
| 131 |
%</driver> |
| 132 |
% \fi |
| 133 |
% |
| 134 |
% \GetFileInfo{\jobname.sty} |
| 135 |
% \title{The \pkg{clistmap}~package\thanks{^^A |
| 136 |
% This file describes version \fileversion, last revised \filedate.^^A |
| 137 |
% }^^A |
| 138 |
% } |
| 139 |
% \author{Erwann Rogard\thanks{first.lastname at gmail.com}} |
| 140 |
% |
| 141 |
% \date{Released \filedate} |
| 142 |
% \begin{documentation} |
| 143 |
% \maketitle |
| 144 |
% \begin{abstract} |
| 145 |
% Let \meta{clist}$\doteq$\meta{e_1}|,...,|\meta{e_n}\cite[l3clist]{interface3}. |
| 146 |
% This package provides a key-based interface for defining templates whose job is to |
| 147 |
% partition \meta{clist}, and map differentiatedly across its components. |
| 148 |
% \cs{clistmap:nnn}\Arg{clist}|{...,|\meta{instance_i}|,...}|\meta{args} iterates over the $i$'s. |
| 149 |
% Implicit in \meta{instance_i} is \meta{rule sequence_i} (the template), \meta{cs name_i}, |
| 150 |
% and \meta{signature_i}$=$\meta{args}' signature. |
| 151 |
% A sequence of instances can be made into a new instance: |
| 152 |
% |serial_math_and:N|$\doteq$|{first_math:N,serial_rest_math_and:N}|, and likewise for the second component. |
| 153 |
% |$\clistmap_inline:nnn{Z,C,Q,R}{serial_math_and:N}|\\|{\mathbb{#1}}$| expands to |
| 154 |
% \ExplSyntaxOn$\clistmap_inline:nnn{Z,C,Q,R}{serial_math_and:N}{\mathbb{#1}}$\ExplSyntaxOff. |
| 155 |
% \cs{clistmap:nnnn} takes an additional argument, \meta{chain}$\sim$|end|\docpipe|append|\docpipe|nest|\docpipe|join|, |
| 156 |
% narrowing the set of instances needed to obtain a particular behaviour. |
| 157 |
% \end{abstract} |
| 158 |
% |
| 159 |
% \tableofcontents |
| 160 |
% |
| 161 |
% \part{Usage}\label{part:usage} |
| 162 |
% \section{Overview} |
| 163 |
% Let \meta{clist}$\equiv$\meta{head}|,|\meta{rest}. |
| 164 |
% The lifecycle has four stages. |
| 165 |
% First, one provides templates called \emph{rule}s, parameterized by |
| 166 |
% \meta{rule sequence}, \meta{cs name}, and \meta{signature}. |
| 167 |
% Typically, a rule checks for the recursion tail\cite[l3quark]{interface3} in some combination of \meta{head} and \meta{rest}, |
| 168 |
% based on which it does either of: stop, recurse, forward to \meta{rule sequence}, |
| 169 |
% and in each case optionally expands \cs[no-index]{\meta{cs name}:\meta{signature}n}\Arg{args}\Arg{head}. |
| 170 |
% Second, one associates keys to sequences of rules, \emph{rule sequence}. |
| 171 |
% Those preset are |first|, |middle|, |last|, |serial_second|, and |serial_last|, |
| 172 |
% for which the stated expression is evaluated for each \meta{e_i} in their respective subsets. |
| 173 |
% Brace groups are preserved. |
| 174 |
% Third, one declares \emph{instance}s of combinations of |
| 175 |
% \meta{rule sequence}, \meta{cs name}, and \meta{signature}. For example, |
| 176 |
% |middle_comma:N| and |serial_middle:| |
| 177 |
% bind together |middle| and |,#1{#2}|, and |,~#1|, respectively. |
| 178 |
% Fourth, define sequences of instances under the constraint that \meta{signature} is identical across them, |
| 179 |
% \emph{instance sequence}s. Among presets, |
| 180 |
% |comma:N| and |serial:| comprise in their natural order the matches for |(?:first_apply|\docpipe|comma_middle|\docpipe|comma_last):N|, |
| 181 |
% and |(?:first_apply|\docpipe|serial_middle|\docpipe|serial_second|\docpipe|serial_last):|, respectively. |
| 182 |
% They expand to |#1{|\meta{e_1}|},...,#1{|\meta{e_n}|}|, and \meta{e_1}|,~...,~and~|\meta{e_n}, respectively. |
| 183 |
% \cs{clistmap:nnn} works the same with an instance sequence or the list of its constituents. |
| 184 |
% |
| 185 |
% \section{Programming} |
| 186 |
% \subsection{\textsf{key}} |
| 187 |
% \begin{function}{rule} |
| 188 |
% \begin{syntax} |
| 189 |
% \cs{clistmap_keys_set:n}|{ rule = |\Arg{key}\Arg{code}| }| |
| 190 |
% \end{syntax} |
| 191 |
% \begin{descr} |
| 192 |
% \item[Parameter semantics]\docfillblank |
| 193 |
% \begin{descr} |
| 194 |
% \item[\#1] \meta{rule sequence} |
| 195 |
% \item[\#2] \meta{cs name} |
| 196 |
% \item[\#3] \meta{signature} |
| 197 |
% \item[\#4] \meta{head is group} |
| 198 |
% \item[\#5] \meta{arguments} |
| 199 |
% \item[\#6] \meta{clist head} |
| 200 |
% \item[\#7] \meta{clist rest} |
| 201 |
% \end{descr} |
| 202 |
% \item[Requirement] \meta{code} is in terms of \texttt{\#1-\#7} |
| 203 |
% \end{descr} |
| 204 |
% \end{function} |
| 205 |
% \begin{function}{rule_if_rest_is_tail_eval_else, rule_if_empty_stop_else} |
| 206 |
% \begin{syntax} |
| 207 |
% \cs{clistmap_keys_set:n}|{ rule_if_rest_is_tail_eval_else = |\Arg{name}\Arg{code}| }| |
| 208 |
% \end{syntax} |
| 209 |
% \begin{descr} |
| 210 |
% \item[Semantics] Specialization of |rule| |
| 211 |
% \end{descr} |
| 212 |
% \end{function} |
| 213 |
% \begin{function}{rule_sequence} |
| 214 |
% \begin{syntax} |
| 215 |
% \cs{clistmap_keys_set:n}|{ rule_sequence = {...,|\meta{key_j} = |{ ...|\Arg{rule_i}|...},...} }| |
| 216 |
% \end{syntax} |
| 217 |
% \end{function} |
| 218 |
% \begin{function}{instance} |
| 219 |
% \begin{syntax} |
| 220 |
% \cs{clistmap_keys_set:n}|{ instance = { |\meta{key prefix}| = |\Arg{rule sequence}\Arg{cs name}\Arg{signature}| } }| |
| 221 |
% \end{syntax} |
| 222 |
% \begin{descr} |
| 223 |
% \item[Semantics] Associates \cs{clistmap_instance_key:nn}\Arg{key prefix}\Arg{signature} with the RHS of \meta{key prefix}| = | |
| 224 |
% \end{descr} |
| 225 |
% \end{function} |
| 226 |
% \begin{function}{instance_sequence} |
| 227 |
% \begin{syntax} |
| 228 |
% \cs{clistmap_keys_set:n}|{ instance_sequence = { |\meta{key} = |{ ...,|\meta{instance_i}|,...},... } }| |
| 229 |
% \end{syntax} |
| 230 |
% \end{function} |
| 231 |
% \subsection{\textsf{cs}} |
| 232 |
% \begin{function}{clistmap_keys_set:n} |
| 233 |
% \begin{syntax} |
| 234 |
% \cs{clistmap_keys_set:n}\Arg{keyval list} |
| 235 |
% \end{syntax} |
| 236 |
% \end{function} |
| 237 |
% \begin{function}[EXP]{\clistmap_info_clist:nn, \clistmap_info_prop:nn} |
| 238 |
% \begin{syntax} |
| 239 |
% \cs{clistmap_info_clist:nn}\Arg{key}\Arg{code} |
| 240 |
% \end{syntax} |
| 241 |
% \begin{descr} |
| 242 |
% \item[Note] Used for generating this doc |
| 243 |
% \end{descr} |
| 244 |
% \end{function} |
| 245 |
% \begin{function}[EXP] |
| 246 |
% {\clistmap_signature:n, |
| 247 |
% \clistmap_instance_key:nn} |
| 248 |
% \begin{syntax} |
| 249 |
% \cs{clistmap_instance_key:n}\Arg{key prefix}\Arg{signature} |
| 250 |
% \end{syntax} |
| 251 |
% \begin{descr} |
| 252 |
% \item[Expands to] \meta{key prefix}|:|\meta{signature} |
| 253 |
% \end{descr} |
| 254 |
% \end{function} |
| 255 |
% \begin{function}[EXP] |
| 256 |
% { \clistmap_instance_sequence_p:n, |
| 257 |
% \clistmap_instance_p:n } |
| 258 |
% \begin{syntax} |
| 259 |
% \cs{clistmap_instance_p:n}\Arg{key} |
| 260 |
% \end{syntax} |
| 261 |
% \begin{descr} |
| 262 |
% \item[Semantics] Whether the instance has been registered |
| 263 |
% \end{descr} |
| 264 |
% \end{function} |
| 265 |
% \begin{function}[EXP] |
| 266 |
% {\clistmap_use_w:nnnn, |
| 267 |
% \clistmap_use_w:nnnnn, |
| 268 |
% \clistmap_use_w_group:nnnnnn } |
| 269 |
% \begin{syntax} |
| 270 |
% \cs{clistmap_use_w:nnnnn} |
| 271 |
% \Arg{rule} |
| 272 |
% \Arg{rule sequence (internal) } |
| 273 |
% \Arg{cs name} |
| 274 |
% \Arg{signature} |
| 275 |
% \Arg{head is group}\meta{more}\cs[no-index]{q_recursion_stop} |
| 276 |
% \end{syntax} |
| 277 |
% \begin{descr} |
| 278 |
% \item[Semantics] Evaluates \meta{code} associated with \meta{rule} |
| 279 |
% \item[Note] For use inside \meta{code} on the RHS of | rule = |\meta{rule bis}\meta{code} |
| 280 |
% \end{descr} |
| 281 |
% \end{function} |
| 282 |
% \begin{function}[EXP] |
| 283 |
% {\clistmap_bound_cs_group:nnnnn} |
| 284 |
% \begin{syntax} |
| 285 |
% \cs{clistmap_bound_cs_group:nnnnn} |
| 286 |
% \Arg{cs name} |
| 287 |
% \Arg{signature} |
| 288 |
% \Arg{group} |
| 289 |
% \Arg{args} |
| 290 |
% \Arg{elem} |
| 291 |
% \end{syntax} |
| 292 |
% \begin{descr} |
| 293 |
% \item[Definition] \meta{new elem}$=$|\bool_if:nTF|\Arg{group}|{|\Arg{elem}|}{|\meta{elem}|}| |
| 294 |
% \item[Semantics] \cs{\meta{cs name}:\meta{signature}}\meta{args}\Arg{new elem} |
| 295 |
% \item[Note] For use in conjunction with \cs{clistmap_use_w:nnnnn} and variants |
| 296 |
% \end{descr} |
| 297 |
% \end{function} |
| 298 |
% \begin{function}[EXP] |
| 299 |
% {\clistmap:nnn} |
| 300 |
% \begin{syntax} |
| 301 |
% \cs{clistmap:nnn}\Arg{clist}|{ ...,|\meta{instance_i}|,... }|\Arg{args} |
| 302 |
% \cs{clistmap:nnn}\Arg{clist}|{ ...,|\meta{instance sequence_i}|,... }|\Arg{args} |
| 303 |
% \end{syntax} |
| 304 |
% \begin{descr} |
| 305 |
% \item[Requirement]\docfillblank |
| 306 |
% \begin{description} |
| 307 |
% \item \meta{clist} has no trailing |,| |
| 308 |
% \item \meta{args} has signature \cs{clistmap_signature:n}\Arg{instance_i} |
| 309 |
% \end{description} |
| 310 |
% \item[Expands to]\docfillblank |
| 311 |
% \begin{descr} |
| 312 |
% \item[First version] For each $i$, the \meta{code} associated with \meta{rule_i}. |
| 313 |
% \item[Second version] Iterates over the constituents of \meta{rule sequence_i} |
| 314 |
% \end{descr} |
| 315 |
% \end{descr} |
| 316 |
% \end{function} |
| 317 |
% \begin{function}{\clistmap_inline:nnn} |
| 318 |
% \begin{syntax} |
| 319 |
% \cs{clistmap_inline:nnn}|{ ...,|\meta{instance_i}|,... }|\Arg{code} |
| 320 |
% \begin{descr} |
| 321 |
% \item[Requirement] \cs{clistmap_signature:n}\Arg{instance_i}$=$|N| |
| 322 |
% \end{descr} |
| 323 |
% \end{syntax} |
| 324 |
% \end{function} |
| 325 |
% \begin{function}[EXP] |
| 326 |
% {\clistmap:nnnn} |
| 327 |
% \begin{syntax} |
| 328 |
% \cs{clistmap:nnnn}\Arg{clist}\Arg{instances}\Arg{args}\Arg{end} |
| 329 |
% \cs{clistmap:nnnn}\Arg{clist}\Arg{instances}\Arg{args}\Arg{append} |
| 330 |
% \cs{clistmap:nnnn}\Arg{clist}\Arg{instances}\Arg{args}\Arg{nest} |
| 331 |
% \cs{clistmap:nnnn}\Arg{clist_1}\Arg{instances}\Arg{args}\Arg{join}\Arg{clist_2} |
| 332 |
% \end{syntax} |
| 333 |
% \begin{descr} |
| 334 |
% \item[Semantics]\docfillblank |
| 335 |
% \begin{descr} |
| 336 |
% \item[end] \cs{clistmap:nnn}\Arg{clist}\Arg{instances}\Arg{args} |
| 337 |
% \item[append] \meta{end}\cs{clistmap:nnnn}\Arg{clist} |
| 338 |
% \item[nest] \cs{clistmap:nnnn}\Arg{end} |
| 339 |
% \item[join] \cs{clistmap:nnnn}|{|\meta{end},\meta{clist_2}|}| |
| 340 |
% \end{descr} |
| 341 |
% \end{descr} |
| 342 |
% \end{function} |
| 343 |
% \begin{function}[EXP] |
| 344 |
% {\clistmap_inline:nnnn} |
| 345 |
% \begin{syntax} |
| 346 |
% \cs{clistmap_inline:nnnn}\Arg{clist}\Arg{instances}\Arg{code}\Arg{chain} |
| 347 |
% \end{syntax} |
| 348 |
% \begin{descr} |
| 349 |
% \item[Requirement] \cs{clistmap_signature:n}\Arg{instance_i}$=$|empty| or |N| |
| 350 |
% \end{descr} |
| 351 |
% \end{function} |
| 352 |
% \clearpage |
| 353 |
% \part{Listing}\label{part:listing} |
| 354 |
% |
| 355 |
% \section{Using keys} |
| 356 |
% \addcontentsline{toc}{subsection}{\texttt{rule}} |
| 357 |
% \iffalse |
| 358 |
%<*guardlisting> |
| 359 |
% \fi |
| 360 |
\begin{listing}[\texttt{rule}] |
| 361 |
{label=lst:opt:rule,listing only} |
| 362 |
\clistmap_keys_set:n |
| 363 |
{% |
| 364 |
rule = {if_rest_is_tail_stop_else_forward_rest} |
| 365 |
{% |
| 366 |
\quark_if_recursion_tail_stop:n{#7} |
| 367 |
\clistmap_use_w:nnne |
| 368 |
{#1}{#2}{#3} |
| 369 |
{\tl_if_head_is_group_p:n{#7}}#5#7\q_recursion_stop |
| 370 |
} |
| 371 |
} |
| 372 |
\end{listing} |
| 373 |
% \iffalse |
| 374 |
%</guardlisting> |
| 375 |
% \fi |
| 376 |
% |
| 377 |
% \addcontentsline{toc}{subsection}{\texttt{rule_sequence}} |
| 378 |
% \iffalse |
| 379 |
%<*guardlisting> |
| 380 |
% \fi |
| 381 |
\begin{listing}[\texttt{rule_sequence}] |
| 382 |
{label=lst:opt:ruleseq, listing only} |
| 383 |
\clistmap_keys_set:n |
| 384 |
{ |
| 385 |
rule_sequence = |
| 386 |
{ |
| 387 |
first = |
| 388 |
{ |
| 389 |
{if_empty_stop_else_forward_head} |
| 390 |
{if_rest_is_tail_eval_else_error} |
| 391 |
} |
| 392 |
} |
| 393 |
} |
| 394 |
\end{listing} |
| 395 |
% \iffalse |
| 396 |
%</guardlisting> |
| 397 |
% \fi |
| 398 |
% |
| 399 |
% \addcontentsline{toc}{subsection}{\texttt{instance}} |
| 400 |
% \iffalse |
| 401 |
%<*guardlisting> |
| 402 |
% \fi |
| 403 |
\begin{listing}[\texttt{instance}] |
| 404 |
{label=lst:opt:inst, listing only} |
| 405 |
\clistmap_keys_set:n |
| 406 |
{ |
| 407 |
instance = |
| 408 |
{ |
| 409 |
{N}{first_apply}{first}{@@_apply}, |
| 410 |
{}{first_apply}{first}{@@_apply} |
| 411 |
} |
| 412 |
} |
| 413 |
\end{listing} |
| 414 |
% \iffalse |
| 415 |
%</guardlisting> |
| 416 |
% \fi |
| 417 |
% |
| 418 |
% \addcontentsline{toc}{subsection}{\texttt{instance_sequence}} |
| 419 |
% \iffalse |
| 420 |
%<*guardlisting> |
| 421 |
% \fi |
| 422 |
\begin{listing}[\texttt{instance_sequence}] |
| 423 |
{label=lst:opt:inst_seq, listing only} |
| 424 |
\clistmap_keys_set:n |
| 425 |
{% |
| 426 |
instance_sequence = |
| 427 |
{ |
| 428 |
{N}{comma:}{first_apply:, rest_comma:}, |
| 429 |
{}{serial_and:}{first_apply:, serial_rest_and:}, |
| 430 |
} |
| 431 |
} |
| 432 |
\end{listing} |
| 433 |
% \iffalse |
| 434 |
%</guardlisting> |
| 435 |
% \fi |
| 436 |
% \section{Preset keys} |
| 437 |
% \addcontentsline{toc}{subsection}{\texttt{rule}} |
| 438 |
% \iffalse |
| 439 |
%<*guardlisting> |
| 440 |
% \fi |
| 441 |
\begin{listing}[\texttt{rule}]{label=lst:preset:rule, text only} |
| 442 |
\ExplSyntaxOn |
| 443 |
\begin{descr} |
| 444 |
\clistmap_info_clist:nn{rule}{\item[#1]} |
| 445 |
\end{descr} |
| 446 |
\ExplSyntaxOff |
| 447 |
\end{listing} |
| 448 |
% \iffalse |
| 449 |
%</guardlisting> |
| 450 |
% \fi |
| 451 |
% |
| 452 |
% \addcontentsline{toc}{subsection}{\texttt{rule_sequence}} |
| 453 |
% \iffalse |
| 454 |
%<*guardlisting> |
| 455 |
% \fi |
| 456 |
% \begin{listing}[\texttt{rule_sequence}]{label=lst:preset:rule_sequence, text only} |
| 457 |
\ExplSyntaxOn |
| 458 |
\begin{descr} |
| 459 |
\tl_map_inline:en |
| 460 |
{ \clistmap_info_prop:n{rule_sequence}}{\item[\use_i:nn#1]} |
| 461 |
\end{descr} |
| 462 |
\ExplSyntaxOff |
| 463 |
\end{listing} |
| 464 |
% \iffalse |
| 465 |
%</guardlisting> |
| 466 |
% \fi |
| 467 |
% |
| 468 |
% \addcontentsline{toc}{subsection}{\texttt{instance}} |
| 469 |
% \iffalse |
| 470 |
%<*guardlisting> |
| 471 |
% \fi |
| 472 |
\begin{listing}[\texttt{instance}]{label=lst:preset:instance, text only} |
| 473 |
\ExplSyntaxOn |
| 474 |
\begin{descr} |
| 475 |
\tl_map_inline:en |
| 476 |
{ \clistmap_info_prop:n{instance} } |
| 477 |
{ \item[\use_i:nn#1]\docfillblank } |
| 478 |
\end{descr} |
| 479 |
\ExplSyntaxOff |
| 480 |
\end{listing} |
| 481 |
% \iffalse |
| 482 |
%</guardlisting> |
| 483 |
% \fi |
| 484 |
% |
| 485 |
% \addcontentsline{toc}{subsection}{\texttt{instance_sequence}} |
| 486 |
% \iffalse |
| 487 |
%<*guardlisting> |
| 488 |
% \fi |
| 489 |
\begin{listing}[\texttt{instance_sequence}]{label=lst:preset:instance_sequence, text only} |
| 490 |
\ExplSyntaxOn |
| 491 |
\begin{descr} |
| 492 |
\tl_map_inline:en |
| 493 |
{ \clistmap_info_prop:n{instance_sequence} } |
| 494 |
{ \item[\use_i:nn#1]\docfillblank } |
| 495 |
\end{descr} |
| 496 |
\ExplSyntaxOff |
| 497 |
\end{listing} |
| 498 |
% \iffalse |
| 499 |
%</guardlisting> |
| 500 |
% \fi |
| 501 |
% |
| 502 |
% \section{\textsf{cs}} |
| 503 |
% \subsection{\textsf{plain}} |
| 504 |
% \addcontentsline{toc}{subsection}{\texttt{math}} |
| 505 |
% \iffalse |
| 506 |
%<*guardlisting> |
| 507 |
% \fi |
| 508 |
\begin{listing}[\texttt{math}]{label=lst:cs:math} |
| 509 |
\ExplSyntaxOn |
| 510 |
\clistmap:nnn{Z, C, Q, R} |
| 511 |
{ first_math:N, serial_rest_math_and:N } |
| 512 |
{\mathbb} |
| 513 |
\ExplSyntaxOff |
| 514 |
\end{listing} |
| 515 |
% \iffalse |
| 516 |
%</guardlisting> |
| 517 |
% \fi |
| 518 |
% |
| 519 |
% \subsection{\textsf{chain}} |
| 520 |
% \addcontentsline{toc}{subsection}{\texttt{append}} |
| 521 |
% \iffalse |
| 522 |
%<*guardlisting> |
| 523 |
% \fi |
| 524 |
\begin{listing}[\texttt{append}]{label=lst:cs:append} |
| 525 |
\ExplSyntaxOn |
| 526 |
\clistmap_inline:nnnn |
| 527 |
{{J,u,l,e,s},Jim,Catherine} |
| 528 |
{first_map:N} |
| 529 |
{#1} |
| 530 |
{append} |
| 531 |
{middle_comma:N} |
| 532 |
{~#1} |
| 533 |
{append} |
| 534 |
{%^^A |
| 535 |
serial_second:N,%^^A ignored in this case |
| 536 |
serial_last:N |
| 537 |
} |
| 538 |
{~et~#1} |
| 539 |
{end} |
| 540 |
\ExplSyntaxOff |
| 541 |
\end{listing} |
| 542 |
% \iffalse |
| 543 |
%</guardlisting> |
| 544 |
% \fi |
| 545 |
% |
| 546 |
% \addcontentsline{toc}{subsection}{\texttt{nest}} |
| 547 |
% \iffalse |
| 548 |
%<*guardlisting> |
| 549 |
% \fi |
| 550 |
\begin{listing}[\texttt{nest}]{label=lst:cs:nest} |
| 551 |
\ExplSyntaxOn |
| 552 |
\noindent |
| 553 |
\clistmap_inline:nnnn |
| 554 |
{{foo},{bar,baz},{qux}} |
| 555 |
{comma_unbrace:} |
| 556 |
{} |
| 557 |
{nest} |
| 558 |
{newline:} |
| 559 |
{} |
| 560 |
{end} |
| 561 |
\ExplSyntaxOff |
| 562 |
\end{listing} |
| 563 |
% \iffalse |
| 564 |
%</guardlisting> |
| 565 |
% \fi |
| 566 |
% |
| 567 |
% \addcontentsline{toc}{subsection}{\texttt{join}} |
| 568 |
% \iffalse |
| 569 |
%<*guardlisting> |
| 570 |
% \fi |
| 571 |
\begin{listing}[\texttt{join}]{label=lst:cs:join} |
| 572 |
\ExplSyntaxOn |
| 573 |
\clistmap_inline:nnnn |
| 574 |
{foo,bar} |
| 575 |
{comma:} |
| 576 |
{} |
| 577 |
{join} |
| 578 |
{baz} |
| 579 |
{comma:} |
| 580 |
{} |
| 581 |
{end} |
| 582 |
\ExplSyntaxOff |
| 583 |
\end{listing} |
| 584 |
% \iffalse |
| 585 |
%</guardlisting> |
| 586 |
% \fi |
| 587 |
% |
| 588 |
% |
| 589 |
% \part{Other} |
| 590 |
% \section{Bibliograhy} |
| 591 |
% \printbibliography[heading=none] |
| 592 |
% \section{To do}\label{other:bug} |
| 593 |
% \begin{enumerate} |
| 594 |
% \item ``Warning: A control sequence of the form ...__clistmap'' |
| 595 |
% That's because of the way \cs[no-index]{__clist_instance_name:nn} is set up, |
| 596 |
% and passing to it an internal control sequence. So? |
| 597 |
% Modify \cs[no-index]{__clist_instance_name:nn}. |
| 598 |
% \end{enumerate} |
| 599 |
% \section{Support}\label{other:support} |
| 600 |
% |
| 601 |
% This package is available from \url{https://github.com/rogard/clistmap}. |
| 602 |
% |
| 603 |
% \changes{v1.0} |
| 604 |
% {2022/01/27} |
| 605 |
% {Initial version} |
| 606 |
% \changes{v1.1} |
| 607 |
% {2022/01/28} |
| 608 |
% {Updated dependency to erw-l3 (from 4.1 to 4.2)} |
| 609 |
% \changes{v1.2} |
| 610 |
% {2022/01/29} |
| 611 |
% {Pkg name change} |
| 612 |
% |
| 613 |
% \StopEventually{ |
| 614 |
% \clearpage |
| 615 |
% \PrintChanges |
| 616 |
% \PrintIndex %^^A https://tex.stackexchange.com/q/610349/112708 |
| 617 |
% } |
| 618 |
% |
| 619 |
% \end{documentation} |
| 620 |
% \begin{implementation} |
| 621 |
% \part{Implementation}\label{part:implem} |
| 622 |
% \begin{macrocode} |
| 623 |
%<*package> |
| 624 |
%<@@=clistmap> |
| 625 |
% \ExplSyntaxOn |
| 626 |
% \end{macrocode} |
| 627 |
% \section{\textsf{boilerplate}} |
| 628 |
% \begin{macro}{\clistmap_keys_set:n, \clistmap_info_clist:nn} |
| 629 |
% \begin{macrocode} |
| 630 |
\cs_generate_variant:Nn\str_if_eq:nnTF{e} |
| 631 |
\cs_generate_variant:Nn\tl_to_str:n{e} |
| 632 |
\cs_generate_variant:Nn\prop_gput:Nnn{Nee} |
| 633 |
\cs_generate_variant:Nn\erw_parameter:n{e} |
| 634 |
\cs_generate_variant:Nn\erw_argument:nn{ne} |
| 635 |
\cs_generate_variant:Nn\erw_parameter:nn{ne} |
| 636 |
\cs_generate_variant:Nn\erw_clist_tl:nn{ne} |
| 637 |
\cs_new:Npn\@@_empty:w#1\q_recursion_stop{} |
| 638 |
\clist_new:N\@@_helper_clist |
| 639 |
\cs_new_protected:Nn |
| 640 |
\clistmap_keys_set:n{ \keys_set:nn{ @@ }{ #1 } } |
| 641 |
\prop_new:N\@@_info_clist_prop |
| 642 |
\cs_new_protected:Npn |
| 643 |
\@@_info_clist_put:nn |
| 644 |
#1 % <key> |
| 645 |
#2 % <name:signature> |
| 646 |
{\prop_gput:Nnn\@@_info_clist_prop{#1}{#2}} |
| 647 |
\cs_new_protected:Npn |
| 648 |
\clistmap_info_clist:nn |
| 649 |
#1 % <key> |
| 650 |
#2 % <code> |
| 651 |
{\clist_map_inline:cn{\prop_item:Nn\@@_info_clist_prop{#1}}{#2}} |
| 652 |
\prop_new:N\@@_info_prop_prop |
| 653 |
\cs_new_protected:Npn |
| 654 |
\@@_info_prop_put:nn |
| 655 |
#1 % <key> |
| 656 |
#2 % <name:signature> |
| 657 |
{\prop_gput:Nnn\@@_info_prop_prop{#1}{#2}} |
| 658 |
\cs_new:Nn |
| 659 |
\@@_brace:nn{{{#1}{#2}}} |
| 660 |
\cs_new:Npn |
| 661 |
\clistmap_info_prop:n |
| 662 |
#1 % <key> |
| 663 |
{ \prop_map_function:cN |
| 664 |
{\prop_item:Nn\@@_info_prop_prop{#1}}\@@_brace:nn } |
| 665 |
\cs_new:Npn |
| 666 |
\clistmap_info_prop:nn |
| 667 |
#1 % <key> |
| 668 |
#2 % <code> |
| 669 |
{ \prop_map_inline:cn |
| 670 |
{\prop_item:Nn\@@_info_prop_prop{#1}}{#2} } |
| 671 |
\cs_new:Nn |
| 672 |
\@@_group_if:nn |
| 673 |
{\bool_if:nTF{#2}{{#1}}{#1}} |
| 674 |
\cs_generate_variant:Nn\@@_group_if:nn{e} |
| 675 |
\cs_new:Nn |
| 676 |
\@@_head_clist:n |
| 677 |
{% |
| 678 |
\exp_args:Ne |
| 679 |
\tl_head:n |
| 680 |
{ \clist_map_function:nN{#1}\@@_head_clist_aux:n } |
| 681 |
} |
| 682 |
\cs_new:Nn |
| 683 |
\@@_head_clist_aux:n{#1} |
| 684 |
% \end{macrocode} |
| 685 |
% \end{macro} |
| 686 |
% \section{\textsf{name}} |
| 687 |
% \begin{macro} |
| 688 |
% { |
| 689 |
% \@@_rule_name:n, |
| 690 |
% \@@_instance_name:nnn, |
| 691 |
% \@@_instance_signature:n, |
| 692 |
% \@@_rule_sequence_name:n |
| 693 |
% } |
| 694 |
% \begin{macrocode} |
| 695 |
\cs_new:Npn |
| 696 |
\@@_rule_name:n |
| 697 |
#1 % <rules> |
| 698 |
{rule_#1} |
| 699 |
\cs_new:Npn |
| 700 |
\@@_instance_name:nn |
| 701 |
#1 % <rules> |
| 702 |
#2 % <cs name> |
| 703 |
{instance_#1_#2} |
| 704 |
\cs_new:Npn |
| 705 |
\@@_instance_name:nnn |
| 706 |
#1 % <rule> |
| 707 |
#2 % <next rules> |
| 708 |
#3 % <cs name> |
| 709 |
{\@@_instance_name:nn{#1_#2}{#3}} |
| 710 |
\cs_new:Npn |
| 711 |
\@@_instance_signature:n |
| 712 |
#1 % <signature> |
| 713 |
{n#1w} |
| 714 |
% \end{macrocode} |
| 715 |
% \end{macro} |
| 716 |
% \section{\textsf{c}} |
| 717 |
% \begin{macrocode} |
| 718 |
\cs_new:Npn |
| 719 |
\@@_c:n |
| 720 |
#1 % <name> |
| 721 |
{@@_#1} |
| 722 |
\cs_generate_variant:Nn\@@_c:n{e} |
| 723 |
\cs_new:Npn |
| 724 |
\@@_c:nn |
| 725 |
#1 % <name> |
| 726 |
#2 % <signature> |
| 727 |
{\@@_c:n{#1:#2}} |
| 728 |
\cs_generate_variant:Nn\@@_c:nn{e, ee} |
| 729 |
\cs_new:Npn |
| 730 |
\@@_bound_cs_c:nn |
| 731 |
#1 % <name> |
| 732 |
#2 % <signature> |
| 733 |
{#1:#2n} |
| 734 |
\cs_new:Npn |
| 735 |
\@@_rule_c:n |
| 736 |
#1 % <rule> |
| 737 |
{% |
| 738 |
\@@_c:en |
| 739 |
{\@@_rule_name:n{#1}} |
| 740 |
{nnnnnnnn} |
| 741 |
} |
| 742 |
\cs_new:Npn |
| 743 |
\@@_instance_c:nn |
| 744 |
#1 % <rules> |
| 745 |
#2 % <cs name> |
| 746 |
{ \@@_c:e |
| 747 |
{ \@@_instance_name:nn{#1}{#2} } } |
| 748 |
\cs_generate_variant:Nn\@@_instance_c:nn{e} |
| 749 |
\cs_new:Npn |
| 750 |
\@@_instance_c:nnn |
| 751 |
#1 % <rules> |
| 752 |
#2 % <cs name> |
| 753 |
#3 % <signature> |
| 754 |
{% |
| 755 |
\@@_c:ee |
| 756 |
{ \@@_instance_name:nn{#1}{#2} } |
| 757 |
{ \@@_instance_signature:n{#3} } |
| 758 |
} |
| 759 |
\cs_generate_variant:Nn\@@_instance_c:nnn{e, nne} |
| 760 |
\cs_new:Npn |
| 761 |
\@@_instance_c_this:nnnn |
| 762 |
#1 % <rule> |
| 763 |
#2 % <next rules> |
| 764 |
#3 % <cs name> |
| 765 |
#4 % <signature> |
| 766 |
{ \@@_instance_c:enn |
| 767 |
{\@@_rule_link:nn{#1}{#2}}{#3}{#4} } |
| 768 |
% \end{macrocode} |
| 769 |
% \section{\textsf{rule_link}} |
| 770 |
% \begin{macrocode} |
| 771 |
\cs_new:Npn |
| 772 |
\@@_rule_link:nn |
| 773 |
#1 % <rule 1> |
| 774 |
#2 % <rule 2> |
| 775 |
{#1_#2} |
| 776 |
\cs_new:Npn |
| 777 |
\@@_rule_link:n |
| 778 |
#1 % <{rule{1}}...> |
| 779 |
{% |
| 780 |
\@@_rule_link:w#1\q_recursion_tail\q_recursion_stop |
| 781 |
} |
| 782 |
\cs_generate_variant:Nn\@@_rule_link:n{e} |
| 783 |
\cs_new:Npn |
| 784 |
\@@_rule_link:w |
| 785 |
#1 |
| 786 |
\q_recursion_stop |
| 787 |
{% |
| 788 |
\quark_if_recursion_tail_stop:n{#1} |
| 789 |
\@@_rule_link:nw #1 \q_recursion_stop} |
| 790 |
\cs_new:Npn |
| 791 |
\@@_rule_link:nw |
| 792 |
#1 % <rules> |
| 793 |
#2 % <{rule{1}}...> |
| 794 |
\q_recursion_stop |
| 795 |
{% |
| 796 |
\quark_if_recursion_tail_stop_do:nn{#2}{#1} |
| 797 |
\@@_rule_link:nnw{#1}#2\q_recursion_stop} |
| 798 |
\cs_generate_variant:Nn\@@_rule_link:nw{e} |
| 799 |
\cs_new:Npn |
| 800 |
\@@_rule_link:nnw |
| 801 |
#1 % <rules> |
| 802 |
#2 % <rule{1}> |
| 803 |
#3 % <{rule{2}}...> |
| 804 |
\q_recursion_stop |
| 805 |
{% |
| 806 |
\@@_rule_link:ew |
| 807 |
{% |
| 808 |
\@@_rule_link:nn |
| 809 |
{#1} % <rule 1> |
| 810 |
{#2} % <rule 2> |
| 811 |
} % <rules> |
| 812 |
#3 % <{rule{1}}...> |
| 813 |
\q_recursion_stop |
| 814 |
} |
| 815 |
% \end{macrocode} |
| 816 |
% \section{\textsf{inline}} |
| 817 |
% \begin{macrocode} |
| 818 |
\cs_new_protected:Nn |
| 819 |
\@@_inline_set_exp_nnnot:Nn |
| 820 |
{\cs_set:Nn#1 |
| 821 |
{\exp_not:n |
| 822 |
{\exp_not:n |
| 823 |
{\exp_not:n{#2}}}}} |
| 824 |
\cs_generate_variant:Nn\@@_inline_set_exp_nnnot:Nn{c} |
| 825 |
\cs_new:Nn\@@_inline_c:n{@@_#1:n} |
| 826 |
\cs_new:Nn\@@_inline_use:n |
| 827 |
{%^^A BUG |
| 828 |
\use:c{\@@_inline_c:n{#1}}} |
| 829 |
\cs_new_protected:Nn |
| 830 |
\@@_inline_set_exp_nnnot:nn |
| 831 |
{\@@_inline_set_exp_nnnot:cn |
| 832 |
{\@@_inline_c:n{#1}}{#2}} |
| 833 |
\msg_new:nnn{@@} |
| 834 |
{inline-empty-N} |
| 835 |
{instance~signature~must~be~empty~or~N;~got~'#1'} |
| 836 |
\msg_new:nnn{@@} |
| 837 |
{inline-empty-args} |
| 838 |
{instance~signature=empty;~so~should~args=#1} |
| 839 |
% \end{macrocode} |
| 840 |
% \section{\textsf{eval}} |
| 841 |
% \begin{macro} |
| 842 |
% {\clistmap:nnn, \clistmap_inline:nnn} |
| 843 |
% \begin{macrocode} |
| 844 |
\msg_new:nnn{@@}{key} |
| 845 |
{no~match~for~#1~in~instance~or~instance~sequence} |
| 846 |
\msg_new:nnn{@@}{signature-mismatch} |
| 847 |
{instance~signature~must~be~#1;~instances:~#2} |
| 848 |
\cs_new_protected:Npn |
| 849 |
\clistmap_inline:nnn |
| 850 |
#1 % <clist> |
| 851 |
#2 % <instances> |
| 852 |
#3 % <empty|code using #1> |
| 853 |
{%^^A |
| 854 |
\bool_if:nTF |
| 855 |
{ \__clistmap_instance_signature_p:nn{#2}{N} } |
| 856 |
{%^^A |
| 857 |
\__clistmap_inline_set_exp_nnnot:nn{a}{#3} |
| 858 |
\clistmap:nnn |
| 859 |
{#1} % <clist> |
| 860 |
{#2} % <key 1> |
| 861 |
{\__clistmap_a:n} |
| 862 |
} |
| 863 |
{%^^A |
| 864 |
\bool_if:nTF |
| 865 |
{ \__clistmap_instance_signature_p:nn{#2}{} } |
| 866 |
{%^^A |
| 867 |
\tl_if_empty:nTF |
| 868 |
{#3} |
| 869 |
{%^^A |
| 870 |
\clistmap:nnn |
| 871 |
{#1} % <clist> |
| 872 |
{#2} % <key 1> |
| 873 |
{} |
| 874 |
} |
| 875 |
{%^^A |
| 876 |
\msg_error:nnnn{__clistmap} |
| 877 |
{inline-empty-args} |
| 878 |
{#3} |
| 879 |
} |
| 880 |
} |
| 881 |
{%^^A |
| 882 |
\msg_error:nnnn{__clistmap} |
| 883 |
{inline-empty-N} |
| 884 |
{#2} |
| 885 |
} |
| 886 |
} |
| 887 |
} |
| 888 |
\cs_new:Npn |
| 889 |
\clistmap:nnn |
| 890 |
% ^^A Warning: trailing ',' inside #2 => Error |
| 891 |
#1 % <clist> |
| 892 |
#2 % <key,...> |
| 893 |
#3 % <arguments> |
| 894 |
{% |
| 895 |
\@@_eval:nenn |
| 896 |
{#2} % <instance key>,... |
| 897 |
{\tl_if_head_is_group_p:n{#1}} % <head is group> |
| 898 |
{#3} % <arguments> |
| 899 |
{#1} % <clist> |
| 900 |
} |
| 901 |
\cs_generate_variant:Nn\clistmap:nnn{e,f,x} |
| 902 |
\cs_new:Npn |
| 903 |
\@@_eval:nnnn |
| 904 |
#1 % <instance key>,... |
| 905 |
#2 % <head is group> |
| 906 |
#3 % <arguments> |
| 907 |
#4 % <clist> |
| 908 |
{% |
| 909 |
\exp_args:Ne |
| 910 |
\@@_eval_aux:nnnn |
| 911 |
{\@@_instance_expand:n{#1}} |
| 912 |
{#2} % <head is group> |
| 913 |
{#3} % <arguments> |
| 914 |
{#4} % <clist> |
| 915 |
} |
| 916 |
\cs_new:Npn |
| 917 |
\@@_eval_aux:nnnn |
| 918 |
#1 % <instance key>,... |
| 919 |
#2 % <head is group> |
| 920 |
#3 % <arguments> |
| 921 |
#4 % <clist> |
| 922 |
{% |
| 923 |
\@@_eval:nnnw |
| 924 |
{#2} % <head is group> |
| 925 |
{#3} % <arguments> |
| 926 |
{#4} % <clist> |
| 927 |
#1 % <instance key>,... |
| 928 |
, \q_recursion_tail |
| 929 |
\q_recursion_stop |
| 930 |
} |
| 931 |
\cs_generate_variant:Nn\@@_eval:nnnn{ ne } |
| 932 |
\cs_new:Npn |
| 933 |
\@@_eval:nnnw |
| 934 |
#1 % <head is group> |
| 935 |
#2 % <arguments> |
| 936 |
#3 % <clist> |
| 937 |
#4 % <instance key> |
| 938 |
\q_recursion_stop |
| 939 |
{% |
| 940 |
\quark_if_recursion_tail_stop:n{#4} |
| 941 |
\@@_eval:nnnnw |
| 942 |
{#1} % <head is group> |
| 943 |
{#2} % <arguments> |
| 944 |
{#3} % <clist> |
| 945 |
#4 % <instance key> |
| 946 |
\q_recursion_stop |
| 947 |
} |
| 948 |
\cs_new:Npn |
| 949 |
\@@_eval:nnnnw |
| 950 |
#1 % <head is group> |
| 951 |
#2 % <arguments> |
| 952 |
#3 % <clist> |
| 953 |
#4 % <instance key> |
| 954 |
, #5 % <instance key,...> |
| 955 |
\q_recursion_stop |
| 956 |
{% |
| 957 |
\exp_last_unbraced:Ne |
| 958 |
\@@_eval:nnnnnn |
| 959 |
{ \@@_instance_get:n{#4} } |
| 960 |
{#1}{#2}{#3} |
| 961 |
\@@_eval:nnnw |
| 962 |
{#1} % <head is group> |
| 963 |
{#2} % <arguments> |
| 964 |
{#3} % <clist> |
| 965 |
#5 % <instance key> |
| 966 |
\q_recursion_stop |
| 967 |
} |
| 968 |
\cs_new:Npn |
| 969 |
\@@_eval:nnnnnn |
| 970 |
#1 % <rule sequence> |
| 971 |
#2 % <cs name> |
| 972 |
#3 % <signature> |
| 973 |
#4 % <head is group> |
| 974 |
#5 % <arguments> |
| 975 |
#6 % <clist> |
| 976 |
{% |
| 977 |
\exp_args:Ne |
| 978 |
\clistmap_use_w:nnnn |
| 979 |
{ \@@_rule_sequence_name:n{#1} } % <rule sequence> |
| 980 |
{#2} % <cs name> |
| 981 |
{#3} % <signature> |
| 982 |
{#4} % <head is group> |
| 983 |
#5 |
| 984 |
#6, \q_recursion_tail\q_recursion_stop |
| 985 |
} |
| 986 |
% \end{macrocode} |
| 987 |
% \end{macro} |
| 988 |
% \section{\textsf{chain}} |
| 989 |
% \begin{macrocode} |
| 990 |
\msg_new:nnn{@@} |
| 991 |
{chain}{unknown~chain~tag~#1} |
| 992 |
\cs_new_protected:Npn |
| 993 |
\@@_append:NNN |
| 994 |
#1 % <new> |
| 995 |
#2 % <\@@_append(?:_inline):nnn> |
| 996 |
#3 % <\clistmap(?_inline):nnnn> |
| 997 |
{%^^A |
| 998 |
#1 |
| 999 |
#2 |
| 1000 |
{%^^A |
| 1001 |
\clistmap:nnn{##1}{##2}{##3} |
| 1002 |
#3{##1} |
| 1003 |
} |
| 1004 |
} |
| 1005 |
\@@_append:NNN |
| 1006 |
\cs_new:Nn |
| 1007 |
\@@_append:nnn |
| 1008 |
\clistmap:nnnn |
| 1009 |
\@@_append:NNN |
| 1010 |
\cs_new_protected:Nn |
| 1011 |
\@@_append_inline:nnn |
| 1012 |
\clistmap_inline:nnnn |
| 1013 |
\cs_new_protected:Npn |
| 1014 |
\@@_nest:NNN |
| 1015 |
#1 % <new> |
| 1016 |
#2 % <\@@_nest(?:_inline):nnn> |
| 1017 |
#3 % <\clistmap(?_inline):nnnn> |
| 1018 |
{%^^A |
| 1019 |
#1 |
| 1020 |
#2 |
| 1021 |
{%^^A |
| 1022 |
\exp_args:Ne |
| 1023 |
#3{ \clistmap:nnn{##1}{##2}{##3} } |
| 1024 |
} |
| 1025 |
} |
| 1026 |
\@@_nest:NNN |
| 1027 |
\cs_new:Nn |
| 1028 |
\@@_nest:nnn |
| 1029 |
\clistmap:nnnn |
| 1030 |
\@@_nest:NNN |
| 1031 |
\cs_new_protected:Nn |
| 1032 |
\@@_nest_inline:nnn |
| 1033 |
\clistmap_inline:nnnn |
| 1034 |
\cs_new_protected:Npn |
| 1035 |
\@@_join:NNNN |
| 1036 |
#1 % <new> |
| 1037 |
#2 % <\@@_join(?:_inline):nnnn> |
| 1038 |
#3 % <\@@_join(?:_inline):nnn> |
| 1039 |
#4 % <\clistmap(?_inline):nnnn> |
| 1040 |
{%^^A |
| 1041 |
#1 |
| 1042 |
#2 |
| 1043 |
{ #4{##1,##2}{##3}{##4} } |
| 1044 |
#1 |
| 1045 |
#3 |
| 1046 |
{ #2{\clistmap:nnn{##1}{##2}{##3}} } |
| 1047 |
} |
| 1048 |
\@@_join:NNNN |
| 1049 |
\cs_new:Nn |
| 1050 |
\@@_join:nnnn |
| 1051 |
\@@_join:nnn |
| 1052 |
\clistmap:nnnn |
| 1053 |
\@@_join:NNNN |
| 1054 |
\cs_new_protected:Nn |
| 1055 |
\@@_join_inline:nnnn |
| 1056 |
\@@_join_inline:nnn |
| 1057 |
\clistmap_inline:nnnn |
| 1058 |
\cs_new_protected:Npn |
| 1059 |
\@@_chain:NNNNN |
| 1060 |
#1 % <new> |
| 1061 |
#2 % <@@_chain(?:_inline):nnnn> |
| 1062 |
#3 % <@@_append(?:_inline):nnn> |
| 1063 |
#4 % <@@_nest(?:_inline):nnn> |
| 1064 |
#5 % <@@_join(?:_inline):nnn> |
| 1065 |
{%^^A |
| 1066 |
#1 |
| 1067 |
#2 |
| 1068 |
{%^^A |
| 1069 |
\str_case:nnTF |
| 1070 |
{##4} |
| 1071 |
{%^^A |
| 1072 |
{end} |
| 1073 |
{ \clistmap:nnn{##1}{##2}{##3} } |
| 1074 |
{append} |
| 1075 |
{ #3{##1}{##2}{##3} } |
| 1076 |
{nest} |
| 1077 |
{ #4{##1}{##2}{##3} } |
| 1078 |
{join} |
| 1079 |
{ #5{##1}{##2}{##3} } |
| 1080 |
} |
| 1081 |
{} |
| 1082 |
{ \msg_error:nnn{@@}{chain}{##4} } |
| 1083 |
} |
| 1084 |
} |
| 1085 |
\@@_chain:NNNNN |
| 1086 |
\cs_new:Nn |
| 1087 |
\clistmap:nnnn |
| 1088 |
\@@_append:nnn |
| 1089 |
\@@_nest:nnn |
| 1090 |
\@@_join:nnn |
| 1091 |
\@@_chain:NNNNN |
| 1092 |
\cs_new_protected:Nn |
| 1093 |
\@@_inline_aux:nnnn |
| 1094 |
\@@_append_inline:nnn |
| 1095 |
\@@_nest_inline:nnn |
| 1096 |
\@@_join_inline:nnn |
| 1097 |
\cs_new_protected:Npn |
| 1098 |
\clistmap_inline:nnnn |
| 1099 |
#1 % <clist> |
| 1100 |
#2 % <inst> |
| 1101 |
#3 % <args> |
| 1102 |
#4 % <chain> |
| 1103 |
{%^^A |
| 1104 |
\bool_if:nTF |
| 1105 |
{ \@@_instance_signature_p:nn{#2}{N} } |
| 1106 |
{%^^A |
| 1107 |
\@@_inline_set_exp_nnnot:nn{a}{#3} |
| 1108 |
\@@_inline_aux:nnnn{#1}{#2}{\@@_a:n}{#4} |
| 1109 |
} |
| 1110 |
{ \@@_inline_aux:nnnn{#1}{#2}{}{#4} } |
| 1111 |
} |
| 1112 |
% \end{macrocode} |
| 1113 |
% \section{\textsf{use_w}}\label{sec:code} |
| 1114 |
% \begin{macro} |
| 1115 |
% { |
| 1116 |
% \clistmap_use_w_group:nnnnnn, |
| 1117 |
% \clistmap_use_w:nnnn, |
| 1118 |
% \clistmap_use_w:nnnnn |
| 1119 |
% } |
| 1120 |
% For use inside \meta{code} inside \nameref{sec:rule} |
| 1121 |
% \begin{macrocode} |
| 1122 |
\cs_new:Npn |
| 1123 |
\clistmap_use_w_group:nnnnnn |
| 1124 |
#1 % <rule sequence> |
| 1125 |
#2 % <cs name> |
| 1126 |
#3 % <signature> |
| 1127 |
#4 % <head is group> |
| 1128 |
#5 % <arguments> |
| 1129 |
#6 % <clist head> |
| 1130 |
{% |
| 1131 |
\clistmap_use_w:nnnn |
| 1132 |
{#1}{#2}{#3} |
| 1133 |
{#4}#5{#6} |
| 1134 |
} |
| 1135 |
\cs_new:Npn |
| 1136 |
\clistmap_use_w:nnnn |
| 1137 |
#1 % <rule sequence> |
| 1138 |
#2 % <cs name> |
| 1139 |
#3 % <signature> |
| 1140 |
#4 % <head is group> |
| 1141 |
{% |
| 1142 |
\use:c{ \@@_instance_c:nnn{#1}{#2}{#3} }{#4} |
| 1143 |
} |
| 1144 |
\cs_generate_variant:Nn\clistmap_use_w:nnnn{nnne} |
| 1145 |
\cs_new:Npn |
| 1146 |
\clistmap_use_w:nnnnn |
| 1147 |
#1 % <rule> |
| 1148 |
#2 % <next rule sequence> |
| 1149 |
#3 % <cs name> |
| 1150 |
#4 % <signature> |
| 1151 |
#5 % <head is group> |
| 1152 |
{% |
| 1153 |
\use:c{% |
| 1154 |
\@@_instance_c_this:nnnn |
| 1155 |
{#1} % <rule> |
| 1156 |
{#2} % <next rules> |
| 1157 |
{#3} % <cs name> |
| 1158 |
{#4} % <signature> |
| 1159 |
}{#5} |
| 1160 |
} |
| 1161 |
\cs_generate_variant:Nn\clistmap_use_w:nnnnn{nnnne} |
| 1162 |
% \end{macrocode} |
| 1163 |
% \end{macro} |
| 1164 |
% \begin{macro} |
| 1165 |
% { \clistmap_bound_cs_group:nnnnn } |
| 1166 |
% \begin{macrocode} |
| 1167 |
\cs_new:Npn |
| 1168 |
\clistmap_bound_cs_group:nnnnn |
| 1169 |
#1 % <cs name> |
| 1170 |
#2 % <signature> |
| 1171 |
#3 % <group (bool)> |
| 1172 |
#4 % <arguments> |
| 1173 |
#5 % <clist> |
| 1174 |
{\@@_bound_cs:nnne{#1}{#2}{#4}{\bool_if:nTF{#3}{{#5}}{#5}}} |
| 1175 |
\cs_generate_variant:Nn\clistmap_bound_cs_use_group:nnnnn{nnenn} |
| 1176 |
\cs_new:Npn |
| 1177 |
\@@_bound_cs:nnnn |
| 1178 |
#1 % <cs name> |
| 1179 |
#2 % <signature> |
| 1180 |
#3 % <arguments> |
| 1181 |
#4 % <clist> |
| 1182 |
{ \use:c{\@@_bound_cs_c:nn{#1}{#2}}#3{#4} } |
| 1183 |
\cs_generate_variant:Nn\@@_bound_cs:nnnn{nnne} |
| 1184 |
% \end{macrocode} |
| 1185 |
% \end{macro} |
| 1186 |
% \section{\textsf{rule}}\label{sec:rule} |
| 1187 |
% \begin{macro}{rule} |
| 1188 |
% \begin{macrocode} |
| 1189 |
\keys_define:nn{ @@ } |
| 1190 |
{ rule.code:n = \@@_rule:nn#1 } |
| 1191 |
% \end{macrocode} |
| 1192 |
% \end{macro} |
| 1193 |
% \begin{macro}{\@@_rule:nn} |
| 1194 |
% \begin{macrocode} |
| 1195 |
\prop_new:N\@@_rule_clist |
| 1196 |
\@@_info_clist_put:nn{rule}{@@_rule_clist} |
| 1197 |
\cs_new_protected:Npn |
| 1198 |
\@@_rule:nn |
| 1199 |
#1 % <rule> |
| 1200 |
#2 % <code> |
| 1201 |
{% |
| 1202 |
\clist_gput_right:Nn\@@_rule_clist{#1} |
| 1203 |
\exp_args:Nno |
| 1204 |
\cs_new_protected:cn |
| 1205 |
{ \@@_rule_c:n{#1} } |
| 1206 |
{% |
| 1207 |
\@@_rule_apply:nnnnnnnn |
| 1208 |
{#1} % {<rule>} |
| 1209 |
{#2} % {<code>} |
| 1210 |
{##1} % <next rule> |
| 1211 |
{##2} % <cs name> |
| 1212 |
{##3} % <signature> |
| 1213 |
{{##4}{##5}{##6}} % <head is group> |
| 1214 |
% ^^A <arguments> |
| 1215 |
% ^^A <clist head> |
| 1216 |
{##7} % <clist rest> |
| 1217 |
{##8} % <parameters} |
| 1218 |
} |
| 1219 |
} |
| 1220 |
% ^^A ##1 % <next rules> |
| 1221 |
% ^^A ##2 % <cs name> |
| 1222 |
% ^^A ##3 % <signature> |
| 1223 |
% ^^A ##4 % <head is group> |
| 1224 |
% ^^A ##5 % <arguments> |
| 1225 |
% ^^A ##6 % <clist head> |
| 1226 |
% ^^A ##7 % <clist rest> |
| 1227 |
% ^^A ##8 % <parameters> |
| 1228 |
\cs_new_protected:Npn |
| 1229 |
\@@_rule_apply:nnnnnnnn |
| 1230 |
#1 % <rule> |
| 1231 |
#2 % <code> |
| 1232 |
#3 % <next rules> |
| 1233 |
#4 % <cs name> |
| 1234 |
#5 % <signature> |
| 1235 |
#6 % {<head is group>}{<arguments>}{<clist head>} |
| 1236 |
#7 % <clist rest> |
| 1237 |
#8 % <parameters> |
| 1238 |
{% |
| 1239 |
\@@_rule_apply:ennnnnn |
| 1240 |
{\@@_instance_c_this:nnnn{#1}{#3}{#4}{#5}} |
| 1241 |
{#2}#6{#7}{#8} |
| 1242 |
} |
| 1243 |
\cs_new_protected:Npn |
| 1244 |
\@@_rule_apply:nnnnnnn |
| 1245 |
#1 % <instance> |
| 1246 |
#2 % <code> |
| 1247 |
#3 % <head is group> |
| 1248 |
#4 % <arguments> |
| 1249 |
#5 % <clist head> |
| 1250 |
#6 % <clist rest> |
| 1251 |
#7 % <parameters> |
| 1252 |
{% |
| 1253 |
\cs_if_exist:cF{#1} |
| 1254 |
{%^^A |
| 1255 |
\cs_new:cpn{#1} |
| 1256 |
#3#7#5, #6\q_recursion_stop % <parameters> |
| 1257 |
{#2} |
| 1258 |
} |
| 1259 |
} |
| 1260 |
\cs_generate_variant:Nn\@@_rule_apply:nnnnnnn{e} |
| 1261 |
% \end{macrocode} |
| 1262 |
% \end{macro} |
| 1263 |
% \section{\textsf{rule template}} |
| 1264 |
% \begin{macrocode} |
| 1265 |
\cs_new:Nn |
| 1266 |
\@@_quark_if_recursion_tail_stop:nn |
| 1267 |
{\quark_if_recursion_tail_stop:n{#1#2}} |
| 1268 |
\cs_generate_variant:Nn\@@_quark_if_recursion_tail_stop:nn{e} |
| 1269 |
% \end{macrocode} |
| 1270 |
% \begin{macro} |
| 1271 |
% {rule_if_rest_is_tail_eval_else} |
| 1272 |
% \begin{macrocode} |
| 1273 |
\keys_define:nn{ @@ } |
| 1274 |
{% |
| 1275 |
rule_if_rest_is_tail_eval_else.code:n |
| 1276 |
= {\@@_rule_if_rest_is_tail_eval_else:nn#1} |
| 1277 |
} |
| 1278 |
\cs_new_protected:Npn |
| 1279 |
\@@_rule_if_rest_is_tail_eval_else:nn |
| 1280 |
#1 % <name> |
| 1281 |
#2 % <else code> |
| 1282 |
{% |
| 1283 |
% ^^A ##1 % <next rules> |
| 1284 |
% ^^A ##2 % <cs name> |
| 1285 |
% ^^A ##3 % <signature> |
| 1286 |
% ^^A ##4 % <head is group> |
| 1287 |
% ^^A ##5 % <arguments> |
| 1288 |
% ^^A ##6 % <clist head> |
| 1289 |
% ^^A ##7 % <clist rest> |
| 1290 |
% ^^A ##8 % <parameters> |
| 1291 |
\clistmap_keys_set:n |
| 1292 |
{% |
| 1293 |
rule = {if_rest_is_tail_eval_else_#1} |
| 1294 |
{% |
| 1295 |
\quark_if_recursion_tail_stop_do:nn{##7} |
| 1296 |
{% |
| 1297 |
\clistmap_bound_cs_group:nnnnn |
| 1298 |
{##2} % <cs name> |
| 1299 |
{##3} % <signature> |
| 1300 |
{##4} % <head is group> |
| 1301 |
{##5} % <arguments> |
| 1302 |
{##6} % <clist> |
| 1303 |
} |
| 1304 |
#2 |
| 1305 |
} |
| 1306 |
} |
| 1307 |
} |
| 1308 |
% \end{macrocode} |
| 1309 |
% \end{macro} |
| 1310 |
% \begin{macro}{rule_if_empty_stop_else} |
| 1311 |
% \begin{macrocode} |
| 1312 |
\keys_define:nn |
| 1313 |
{ @@ } |
| 1314 |
{ |
| 1315 |
rule_if_empty_stop_else.code:n |
| 1316 |
= {\@@_rule_if_empty_stop_else:nn#1} |
| 1317 |
} |
| 1318 |
\cs_new_protected:Npn |
| 1319 |
\@@_rule_if_empty_stop_else:nn |
| 1320 |
#1 % <name> |
| 1321 |
#2 % <else code> |
| 1322 |
{% |
| 1323 |
% ^^A ##1 % <next rules> |
| 1324 |
% ^^A ##2 % <cs name> |
| 1325 |
% ^^A ##3 % <signature> |
| 1326 |
% ^^A ##4 % <head is group> |
| 1327 |
% ^^A ##5 % <arguments> |
| 1328 |
% ^^A ##6 % <clist head> |
| 1329 |
% ^^A ##7 % <clist rest> |
| 1330 |
% ^^A ##8 % <parameters> |
| 1331 |
\clistmap_keys_set:n |
| 1332 |
{% |
| 1333 |
rule = {if_empty_stop_else_#1} |
| 1334 |
{% |
| 1335 |
\@@_quark_if_recursion_tail_stop:en |
| 1336 |
{\bool_if:nTF{##4}{{##6}}{##6}}{##7} |
| 1337 |
#2 |
| 1338 |
} |
| 1339 |
} |
| 1340 |
} |
| 1341 |
% \end{macrocode} |
| 1342 |
% \end{macro} |
| 1343 |
% \section{\textsf{instantiate}} |
| 1344 |
% \begin{macro}{\@@_instantiate:nnnn} |
| 1345 |
% \begin{macrocode} |
| 1346 |
\cs_new_protected:Npn |
| 1347 |
\@@_instantiate:nnnn |
| 1348 |
#1 % <rule> |
| 1349 |
#2 % <next rules> |
| 1350 |
#3 % <cs name> |
| 1351 |
#4 % <signature> |
| 1352 |
{% |
| 1353 |
\exp_args:Ne |
| 1354 |
\@@_instantiate:nnnnn |
| 1355 |
{\tl_count:n{#4}} % <signature arity> |
| 1356 |
{#1} % <rule> |
| 1357 |
{#2} % <next rules> |
| 1358 |
{#3} % <cs name> |
| 1359 |
{#4} % <signature> |
| 1360 |
} |
| 1361 |
\cs_new_protected:Npn |
| 1362 |
\@@_instantiate:nnnnn |
| 1363 |
#1 % <signature arity> |
| 1364 |
#2 % <rule> |
| 1365 |
#3 % <next rules> |
| 1366 |
#4 % <cs name> |
| 1367 |
#5 % <signature> |
| 1368 |
{%^^A |
| 1369 |
\@@_instantiate:eeeeennn |
| 1370 |
{ \erw_parameter:n{ 1 } } % <head is group> |
| 1371 |
{ \erw_parameter:ne{2}{ #1 } } % <parameters> |
| 1372 |
{ \erw_parameter:e{ \int_eval:n{#1+2} } } % <clist head> |
| 1373 |
{ \erw_parameter:e{ \int_eval:n{#1+3} } } % <clist rest> |
| 1374 |
{ \erw_argument:ne{2}{ #5 } } % <arguments> |
| 1375 |
{ #2 } % <rule> |
| 1376 |
{ #3 } % <next rules> |
| 1377 |
{ #4 } % <cs name> |
| 1378 |
{ #5 } % <signature> |
| 1379 |
} |
| 1380 |
\cs_new:Npn |
| 1381 |
\@@_instantiate:nnnnnnnn |
| 1382 |
#1 % <head is group> |
| 1383 |
#2 % <parameters> |
| 1384 |
#3 % <clist head> |
| 1385 |
#4 % <clist rest> |
| 1386 |
#5 % <arguments> |
| 1387 |
#6 % <rule> |
| 1388 |
#7 % <next rules> |
| 1389 |
#8 % <cs name> |
| 1390 |
#9 % <signature> |
| 1391 |
{% |
| 1392 |
\use:c{ \@@_rule_c:n{#6} } |
| 1393 |
{#7} % <next rules> |
| 1394 |
{#8} % <cs name> |
| 1395 |
{#9} % <signature> |
| 1396 |
{#1} % <head is group> |
| 1397 |
{#2} % <arguments> |
| 1398 |
{#3} % <clist head> |
| 1399 |
{#4} % <clist rest> |
| 1400 |
{#2} % <parameters> |
| 1401 |
} |
| 1402 |
\cs_generate_variant:Nn\@@_instantiate:nnnnnnnn{eeeee} |
| 1403 |
% \end{macrocode} |
| 1404 |
% \end{macro} |
| 1405 |
% \section{\textsf{property}} |
| 1406 |
% \begin{macro}{rule_sequence} |
| 1407 |
% \begin{macrocode} |
| 1408 |
\cs_new:Npn |
| 1409 |
\@@_rule_sequence_name:n |
| 1410 |
#1 % <rule sequence> |
| 1411 |
{% |
| 1412 |
\@@_rule_link:e |
| 1413 |
{\@@_rule_sequence_get:n{#1}{null}} |
| 1414 |
} |
| 1415 |
\keys_define:nn{@@} |
| 1416 |
{ rule_sequence.code:n = \@@_rule_sequence_from_keyval:n{#1} } |
| 1417 |
\prop_new:N\@@_rule_sequence_prop |
| 1418 |
\@@_info_prop_put:nn{rule_sequence}{@@_rule_sequence_prop} |
| 1419 |
\cs_new_protected:Npn |
| 1420 |
\@@_rule_sequence_from_keyval:n |
| 1421 |
#1 % <key = {{rule{1}}...> |
| 1422 |
{% |
| 1423 |
\prop_set_from_keyval:Nn |
| 1424 |
\@@_rule_sequence_prop{#1} |
| 1425 |
} |
| 1426 |
\cs_new:Npn |
| 1427 |
\@@_rule_sequence_get:n |
| 1428 |
#1 % <key> |
| 1429 |
{% |
| 1430 |
\exp_args:Ne |
| 1431 |
\@@_rule_sequence_aux:n |
| 1432 |
{% |
| 1433 |
\prop_item:Nn |
| 1434 |
\@@_rule_sequence_prop{#1} |
| 1435 |
} |
| 1436 |
} |
| 1437 |
\cs_new:Npn |
| 1438 |
\@@_rule_sequence_aux:n |
| 1439 |
#1 % <value> |
| 1440 |
{% |
| 1441 |
\prop_if_in:NnTF |
| 1442 |
\@@_rule_sequence_prop |
| 1443 |
{#1} |
| 1444 |
{\@@_rule_sequence_get:n{#1}} |
| 1445 |
{#1} |
| 1446 |
} |
| 1447 |
% \end{macrocode} |
| 1448 |
% \end{macro} |
| 1449 |
% \begin{macro}{\clistmap_signature:n, \clistmap_instance_p:n} |
| 1450 |
% \begin{macrocode} |
| 1451 |
\prg_new_conditional:Npnn |
| 1452 |
\clistmap_instance:n |
| 1453 |
#1 |
| 1454 |
{p} |
| 1455 |
{\prop_if_in:NnTF |
| 1456 |
\@@_instance_prop{#1} |
| 1457 |
{\prg_return_true:} |
| 1458 |
{\prg_return_false:} |
| 1459 |
} |
| 1460 |
\msg_new:nnn{@@}{instance-not}{#1~is~not~an~instance} |
| 1461 |
\msg_new:nnn{@@}{key-conflict}{key~#1~already~exists~in~prop~#2} |
| 1462 |
\prop_new:N\@@_instance_prop |
| 1463 |
\@@_info_prop_put:nn{instance}{@@_instance_prop} |
| 1464 |
\cs_new_protected:Npn |
| 1465 |
\@@_instance_put:nnnn |
| 1466 |
#1 % <key> |
| 1467 |
#2 % <rule sequence> |
| 1468 |
#3 % <name> |
| 1469 |
#4 % <signature> |
| 1470 |
{% |
| 1471 |
\prop_gput:Nnn |
| 1472 |
\@@_instance_prop{#1} |
| 1473 |
{ {#2}{#3}{#4} } |
| 1474 |
} |
| 1475 |
\cs_new:Npn |
| 1476 |
\@@_instance_get:n |
| 1477 |
#1 % <key> |
| 1478 |
{ \prop_item:Nn\@@_instance_prop{#1} } |
| 1479 |
\cs_new:Nn |
| 1480 |
\clistmap_signature:n |
| 1481 |
{%^^A |
| 1482 |
\bool_if:nTF |
| 1483 |
{ \clistmap_instance_p:n{#1} } |
| 1484 |
{ \@@_instance_signature_get:n{#1} } |
| 1485 |
{ \msg_error:nnn{@@}{instance-not}{#1} } |
| 1486 |
} |
| 1487 |
\cs_new:Npn |
| 1488 |
\@@_instance_signature_get:n |
| 1489 |
#1 % <instance> |
| 1490 |
{\exp_last_unbraced:Ne\use_iii:nnn |
| 1491 |
{\@@_instance_get:n{#1}}} |
| 1492 |
\cs_new:Npn |
| 1493 |
\@@_instance_expand:n |
| 1494 |
#1 %^^A <instance(?:_sequence)_1,...> |
| 1495 |
{%^^A |
| 1496 |
\@@_instance_expand:w |
| 1497 |
#1, \q_recursion_tail |
| 1498 |
\q_recursion_stop |
| 1499 |
} |
| 1500 |
\cs_new:Npn |
| 1501 |
\@@_instance_expand:w |
| 1502 |
#1 %^^A <instance(?:_sequence)_1,...> |
| 1503 |
,#2 |
| 1504 |
\q_recursion_stop |
| 1505 |
{ |
| 1506 |
\quark_if_recursion_tail_stop:n{#1#2} |
| 1507 |
\@@_instance_expand:nw#1, #2\q_recursion_stop |
| 1508 |
} |
| 1509 |
\cs_new:Npn |
| 1510 |
\@@_instance_expand:nw |
| 1511 |
#1 % <head> |
| 1512 |
, #2 % <rest> |
| 1513 |
\q_recursion_stop |
| 1514 |
{ |
| 1515 |
\bool_if:nTF |
| 1516 |
{\clistmap_instance_sequence_p:n{#1}} |
| 1517 |
{%^^A |
| 1518 |
\exp_args:Ne |
| 1519 |
\@@_instance_expand:n |
| 1520 |
{ \@@_instance_sequence_get:n{#1} } |
| 1521 |
} |
| 1522 |
{% |
| 1523 |
\bool_if:nTF |
| 1524 |
{\clistmap_instance_p:n{#1}} |
| 1525 |
{#1} |
| 1526 |
{\msg_error:nnn{@@}{neither-inst-seq}{#1}} |
| 1527 |
} |
| 1528 |
\quark_if_recursion_tail_stop:n{#2},%^^A comma |
| 1529 |
\@@_instance_expand:nw#2\q_recursion_stop |
| 1530 |
} |
| 1531 |
\msg_new:nnn{@@}{neither-inst-seq} |
| 1532 |
{#1~is~neither~an~instance~nor~a~sequence} |
| 1533 |
\prg_new_conditional:Npnn |
| 1534 |
\@@_instance_signature:nn |
| 1535 |
#1 % <instance_1,...> |
| 1536 |
#2 % <signature> |
| 1537 |
{p} |
| 1538 |
{%^^A |
| 1539 |
\bool_if:nTF |
| 1540 |
{ |
| 1541 |
\exp_args:Ne |
| 1542 |
\@@_instance_signature_aux_p:nn |
| 1543 |
{%^^A |
| 1544 |
\exp_args:Ne |
| 1545 |
\clist_map_function:nN |
| 1546 |
{ \@@_instance_expand:n{#1} } |
| 1547 |
\clistmap_signature:n |
| 1548 |
} |
| 1549 |
{#2} |
| 1550 |
} |
| 1551 |
{\prg_return_true:} |
| 1552 |
{\prg_return_false:} |
| 1553 |
} |
| 1554 |
\prg_new_conditional:Npnn |
| 1555 |
\@@_instance_signature_aux:nn |
| 1556 |
#1 % <signature_1,...> |
| 1557 |
#2 % <signature> |
| 1558 |
{p} |
| 1559 |
{% |
| 1560 |
\tl_if_empty:nTF |
| 1561 |
{#1} |
| 1562 |
{%^^A |
| 1563 |
\tl_if_empty:nTF{#2} |
| 1564 |
{\prg_return_true:} |
| 1565 |
{\prg_return_false:} |
| 1566 |
} |
| 1567 |
{%^^A |
| 1568 |
\bool_if:nTF |
| 1569 |
{%^^A |
| 1570 |
\erw_and_tl_p:nn |
| 1571 |
{ \str_if_eq_p:nn{#2} } |
| 1572 |
{ #1 } |
| 1573 |
} |
| 1574 |
{\prg_return_true:} |
| 1575 |
{\prg_return_false:} |
| 1576 |
} |
| 1577 |
} |
| 1578 |
% \end{macrocode} |
| 1579 |
% \end{macro} |
| 1580 |
% \begin{macro}{instance_sequence, \clistmap_instance_sequence_p:n} |
| 1581 |
% \begin{macrocode} |
| 1582 |
\keys_define:nn{ @@ } |
| 1583 |
{%^^A |
| 1584 |
instance_sequence.code:n |
| 1585 |
= {%^^A |
| 1586 |
\clist_map_function:nN{#1} |
| 1587 |
\@@_instance_sequence_put:n |
| 1588 |
} |
| 1589 |
} |
| 1590 |
\prg_new_conditional:Npnn |
| 1591 |
\clistmap_instance_sequence:n |
| 1592 |
#1 |
| 1593 |
{p} |
| 1594 |
{% |
| 1595 |
\prop_if_in:NnTF |
| 1596 |
\@@_instance_sequence_prop{#1} |
| 1597 |
{\prg_return_true:} |
| 1598 |
{\prg_return_false:} |
| 1599 |
} |
| 1600 |
\prop_new:N |
| 1601 |
\@@_instance_sequence_prop |
| 1602 |
\@@_info_prop_put:nn{instance_sequence}{@@_instance_sequence_prop} |
| 1603 |
\cs_new:Nn\@@_first_braced:nn{{#1}} |
| 1604 |
\cs_new:Nn\@@_instance_sequence_keys: |
| 1605 |
{% |
| 1606 |
\prop_map_function:NN |
| 1607 |
\@@_instance_sequence_prop |
| 1608 |
\@@_first_braced:nn |
| 1609 |
} |
| 1610 |
% ^^A\cs_new_protected:Npn |
| 1611 |
% ^^A\@@_instance_sequence_put:n |
| 1612 |
% ^^A#1 % <{key}{key{1},...}> |
| 1613 |
% ^^A{ \@@_instance_sequence_put:nn#1 } |
| 1614 |
\cs_new_protected:Npn |
| 1615 |
\@@_instance_sequence_put:n |
| 1616 |
#1 % <{signature}{prefix key}{prefix key{1},...}> |
| 1617 |
{ \@@_instance_sequence_put:nnn#1 } |
| 1618 |
\cs_new:Npn |
| 1619 |
\@@_instance_sequence_value:nn |
| 1620 |
#1 % <signature> |
| 1621 |
#2 % <key prefix 1,...> |
| 1622 |
{% |
| 1623 |
\exp_args:Nne |
| 1624 |
\erw_clist_tl:nn{\c_false_bool} |
| 1625 |
{%^^A |
| 1626 |
\clist_map_tokens:nn |
| 1627 |
{#2} |
| 1628 |
{ \@@_instance_sequence_value_aux:nn{#1} } |
| 1629 |
} |
| 1630 |
} |
| 1631 |
\cs_new:Nn |
| 1632 |
\@@_instance_sequence_value_aux:nn |
| 1633 |
{{\clistmap_instance_key:nn{#2}{#1}}} |
| 1634 |
\cs_new_protected:Npn |
| 1635 |
\@@_instance_sequence_put:nnn |
| 1636 |
#1 % <signature> |
| 1637 |
#2 % <prefix key> |
| 1638 |
#3 % <prefix key{1}>,... |
| 1639 |
{%^^A |
| 1640 |
\exp_args:Nee |
| 1641 |
\@@_instance_sequence_put:nn |
| 1642 |
{ \clistmap_instance_key:nn{#2}{#1} } |
| 1643 |
{ \@@_instance_sequence_value:nn{#1}{#3} } |
| 1644 |
} |
| 1645 |
\cs_new_protected:Npn |
| 1646 |
\@@_instance_sequence_put:nn |
| 1647 |
#1 % <key> |
| 1648 |
#2 % <instance key{1}>,... |
| 1649 |
{% |
| 1650 |
\prop_if_in:NnTF |
| 1651 |
\@@_instance_prop{#1} |
| 1652 |
{\msg_error:nnnn{@@}{key-conflict}{#1}{instance}} |
| 1653 |
{% |
| 1654 |
\prop_gput:Nnn |
| 1655 |
\@@_instance_sequence_prop{#1} |
| 1656 |
{ #2 } |
| 1657 |
} |
| 1658 |
} |
| 1659 |
\cs_new:Nn |
| 1660 |
\clistmap_instance_sequence:n |
| 1661 |
{\@@_instance_sequence_get:n{#1}} |
| 1662 |
\cs_new:Npn |
| 1663 |
\@@_instance_sequence_get:n |
| 1664 |
#1 % <key> |
| 1665 |
{\prop_item:Nn\@@_instance_sequence_prop{#1}} |
| 1666 |
% \end{macrocode} |
| 1667 |
% \end{macro} |
| 1668 |
% \section{\textsf{instance}} |
| 1669 |
% \begin{macro}{instance, \clistmap_instance_key:nn} |
| 1670 |
% \begin{macrocode} |
| 1671 |
\keys_define:nn{@@} |
| 1672 |
{ instance.code:n = \clist_map_function:nN{#1} \@@_instance:n } |
| 1673 |
\cs_new_protected:Npn |
| 1674 |
\@@_instance:n |
| 1675 |
% ^^A#1 % {key prefix}{<rule sequence>}{<cs name>}{<signature>} |
| 1676 |
#1 % {<signature>}{key prefix}{<rule sequence>}{<cs name>} |
| 1677 |
{ \@@_instance:nnnn#1 } |
| 1678 |
\cs_new_protected:Npn |
| 1679 |
\@@_instance:nnnn |
| 1680 |
% ^^A#1 % <key prefix> |
| 1681 |
% ^^A#2 % <rule sequence> |
| 1682 |
% ^^A#3 % <cs name> |
| 1683 |
% ^^A#4 % <signature> |
| 1684 |
#1 % <signature> |
| 1685 |
#2 % <key prefix> |
| 1686 |
#3 % <rule sequence> |
| 1687 |
#4 % <cs name> |
| 1688 |
{% |
| 1689 |
\exp_args:Ne |
| 1690 |
\@@_instance_aux:nnnn |
| 1691 |
{ \clistmap_instance_key:nn{#2}{#1} } |
| 1692 |
{#3}{#4}{#1} |
| 1693 |
} |
| 1694 |
\cs_new:Npn |
| 1695 |
\clistmap_instance_key:nn |
| 1696 |
#1 % <key prefix> |
| 1697 |
#2 % <signature> |
| 1698 |
{#1:#2} |
| 1699 |
\cs_new_protected:Npn |
| 1700 |
\@@_instance_aux:nnnn |
| 1701 |
#1 % <key> |
| 1702 |
#2 % <rule sequence> |
| 1703 |
#3 % <signature> |
| 1704 |
#4 % <cs name> |
| 1705 |
{% |
| 1706 |
\@@_instance_put:nnnn{#1}{#2}{#3}{#4} |
| 1707 |
\@@_instance_using_key:nnn{#2}{#3}{#4} |
| 1708 |
} |
| 1709 |
\cs_new_protected:Npn |
| 1710 |
\@@_instance_using_key:nnn |
| 1711 |
#1 % <rule sequence> |
| 1712 |
#2 % <cs name> |
| 1713 |
#3 % <signature> |
| 1714 |
{% |
| 1715 |
\@@_instance_using_list:enn |
| 1716 |
{ \@@_rule_sequence_get:n{#1}{null} } % <{rule{1}}...> |
| 1717 |
{#2} % <cs name> |
| 1718 |
{#3}% <signature> |
| 1719 |
} |
| 1720 |
\cs_new_protected:Npn |
| 1721 |
\@@_instance_using_list:nnn |
| 1722 |
#1 % <{rule{1}}{rule{2}}...> |
| 1723 |
#2 % <cs name> |
| 1724 |
#3 % <signature> |
| 1725 |
{% |
| 1726 |
\exp_last_unbraced:Ne |
| 1727 |
\@@_instance_backward:nnnnn |
| 1728 |
{% |
| 1729 |
{ \tl_count:n{#3} } % <signature arity> |
| 1730 |
\erw_last:n{#1} % <rule{n}> |
| 1731 |
{ \erw_remove_first:e{\tl_reverse:n{#1}} } % <{rule{n-1}}{rule{n-2}}...> |
| 1732 |
} |
| 1733 |
{ #2 } % <cs name> |
| 1734 |
{ #3 } % <signature> |
| 1735 |
} |
| 1736 |
\cs_generate_variant:Nn\@@_instance_using_list:nnn{enn} |
| 1737 |
\msg_new:nnn{@@}{null} |
| 1738 |
{clistmap~expects~'null'~as~the~last~rule;~got~'#1'} |
| 1739 |
\cs_new_protected:Npn |
| 1740 |
\@@_instance_backward:nnnnn |
| 1741 |
#1 % <signature arity> |
| 1742 |
#2 % <rule{n}> |
| 1743 |
#3 % <{rule{n-1}}{rule{n-2}}...> |
| 1744 |
#4 % <cs name> |
| 1745 |
#5 % <signature> |
| 1746 |
{% |
| 1747 |
\str_case:nnTF{#2} |
| 1748 |
{ {null}{} } |
| 1749 |
{% |
| 1750 |
\@@_instance_backward:nnnw |
| 1751 |
{#2} % <next rules> |
| 1752 |
{#4} % <cs name> |
| 1753 |
{#5} % <signature> |
| 1754 |
#3\q_recursion_tail % <{rule{n}}{rule{n-1}}...> |
| 1755 |
\q_recursion_stop |
| 1756 |
} |
| 1757 |
{% |
| 1758 |
\msg_error:nnn{@@} |
| 1759 |
{null} |
| 1760 |
{#2} |
| 1761 |
} |
| 1762 |
} |
| 1763 |
\cs_generate_variant:Nn\@@_instance_backward:nnnnn{eee} |
| 1764 |
\cs_new_protected:Npn |
| 1765 |
\@@_instance_backward:nnnw |
| 1766 |
#1 % <next rules> |
| 1767 |
#2 % <cs name> |
| 1768 |
#3 % <signature> |
| 1769 |
#4 % <{rule{n}}{rule{n-1}}...> |
| 1770 |
\q_recursion_stop |
| 1771 |
{% |
| 1772 |
\quark_if_recursion_tail_stop:n{#4} |
| 1773 |
\@@_instance_backward:nnnnw |
| 1774 |
{#1} % <next rules> |
| 1775 |
{#2} % <cs name> |
| 1776 |
{#3} % <signature> |
| 1777 |
#4 % <rule{n}> |
| 1778 |
% <{rule{n-1}}...> |
| 1779 |
\q_recursion_stop |
| 1780 |
} |
| 1781 |
\cs_generate_variant:Nn\@@_instance_backward:nnnw{e} |
| 1782 |
\cs_new_protected:Npn |
| 1783 |
\@@_instance_backward:nnnnw |
| 1784 |
#1 % <next rules> |
| 1785 |
#2 % <cs name> |
| 1786 |
#3 % <signature> |
| 1787 |
#4 % <rule{n}> |
| 1788 |
#5 % <{rule{n-1}}...> |
| 1789 |
\q_recursion_stop |
| 1790 |
{% |
| 1791 |
\@@_instantiate:nnnn |
| 1792 |
{#4} % <rule> |
| 1793 |
{#1} % <next rules> |
| 1794 |
{#2} % <cs name> |
| 1795 |
{#3} % <signature> |
| 1796 |
\@@_instance_backward:ennw |
| 1797 |
{\@@_rule_link:nn{#4}{#1}} % <next rules> |
| 1798 |
{#2} % <cs name> |
| 1799 |
{#3} % <signature> |
| 1800 |
#5 % <{rule{n}}...> |
| 1801 |
\q_recursion_stop |
| 1802 |
} |
| 1803 |
% \end{macrocode} |
| 1804 |
% \end{macro} |
| 1805 |
% \section{\textsf{preset}} |
| 1806 |
% \subsection{\textsf{rule}} |
| 1807 |
% \begin{macrocode} |
| 1808 |
\msg_new:nnn{@@}{tail}{expects~tail;~got~'#1'} |
| 1809 |
% ^^A ##1 % <next rules> |
| 1810 |
% ^^A ##2 % <cs name> |
| 1811 |
% ^^A ##3 % <signature> |
| 1812 |
% ^^A ##4 % <head is group> |
| 1813 |
% ^^A ##5 % <arguments> |
| 1814 |
% ^^A ##6 % <clist head> |
| 1815 |
% ^^A ##7 % <clist rest> |
| 1816 |
% ^^A ##8 % <args> |
| 1817 |
\clistmap_keys_set:n |
| 1818 |
{% |
| 1819 |
rule = {if_rest_is_tail_stop_else_eval_recurse} |
| 1820 |
{% |
| 1821 |
\quark_if_recursion_tail_stop:n{#7} |
| 1822 |
\clistmap_bound_cs_group:nnnnn |
| 1823 |
{#2} % <cs name> |
| 1824 |
{#3} % <signature> |
| 1825 |
{#4} % <head is group> |
| 1826 |
{#5} % <arguments> |
| 1827 |
{#6} % <clist> |
| 1828 |
\clistmap_use_w:nnnne |
| 1829 |
{if_rest_is_tail_stop_else_eval_recurse} % <rule> |
| 1830 |
{#1} % <next rule rule sequence> |
| 1831 |
{#2} % <cs name> |
| 1832 |
{#3} % <signature> |
| 1833 |
{\tl_if_head_is_group_p:n{#7}}#5#7\q_recursion_stop % <head is group> |
| 1834 |
}, |
| 1835 |
rule = {if_rest_is_tail_stop_else_forward_rest} |
| 1836 |
{% |
| 1837 |
\quark_if_recursion_tail_stop:n{#7} |
| 1838 |
\clistmap_use_w:nnne |
| 1839 |
{#1}{#2}{#3} |
| 1840 |
{\tl_if_head_is_group_p:n{#7}}#5#7\q_recursion_stop |
| 1841 |
}, |
| 1842 |
rule_if_empty_stop_else = {error} |
| 1843 |
{% |
| 1844 |
\msg_error:nnn{@@}{tail}{#6#7} |
| 1845 |
\@@_empty:w{}\q_recursion_stop |
| 1846 |
}, |
| 1847 |
rule_if_empty_stop_else = {forward_head} |
| 1848 |
{% |
| 1849 |
\bool_if:nTF{#4} |
| 1850 |
{% |
| 1851 |
\clistmap_use_w_group:nnnnnn{#1}{#2}{#3}{#4}{#5}{#6} |
| 1852 |
,\q_recursion_tail\q_recursion_stop |
| 1853 |
} |
| 1854 |
{% |
| 1855 |
\clistmap_use_w:nnnn{#1}{#2}{#3} |
| 1856 |
{#4}#5#6,\q_recursion_tail\q_recursion_stop |
| 1857 |
} |
| 1858 |
}, |
| 1859 |
rule_if_empty_stop_else = {forward_rest} |
| 1860 |
{% |
| 1861 |
\clistmap_use_w:nnne |
| 1862 |
{#1}{#2}{#3} |
| 1863 |
{\tl_if_head_is_group_p:n{#7}}#5#7\q_recursion_stop |
| 1864 |
}, |
| 1865 |
rule_if_empty_stop_else = {forward_all} |
| 1866 |
{% |
| 1867 |
\bool_if:nTF{#4} |
| 1868 |
{% |
| 1869 |
\clistmap_use_w_group:nnnnnn{#1}{#2}{#3}{#4}{#5}{#6}, |
| 1870 |
#7\q_recursion_stop |
| 1871 |
} |
| 1872 |
{% |
| 1873 |
\clistmap_use_w:nnnn |
| 1874 |
{#1}{#2}{#3}{#4}#5#6, #7\q_recursion_stop |
| 1875 |
} |
| 1876 |
}, |
| 1877 |
rule_if_rest_is_tail_eval_else = {error} |
| 1878 |
{% |
| 1879 |
\msg_error:nnn{@@}{tail}{#6} |
| 1880 |
\@@_empty:w\q_recursion_stop |
| 1881 |
}, |
| 1882 |
rule_if_rest_is_tail_eval_else = {stop} |
| 1883 |
{% |
| 1884 |
\@@_empty:w{}\q_recursion_stop |
| 1885 |
}, |
| 1886 |
rule_if_rest_is_tail_eval_else = {recurse} |
| 1887 |
{% |
| 1888 |
\clistmap_use_w:nnnne |
| 1889 |
{if_rest_is_tail_eval_else_recurse} % <rule> |
| 1890 |
{#1} % <next rule rule sequence> |
| 1891 |
{#2} % <cs name> |
| 1892 |
{#3} % <signature> |
| 1893 |
{\tl_if_head_is_group_p:n{#7}} % <head is group> |
| 1894 |
#5 % <argument> |
| 1895 |
#7 % <clist> |
| 1896 |
\q_recursion_stop |
| 1897 |
} |
| 1898 |
} |
| 1899 |
% \end{macrocode} |
| 1900 |
% \subsection{\textsf{rule_sequence}} |
| 1901 |
% \begin{macrocode} |
| 1902 |
\clistmap_keys_set:n |
| 1903 |
{% |
| 1904 |
rule_sequence = |
| 1905 |
{% |
| 1906 |
first = |
| 1907 |
{ |
| 1908 |
{if_empty_stop_else_forward_head} |
| 1909 |
{if_rest_is_tail_eval_else_error} |
| 1910 |
}, |
| 1911 |
middle = |
| 1912 |
{ |
| 1913 |
{if_empty_stop_else_forward_all} |
| 1914 |
{if_rest_is_tail_stop_else_forward_rest} |
| 1915 |
{if_rest_is_tail_stop_else_eval_recurse} |
| 1916 |
}, |
| 1917 |
last = |
| 1918 |
{ |
| 1919 |
{if_empty_stop_else_forward_all} |
| 1920 |
{if_rest_is_tail_stop_else_forward_rest} |
| 1921 |
{if_rest_is_tail_eval_else_recurse} |
| 1922 |
}, |
| 1923 |
serial_second = |
| 1924 |
{ |
| 1925 |
{if_empty_stop_else_forward_all} |
| 1926 |
{if_rest_is_tail_stop_else_forward_rest} |
| 1927 |
{if_rest_is_tail_eval_else_stop} |
| 1928 |
}, |
| 1929 |
serial_last = |
| 1930 |
{ |
| 1931 |
{if_empty_stop_else_forward_all} |
| 1932 |
{if_rest_is_tail_stop_else_forward_rest} |
| 1933 |
{if_rest_is_tail_stop_else_forward_rest} |
| 1934 |
{if_rest_is_tail_eval_else_recurse} |
| 1935 |
} |
| 1936 |
} |
| 1937 |
} |
| 1938 |
% \end{macrocode} |
| 1939 |
% \subsection{\textsf{cs}} |
| 1940 |
% \begin{macrocode} |
| 1941 |
\msg_new:nnnn{@@}{text}{text~is~not~loaded}{amsmath} |
| 1942 |
\cs_new:Nn\@@_unbrace_aux:n{#1} |
| 1943 |
\erw_keys_set:n |
| 1944 |
{ |
| 1945 |
clist_map_inline = |
| 1946 |
{% |
| 1947 |
{Nn}{apply}{#1{#2}}, |
| 1948 |
{Nn}{math}{\ensuremath{#1{#2}}}, |
| 1949 |
{Nn}{comma_map}{,\clist_map_function:nN#2#1}, |
| 1950 |
{Nn}{comma}{,#1{#2}}, |
| 1951 |
{Nn}{serial_math}{\text{,~}\ensuremath{#1{#2}}}, |
| 1952 |
{Nn}{serial_math_and}{\text{,~and~}\ensuremath{#1{#2}}}, |
| 1953 |
{Nn}{map}{\clist_map_function:nN#2#1}, |
| 1954 |
{Nn}{noindent}{\noindent}, |
| 1955 |
{n}{apply}{#1}, |
| 1956 |
{n}{math}{\ensuremath{#1}}, |
| 1957 |
{n}{comma_math}{,\ensuremath{#1}}, |
| 1958 |
{n}{newline}{\\#1}, |
| 1959 |
{n}{comma_unbrace}{,\@@_unbrace_aux:n#1}, |
| 1960 |
{n}{comma}{,#1}, |
| 1961 |
{n}{noindent}{\noindent}, |
| 1962 |
{n}{serial_and}{,~and~#1}, |
| 1963 |
{n}{serial_math_and}{\text{,~and~}\ensuremath{#1}}, |
| 1964 |
{n}{serial_math}{\text{,~}\ensuremath{#1}}, |
| 1965 |
{n}{serial}{,~#1}, |
| 1966 |
{n}{unbrace}{\@@_unbrace_aux:n#1} |
| 1967 |
} |
| 1968 |
{nnn} |
| 1969 |
{ |
| 1970 |
\clist_gput_right:Nn\@@_helper_clist{#2:#1} |
| 1971 |
\cs_new:cn{@@_#2:#1}{#3} |
| 1972 |
} |
| 1973 |
} |
| 1974 |
% \end{macrocode} |
| 1975 |
% \subsection{\textsf{instance}} |
| 1976 |
% \begin{macrocode} |
| 1977 |
\clistmap_keys_set:n |
| 1978 |
{ |
| 1979 |
instance = |
| 1980 |
{ |
| 1981 |
{N}{first_apply}{first}{@@_apply}, |
| 1982 |
{N}{first_map}{first}{@@_map}, |
| 1983 |
{N}{first_math}{first}{@@_math}, |
| 1984 |
{N}{first_noindent}{first}{@@_noindent}, |
| 1985 |
{N}{last_apply}{last}{@@_apply}, |
| 1986 |
{N}{last_comma_map}{last}{@@_comma_map}, |
| 1987 |
{N}{last_comma_math}{last}{@@_comma_math}, |
| 1988 |
{N}{last_comma}{last}{@@_comma}, |
| 1989 |
{N}{serial_last}{serial_last}{@@_comma}, |
| 1990 |
{N}{serial_second}{serial_second}{@@_comma}, |
| 1991 |
{N}{middle_apply}{middle}{@@_apply}, |
| 1992 |
{N}{middle_comma_map}{middle}{@@_comma_map}, |
| 1993 |
{N}{middle_comma_math}{middle}{@@_comma_math}, |
| 1994 |
{N}{middle_comma}{middle}{@@_comma}, |
| 1995 |
{N}{serial_last_math_and}{serial_last}{@@_serial_math_and}, |
| 1996 |
{N}{serial_middle_math}{middle}{@@_serial_math}, |
| 1997 |
{N}{serial_second_math_and}{serial_second}{@@_serial_math_and}, |
| 1998 |
{}{first_apply}{first}{@@_apply}, |
| 1999 |
{}{first_math}{first}{@@_math}, |
| 2000 |
{}{first_noindent}{first}{@@_noindent}, |
| 2001 |
{}{first_unbrace}{first}{@@_unbrace}, |
| 2002 |
{}{last_apply}{last}{@@_apply}, |
| 2003 |
{}{last_comma_math}{last}{@@_comma_math}, |
| 2004 |
{}{last_comma_unbrace}{last}{@@_comma_unbrace}, |
| 2005 |
{}{last_comma}{last}{@@_comma}, |
| 2006 |
{}{last_newline}{last}{@@_newline}, |
| 2007 |
{}{last_unbrace}{last}{@@_unbrace}, |
| 2008 |
{}{middle_apply}{middle}{@@_apply}, |
| 2009 |
{}{middle_comma_math}{middle}{@@_comma_math}, |
| 2010 |
{}{middle_comma_unbrace}{middle}{@@_comma_unbrace}, |
| 2011 |
{}{middle_comma}{middle}{@@_comma}, |
| 2012 |
{}{middle_newline}{middle}{@@_newline}, |
| 2013 |
{}{middle_unbrace}{middle}{@@_unbrace}, |
| 2014 |
{}{serial_last_and}{serial_last}{@@_serial_and}, |
| 2015 |
{}{serial_last_math_and}{serial_last}{@@_serial_math_and}, |
| 2016 |
{}{serial_middle_math}{middle}{@@_serial_math}, |
| 2017 |
{}{serial_middle}{middle}{@@_serial}, |
| 2018 |
{}{serial_second_and}{serial_second}{@@_serial_and}, |
| 2019 |
{}{serial_second_math_and}{serial_second}{@@_serial_math_and}, |
| 2020 |
} |
| 2021 |
} |
| 2022 |
% \end{macrocode} |
| 2023 |
% \subsection{\textsf{instance_sequence}} |
| 2024 |
% \begin{macrocode} |
| 2025 |
\clistmap_keys_set:n |
| 2026 |
{% |
| 2027 |
instance_sequence = |
| 2028 |
{ |
| 2029 |
{N}{apply}{first_apply, rest_apply}, |
| 2030 |
{N}{comma_map}{first_map, rest_comma_map}, |
| 2031 |
{N}{comma_math}{first_math, rest_comma_math}, |
| 2032 |
{N}{comma}{first_apply, rest_comma}, |
| 2033 |
{N}{rest_apply}{middle_apply, last_apply}, |
| 2034 |
{N}{rest_comma_map}{middle_comma_map, last_comma_map}, |
| 2035 |
{N}{rest_comma_math}{middle_comma_math, last_comma_math}, |
| 2036 |
{N}{rest_comma}{middle_comma, last_comma}, |
| 2037 |
{N}{serial_and}{first_apply, serial_rest_and}, |
| 2038 |
{N}{serial_math_and}{first_math, serial_rest_math_and}, |
| 2039 |
{N}{serial_rest_and}{serial_middle, serial_second_and, serial_last_and}, |
| 2040 |
%^^A <one long entry> |
| 2041 |
{N} |
| 2042 |
{serial_rest_math_and} |
| 2043 |
{serial_middle_math, serial_second_math_and, serial_last_math_and} |
| 2044 |
%^^A </one long entry> |
| 2045 |
, |
| 2046 |
{}{apply}{first_apply, rest_apply}, |
| 2047 |
{}{comma_math}{first_math, rest_comma_math}, |
| 2048 |
{}{newline}{first_apply, rest_newline}, |
| 2049 |
{}{comma_unbrace}{first_unbrace, rest_comma_unbrace}, |
| 2050 |
{}{comma}{first_apply, rest_comma}, |
| 2051 |
{}{rest_apply}{middle_apply, last_apply}, |
| 2052 |
{}{rest_comma_math}{middle_comma_math, last_comma_math}, |
| 2053 |
{}{rest_newline}{middle_newline, last_newline}, |
| 2054 |
{}{rest_comma_unbrace}{middle_comma_unbrace, last_comma_unbrace}, |
| 2055 |
{}{rest_comma}{middle_comma, last_comma}, |
| 2056 |
{}{rest_unbrace}{middle_unbrace, last_unbrace}, |
| 2057 |
{}{serial_and}{first_apply, serial_rest_and}, |
| 2058 |
{}{serial_math_and}{first_apply, serial_rest_math_and}, |
| 2059 |
{}{unbrace}{first_unbrace, rest_unbrace}, |
| 2060 |
% ^^A <one long entry> |
| 2061 |
{}{serial_rest_and} |
| 2062 |
{serial_middle, serial_second_and, serial_last_and} |
| 2063 |
% ^^A </one long entry> |
| 2064 |
, |
| 2065 |
% ^^A <one long entry> |
| 2066 |
{}{serial_rest_math_and} |
| 2067 |
{serial_middle_math, serial_second_math_and, serial_last_math_and} |
| 2068 |
% ^^A </one long entry> |
| 2069 |
} |
| 2070 |
} |
| 2071 |
% \end{macrocode} |
| 2072 |
% \section{\textsf{other}} |
| 2073 |
% \begin{macrocode} |
| 2074 |
\ProcessKeysOptions{@@} |
| 2075 |
\ExplSyntaxOff |
| 2076 |
%</package> |
| 2077 |
% \end{macrocode} |
| 2078 |
% \end{implementation} |
| 2079 |
% \Finale |
| 2080 |
\endinput |