Debian Codegraph @

texmf-dist/source/latex/unravel/unravel.dtx

raw
1 % \iffalse
2 %% File: unravel.dtx Copyright (C) 2013, 2015, 2018-2019, 2021, 2024 Bruno Le Floch
3 %%
4 %% It may be distributed and/or modified under the conditions of the
5 %% LaTeX Project Public License (LPPL), either version 1.3c of this
6 %% license or (at your option) any later version. The latest version
7 %% of this license is in the file
8 %%
9 %% http://www.latex-project.org/lppl.txt
10 %%
11 %% -----------------------------------------------------------------------
12 %
13 %<*driver>
14 %\fi
15 %\iffalse
16 \documentclass[full]{l3doc}
17 \usepackage{unravel}
18 \begin{document}
19 \DocInput{unravel.dtx}
20 \end{document}
21 %</driver>
22 % \fi
23 %
24 % \title{The \textsf{unravel} package: \\
25 % watching TeX digest tokens\thanks{This
26 % file has version number 0.3c, last revised 2024/01/05.}}
27 % \author{Bruno Le Floch}
28 % \date{2024/01/05}
29 %
30 % \maketitle
31 % \tableofcontents
32 %
33 % \begin{documentation}
34 %
35 % \section{\pkg{unravel} documentation}
36 %
37 % The aim of this \LaTeX{} package is to help debug complicated macros.
38 % This is done by letting the user step through the execution of some
39 % \TeX{} code, going through the details of nested expansions,
40 % performing assignments, as well as some simple typesetting commands.
41 % To use this package, one should normally run \TeX{} in a terminal.
42 %
43 % \subsection{Commands}
44 %
45 % \begin{function}{\unravel}
46 % \begin{syntax}
47 % \cs{unravel} \oarg{key-value list} \marg{code}
48 % \end{syntax}
49 % This command shows in the terminal the steps performed by \TeX{}
50 % when running the \meta{code}. By default, it pauses to let the
51 % user read the description of every step: simply press |<return>| to
52 % proceed. Typing |s|\meta{integer} instead will go forward
53 % \meta{integer} steps somewhat silently. In the future it will be
54 % possible to use a negative \meta{integer} to go back a few steps.
55 % Typing |h| gives a list of various other possibilities.
56 % The available \meta{key-value} options are described in
57 % Section~\ref{sec:options}.
58 % \end{function}
59 %
60 % \begin{function}{\unravelsetup}
61 % \begin{syntax}
62 % \cs{unravelsetup} \marg{options}
63 % \end{syntax}
64 % Sets \meta{options} that apply to all subsequent \cs{unravel}. See
65 % options in Section~\ref{sec:options}.
66 % \end{function}
67 %
68 % \begin{function}{\unravel:nn}
69 % \begin{syntax}
70 % \cs{unravel:nn} \Arg{options} \Arg{code}
71 % \end{syntax}
72 % See \cs{unravel}.
73 % \end{function}
74 %
75 % \begin{function}{\unravel_get:nnN}
76 % \begin{syntax}
77 % \cs{unravel_get:nnN} \Arg{options} \Arg{code} \meta{tl var}
78 % \end{syntax}
79 % Performs \cs{unravel:nn} with the \meta{options} and \meta{code}
80 % then saves the output into the \meta{tl var}. The option
81 % |mute| is useful in this case.
82 % \end{function}
83 %
84 % \begin{function}{\unravel_setup:n}
85 % \begin{syntax}
86 % \cs{unravel_setup:n} \Arg{options}
87 % \end{syntax}
88 % See \cs{unravelsetup}.
89 % \end{function}
90 %
91 % \subsection{Examples}
92 %
93 % The \pkg{unravel} package is currently based on the behaviour of
94 % \pdfTeX{}, but it should work in all engines supported by \pkg{expl3}
95 % (\pdfTeX{}, \XeTeX{}, \LuaTeX{}, ep\TeX{}, eup\TeX{}) as long as none
96 % of the primitives specific to those engines is used. Any
97 % difference between how \pkg{unravel} and (pdf)\TeX{} process a given
98 % piece of code, unless described in the section~\ref{sec:differences},
99 % should be reported on the issue tracker
100 % (\url{https://github.com/blefloch/latex-unravel/issues}).
101 %
102 % As a simple example, one can run \LaTeX{} on the following file.
103 % \begin{verbatim}
104 % \documentclass{article}
105 % \usepackage{unravel}
106 % \unravel
107 % {
108 % \title{My title}
109 % \author{Me}
110 % \date{\today}
111 % }
112 % \begin{document}
113 % \maketitle
114 % \end{document}
115 % \end{verbatim}
116 %
117 % A more elaborate example is to understand how \tn{newcommand} works.
118 % \begin{verbatim}
119 % \documentclass{article}
120 % \usepackage{unravel}
121 % \begin{document}
122 % \unravel
123 % {
124 % \newcommand*{\foo}[1]{bar(#1)}
125 % \foo{3}
126 % }
127 % \end{document}
128 % \end{verbatim}
129 %
130 % The \pkg{unravel} package understands deeply nested expansions as can
131 % be seen for instance by unravelling functions from \pkg{l3fp}, such as
132 % with the following code (given the current default settings, this code
133 % runs for roughly 2000 steps: you can type |s1980| as a response to the
134 % prompt, then press ``enter'' a few times to see the last few steps of
135 % expansion).
136 % \begin{verbatim}
137 % \documentclass{article}
138 % \usepackage{unravel}
139 % \begin{document}
140 % \ExplSyntaxOn
141 % \unravel { \fp_eval:n { 3.45 * 2 pi } }
142 % \ExplSyntaxOff
143 % \end{document}
144 % \end{verbatim}
145 %
146 % Given all the work that \pkg{unravel} has to do to emulate \TeX{}, it
147 % is not fast on very large pieces of code. For instance, running it on
148 % |\documentclass{article}| takes about thirty seconds on my machine, and
149 % finishes after somewhat less than $21000$ steps.
150 % \begin{verbatim}
151 % \RequirePackage{unravel}
152 % \unravel{\documentclass{article}\relax}
153 % \usepackage{lipsum}
154 % \begin{document}
155 % \lipsum
156 % \end{document}
157 % \end{verbatim}
158 % The \tn{relax} command is needed after |\documentclass{article}|
159 % because this command tries to look for an optional argument:
160 % \cs{unravel} would not find any token, and would give up, as \TeX{}
161 % would if your file ended just after |\documentclass{article}|. After
162 % running the above through \pdfTeX{}, one can check that the result is
163 % identical to that without \pkg{unravel}. Note that
164 % \cs{unravel}|{\usepackage{lipsum}\relax}|, despite taking roughly as many steps
165 % to complete, is ten times slower, because \tn{newcommand} uses
166 % delimited arguments, which prevent some optimizations that
167 % \pkg{unravel} can otherwise obtain. For comparison,
168 % |\unravel{\lipsum[1-30]}| also takes $20000$ step and is ten times
169 % faster than loading the package.
170 %
171 % \subsection{Options}
172 % \label{sec:options}
173 %
174 % \begin{function}{explicit-prompt}
175 % Boolean option (default \texttt{false}) determining whether to give
176 % an explicit prompt. If \texttt{true}, the text ``|Your input=|''
177 % will appear at the beginning of lines where user input is expected.
178 % \end{function}
179 %
180 % \begin{function}{internal-debug}
181 % Boolean option (default \texttt{false}) used to debug \pkg{unravel}
182 % itself.
183 % \end{function}
184 %
185 % \begin{function}{machine}
186 % Option which takes no value and makes \pkg{unravel} produce an
187 % output that is somewhat more suitable for automatic processing. In
188 % particular, it sets |max-action|, |max-output|, |max-input| to very
189 % large values, and |number-steps| to \texttt{false}.
190 % \end{function}
191 %
192 % \begin{function}{max-action, max-output, max-input}
193 % Integer options (defaults $50$, $300$, $300$) determining the
194 % maximum number of characters displayed for the action, the output
195 % part, and the input part.
196 % \end{function}
197 %
198 % \begin{function}{mute}
199 % Make none of the steps produce any output, by setting
200 % |trace-assigns|, |trace-expansion|, |trace-other|, |welcome-message|
201 % to \texttt{false}. This is only useful with \cs{unravel_get:nnN} or
202 % when other options change some of these settings.
203 % \end{function}
204 %
205 % \begin{function}{number-steps}
206 % Boolean option (default \texttt{true}) determining whether to
207 % number steps.
208 % \end{function}
209 %
210 % \begin{function}{online}
211 % Integer option (default~$1$) determining where to write the output:
212 % terminal and log if the option is positive, log only if the option
213 % is zero, neither if the option is negative.
214 % \end{function}
215 %
216 % \begin{function}{output-file}
217 % Name of a file where the output is written instead of the log file.
218 % Setting this option also sets \texttt{online} to zero. If
219 % \texttt{online} is further modified to be positive then the output
220 % is written to the terminal as well (hence inevitably to the log
221 % file), while if it is made negative then the output is written
222 % nowhere.
223 % \end{function}
224 %
225 % \begin{function}{prompt-input}
226 % Comma-delimited list option (empty by default) whose items are used
227 % one by one as if the user typed them at the prompt. Since the
228 % key-value list is itself comma-delimited, the value here must be
229 % wrapped in braces. For instance, |prompt-input = {s10, m, u\def}|
230 % skips $10$ steps, shows the first token's meaning, then continues
231 % silently until the first token is~|\def|, and any subsequent prompt
232 % is treated normally with user interaction. This can be useful when
233 % repeatedly debugging complicated code when the issue is known to lie
234 % quite late in the code.
235 %
236 % As for any |clist|, spaces are discarded around each comma and empty
237 % entries are removed, then for each item one pair of braces is
238 % removed (if any is present); to get an empty item use an empty brace
239 % group, such as in |prompt-input = {s10, {}, x}|. Category codes are
240 % those in effect when the |prompt-input| option is read.
241 % \end{function}
242 %
243 % \begin{function}{trace-assigns, trace-expansion, trace-other}
244 % Boolean options (default \texttt{true}) controlling what steps
245 % produce any output at all. The keys |trace-assigns|,
246 % |trace-expansion|, |trace-other| control tracing of different types
247 % of steps.
248 % \end{function}
249 %
250 % \begin{function}{welcome-message}
251 % Boolean option (default \texttt{true}) determining whether to
252 % display the welcome message.
253 % \end{function}
254 %
255 % \subsection{Differences between \pkg{unravel} and \TeX{}'s processing}
256 % \label{sec:differences}
257 %
258 % Bugs are listed at \url{https://github.com/blefloch/latex-unravel/issues}.
259 %
260 % Differences.
261 % \begin{itemize}
262 % \item Kerning between letters of a word is omitted, which can lead to
263 % incorrect widths.
264 % \item Some primitives are not implemented yet: alignments
265 % (\tn{halign}, \tn{valign}, \tn{noalign}, \tn{omit}, \tn{span},
266 % \tn{cr}, \tn{crcr},~|&|), some math mode primitives, and
267 % \tn{pdfprimitive}, as well as
268 % many primitives specific to engines other than \pdfTeX{}.
269 % This list may sadly be incomplete!
270 % \item \tn{aftergroup} is only partially implemented.
271 % \item \tn{everyhbox}, \tn{everyvbox}, \tn{everymath},
272 % \tn{everydisplay}, \tn{lastkern}, \tn{lastnodetype},
273 % \tn{lastpenalty}, \tn{lastskip}, \tn{currentifbranch}
274 % may have wrong values. Perhaps
275 % \tn{currentgrouplevel} and \tn{currentgrouptype} too.
276 % \item Setting \tn{globaldefs} to a non-zero value may cause problems.
277 % \item Tokens passed to \tn{aftergroup} are lost when \pkg{unravel} is
278 % done.
279 % \item For \pkg{unravel}, category codes are fixed when a file is read
280 % using \tn{input},
281 % while \TeX{} only fixes category codes when the corresponding
282 % characters are converted to tokens. Similarly, the argument of
283 % \tn{scantokens} is converted to the new category code regime in
284 % one go, and the result must be balanced.
285 % \item Explicit begin-group and end-group characters other than the
286 % usual left and right braces may make \pkg{unravel} choke, or may be
287 % silently replaced by the usual left and right braces.
288 % \item \tn{endinput} is ignored with a warning, as it is very difficult
289 % to implement it in a way similar to \TeX{}'s, and as it is most
290 % often used at the very end of files, in a redundant way.
291 % \item \tn{outer} is not supported.
292 % \item \cs{unravel} cannot be nested.
293 % \item Control sequences of the form \cs{notexpanded:\ldots{}} are
294 % reserved for use by \pkg{unravel}.
295 % \end{itemize}
296 %
297 % \subsection{Future perhaps}
298 %
299 % \begin{itemize}
300 % \item Use the |file-error| fatal error message: first implement
301 % \cs{@@_file_if_exist:nTF} and use it to determine whether
302 % \tn{input} will throw a fatal error in \tn{batchmode} and
303 % \tn{nonstopmode}.
304 % \item Use the |interwoven-preambles| fatal error message once
305 % alignments are implemented.
306 % \item Find out why so many input levels are used (see the log of the
307 % |unravel003| testfile for instance)
308 % \end{itemize}
309 %
310 % \end{documentation}
311 %
312 % \begin{implementation}
313 %
314 % \section{\pkg{unravel} implementation}
315 %
316 % Some support packages are loaded first, then we declare the package's
317 % name, date, version, and purpose.
318 %
319 % \begin{macrocode}
320 %<*package>
321 % \end{macrocode}
322 %
323 % \begin{macrocode}
324 %<@@=unravel>
325 % \end{macrocode}
326 %
327 % Catcode settings. In a group, set |\c| to be a synonym of |\catcode|
328 % for short, set the catcode of space to be 10 (using |\fam| to avoid
329 % needing a space or an equal sign to separate the two integer
330 % arguments of |\catcode|) and that of |%| to be 14 (using |\fam| again
331 % to avoid needing the digit 7 to have catcode other: we need the digit
332 % 5 anyway in two steps). Then make |-|, |6|, |7|, |8|, |9| other (we
333 % must assume that |0| through |5| are already other), and make |:|,
334 % |_|, |h|, |j|, |k|, |q|, |s|, |w|, |x|, |y|, |z| letters (other
335 % lowercase letters already need to be letters in the rest of the
336 % code). Make sure there is no |\endlinechar|. We are finally ready
337 % to safely test whether the package has already been loaded and bail
338 % out in case it has. Expanding |\fi| before ending the group ensures
339 % that the whole line has been read by \TeX{} before restoring earlier
340 % catcodes.
341 % \begin{macrocode}
342 \begingroup\let\c\catcode\fam32\c\fam10\advance\fam5\c\fam14\c45 12 %
343 \c54 12\c55 12\c56 12\c57 12\c58 11\c95 11\c104 11\c106 11\c107 11 %
344 \c113 11\c115 11\c119 11\c120 11\c121 11\c122 11\endlinechar-1 %
345 \expandafter\ifx\csname unravel\endcsname\relax
346 \else\endinput\expandafter\endgroup\fi
347 % \end{macrocode}
348 %
349 % Set |T| and |X| to be letters for an error message. Set up braces
350 % and |#| for definitions, |=| for nicer character code assignments,
351 % |>| for integer comparison, |+| for integer expressions.
352 % \begin{macrocode}
353 \c84 11\c88 11\c35 6\c123 1\c125 2\c62 12\c61 12\c43 12 %
354 % \end{macrocode}
355 %
356 % If \eTeX{}'s \tn{numexpr} or \tn{protected} are not available, bail
357 % out with an error.
358 % \begin{macrocode}
359 \expandafter\ifx\csname numexpr\endcsname\relax
360 \errmessage{unravel requires \numexpr from eTeX}
361 \endinput\expandafter\endgroup\fi
362 \expandafter\ifx\csname protected\endcsname\relax
363 \errmessage{unravel requires \protected from eTeX}
364 \endinput\expandafter\endgroup\fi
365 % \end{macrocode}
366 %
367 % If \pkg{unravel} is loaded within a group, bail out because
368 % \pkg{expl3} would not be loaded properly.
369 % \begin{macrocode}
370 \expandafter\ifx\csname currentgrouplevel\endcsname\relax\else
371 \ifnum\currentgrouplevel>1 \errmessage{unravel loaded in a group}
372 \endinput\expandafter\expandafter\expandafter\endgroup\fi\fi
373 % \end{macrocode}
374 %
375 % Make spaces ignored and make |~| a space, to prettify code.
376 % \begin{macrocode}
377 \catcode 32 = 9 \relax
378 \catcode 126 = 10 \relax
379 % \end{macrocode}
380 %
381 % \begin{variable}{\l_@@_setup_restore_tl}
382 % This token list variable will contain code to restore category
383 % codes to their value when the package was loaded.
384 % \begin{macrocode}
385 \gdef \l_@@_setup_restore_tl { }
386 % \end{macrocode}
387 % \end{variable}
388 %
389 % \begin{macro}{\@@_setup_restore:}
390 % Use the token list to restore catcodes to their former values, then
391 % empty the list since there is no catcode to restore anymore. This
392 % mechanism cannot be nested.
393 % \begin{macrocode}
394 \protected \gdef \@@_setup_restore:
395 {
396 \l_@@_setup_restore_tl
397 \def \l_@@_setup_restore_tl { }
398 }
399 % \end{macrocode}
400 % \end{macro}
401 %
402 % \begin{macro}{\@@_setup_save:}
403 % \begin{macro}[EXP]{\@@_setup_save_aux:n}
404 % This saves into \cs{l_@@_setup_restore_tl} the current catcodes
405 % (from $0$ to $255$ only), \tn{endlinechar}, \tn{escapechar},
406 % \tn{newlinechar}.
407 % \begin{macrocode}
408 \protected \gdef \@@_setup_save:
409 {
410 \edef \l_@@_setup_restore_tl
411 {
412 \@@_setup_save_aux:w 0 =
413 \endlinechar = \the \endlinechar
414 \escapechar = \the \escapechar
415 \newlinechar = \the \newlinechar
416 \relax
417 }
418 }
419 \long \gdef \@@_setup_save_aux:w #1 =
420 {
421 \catcode #1 = \the \catcode #1 ~
422 \ifnum 255 > #1 ~
423 \expandafter \@@_setup_save_aux:w
424 \the \numexpr #1 + 1 \expandafter =
425 \fi
426 }
427 % \end{macrocode}
428 % \end{macro}
429 % \end{macro}
430 %
431 % \begin{macro}{\@@_setup_catcodes:nnn}
432 % This sets all characters from |#1| to |#2| (inclusive) to have
433 % catcode |#3|.
434 % \begin{macrocode}
435 \protected \long \gdef \@@_setup_catcodes:nnn #1 #2 #3
436 {
437 \ifnum #1 > #2 ~ \else
438 \catcode #1 = #3 ~
439 \expandafter \@@_setup_catcodes:nnn \expandafter
440 { \the \numexpr #1 + 1 } {#2} {#3}
441 \fi
442 }
443 % \end{macrocode}
444 % \end{macro}
445 %
446 % \begin{macro}{\@@_setup_latexe:}
447 % This saves the catcodes and related parameters, then sets them to
448 % the value they normally have in a \LaTeXe{} package (in particular,
449 % |@| is a letter).
450 % \begin{macrocode}
451 \protected \gdef \@@_setup_latexe:
452 {
453 \@@_setup_save:
454 \@@_setup_catcodes:nnn {0} {8} {15}
455 \catcode 9 = 10 ~
456 \catcode 10 = 12 ~
457 \catcode 11 = 15 ~
458 \catcode 12 = 13 ~
459 \catcode 13 = 5 ~
460 \@@_setup_catcodes:nnn {14} {31} {15}
461 \catcode 32 = 10 ~
462 \catcode 33 = 12 ~
463 \catcode 34 = 12 ~
464 \catcode 35 = 6 ~
465 \catcode 36 = 3 ~
466 \catcode 37 = 14 ~
467 \catcode 38 = 4 ~
468 \@@_setup_catcodes:nnn {39} {63} {12}
469 \@@_setup_catcodes:nnn {64} {90} {11}
470 \catcode 91 = 12 ~
471 \catcode 92 = 0 ~
472 \catcode 93 = 12 ~
473 \catcode 94 = 7 ~
474 \catcode 95 = 8 ~
475 \catcode 96 = 12 ~
476 \@@_setup_catcodes:nnn {97} {122} {11}
477 \catcode 123 = 1 ~
478 \catcode 124 = 12 ~
479 \catcode 125 = 2 ~
480 \catcode 126 = 13 ~
481 \catcode 127 = 15 ~
482 \@@_setup_catcodes:nnn {128} {255} {12}
483 \endlinechar = 13 ~
484 \escapechar = 92 ~
485 \newlinechar = 10 ~
486 }
487 % \end{macrocode}
488 % \end{macro}
489 %
490 % \begin{macro}{\@@_setup_unravel:}
491 % Catcodes for \pkg{unravel} (in particular, |@| is other, |:| and
492 % |_| are letters, spaces are ignored, |~| is a space).
493 % \begin{macrocode}
494 \protected \gdef \@@_setup_unravel:
495 {
496 \@@_setup_save:
497 \@@_setup_catcodes:nnn {0} {8} {15}
498 \catcode 9 = 9 ~
499 \catcode 10 = 12 ~
500 \catcode 11 = 15 ~
501 \catcode 12 = 13 ~
502 \catcode 13 = 5 ~
503 \@@_setup_catcodes:nnn {14} {31} {15}
504 \catcode 32 = 9 ~
505 \catcode 33 = 12 ~
506 \catcode 34 = 12 ~
507 \catcode 35 = 6 ~
508 \catcode 36 = 3 ~
509 \catcode 37 = 14 ~
510 \catcode 38 = 4 ~
511 \@@_setup_catcodes:nnn {39} {57} {12}
512 \catcode 58 = 11 ~
513 \@@_setup_catcodes:nnn {59} {64} {12}
514 \@@_setup_catcodes:nnn {65} {90} {11}
515 \catcode 91 = 12 ~
516 \catcode 92 = 0 ~
517 \catcode 93 = 12 ~
518 \catcode 94 = 7 ~
519 \catcode 95 = 11 ~
520 \catcode 96 = 12 ~
521 \@@_setup_catcodes:nnn {97} {122} {11}
522 \catcode 123 = 1 ~
523 \catcode 124 = 12 ~
524 \catcode 125 = 2 ~
525 \catcode 126 = 10 ~
526 \catcode 127 = 15 ~
527 \@@_setup_catcodes:nnn {128} {255} {12}
528 \escapechar = 92 ~
529 \endlinechar = 32 ~
530 \newlinechar = 10 ~
531 }
532 % \end{macrocode}
533 % \end{macro}
534 %
535 % End the group where all catcodes where changed, but expand
536 % \cs{@@_setup_latexe:} to sanitize catcodes again outside the
537 % group. The catcodes are saved.
538 % \begin{macrocode}
539 \expandafter \endgroup \@@_setup_latexe:
540 % \end{macrocode}
541 %
542 % Load the \pkg{gtl} dependency.
543 % \begin{macrocode}
544 \RequirePackage{gtl}[2024/01/04]
545 % \end{macrocode}
546 %
547 % Before loading \pkg{unravel}, restore catcodes, so that the implicit
548 % \cs{ExplSyntaxOn} in \cs{ProvidesExplPackage} picks up the correct
549 % catcodes to restore when \cs{ExplSyntaxOff} is run at the end of the
550 % package. The place where catcodes are restored are beyond
551 % \pkg{unravel}'s reach, which is why we cannot bypass \pkg{expl3} and
552 % simply restore the catcodes once everything is done. To avoid issues
553 % with crazy catcodes, make \TeX{} read the arguments of
554 % \cs{ProvidesExplPackage} before restoring catcodes. Then immediately
555 % go to the catcodes we want.
556 % \begin{macrocode}
557 \csname use:n\endcsname
558 {%
559 \csname @@_setup_restore:\endcsname
560 \ProvidesExplPackage
561 {unravel} {2024/01/05} {0.3c} {Watching TeX digest tokens}%
562 \csname @@_setup_unravel:\endcsname
563 }%
564 % \end{macrocode}
565 %
566 % \subsection{Primitives, variants, and helpers}
567 %
568 % \subsubsection{Adjustments to \pkg{expl3}}
569 %
570 % In upcoming versions of \pkg{expl3}, the \cs{group_align_safe_begin:}
571 % and \cs{group_align_safe_end:} commands may involve an explicit
572 % end-group character token with non-standard character code, which
573 % would wrongly be normalized by \pkg{gtl} (used by \pkg{unravel}),
574 % hence break. To avoid this we change here the definitions slightly.
575 % \begin{macrocode}
576 \cs_gset:Npn \group_align_safe_begin:
577 { \exp:w \if_false: { \fi: -`} \exp_stop_f: }
578 \cs_gset:Npn \group_align_safe_end:
579 { \if_int_compare:w `{ = \c_zero_int } \fi: }
580 % \end{macrocode}
581 %
582 % \subsubsection{Renamed primitives}
583 %
584 % \begin{macro}
585 % {
586 % \@@_currentgrouptype:, \@@_everyeof:w, \@@_everypar:w,
587 % \@@_set_escapechar:n, \@@_nullfont:,
588 % \@@_hbox:w, \@@_the:w,
589 % }
590 % Copy primitives which are used multiple times, to avoid littering
591 % the code with |:D| commands. Primitives are left as |:D| in the
592 % code when that is clearer (typically when testing the meaning of
593 % a token against that of a primitive).
594 % \begin{macrocode}
595 \cs_new_eq:NN \@@_currentgrouptype: \tex_currentgrouptype:D
596 \cs_new_protected:Npn \@@_set_escapechar:n
597 { \int_set:Nn \tex_escapechar:D }
598 \cs_new_eq:NN \@@_everyeof:w \tex_everyeof:D
599 \cs_new_eq:NN \@@_everypar:w \tex_everypar:D
600 \cs_new_eq:NN \@@_hbox:w \tex_hbox:D
601 \cs_new_eq:NN \@@_mag: \tex_mag:D
602 \cs_new_eq:NN \@@_nullfont: \tex_nullfont:D
603 \cs_new_eq:NN \@@_the:w \tex_the:D
604 \cs_new_eq:NN \@@_number:w \tex_number:D
605 % \end{macrocode}
606 % \end{macro}
607 %
608 % \begin{macro}{\@@_special_relax:}
609 % A special marker slightly different from \tn{relax} (its
610 % \tn{meaning} is \tn{relax} but it differs from \tn{relax} according
611 % to \tn{ifx}). In the right-hand side of our assignment,
612 % \cs{@@_special_relax:} could be replaced by any other expandable
613 % command.
614 % \begin{macrocode}
615 \exp_after:wN \cs_new_eq:NN
616 \exp_after:wN \@@_special_relax:
617 \exp_not:N \@@_special_relax:
618 % \end{macrocode}
619 % \end{macro}
620 %
621 % \begin{macro}{\c_@@_prompt_ior, \c_@@_noprompt_ior}
622 % These are not quite primitives, but are very low-level
623 % |ior| streams to prompt the user explicitly or not.
624 % \begin{macrocode}
625 \int_const:Nn \c_@@_prompt_ior { 16 }
626 \int_const:Nn \c_@@_noprompt_ior { -1 }
627 % \end{macrocode}
628 % \end{macro}
629 %
630 % \subsubsection{Variants}
631 %
632 % Variants that we need.
633 % \begin{macrocode}
634 \cs_generate_variant:Nn \seq_push:Nn { Nf }
635 \cs_generate_variant:Nn \str_head:n { f }
636 \cs_generate_variant:Nn \tl_to_str:n { o }
637 \cs_generate_variant:Nn \tl_if_eq:nnTF { o }
638 \cs_generate_variant:Nn \tl_if_head_eq_meaning:nNT { V }
639 \cs_generate_variant:Nn \tl_if_head_eq_meaning:nNTF { V }
640 \cs_generate_variant:Nn \tl_if_single_token:nT { V }
641 \cs_generate_variant:Nn \gtl_gput_right:Nn { NV }
642 \cs_generate_variant:Nn \gtl_if_empty:NTF { c }
643 \cs_generate_variant:Nn \gtl_if_tl:NT { c }
644 \cs_generate_variant:Nn \gtl_to_str:N { c }
645 \cs_generate_variant:Nn \gtl_gpop_left:NN { c }
646 \cs_generate_variant:Nn \gtl_get_left:NN { c }
647 \cs_generate_variant:Nn \gtl_gset:Nn { c }
648 \cs_generate_variant:Nn \gtl_gconcat:NNN { ccc , cNc }
649 \cs_generate_variant:Nn \gtl_gclear:N { c }
650 \cs_generate_variant:Nn \gtl_gclear_new:N { c }
651 \cs_generate_variant:Nn \gtl_left_tl:N { c }
652 % \end{macrocode}
653 %
654 % \begin{macro}{\@@_tl_if_in:ooTF}
655 % Analogue of \cs{tl_if_in:ooTF} but with an extra group because that
656 % function redefines an auxiliary that may appear in the code being
657 % debugged (see Github issue |#27|).
658 % \begin{macrocode}
659 \cs_new_protected:Npn \@@_tl_if_in:ooTF #1#2#3#4
660 {
661 \group_begin:
662 \exp_args:Noo \tl_if_in:nnTF {#1} {#2}
663 { \group_end: #3 } { \group_end: #4 }
664 }
665 % \end{macrocode}
666 % \end{macro}
667 %
668 % \subsubsection{Miscellanous helpers}
669 %
670 % \begin{macro}{\@@_tmp:w}
671 % Temporary function used to define other functions.
672 % \begin{macrocode}
673 \cs_new_protected:Npn \@@_tmp:w { }
674 % \end{macrocode}
675 % \end{macro}
676 %
677 % \begin{macro}{\@@_file_get:nN}
678 % \begin{macro}{\@@_file_get_aux:wN}
679 % \begin{macrocode}
680 \cs_set_protected:Npn \@@_tmp:w #1
681 {
682 \cs_new_protected:Npn \@@_file_get:nN ##1##2
683 {
684 \group_begin:
685 \@@_everyeof:w { #1 ##2 }
686 \exp_after:wN \@@_file_get_aux:wN
687 \exp_after:wN \prg_do_nothing:
688 \tex_input:D ##1 \scan_stop:
689 }
690 \cs_new_protected:Npn \@@_file_get_aux:wN ##1 #1 ##2
691 {
692 \group_end:
693 \tl_set:Ne ##2
694 { \exp_not:o {##1} \exp_not:V \@@_everyeof:w }
695 }
696 }
697 \exp_args:No \@@_tmp:w { \token_to_str:N : : }
698 % \end{macrocode}
699 % \end{macro}
700 % \end{macro}
701 %
702 % \begin{macro}[EXP]{\@@_tl_first_int:N}
703 % \begin{macro}[EXP]{\@@_tl_first_int_aux:Nn}
704 % Function that finds an explicit number in a token list. This is
705 % used for instance when implementing \tn{read}, to find the stream
706 % \meta{number} within the whole \tn{read} \meta{number} |to|
707 % \meta{cs} construction. The auxiliary initially has itself as a
708 % first argument, and once a first digit is found it has
709 % \cs{use_none_delimit_by_q_stop:w}. That first argument is used
710 % whenever what follows is not a digit, hence initially we loop,
711 % while after the first digit is found any non-digit stops the
712 % recursion. If no integer is found, $0$ is left in the token list.
713 % The surrounding \cs{int_eval:n} lets us dump digits in the input
714 % stream while keeping the function fully expandable.
715 % \begin{macrocode}
716 \cs_new:Npn \@@_tl_first_int:N #1
717 {
718 \int_eval:n
719 {
720 \exp_after:wN \@@_tl_first_int_aux:Nn
721 \exp_after:wN \@@_tl_first_int_aux:Nn
722 #1 ? 0 ? \q_stop
723 }
724 }
725 \cs_new:Npn \@@_tl_first_int_aux:Nn #1#2
726 {
727 \tl_if_single:nT {#2}
728 {
729 \token_if_eq_catcode:NNT + #2
730 {
731 \if_int_compare:w 1 < 1 #2 \exp_stop_f:
732 #2
733 \exp_after:wN \use_i_ii:nnn
734 \exp_after:wN \@@_tl_first_int_aux:Nn
735 \exp_after:wN \use_none_delimit_by_q_stop:w
736 \fi:
737 }
738 }
739 #1
740 }
741 % \end{macrocode}
742 % \end{macro}
743 % \end{macro}
744 %
745 % \begin{macro}[EXP]{\@@_use_ii_i:nn}
746 % \begin{macrocode}
747 \cs_new:Npn \@@_use_ii_i:nn #1#2 { #2 #1 }
748 % \end{macrocode}
749 % \end{macro}
750 %
751 % \begin{macro}{\@@_prompt_input:Nn}
752 % \begin{macro}[rEXP]{\@@_prompt_input:w}
753 % \begin{macro}[EXP]{\@@_prompt_input_aux:w, \@@_use_none_delimit_by_q_recursion_tail:w}
754 % \begin{variable}{\q_@@_recursion_tail}
755 % \begin{macrocode}
756 \cs_new_protected:Npn \@@_prompt_input:Nn #1#2
757 {
758 \clist_gset:Ne #1
759 { \@@_prompt_input:w \prg_do_nothing: #2 , \q_@@_recursion_tail , }
760 }
761 \cs_new:Npn \@@_prompt_input:w #1 ,
762 {
763 \tl_trim_spaces_apply:oN {#1} \@@_use_ii_i:nn
764 \@@_prompt_input_aux:w ,
765 }
766 \cs_new:Npn \@@_prompt_input_aux:w #1 ,
767 {
768 \@@_use_none_delimit_by_q_recursion_tail:w #1
769 \use_none:nnnnn \q_@@_recursion_tail
770 { \tl_to_str:n {#1} } ,
771 \@@_prompt_input:w \prg_do_nothing:
772 }
773 \cs_new:Npn \@@_use_none_delimit_by_q_recursion_tail:w
774 #1 \q_@@_recursion_tail { }
775 \quark_new:N \q_@@_recursion_tail
776 % \end{macrocode}
777 % \end{variable}
778 % \end{macro}
779 % \end{macro}
780 % \end{macro}
781 %
782 % \subsubsection{String helpers}
783 %
784 % \begin{macro}{\@@_strip_escape:w}
785 % \begin{macro}{\@@_strip_escape_aux:N, \@@_strip_escape_aux:w}
786 % This is based on the 2013-07-19 (and earlier) version of
787 % \cs{cs_to_str:N}. There are three cases. If the escape character
788 % is printable, the charcode test is false, and
789 % \cs{@@_strip_escape_aux:N} removes one character. If the escape
790 % character is a space, the charcode test is true, and if there is no
791 % escape charcter, the test is unfinished after |\token_to_str:N \ |.
792 % In both of those cases, \cs{@@_strip_escape_aux:w} inserts
793 % |-\@@_number:w \fi: \c_zero_int|. If the escape character was a
794 % space, the test was true, and \cs{int_value:w} converts
795 % \cs{c_zero_int} to~|0|, hence the leading roman numeral expansion
796 % removes a space from what follows (it is important that what follows
797 % cannot start with a digit). Otherwise, the test takes~|-| as its
798 % second operand, is false, and the roman numeral expansion only sees
799 % \cs{c_zero_int}, thus does not remove anything from what follows.
800 % \begin{macrocode}
801 \cs_new:Npn \@@_strip_escape:w
802 {
803 \tex_romannumeral:D
804 \if_charcode:w \token_to_str:N \ \@@_strip_escape_aux:w \fi:
805 \@@_strip_escape_aux:N
806 }
807 \cs_new:Npn \@@_strip_escape_aux:N #1 { \c_zero_int }
808 \cs_new:Npn \@@_strip_escape_aux:w #1#2
809 { - \@@_number:w #1 \c_zero_int }
810 % \end{macrocode}
811 % \end{macro}
812 % \end{macro}
813 %
814 % \begin{macro}[EXP]{\@@_to_str:Nn}
815 % Use the type-appropriate conversion to string.
816 % \begin{macrocode}
817 \cs_new:Npn \@@_to_str:Nn #1
818 {
819 \if_meaning:w T #1
820 \exp_after:wN \tl_to_str:n
821 \else:
822 \exp_after:wN \gtl_to_str:n
823 \fi:
824 }
825 % \end{macrocode}
826 % \end{macro}
827 %
828 % \begin{macro}{\@@_str_truncate_left:nn}
829 % \begin{macro}{\@@_str_truncate_left_aux:nnn}
830 % Truncate the string |#1| to a maximum of |#2| characters. If it is
831 % longer, replace some characters on the left of the string by
832 % |(123~more~chars)~| with the appropriate number instead of~|123|.
833 % In any reasonable case, $25$ is big enough to fit this extra text.
834 % \begin{macrocode}
835 \cs_new:Npn \@@_str_truncate_left:nn #1#2
836 {
837 \exp_args:Nf \@@_str_truncate_left_aux:nnn
838 { \str_count:n {#1} } {#1} {#2}
839 }
840 \cs_new:Npn \@@_str_truncate_left_aux:nnn #1#2#3
841 {
842 \int_compare:nNnTF {#1} > {#3}
843 {
844 ( \int_eval:n { #1 - #3 + 25 } ~ more~chars ) ~
845 \str_range:nnn {#2} { #1 - #3 + 26 } {#1}
846 }
847 { \tl_to_str:n {#2} }
848 }
849 % \end{macrocode}
850 % \end{macro}
851 % \end{macro}
852 %
853 % \begin{macro}{\@@_str_truncate_right:nn}
854 % \begin{macro}{\@@_str_truncate_right_aux:nnn}
855 % Truncate the string |#1| to a maximum of |#2| characters. If it is
856 % longer, replace some characters on the right of the string by
857 % |~(123~more~chars)| with the appropriate number instead of~|123|.
858 % In any reasonable case, $25$ is big enough to fit this extra text.
859 % \begin{macrocode}
860 \cs_new:Npn \@@_str_truncate_right:nn #1#2
861 {
862 \exp_args:Nf \@@_str_truncate_right_aux:nnn
863 { \str_count:n {#1} } {#1} {#2}
864 }
865 \cs_new:Npn \@@_str_truncate_right_aux:nnn #1#2#3
866 {
867 \int_compare:nNnTF {#1} > {#3}
868 {
869 \str_range:nnn {#2} { 1 } { #3 - 25 } ~
870 ( \int_eval:n { #1 - #3 + 25 } ~ more~chars )
871 }
872 { \tl_to_str:n {#2} }
873 }
874 % \end{macrocode}
875 % \end{macro}
876 % \end{macro}
877 %
878 % \subsubsection{Helpers for control flow}
879 %
880 % \begin{macro}[EXP]{\@@_exit:w, \@@_exit_hard:w, \@@_exit_point:}
881 % Jump to the very end of this instance of \cs{unravel}.
882 % \begin{macrocode}
883 \cs_new_eq:NN \@@_exit_point: \prg_do_nothing:
884 \cs_new:Npn \@@_exit:w #1 \@@_exit_point: { }
885 \cs_new:Npn \@@_exit_hard:w #1 \@@_exit_point: #2 \@@_exit_point: { }
886 % \end{macrocode}
887 % \end{macro}
888 %
889 % \begin{macro}[EXP]{\@@_break:w, \@@_break_point:}
890 % Useful to jump out of complicated conditionals.
891 % \begin{macrocode}
892 \cs_new_eq:NN \@@_break_point: \prg_do_nothing:
893 \cs_new:Npn \@@_break:w #1 \@@_break_point: { }
894 % \end{macrocode}
895 % \end{macro}
896 %
897 % \begin{macro}{\@@_cmd_if_internal:TF}
898 % Test whether the \cs{l_@@_head_cmd_int} denotes an ``internal''
899 % command, between |min_internal| and |max_internal| (see
900 % Section~\ref{sec:numeric-codes}).
901 % \begin{macrocode}
902 \prg_new_conditional:Npnn \@@_cmd_if_internal: { TF }
903 {
904 \int_compare:nNnTF
905 \l_@@_head_cmd_int < { \@@_tex_use:n { min_internal } }
906 { \prg_return_false: }
907 {
908 \int_compare:nNnTF
909 \l_@@_head_cmd_int
910 > { \@@_tex_use:n { max_internal } }
911 { \prg_return_false: }
912 { \prg_return_true: }
913 }
914 }
915 % \end{macrocode}
916 % \end{macro}
917 %
918 % \subsubsection{Helpers concerning tokens}
919 %
920 % \begin{macro}{\@@_active_do:nn}
921 % Apply some code to an active character token constructed from its
922 % character code.
923 % \begin{macrocode}
924 \cs_new_protected:Npn \@@_active_do:nn #1#2
925 {
926 \group_begin:
927 \char_set_active_eq:nN {#1} \scan_stop:
928 \use:e
929 {
930 \group_end:
931 \exp_not:n {#2} { \char_generate:nn {#1} { 13 } }
932 }
933 }
934 % \end{macrocode}
935 % \end{macro}
936 %
937 % \begin{macro}{\@@_token_to_char:N}
938 % \begin{macro}{\@@_meaning_to_char:n, \@@_meaning_to_char:o}
939 % \begin{macro}
940 % {\@@_meaning_to_char_auxi:w, \@@_meaning_to_char_auxii:w}
941 % From the meaning of a character token (with arbitrary character
942 % code, except active), extract the character itself (with string
943 % category codes). This is somewhat robust against wrong input.
944 % \begin{macrocode}
945 \cs_new:Npn \@@_meaning_to_char:n #1
946 { \@@_meaning_to_char_auxi:w #1 \q_mark ~ {} ~ \q_mark \q_stop }
947 \cs_new:Npn \@@_meaning_to_char_auxi:w #1 ~ #2 ~ #3 \q_mark #4 \q_stop
948 { \@@_meaning_to_char_auxii:w #3 ~ #3 ~ \q_stop }
949 \cs_new:Npn \@@_meaning_to_char_auxii:w #1 ~ #2 ~ #3 \q_stop
950 { \tl_if_empty:nTF {#2} { ~ } {#2} }
951 \cs_generate_variant:Nn \@@_meaning_to_char:n { o }
952 \cs_new:Npn \@@_token_to_char:N #1
953 { \@@_meaning_to_char:o { \token_to_meaning:N #1 } }
954 % \end{macrocode}
955 % \end{macro}
956 % \end{macro}
957 % \end{macro}
958 %
959 % \begin{macro}[EXP,pTF]{\@@_token_if_expandable:N}
960 % We need to cook up our own version of \cs{token_if_expandable:NTF}
961 % because the \pkg{expl3} one does not think that |undefined| is
962 % expandable.
963 % \begin{macrocode}
964 \prg_new_conditional:Npnn \@@_token_if_expandable:N #1
965 { p , T , F , TF }
966 {
967 \exp_after:wN \if_meaning:w \exp_not:N #1 #1
968 \prg_return_false:
969 \else:
970 \prg_return_true:
971 \fi:
972 }
973 % \end{macrocode}
974 % \end{macro}
975 %
976 % \begin{macro}[EXP,pTF]{\@@_token_if_protected:N}
977 % Returns \texttt{true} if the token is either not expandable or is a
978 % protected macro.
979 % \begin{macrocode}
980 \prg_new_conditional:Npnn \@@_token_if_protected:N #1
981 { p , T , F , TF }
982 {
983 \@@_token_if_expandable:NTF #1
984 {
985 \token_if_protected_macro:NTF #1
986 { \prg_return_true: }
987 {
988 \token_if_protected_long_macro:NTF #1
989 { \prg_return_true: }
990 { \prg_return_false: }
991 }
992 }
993 { \prg_return_true: }
994 }
995 % \end{macrocode}
996 % \end{macro}
997 %
998 % \begin{macro}[TF]{\@@_token_if_active_char:N}
999 % Lowercase the token after setting its \tn{lccode} (more precisely
1000 % the \tn{lccode} of the first character in its string representation)
1001 % to a known value, then compare the result with that active
1002 % character.
1003 % \begin{macrocode}
1004 \group_begin:
1005 \char_set_catcode_active:n { `Z }
1006 \prg_new_protected_conditional:Npnn \@@_token_if_active_char:N #1
1007 { TF }
1008 {
1009 \group_begin:
1010 \exp_args:Ne \char_set_lccode:nn
1011 { ` \exp_args:No \str_head:n { \token_to_str:N #1 } }
1012 { ` Z }
1013 \tex_lowercase:D { \tl_if_eq:nnTF {#1} } { Z }
1014 { \group_end: \prg_return_true: }
1015 { \group_end: \prg_return_false: }
1016 }
1017 \group_end:
1018 % \end{macrocode}
1019 % \end{macro}
1020 %
1021 % \begin{macro}[TF]{\@@_token_if_definable:N}
1022 % Within a group, set the escape character to a non-space value
1023 % (backslash). Convert the token to a string with
1024 % \cs{token_to_str:N}. The result is multiple characters if the token
1025 % is a control sequence, and a single character otherwise (even for
1026 % explicit catcode~$6$ character tokens which would be doubled if we
1027 % used \cs{tl_to_str:n} instead of \cs{token_to_str:N}). Thus
1028 % \cs{str_tail:n} gives a non-empty result exactly for control
1029 % sequences. Those are definable (technically, not always:
1030 % |\expandafter\font\csname\endcsname=cmr10|
1031 % |\expandafter\def\the\csname\endcsname{}|). For characters just
1032 % check for active characters. In both cases remember to end the
1033 % group.
1034 % \begin{macrocode}
1035 \group_begin:
1036 \char_set_catcode_active:n { `Z }
1037 \prg_new_protected_conditional:Npnn \@@_token_if_definable:N #1
1038 { TF }
1039 {
1040 \group_begin:
1041 \@@_set_escapechar:n { 92 }
1042 \tl_set:Ne \l_@@_tmpa_tl
1043 { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
1044 \tl_if_empty:NTF \l_@@_tmpa_tl
1045 {
1046 \@@_token_if_active_char:NTF #1
1047 { \group_end: \prg_return_true: }
1048 { \group_end: \prg_return_false: }
1049 }
1050 { \group_end: \prg_return_true: }
1051 }
1052 \group_end:
1053 % \end{macrocode}
1054 % \end{macro}
1055 %
1056 % \begin{macro}[TF]{\@@_gtl_if_head_is_definable:N}
1057 % Tests if a generalized token list is a single control sequence or a
1058 % single active character. First test that it is single, then filter
1059 % out the case of (explicit) begin-group, end-group, and blank space
1060 % characters: those are neither control sequences nor active. Then
1061 % feed the single normal token to a first auxiliary.
1062 % \begin{macrocode}
1063 \prg_new_protected_conditional:Npnn \@@_gtl_if_head_is_definable:N #1
1064 { TF , F }
1065 {
1066 \gtl_if_single_token:NTF #1
1067 {
1068 \gtl_if_head_is_N_type:NTF #1
1069 {
1070 \gtl_head_do:NN #1 \@@_token_if_definable:NTF
1071 { \prg_return_true: }
1072 { \prg_return_false: }
1073 }
1074 { \prg_return_false: }
1075 }
1076 { \prg_return_false: }
1077 }
1078 % \end{macrocode}
1079 % \end{macro}
1080 %
1081 % \subsubsection{Helpers for previous input}
1082 %
1083 % \begin{macro}[EXP]{\@@_prev_input_count:, \@@_prev_input_count_aux:n, \@@_prev_input_count_aux:Nn}
1084 % Count prev input levels, skipping empty ones (of either tl or gtl
1085 % type).
1086 % \begin{macrocode}
1087 \cs_new:Npn \@@_prev_input_count:
1088 {
1089 \int_eval:n
1090 {
1091 0
1092 \seq_map_function:NN \g_@@_prev_input_seq
1093 \@@_prev_input_count_aux:n
1094 }
1095 }
1096 \cs_new:Npn \@@_prev_input_count_aux:n #1
1097 { \@@_prev_input_count_aux:Nn #1 }
1098 \cs_new:Npn \@@_prev_input_count_aux:Nn #1#2
1099 {
1100 \if_meaning:w T #1
1101 \exp_after:wN \tl_if_empty:nF
1102 \else:
1103 \exp_after:wN \str_if_eq:onF \exp_after:wN \c_empty_gtl
1104 \fi:
1105 {#2} { + 1 }
1106 }
1107 % \end{macrocode}
1108 % \end{macro}
1109 %
1110 % \begin{macro}
1111 % {
1112 % \@@_prev_input_gpush:,
1113 % \@@_prev_input_gpush:N,
1114 % \@@_prev_input_gpush_gtl:,
1115 % \@@_prev_input_gpush_gtl:N,
1116 % \@@_prev_input_gpush_aux:NN
1117 % }
1118 % \begin{macrocode}
1119 \cs_new_protected:Npn \@@_prev_input_gpush:
1120 { \seq_gput_right:Nn \g_@@_prev_input_seq { T { } } }
1121 \cs_new_protected:Npn \@@_prev_input_gpush:N
1122 { \@@_prev_input_gpush_aux:NN T }
1123 \cs_new_protected:Npn \@@_prev_input_gpush_gtl:
1124 { \@@_prev_input_gpush_gtl:N \c_empty_gtl }
1125 \cs_new_protected:Npn \@@_prev_input_gpush_gtl:N
1126 { \@@_prev_input_gpush_aux:NN G }
1127 \cs_new_protected:Npn \@@_prev_input_gpush_aux:NN #1#2
1128 { \seq_gput_right:Ne \g_@@_prev_input_seq { #1 { \exp_not:o {#2} } } }
1129 % \end{macrocode}
1130 % \end{macro}
1131 %
1132 % \begin{variable}{\l_@@_prev_aux_tl}
1133 % \begin{macro}
1134 % {
1135 % \@@_prev_input_get:N,
1136 % \@@_prev_input_gpop:N,
1137 % \@@_prev_input_gpop_gtl:N,
1138 % \@@_prev_input_aux:NNN,
1139 % \@@_prev_input_aux:NNNn,
1140 % }
1141 % \begin{macrocode}
1142 \tl_new:N \l_@@_prev_aux_tl
1143 \cs_new_protected:Npn \@@_prev_input_get:N
1144 { \@@_prev_input_aux:NNN \seq_get_right:NN T }
1145 \cs_new_protected:Npn \@@_prev_input_gpop:N
1146 { \@@_prev_input_aux:NNN \seq_gpop_right:NN T }
1147 \cs_new_protected:Npn \@@_prev_input_gpop_gtl:N
1148 { \@@_prev_input_aux:NNN \seq_gpop_right:NN G }
1149 \cs_new_protected:Npn \@@_prev_input_aux:NNN #1#2#3
1150 {
1151 #1 \g_@@_prev_input_seq \l_@@_prev_aux_tl
1152 \exp_after:wN \@@_prev_input_aux:NNNn
1153 \exp_after:wN #2 \exp_after:wN #3 \l_@@_prev_aux_tl
1154 }
1155 \cs_new_protected:Npn \@@_prev_input_aux:NNNn #1#2#3
1156 {
1157 \token_if_eq_meaning:NNTF #1#3
1158 { \tl_set:Nn }
1159 { \@@_error:nnnnn { prev-input } {#1} {#3} }
1160 #2
1161 }
1162 % \end{macrocode}
1163 % \end{macro}
1164 % \end{variable}
1165 %
1166 % \begin{macro}
1167 % {
1168 % \@@_prev_input_silent:n,
1169 % \@@_prev_input_silent:V,
1170 % \@@_prev_input_silent:e
1171 % }
1172 % \begin{macro}
1173 % {
1174 % \@@_prev_input:n,
1175 % \@@_prev_input:V,
1176 % \@@_prev_input:e
1177 % }
1178 % \begin{macrocode}
1179 \cs_new_protected:Npn \@@_prev_input_silent:n #1
1180 {
1181 \@@_prev_input_gpop:N \l_@@_prev_input_tl
1182 \tl_put_right:Nn \l_@@_prev_input_tl {#1}
1183 \@@_prev_input_gpush:N \l_@@_prev_input_tl
1184 }
1185 \cs_generate_variant:Nn \@@_prev_input_silent:n { V , e }
1186 \cs_new_protected:Npn \@@_prev_input:n #1
1187 {
1188 \@@_prev_input_silent:n {#1}
1189 \@@_print_action:e { \tl_to_str:n {#1} }
1190 }
1191 \cs_generate_variant:Nn \@@_prev_input:n { V , e }
1192 % \end{macrocode}
1193 % \end{macro}
1194 % \end{macro}
1195 %
1196 % \begin{macro}{\@@_prev_input_gtl:N}
1197 % \begin{macrocode}
1198 \cs_new_protected:Npn \@@_prev_input_gtl:N #1
1199 {
1200 \@@_prev_input_gpop_gtl:N \l_@@_prev_input_gtl
1201 \gtl_concat:NNN \l_@@_prev_input_gtl \l_@@_prev_input_gtl #1
1202 \@@_prev_input_gpush_gtl:N \l_@@_prev_input_gtl
1203 }
1204 % \end{macrocode}
1205 % \end{macro}
1206 %
1207 % \begin{macro}{\@@_prev_input_join_get:nnN}
1208 % \begin{macro}{\@@_join_get_aux:NNnN}
1209 % Pops the previous-input sequence twice to get some value in
1210 % \cs{l_@@_head_tl} and some sign or decimal number in
1211 % \cs{l_@@_tmpa_tl}. Combines them into a value, using
1212 % the appropriate evaluation function, determined based
1213 % on~|#1|.
1214 % \begin{macrocode}
1215 \cs_new_protected:Npn \@@_prev_input_join_get:nnN #1
1216 {
1217 \int_case:nnF {#1}
1218 {
1219 { 2 } { \@@_join_get_aux:NNnN \skip_eval:n \tex_glueexpr:D }
1220 { 3 } { \@@_join_get_aux:NNnN \muskip_eval:n \tex_muexpr:D }
1221 }
1222 {
1223 \@@_error:nnnnn { internal } { join-factor } { } { } { }
1224 \@@_join_get_aux:NNnN \use:n \prg_do_nothing:
1225 }
1226 }
1227 \cs_new_protected:Npn \@@_join_get_aux:NNnN #1#2#3#4
1228 {
1229 \@@_prev_input_gpop:N \l_@@_head_tl
1230 \@@_prev_input_gpop:N \l_@@_tmpa_tl
1231 \tl_set:Ne #4 { #1 { \l_@@_tmpa_tl #2 \l_@@_head_tl #3 } }
1232 }
1233 % \end{macrocode}
1234 % \end{macro}
1235 % \end{macro}
1236 %
1237 % \subsection{Variables}
1238 %
1239 % \subsubsection{User interaction}
1240 %
1241 % \begin{variable}{\g_@@_iow, \g_@@_current_output_file_tl}
1242 % The stream is used to implement the \texttt{output-file} option. At
1243 % any given time it points to the file named
1244 % \cs{g_@@_current_output_file_tl}, unless that is empty, in which
1245 % case the stream is closed. The idea is that we do not want to close
1246 % the file in between different \cs{unravel} calls since file writing
1247 % is not additive in \TeX{}.
1248 % \begin{macrocode}
1249 \iow_new:N \g_@@_iow
1250 \tl_new:N \g_@@_current_output_file_tl
1251 % \end{macrocode}
1252 % \end{variable}
1253 %
1254 % \begin{variable}{\g_@@_before_print_state_tl, \g_@@_before_prompt_tl}
1255 % Code to run before printing the state or before the prompt.
1256 % \begin{macrocode}
1257 \tl_new:N \g_@@_before_print_state_tl
1258 \tl_new:N \g_@@_before_prompt_tl
1259 % \end{macrocode}
1260 % \end{variable}
1261 %
1262 % \begin{variable}{\l_@@_prompt_tmpa_int}
1263 % \begin{macrocode}
1264 \int_new:N \l_@@_prompt_tmpa_int
1265 % \end{macrocode}
1266 % \end{variable}
1267 %
1268 % \begin{variable}{\g_@@_nonstop_int}
1269 % The number of prompts to skip.
1270 % \begin{macrocode}
1271 \int_new:N \g_@@_nonstop_int
1272 % \end{macrocode}
1273 % \end{variable}
1274 %
1275 % \begin{variable}{\g_@@_current_online_int}
1276 % Temporary value replacing \cs{g_@@_online_int} and that can be set
1277 % through the prompt.
1278 % \begin{macrocode}
1279 \int_new:N \g_@@_current_online_int
1280 % \end{macrocode}
1281 % \end{variable}
1282 %
1283 % \begin{variable}
1284 % {
1285 % \g_@@_default_explicit_prompt_bool , \g_@@_explicit_prompt_bool ,
1286 % \g_@@_default_internal_debug_bool , \g_@@_internal_debug_bool ,
1287 % \g_@@_default_number_steps_bool , \g_@@_number_steps_bool ,
1288 % \g_@@_default_online_int , \g_@@_online_int ,
1289 % \g_@@_default_output_file_tl , \g_@@_output_file_tl ,
1290 % \g_@@_default_prompt_input_clist , \g_@@_prompt_input_clist ,
1291 % \g_@@_default_trace_assigns_bool , \g_@@_trace_assigns_bool ,
1292 % \g_@@_default_trace_expansion_bool , \g_@@_trace_expansion_bool ,
1293 % \g_@@_default_trace_other_bool , \g_@@_trace_other_bool ,
1294 % \g_@@_default_welcome_message_bool , \g_@@_welcome_message_bool ,
1295 % }
1296 % Variables for the options |explicit-prompt|,
1297 % |internal-debug|, |number-steps|, and so on. The
1298 % \texttt{default_} booleans/integers store the default value of these
1299 % options, and are affected by \cs{unravelsetup} or
1300 % \cs{unravel_setup:n}.
1301 % \begin{macrocode}
1302 \bool_new:N \g_@@_default_explicit_prompt_bool
1303 \bool_new:N \g_@@_default_internal_debug_bool
1304 \bool_new:N \g_@@_default_number_steps_bool
1305 \int_new:N \g_@@_default_online_int
1306 \tl_new:N \g_@@_default_output_file_tl
1307 \clist_new:N \g_@@_default_prompt_input_clist
1308 \bool_new:N \g_@@_default_trace_assigns_bool
1309 \bool_new:N \g_@@_default_trace_expansion_bool
1310 \bool_new:N \g_@@_default_trace_other_bool
1311 \bool_new:N \g_@@_default_welcome_message_bool
1312 \bool_gset_true:N \g_@@_default_number_steps_bool
1313 \int_gset:Nn \g_@@_default_online_int { 1 }
1314 \bool_gset_true:N \g_@@_default_trace_assigns_bool
1315 \bool_gset_true:N \g_@@_default_trace_expansion_bool
1316 \bool_gset_true:N \g_@@_default_trace_other_bool
1317 \bool_gset_true:N \g_@@_default_welcome_message_bool
1318 \bool_new:N \g_@@_explicit_prompt_bool
1319 \bool_new:N \g_@@_internal_debug_bool
1320 \bool_new:N \g_@@_number_steps_bool
1321 \int_new:N \g_@@_online_int
1322 \tl_new:N \g_@@_output_file_tl
1323 \clist_new:N \g_@@_prompt_input_clist
1324 \bool_new:N \g_@@_trace_assigns_bool
1325 \bool_new:N \g_@@_trace_expansion_bool
1326 \bool_new:N \g_@@_trace_other_bool
1327 \bool_new:N \g_@@_welcome_message_bool
1328 % \end{macrocode}
1329 % \end{variable}
1330 %
1331 % \begin{variable}{\g_@@_step_int}
1332 % Current expansion step.
1333 % \begin{macrocode}
1334 \int_new:N \g_@@_step_int
1335 % \end{macrocode}
1336 % \end{variable}
1337 %
1338 % \begin{variable}{\g_@@_action_text_str}
1339 % Text describing the action, displayed at each step. This should
1340 % only be altered through \cs{@@_set_action_text:e}, which sets the
1341 % escape character as appropriate before converting the argument to a
1342 % string.
1343 % \begin{macrocode}
1344 \str_new:N \g_@@_action_text_str
1345 % \end{macrocode}
1346 % \end{variable}
1347 %
1348 % \begin{variable}
1349 % {
1350 % \g_@@_default_max_action_int,
1351 % \g_@@_default_max_output_int,
1352 % \g_@@_default_max_input_int,
1353 % \g_@@_max_action_int,
1354 % \g_@@_max_output_int,
1355 % \g_@@_max_input_int
1356 % }
1357 % Maximum length of various pieces of what is shown on the terminal.
1358 % \begin{macrocode}
1359 \int_new:N \g_@@_default_max_action_int
1360 \int_new:N \g_@@_default_max_output_int
1361 \int_new:N \g_@@_default_max_input_int
1362 \int_gset:Nn \g_@@_default_max_action_int { 50 }
1363 \int_gset:Nn \g_@@_default_max_output_int { 300 }
1364 \int_gset:Nn \g_@@_default_max_input_int { 300 }
1365 \int_new:N \g_@@_max_action_int
1366 \int_new:N \g_@@_max_output_int
1367 \int_new:N \g_@@_max_input_int
1368 % \end{macrocode}
1369 % \end{variable}
1370 %
1371 % \begin{variable}{\g_@@_speedup_macros_bool}
1372 % If this boolean is true, speed up macros which have a simple
1373 % parameter text. This may not be safe if very weird macros appear.
1374 % \begin{macrocode}
1375 \bool_new:N \g_@@_speedup_macros_bool
1376 \bool_gset_true:N \g_@@_speedup_macros_bool
1377 % \end{macrocode}
1378 % \end{variable}
1379 %
1380 % \begin{variable}{\l_@@_print_int}
1381 % The length of one piece of the terminal output.
1382 % \begin{macrocode}
1383 \int_new:N \l_@@_print_int
1384 % \end{macrocode}
1385 % \end{variable}
1386 %
1387 % \subsubsection{Working with tokens}
1388 %
1389 % \begin{variable}{\g_@@_input_int}
1390 % The user input, at each stage of expansion, is stored in multiple
1391 % \texttt{gtl} variables, from |\g_@@_input_|\meta{n}|_gtl| to
1392 % \cs{g_@@_input_1_gtl}. The split between variables is akin to
1393 % \TeX{}'s input stack, and allows us to manipulate smaller token
1394 % lists, speeding up processing. The total number \meta{n} of lists
1395 % is \cs{g_@@_input_int}. The highest numbered \texttt{gtl}
1396 % represents input that comes to the left of lower numbered ones.
1397 % \begin{macrocode}
1398 \int_new:N \g_@@_input_int
1399 % \end{macrocode}
1400 % \end{variable}
1401 %
1402 % \begin{variable}{\g_@@_input_tmpa_int}
1403 % \begin{variable}{\l_@@_input_tmpa_tl}
1404 % \begin{macrocode}
1405 \int_new:N \g_@@_input_tmpa_int
1406 \tl_new:N \l_@@_input_tmpa_tl
1407 % \end{macrocode}
1408 % \end{variable}
1409 % \end{variable}
1410 %
1411 % \begin{variable}
1412 % {\g_@@_prev_input_seq, \l_@@_prev_input_tl, \l_@@_prev_input_gtl}
1413 % The different levels of expansion are stored in
1414 % \cs{g_@@_prev_input_seq}, with the innermost at the end of the
1415 % sequence (otherwise the sequence would have to be reversed for
1416 % display). When adding material to the last level of expansion,
1417 % \cs{l_@@_prev_input_tl} or \cs{l_@@_prev_input_gtl} are used to
1418 % temporarily store the last level of expansion.
1419 % \begin{macrocode}
1420 \seq_new:N \g_@@_prev_input_seq
1421 \tl_new:N \l_@@_prev_input_tl
1422 \gtl_new:N \l_@@_prev_input_gtl
1423 % \end{macrocode}
1424 % \end{variable}
1425 %
1426 % \begin{variable}{\g_@@_output_gtl}
1427 % Material that is ``typeset'' or otherwise sent further down \TeX{}'s
1428 % digestion.
1429 % \begin{macrocode}
1430 \gtl_new:N \g_@@_output_gtl
1431 % \end{macrocode}
1432 % \end{variable}
1433 %
1434 % \begin{variable}
1435 % {
1436 % \l_@@_head_gtl,
1437 % \l_@@_head_tl,
1438 % \l_@@_head_token,
1439 % \l_@@_head_cmd_int,
1440 % \l_@@_head_char_int
1441 % }
1442 % First token in the input, as a generalized token list (general case)
1443 % or as a token list whenever this is possible. Also, a token set
1444 % equal to it, and its command code and character code, following
1445 % \TeX{}.
1446 % \begin{macrocode}
1447 \gtl_new:N \l_@@_head_gtl
1448 \tl_new:N \l_@@_head_tl
1449 \cs_new_eq:NN \l_@@_head_token ?
1450 \int_new:N \l_@@_head_cmd_int
1451 \int_new:N \l_@@_head_char_int
1452 % \end{macrocode}
1453 % \end{variable}
1454 %
1455 % \begin{variable}{\l_@@_head_meaning_tl}
1456 % \begin{macrocode}
1457 \tl_new:N \l_@@_head_meaning_tl
1458 % \end{macrocode}
1459 % \end{variable}
1460 %
1461 % \begin{variable}{\l_@@_argi_tl, \l_@@_argii_tl}
1462 % Token list variables used to store first/second arguments.
1463 % \begin{macrocode}
1464 \tl_new:N \l_@@_argi_tl
1465 \tl_new:N \l_@@_argii_tl
1466 % \end{macrocode}
1467 % \end{variable}
1468 %
1469 % \begin{variable}{\l_@@_tmpa_tl, \l_@@_tmpb_gtl, \g_@@_tmpc_tl, \l_@@_tmpa_seq, \l_@@_unused_gtl, \l_@@_tmpb_token}
1470 % Temporary storage. The \cs{l_@@_unused_gtl} is only used once,
1471 % to ignore some unwanted tokens.
1472 % \begin{macrocode}
1473 \tl_new:N \l_@@_tmpa_tl
1474 \gtl_new:N \l_@@_unused_gtl
1475 \gtl_new:N \l_@@_tmpb_gtl
1476 \tl_new:N \g_@@_tmpc_tl
1477 \seq_new:N \l_@@_tmpa_seq
1478 \cs_new_eq:NN \l_@@_tmpb_token ?
1479 % \end{macrocode}
1480 % \end{variable}
1481 %
1482 % \begin{variable}{\l_@@_defined_tl, \l_@@_defining_tl}
1483 % The token that is defined by the prefixed command (such as
1484 % \tn{chardef} or \tn{futurelet}), and the code to define it. We do
1485 % not use the the previous-input sequence to store that code because
1486 % this sequence contains a string representation of the code, which is
1487 % not suitable for the definition. Using a single variable here is
1488 % safe, as definitions cannot be nested. This is needed for expanding
1489 % assignments, as expansion should be shown to the user, but then
1490 % later should not be performed again when defining. It is also
1491 % helpful in tracking some register assignments.
1492 % \begin{macrocode}
1493 \tl_new:N \l_@@_defined_tl
1494 \tl_new:N \l_@@_defining_tl
1495 % \end{macrocode}
1496 % \end{variable}
1497 %
1498 % \begin{macro}{\@@_inaccessible:w}
1499 % \begin{macrocode}
1500 \cs_new_eq:NN \@@_inaccessible:w ?
1501 % \end{macrocode}
1502 % \end{macro}
1503 %
1504 % \begin{variable}{\g_@@_lastnamedcs_tl}
1505 % Used for \LuaTeX{}'s \tn{lastnamedcs} primitive.
1506 % \begin{macrocode}
1507 \tl_new:N \g_@@_lastnamedcs_tl
1508 % \end{macrocode}
1509 % \end{variable}
1510 %
1511 % \begin{variable}
1512 % {
1513 % \g_@@_after_assignment_gtl,
1514 % \g_@@_set_box_allowed_bool,
1515 % \g_@@_name_in_progress_bool
1516 % }
1517 % Global variables keeping track of the state of \TeX{}. Token to
1518 % insert after the next assignment. Is \tn{setbox} currently allowed?
1519 % Should \tn{input} expand?
1520 % \begin{macrocode}
1521 \gtl_new:N \g_@@_after_assignment_gtl
1522 \bool_new:N \g_@@_set_box_allowed_bool
1523 \bool_new:N \g_@@_name_in_progress_bool
1524 % \end{macrocode}
1525 % \end{variable}
1526 %
1527 % \begin{variable}{\l_@@_after_group_gtl}
1528 % Tokens to insert after the current group ends. This variable must
1529 % be emptied at the beginning of every group.
1530 % \begin{macrocode}
1531 \gtl_new:N \l_@@_after_group_gtl
1532 % \end{macrocode}
1533 % \end{variable}
1534 %
1535 % \begin{variable}{\c_@@_parameters_tl}
1536 % Used to determine if a macro has simple parameters or not.
1537 % \begin{macrocode}
1538 \group_begin:
1539 \cs_set_nopar:Npe \@@_tmp:w #1 { \c_hash_str #1 }
1540 \tl_const:Ne \c_@@_parameters_tl
1541 { ^ \tl_map_function:nN { 123456789 } \@@_tmp:w }
1542 \group_end:
1543 % \end{macrocode}
1544 % \end{variable}
1545 %
1546 % \subsubsection{Numbers and conditionals}
1547 %
1548 % \begin{variable}{\g_@@_val_level_int}
1549 % See \TeX{}'s |cur_val_level| variable. This is set by
1550 % \cs{@@_rescan_something_internal:n} to
1551 % \begin{itemize}
1552 % \item $0$ for integer values,
1553 % \item $1$ for dimension values,
1554 % \item $2$ for glue values,
1555 % \item $3$ for mu glue values,
1556 % \item $4$ for font identifiers,
1557 % \item $5$ for token lists.
1558 % \end{itemize}
1559 % \begin{macrocode}
1560 \int_new:N \g_@@_val_level_int
1561 % \end{macrocode}
1562 % \end{variable}
1563 %
1564 % \begin{variable}{\g_@@_if_limit_tl}
1565 % \begin{variable}{\g_@@_if_limit_int}
1566 % \begin{variable}{\g_@@_if_depth_int}
1567 % Stack for what \TeX{} calls |if_limit|, and its depth.
1568 % \begin{macrocode}
1569 \tl_new:N \g_@@_if_limit_tl
1570 \int_new:N \g_@@_if_limit_int
1571 \int_new:N \g_@@_if_depth_int
1572 % \end{macrocode}
1573 % \end{variable}
1574 % \end{variable}
1575 % \end{variable}
1576 %
1577 % \begin{variable}{\l_@@_if_nesting_int}
1578 % \begin{macrocode}
1579 \int_new:N \l_@@_if_nesting_int
1580 % \end{macrocode}
1581 % \end{variable}
1582 %
1583 % \subsubsection{Boxes and groups}
1584 %
1585 % \begin{variable}{\l_@@_leaders_box_seq}
1586 % A stack of letters: the first token in the token list is |h|~if the
1587 % innermost explicit box (created with \tn{vtop}, \tn{vbox}, or
1588 % \tn{hbox}) appears in a horizontal (or math) mode leaders
1589 % construction; it is |v|~if the innermost explicit box appears in a
1590 % vertical mode leaders construction; it is |Z|~otherwise.
1591 % \begin{macrocode}
1592 \seq_new:N \l_@@_leaders_box_seq
1593 % \end{macrocode}
1594 % \end{variable}
1595 %
1596 % \begin{variable}{\g_@@_ends_int}
1597 % Number of times \tn{end} will be put back into the input in case
1598 % there remains to ship some pages.
1599 % \begin{macrocode}
1600 \int_new:N \g_@@_ends_int
1601 \int_gset:Nn \g_@@_ends_int { 3 }
1602 % \end{macrocode}
1603 % \end{variable}
1604 %
1605 % \subsubsection{Constants}
1606 %
1607 % \begin{variable}
1608 % {
1609 % \c_@@_plus_tl, \c_@@_minus_tl, \c_@@_times_tl, \c_@@_over_tl,
1610 % \c_@@_lq_tl, \c_@@_rq_tl, \c_@@_dq_tl, \c_@@_lp_tl, \c_@@_rp_tl,
1611 % \c_@@_eq_tl, \c_@@_comma_tl, \c_@@_point_tl,
1612 % }
1613 % \begin{macrocode}
1614 \tl_const:Nn \c_@@_plus_tl { + }
1615 \tl_const:Nn \c_@@_minus_tl { - }
1616 \tl_const:Nn \c_@@_times_tl { * }
1617 \tl_const:Nn \c_@@_over_tl { / }
1618 \tl_const:Nn \c_@@_lq_tl { ` }
1619 \tl_const:Nn \c_@@_rq_tl { ' }
1620 \tl_const:Nn \c_@@_dq_tl { " } %"
1621 \tl_const:Nn \c_@@_lp_tl { ( }
1622 \tl_const:Nn \c_@@_rp_tl { ) }
1623 \tl_const:Nn \c_@@_eq_tl { = }
1624 \tl_const:Nn \c_@@_comma_tl { , }
1625 \tl_const:Nn \c_@@_point_tl { . }
1626 % \end{macrocode}
1627 % \end{variable}
1628 %
1629 % \begin{variable}{\c_@@_frozen_relax_gtl}
1630 % \TeX{}'s |frozen_relax|, inserted by \cs{@@_insert_relax:}.
1631 % \begin{macrocode}
1632 \gtl_const:Ne \c_@@_frozen_relax_gtl { \if_int_compare:w 0 = 0 \fi: }
1633 % \end{macrocode}
1634 % \end{variable}
1635 %
1636 % \subsubsection{\TeX{} parameters}
1637 %
1638 % \begin{variable}{\g_@@_mag_set_int}
1639 % The first time \TeX{} uses the value of \tn{mag}, it stores it in a
1640 % global parameter |mag_set| (initially $0$ to denote not being set).
1641 % Any time \TeX{} needs the value of \tn{mag}, it checks that the
1642 % value matches |mag_set|. This is done in \pkg{unravel} by
1643 % \cs{@@_prepare_mag:}, storing |mag_set| in \cs{g_@@_mag_set_int}.
1644 % \begin{macrocode}
1645 \int_new:N \g_@@_mag_set_int
1646 % \end{macrocode}
1647 % \end{variable}
1648 %
1649 % \begin{macro}{\@@_prepare_mag:}
1650 % Used whenever \TeX{} needs the value of \tn{mag}.
1651 % \begin{macrocode}
1652 \cs_new_protected:Npn \@@_prepare_mag:
1653 {
1654 \int_compare:nNnT { \g_@@_mag_set_int } > { 0 }
1655 {
1656 \int_compare:nNnF { \@@_mag: } = { \g_@@_mag_set_int }
1657 {
1658 \@@_tex_error:nn { incompatible-mag } { }
1659 \int_gset_eq:NN \@@_mag: \g_@@_mag_set_int
1660 }
1661 }
1662 \int_compare:nF { 1 <= \@@_mag: <= 32768 }
1663 {
1664 \@@_tex_error:nV { illegal-mag } \l_@@_head_tl
1665 \int_gset:Nn \@@_mag: { 1000 }
1666 }
1667 \int_gset_eq:NN \g_@@_mag_set_int \@@_mag:
1668 }
1669 % \end{macrocode}
1670 % \end{macro}
1671 %
1672 % \subsection{Numeric codes}
1673 % \label{sec:numeric-codes}
1674 %
1675 % First we define some numeric codes, following Section~15 of the \TeX{}
1676 % web code, then we associate a command code to each \TeX{} primitive,
1677 % and a character code, to decide what action to perform upon seeing
1678 % them.
1679 %
1680 % \begin{macro}{\@@_tex_const:nn}
1681 % \begin{macro}[EXP]{\@@_tex_use:n}
1682 % \begin{macrocode}
1683 \cs_new_protected:Npn \@@_tex_const:nn #1#2
1684 { \int_const:cn { c_@@_tex_#1_int } {#2} }
1685 \cs_new:Npn \@@_tex_use:n #1 { \int_use:c { c_@@_tex_#1_int } }
1686 % \end{macrocode}
1687 % \end{macro}
1688 % \end{macro}
1689 %
1690 % \begin{macro}{\@@_tex_primitive:nnn, \@@_tex_primitive_pdf:nnn}
1691 % \begin{macrocode}
1692 \cs_new_protected:Npn \@@_tex_primitive:nnn #1#2#3
1693 {
1694 \tl_const:ce { c_@@_tex_#1_tl }
1695 { { \@@_tex_use:n {#2} } {#3} }
1696 }
1697 \cs_new_protected:Npn \@@_tex_primitive_pdf:nnn #1#2#3
1698 {
1699 \sys_if_engine_pdftex:F
1700 { \@@_tex_primitive:nnn {#1} {#2} {#3} }
1701 \@@_tex_primitive:nnn { pdf #1 } {#2} {#3}
1702 }
1703 % \end{macrocode}
1704 % \end{macro}
1705 %
1706 % \begin{macro}{\@@_new_tex_cmd:nn, \@@_new_eq_tex_cmd:nn}
1707 % \begin{macrocode}
1708 \cs_new_protected:Npn \@@_new_tex_cmd:nn #1#2
1709 {
1710 \cs_new_protected:cpn
1711 { @@_cmd_ \@@_tex_use:n {#1} : } {#2}
1712 }
1713 \cs_new_protected:Npn \@@_new_eq_tex_cmd:nn #1#2
1714 {
1715 \cs_new_eq:cc
1716 { @@_cmd_ \@@_tex_use:n {#1} : }
1717 { @@_cmd_ \@@_tex_use:n {#2} : }
1718 }
1719 % \end{macrocode}
1720 % \end{macro}
1721 %
1722 % \begin{macro}{\@@_new_tex_expandable:nn}
1723 % \begin{macrocode}
1724 \cs_new_protected:Npn \@@_new_tex_expandable:nn #1#2
1725 {
1726 \cs_new_protected:cpn
1727 { @@_expandable_ \@@_tex_use:n {#1} : } {#2}
1728 }
1729 % \end{macrocode}
1730 % \end{macro}
1731 %
1732 % Contrarily to \TeX{}, all macros are |call|, no |long_call| and the
1733 % like.
1734 % \begin{macrocode}
1735 \@@_tex_const:nn { relax } { 0 }
1736 \@@_tex_const:nn { begin-group_char } { 1 }
1737 \@@_tex_const:nn { end-group_char } { 2 }
1738 \@@_tex_const:nn { math_char } { 3 }
1739 \@@_tex_const:nn { tab_mark } { 4 }
1740 \@@_tex_const:nn { alignment_char } { 4 }
1741 \@@_tex_const:nn { car_ret } { 5 }
1742 \@@_tex_const:nn { macro_char } { 6 }
1743 \@@_tex_const:nn { superscript_char } { 7 }
1744 \@@_tex_const:nn { subscript_char } { 8 }
1745 \@@_tex_const:nn { endv } { 9 }
1746 \@@_tex_const:nn { blank_char } { 10 }
1747 \@@_tex_const:nn { the_char } { 11 }
1748 \@@_tex_const:nn { other_char } { 12 }
1749 \@@_tex_const:nn { par_end } { 13 }
1750 \@@_tex_const:nn { stop } { 14 }
1751 \@@_tex_const:nn { delim_num } { 15 }
1752 \@@_tex_const:nn { max_char_code } { 15 }
1753 \@@_tex_const:nn { char_num } { 16 }
1754 \@@_tex_const:nn { math_char_num } { 17 }
1755 \@@_tex_const:nn { mark } { 18 }
1756 \@@_tex_const:nn { xray } { 19 }
1757 \@@_tex_const:nn { make_box } { 20 }
1758 \@@_tex_const:nn { hmove } { 21 }
1759 \@@_tex_const:nn { vmove } { 22 }
1760 \@@_tex_const:nn { un_hbox } { 23 }
1761 \@@_tex_const:nn { un_vbox } { 24 }
1762 \@@_tex_const:nn { remove_item } { 25 }
1763 \@@_tex_const:nn { hskip } { 26 }
1764 \@@_tex_const:nn { vskip } { 27 }
1765 \@@_tex_const:nn { mskip } { 28 }
1766 \@@_tex_const:nn { kern } { 29 }
1767 \@@_tex_const:nn { mkern } { 30 }
1768 \@@_tex_const:nn { leader_ship } { 31 }
1769 \@@_tex_const:nn { halign } { 32 }
1770 \@@_tex_const:nn { valign } { 33 }
1771 \@@_tex_const:nn { no_align } { 34 }
1772 \@@_tex_const:nn { vrule } { 35 }
1773 \@@_tex_const:nn { hrule } { 36 }
1774 \@@_tex_const:nn { insert } { 37 }
1775 \@@_tex_const:nn { vadjust } { 38 }
1776 \@@_tex_const:nn { ignore_spaces } { 39 }
1777 \@@_tex_const:nn { after_assignment } { 40 }
1778 \@@_tex_const:nn { after_group } { 41 }
1779 \@@_tex_const:nn { break_penalty } { 42 }
1780 \@@_tex_const:nn { start_par } { 43 }
1781 \@@_tex_const:nn { ital_corr } { 44 }
1782 \@@_tex_const:nn { accent } { 45 }
1783 \@@_tex_const:nn { math_accent } { 46 }
1784 \@@_tex_const:nn { discretionary } { 47 }
1785 \@@_tex_const:nn { eq_no } { 48 }
1786 \@@_tex_const:nn { left_right } { 49 }
1787 \@@_tex_const:nn { math_comp } { 50 }
1788 \@@_tex_const:nn { limit_switch } { 51 }
1789 \@@_tex_const:nn { above } { 52 }
1790 \@@_tex_const:nn { math_style } { 53 }
1791 \@@_tex_const:nn { math_choice } { 54 }
1792 \@@_tex_const:nn { non_script } { 55 }
1793 \@@_tex_const:nn { vcenter } { 56 }
1794 \@@_tex_const:nn { case_shift } { 57 }
1795 \@@_tex_const:nn { message } { 58 }
1796 \@@_tex_const:nn { extension } { 59 }
1797 \@@_tex_const:nn { in_stream } { 60 }
1798 \@@_tex_const:nn { begin_group } { 61 }
1799 \@@_tex_const:nn { end_group } { 62 }
1800 \@@_tex_const:nn { omit } { 63 }
1801 \@@_tex_const:nn { ex_space } { 64 }
1802 \@@_tex_const:nn { no_boundary } { 65 }
1803 \@@_tex_const:nn { radical } { 66 }
1804 \@@_tex_const:nn { end_cs_name } { 67 }
1805 \@@_tex_const:nn { min_internal } { 68 }
1806 \@@_tex_const:nn { char_given } { 68 }
1807 \@@_tex_const:nn { math_given } { 69 }
1808 \@@_tex_const:nn { last_item } { 70 }
1809 \@@_tex_const:nn { max_non_prefixed_command } { 70 }
1810 \@@_tex_const:nn { toks_register } { 71 }
1811 \@@_tex_const:nn { assign_toks } { 72 }
1812 \@@_tex_const:nn { assign_int } { 73 }
1813 \@@_tex_const:nn { assign_dimen } { 74 }
1814 \@@_tex_const:nn { assign_glue } { 75 }
1815 \@@_tex_const:nn { assign_mu_glue } { 76 }
1816 \@@_tex_const:nn { assign_font_dimen } { 77 }
1817 \@@_tex_const:nn { assign_font_int } { 78 }
1818 \@@_tex_const:nn { set_aux } { 79 }
1819 \@@_tex_const:nn { set_prev_graf } { 80 }
1820 \@@_tex_const:nn { set_page_dimen } { 81 }
1821 \@@_tex_const:nn { set_page_int } { 82 }
1822 \@@_tex_const:nn { set_box_dimen } { 83 }
1823 \@@_tex_const:nn { set_shape } { 84 }
1824 \@@_tex_const:nn { def_code } { 85 }
1825 \@@_tex_const:nn { def_family } { 86 }
1826 \@@_tex_const:nn { set_font } { 87 }
1827 \@@_tex_const:nn { def_font } { 88 }
1828 \@@_tex_const:nn { register } { 89 }
1829 \@@_tex_const:nn { max_internal } { 89 }
1830 \@@_tex_const:nn { advance } { 90 }
1831 \@@_tex_const:nn { multiply } { 91 }
1832 \@@_tex_const:nn { divide } { 92 }
1833 \@@_tex_const:nn { prefix } { 93 }
1834 \@@_tex_const:nn { let } { 94 }
1835 \@@_tex_const:nn { shorthand_def } { 95 }
1836 \@@_tex_const:nn { read_to_cs } { 96 }
1837 \@@_tex_const:nn { def } { 97 }
1838 \@@_tex_const:nn { set_box } { 98 }
1839 \@@_tex_const:nn { hyph_data } { 99 }
1840 \@@_tex_const:nn { set_interaction } { 100 }
1841 \@@_tex_const:nn { letterspace_font } { 101 }
1842 \@@_tex_const:nn { pdf_copy_font } { 102 }
1843 \@@_tex_const:nn { max_command } { 102 }
1844 \@@_tex_const:nn { undefined_cs } { 103 }
1845 \@@_tex_const:nn { expand_after } { 104 }
1846 \@@_tex_const:nn { no_expand } { 105 }
1847 \@@_tex_const:nn { input } { 106 }
1848 \@@_tex_const:nn { if_test } { 107 }
1849 \@@_tex_const:nn { fi_or_else } { 108 }
1850 \@@_tex_const:nn { cs_name } { 109 }
1851 \@@_tex_const:nn { convert } { 110 }
1852 \@@_tex_const:nn { the } { 111 }
1853 \@@_tex_const:nn { top_bot_mark } { 112 }
1854 \@@_tex_const:nn { call } { 113 }
1855 \@@_tex_const:nn { end_template } { 117 }
1856 % \end{macrocode}
1857 % So far we've implemented properly [71,104]; [107,113].
1858 %
1859 % A few minor differences with pdf\TeX{}'s internal numbers are as
1860 % follows.
1861 % \begin{itemize}
1862 % \item |case_shift| is shifted by |3983|.
1863 % \item |assign_toks| is shifted by |local_base=3412|.
1864 % \item |assign_int| is shifted by |int_base=5263|.
1865 % \item |assign_dimen| is shifted by |dimen_base=5830|.
1866 % \item |assign_glue| and |assign_mu_glue| are shifted by
1867 % |glue_base=2882|.
1868 % \item |set_shape| is shifted (in \eTeX{}) by |local_base|.
1869 % \item |def_code| and |def_family| is shifted by |cat_code_base=3983|.
1870 % \item In \TeX{}, |inputlineno.char=3| and |badness.char=4|.
1871 % \end{itemize}
1872 % A special case for \LuaTeX{} deals with the fact that the
1873 % \cs{@@_special_relax:} has a strange meaning \enquote{[unknown command
1874 % code! (0, 1)]}. For instance \tn{expandafter} \tn{show} \tn{noexpand}
1875 % \tn{undefined} shows this.
1876 % \begin{macrocode}
1877 \sys_if_engine_luatex:T
1878 {
1879 \@@_tex_primitive:nnn
1880 { \exp_after:wN \use_none:n \token_to_meaning:N \@@_special_relax: }
1881 { relax } { 1 }
1882 }
1883 \@@_tex_primitive:nnn { relax } { relax } { 256 }
1884 \@@_tex_primitive:nnn { span } { tab_mark } { 256 }
1885 \@@_tex_primitive:nnn { cr } { car_ret } { 257 }
1886 \@@_tex_primitive:nnn { crcr } { car_ret } { 258 }
1887 \@@_tex_primitive:nnn { par } { par_end } { 256 }
1888 \@@_tex_primitive:nnn { end } { stop } { 0 }
1889 \@@_tex_primitive:nnn { dump } { stop } { 1 }
1890 \@@_tex_primitive:nnn { delimiter } { delim_num } { 0 }
1891 \@@_tex_primitive:nnn { char } { char_num } { 0 }
1892 \@@_tex_primitive:nnn { mathchar } { math_char_num } { 0 }
1893 \@@_tex_primitive:nnn { mark } { mark } { 0 }
1894 \@@_tex_primitive:nnn { marks } { mark } { 5 }
1895 \@@_tex_primitive:nnn { show } { xray } { 0 }
1896 \@@_tex_primitive:nnn { showbox } { xray } { 1 }
1897 \@@_tex_primitive:nnn { showthe } { xray } { 2 }
1898 \@@_tex_primitive:nnn { showlists } { xray } { 3 }
1899 \@@_tex_primitive:nnn { showgroups } { xray } { 4 }
1900 \@@_tex_primitive:nnn { showtokens } { xray } { 5 }
1901 \@@_tex_primitive:nnn { showifs } { xray } { 6 }
1902 \@@_tex_primitive:nnn { box } { make_box } { 0 }
1903 \@@_tex_primitive:nnn { copy } { make_box } { 1 }
1904 \@@_tex_primitive:nnn { lastbox } { make_box } { 2 }
1905 \@@_tex_primitive:nnn { vsplit } { make_box } { 3 }
1906 \@@_tex_primitive:nnn { vtop } { make_box } { 4 }
1907 \@@_tex_primitive:nnn { vbox } { make_box } { 5 }
1908 \@@_tex_primitive:nnn { hbox } { make_box } { 106 }
1909 \@@_tex_primitive:nnn { moveright } { hmove } { 0 }
1910 \@@_tex_primitive:nnn { moveleft } { hmove } { 1 }
1911 \@@_tex_primitive:nnn { lower } { vmove } { 0 }
1912 \@@_tex_primitive:nnn { raise } { vmove } { 1 }
1913 \@@_tex_primitive:nnn { unhbox } { un_hbox } { 0 }
1914 \@@_tex_primitive:nnn { unhcopy } { un_hbox } { 1 }
1915 \@@_tex_primitive:nnn { unvbox } { un_vbox } { 0 }
1916 \@@_tex_primitive:nnn { unvcopy } { un_vbox } { 1 }
1917 \@@_tex_primitive:nnn { pagediscards } { un_vbox } { 2 }
1918 \@@_tex_primitive:nnn { splitdiscards } { un_vbox } { 3 }
1919 \@@_tex_primitive:nnn { unpenalty } { remove_item } { 12 }
1920 \@@_tex_primitive:nnn { unkern } { remove_item } { 11 }
1921 \@@_tex_primitive:nnn { unskip } { remove_item } { 10 }
1922 \@@_tex_primitive:nnn { hfil } { hskip } { 0 }
1923 \@@_tex_primitive:nnn { hfill } { hskip } { 1 }
1924 \@@_tex_primitive:nnn { hss } { hskip } { 2 }
1925 \@@_tex_primitive:nnn { hfilneg } { hskip } { 3 }
1926 \@@_tex_primitive:nnn { hskip } { hskip } { 4 }
1927 \@@_tex_primitive:nnn { vfil } { vskip } { 0 }
1928 \@@_tex_primitive:nnn { vfill } { vskip } { 1 }
1929 \@@_tex_primitive:nnn { vss } { vskip } { 2 }
1930 \@@_tex_primitive:nnn { vfilneg } { vskip } { 3 }
1931 \@@_tex_primitive:nnn { vskip } { vskip } { 4 }
1932 \@@_tex_primitive:nnn { mskip } { mskip } { 5 }
1933 \@@_tex_primitive:nnn { kern } { kern } { 1 }
1934 \@@_tex_primitive:nnn { mkern } { mkern } { 99 }
1935 \@@_tex_primitive:nnn { shipout } { leader_ship } { 99 }
1936 \@@_tex_primitive:nnn { leaders } { leader_ship } { 100 }
1937 \@@_tex_primitive:nnn { cleaders } { leader_ship } { 101 }
1938 \@@_tex_primitive:nnn { xleaders } { leader_ship } { 102 }
1939 \@@_tex_primitive:nnn { halign } { halign } { 0 }
1940 \@@_tex_primitive:nnn { valign } { valign } { 0 }
1941 \@@_tex_primitive:nnn { beginL } { valign } { 4 }
1942 \@@_tex_primitive:nnn { endL } { valign } { 5 }
1943 \@@_tex_primitive:nnn { beginR } { valign } { 8 }
1944 \@@_tex_primitive:nnn { endR } { valign } { 9 }
1945 \@@_tex_primitive:nnn { noalign } { no_align } { 0 }
1946 \@@_tex_primitive:nnn { vrule } { vrule } { 0 }
1947 \@@_tex_primitive:nnn { hrule } { hrule } { 0 }
1948 \@@_tex_primitive:nnn { insert } { insert } { 0 }
1949 \@@_tex_primitive:nnn { vadjust } { vadjust } { 0 }
1950 \@@_tex_primitive:nnn { ignorespaces } { ignore_spaces } { 0 }
1951 \@@_tex_primitive:nnn { afterassignment } { after_assignment } { 0 }
1952 \@@_tex_primitive:nnn { aftergroup } { after_group } { 0 }
1953 \@@_tex_primitive:nnn { penalty } { break_penalty } { 0 }
1954 \@@_tex_primitive:nnn { indent } { start_par } { 1 }
1955 \@@_tex_primitive:nnn { noindent } { start_par } { 0 }
1956 \@@_tex_primitive:nnn { quitvmode } { start_par } { 2 }
1957 \@@_tex_primitive:nnn { / } { ital_corr } { 0 }
1958 \@@_tex_primitive:nnn { accent } { accent } { 0 }
1959 \@@_tex_primitive:nnn { mathaccent } { math_accent } { 0 }
1960 \sys_if_engine_luatex:T
1961 {
1962 \@@_tex_primitive:nnn
1963 { explicitdiscretionary } { discretionary } { 1 }
1964 }
1965 \@@_tex_primitive:nnn { - } { discretionary } { 1 }
1966 \@@_tex_primitive:nnn { discretionary } { discretionary } { 0 }
1967 \@@_tex_primitive:nnn { eqno } { eq_no } { 0 }
1968 \@@_tex_primitive:nnn { leqno } { eq_no } { 1 }
1969 \@@_tex_primitive:nnn { left } { left_right } { 30 }
1970 \@@_tex_primitive:nnn { right } { left_right } { 31 }
1971 \@@_tex_primitive:nnn { middle } { left_right } { 17 }
1972 \@@_tex_primitive:nnn { mathord } { math_comp } { 16 }
1973 \@@_tex_primitive:nnn { mathop } { math_comp } { 17 }
1974 \@@_tex_primitive:nnn { mathbin } { math_comp } { 18 }
1975 \@@_tex_primitive:nnn { mathrel } { math_comp } { 19 }
1976 \@@_tex_primitive:nnn { mathopen } { math_comp } { 20 }
1977 \@@_tex_primitive:nnn { mathclose } { math_comp } { 21 }
1978 \@@_tex_primitive:nnn { mathpunct } { math_comp } { 22 }
1979 \@@_tex_primitive:nnn { mathinner } { math_comp } { 23 }
1980 \@@_tex_primitive:nnn { underline } { math_comp } { 26 }
1981 \@@_tex_primitive:nnn { overline } { math_comp } { 27 }
1982 \@@_tex_primitive:nnn { displaylimits } { limit_switch } { 0 }
1983 \@@_tex_primitive:nnn { limits } { limit_switch } { 1 }
1984 \@@_tex_primitive:nnn { nolimits } { limit_switch } { 2 }
1985 \@@_tex_primitive:nnn { above } { above } { 0 }
1986 \@@_tex_primitive:nnn { over } { above } { 1 }
1987 \@@_tex_primitive:nnn { atop } { above } { 2 }
1988 \@@_tex_primitive:nnn { abovewithdelims } { above } { 3 }
1989 \@@_tex_primitive:nnn { overwithdelims } { above } { 4 }
1990 \@@_tex_primitive:nnn { atopwithdelims } { above } { 5 }
1991 \@@_tex_primitive:nnn { displaystyle } { math_style } { 0 }
1992 \@@_tex_primitive:nnn { textstyle } { math_style } { 2 }
1993 \@@_tex_primitive:nnn { scriptstyle } { math_style } { 4 }
1994 \@@_tex_primitive:nnn { scriptscriptstyle } { math_style } { 6 }
1995 \@@_tex_primitive:nnn { mathchoice } { math_choice } { 0 }
1996 \@@_tex_primitive:nnn { nonscript } { non_script } { 0 }
1997 \@@_tex_primitive:nnn { vcenter } { vcenter } { 0 }
1998 \@@_tex_primitive:nnn { lowercase } { case_shift } { 256 }
1999 \@@_tex_primitive:nnn { uppercase } { case_shift } { 512 }
2000 \@@_tex_primitive:nnn { message } { message } { 0 }
2001 \@@_tex_primitive:nnn { errmessage } { message } { 1 }
2002 \@@_tex_primitive:nnn { openout } { extension } { 0 }
2003 \@@_tex_primitive:nnn { write } { extension } { 1 }
2004 \@@_tex_primitive:nnn { closeout } { extension } { 2 }
2005 \@@_tex_primitive:nnn { special } { extension } { 3 }
2006 \@@_tex_primitive:nnn { immediate } { extension } { 4 }
2007 \@@_tex_primitive:nnn { setlanguage } { extension } { 5 }
2008 \@@_tex_primitive_pdf:nnn { literal } { extension } { 6 }
2009 \@@_tex_primitive_pdf:nnn { obj } { extension } { 7 }
2010 \@@_tex_primitive_pdf:nnn { refobj } { extension } { 8 }
2011 \@@_tex_primitive_pdf:nnn { xform } { extension } { 9 }
2012 \@@_tex_primitive_pdf:nnn { refxform } { extension } { 10 }
2013 \@@_tex_primitive_pdf:nnn { ximage } { extension } { 11 }
2014 \@@_tex_primitive_pdf:nnn { refximage } { extension } { 12 }
2015 \@@_tex_primitive_pdf:nnn { annot } { extension } { 13 }
2016 \@@_tex_primitive_pdf:nnn { startlink } { extension } { 14 }
2017 \@@_tex_primitive_pdf:nnn { endlink } { extension } { 15 }
2018 \@@_tex_primitive_pdf:nnn { outline } { extension } { 16 }
2019 \@@_tex_primitive_pdf:nnn { dest } { extension } { 17 }
2020 \@@_tex_primitive_pdf:nnn { thread } { extension } { 18 }
2021 \@@_tex_primitive_pdf:nnn { startthread } { extension } { 19 }
2022 \@@_tex_primitive_pdf:nnn { endthread } { extension } { 20 }
2023 \@@_tex_primitive_pdf:nnn { savepos } { extension } { 21 }
2024 \@@_tex_primitive_pdf:nnn { info } { extension } { 22 }
2025 \@@_tex_primitive_pdf:nnn { catalog } { extension } { 23 }
2026 \@@_tex_primitive_pdf:nnn { names } { extension } { 24 }
2027 \@@_tex_primitive_pdf:nnn { fontattr } { extension } { 25 }
2028 \@@_tex_primitive_pdf:nnn { includechars } { extension } { 26 }
2029 \@@_tex_primitive_pdf:nnn { mapfile } { extension } { 27 }
2030 \@@_tex_primitive_pdf:nnn { mapline } { extension } { 28 }
2031 \@@_tex_primitive_pdf:nnn { trailer } { extension } { 29 }
2032 \@@_tex_primitive_pdf:nnn { resettimer } { extension } { 30 }
2033 \@@_tex_primitive_pdf:nnn { fontexpand } { extension } { 31 }
2034 \@@_tex_primitive_pdf:nnn { setrandomseed } { extension } { 32 }
2035 \@@_tex_primitive_pdf:nnn { snaprefpoint } { extension } { 33 }
2036 \@@_tex_primitive_pdf:nnn { snapy } { extension } { 34 }
2037 \@@_tex_primitive_pdf:nnn { snapycomp } { extension } { 35 }
2038 \@@_tex_primitive_pdf:nnn { glyphtounicode} { extension } { 36 }
2039 \@@_tex_primitive_pdf:nnn { colorstack } { extension } { 37 }
2040 \@@_tex_primitive_pdf:nnn { setmatrix } { extension } { 38 }
2041 \@@_tex_primitive_pdf:nnn { save } { extension } { 39 }
2042 \@@_tex_primitive_pdf:nnn { restore } { extension } { 40 }
2043 \@@_tex_primitive_pdf:nnn { nobuiltintounicode } { extension } { 41 }
2044 \@@_tex_primitive:nnn { openin } { in_stream } { 1 }
2045 \@@_tex_primitive:nnn { closein } { in_stream } { 0 }
2046 \@@_tex_primitive:nnn { begingroup } { begin_group } { 0 }
2047 \@@_tex_primitive:nnn { endgroup } { end_group } { 0 }
2048 \@@_tex_primitive:nnn { omit } { omit } { 0 }
2049 \@@_tex_primitive:nnn { ~ } { ex_space } { 0 }
2050 \@@_tex_primitive:nnn { noboundary } { no_boundary } { 0 }
2051 \@@_tex_primitive:nnn { radical } { radical } { 0 }
2052 \@@_tex_primitive:nnn { endcsname } { end_cs_name } { 0 }
2053 \@@_tex_primitive:nnn { lastpenalty } { last_item } { 0 }
2054 \@@_tex_primitive:nnn { lastkern } { last_item } { 1 }
2055 \@@_tex_primitive:nnn { lastskip } { last_item } { 2 }
2056 \@@_tex_primitive:nnn { lastnodetype } { last_item } { 3 }
2057 \@@_tex_primitive:nnn { inputlineno } { last_item } { 4 }
2058 \@@_tex_primitive:nnn { badness } { last_item } { 5 }
2059 \@@_tex_primitive_pdf:nnn { texversion } { last_item } { 6 }
2060 \@@_tex_primitive_pdf:nnn { lastobj } { last_item } { 7 }
2061 \@@_tex_primitive_pdf:nnn { lastxform } { last_item } { 8 }
2062 \@@_tex_primitive_pdf:nnn { lastximage } { last_item } { 9 }
2063 \@@_tex_primitive_pdf:nnn { lastximagepages } { last_item } { 10 }
2064 \@@_tex_primitive_pdf:nnn { lastannot } { last_item } { 11 }
2065 \@@_tex_primitive_pdf:nnn { lastxpos } { last_item } { 12 }
2066 \@@_tex_primitive_pdf:nnn { lastypos } { last_item } { 13 }
2067 \@@_tex_primitive_pdf:nnn { retval } { last_item } { 14 }
2068 \@@_tex_primitive_pdf:nnn { lastximagecolordepth } { last_item } { 15 }
2069 \@@_tex_primitive_pdf:nnn { elapsedtime } { last_item } { 16 }
2070 \@@_tex_primitive_pdf:nnn { shellescape } { last_item } { 17 }
2071 \@@_tex_primitive_pdf:nnn { randomseed } { last_item } { 18 }
2072 \@@_tex_primitive_pdf:nnn { lastlink } { last_item } { 19 }
2073 \@@_tex_primitive:nnn { eTeXversion } { last_item } { 20 }
2074 \@@_tex_primitive:nnn { currentgrouplevel } { last_item } { 21 }
2075 \@@_tex_primitive:nnn { currentgrouptype } { last_item } { 22 }
2076 \@@_tex_primitive:nnn { currentiflevel } { last_item } { 23 }
2077 \@@_tex_primitive:nnn { currentiftype } { last_item } { 24 }
2078 \@@_tex_primitive:nnn { currentifbranch } { last_item } { 25 }
2079 \@@_tex_primitive:nnn { gluestretchorder } { last_item } { 26 }
2080 \@@_tex_primitive:nnn { glueshrinkorder } { last_item } { 27 }
2081 \@@_tex_primitive:nnn { fontcharwd } { last_item } { 28 }
2082 \@@_tex_primitive:nnn { fontcharht } { last_item } { 29 }
2083 \@@_tex_primitive:nnn { fontchardp } { last_item } { 30 }
2084 \@@_tex_primitive:nnn { fontcharic } { last_item } { 31 }
2085 \@@_tex_primitive:nnn { parshapelength } { last_item } { 32 }
2086 \@@_tex_primitive:nnn { parshapeindent } { last_item } { 33 }
2087 \@@_tex_primitive:nnn { parshapedimen } { last_item } { 34 }
2088 \@@_tex_primitive:nnn { gluestretch } { last_item } { 35 }
2089 \@@_tex_primitive:nnn { glueshrink } { last_item } { 36 }
2090 \@@_tex_primitive:nnn { mutoglue } { last_item } { 37 }
2091 \@@_tex_primitive:nnn { gluetomu } { last_item } { 38 }
2092 \@@_tex_primitive:nnn { numexpr } { last_item } { 39 }
2093 \@@_tex_primitive:nnn { dimexpr } { last_item } { 40 }
2094 \@@_tex_primitive:nnn { glueexpr } { last_item } { 41 }
2095 \@@_tex_primitive:nnn { muexpr } { last_item } { 42 }
2096 \@@_tex_primitive:nnn { toks } { toks_register } { 0 }
2097 \@@_tex_primitive:nnn { output } { assign_toks } { 1 }
2098 \@@_tex_primitive:nnn { everypar } { assign_toks } { 2 }
2099 \@@_tex_primitive:nnn { everymath } { assign_toks } { 3 }
2100 \@@_tex_primitive:nnn { everydisplay } { assign_toks } { 4 }
2101 \@@_tex_primitive:nnn { everyhbox } { assign_toks } { 5 }
2102 \@@_tex_primitive:nnn { everyvbox } { assign_toks } { 6 }
2103 \@@_tex_primitive:nnn { everyjob } { assign_toks } { 7 }
2104 \@@_tex_primitive:nnn { everycr } { assign_toks } { 8 }
2105 \@@_tex_primitive:nnn { errhelp } { assign_toks } { 9 }
2106 \@@_tex_primitive_pdf:nnn { pagesattr } { assign_toks } { 10 }
2107 \@@_tex_primitive_pdf:nnn { pageattr } { assign_toks } { 11 }
2108 \@@_tex_primitive_pdf:nnn { pageresources } { assign_toks } { 12 }
2109 \@@_tex_primitive_pdf:nnn { pkmode } { assign_toks } { 13 }
2110 \@@_tex_primitive:nnn { everyeof } { assign_toks } { 14 }
2111 \@@_tex_primitive:nnn { pretolerance } { assign_int } { 0 }
2112 \@@_tex_primitive:nnn { tolerance } { assign_int } { 1 }
2113 \@@_tex_primitive:nnn { linepenalty } { assign_int } { 2 }
2114 \@@_tex_primitive:nnn { hyphenpenalty } { assign_int } { 3 }
2115 \@@_tex_primitive:nnn { exhyphenpenalty } { assign_int } { 4 }
2116 \@@_tex_primitive:nnn { clubpenalty } { assign_int } { 5 }
2117 \@@_tex_primitive:nnn { widowpenalty } { assign_int } { 6 }
2118 \@@_tex_primitive:nnn { displaywidowpenalty } { assign_int } { 7 }
2119 \@@_tex_primitive:nnn { brokenpenalty } { assign_int } { 8 }
2120 \@@_tex_primitive:nnn { binoppenalty } { assign_int } { 9 }
2121 \@@_tex_primitive:nnn { relpenalty } { assign_int } { 10 }
2122 \@@_tex_primitive:nnn { predisplaypenalty } { assign_int } { 11 }
2123 \@@_tex_primitive:nnn { postdisplaypenalty } { assign_int } { 12 }
2124 \@@_tex_primitive:nnn { interlinepenalty } { assign_int } { 13 }
2125 \@@_tex_primitive:nnn { doublehyphendemerits } { assign_int } { 14 }
2126 \@@_tex_primitive:nnn { finalhyphendemerits } { assign_int } { 15 }
2127 \@@_tex_primitive:nnn { adjdemerits } { assign_int } { 16 }
2128 \@@_tex_primitive:nnn { mag } { assign_int } { 17 }
2129 \@@_tex_primitive:nnn { delimiterfactor } { assign_int } { 18 }
2130 \@@_tex_primitive:nnn { looseness } { assign_int } { 19 }
2131 \@@_tex_primitive:nnn { time } { assign_int } { 20 }
2132 \@@_tex_primitive:nnn { day } { assign_int } { 21 }
2133 \@@_tex_primitive:nnn { month } { assign_int } { 22 }
2134 \@@_tex_primitive:nnn { year } { assign_int } { 23 }
2135 \@@_tex_primitive:nnn { showboxbreadth } { assign_int } { 24 }
2136 \@@_tex_primitive:nnn { showboxdepth } { assign_int } { 25 }
2137 \@@_tex_primitive:nnn { hbadness } { assign_int } { 26 }
2138 \@@_tex_primitive:nnn { vbadness } { assign_int } { 27 }
2139 \@@_tex_primitive:nnn { pausing } { assign_int } { 28 }
2140 \@@_tex_primitive:nnn { tracingonline } { assign_int } { 29 }
2141 \@@_tex_primitive:nnn { tracingmacros } { assign_int } { 30 }
2142 \@@_tex_primitive:nnn { tracingstats } { assign_int } { 31 }
2143 \@@_tex_primitive:nnn { tracingparagraphs } { assign_int } { 32 }
2144 \@@_tex_primitive:nnn { tracingpages } { assign_int } { 33 }
2145 \@@_tex_primitive:nnn { tracingoutput } { assign_int } { 34 }
2146 \@@_tex_primitive:nnn { tracinglostchars } { assign_int } { 35 }
2147 \@@_tex_primitive:nnn { tracingcommands } { assign_int } { 36 }
2148 \@@_tex_primitive:nnn { tracingrestores } { assign_int } { 37 }
2149 \@@_tex_primitive:nnn { uchyph } { assign_int } { 38 }
2150 \@@_tex_primitive:nnn { outputpenalty } { assign_int } { 39 }
2151 \@@_tex_primitive:nnn { maxdeadcycles } { assign_int } { 40 }
2152 \@@_tex_primitive:nnn { hangafter } { assign_int } { 41 }
2153 \@@_tex_primitive:nnn { floatingpenalty } { assign_int } { 42 }
2154 \@@_tex_primitive:nnn { globaldefs } { assign_int } { 43 }
2155 \@@_tex_primitive:nnn { fam } { assign_int } { 44 }
2156 \@@_tex_primitive:nnn { escapechar } { assign_int } { 45 }
2157 \@@_tex_primitive:nnn { defaulthyphenchar } { assign_int } { 46 }
2158 \@@_tex_primitive:nnn { defaultskewchar } { assign_int } { 47 }
2159 \@@_tex_primitive:nnn { endlinechar } { assign_int } { 48 }
2160 \@@_tex_primitive:nnn { newlinechar } { assign_int } { 49 }
2161 \@@_tex_primitive:nnn { language } { assign_int } { 50 }
2162 \@@_tex_primitive:nnn { lefthyphenmin } { assign_int } { 51 }
2163 \@@_tex_primitive:nnn { righthyphenmin } { assign_int } { 52 }
2164 \@@_tex_primitive:nnn { holdinginserts } { assign_int } { 53 }
2165 \@@_tex_primitive:nnn { errorcontextlines } { assign_int } { 54 }
2166 \@@_tex_primitive:nnn { pdfoutput } { assign_int } { 55 }
2167 \@@_tex_primitive_pdf:nnn { compresslevel } { assign_int } { 56 }
2168 \@@_tex_primitive_pdf:nnn { decimaldigits } { assign_int } { 57 }
2169 \@@_tex_primitive_pdf:nnn { movechars } { assign_int } { 58 }
2170 \@@_tex_primitive_pdf:nnn { imageresolution } { assign_int } { 59 }
2171 \@@_tex_primitive_pdf:nnn { pkresolution } { assign_int } { 60 }
2172 \@@_tex_primitive_pdf:nnn { uniqueresname } { assign_int } { 61 }
2173 \@@_tex_primitive_pdf:nnn
2174 { optionalwaysusepdfpagebox } { assign_int } { 62 }
2175 \@@_tex_primitive_pdf:nnn
2176 { optionpdfinclusionerrorlevel } { assign_int } { 63 }
2177 \@@_tex_primitive_pdf:nnn
2178 { optionpdfminorversion } { assign_int } { 64 }
2179 \@@_tex_primitive_pdf:nnn { minorversion } { assign_int } { 64 }
2180 \@@_tex_primitive_pdf:nnn { forcepagebox } { assign_int } { 65 }
2181 \@@_tex_primitive_pdf:nnn { pagebox } { assign_int } { 66 }
2182 \@@_tex_primitive_pdf:nnn
2183 { inclusionerrorlevel } { assign_int } { 67 }
2184 \@@_tex_primitive_pdf:nnn { gamma } { assign_int } { 68 }
2185 \@@_tex_primitive_pdf:nnn { imagegamma } { assign_int } { 69 }
2186 \@@_tex_primitive_pdf:nnn { imagehicolor } { assign_int } { 70 }
2187 \@@_tex_primitive_pdf:nnn { imageapplygamma } { assign_int } { 71 }
2188 \@@_tex_primitive_pdf:nnn { adjustspacing } { assign_int } { 72 }
2189 \@@_tex_primitive_pdf:nnn { protrudechars } { assign_int } { 73 }
2190 \@@_tex_primitive_pdf:nnn { tracingfonts } { assign_int } { 74 }
2191 \@@_tex_primitive_pdf:nnn { objcompresslevel } { assign_int } { 75 }
2192 \@@_tex_primitive_pdf:nnn
2193 { adjustinterwordglue } { assign_int } { 76 }
2194 \@@_tex_primitive_pdf:nnn { prependkern } { assign_int } { 77 }
2195 \@@_tex_primitive_pdf:nnn { appendkern } { assign_int } { 78 }
2196 \@@_tex_primitive_pdf:nnn { gentounicode } { assign_int } { 79 }
2197 \@@_tex_primitive_pdf:nnn { draftmode } { assign_int } { 80 }
2198 \@@_tex_primitive_pdf:nnn { inclusioncopyfonts } { assign_int } { 81 }
2199 \@@_tex_primitive:nnn { tracingassigns } { assign_int } { 82 }
2200 \@@_tex_primitive:nnn { tracinggroups } { assign_int } { 83 }
2201 \@@_tex_primitive:nnn { tracingifs } { assign_int } { 84 }
2202 \@@_tex_primitive:nnn { tracingscantokens } { assign_int } { 85 }
2203 \@@_tex_primitive:nnn { tracingnesting } { assign_int } { 86 }
2204 \@@_tex_primitive:nnn { predisplaydirection } { assign_int } { 87 }
2205 \@@_tex_primitive:nnn { lastlinefit } { assign_int } { 88 }
2206 \@@_tex_primitive:nnn { savingvdiscards } { assign_int } { 89 }
2207 \@@_tex_primitive:nnn { savinghyphcodes } { assign_int } { 90 }
2208 \@@_tex_primitive:nnn { TeXXeTstate } { assign_int } { 91 }
2209 \@@_tex_primitive:nnn { parindent } { assign_dimen } { 0 }
2210 \@@_tex_primitive:nnn { mathsurround } { assign_dimen } { 1 }
2211 \@@_tex_primitive:nnn { lineskiplimit } { assign_dimen } { 2 }
2212 \@@_tex_primitive:nnn { hsize } { assign_dimen } { 3 }
2213 \@@_tex_primitive:nnn { vsize } { assign_dimen } { 4 }
2214 \@@_tex_primitive:nnn { maxdepth } { assign_dimen } { 5 }
2215 \@@_tex_primitive:nnn { splitmaxdepth } { assign_dimen } { 6 }
2216 \@@_tex_primitive:nnn { boxmaxdepth } { assign_dimen } { 7 }
2217 \@@_tex_primitive:nnn { hfuzz } { assign_dimen } { 8 }
2218 \@@_tex_primitive:nnn { vfuzz } { assign_dimen } { 9 }
2219 \@@_tex_primitive:nnn { delimitershortfall } { assign_dimen } { 10 }
2220 \@@_tex_primitive:nnn { nulldelimiterspace } { assign_dimen } { 11 }
2221 \@@_tex_primitive:nnn { scriptspace } { assign_dimen } { 12 }
2222 \@@_tex_primitive:nnn { predisplaysize } { assign_dimen } { 13 }
2223 \@@_tex_primitive:nnn { displaywidth } { assign_dimen } { 14 }
2224 \@@_tex_primitive:nnn { displayindent } { assign_dimen } { 15 }
2225 \@@_tex_primitive:nnn { overfullrule } { assign_dimen } { 16 }
2226 \@@_tex_primitive:nnn { hangindent } { assign_dimen } { 17 }
2227 \@@_tex_primitive:nnn { hoffset } { assign_dimen } { 18 }
2228 \@@_tex_primitive:nnn { voffset } { assign_dimen } { 19 }
2229 \@@_tex_primitive:nnn { emergencystretch } { assign_dimen } { 20 }
2230 \@@_tex_primitive_pdf:nnn { horigin } { assign_dimen } { 21 }
2231 \@@_tex_primitive_pdf:nnn { vorigin } { assign_dimen } { 22 }
2232 \@@_tex_primitive_pdf:nnn { pagewidth } { assign_dimen } { 23 }
2233 \@@_tex_primitive_pdf:nnn { pageheight } { assign_dimen } { 24 }
2234 \@@_tex_primitive_pdf:nnn { linkmargin } { assign_dimen } { 25 }
2235 \@@_tex_primitive_pdf:nnn { destmargin } { assign_dimen } { 26 }
2236 \@@_tex_primitive_pdf:nnn { threadmargin } { assign_dimen } { 27 }
2237 \@@_tex_primitive_pdf:nnn { firstlineheight } { assign_dimen } { 28 }
2238 \@@_tex_primitive_pdf:nnn { lastlinedepth } { assign_dimen } { 29 }
2239 \@@_tex_primitive_pdf:nnn { eachlineheight } { assign_dimen } { 30 }
2240 \@@_tex_primitive_pdf:nnn { eachlinedepth } { assign_dimen } { 31 }
2241 \@@_tex_primitive_pdf:nnn { ignoreddimen } { assign_dimen } { 32 }
2242 \@@_tex_primitive_pdf:nnn { pxdimen } { assign_dimen } { 33 }
2243 \@@_tex_primitive:nnn { lineskip } { assign_glue } { 0 }
2244 \@@_tex_primitive:nnn { baselineskip } { assign_glue } { 1 }
2245 \@@_tex_primitive:nnn { parskip } { assign_glue } { 2 }
2246 \@@_tex_primitive:nnn { abovedisplayskip } { assign_glue } { 3 }
2247 \@@_tex_primitive:nnn { belowdisplayskip } { assign_glue } { 4 }
2248 \@@_tex_primitive:nnn { abovedisplayshortskip } { assign_glue } { 5 }
2249 \@@_tex_primitive:nnn { belowdisplayshortskip } { assign_glue } { 6 }
2250 \@@_tex_primitive:nnn { leftskip } { assign_glue } { 7 }
2251 \@@_tex_primitive:nnn { rightskip } { assign_glue } { 8 }
2252 \@@_tex_primitive:nnn { topskip } { assign_glue } { 9 }
2253 \@@_tex_primitive:nnn { splittopskip } { assign_glue } { 10 }
2254 \@@_tex_primitive:nnn { tabskip } { assign_glue } { 11 }
2255 \@@_tex_primitive:nnn { spaceskip } { assign_glue } { 12 }
2256 \@@_tex_primitive:nnn { xspaceskip } { assign_glue } { 13 }
2257 \@@_tex_primitive:nnn { parfillskip } { assign_glue } { 14 }
2258 \@@_tex_primitive:nnn { thinmuskip } { assign_mu_glue } { 15 }
2259 \@@_tex_primitive:nnn { medmuskip } { assign_mu_glue } { 16 }
2260 \@@_tex_primitive:nnn { thickmuskip } { assign_mu_glue } { 17 }
2261 \@@_tex_primitive:nnn { fontdimen } { assign_font_dimen } { 0 }
2262 \@@_tex_primitive:nnn { hyphenchar } { assign_font_int } { 0 }
2263 \@@_tex_primitive:nnn { skewchar } { assign_font_int } { 1 }
2264 \@@_tex_primitive:nnn { lpcode } { assign_font_int } { 2 }
2265 \@@_tex_primitive:nnn { rpcode } { assign_font_int } { 3 }
2266 \@@_tex_primitive:nnn { efcode } { assign_font_int } { 4 }
2267 \@@_tex_primitive:nnn { tagcode } { assign_font_int } { 5 }
2268 \@@_tex_primitive_pdf:nnn { noligatures } { assign_font_int } { 6 }
2269 \@@_tex_primitive:nnn { knbscode } { assign_font_int } { 7 }
2270 \@@_tex_primitive:nnn { stbscode } { assign_font_int } { 8 }
2271 \@@_tex_primitive:nnn { shbscode } { assign_font_int } { 9 }
2272 \@@_tex_primitive:nnn { knbccode } { assign_font_int } { 10 }
2273 \@@_tex_primitive:nnn { knaccode } { assign_font_int } { 11 }
2274 \@@_tex_primitive:nnn { spacefactor } { set_aux } { 102 }
2275 \@@_tex_primitive:nnn { prevdepth } { set_aux } { 1 }
2276 \@@_tex_primitive:nnn { prevgraf } { set_prev_graf } { 0 }
2277 \@@_tex_primitive:nnn { pagegoal } { set_page_dimen } { 0 }
2278 \@@_tex_primitive:nnn { pagetotal } { set_page_dimen } { 1 }
2279 \@@_tex_primitive:nnn { pagestretch } { set_page_dimen } { 2 }
2280 \@@_tex_primitive:nnn { pagefilstretch } { set_page_dimen } { 3 }
2281 \@@_tex_primitive:nnn { pagefillstretch } { set_page_dimen } { 4 }
2282 \@@_tex_primitive:nnn { pagefilllstretch } { set_page_dimen } { 5 }
2283 \@@_tex_primitive:nnn { pageshrink } { set_page_dimen } { 6 }
2284 \@@_tex_primitive:nnn { pagedepth } { set_page_dimen } { 7 }
2285 \@@_tex_primitive:nnn { deadcycles } { set_page_int } { 0 }
2286 \@@_tex_primitive:nnn { insertpenalties } { set_page_int } { 1 }
2287 \@@_tex_primitive:nnn { interactionmode } { set_page_int } { 2 }
2288 \@@_tex_primitive:nnn { wd } { set_box_dimen } { 1 }
2289 \@@_tex_primitive:nnn { dp } { set_box_dimen } { 2 }
2290 \@@_tex_primitive:nnn { ht } { set_box_dimen } { 3 }
2291 \@@_tex_primitive:nnn { parshape } { set_shape } { 0 }
2292 \@@_tex_primitive:nnn { interlinepenalties } { set_shape } { 1 }
2293 \@@_tex_primitive:nnn { clubpenalties } { set_shape } { 2 }
2294 \@@_tex_primitive:nnn { widowpenalties } { set_shape } { 3 }
2295 \@@_tex_primitive:nnn { displaywidowpenalties } { set_shape } { 4 }
2296 \@@_tex_primitive:nnn { catcode } { def_code } { 0 }
2297 \@@_tex_primitive:nnn { lccode } { def_code } { 256 }
2298 \@@_tex_primitive:nnn { uccode } { def_code } { 512 }
2299 \@@_tex_primitive:nnn { sfcode } { def_code } { 768 }
2300 \@@_tex_primitive:nnn { mathcode } { def_code } { 1024 }
2301 \@@_tex_primitive:nnn { delcode } { def_code } { 1591 }
2302 \@@_tex_primitive:nnn { textfont } { def_family } { -48 }
2303 \@@_tex_primitive:nnn { scriptfont } { def_family } { -32 }
2304 \@@_tex_primitive:nnn { scriptscriptfont } { def_family } { -16 }
2305 \@@_tex_primitive:nnn { nullfont } { set_font } { 0 }
2306 \@@_tex_primitive:nnn { font } { def_font } { 0 }
2307 \@@_tex_primitive:nnn { count } { register } { 1 000 000 }
2308 \@@_tex_primitive:nnn { dimen } { register } { 2 000 000 }
2309 \@@_tex_primitive:nnn { skip } { register } { 3 000 000 }
2310 \@@_tex_primitive:nnn { muskip } { register } { 4 000 000 }
2311 \@@_tex_primitive:nnn { advance } { advance } { 0 }
2312 \@@_tex_primitive:nnn { multiply } { multiply } { 0 }
2313 \@@_tex_primitive:nnn { divide } { divide } { 0 }
2314 \@@_tex_primitive:nnn { long } { prefix } { 1 }
2315 \@@_tex_primitive:nnn { outer } { prefix } { 2 }
2316 \@@_tex_primitive:nnn { global } { prefix } { 4 }
2317 \@@_tex_primitive:nnn { protected } { prefix } { 8 }
2318 \@@_tex_primitive:nnn { let } { let } { 0 }
2319 \@@_tex_primitive:nnn { futurelet } { let } { 1 }
2320 \@@_tex_primitive:nnn { chardef } { shorthand_def } { 0 }
2321 \@@_tex_primitive:nnn { mathchardef } { shorthand_def } { 1 }
2322 \@@_tex_primitive:nnn { countdef } { shorthand_def } { 2 }
2323 \@@_tex_primitive:nnn { dimendef } { shorthand_def } { 3 }
2324 \@@_tex_primitive:nnn { skipdef } { shorthand_def } { 4 }
2325 \@@_tex_primitive:nnn { muskipdef } { shorthand_def } { 5 }
2326 \@@_tex_primitive:nnn { toksdef } { shorthand_def } { 6 }
2327 \@@_tex_primitive:nnn { read } { read_to_cs } { 0 }
2328 \@@_tex_primitive:nnn { readline } { read_to_cs } { 1 }
2329 \@@_tex_primitive:nnn { def } { def } { 0 }
2330 \@@_tex_primitive:nnn { gdef } { def } { 1 }
2331 \@@_tex_primitive:nnn { edef } { def } { 2 }
2332 \@@_tex_primitive:nnn { xdef } { def } { 3 }
2333 \@@_tex_primitive:nnn { setbox } { set_box } { 0 }
2334 \@@_tex_primitive:nnn { hyphenation } { hyph_data } { 0 }
2335 \@@_tex_primitive:nnn { patterns } { hyph_data } { 1 }
2336 \@@_tex_primitive:nnn { batchmode } { set_interaction } { 0 }
2337 \@@_tex_primitive:nnn { nonstopmode } { set_interaction } { 1 }
2338 \@@_tex_primitive:nnn { scrollmode } { set_interaction } { 2 }
2339 \@@_tex_primitive:nnn { errorstopmode } { set_interaction } { 3 }
2340 \@@_tex_primitive:nnn { letterspacefont } { letterspace_font } { 0 }
2341 \@@_tex_primitive_pdf:nnn { copyfont } { pdf_copy_font } { 0 }
2342 \@@_tex_primitive:nnn { undefined } { undefined_cs } { 0 }
2343 \@@_tex_primitive:nnn { ndefined } { undefined_cs } { 0 }
2344 \@@_tex_primitive:nnn { expandafter } { expand_after } { 0 }
2345 \@@_tex_primitive:nnn { unless } { expand_after } { 1 }
2346 \@@_tex_primitive_pdf:nnn { primitive } { no_expand } { 1 }
2347 \@@_tex_primitive:nnn { noexpand } { no_expand } { 0 }
2348 \@@_tex_primitive:nnn { input } { input } { 0 }
2349 \@@_tex_primitive:nnn { endinput } { input } { 1 }
2350 \@@_tex_primitive:nnn { scantokens } { input } { 2 }
2351 \@@_tex_primitive:nnn { if } { if_test } { 0 }
2352 \@@_tex_primitive:nnn { ifcat } { if_test } { 1 }
2353 \@@_tex_primitive:nnn { ifnum } { if_test } { 2 }
2354 \@@_tex_primitive:nnn { ifdim } { if_test } { 3 }
2355 \@@_tex_primitive:nnn { ifodd } { if_test } { 4 }
2356 \@@_tex_primitive:nnn { ifvmode } { if_test } { 5 }
2357 \@@_tex_primitive:nnn { ifhmode } { if_test } { 5 }
2358 \@@_tex_primitive:nnn { ifmmode } { if_test } { 5 }
2359 \@@_tex_primitive:nnn { ifinner } { if_test } { 5 }
2360 \@@_tex_primitive:nnn { ifvoid } { if_test } { 9 }
2361 \@@_tex_primitive:nnn { ifhbox } { if_test } { 9 }
2362 \@@_tex_primitive:nnn { ifvbox } { if_test } { 9 }
2363 \@@_tex_primitive:nnn { ifx } { if_test } { 12 }
2364 \@@_tex_primitive:nnn { ifeof } { if_test } { 13 }
2365 \@@_tex_primitive:nnn { iftrue } { if_test } { 14 }
2366 \@@_tex_primitive:nnn { iffalse } { if_test } { 15 }
2367 \@@_tex_primitive:nnn { ifcase } { if_test } { 16 }
2368 \@@_tex_primitive:nnn { ifdefined } { if_test } { 17 }
2369 \@@_tex_primitive:nnn { ifcsname } { if_test } { 18 }
2370 \@@_tex_primitive:nnn { iffontchar } { if_test } { 19 }
2371 \@@_tex_primitive:nnn { ifincsname } { if_test } { 20 }
2372 \@@_tex_primitive:nnn { ifprimitive } { if_test } { 21 }
2373 \@@_tex_primitive:nnn { ifpdfprimitive } { if_test } { 21 }
2374 \@@_tex_primitive:nnn { ifabsnum } { if_test } { 22 }
2375 \@@_tex_primitive:nnn { ifpdfabsnum } { if_test } { 22 }
2376 \@@_tex_primitive:nnn { ifabsdim } { if_test } { 23 }
2377 \@@_tex_primitive:nnn { ifpdfabsdim } { if_test } { 23 }
2378 \bool_if:nT { \sys_if_engine_ptex_p: || \sys_if_engine_uptex_p: }
2379 {
2380 \@@_tex_primitive:nnn { iftdir } { if_test } { 5 }
2381 \@@_tex_primitive:nnn { ifydir } { if_test } { 5 }
2382 \@@_tex_primitive:nnn { ifddir } { if_test } { 5 }
2383 \@@_tex_primitive:nnn { ifmdir } { if_test } { 5 }
2384 \@@_tex_primitive:nnn { iftbox } { if_test } { 9 }
2385 \@@_tex_primitive:nnn { ifybox } { if_test } { 9 }
2386 \@@_tex_primitive:nnn { ifdbox } { if_test } { 9 }
2387 \@@_tex_primitive:nnn { ifmbox } { if_test } { 9 }
2388 \@@_tex_primitive:nnn { ifjfont } { if_test } { 24 }
2389 \@@_tex_primitive:nnn { iftfont } { if_test } { 24 }
2390 }
2391 \@@_tex_primitive:nnn { fi } { fi_or_else } { 2 }
2392 \@@_tex_primitive:nnn { else } { fi_or_else } { 3 }
2393 \@@_tex_primitive:nnn { or } { fi_or_else } { 4 }
2394 \@@_tex_primitive:nnn { csname } { cs_name } { 0 }
2395 \@@_tex_primitive:nnn { lastnamedcs } { cs_name } { 1 }
2396 \@@_tex_primitive:nnn { number } { convert } { 0 }
2397 \@@_tex_primitive:nnn { romannumeral } { convert } { 1 }
2398 \@@_tex_primitive:nnn { string } { convert } { 2 }
2399 \@@_tex_primitive:nnn { meaning } { convert } { 3 }
2400 \@@_tex_primitive:nnn { fontname } { convert } { 4 }
2401 \@@_tex_primitive:nnn { eTeXrevision } { convert } { 5 }
2402 \@@_tex_primitive_pdf:nnn { texrevision } { convert } { 6 }
2403 \@@_tex_primitive_pdf:nnn { texbanner } { convert } { 7 }
2404 \@@_tex_primitive:nnn { pdffontname } { convert } { 8 }
2405 \@@_tex_primitive_pdf:nnn { fontobjnum } { convert } { 9 }
2406 \@@_tex_primitive_pdf:nnn { fontsize } { convert } { 10 }
2407 \@@_tex_primitive_pdf:nnn { pageref } { convert } { 11 }
2408 \@@_tex_primitive_pdf:nnn { xformname } { convert } { 12 }
2409 \@@_tex_primitive_pdf:nnn { escapestring } { convert } { 13 }
2410 \@@_tex_primitive_pdf:nnn { escapename } { convert } { 14 }
2411 \@@_tex_primitive:nnn { leftmarginkern } { convert } { 15 }
2412 \@@_tex_primitive:nnn { rightmarginkern } { convert } { 16 }
2413 \@@_tex_primitive_pdf:nnn { strcmp } { convert } { 17 }
2414 \@@_tex_primitive_pdf:nnn { colorstackinit } { convert } { 18 }
2415 \@@_tex_primitive_pdf:nnn { escapehex } { convert } { 19 }
2416 \@@_tex_primitive_pdf:nnn { unescapehex } { convert } { 20 }
2417 \@@_tex_primitive_pdf:nnn { creationdate } { convert } { 21 }
2418 \@@_tex_primitive_pdf:nnn { filemoddate } { convert } { 22 }
2419 \@@_tex_primitive_pdf:nnn { filesize } { convert } { 23 }
2420 \@@_tex_primitive_pdf:nnn { mdfivesum } { convert } { 24 }
2421 \@@_tex_primitive_pdf:nnn { filedump } { convert } { 25 }
2422 \@@_tex_primitive_pdf:nnn { match } { convert } { 26 }
2423 \@@_tex_primitive_pdf:nnn { lastmatch } { convert } { 27 }
2424 \@@_tex_primitive_pdf:nnn { uniformdeviate } { convert } { 28 }
2425 \@@_tex_primitive_pdf:nnn { normaldeviate } { convert } { 29 }
2426 \@@_tex_primitive_pdf:nnn { insertht } { convert } { 30 }
2427 \@@_tex_primitive_pdf:nnn { ximagebbox } { convert } { 31 }
2428 \@@_tex_primitive:nnn { jobname } { convert } { 32 }
2429 \sys_if_engine_luatex:T
2430 { \@@_tex_primitive:nnn { directlua } { convert } { 33 } }
2431 \@@_tex_primitive:nnn { expanded } { convert } { 34 }
2432 \sys_if_engine_luatex:T
2433 { \@@_tex_primitive:nnn { luaescapestring } { convert } { 35 } }
2434 \bool_if:nT { \sys_if_engine_xetex_p: || \sys_if_engine_ptex_p: || \sys_if_engine_uptex_p: }
2435 {
2436 \@@_tex_primitive:nnn { Ucharcat } { convert } { 40 }
2437 }
2438 \@@_tex_primitive:nnn { the } { the } { 0 }
2439 \@@_tex_primitive:nnn { unexpanded } { the } { 1 }
2440 \@@_tex_primitive:nnn { detokenize } { the } { 5 }
2441 \@@_tex_primitive:nnn { topmark } { top_bot_mark } { 0 }
2442 \@@_tex_primitive:nnn { firstmark } { top_bot_mark } { 1 }
2443 \@@_tex_primitive:nnn { botmark } { top_bot_mark } { 2 }
2444 \@@_tex_primitive:nnn { splitfirstmark } { top_bot_mark } { 3 }
2445 \@@_tex_primitive:nnn { splitbotmark } { top_bot_mark } { 4 }
2446 \@@_tex_primitive:nnn { topmarks } { top_bot_mark } { 5 }
2447 \@@_tex_primitive:nnn { firstmarks } { top_bot_mark } { 6 }
2448 \@@_tex_primitive:nnn { botmarks } { top_bot_mark } { 7 }
2449 \@@_tex_primitive:nnn { splitfirstmarks } { top_bot_mark } { 8 }
2450 \@@_tex_primitive:nnn { splitbotmarks } { top_bot_mark } { 9 }
2451 % \end{macrocode}
2452 %
2453 % \subsection{Get next token}
2454 %
2455 % We define here two functions which fetch the next token in the token
2456 % list.
2457 % \begin{itemize}
2458 % \item \cs{@@_get_next:} sets \cs{l_@@_head_gtl}, \cs{l_@@_head_token},
2459 % and if possible \cs{l_@@_head_tl} (otherwise it is cleared).
2460 % \item \cs{@@_get_token:} additionally sets \cs{l_@@_head_cmd_int} and
2461 % \cs{l_@@_head_char_int}.
2462 % \end{itemize}
2463 % The latter is based on \cs{@@_set_cmd:} which derives the
2464 % \cs{l_@@_head_cmd_int} and \cs{l_@@_head_char_int} from
2465 % \cs{l_@@_head_token}.
2466 %
2467 % \begin{macro}{\@@_get_next:}
2468 % \begin{macro}{\@@_get_next_aux:w}
2469 % If the input is empty, insert a frozen \tn{relax} (the alternative
2470 % would be either to grab a token in the input stream after
2471 % \cs{unravel}, which is tough, or simply produce an error and exit;
2472 % perhaps this should be configurable).
2473 % Then remove the first token in the input, and store it in
2474 % \cs{l_@@_head_gtl}. Set \cs{l_@@_head_token} equal in meaning to
2475 % that first token. Then set \cs{l_@@_head_tl} to contain the token,
2476 % unless it is a begin-group or end-group character, in which case
2477 % this token list is emptied.
2478 % \begin{macrocode}
2479 \cs_new_protected:Npn \@@_get_next:
2480 {
2481 \@@_input_if_empty:TF
2482 {
2483 \@@_error:nnnnn { runaway-unravel } { } { } { } { }
2484 \@@_back_input_gtl:N \c_@@_frozen_relax_gtl
2485 }
2486 { }
2487 \@@_input_gpop:N \l_@@_head_gtl
2488 \gtl_head_do:NN \l_@@_head_gtl \@@_get_next_aux:w
2489 \gtl_if_tl:NTF \l_@@_head_gtl
2490 {
2491 \tl_set:Ne \l_@@_head_tl
2492 { \gtl_head:N \l_@@_head_gtl }
2493 \token_if_eq_meaning:NNT
2494 \l_@@_head_token \@@_special_relax:
2495 \@@_get_next_notexpanded:
2496 }
2497 { \tl_clear:N \l_@@_head_tl }
2498 }
2499 \cs_new_protected:Npn \@@_get_next_aux:w
2500 { \cs_set_eq:NN \l_@@_head_token }
2501 % \end{macrocode}
2502 % \end{macro}
2503 % \end{macro}
2504 %
2505 % \begin{macro}{\@@_get_next_notexpanded:}
2506 % \begin{macro}{\@@_notexpanded_test:w, \@@_notexpanded_expand:nN, \@@_notexpanded_expand:NN}
2507 % At this point we have likely encountered a special \tn{relax} marker
2508 % that we use to mark cases where \tn{noexpand} acts on a control
2509 % sequence or an active character. To make sure of that check the
2510 % control sequence has the form \cs{notexpanded:\ldots{}}. Since we
2511 % don't know the escape character we must use \cs{cs_to_str:N}, but
2512 % that function is not meant for active characters and has a runaway
2513 % argument if its argument is a space (active since we know its
2514 % meaning is the special \tn{relax}). To avoid the runaway we include
2515 % an arbitrary delimiter~|Z|. If the token in \cs{l_@@_head_tl} is
2516 % not \cs{notexpanded:\ldots{}} we do nothing. Otherwise
2517 % \cs{@@_notexpanded_expand:n} reconstructs the token that was hit
2518 % with \tn{noexpand} (an active character if the argument is a single
2519 % character) and do the job of \cs{@@_get_next:}, setting
2520 % \cs{l_@@_head_token} to the special \tn{relax} marker for expandable
2521 % commands, as \tn{noexpand} would.
2522 % \begin{macrocode}
2523 \cs_set_protected:Npn \@@_tmp:w #1
2524 {
2525 \cs_new_protected:Npn \@@_get_next_notexpanded:
2526 {
2527 \tl_if_eq:onTF { \l_@@_head_tl } { \@@_unravel_marker: }
2528 { \@@_get_next_marker: }
2529 {
2530 \exp_args:NNe \use:nn \@@_notexpanded_test:w
2531 { \scan_stop: \exp_after:wN \cs_to_str:N \l_@@_head_tl Z }
2532 \q_mark \@@_notexpanded_expand:n
2533 #1 Z \q_mark \use_none:n
2534 \q_stop
2535 }
2536 }
2537 \cs_new_protected:Npn \@@_notexpanded_test:w
2538 ##1 #1 ##2 Z \q_mark ##3##4 \q_stop
2539 { ##3 {##2} }
2540 }
2541 \exp_args:Ne \@@_tmp:w { \scan_stop: \tl_to_str:n { notexpanded: } }
2542 \group_begin:
2543 \char_set_catcode_active:n { 0 }
2544 \cs_new_protected:Npn \@@_notexpanded_expand:n #1
2545 {
2546 \exp_args:Ne \tl_if_empty:nTF { \str_tail:n {#1} }
2547 {
2548 \group_begin:
2549 \char_set_lccode:nn { 0 } { `#1 }
2550 \tex_lowercase:D
2551 {
2552 \group_end:
2553 \@@_notexpanded_expand:N ^^@
2554 }
2555 }
2556 {
2557 \group_begin: \exp_args:NNc \group_end:
2558 \@@_notexpanded_expand:N { \use_none:n #1 }
2559 }
2560 }
2561 \group_end:
2562 \cs_new_protected:Npn \@@_notexpanded_expand:N #1
2563 {
2564 \gtl_set:Nn \l_@@_head_gtl {#1}
2565 \tl_set:Nn \l_@@_head_tl {#1}
2566 \cs_set_eq:NN \l_@@_head_token \@@_special_relax:
2567 }
2568 % \end{macrocode}
2569 % \end{macro}
2570 % \end{macro}
2571 %
2572 % \begin{macro}{\@@_get_next_marker:}
2573 % This is used to deal with nested unravel.
2574 % \begin{macrocode}
2575 \cs_new_protected:Npn \@@_get_next_marker:
2576 {
2577 \@@_get_next:
2578 \tl_if_eq:onTF \l_@@_head_tl { \@@:nn }
2579 { \@@_error:neeee { nested-unravel } { } { } { } { } }
2580 { \@@_error:neeee { internal } { marker~unknown } { } { } { } }
2581 \@@_input_gpop_item:NF \l_@@_argi_tl
2582 { \@@_error:neeee { internal } { marker~1 } { } { } { } }
2583 \@@_input_gpop_item:NF \l_@@_argii_tl
2584 { \@@_error:neeee { internal } { marker~2 } { } { } { } }
2585 \exp_args:Nno \keys_set:nn { unravel } \l_@@_argi_tl
2586 \exp_args:Ne \@@_back_input:n
2587 { \exp_not:N \exp_not:n { \exp_not:o \l_@@_argii_tl } }
2588 \@@_get_next:
2589 }
2590 % \end{macrocode}
2591 % \end{macro}
2592 %
2593 % \begin{macro}{\@@_get_token:}
2594 % Call \cs{@@_get_next:} to set \cs{l_@@_head_gtl}, \cs{l_@@_head_tl}
2595 % and \cs{l_@@_head_token}, then call \cs{@@_set_cmd:} to set
2596 % \cs{l_@@_head_cmd_int} and \cs{l_@@_head_char_int}.
2597 % \begin{macrocode}
2598 \cs_new_protected:Npn \@@_get_token:
2599 {
2600 \@@_get_next:
2601 \@@_set_cmd:
2602 }
2603 % \end{macrocode}
2604 % \end{macro}
2605 %
2606 % \begin{macro}{\@@_set_cmd:}
2607 % After the call to \cs{@@_get_next:}, we find the command code
2608 % \cs{l_@@_head_cmd_int} and the character code
2609 % \cs{l_@@_head_char_int}, based only on \cs{l_@@_head_token}. First
2610 % set \cs{l_@@_head_meaning_tl} from the \tn{meaning} of the first
2611 % token. If the corresponding primitive exists, use the information
2612 % to set the two integers. If the token is expandable, it can either
2613 % be a macro or be a primitive that we somehow do not know
2614 % (\emph{e.g.}, an expandable \XeTeX{} or \LuaTeX{} primitive
2615 % perhaps). Otherwise, it can be a control sequence or a character.
2616 % \begin{macrocode}
2617 \cs_new_protected:Npn \@@_set_cmd:
2618 {
2619 \@@_set_cmd_aux_meaning:
2620 \@@_set_cmd_aux_primitive:oTF { \l_@@_head_meaning_tl }
2621 { }
2622 {
2623 \@@_token_if_expandable:NTF \l_@@_head_token
2624 {
2625 \token_if_macro:NTF \l_@@_head_token
2626 { \@@_set_cmd_aux_macro: }
2627 { \@@_set_cmd_aux_unknown: }
2628 }
2629 {
2630 \token_if_cs:NTF \l_@@_head_token
2631 { \@@_set_cmd_aux_cs: }
2632 { \@@_set_cmd_aux_char: }
2633 }
2634 }
2635 }
2636 % \end{macrocode}
2637 % \end{macro}
2638 %
2639 % \begin{macro}{\@@_set_cmd_aux_meaning:}
2640 % \begin{macro}[EXP]{\@@_set_cmd_aux_meaning:w}
2641 % Remove the leading escape character (\cs{@@_strip_escape:w} takes
2642 % care of special cases there) from the \tn{meaning} of the first
2643 % token, then remove anything after the first~|:|, which is present
2644 % for macros, for marks, and for that character too. For any
2645 % primitive except \tn{nullfont}, this leaves the primitive's name.
2646 % \begin{macrocode}
2647 \cs_new_protected:Npn \@@_set_cmd_aux_meaning:
2648 {
2649 \tl_set:Ne \l_@@_head_meaning_tl
2650 {
2651 \exp_after:wN \@@_strip_escape:w
2652 \token_to_meaning:N \l_@@_head_token
2653 \tl_to_str:n { : }
2654 }
2655 \tl_set:Ne \l_@@_head_meaning_tl
2656 {
2657 \exp_after:wN \@@_set_cmd_aux_meaning:w
2658 \l_@@_head_meaning_tl \q_stop
2659 }
2660 }
2661 \use:e
2662 {
2663 \cs_new:Npn \exp_not:N \@@_set_cmd_aux_meaning:w
2664 #1 \token_to_str:N : #2 \exp_not:N \q_stop {#1}
2665 }
2666 % \end{macrocode}
2667 % \end{macro}
2668 % \end{macro}
2669 %
2670 % \begin{macro}
2671 % {\@@_set_cmd_aux_primitive:nTF, \@@_set_cmd_aux_primitive:oTF}
2672 % \begin{macro}{\@@_set_cmd_aux_primitive:nn}
2673 % Test if there is any information about the given (cleaned-up)
2674 % \tn{meaning}. If there is, use that as the command and character
2675 % integers.
2676 % \begin{macrocode}
2677 \cs_new_protected:Npn \@@_set_cmd_aux_primitive:nTF #1#2
2678 {
2679 \cs_if_exist:cTF { c_@@_tex_#1_tl }
2680 {
2681 \exp_last_unbraced:Nv \@@_set_cmd_aux_primitive:nn
2682 { c_@@_tex_#1_tl }
2683 #2
2684 }
2685 }
2686 \cs_generate_variant:Nn \@@_set_cmd_aux_primitive:nTF { o }
2687 \cs_new_protected:Npn \@@_set_cmd_aux_primitive:nn #1#2
2688 {
2689 \int_set:Nn \l_@@_head_cmd_int {#1}
2690 \int_set:Nn \l_@@_head_char_int {#2}
2691 }
2692 % \end{macrocode}
2693 % \end{macro}
2694 % \end{macro}
2695 %
2696 % \begin{macro}{\@@_set_cmd_aux_macro:}
2697 % The token is a macro. There is no need to determine whether the
2698 % macro is long/outer.
2699 % \begin{macrocode}
2700 \cs_new_protected:Npn \@@_set_cmd_aux_macro:
2701 {
2702 \int_set:Nn \l_@@_head_cmd_int { \@@_tex_use:n { call } }
2703 \int_zero:N \l_@@_head_char_int
2704 }
2705 % \end{macrocode}
2706 % \end{macro}
2707 %
2708 % \begin{macro}{\@@_set_cmd_aux_unknown:}
2709 % Complain about an unknown primitive, and consider it as if it were
2710 % \tn{relax}.
2711 % \begin{macrocode}
2712 \sys_if_engine_luatex:TF
2713 {
2714 \cs_new_protected:Npn \@@_set_cmd_aux_unknown:
2715 {
2716 \exp_last_unbraced:NV \@@_set_cmd_aux_primitive:nn
2717 \c_@@_tex_relax_tl
2718 \@@_tl_if_in:ooTF \l_@@_head_meaning_tl
2719 { \tl_to_str:n { xpandable~luacall } }
2720 { }
2721 {
2722 \@@_error:neeee { unknown-primitive }
2723 { \l_@@_head_meaning_tl } { } { } { }
2724 }
2725 }
2726 }
2727 {
2728 \cs_new_protected:Npn \@@_set_cmd_aux_unknown:
2729 {
2730 \exp_last_unbraced:NV \@@_set_cmd_aux_primitive:nn
2731 \c_@@_tex_relax_tl
2732 \@@_error:neeee { unknown-primitive }
2733 { \l_@@_head_meaning_tl } { } { } { }
2734 }
2735 }
2736 % \end{macrocode}
2737 % \end{macro}
2738 %
2739 % \begin{macro}{\@@_set_cmd_aux_cs:}
2740 % If the \tn{meaning} contains \verb*|elect font|, the control
2741 % sequence is \tn{nullfont} or similar (note that we do not search for
2742 % \verb*|select font|, as the code to trim the escape character from
2743 % the meaning may have removed the leading~|s|). Otherwise, we expect
2744 % the \tn{meaning} to be \tn{char} or \tn{mathchar} or similar followed by
2745 % |"|~and an uppercase hexadecimal number, or one of \tn{count},
2746 % \tn{dimen}, \tn{skip}, \tn{muskip} or \tn{toks} followed by a
2747 % decimal number.
2748 % \begin{macrocode}
2749 \cs_new_protected:Npn \@@_set_cmd_aux_cs:
2750 {
2751 \@@_tl_if_in:ooTF \l_@@_head_meaning_tl
2752 { \tl_to_str:n { elect~font } }
2753 {
2754 \exp_last_unbraced:NV \@@_set_cmd_aux_primitive:nn
2755 \c_@@_tex_nullfont_tl
2756 }
2757 { \@@_set_cmd_aux_numeric: }
2758 }
2759 % \end{macrocode}
2760 % \end{macro}
2761 %
2762 % \begin{macro}
2763 % {
2764 % \@@_set_cmd_aux_numeric:,
2765 % \@@_set_cmd_aux_numeric:w,
2766 % \@@_set_cmd_aux_given:n
2767 % }
2768 % \begin{macro}[rEXP]{\@@_set_cmd_aux_numeric:N}
2769 % Insert \cs{q_mark} before the first non-letter (in fact, anything
2770 % less than~|A|) in the \tn{meaning} by looping one character at a
2771 % time (skipping spaces, but there should be none). We expect the
2772 % first part to be |char| or~|mathchar| (or |kchar| or |omathchar| in (u)p\TeX{}),
2773 % or one of |count|, |dimen|,
2774 % |skip|, |muskip|, or |toks|. In the first two (three) cases, the command is
2775 % |char_given| or |math_given|. It is otherwise identical to the
2776 % corresponding primitive (\tn{count} \emph{etc.}). We then keep
2777 % track of the associated number (part after \cs{q_mark}) in
2778 % \cs{l_@@_head_char_int}. For unknown non-expandable primitives,
2779 % assuming that their meaning consists solely of letters, the
2780 % \cs{q_mark} is inserted at their end, and is followed by~|+0|, so
2781 % nothing breaks.
2782 % \begin{macrocode}
2783 \cs_new_protected:Npn \@@_set_cmd_aux_numeric:
2784 {
2785 \tl_set:Ne \l_@@_tmpa_tl
2786 {
2787 \exp_after:wN \@@_set_cmd_aux_numeric:N
2788 \l_@@_head_meaning_tl + 0
2789 }
2790 \exp_after:wN \@@_set_cmd_aux_numeric:w
2791 \l_@@_tmpa_tl \q_stop
2792 }
2793 \cs_new:Npn \@@_set_cmd_aux_numeric:N #1
2794 {
2795 \if_int_compare:w `#1 < `A \exp_stop_f:
2796 \exp_not:N \q_mark
2797 \exp_after:wN \use_i:nn
2798 \fi:
2799 #1 \@@_set_cmd_aux_numeric:N
2800 }
2801 \cs_new_protected:Npn \@@_set_cmd_aux_numeric:w #1 \q_mark #2 \q_stop
2802 {
2803 \str_case:nnF {#1}
2804 {
2805 { char } { \@@_set_cmd_aux_given:n { char_given } }
2806 { kchar } { \@@_set_cmd_aux_given:n { char_given } }
2807 { mathchar } { \@@_set_cmd_aux_given:n { math_given } }
2808 { omathchar } { \@@_set_cmd_aux_given:n { math_given } }
2809 }
2810 {
2811 \@@_set_cmd_aux_primitive:nTF {#1}
2812 { }
2813 { \@@_set_cmd_aux_unknown: }
2814 \int_add:Nn \l_@@_head_char_int { 100 000 }
2815 }
2816 \int_add:Nn \l_@@_head_char_int {#2}
2817 }
2818 \cs_new_protected:Npn \@@_set_cmd_aux_given:n #1
2819 {
2820 \int_set:Nn \l_@@_head_cmd_int { \@@_tex_use:n {#1} }
2821 \int_zero:N \l_@@_head_char_int
2822 }
2823 % \end{macrocode}
2824 % \end{macro}
2825 % \end{macro}
2826 %
2827 % \begin{macro}{\@@_set_cmd_aux_char:}
2828 % \begin{macro}{\@@_set_cmd_aux_char:w}
2829 % At this point, the \tn{meaning} token list has been shortened by the
2830 % code meant to remove the escape character. We thus set it again to
2831 % the \tn{meaning} of the leading token. The command is then the
2832 % first word (delimited by a space) of the \tn{meaning}, followed by
2833 % |_char|, except for category other, where we use |other_char|. For
2834 % the character code, there is a need to expand
2835 % \cs{@@_token_to_char:N} before placing~|`|.
2836 % \begin{macrocode}
2837 \cs_new_protected:Npn \@@_set_cmd_aux_char:
2838 {
2839 \tl_set:Ne \l_@@_head_meaning_tl
2840 { \token_to_meaning:N \l_@@_head_token }
2841 \token_if_eq_catcode:NNT \l_@@_head_token \c_catcode_other_token
2842 { \tl_set:Nn \l_@@_head_meaning_tl { other~ } }
2843 \exp_after:wN \@@_set_cmd_aux_char:w
2844 \l_@@_head_meaning_tl \q_stop
2845 \exp_args:NNe \int_set:Nn \l_@@_head_char_int
2846 { ` \@@_token_to_char:N \l_@@_head_token }
2847 }
2848 \cs_new_protected:Npn \@@_set_cmd_aux_char:w #1 ~ #2 \q_stop
2849 {
2850 \int_set:Nn \l_@@_head_cmd_int
2851 { \@@_tex_use:n { #1_char } }
2852 }
2853 % \end{macrocode}
2854 % \end{macro}
2855 % \end{macro}
2856 %
2857 % \subsection{Manipulating the input}
2858 %
2859 % \subsubsection{Elementary operations}
2860 %
2861 % \begin{macro}[rEXP]{\@@_input_to_str:}
2862 % Map \cs{gtl_to_str:c} through the input stack.
2863 % \begin{macrocode}
2864 \cs_new:Npn \@@_input_to_str:
2865 {
2866 \int_step_function:nnnN \g_@@_input_int { -1 } { 1 }
2867 \@@_input_to_str_aux:n
2868 }
2869 \cs_new:Npn \@@_input_to_str_aux:n #1
2870 { \gtl_to_str:c { g_@@_input_#1_gtl } }
2871 % \end{macrocode}
2872 % \end{macro}
2873 %
2874 % \begin{macro}{\@@_input_if_empty:TF}
2875 % If the input stack is empty, the input contains no token.
2876 % Otherwise, check the top of the stack for tokens: if there are, then
2877 % the input is non-empty, and if there are none, then we get rid of
2878 % the top of stack and loop.
2879 % \begin{macrocode}
2880 \cs_new_protected:Npn \@@_input_if_empty:TF
2881 {
2882 \int_compare:nNnTF \g_@@_input_int = 0
2883 { \use_i:nn }
2884 {
2885 \gtl_if_empty:cTF
2886 { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
2887 {
2888 \int_gdecr:N \g_@@_input_int
2889 \@@_input_if_empty:TF
2890 }
2891 {
2892 \@@_input_split:
2893 \use_ii:nn
2894 }
2895 }
2896 }
2897 % \end{macrocode}
2898 % \end{macro}
2899 %
2900 % ^^A todo: profiling to know if \@@_input_split: is beneficial.
2901 %
2902 % \begin{macro}{\@@_input_split:}
2903 % If the input is completely flat, and is a token list starting with
2904 % an |N|-type token, try to unflatten it by splitting at each
2905 % occurence of that first token.
2906 % \begin{macrocode}
2907 \cs_new_protected:Npn \@@_input_split:
2908 {
2909 \int_compare:nNnT \g_@@_input_int = 1
2910 {
2911 \exp_args:Nc \@@_input_split_aux:N
2912 { g_@@_input_1_gtl }
2913 }
2914 }
2915 \cs_new_protected:Npn \@@_input_split_aux:N #1
2916 {
2917 \gtl_if_tl:NT #1
2918 {
2919 \gtl_if_head_is_N_type:NT #1
2920 {
2921 \tl_set:Ne \l_@@_input_tmpa_tl { \gtl_left_tl:N #1 }
2922 \exp_args:NNe \use:nn
2923 \@@_input_split_auxii:N
2924 { \tl_head:N \l_@@_input_tmpa_tl }
2925 }
2926 }
2927 }
2928 \cs_new_protected:Npn \@@_input_split_auxii:N #1
2929 {
2930 \token_if_parameter:NF #1
2931 {
2932 \tl_replace_all:Nnn \l_@@_input_tmpa_tl {#1}
2933 { \@@_input_split_end: \@@_input_split_auxiii:w #1 }
2934 \group_begin:
2935 \cs_set:Npn \@@_input_split_auxiii:w
2936 ##1 \@@_input_split_end: { + 1 }
2937 \int_gset:Nn \g_@@_input_int
2938 { 0 \l_@@_input_tmpa_tl \@@_input_split_end: }
2939 \group_end:
2940 \int_gset_eq:NN \g_@@_input_tmpa_int \g_@@_input_int
2941 \l_@@_input_tmpa_tl \@@_input_split_end:
2942 }
2943 }
2944 \cs_new:Npn \@@_input_split_end: { }
2945 \cs_new_protected:Npn \@@_input_split_auxiii:w
2946 #1 \@@_input_split_end:
2947 {
2948 \gtl_gclear_new:c
2949 { g_@@_input_ \int_use:N \g_@@_input_tmpa_int _gtl }
2950 \gtl_gset:cn
2951 { g_@@_input_ \int_use:N \g_@@_input_tmpa_int _gtl } {#1}
2952 \int_gdecr:N \g_@@_input_tmpa_int
2953 }
2954 % \end{macrocode}
2955 % \end{macro}
2956 %
2957 % \begin{macro}{\@@_input_gset:n}
2958 % At first, all of the input is in the same~\texttt{gtl}.
2959 % \begin{macrocode}
2960 \cs_new_protected:Npn \@@_input_gset:n
2961 {
2962 \int_gzero:N \g_@@_input_int
2963 \@@_back_input:n
2964 }
2965 % \end{macrocode}
2966 % \end{macro}
2967 %
2968 % \begin{macro}{\@@_input_get:N}
2969 % \begin{macrocode}
2970 \cs_new_protected:Npn \@@_input_get:N #1
2971 {
2972 \@@_input_if_empty:TF
2973 { \gtl_set:Nn #1 { \q_no_value } }
2974 {
2975 \gtl_get_left:cN
2976 { g_@@_input_ \int_use:N \g_@@_input_int _gtl } #1
2977 }
2978 }
2979 % \end{macrocode}
2980 % \end{macro}
2981 %
2982 % \begin{macro}{\@@_input_get_left:N, \@@_input_get_left_aux:nN}
2983 % \begin{variable}{\l_@@_input_get_left_tl}
2984 % \begin{macrocode}
2985 \tl_new:N \l_@@_input_get_left_tl
2986 \cs_new_protected:Npn \@@_input_get_left:N #1
2987 {
2988 \tl_clear:N #1
2989 \exp_args:NV \@@_input_get_left_aux:nN \g_@@_input_int #1
2990 }
2991 \cs_new_protected:Npn \@@_input_get_left_aux:nN #1#2
2992 {
2993 \int_compare:nNnF {#1} = 0
2994 {
2995 \tl_set:Ne \l_@@_input_get_left_tl
2996 { \gtl_left_tl:c { g_@@_input_#1_gtl } }
2997 \tl_concat:NNN #2 #2 \l_@@_input_get_left_tl
2998 \gtl_if_tl:cT { g_@@_input_#1_gtl }
2999 {
3000 \exp_args:Nf \@@_input_get_left_aux:nN
3001 { \int_eval:n { #1 - 1 } } #2
3002 }
3003 }
3004 }
3005 % \end{macrocode}
3006 % \end{variable}
3007 % \end{macro}
3008 %
3009 % \begin{macro}{\@@_input_gpop:N}
3010 % Call \cs{@@_input_if_empty:TF} to remove empty levels from the input
3011 % stack, then extract the first token from the left-most non-empty
3012 % level.
3013 % \begin{macrocode}
3014 \cs_new_protected:Npn \@@_input_gpop:N #1
3015 {
3016 \@@_input_if_empty:TF
3017 { \gtl_set:Nn #1 { \q_no_value } }
3018 {
3019 \gtl_gpop_left:cN
3020 { g_@@_input_ \int_use:N \g_@@_input_int _gtl } #1
3021 }
3022 }
3023 % \end{macrocode}
3024 % \end{macro}
3025 %
3026 % \begin{macro}{\@@_input_merge:}
3027 % Merge the top two levels of input. This requires, but does not
3028 % check, that \cs{g_@@_input_int} is at least~$2$.
3029 % \begin{macrocode}
3030 \cs_new_protected:Npn \@@_input_merge:
3031 {
3032 \int_gdecr:N \g_@@_input_int
3033 \gtl_gconcat:ccc
3034 { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3035 { g_@@_input_ \int_eval:n { \g_@@_input_int + 1 } _gtl }
3036 { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3037 \gtl_gclear:c
3038 { g_@@_input_ \int_eval:n { \g_@@_input_int + 1 } _gtl }
3039 }
3040 % \end{macrocode}
3041 % \end{macro}
3042 %
3043 % \begin{macro}[TF]{\@@_input_gpop_item:N}
3044 % \begin{macro}{\@@_input_gpop_item_aux:NN}
3045 % If there is no input, we cannot pop an item. Othewise, try to pop
3046 % from the top of the input stack. If this succeeds, or if this
3047 % failed and the top of stack has extra end-group characters, or if
3048 % the input stack contains only the top-most item, then the answer
3049 % given by \cs{gtl_gpop_left_item:NNTF} is the correct one, which we
3050 % return. Otherwise, merge the top two levels and repeat.
3051 % \begin{macrocode}
3052 \prg_new_protected_conditional:Npnn \@@_input_gpop_item:N #1 { F }
3053 {
3054 \int_compare:nNnTF \g_@@_input_int = 0
3055 { \prg_return_false: }
3056 {
3057 \exp_args:Nc \@@_input_gpop_item_aux:NN
3058 { g_@@_input_ \int_use:N \g_@@_input_int _gtl } #1
3059 }
3060 }
3061 \cs_new_protected:Npn \@@_input_gpop_item_aux:NN #1#2
3062 {
3063 \gtl_gpop_left_item:NNTF #1#2
3064 { \prg_return_true: }
3065 {
3066 \int_compare:nNnTF { \gtl_extra_end:N #1 } > 0
3067 { \prg_return_false: }
3068 {
3069 \int_compare:nNnTF \g_@@_input_int = 1
3070 { \prg_return_false: }
3071 {
3072 \@@_input_merge:
3073 \exp_args:Nc \@@_input_gpop_item_aux:NN
3074 {
3075 g_@@_input_
3076 \int_use:N \g_@@_input_int _gtl
3077 }
3078 #2
3079 }
3080 }
3081 }
3082 }
3083 % \end{macrocode}
3084 % \end{macro}
3085 % \end{macro}
3086 %
3087 % \begin{macro}{\@@_input_gpop_tl:N}
3088 % \begin{macrocode}
3089 \cs_new_protected:Npn \@@_input_gpop_tl:N #1
3090 { \tl_clear:N #1 \@@_input_gpop_tl_aux:N #1 }
3091 \cs_new_protected:Npn \@@_input_gpop_tl_aux:N #1
3092 {
3093 \int_compare:nNnF \g_@@_input_int = 0
3094 {
3095 \exp_args:Nc \@@_input_gpop_tl_aux:NN
3096 { g_@@_input_ \int_use:N \g_@@_input_int _gtl } #1
3097 }
3098 }
3099 \cs_new_protected:Npn \@@_input_gpop_tl_aux:NN #1#2
3100 {
3101 \gtl_if_tl:NTF #1
3102 {
3103 \tl_put_right:Ne #2 { \gtl_left_tl:N #1 }
3104 \gtl_gclear:N #1
3105 \int_gdecr:N \g_@@_input_int
3106 \@@_input_gpop_tl_aux:N #2
3107 }
3108 {
3109 \int_compare:nNnTF \g_@@_input_int > 1
3110 { \int_compare:nNnTF { \gtl_extra_end:N #1 } > 0 }
3111 { \use_i:nn }
3112 {
3113 \tl_put_right:Ne #2 { \gtl_left_tl:N #1 }
3114 \gtl_gpop_left_tl:N #1
3115 }
3116 {
3117 \@@_input_merge:
3118 \@@_input_gpop_tl_aux:N #2
3119 }
3120 }
3121 }
3122 % \end{macrocode}
3123 % \end{macro}
3124 %
3125 % \begin{macro}[TF]{\@@_input_if_head_is_group_begin:}
3126 % Call \cs{@@_input_if_empty:TF} to remove empty levels from the input
3127 % stack, then check if the left-most non-empty level starts with an
3128 % explicit begin-group character token.
3129 % \begin{macrocode}
3130 \prg_new_protected_conditional:Npnn \@@_input_if_head_is_group_begin: { T , F , TF }
3131 {
3132 \@@_input_if_empty:TF
3133 { \prg_return_false: }
3134 {
3135 \exp_args:Nc \gtl_if_head_is_group_begin:NTF
3136 { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3137 { \prg_return_true: }
3138 { \prg_return_false: }
3139 }
3140 }
3141 % \end{macrocode}
3142 % \end{macro}
3143 %
3144 % \begin{macro}{\@@_back_input:n, \@@_back_input:V, \@@_back_input:o}
3145 % Insert a token list back into the input. Use \cs{gtl_gclear_new:c}
3146 % to define the gtl variable if necessary: this happens whenever a
3147 % new largest value of \cs{g_@@_input_int} is reached.
3148 % \begin{macrocode}
3149 \cs_new_protected:Npn \@@_back_input:n
3150 {
3151 \int_gincr:N \g_@@_input_int
3152 \gtl_gclear_new:c { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3153 \gtl_gset:cn { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3154 }
3155 \cs_generate_variant:Nn \@@_back_input:n { V , o }
3156 % \end{macrocode}
3157 % \end{macro}
3158 %
3159 % \begin{macro}{\@@_back_input_gtl:N}
3160 % Insert a generalized token list back into the input.
3161 % \begin{macrocode}
3162 \cs_new_protected:Npn \@@_back_input_gtl:N #1
3163 {
3164 \gtl_if_tl:NTF #1
3165 { \exp_args:Ne \@@_back_input:n { \gtl_left_tl:N #1 } }
3166 {
3167 \gtl_gconcat:cNc
3168 { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3169 #1
3170 { g_@@_input_ \int_use:N \g_@@_input_int _gtl }
3171 }
3172 }
3173 % \end{macrocode}
3174 % \end{macro}
3175 %
3176 % \begin{macro}{\@@_back_input:}
3177 % Insert the last token read back into the input stream.
3178 % \begin{macrocode}
3179 \cs_new_protected:Npn \@@_back_input:
3180 { \@@_back_input_gtl:N \l_@@_head_gtl }
3181 % \end{macrocode}
3182 % \end{macro}
3183 %
3184 % \begin{macro}{\@@_back_input_tl_o:}
3185 % Insert the \cs{l_@@_head_tl} (may or may not be the last token read)
3186 % back into the input stream, after expanding it once. Then print
3187 % some diagnostic information.
3188 % \begin{macrocode}
3189 \cs_new_protected:Npn \@@_back_input_tl_o:
3190 {
3191 \tl_set:Ne \l_@@_tmpa_tl
3192 { \exp_args:NV \exp_not:o \l_@@_head_tl }
3193 \@@_back_input:V \l_@@_tmpa_tl
3194 \@@_print_expansion:e
3195 { \tl_to_str:N \l_@@_head_tl = \tl_to_str:N \l_@@_tmpa_tl }
3196 }
3197 % \end{macrocode}
3198 % \end{macro}
3199 %
3200 % \subsubsection{Insert token for error recovery}
3201 %
3202 % \begin{macro}{\@@_insert_relax:}
3203 % This function inserts \TeX{}'s |frozen_relax|. It is called when a
3204 % conditional is not done finding its condition, but hits the
3205 % corresponding \tn{fi} or \tn{or} or \tn{else}, or when \tn{input}
3206 % appears while \cs{g_@@_name_in_progress_bool} is \texttt{true}.
3207 % \begin{macrocode}
3208 \cs_new_protected:Npn \@@_insert_relax:
3209 {
3210 \@@_back_input:
3211 \gtl_set_eq:NN \l_@@_head_gtl \c_@@_frozen_relax_gtl
3212 \@@_back_input:
3213 \@@_print_action:
3214 }
3215 % \end{macrocode}
3216 % \end{macro}
3217 %
3218 % \begin{macro}{\@@_insert_group_begin_error:}
3219 % \begin{macrocode}
3220 \cs_new_protected:Npn \@@_insert_group_begin_error:
3221 {
3222 \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_head_tl
3223 \@@_back_input:
3224 \gtl_set_eq:NN \l_@@_head_gtl \c_group_begin_gtl
3225 \@@_back_input:
3226 \@@_tex_error:nV { missing-lbrace } \l_@@_tmpa_tl
3227 \@@_print_action:
3228 }
3229 % \end{macrocode}
3230 % \end{macro}
3231 %
3232 % \begin{macro}{\@@_insert_dollar_error:}
3233 % \begin{macrocode}
3234 \cs_new_protected:Npn \@@_insert_dollar_error:
3235 {
3236 \@@_back_input:
3237 \@@_back_input:n { $ } % $
3238 \@@_error:nnnnn { missing-dollar } { } { } { } { }
3239 \@@_print_action:
3240 }
3241 % \end{macrocode}
3242 % \end{macro}
3243 %
3244 % \subsubsection{Macro calls}
3245 %
3246 % \begin{macro}[EXP]
3247 % {
3248 % \@@_macro_prefix:N,
3249 % \@@_macro_parameter:N,
3250 % \@@_macro_replacement:N
3251 % }
3252 % \begin{macrocode}
3253 \use:e
3254 {
3255 \exp_not:n { \cs_new:Npn \@@_macro_split_do:NN #1 }
3256 {
3257 \exp_not:n { \exp_after:wN \@@_macro_split_do:wN }
3258 \exp_not:n { \token_to_meaning:N #1 \q_mark { } }
3259 \tl_to_str:n { : } \exp_not:n { -> \q_mark \use_none:nnnn }
3260 \exp_not:N \q_stop
3261 }
3262 \exp_not:n { \cs_new:Npn \@@_macro_split_do:wN }
3263 \exp_not:n {#1} \tl_to_str:n { : } \exp_not:n { #2 -> }
3264 \exp_not:n { #3 \q_mark #4 #5 \q_stop #6 }
3265 { \exp_not:n { #4 #6 {#1} {#2} {#3} } }
3266 }
3267 \cs_new:Npn \@@_macro_prefix:N #1
3268 { \@@_macro_split_do:NN #1 \use_i:nnn }
3269 \cs_new:Npn \@@_macro_parameter:N #1
3270 { \@@_macro_split_do:NN #1 \use_ii:nnn }
3271 \cs_new:Npn \@@_macro_replacement:N #1
3272 { \@@_macro_split_do:NN #1 \use_iii:nnn }
3273 % \end{macrocode}
3274 % \end{macro}
3275 %
3276 % ^^A todo: redoc
3277 % \begin{macro}{\@@_macro_call:}
3278 % \begin{macro}
3279 % {
3280 % \@@_macro_call_safe:,
3281 % \@@_macro_call_quick:,
3282 % \@@_macro_call_quick_loop:NNN,
3283 % \@@_macro_call_quick_loop:NN,
3284 % \@@_macro_call_quick_runaway:Nw,
3285 % }
3286 % Macros are simply expanded once. We cannot determine precisely
3287 % which tokens a macro will need for its parameters, but we know that
3288 % it must form a balanced token list. Thus we can be safe by
3289 % extracting the longest balanced prefix in the input and working with
3290 % that. We need to check if the argument was braced, to improve the
3291 % error recovery for a non-\tn{long} macro receiving \tn{par}.
3292 % \begin{macrocode}
3293 \cs_new_protected:Npn \@@_macro_call:
3294 {
3295 \bool_if:NTF \g_@@_speedup_macros_bool
3296 {
3297 \tl_set:Ne \l_@@_tmpa_tl
3298 { ^ \exp_after:wN \@@_macro_parameter:N \l_@@_head_tl }
3299 \@@_tl_if_in:ooTF \c_@@_parameters_tl \l_@@_tmpa_tl
3300 { \@@_macro_call_quick: } { \@@_macro_call_safe: }
3301 }
3302 { \@@_macro_call_safe: }
3303 \exp_args:NV \@@_back_input:o \l_@@_head_tl
3304 \@@_print_expansion:
3305 }
3306 \cs_new_protected:Npn \@@_macro_call_safe:
3307 {
3308 \@@_input_gpop_tl:N \l_@@_tmpa_tl
3309 \tl_put_right:NV \l_@@_head_tl \l_@@_tmpa_tl
3310 }
3311 \cs_new_protected:Npn \@@_macro_call_quick:
3312 {
3313 \exp_after:wN \@@_macro_call_quick_loop:NNN \l_@@_tmpa_tl
3314 { ? \use_none_delimit_by_q_stop:w } \q_stop
3315 }
3316 \cs_new_protected:Npn \@@_macro_call_quick_loop:NNN #1#2#3
3317 {
3318 \use_none:n #2
3319 \@@_input_if_head_is_group_begin:TF
3320 { \@@_macro_call_quick_loop:NN \prg_do_nothing: }
3321 { \@@_macro_call_quick_loop:NN \use:n }
3322 #3
3323 }
3324 \cs_new_protected:Npn \@@_macro_call_quick_loop:NN #1#2
3325 {
3326 \@@_input_gpop_item:NF \l_@@_tmpa_tl
3327 { \@@_macro_call_quick_runaway:Nw #2 }
3328 \tl_put_right:Ne \l_@@_head_tl
3329 { #1 { \exp_not:V \l_@@_tmpa_tl } }
3330 \@@_macro_call_quick_loop:NNN
3331 #2
3332 }
3333 \cs_new_protected:Npn \@@_macro_call_quick_runaway:Nw #1#2 \q_stop
3334 {
3335 \@@_error:neeee { runaway-macro-parameter }
3336 { \tl_to_str:N \l_@@_head_tl } { \tl_to_str:n {#1} } { } { }
3337 }
3338 % \end{macrocode}
3339 % \end{macro}
3340 % \end{macro}
3341 %
3342 % \subsection{Expand next token}
3343 %
3344 % \begin{macro}{\@@_expand_do:N}
3345 % The argument is a command that will almost always be run to continue
3346 % a loop whose aim is to find the next non-expandable token, for
3347 % various purposes. The only case where we will end up grabbing the
3348 % argument is to suppress the loop by \cs{@@_noexpand:N}.
3349 % \begin{itemize}
3350 % \item \cs{@@_get_x_next:} when \TeX{} is looking for the first
3351 % non-expandable token in the main loop or when looking for numbers,
3352 % optional spaces etc.
3353 % \item \cs{@@_get_x_or_protected:} at the start of an alignment cell.
3354 % \item \cs{@@_get_token_xdef:} in the replacement text of \tn{edef}
3355 % and \tn{xdef}.
3356 % \item \cs{@@_get_token_x:} in the argument of \tn{message} and the
3357 % like.
3358 % \item \cs{prg_do_nothing:} in \cs{@@_expandafter:} namely after
3359 % \tn{expandafter}.
3360 % \end{itemize}
3361 % We mimick \TeX{}'s structure, distinguishing macros from other
3362 % commands because we find macro arguments very differently from
3363 % primitives.
3364 % \begin{macrocode}
3365 \cs_new_protected:Npn \@@_expand_do:N
3366 {
3367 \@@_set_action_text:
3368 \bool_if:NT \g_@@_internal_debug_bool
3369 {
3370 \@@_set_cmd:
3371 \exp_args:Ne \iow_term:n { Exp:~\int_to_arabic:n { \l_@@_head_cmd_int } }
3372 }
3373 \token_if_macro:NTF \l_@@_head_token
3374 { \@@_macro_call: }
3375 { \@@_expand_nonmacro: }
3376 }
3377 % \end{macrocode}
3378 % \end{macro}
3379 %
3380 % \begin{macro}{\@@_expand_nonmacro:}
3381 % The token is a primitive. We find its (cleaned-up) \tn{meaning},
3382 % and call the function implementing that expansion. If we do not
3383 % recognize the meaning then it is probably an unknown primitive.
3384 % Then do something similar to what we do for macros: get all tokens
3385 % that are not too unlikely to appear in the arguments of the
3386 % primitive and expand the resulting token list once before putting it
3387 % back into the input stream.
3388 % \begin{macrocode}
3389 \cs_new_protected:Npn \@@_expand_nonmacro:
3390 {
3391 \@@_set_cmd_aux_meaning:
3392 \@@_set_cmd_aux_primitive:oTF { \l_@@_head_meaning_tl }
3393 {
3394 \cs_if_exist_use:cF
3395 { @@_expandable_ \int_use:N \l_@@_head_cmd_int : }
3396 { \@@_error:neeee { internal } { expandable } { } { } { } }
3397 }
3398 {
3399 \@@_set_cmd_aux_unknown:
3400 \@@_input_gpop_tl:N \l_@@_tmpa_tl
3401 \tl_put_right:NV \l_@@_head_tl \l_@@_tmpa_tl
3402 \exp_args:NV \@@_back_input:o \l_@@_head_tl
3403 \@@_print_expansion:
3404 }
3405 }
3406 % \end{macrocode}
3407 % \end{macro}
3408 %
3409 % \begin{macro}{\@@_get_x_next:}
3410 % Get a token. If it is expandable, then expand it, and repeat. This
3411 % function does not set the |cmd| and |char| integers. It is the
3412 % basis of all routines that look for keywords, numbers, equal signs,
3413 % filenames, optional spaces etc (in the language of \LaTeX3 these are
3414 % situations where \TeX{} \enquote{\texttt{f}-expands}). It is also
3415 % the basis of the \cs{@@_main_loop:}.
3416 % \begin{macrocode}
3417 \cs_new_protected:Npn \@@_get_x_next:
3418 {
3419 \@@_get_next:
3420 \@@_token_if_expandable:NT \l_@@_head_token
3421 { \@@_expand_do:N \@@_get_x_next: }
3422 }
3423 % \end{macrocode}
3424 % \end{macro}
3425 %
3426 % \begin{macro}{\@@_get_x_or_protected:}
3427 % Get a token. If it is expandable, but not protected, then expand
3428 % it, and repeat. This function does not set the |cmd| and |char|
3429 % integers. This function is not used at present: it will be used at
3430 % the start of alignment cells.
3431 % \begin{macrocode}
3432 \cs_new_protected:Npn \@@_get_x_or_protected:
3433 {
3434 \@@_get_next:
3435 \@@_token_if_protected:NF \l_@@_head_token
3436 { \@@_expand_do:N \@@_get_x_or_protected: }
3437 }
3438 % \end{macrocode}
3439 % \end{macro}
3440 %
3441 % \begin{macro}{\@@_get_token_xdef:, \@@_get_token_x:}
3442 % These are similar to \cs{@@_get_x_next:}, for use when reading the
3443 % replacement text of \tn{edef}/\tn{xdef} or the argument of a
3444 % primitive like \tn{message} that should be expanded as we read
3445 % tokens. Loop until finding a non-expandable token (or protected
3446 % macro).
3447 % \begin{macrocode}
3448 \cs_new_protected:Npn \@@_get_token_xdef:
3449 {
3450 \@@_get_next:
3451 \@@_token_if_protected:NF \l_@@_head_token
3452 { \@@_expand_do:N \@@_get_token_xdef: }
3453 }
3454 \cs_new_protected:Npn \@@_get_token_x:
3455 {
3456 \@@_get_next:
3457 \@@_token_if_protected:NF \l_@@_head_token
3458 { \@@_expand_do:N \@@_get_token_x: }
3459 }
3460 % \end{macrocode}
3461 % \end{macro}
3462 %
3463 % \subsection{Basic scanning subroutines}
3464 %
3465 % ^^A todo: implement |test_no_ligatures|?
3466 % ^^A todo: implement |get_tag_code|?
3467 %
3468 % \begin{macro}{\@@_get_x_non_blank:}
3469 % This function does not set the |cmd| and |char| integers.
3470 % \begin{macrocode}
3471 \cs_new_protected:Npn \@@_get_x_non_blank:
3472 {
3473 \@@_get_x_next:
3474 \token_if_eq_catcode:NNT \l_@@_head_token \c_space_token
3475 { \@@_get_x_non_blank: }
3476 }
3477 % \end{macrocode}
3478 % \end{macro}
3479 %
3480 % \begin{macro}{\@@_get_x_non_relax:}
3481 % This function does not set the |cmd| and |char| integers.
3482 % \begin{macrocode}
3483 \cs_new_protected:Npn \@@_get_x_non_relax:
3484 {
3485 \@@_get_x_next:
3486 \token_if_eq_meaning:NNTF \l_@@_head_token \scan_stop:
3487 { \@@_get_x_non_relax: }
3488 {
3489 \token_if_eq_meaning:NNTF \l_@@_head_token \@@_special_relax:
3490 { \@@_get_x_non_relax: }
3491 {
3492 \token_if_eq_catcode:NNT \l_@@_head_token \c_space_token
3493 { \@@_get_x_non_relax: }
3494 }
3495 }
3496 }
3497 % \end{macrocode}
3498 % \end{macro}
3499 %
3500 % \begin{macro}{\@@_skip_optional_space:}
3501 % \begin{macrocode}
3502 \cs_new_protected:Npn \@@_skip_optional_space:
3503 {
3504 \@@_get_x_next:
3505 \token_if_eq_catcode:NNF \l_@@_head_token \c_space_token
3506 { \@@_back_input: }
3507 }
3508 % \end{macrocode}
3509 % \end{macro}
3510 %
3511 % \begin{macro}{\@@_scan_optional_equals:}
3512 % See \TeX{}'s |scan_optional_equals|. In all cases we forcefully
3513 % insert an equal sign in the output, because this sign is required,
3514 % as \cs{@@_rescan_something_internal:n} leaves raw numbers in
3515 % the previous-input sequence.
3516 % \begin{macrocode}
3517 \cs_new_protected:Npn \@@_scan_optional_equals:
3518 {
3519 \@@_get_x_non_blank:
3520 \tl_if_eq:NNTF \l_@@_head_tl \c_@@_eq_tl
3521 { \@@_prev_input:n { = } }
3522 {
3523 \@@_prev_input_silent:n { = }
3524 \@@_back_input:
3525 }
3526 }
3527 % \end{macrocode}
3528 % \end{macro}
3529 %
3530 % \begin{macro}{\@@_scan_left_brace:}
3531 % The presence of \tn{relax} is allowed before a begin-group token.
3532 % If there is no begin-group token, insert one, produce an error, and
3533 % scan that begin-group using \cs{@@_get_next:}.
3534 % \begin{macrocode}
3535 \cs_new_protected:Npn \@@_scan_left_brace:
3536 {
3537 \@@_get_x_non_relax:
3538 \token_if_eq_catcode:NNF \l_@@_head_token \c_group_begin_token
3539 {
3540 \@@_insert_group_begin_error:
3541 \@@_get_next:
3542 }
3543 }
3544 % \end{macrocode}
3545 % \end{macro}
3546 %
3547 % \begin{macro}{\@@_scan_keyword:n}
3548 % \begin{macro}[TF]{\@@_scan_keyword:n}
3549 % \begin{macro}
3550 % {
3551 % \@@_scan_keyword_loop:NNN,
3552 % \@@_scan_keyword_test:NNTF,
3553 % \@@_scan_keyword_true:,
3554 % \@@_scan_keyword_false:w
3555 % }
3556 %
3557 % The details of how \TeX{} looks for keywords are quite tricky to get
3558 % right, in particular with respect to expansion, case-insensitivity,
3559 % and spaces. We get rid of the case issue by requiring the keyword
3560 % to be given in both cases, intertwined: for instance,
3561 % \cs{@@_scan_keyword:n} |{| |pPtT| |}|. Then loop through pairs of
3562 % letters (which should be matching lowercase and uppercase letters).
3563 % The looping auxiliary takes three arguments, the first of which is a
3564 % boolean, \texttt{true} if spaces are allowed (no letter of the
3565 % keyword has been found yet). At each iteration, get a token, with
3566 % expansion, and test whether it is a non-active character equal (in
3567 % character code) to either letter of the pair: this happens if the
3568 % token is not ``definable'' (neither a control sequence nor an active
3569 % character) and it has the right string representation\ldots{} well,
3570 % it could also be doubled (macro parameter character), hence we look
3571 % at the first character only; spaces become an empty string, but this
3572 % works out because no keyword contains a space. So, at each
3573 % iteration, if the token is the correct non-active character, add it
3574 % to the previous-input sequence (as a generalized token list since
3575 % keywords may match begin-group or end-group characters), and
3576 % otherwise break with \cs{@@_scan_keyword_false:w}, unless we are
3577 % still at the beginning of the keyword and the token is a space.
3578 % When the loop reaches the end of the keyword letter pairs, complain
3579 % if there were an odd number of letters, and otherwise conclude the
3580 % loop with \cs{@@_scan_keyword_true:}, which stores the keyword,
3581 % converted to a string. Note that \TeX{}'s skipping of leading
3582 % spaces here must be intertwined with the search for keyword, as is
3583 % shown by the (plain \TeX{}) example
3584 % \begin{verbatim}
3585 % \lccode32=`f \lowercase{\def\fspace{ }}
3586 % \skip0=1pt plus 1 \fspace il\relax
3587 % \message{\the\skip0} % => 1pt plus 1fil
3588 % \end{verbatim}
3589 % \begin{macrocode}
3590 \cs_new_protected:Npn \@@_scan_keyword:n #1
3591 { \@@_scan_keyword:nTF {#1} { } { } }
3592 \prg_new_protected_conditional:Npnn \@@_scan_keyword:n #1
3593 { T , F , TF }
3594 {
3595 \@@_prev_input_gpush_gtl:
3596 \@@_scan_keyword_loop:NNN \c_true_bool
3597 #1 \q_recursion_tail \q_recursion_tail \q_recursion_stop
3598 }
3599 \cs_new_protected:Npn \@@_scan_keyword_loop:NNN #1#2#3
3600 {
3601 \quark_if_recursion_tail_stop_do:nn {#2}
3602 { \@@_scan_keyword_true: }
3603 \quark_if_recursion_tail_stop_do:nn {#3}
3604 { \@@_error:neeee { internal } { odd-keyword-length } { } { } { } }
3605 \@@_get_x_next:
3606 \@@_scan_keyword_test:NNTF #2#3
3607 {
3608 \@@_prev_input_gtl:N \l_@@_head_gtl
3609 \@@_scan_keyword_loop:NNN \c_false_bool
3610 }
3611 {
3612 \token_if_eq_catcode:NNF \l_@@_head_token \c_space_token
3613 { \@@_scan_keyword_false:w }
3614 \bool_if:NF #1
3615 { \@@_scan_keyword_false:w }
3616 \@@_scan_keyword_loop:NNN #1#2#3
3617 }
3618 }
3619 \prg_new_protected_conditional:Npnn \@@_scan_keyword_test:NN #1#2
3620 { TF }
3621 {
3622 \@@_gtl_if_head_is_definable:NTF \l_@@_head_gtl
3623 { \prg_return_false: }
3624 {
3625 \str_if_eq:eeTF
3626 { \str_head:f { \gtl_to_str:N \l_@@_head_gtl } } {#1}
3627 { \prg_return_true: }
3628 {
3629 \str_if_eq:eeTF
3630 { \str_head:f { \gtl_to_str:N \l_@@_head_gtl } } {#2}
3631 { \prg_return_true: }
3632 { \prg_return_false: }
3633 }
3634 }
3635 }
3636 \cs_new_protected:Npn \@@_scan_keyword_true:
3637 {
3638 \@@_prev_input_gpop_gtl:N \l_@@_tmpb_gtl
3639 \@@_prev_input:e { \gtl_to_str:N \l_@@_tmpb_gtl }
3640 \prg_return_true:
3641 }
3642 \cs_new_protected:Npn \@@_scan_keyword_false:w
3643 #1 \q_recursion_stop
3644 {
3645 \@@_back_input:
3646 \@@_prev_input_gpop_gtl:N \l_@@_tmpb_gtl
3647 \@@_back_input_gtl:N \l_@@_tmpb_gtl
3648 \prg_return_false:
3649 }
3650 % \end{macrocode}
3651 % \end{macro}
3652 % \end{macro}
3653 % \end{macro}
3654 %
3655 % \begin{macro}{\@@_scan_to:}
3656 % Used when |to| is mandatory: after \tn{read} or \tn{readline} and
3657 % after \tn{vsplit}.
3658 % \begin{macrocode}
3659 \cs_new_protected:Npn \@@_scan_to:
3660 {
3661 \@@_scan_keyword:nF { tToO }
3662 {
3663 \@@_error:nnnnn { missing-to } { } { } { } { }
3664 \@@_prev_input:n { to }
3665 }
3666 }
3667 % \end{macrocode}
3668 % \end{macro}
3669 %
3670 % \begin{macro}{\@@_scan_font_ident:}
3671 % Find a font identifier.
3672 % \begin{macrocode}
3673 \cs_new_protected:Npn \@@_scan_font_ident:
3674 {
3675 \@@_get_x_non_blank:
3676 \@@_set_cmd:
3677 \int_case:nnF \l_@@_head_cmd_int
3678 {
3679 { \@@_tex_use:n { def_font } }
3680 { \@@_prev_input:V \l_@@_head_tl }
3681 { \@@_tex_use:n { letterspace_font } }
3682 { \@@_prev_input:V \l_@@_head_tl }
3683 { \@@_tex_use:n { pdf_copy_font } }
3684 { \@@_prev_input:V \l_@@_head_tl }
3685 { \@@_tex_use:n { set_font } }
3686 { \@@_prev_input:V \l_@@_head_tl }
3687 { \@@_tex_use:n { def_family } }
3688 {
3689 \@@_prev_input:V \l_@@_head_tl
3690 \@@_scan_int:
3691 }
3692 }
3693 {
3694 \@@_error:nnnnn { missing-font-id } { } { } { } { }
3695 \@@_back_input:
3696 \@@_prev_input:n { \@@_nullfont: }
3697 }
3698 }
3699 % \end{macrocode}
3700 % \end{macro}
3701 %
3702 % \begin{macro}{\@@_scan_font_int:}
3703 % Find operands for one of \tn{hyphenchar}'s friends (command code
3704 % |assign_font_int=78|).
3705 % \begin{macrocode}
3706 \cs_new_protected:Npn \@@_scan_font_int:
3707 {
3708 \int_case:nnF \l_@@_head_char_int
3709 {
3710 { 0 } { \@@_scan_font_ident: }
3711 { 1 } { \@@_scan_font_ident: }
3712 { 6 } { \@@_scan_font_ident: }
3713 }
3714 { \@@_scan_font_ident: \@@_scan_int: }
3715 }
3716 % \end{macrocode}
3717 % \end{macro}
3718 %
3719 % \begin{macro}{\@@_scan_font_dimen:}
3720 % Find operands for \tn{fontdimen}.
3721 % \begin{macrocode}
3722 \cs_new_protected:Npn \@@_scan_font_dimen:
3723 {
3724 \@@_scan_int:
3725 \@@_scan_font_ident:
3726 }
3727 % \end{macrocode}
3728 % \end{macro}
3729 %
3730 % \begin{macro}{\@@_rescan_something_internal:n}
3731 % \begin{macro}{\@@_scan_something_aux:nwn}
3732 % Receives an (explicit) \enquote{level} argument:
3733 % \begin{itemize}
3734 % \item |int_val=0| for integer values;
3735 % \item |dimen_val=1| for dimension values;
3736 % \item |glue_val=2| for glue specifications;
3737 % \item |mu_val=3| for math glue specifications;
3738 % \item |ident_val=4| for font identifiers (this never happens);
3739 % \item |tok_val=5| for token lists (after |\the| or |\showthe|).
3740 % \end{itemize}
3741 % Scans something internal, and places its value, converted to the
3742 % given level, to the right of the last item of
3743 % the previous-input sequence, then sets \cs{g_@@_val_level_int} to the
3744 % found level (level before conversion, so this may be higher than
3745 % requested).
3746 %
3747 % From \cs{@@_thing_case:}, get the information about what level is
3748 % produced by the given token once it has received all its operands
3749 % (head of \cs{l_@@_tmpa_tl}), and about what to do to find those
3750 % operands (tail of \cs{l_@@_tmpa_tl}). If the first token may not
3751 % appear after \tn{the} at all, \cs{@@_thing_case:} gives level~$8$.
3752 %
3753 % If the argument (|#3|~in the auxiliary) is $<4$ but the level that
3754 % will be produced (|#1|~in the auxiliary) is $\geq 4$ (that is,
3755 % $4$, $5$, or $8$) complain about a missing number and insert a
3756 % zero dimension, to get exactly \TeX{}'s error recovery. If the
3757 % level produced is~$8$, complain that |\the| cannot do this.
3758 %
3759 % Otherwise, scan the arguments (in a new input level). If both the
3760 % argument and the level produced are $<4$, then get the value with
3761 % \cs{@@_thing_use_get:nnNN} which downgrades from glue to dimension
3762 % to integer and produces the |incompatible-units| error if needed.
3763 % The only remaining case is that the argument is $5$ (since $4$ is
3764 % never used) and the level produced is that or less: then the value
3765 % found is used with \cs{@@_the:w}.
3766 %
3767 % Finally, tell the user the tokens that have been found (if there
3768 % was a single token, its meaning as well) and their value. Use |=>|
3769 % rather than |=| because the value displayed is the value used, not
3770 % the actual value (this matters in constructions such as
3771 % |\parindent=\parskip| where a skip or a dimen is downgraded to a
3772 % dimen or an int, or when there was an error).
3773 % \begin{macrocode}
3774 \cs_new_protected:Npn \@@_rescan_something_internal:n #1
3775 {
3776 \@@_set_cmd:
3777 \@@_set_action_text:
3778 \tl_set:Nf \l_@@_tmpa_tl { \@@_thing_case: }
3779 \exp_after:wN \@@_scan_something_aux:nwn
3780 \l_@@_tmpa_tl \q_stop {#1}
3781 }
3782 \cs_new_protected:Npn \@@_scan_something_aux:nwn #1#2 \q_stop #3
3783 {
3784 \int_compare:nT { #3 < 4 <= #1 }
3785 {
3786 \@@_back_input:
3787 \@@_tex_error:nV { missing-number } \l_@@_head_tl
3788 \@@_thing_use_get:nnNN { 1 } {#3} \c_zero_dim \l_@@_tmpa_tl
3789 \@@_rescan_something_internal_auxii:Vn \l_@@_tmpa_tl { 1 }
3790 \@@_break:w
3791 }
3792 \int_compare:nNnT {#1} = { 8 }
3793 {
3794 \@@_tex_error:nV { the-cannot } \l_@@_head_tl
3795 \@@_rescan_something_internal_auxii:nn 0 { 0 }
3796 \@@_break:w
3797 }
3798 \tl_if_empty:nF {#2}
3799 {
3800 \@@_prev_input_gpush:N \l_@@_head_tl
3801 \@@_print_action:
3802 #2
3803 \@@_prev_input_gpop:N \l_@@_head_tl
3804 }
3805 \int_compare:nNnTF {#3} < { 4 }
3806 { \@@_thing_use_get:nnNN {#1} {#3} \l_@@_head_tl \l_@@_tmpa_tl }
3807 { \tl_set:Ne \l_@@_tmpa_tl { \@@_the:w \l_@@_head_tl } }
3808 \@@_rescan_something_internal_auxii:Vn \l_@@_tmpa_tl {#1}
3809 \@@_break_point:
3810 \int_compare:nNnT {#3} < { 4 } { \@@_print_action: }
3811 }
3812 \cs_new_protected:Npn \@@_rescan_something_internal_auxii:nn #1#2
3813 {
3814 \@@_prev_input_silent:n {#1}
3815 \@@_set_action_text:
3816 \@@_set_action_text:e
3817 { \g_@@_action_text_str \use:n { ~ => ~ } \tl_to_str:n {#1} }
3818 \int_gset:Nn \g_@@_val_level_int {#2}
3819 }
3820 \cs_generate_variant:Nn \@@_rescan_something_internal_auxii:nn { V }
3821 % \end{macrocode}
3822 % \end{macro}
3823 % \end{macro}
3824 %
3825 % \begin{macro}[EXP]
3826 % {\@@_thing_case:, \@@_thing_last_item:, \@@_thing_register:}
3827 % This expands to a digit (the level generated by whatever token is
3828 % the current |head|), followed by some code to fetch necessary
3829 % operands. In most cases, this can be done by simply looking at the
3830 % |cmd| integer, but for |last_item|, |set_aux|, |set_shape| and
3831 % |register|, the level of the token, or what has to be scanned,
3832 % depends on the |char| integer. When the token is not allowed
3833 % after \tn{the} (or at any other position where
3834 % \cs{@@_rescan_something_internal:n} is called), the resulting level
3835 % is~$8$, large enough so that the main function knows it is
3836 % forbidden.
3837 % \begin{macrocode}
3838 \cs_new:Npn \@@_thing_case:
3839 {
3840 \int_case:nnF \l_@@_head_cmd_int
3841 {
3842 { 68 } { 0 } % char_given
3843 { 69 } { 0 } % math_given
3844 { 70 } { \@@_thing_last_item: } % last_item
3845 { 71 } { 5 \@@_scan_toks_register: } % toks_register
3846 { 72 } { 5 } % assign_toks
3847 { 73 } { 0 } % assign_int
3848 { 74 } { 1 } % assign_dimen
3849 { 75 } { 2 } % assign_glue
3850 { 76 } { 3 } % assign_mu_glue
3851 { 77 } { 1 \@@_scan_font_dimen: } % assign_font_dimen
3852 { 78 } { 0 \@@_scan_font_int: } % assign_font_int
3853 { 79 } { \@@_thing_set_aux: } % set_aux
3854 { 80 } { 0 } % set_prev_graf
3855 { 81 } { 1 } % set_page_dimen
3856 { 82 } { 0 } % set_page_int
3857 { 83 } { 1 \@@_scan_int: } % set_box_dimen
3858 { 84 } { \@@_thing_set_shape: } % set_shape
3859 { 85 } { 0 \@@_scan_int: } % def_code
3860 { 86 } { 4 \@@_scan_int: } % def_family
3861 { 87 } { 4 } % set_font
3862 { 88 } { 4 } % def_font
3863 { 89 } { \@@_thing_register: } % register
3864 {101 } { 4 } % letterspace_font
3865 {102 } { 4 } % pdf_copy_font
3866 }
3867 { 8 }
3868 }
3869 \cs_new:Npn \@@_thing_set_aux:
3870 { \int_compare:nNnTF \l_@@_head_char_int = { 1 } { 1 } { 0 } }
3871 \cs_new:Npn \@@_thing_set_shape:
3872 { \int_compare:nNnTF \l_@@_head_char_int = 0 { 0 } { 0 \@@_scan_int: } }
3873 \cs_new:Npn \@@_thing_last_item:
3874 {
3875 \int_compare:nNnTF \l_@@_head_char_int < { 26 }
3876 {
3877 \int_case:nnF \l_@@_head_char_int
3878 {
3879 { 1 } { 1 } % lastkern
3880 { 2 } { 2 } % lastskip
3881 }
3882 { 0 } % other integer parameters
3883 }
3884 {
3885 \int_case:nnF \l_@@_head_char_int
3886 {
3887 { 26 } { 0 \@@_scan_normal_glue: } % gluestretchorder
3888 { 27 } { 0 \@@_scan_normal_glue: } % glueshrinkorder
3889 { 28 } % fontcharwd
3890 { 1 \@@_scan_font_ident: \@@_scan_int: }
3891 { 29 } % fontcharht
3892 { 1 \@@_scan_font_ident: \@@_scan_int: }
3893 { 30 } % fontchardp
3894 { 1 \@@_scan_font_ident: \@@_scan_int: }
3895 { 31 } % fontcharic
3896 { 1 \@@_scan_font_ident: \@@_scan_int: }
3897 { 32 } { 1 \@@_scan_int: } % parshapelength
3898 { 33 } { 1 \@@_scan_int: } % parshapeindent
3899 { 34 } { 1 \@@_scan_int: } % parshapedimen
3900 { 35 } { 1 \@@_scan_normal_glue: } % gluestretch
3901 { 36 } { 1 \@@_scan_normal_glue: } % glueshrink
3902 { 37 } { 2 \@@_scan_mu_glue: } % mutoglue
3903 { 38 } { 3 \@@_scan_normal_glue: } % gluetomu
3904 { 39 } % numepr
3905 { 0 \@@_scan_expr:N \@@_scan_int: }
3906 { 40 } % dimexpr
3907 { 1 \@@_scan_expr:N \@@_scan_normal_dimen: }
3908 { 41 } % glueexpr
3909 { 2 \@@_scan_expr:N \@@_scan_normal_glue: }
3910 { 42 } % muexpr
3911 { 3 \@@_scan_expr:N \@@_scan_mu_glue: }
3912 }
3913 { }
3914 }
3915 }
3916 \cs_new:Npn \@@_thing_register:
3917 {
3918 \int_eval:n { \l_@@_head_char_int / 1 000 000 - 1 }
3919 \int_compare:nNnT { \tl_tail:V \l_@@_head_char_int } = 0
3920 { \@@_scan_int: }
3921 }
3922 % \end{macrocode}
3923 % \end{macro}
3924 %
3925 % \begin{macro}{\@@_scan_toks_register:}
3926 % A case where getting operands is not completely trivial.
3927 % \begin{macrocode}
3928 \cs_new_protected:Npn \@@_scan_toks_register:
3929 {
3930 \int_compare:nNnT \l_@@_head_char_int = 0
3931 { \@@_scan_int: }
3932 }
3933 % \end{macrocode}
3934 % \end{macro}
3935 %
3936 % \begin{macro}{\@@_thing_use_get:nnNN}
3937 % Given a level found~|#1| and a target level~|#2| (both in $[0,3]$),
3938 % turn the token list |#3| into the desired level or less, and store
3939 % the result in |#4|.
3940 % \begin{macrocode}
3941 \cs_new_protected:Npn \@@_thing_use_get:nnNN #1#2#3#4
3942 {
3943 \int_compare:nNnTF {#2} < { 3 }
3944 {
3945 \int_compare:nNnT {#1} = { 3 }
3946 { \@@_tex_error:nV { incompatible-units } #3 }
3947 \tl_set:Ne #4
3948 {
3949 \int_case:nn { \int_min:nn {#1} {#2} }
3950 {
3951 { 0 } \int_eval:n
3952 { 1 } \dim_eval:n
3953 { 2 } \skip_eval:n
3954 }
3955 { \int_compare:nNnT {#1} = { 3 } \tex_mutoglue:D #3 }
3956 }
3957 }
3958 {
3959 \int_case:nnF {#1}
3960 {
3961 { 0 } { \tl_set:Ne #4 { \int_eval:n {#3} } }
3962 { 3 } { \tl_set:Ne #4 { \muskip_eval:n {#3} } }
3963 }
3964 {
3965 \@@_tex_error:nV { incompatible-units } #3
3966 \tl_set:Ne #4 { \muskip_eval:n { \tex_gluetomu:D #3 } }
3967 }
3968 }
3969 }
3970 % \end{macrocode}
3971 % \end{macro}
3972 %
3973 % \begin{macro}{\@@_scan_expr:N}
3974 % \begin{macro}{\@@_scan_expr_aux:NN, \@@_scan_factor:N}
3975 % \begin{macrocode}
3976 \cs_new_protected:Npn \@@_scan_expr:N #1
3977 { \@@_scan_expr_aux:NN #1 \c_false_bool }
3978 \cs_new_protected:Npn \@@_scan_expr_aux:NN #1#2
3979 {
3980 \@@_get_x_non_blank:
3981 \@@_scan_factor:N #1
3982 \@@_scan_expr_op:NN #1#2
3983 }
3984 \cs_new_protected:Npn \@@_scan_expr_op:NN #1#2
3985 {
3986 \@@_get_x_non_blank:
3987 \token_case_meaning:NnF \l_@@_head_tl
3988 {
3989 \c_@@_plus_tl
3990 {
3991 \@@_prev_input:V \l_@@_head_tl
3992 \@@_scan_expr_aux:NN #1#2
3993 }
3994 \c_@@_minus_tl
3995 {
3996 \@@_prev_input:V \l_@@_head_tl
3997 \@@_scan_expr_aux:NN #1#2
3998 }
3999 \c_@@_times_tl
4000 {
4001 \@@_prev_input:V \l_@@_head_tl
4002 \@@_get_x_non_blank:
4003 \@@_scan_factor:N \@@_scan_int:
4004 \@@_scan_expr_op:NN #1#2
4005 }
4006 \c_@@_over_tl
4007 {
4008 \@@_prev_input:V \l_@@_head_tl
4009 \@@_get_x_non_blank:
4010 \@@_scan_factor:N \@@_scan_int:
4011 \@@_scan_expr_op:NN #1#2
4012 }
4013 \c_@@_rp_tl
4014 {
4015 \bool_if:NTF #2
4016 { \@@_prev_input:V \l_@@_head_tl }
4017 { \@@_back_input: }
4018 }
4019 }
4020 {
4021 \bool_if:NTF #2
4022 {
4023 \@@_error:nnnnn { missing-rparen } { } { } { } { }
4024 \@@_back_input:
4025 \@@_prev_input:V \c_@@_rp_tl
4026 }
4027 {
4028 \token_if_eq_meaning:NNF \l_@@_head_token \scan_stop:
4029 { \@@_back_input: }
4030 }
4031 }
4032 }
4033 \cs_new_protected:Npn \@@_scan_factor:N #1
4034 {
4035 \tl_if_eq:NNTF \l_@@_head_tl \c_@@_lp_tl
4036 {
4037 \@@_prev_input:V \l_@@_head_tl
4038 \@@_scan_expr_aux:NN #1 \c_true_bool
4039 }
4040 {
4041 \@@_back_input:
4042 #1
4043 }
4044 }
4045 % \end{macrocode}
4046 % \end{macro}
4047 % \end{macro}
4048 %
4049 % \begin{macro}{\@@_scan_signs:}
4050 % Skips blanks, scans signs, and places them to the right of the last
4051 % item of \cs{@@_prev_input:n}.
4052 % \begin{macrocode}
4053 \cs_new_protected:Npn \@@_scan_signs:
4054 {
4055 \@@_get_x_non_blank:
4056 \tl_if_eq:NNTF \l_@@_head_tl \c_@@_plus_tl
4057 {
4058 \@@_prev_input:V \l_@@_head_tl
4059 \@@_scan_signs:
4060 }
4061 {
4062 \tl_if_eq:NNT \l_@@_head_tl \c_@@_minus_tl
4063 {
4064 \@@_prev_input:V \l_@@_head_tl
4065 \@@_scan_signs:
4066 }
4067 }
4068 }
4069 % \end{macrocode}
4070 % \end{macro}
4071 %
4072 % \begin{macro}{\@@_scan_int:}
4073 % \begin{macro}
4074 % {\@@_scan_int_char:, \@@_scan_int_lq:, \@@_scan_int_explicit:n}
4075 % \begin{macrocode}
4076 \cs_new_protected:Npn \@@_scan_int:
4077 {
4078 \@@_scan_signs:
4079 \@@_set_cmd:
4080 \@@_cmd_if_internal:TF
4081 { \@@_rescan_something_internal:n { 0 } }
4082 { \@@_scan_int_char: }
4083 }
4084 \cs_new_protected:Npn \@@_scan_int_char:
4085 {
4086 \token_case_meaning:NnF \l_@@_head_tl
4087 {
4088 \c_@@_lq_tl { \@@_scan_int_lq: }
4089 \c_@@_rq_tl
4090 {
4091 \@@_prev_input:V \l_@@_head_tl
4092 \@@_get_x_next:
4093 \@@_scan_int_explicit:Nn \c_false_bool { ' }
4094 }
4095 \c_@@_dq_tl
4096 {
4097 \@@_prev_input:V \l_@@_head_tl
4098 \@@_get_x_next:
4099 \@@_scan_int_explicit:Nn \c_false_bool { " } % "
4100 }
4101 }
4102 { \@@_scan_int_explicit:Nn \c_false_bool { } }
4103 }
4104 \cs_new_protected:Npn \@@_scan_int_lq:
4105 {
4106 \@@_get_next:
4107 \@@_gtl_if_head_is_definable:NF \l_@@_head_gtl
4108 {
4109 \tl_set:Ne \l_@@_head_tl
4110 { \@@_token_to_char:N \l_@@_head_token }
4111 }
4112 \tl_set:Ne \l_@@_tmpa_tl
4113 { \int_eval:n { \exp_after:wN ` \l_@@_head_tl } }
4114 \@@_prev_input_silent:V \l_@@_tmpa_tl
4115 \@@_print_action:e
4116 { ` \gtl_to_str:N \l_@@_head_gtl = \l_@@_tmpa_tl }
4117 \@@_skip_optional_space:
4118 }
4119 \cs_new_protected:Npn \@@_scan_int_explicit:Nn #1#2
4120 {
4121 \if_int_compare:w 1
4122 < #2 1 \exp_after:wN \exp_not:N \l_@@_head_tl \exp_stop_f:
4123 \exp_after:wN \use_i:nn
4124 \else:
4125 \exp_after:wN \use_ii:nn
4126 \fi:
4127 {
4128 \@@_prev_input:V \l_@@_head_tl
4129 \@@_get_x_next:
4130 \@@_scan_int_explicit:Nn \c_true_bool {#2}
4131 }
4132 {
4133 \token_if_eq_catcode:NNF \l_@@_head_token \c_space_token
4134 { \@@_back_input: }
4135 \bool_if:NF #1
4136 {
4137 \@@_tex_error:nV { missing-number } \l_@@_head_tl
4138 \@@_prev_input:n { 0 }
4139 }
4140 }
4141 }
4142 % \end{macrocode}
4143 % \end{macro}
4144 % \end{macro}
4145 %
4146 % \begin{macro}{\@@_scan_normal_dimen:}
4147 % \begin{macrocode}
4148 \cs_new_protected:Npn \@@_scan_normal_dimen:
4149 { \@@_scan_dimen:nN { 2 } \c_false_bool }
4150 % \end{macrocode}
4151 % \end{macro}
4152 %
4153 % \begin{macro}{\@@_scan_dimen:nN}
4154 % The first argument is $2$ if the unit may not be |mu| and $3$ if
4155 % the unit must be |mu| (or |fil|). The second argument is
4156 % \cs{c_true_bool} if |fil|, |fill|, |filll| are permitted, and is
4157 % otherwise |false|. These arguments are similar to those of
4158 % \TeX{}'s own |scan_dimen| procedure, in which |mu| is |bool(#1=3)|
4159 % and |inf| is |#2|. The third argument of this procedure is omitted
4160 % here, as the corresponding shortcut is provided as a separate
4161 % function, \cs{@@_scan_dim_unit:nN}.
4162 %
4163 % Ideally, \cs{@@_scan_inf_unit_loop:} would produce an \pkg{unravel}
4164 % error when reaching the third ``L'', rather than letting TeX produce
4165 % the error later on.
4166 % \begin{macrocode}
4167 \cs_new_protected:Npn \@@_scan_dimen:nN #1#2
4168 {
4169 \@@_scan_signs:
4170 \@@_prev_input_gpush:
4171 \@@_set_cmd:
4172 \@@_cmd_if_internal:TF
4173 {
4174 \int_compare:nNnTF {#1} = { 3 }
4175 { \@@_rescan_something_internal:n { 3 } }
4176 { \@@_rescan_something_internal:n { 1 } }
4177 \int_compare:nNnT \g_@@_val_level_int = { 0 }
4178 { \@@_scan_dim_unit:nN {#1} #2 }
4179 }
4180 { \@@_scan_dimen_char:nN {#1} #2 }
4181 \@@_prev_input_gpop:N \l_@@_head_tl
4182 \@@_prev_input_silent:V \l_@@_head_tl
4183 }
4184 \cs_new_protected:Npn \@@_scan_dimen_char:nN #1#2
4185 {
4186 \tl_if_eq:NNT \l_@@_head_tl \c_@@_comma_tl
4187 { \tl_set_eq:NN \l_@@_head_tl \c_@@_point_tl }
4188 \tl_if_eq:NNTF \l_@@_head_tl \c_@@_point_tl
4189 {
4190 \@@_prev_input:n { . }
4191 \@@_scan_decimal_loop:
4192 }
4193 {
4194 \@@_tl_if_in:ooTF { 0123456789 } \l_@@_head_tl
4195 {
4196 \@@_back_input:
4197 \@@_scan_int:
4198 \tl_if_eq:NNT \l_@@_head_tl \c_@@_comma_tl
4199 { \tl_set_eq:NN \l_@@_head_tl \c_@@_point_tl }
4200 \tl_if_eq:NNT \l_@@_head_tl \c_@@_point_tl
4201 {
4202 \@@_input_gpop:N \l_@@_tmpb_gtl
4203 \@@_prev_input:n { . }
4204 \@@_scan_decimal_loop:
4205 }
4206 }
4207 {
4208 \@@_back_input:
4209 \@@_scan_int:
4210 }
4211 }
4212 \@@_scan_dim_unit:nN {#1} #2
4213 }
4214 \cs_new_protected:Npn \@@_scan_dim_unit:nN #1#2
4215 {
4216 \bool_if:NT #2
4217 {
4218 \@@_scan_keyword:nT { fFiIlL }
4219 {
4220 \@@_scan_inf_unit_loop:
4221 \@@_break:w
4222 }
4223 }
4224 \@@_get_x_non_blank:
4225 \@@_set_cmd:
4226 \@@_cmd_if_internal:TF
4227 {
4228 \@@_prev_input_gpush:
4229 \@@_rescan_something_internal:n {#1}
4230 \int_compare:nNnTF \g_@@_val_level_int = { 0 }
4231 { \@@_prev_input_join_get:nnN {#1} { sp } \l_@@_tmpa_tl }
4232 { \@@_prev_input_join_get:nnN {#1} { } \l_@@_tmpa_tl }
4233 \@@_prev_input_gpush:N \l_@@_tmpa_tl
4234 \exp_after:wN \use_none:n \@@_break:w
4235 }
4236 { }
4237 \@@_back_input:
4238 \int_compare:nNnT {#1} = { 3 }
4239 {
4240 \@@_scan_keyword:nT { mMuU } { \@@_break:w }
4241 \@@_tex_error:nV { missing-mu } \l_@@_head_tl
4242 \@@_prev_input:n { mu }
4243 \@@_break:w
4244 }
4245 \@@_scan_keyword:nT { eEmM } { \@@_break:w }
4246 \@@_scan_keyword:nT { eExX } { \@@_break:w }
4247 \@@_scan_keyword:nT { pPxX } { \@@_break:w }
4248 \@@_scan_keyword:nT { tTrRuUeE }
4249 { \@@_prepare_mag: }
4250 \@@_scan_keyword:nT { pPtT } { \@@_break:w }
4251 \@@_scan_keyword:nT { iInN } { \@@_break:w }
4252 \@@_scan_keyword:nT { pPcC } { \@@_break:w }
4253 \@@_scan_keyword:nT { cCmM } { \@@_break:w }
4254 \@@_scan_keyword:nT { mMmM } { \@@_break:w }
4255 \@@_scan_keyword:nT { bBpP } { \@@_break:w }
4256 \@@_scan_keyword:nT { dDdD } { \@@_break:w }
4257 \@@_scan_keyword:nT { cCcC } { \@@_break:w }
4258 \@@_scan_keyword:nT { nNdD } { \@@_break:w }
4259 \@@_scan_keyword:nT { nNcC } { \@@_break:w }
4260 \@@_scan_keyword:nT { sSpP } { \@@_break:w }
4261 \@@_tex_error:nV { missing-pt } \l_@@_head_tl
4262 \@@_prev_input:n { pt }
4263 \@@_break_point:
4264 \@@_skip_optional_space:
4265 }
4266 \cs_new_protected:Npn \@@_scan_inf_unit_loop:
4267 { \@@_scan_keyword:nT { lL } { \@@_scan_inf_unit_loop: } }
4268 \cs_new_protected:Npn \@@_scan_decimal_loop:
4269 {
4270 \@@_get_x_next:
4271 \tl_if_empty:NTF \l_@@_head_tl
4272 { \use_ii:nn }
4273 { \@@_tl_if_in:ooTF { 0123456789 } \l_@@_head_tl }
4274 {
4275 \@@_prev_input:V \l_@@_head_tl
4276 \@@_scan_decimal_loop:
4277 }
4278 {
4279 \token_if_eq_catcode:NNF \l_@@_head_token \c_space_token
4280 { \@@_back_input: }
4281 \@@_prev_input_silent:n { ~ }
4282 }
4283 }
4284 % \end{macrocode}
4285 % \end{macro}
4286 %
4287 % \begin{macro}{\@@_scan_normal_glue:, \@@_scan_mu_glue:}
4288 % \begin{macrocode}
4289 \cs_new_protected:Npn \@@_scan_normal_glue:
4290 { \@@_scan_glue:n { 2 } }
4291 \cs_new_protected:Npn \@@_scan_mu_glue:
4292 { \@@_scan_glue:n { 3 } }
4293 % \end{macrocode}
4294 % \end{macro}
4295 %
4296 % \begin{macro}{\@@_scan_glue:n}
4297 % \begin{macrocode}
4298 \cs_new_protected:Npn \@@_scan_glue:n #1
4299 {
4300 \@@_prev_input_gpush:
4301 \@@_scan_signs:
4302 \@@_prev_input_gpush:
4303 \@@_set_cmd:
4304 \@@_cmd_if_internal:TF
4305 {
4306 \@@_rescan_something_internal:n {#1}
4307 \int_case:nnF \g_@@_val_level_int
4308 {
4309 { 0 } { \@@_scan_dim_unit:nN {#1} \c_false_bool }
4310 { 1 } { }
4311 }
4312 { \@@_break:w }
4313 }
4314 { \@@_back_input: \@@_scan_dimen:nN {#1} \c_false_bool }
4315 \@@_prev_input_join_get:nnN {#1} { } \l_@@_tmpa_tl
4316 \@@_prev_input_gpush:
4317 \@@_prev_input_gpush:N \l_@@_tmpa_tl
4318 \@@_scan_keyword:nT { pPlLuUsS }
4319 { \@@_scan_dimen:nN {#1} \c_true_bool }
4320 \@@_scan_keyword:nT { mMiInNuUsS }
4321 { \@@_scan_dimen:nN {#1} \c_true_bool }
4322 \@@_break_point:
4323 \@@_prev_input_join_get:nnN {#1} { } \l_@@_tmpa_tl
4324 \@@_prev_input_silent:V \l_@@_tmpa_tl
4325 }
4326 % \end{macrocode}
4327 % \end{macro}
4328 %
4329 % \begin{macro}{\@@_scan_file_name:}
4330 % \begin{macrocode}
4331 \cs_new_protected:Npn \@@_scan_file_name:
4332 {
4333 \@@_get_x_non_relax:
4334 \token_if_eq_catcode:NNTF \l_@@_head_token \c_group_begin_token
4335 { \@@_scan_group_x:N \c_false_bool }
4336 {
4337 \@@_back_input:
4338 \bool_gset_true:N \g_@@_name_in_progress_bool
4339 \bool_gset_false:N \g_@@_quotes_bool
4340 \@@_get_x_non_blank:
4341 \@@_scan_file_name_loop:
4342 \bool_gset_false:N \g_@@_name_in_progress_bool
4343 \@@_prev_input_silent:n { ~ }
4344 }
4345 }
4346 \cs_new_protected:Npn \@@_scan_file_name_loop:
4347 {
4348 \@@_gtl_if_head_is_definable:NTF \l_@@_head_gtl
4349 { \@@_back_input: }
4350 {
4351 \tl_set:Ne \l_@@_tmpa_tl
4352 { \@@_token_to_char:N \l_@@_head_token }
4353 \tl_if_eq:NNT \l_@@_tmpa_tl \c_@@_dq_tl
4354 {
4355 \bool_if:NTF \g_@@_quotes_bool
4356 { \bool_set_false:N } { \bool_set_true:N } \g_@@_quotes_bool
4357 }
4358 \bool_if:NTF \g_@@_quotes_bool
4359 { \use:n } { \tl_if_eq:NNF \l_@@_tmpa_tl \c_space_tl }
4360 {
4361 \@@_prev_input_silent:V \l_@@_tmpa_tl
4362 \@@_get_x_next:
4363 \@@_scan_file_name_loop:
4364 }
4365 }
4366 }
4367 \bool_new:N \g_@@_quotes_bool
4368 % \end{macrocode}
4369 % \end{macro}
4370 %
4371 % \begin{macro}{\@@_scan_r_token:}
4372 % This is analogous to \TeX{}'s |get_r_token|. We store in
4373 % \cs{l_@@_defined_tl} the token which we found, as this is what will
4374 % be defined by the next assignment.
4375 % \begin{macrocode}
4376 \cs_new_protected:Npn \@@_scan_r_token:
4377 {
4378 \bool_do_while:nn
4379 { \tl_if_eq_p:NN \l_@@_head_tl \c_space_tl }
4380 { \@@_get_next: }
4381 \@@_gtl_if_head_is_definable:NF \l_@@_head_gtl
4382 {
4383 \@@_error:nnnnn { missing-cs } { } { } { } { }
4384 \@@_back_input:
4385 \tl_set:Nn \l_@@_head_tl { \@@_inaccessible:w }
4386 }
4387 \@@_prev_input_silent:V \l_@@_head_tl
4388 \tl_set_eq:NN \l_@@_defined_tl \l_@@_head_tl
4389 }
4390 % \end{macrocode}
4391 % \end{macro}
4392 %
4393 % \begin{macro}{\@@_scan_toks_to_str:}
4394 % \begin{macrocode}
4395 \cs_new_protected:Npn \@@_scan_toks_to_str:
4396 {
4397 \@@_prev_input_gpush:
4398 \@@_scan_toks:NN \c_false_bool \c_true_bool
4399 \@@_prev_input_gpop:N \l_@@_tmpa_tl
4400 \@@_prev_input_silent:e
4401 { { \exp_after:wN \tl_to_str:n \l_@@_tmpa_tl } }
4402 }
4403 % \end{macrocode}
4404 % \end{macro}
4405 %
4406 % \begin{macro}{\@@_scan_pdf_ext_toks:}
4407 % \begin{macrocode}
4408 \cs_new_protected:Npn \@@_scan_pdf_ext_toks:
4409 {
4410 \@@_prev_input_gpush:
4411 \@@_scan_toks:NN \c_false_bool \c_true_bool
4412 \@@_prev_input_gpop:N \l_@@_tmpa_tl
4413 \@@_prev_input_silent:e
4414 { { \exp_not:N \exp_not:n \exp_not:V \l_@@_tmpa_tl } }
4415 }
4416 % \end{macrocode}
4417 % \end{macro}
4418 %
4419 % \begin{macro}{\@@_scan_toks:NN}
4420 % The boolean |#1| is true if we are making a definition (then we
4421 % start by scanning the parameter text), false if we are simply
4422 % scanning a general text. The boolean |#2| is true if we need to
4423 % expand, false otherwise (for instance for \tn{lowercase}).
4424 % \begin{macrocode}
4425 \cs_new_protected:Npn \@@_scan_toks:NN #1#2
4426 {
4427 \bool_if:NT #1 { \@@_scan_param: }
4428 \@@_scan_left_brace:
4429 \bool_if:NTF #2
4430 { \@@_scan_group_x:N #1 }
4431 { \@@_scan_group_n:N #1 }
4432 }
4433 % \end{macrocode}
4434 % \end{macro}
4435 %
4436 % \begin{macro}{\@@_scan_param:}
4437 % \begin{macro}{\@@_scan_param_aux:}
4438 % Collect the parameter text into \cs{l_@@_tmpa_tl}, and when seeing
4439 % either a begin-group or an end-group character, put it back into the
4440 % input, stop looping, and put what we collected into
4441 % \cs{l_@@_defining_tl} and into the |prev_input|.
4442 % \begin{macrocode}
4443 \cs_new_protected:Npn \@@_scan_param:
4444 {
4445 \tl_clear:N \l_@@_tmpa_tl
4446 \@@_scan_param_aux:
4447 \tl_put_right:NV \l_@@_defining_tl \l_@@_tmpa_tl
4448 \@@_prev_input_silent:V \l_@@_tmpa_tl
4449 }
4450 \cs_new_protected:Npn \@@_scan_param_aux:
4451 {
4452 \@@_get_next:
4453 \tl_concat:NNN \l_@@_tmpa_tl
4454 \l_@@_tmpa_tl \l_@@_head_tl
4455 \tl_if_empty:NTF \l_@@_head_tl
4456 { \@@_back_input: } { \@@_scan_param_aux: }
4457 }
4458 % \end{macrocode}
4459 % \end{macro}
4460 % \end{macro}
4461 %
4462 % \begin{macro}{\@@_scan_group_n:N}
4463 % The boolean |#1| is true if we are making a definition, false
4464 % otherwise. In both cases put the open brace back and grab the first
4465 % item. The only difference is that when making a definition we store
4466 % the data into \cs{l_@@_defining_tl} as well.
4467 % \begin{macrocode}
4468 \cs_new_protected:Npn \@@_scan_group_n:N #1
4469 {
4470 \gtl_set_eq:NN \l_@@_head_gtl \c_group_begin_gtl
4471 \@@_back_input:
4472 \@@_input_gpop_item:NF \l_@@_head_tl
4473 {
4474 \@@_error:nnnnn { runaway-text } { } { } { } { }
4475 \@@_exit_hard:w
4476 }
4477 \tl_set:Ne \l_@@_head_tl { { \exp_not:V \l_@@_head_tl } }
4478 \bool_if:NT #1
4479 { \tl_put_right:NV \l_@@_defining_tl \l_@@_head_tl }
4480 \@@_prev_input_silent:V \l_@@_head_tl
4481 }
4482 % \end{macrocode}
4483 % \end{macro}
4484 %
4485 % \begin{macro}{\@@_scan_group_x:N}
4486 % The boolean |#1| is true if we are making a definition, false
4487 % otherwise.
4488 % \begin{macrocode}
4489 \cs_new_protected:Npn \@@_scan_group_x:N #1
4490 {
4491 \@@_input_gpop_tl:N \l_@@_head_tl
4492 \@@_back_input:V \l_@@_head_tl
4493 \bool_if:NTF #1
4494 {
4495 \@@_prev_input_silent:V \c_left_brace_str
4496 \tl_put_right:Nn \l_@@_defining_tl { { \if_false: } \fi: }
4497 \@@_scan_group_xdef:n { 1 }
4498 }
4499 {
4500 \@@_prev_input_gpush_gtl:
4501 \@@_prev_input_gtl:N \l_@@_head_gtl
4502 \@@_scan_group_x:n { 1 }
4503 \@@_prev_input_gpop_gtl:N \l_@@_tmpb_gtl
4504 \@@_prev_input_silent:e
4505 { \gtl_left_tl:N \l_@@_tmpb_gtl }
4506 }
4507 }
4508 % \end{macrocode}
4509 % \end{macro}
4510 %
4511 % \begin{macro}{\@@_scan_group_xdef:n}
4512 % This is to scan the replacement text of an \tn{edef} or \tn{xdef}.
4513 % The integer |#1| counts the brace balance.
4514 % \begin{macrocode}
4515 \cs_new_protected:Npn \@@_scan_group_xdef:n #1
4516 {
4517 \@@_get_token_xdef:
4518 \tl_if_empty:NTF \l_@@_head_tl
4519 {
4520 \gtl_if_head_is_group_begin:NTF \l_@@_head_gtl
4521 {
4522 \@@_prev_input_silent:V \c_left_brace_str
4523 \tl_put_right:Nn \l_@@_defining_tl { { \if_false: } \fi: }
4524 \@@_scan_group_xdef:f { \int_eval:n { #1 + 1 } }
4525 }
4526 {
4527 \@@_prev_input_silent:V \c_right_brace_str
4528 \tl_put_right:Nn \l_@@_defining_tl { \if_false: { \fi: } }
4529 \int_compare:nNnF {#1} = 1
4530 { \@@_scan_group_xdef:f { \int_eval:n { #1 - 1 } } }
4531 }
4532 }
4533 {
4534 \@@_prev_input_silent:V \l_@@_head_tl
4535 \tl_put_right:Ne \l_@@_defining_tl
4536 { \exp_not:N \exp_not:N \exp_not:V \l_@@_head_tl }
4537 \@@_scan_group_xdef:n {#1}
4538 }
4539 }
4540 \cs_generate_variant:Nn \@@_scan_group_xdef:n { f }
4541 % \end{macrocode}
4542 % \end{macro}
4543 %
4544 % \begin{macro}{\@@_scan_group_x:n}
4545 % \begin{macrocode}
4546 \cs_new_protected:Npn \@@_scan_group_x:n #1
4547 {
4548 \@@_get_token_x:
4549 \@@_prev_input_gtl:N \l_@@_head_gtl
4550 \tl_if_empty:NTF \l_@@_head_tl
4551 {
4552 \gtl_if_head_is_group_begin:NTF \l_@@_head_gtl
4553 { \@@_scan_group_x:f { \int_eval:n { #1 + 1 } } }
4554 {
4555 \int_compare:nNnF {#1} = 1
4556 { \@@_scan_group_x:f { \int_eval:n { #1 - 1 } } }
4557 }
4558 }
4559 { \@@_scan_group_x:n {#1} }
4560 }
4561 \cs_generate_variant:Nn \@@_scan_group_x:n { f }
4562 % \end{macrocode}
4563 % \end{macro}
4564 %
4565 % \begin{macro}{\@@_scan_alt_rule:}
4566 % \begin{macrocode}
4567 \cs_new_protected:Npn \@@_scan_alt_rule:
4568 {
4569 \@@_scan_keyword:nTF { wWiIdDtThH }
4570 {
4571 \@@_scan_normal_dimen:
4572 \@@_scan_alt_rule:
4573 }
4574 {
4575 \@@_scan_keyword:nTF { hHeEiIgGhHtT }
4576 {
4577 \@@_scan_normal_dimen:
4578 \@@_scan_alt_rule:
4579 }
4580 {
4581 \@@_scan_keyword:nT { dDeEpPtThH }
4582 {
4583 \@@_scan_normal_dimen:
4584 \@@_scan_alt_rule:
4585 }
4586 }
4587 }
4588 }
4589 % \end{macrocode}
4590 % \end{macro}
4591 %
4592 % \begin{macro}{\@@_scan_spec:}
4593 % Some \TeX{} primitives accept the keywords |to| and |spread|,
4594 % followed by a dimension.
4595 % \begin{macrocode}
4596 \cs_new_protected:Npn \@@_scan_spec:
4597 {
4598 \@@_scan_keyword:nTF { tToO } { \@@_scan_normal_dimen: }
4599 {
4600 \@@_scan_keyword:nT { sSpPrReEaAdD }
4601 { \@@_scan_normal_dimen: }
4602 }
4603 \@@_scan_left_brace:
4604 }
4605 % \end{macrocode}
4606 % \end{macro}
4607 %
4608 % \subsection{Working with boxes}
4609 %
4610 % \begin{macro}{\@@_do_box:N}
4611 % When this procedure is called, the last item in
4612 % the previous-input sequence is
4613 % \begin{itemize}
4614 % \item empty if the box is meant to be put in the input stream,
4615 % \item \tn{setbox}\meta{int} if it is meant to be stored somewhere,
4616 % \item \tn{moveright}\meta{dim}, \tn{moveleft}\meta{dim},
4617 % \tn{lower}\meta{dim}, \tn{raise}\meta{dim} if it is meant to be
4618 % shifted,
4619 % \item \tn{leaders} or \tn{cleaders} or \tn{xleaders}, in which case
4620 % the argument is \cs{c_true_bool} (otherwise \cs{c_false_bool}).
4621 % \end{itemize}
4622 % If a |make_box| command follows, we fetch the operands. If leaders
4623 % are followed by a rule, then this is also ok. In all other cases,
4624 % call \cs{@@_do_box_error:} to clean up.
4625 % \begin{macrocode}
4626 \cs_new_protected:Npn \@@_do_box:N #1
4627 {
4628 \@@_get_x_non_relax:
4629 \@@_set_cmd:
4630 \int_compare:nNnTF
4631 \l_@@_head_cmd_int = { \@@_tex_use:n { make_box } }
4632 { \@@_do_begin_box:N #1 }
4633 {
4634 \bool_if:NTF #1
4635 {
4636 \int_case:nnTF \l_@@_head_cmd_int
4637 {
4638 { \@@_tex_use:n { hrule } } { }
4639 { \@@_tex_use:n { vrule } } { }
4640 }
4641 { \@@_do_leaders_rule: }
4642 { \@@_do_box_error: }
4643 }
4644 { \@@_do_box_error: }
4645 }
4646 }
4647 % \end{macrocode}
4648 % \end{macro}
4649 %
4650 % \begin{macro}{\@@_do_box_error:}
4651 % Put the (non-|make_box|) command back into the input and complain.
4652 % Then recover by throwing away the action (last item of
4653 % the previous-input sequence). For some reason (this appears to be what
4654 % \TeX{} does), there is no need to remove the after assignment token
4655 % here.
4656 % \begin{macrocode}
4657 \cs_new_protected:Npn \@@_do_box_error:
4658 {
4659 \@@_back_input:
4660 \@@_error:nnnnn { missing-box } { } { } { } { }
4661 \@@_prev_input_gpop:N \l_@@_head_tl
4662 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
4663 }
4664 % \end{macrocode}
4665 % \end{macro}
4666 %
4667 % \begin{macro}{\@@_do_begin_box:N}
4668 % We have just found a |make_box| command and placed it into the last
4669 % item of the previous-input sequence. If it is ``simple''
4670 % (\tn{box}\meta{int}, \tn{copy}\meta{int}, \tn{lastbox},
4671 % \tn{vsplit}\meta{int} \texttt{to} \meta{dim}) then we grab its
4672 % operands, then call \cs{@@_do_simple_box:N} to finish up. If it is
4673 % \tn{vtop} or \tn{vbox} or \tn{hbox}, we need to work harder.
4674 % \begin{macrocode}
4675 \cs_new_protected:Npn \@@_do_begin_box:N #1
4676 {
4677 \@@_prev_input:V \l_@@_head_tl
4678 \int_case:nnTF \l_@@_head_char_int
4679 {
4680 { 0 } { \@@_scan_int: } % box
4681 { 1 } { \@@_scan_int: } % copy
4682 { 2 } { } % lastbox
4683 { 3 } % vsplit
4684 {
4685 \@@_scan_int:
4686 \@@_scan_to:
4687 \@@_scan_normal_dimen:
4688 }
4689 }
4690 { \@@_do_simple_box:N #1 }
4691 { \@@_do_box_explicit:N #1 }
4692 }
4693 % \end{macrocode}
4694 % \end{macro}
4695 %
4696 % \begin{macro}{\@@_do_simple_box:N}
4697 % For leaders, we need to fetch a glue. In all cases, retrieve the
4698 % box construction (such as |\raise3pt\vsplit7to5em|). Finally, let
4699 % \TeX{} run the code and print what we have done.
4700 % In the case of \tn{shipout}, check that \tn{mag} has a value
4701 % between $1$ and $32768$.
4702 % \begin{macrocode}
4703 \cs_new_protected:Npn \@@_do_simple_box:N #1
4704 {
4705 \bool_if:NTF #1 { \@@_do_leaders_fetch_skip: }
4706 {
4707 \@@_prev_input_gpop:N \l_@@_head_tl
4708 \tl_if_head_eq_meaning:VNT \l_@@_head_tl \tex_shipout:D
4709 { \@@_prepare_mag: }
4710 \tl_use:N \l_@@_head_tl \scan_stop:
4711 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
4712 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
4713 }
4714 }
4715 % \end{macrocode}
4716 % \end{macro}
4717 %
4718 % \begin{macro}{\@@_do_leaders_fetch_skip:}
4719 % \begin{macrocode}
4720 \cs_new_protected:Npn \@@_do_leaders_fetch_skip:
4721 {
4722 \@@_get_x_non_relax:
4723 \@@_set_cmd:
4724 \int_compare:nNnTF \l_@@_head_cmd_int
4725 = { \@@_tex_use:n { \mode_if_vertical:TF { vskip } { hskip } } }
4726 {
4727 \@@_prev_input_gpop:N \l_@@_tmpa_tl
4728 \tl_put_left:NV \l_@@_head_tl \l_@@_tmpa_tl
4729 \@@_do_append_glue:
4730 }
4731 {
4732 \@@_back_input:
4733 \@@_error:nnnnn { improper-leaders } { } { } { } { }
4734 \@@_prev_input_gpop:N \l_@@_head_tl
4735 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
4736 }
4737 }
4738 % \end{macrocode}
4739 % \end{macro}
4740 %
4741 % ^^A todo: less intrusive hooking into \everyhbox/\everyvbox?
4742 % \begin{macro}{\@@_do_box_explicit:N}
4743 % At this point, the last item in the previous-input sequence is
4744 % typically |\setbox0\hbox| or |\raise 3pt\hbox|. Scan for keywords
4745 % |to| and |spread| and a left brace. Install a hook in
4746 % \tn{everyhbox} or \tn{everyvbox} (whichever \TeX{} is going to
4747 % insert in the box). We then retrieve all the material that led to
4748 % the current box into \cs{l_@@_head_tl} in order to print it, then
4749 % let \TeX{} perform the box operation (here we need to provide the
4750 % begin-group token, as it was scanned but not placed in
4751 % the previous-input sequence). \TeX{} inserts \tn{everyhbox} or
4752 % \tn{everyvbox} just after the begin-group token, and the hook we did
4753 % is such that all that material is collected and put into the input
4754 % that we will study.
4755 % We must remember to find a glue for leaders, and for this
4756 % we use a stack of letters |v|, |h| for vertical/horizontal
4757 % leaders, and |Z| for normal boxes.
4758 % \begin{macrocode}
4759 \cs_new_protected:Npn \@@_do_box_explicit:N #1
4760 {
4761 \token_if_eq_meaning:NNTF \l_@@_head_token \@@_hbox:w
4762 { \@@_box_hook:N \tex_everyhbox:D }
4763 { \@@_box_hook:N \tex_everyvbox:D }
4764 \@@_scan_spec:
4765 \@@_prev_input_gpop:N \l_@@_head_tl
4766 \@@_set_action_text:e
4767 { \tl_to_str:N \l_@@_head_tl \iow_char:N \{ }
4768 \seq_push:Nf \l_@@_leaders_box_seq
4769 { \bool_if:NTF #1 { \mode_if_vertical:TF { v } { h } } { Z } }
4770 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
4771 \gtl_gconcat:NNN \g_@@_output_gtl
4772 \g_@@_output_gtl \c_group_begin_gtl
4773 \tl_use:N \l_@@_head_tl
4774 \c_group_begin_token \@@_box_hook_end:
4775 }
4776 % \end{macrocode}
4777 % \end{macro}
4778 %
4779 % \begin{macro}{\@@_box_hook:N}
4780 % \begin{macro}{\@@_box_hook:w, \@@_box_hook_end:}
4781 % Used to capture the contents of an \tn{everyhbox} or similar,
4782 % without altering \tn{everyhbox} too much (just add one token at the
4783 % start). The various \texttt{o}-expansions remove
4784 % \cs{prg_do_nothing:}, used to avoid losing braces.
4785 % \begin{macrocode}
4786 \cs_new_protected:Npn \@@_box_hook:N #1
4787 {
4788 \tl_set:NV \l_@@_tmpa_tl #1
4789 \str_if_eq:eeF
4790 { \tl_head:N \l_@@_tmpa_tl } { \exp_not:N \@@_box_hook:w }
4791 {
4792 \exp_args:Ne #1
4793 {
4794 \exp_not:n { \@@_box_hook:w \prg_do_nothing: }
4795 \exp_not:V #1
4796 }
4797 }
4798 \cs_gset_protected:Npn \@@_box_hook:w ##1 \@@_box_hook_end:
4799 {
4800 \exp_args:No #1 {##1}
4801 \cs_gset_eq:NN \@@_box_hook:w \prg_do_nothing:
4802 \gtl_clear:N \l_@@_after_group_gtl
4803 \@@_print_action:
4804 \@@_back_input:o {##1}
4805 \@@_set_action_text:e
4806 { \token_to_meaning:N #1 = \tl_to_str:o {##1} }
4807 \tl_if_empty:oF {##1} { \@@_print_action: }
4808 }
4809 }
4810 \cs_new_eq:NN \@@_box_hook:w \prg_do_nothing:
4811 \cs_new_eq:NN \@@_box_hook_end: \prg_do_nothing:
4812 % \end{macrocode}
4813 % \end{macro}
4814 % \end{macro}
4815 %
4816 % \begin{macro}{\@@_do_leaders_rule:}
4817 % After finding a |vrule| or |hrule| command and looking for |depth|,
4818 % |heigh| and |width| keywords, we are in the same situation as after
4819 % finding a box. Fetch the required skip accordingly.
4820 % \begin{macrocode}
4821 \cs_new_protected:Npn \@@_do_leaders_rule:
4822 {
4823 \@@_prev_input:V \l_@@_head_tl
4824 \@@_scan_alt_rule:
4825 \@@_do_leaders_fetch_skip:
4826 }
4827 % \end{macrocode}
4828 % \end{macro}
4829 %
4830 % \subsection{Paragraphs}
4831 %
4832 % \begin{macro}[TF]{\@@_charcode_if_safe:n}
4833 % \begin{macrocode}
4834 \prg_new_protected_conditional:Npnn \@@_charcode_if_safe:n #1 { TF }
4835 {
4836 \bool_if:nTF
4837 {
4838 \int_compare_p:n { #1 = `! }
4839 || \int_compare_p:n { `' <= #1 <= `[ }
4840 || \int_compare_p:n { #1 = `] }
4841 || \int_compare_p:n { ` ` <= #1 <= `z }
4842 }
4843 { \prg_return_true: }
4844 { \prg_return_false: }
4845 }
4846 % \end{macrocode}
4847 % \end{macro}
4848 %
4849 % \begin{macro}{\@@_char:n, \@@_char:V, \@@_char:e}
4850 % \begin{macrocode}
4851 \cs_new_protected:Npn \@@_char:n #1
4852 {
4853 \tex_char:D #1 \scan_stop:
4854 \@@_charcode_if_safe:nTF {#1}
4855 {
4856 \tl_set:Ne \l_@@_tmpa_tl { \char_generate:nn {#1} { 12 } }
4857 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_tmpa_tl
4858 \@@_print_action:e { \tl_to_str:N \l_@@_tmpa_tl }
4859 }
4860 {
4861 \tl_set:Ne \l_@@_tmpa_tl
4862 { \exp_not:N \char \int_eval:n {#1} ~ }
4863 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_tmpa_tl
4864 \@@_print_action:e
4865 { " \char_generate:nn {#1} { 12 } " = \tl_to_str:N \l_@@_tmpa_tl }
4866 }
4867 }
4868 \cs_generate_variant:Nn \@@_char:n { V , e }
4869 % \end{macrocode}
4870 % \end{macro}
4871 %
4872 % \begin{macro}
4873 % {\@@_char_in_mmode:n, \@@_char_in_mmode:V, \@@_char_in_mmode:e}
4874 % \begin{macrocode}
4875 \cs_new_protected:Npn \@@_char_in_mmode:n #1
4876 {
4877 \int_compare:nNnTF { \tex_mathcode:D #1 }
4878 = { \sys_if_engine_luatex:TF { "1000000 } { "8000 } }
4879 { % math active
4880 \@@_active_do:nn {#1} { \gtl_set:Nn \l_@@_head_gtl }
4881 \@@_back_input:
4882 \@@_print_action:e
4883 { \char_generate:nn {#1} { 12 } ~ active }
4884 }
4885 { \@@_char:n {#1} }
4886 }
4887 \cs_generate_variant:Nn \@@_char_in_mmode:n { V , e }
4888 % \end{macrocode}
4889 % \end{macro}
4890 %
4891 % \begin{macro}{\@@_mathchar:n, \@@_mathchar:e}
4892 % ^^A todo: \omathchar support
4893 % \begin{macrocode}
4894 \cs_new_protected:Npn \@@_mathchar:n #1
4895 {
4896 \tex_mathchar:D #1 \scan_stop:
4897 \tl_set:Ne \l_@@_tmpa_tl
4898 { \exp_not:N \mathchar " \int_to_hex:n {#1} ~ } % "
4899 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_tmpa_tl
4900 \@@_print_action:e { \tl_to_str:N \l_@@_tmpa_tl }
4901 }
4902 \cs_generate_variant:Nn \@@_mathchar:n { e }
4903 % \end{macrocode}
4904 % \end{macro}
4905 %
4906 % \begin{macro}{\@@_new_graf:N}
4907 % The argument is a boolean, indicating whether the paragraph should
4908 % be indented. We have much less work to do here than \TeX{} itself.
4909 % Our only task is to correctly position the \tn{everypar} tokens in
4910 % the input that we will read, rather than letting \TeX{} run the code
4911 % right away.
4912 % \begin{macrocode}
4913 \cs_new_protected:Npn \@@_new_graf:N #1
4914 {
4915 \tl_set:NV \l_@@_tmpa_tl \@@_everypar:w
4916 \@@_everypar:w { }
4917 \bool_if:NTF #1 { \tex_indent:D } { \tex_noindent:D }
4918 \exp_args:NV \@@_everypar:w \l_@@_tmpa_tl
4919 \@@_back_input:V \l_@@_tmpa_tl
4920 \@@_print_action:e
4921 {
4922 \g_@@_action_text_str \c_space_tl : ~
4923 \token_to_str:N \everypar = { \tl_to_str:N \l_@@_tmpa_tl }
4924 }
4925 }
4926 % \end{macrocode}
4927 % \end{macro}
4928 %
4929 % \begin{macro}{\@@_par_if_hmode:}
4930 % This is like the |end_graf| procedure in \TeX{}.
4931 % \begin{macrocode}
4932 \cs_new_protected:Npn \@@_par_if_hmode:
4933 { \mode_if_horizontal:T { \@@_par: } }
4934 % \end{macrocode}
4935 % \end{macro}
4936 %
4937 % ^^A todo: Do we need to do more?
4938 % \begin{macro}{\@@_par:}
4939 % \begin{macrocode}
4940 \cs_new_protected:Npn \@@_par:
4941 {
4942 \tex_par:D
4943 \gtl_gput_right:Nn \g_@@_output_gtl { \par }
4944 \@@_print_action:e { Paragraph~end. }
4945 }
4946 % \end{macrocode}
4947 % \end{macro}
4948 %
4949 % ^^A todo: do something to the \output routine?
4950 % \begin{macro}{\@@_build_page:}
4951 % \begin{macrocode}
4952 \cs_new_protected:Npn \@@_build_page:
4953 {
4954 }
4955 % \end{macrocode}
4956 % \end{macro}
4957 %
4958 % \subsection{Groups}
4959 %
4960 % \begin{variable}{\l_@@_choice_int}
4961 % Used by \tn{mathchoice} etc to keep
4962 % track of which argument we are currently in.
4963 % \begin{macrocode}
4964 \int_new:N \l_@@_choice_int
4965 % \end{macrocode}
4966 % \end{variable}
4967 %
4968 % \begin{macro}{\@@_handle_right_brace:}
4969 % When an end-group character is sensed, the result depends on the
4970 % current group type. Suppress the |after_group| tokens in
4971 % \tn{discretionary} or \tn{mathchoice}.
4972 % \begin{macrocode}
4973 \cs_new_protected:Npn \@@_handle_right_brace:
4974 {
4975 \int_compare:nTF { 1 <= \@@_currentgrouptype: <= 13 }
4976 {
4977 \gtl_gconcat:NNN \g_@@_output_gtl
4978 \g_@@_output_gtl \c_group_end_gtl
4979 \int_case:nnF \@@_currentgrouptype:
4980 {
4981 { 10 } { } % disc
4982 { 13 } { } % math_choice
4983 }
4984 { \@@_back_input_gtl:N \l_@@_after_group_gtl }
4985 \int_case:nn \@@_currentgrouptype:
4986 {
4987 { 1 } { \@@_end_simple_group: } % simple
4988 { 2 } { \@@_end_box_group: } % hbox
4989 { 3 } { \@@_end_box_group: } % adjusted_hbox
4990 { 4 } { \@@_par_if_hmode: \@@_end_box_group: } % vbox
4991 { 5 } { \@@_par_if_hmode: \@@_end_box_group: } % vtop
4992 { 6 } { \@@_end_align_group: } % align
4993 { 7 } { \@@_end_no_align_group: } % no_align
4994 { 8 } { \@@_end_output_group: } % output
4995 { 9 } { \@@_end_simple_group: } % math
4996 { 10 } { \@@_end_choice_group:NN 2 \discretionary } % disc
4997 { 11 } { \@@_par_if_hmode: \@@_end_simple_group: } % insert
4998 { 12 } { \@@_par_if_hmode: \@@_end_simple_group: } % vcenter
4999 { 13 } { \@@_end_choice_group:NN 3 \mathchoice } % math_choice
5000 }
5001 }
5002 { % bottom_level, semi_simple, math_shift, math_left
5003 \l_@@_head_token
5004 \@@_print_action:
5005 }
5006 }
5007 % \end{macrocode}
5008 % \end{macro}
5009 %
5010 % \begin{macro}{\@@_end_simple_group:}
5011 % This command is used to simply end a group, when there are no
5012 % specific operations to perform.
5013 % \begin{macrocode}
5014 \cs_new_protected:Npn \@@_end_simple_group:
5015 {
5016 \l_@@_head_token
5017 \@@_print_action:
5018 }
5019 % \end{macrocode}
5020 % \end{macro}
5021 %
5022 % \begin{macro}{\@@_end_box_group:}
5023 % The end of an explicit box (generated by \tn{vtop}, \tn{vbox}, or
5024 % \tn{hbox}) can either be simple, or can mean that we need to find a
5025 % skip for a \tn{leaders}/\tn{cleaders}/\tn{xleaders} construction.
5026 % \begin{macrocode}
5027 \cs_new_protected:Npn \@@_end_box_group:
5028 {
5029 \seq_pop:NN \l_@@_leaders_box_seq \l_@@_tmpa_tl
5030 \exp_args:No \@@_end_box_group_aux:n { \l_@@_tmpa_tl }
5031 }
5032 \cs_new_protected:Npn \@@_end_box_group_aux:n #1
5033 {
5034 \str_if_eq:eeTF {#1} { Z }
5035 { \@@_end_simple_group: }
5036 {
5037 \@@_get_x_non_relax:
5038 \@@_set_cmd:
5039 \int_compare:nNnTF \l_@@_head_cmd_int
5040 = { \@@_tex_use:n { #1 skip } }
5041 {
5042 \tl_put_left:Nn \l_@@_head_tl { \c_group_end_token }
5043 \@@_do_append_glue:
5044 }
5045 {
5046 \@@_back_input:
5047 \c_group_end_token \group_begin: \group_end:
5048 \@@_print_action:
5049 }
5050 }
5051 }
5052 % \end{macrocode}
5053 % \end{macro}
5054 %
5055 % \begin{macro}{\@@_end_align_group:}
5056 % \begin{macrocode}
5057 \cs_new_protected:Npn \@@_end_align_group:
5058 {
5059 \@@_not_implemented:n { end_align_group }
5060 \@@_end_simple_group:
5061 }
5062 % \end{macrocode}
5063 % \end{macro}
5064 %
5065 % \begin{macro}{\@@_end_no_align_group:}
5066 % ^^A todo: should start with \@@_par_if_hmode:
5067 % \begin{macrocode}
5068 \cs_new_protected:Npn \@@_end_no_align_group:
5069 {
5070 \@@_not_implemented:n { end_no_align_group }
5071 \@@_end_simple_group:
5072 }
5073 % \end{macrocode}
5074 % \end{macro}
5075 %
5076 % \begin{macro}{\@@_end_output_group:}
5077 % \begin{macrocode}
5078 \cs_new_protected:Npn \@@_end_output_group:
5079 {
5080 \@@_not_implemented:n { end_output_group }
5081 \@@_end_simple_group:
5082 }
5083 % \end{macrocode}
5084 % \end{macro}
5085 %
5086 % \begin{macro}{\@@_end_choice_group:NN, \@@_end_choice_group:nN}
5087 % \begin{macrocode}
5088 \cs_new_protected:Npn \@@_end_choice_group:NN #1#2
5089 {
5090 \int_compare:nNnTF \l_@@_choice_int > {#1}
5091 {
5092 \@@_back_input_gtl:N \l_@@_after_group_gtl
5093 \c_group_end_token
5094 \@@_print_action:e
5095 { \token_to_str:N #2 \prg_replicate:nn { #1 + 1 } { {...} } }
5096 }
5097 { \exp_args:NV \@@_end_choice_group:nN \l_@@_choice_int #2 }
5098 }
5099 \cs_new_protected:Npn \@@_end_choice_group:nN #1#2
5100 {
5101 \@@_scan_left_brace:
5102 \gtl_gconcat:NNN \g_@@_output_gtl
5103 \g_@@_output_gtl \c_group_begin_gtl
5104 \@@_back_input_gtl:N \l_@@_after_group_gtl
5105 \use:n \c_group_end_token
5106 \use:n \c_group_begin_token
5107 \int_set:Nn \l_@@_choice_int { #1 + 1 }
5108 \gtl_clear:N \l_@@_after_group_gtl
5109 \@@_print_action:e
5110 {
5111 \token_to_str:N #2
5112 \prg_replicate:nn {#1} { { ... } }
5113 \iow_char:N \{
5114 }
5115 }
5116 % \end{macrocode}
5117 % \end{macro}
5118 %
5119 % \begin{macro}{\@@_off_save:}
5120 % \begin{macrocode}
5121 \cs_new_protected:Npn \@@_off_save:
5122 {
5123 \int_compare:nNnTF \@@_currentgrouptype: = { 0 }
5124 { % bottom-level
5125 \@@_error:neeee { extra-close }
5126 { \token_to_meaning:N \l_@@_head_token } { } { } { }
5127 }
5128 {
5129 \@@_back_input:
5130 \int_case:nnF \@@_currentgrouptype:
5131 {
5132 { 14 } % semi_simple_group
5133 { \gtl_set:Nn \l_@@_head_gtl { \group_end: } }
5134 { 15 } % math_shift_group
5135 { \gtl_set:Nn \l_@@_head_gtl { $ } } % $
5136 { 16 } % math_left_group
5137 { \gtl_set:Nn \l_@@_head_gtl { \tex_right:D . } }
5138 }
5139 { \gtl_set_eq:NN \l_@@_head_gtl \c_group_end_gtl }
5140 \@@_back_input:
5141 \@@_error:neeee { off-save }
5142 { \gtl_to_str:N \l_@@_head_gtl } { } { } { }
5143 }
5144 }
5145 % \end{macrocode}
5146 % \end{macro}
5147 %
5148 % \subsection{Modes}
5149 % ^^A todo: implement \aftergroup and things happening at end-group
5150 %
5151 % \begin{macro}
5152 % {\@@_mode_math:n, \@@_mode_non_math:n, \@@_mode_vertical:n}
5153 % \begin{macrocode}
5154 \cs_new_protected:Npn \@@_mode_math:n #1
5155 { \mode_if_math:TF {#1} { \@@_insert_dollar_error: } }
5156 \cs_new_protected:Npn \@@_mode_non_math:n #1
5157 { \mode_if_math:TF { \@@_insert_dollar_error: } {#1} }
5158 \cs_new_protected:Npn \@@_mode_vertical:n #1
5159 {
5160 \mode_if_math:TF
5161 { \@@_insert_dollar_error: }
5162 { \mode_if_horizontal:TF { \@@_head_for_vmode: } {#1} }
5163 }
5164 \cs_new_protected:Npn \@@_mode_non_vertical:n #1
5165 {
5166 \mode_if_vertical:TF
5167 { \@@_back_input: \@@_new_graf:N \c_true_bool }
5168 {#1}
5169 }
5170 % \end{macrocode}
5171 % \end{macro}
5172 %
5173 % \begin{macro}{\@@_head_for_vmode:}
5174 % See \TeX{}'s |head_for_vmode|.
5175 % \begin{macrocode}
5176 \cs_new_protected:Npn \@@_head_for_vmode:
5177 {
5178 \mode_if_inner:TF
5179 {
5180 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_hrule:D
5181 {
5182 \@@_error:nnnnn { hrule-bad-mode } { } { } { } { }
5183 \@@_print_action:
5184 }
5185 { \@@_off_save: }
5186 }
5187 {
5188 \@@_back_input:
5189 \gtl_set:Nn \l_@@_head_gtl { \par }
5190 \@@_back_input:
5191 }
5192 }
5193 % \end{macrocode}
5194 % \end{macro}
5195 %
5196 % \begin{macro}{\@@_goto_inner_math:}
5197 % \begin{macrocode}
5198 \cs_new_protected:Npn \@@_goto_inner_math:
5199 {
5200 \@@_box_hook:N \tex_everymath:D
5201 $ % $
5202 \@@_box_hook_end:
5203 }
5204 % \end{macrocode}
5205 % \end{macro}
5206 %
5207 % \begin{macro}{\@@_goto_display_math:}
5208 % \begin{macrocode}
5209 \cs_new_protected:Npn \@@_goto_display_math:
5210 {
5211 \@@_box_hook:N \tex_everydisplay:D
5212 $ $
5213 \@@_box_hook_end:
5214 }
5215 % \end{macrocode}
5216 % \end{macro}
5217 %
5218 % \begin{macro}{\@@_after_math:}
5219 % In display math mode, or in a group started by \tn{eqno} or
5220 % \tn{leqno} (namely in inner math mode with non-zero
5221 % \cs{l_@@_choice_int}), search for another
5222 % |$|; otherwise simply close the inner math.
5223 % \begin{macrocode}
5224 \cs_new_protected:Npn \@@_after_math:
5225 {
5226 \mode_if_inner:TF
5227 { \int_compare:nNnTF \l_@@_choice_int > 0 }
5228 { \use_i:nn }
5229 {
5230 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5231 \@@_get_x_next:
5232 \token_if_eq_catcode:NNF
5233 \l_@@_head_token \c_math_toggle_token
5234 {
5235 \@@_back_input:
5236 \tl_set:Nn \l_@@_head_tl { $ } % $
5237 \@@_error:nnnnn { missing-dollar } { } { } { } { }
5238 }
5239 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5240 \@@_back_input_gtl:N \l_@@_after_group_gtl
5241 $ $
5242 }
5243 {
5244 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5245 \@@_back_input_gtl:N \l_@@_after_group_gtl
5246 $ % $
5247 }
5248 \@@_print_action:
5249 }
5250 % \end{macrocode}
5251 % \end{macro}
5252 %
5253 % \subsection{Commands}
5254 %
5255 % We will implement commands in order of their command codes (some of
5256 % the more elaborate commands call auxiliaries defined in other
5257 % sections). Some cases are forbidden.
5258 %
5259 % \begin{macro}{\@@_forbidden_case:}
5260 % \begin{macrocode}
5261 \cs_new_protected:Npn \@@_forbidden_case:
5262 { \@@_tex_error:nV { forbidden-case } \l_@@_head_tl }
5263 % \end{macrocode}
5264 % \end{macro}
5265 %
5266 % \subsubsection{Characters: from 0 to 15}
5267 %
5268 % This section is about command codes in the range $[0, 15]$.
5269 % \begin{itemize}
5270 % \item |relax=0| for \tn{relax}.
5271 % \item |begin-group_char=1| for begin-group characters (catcode~$1$).
5272 % \item |end-group_char=2| for end-group characters (catcode~$2$).
5273 % \item |math_char=3| for math shift (math toggle in \pkg{expl3})
5274 % characters (catcode~$3$).
5275 % \item |tab_mark=4| for \tn{span}
5276 % \item |alignment_char=4| for alignment tab characters (catcode~$4$).
5277 % \item |car_ret=5| for \tn{cr} and \tn{crcr}.
5278 % \item |macro_char=6| for macro parameter characters (catcode~$6$).
5279 % \item |superscript_char=7| for superscript characters (catcode~$7$).
5280 % \item |subscript_char=8| for subscript characters (catcode~$8$).
5281 % \item |endv=9| for |?|.
5282 % \item |blank_char=10| for blank spaces (catcode~$10$).
5283 % \item |the_char=11| for letters (catcode~$11$).
5284 % \item |other_char=12| for other characters (catcode~$12$).
5285 % \item |par_end=13| for \tn{par}.
5286 % \item |stop=14| for \tn{end} and \tn{dump}.
5287 % \item |delim_num=15| for \tn{delimiter}.
5288 % \end{itemize}
5289 % Not implemented at all: |endv|.
5290 %
5291 % \tn{relax} does nothing.
5292 % \begin{macrocode}
5293 \@@_new_tex_cmd:nn { relax } % 0
5294 {
5295 \token_if_eq_meaning:NNT \l_@@_head_token \@@_special_relax:
5296 {
5297 \exp_after:wN \@@_token_if_expandable:NTF \l_@@_head_tl
5298 {
5299 \@@_set_action_text:e
5300 { \iow_char:N \\notexpanded: \g_@@_action_text_str }
5301 }
5302 { }
5303 }
5304 \@@_print_action:
5305 }
5306 % \end{macrocode}
5307 %
5308 % Begin-group characters are sent to the output, as their grouping
5309 % behaviour may affect the scope of font changes, for instance. They are
5310 % also performed.
5311 % \begin{macrocode}
5312 \@@_new_tex_cmd:nn { begin-group_char } % 1
5313 {
5314 \gtl_gconcat:NNN \g_@@_output_gtl
5315 \g_@@_output_gtl \c_group_begin_gtl
5316 \@@_print_action:
5317 \l_@@_head_token
5318 \gtl_clear:N \l_@@_after_group_gtl
5319 }
5320 % \end{macrocode}
5321 %
5322 % \begin{macrocode}
5323 \@@_new_tex_cmd:nn { end-group_char } % 2
5324 { \@@_handle_right_brace: }
5325 % \end{macrocode}
5326 %
5327 % Math shift characters quit vertical mode, and start math mode.
5328 % \begin{macrocode}
5329 \@@_new_tex_cmd:nn { math_char } % 3
5330 {
5331 \@@_mode_non_vertical:n
5332 {
5333 \mode_if_math:TF
5334 {
5335 \int_compare:nNnTF
5336 \@@_currentgrouptype: = { 15 } % math_shift_group
5337 { \@@_after_math: }
5338 { \@@_off_save: }
5339 }
5340 {
5341 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5342 \@@_get_next:
5343 \token_if_eq_catcode:NNTF
5344 \l_@@_head_token \c_math_toggle_token
5345 {
5346 \mode_if_inner:TF
5347 { \@@_back_input: \@@_goto_inner_math: }
5348 {
5349 \gtl_gput_right:NV
5350 \g_@@_output_gtl \l_@@_head_tl
5351 \@@_goto_display_math:
5352 }
5353 }
5354 { \@@_back_input: \@@_goto_inner_math: }
5355 }
5356 }
5357 }
5358 % \end{macrocode}
5359 %
5360 % Some commands are errors when they reach \TeX{}'s stomach. Among
5361 % others, |tab_mark=alignment_char|, |car_ret| and |macro_char|. We let
5362 % \TeX{} insert the proper error.
5363 % \begin{macrocode}
5364 \@@_new_tex_cmd:nn { alignment_char } % 4
5365 { \l_@@_head_token \@@_print_action: }
5366 \@@_new_tex_cmd:nn { car_ret } % 5
5367 { \l_@@_head_token \@@_print_action: }
5368 \@@_new_tex_cmd:nn { macro_char } % 6
5369 { \l_@@_head_token \@@_print_action: }
5370 % \end{macrocode}
5371 %
5372 % \begin{macrocode}
5373 \@@_new_tex_cmd:nn { superscript_char } % 7
5374 { \@@_mode_math:n { \@@_sub_sup: } }
5375 \@@_new_tex_cmd:nn { subscript_char } % 8
5376 { \@@_mode_math:n { \@@_sub_sup: } }
5377 \cs_new_protected:Npn \@@_sub_sup:
5378 {
5379 \@@_prev_input_gpush:N \l_@@_head_tl
5380 \@@_print_action:
5381 \@@_do_one_atom:
5382 }
5383 \cs_new_protected:Npn \@@_do_one_atom:
5384 {
5385 \@@_get_x_non_relax:
5386 \@@_set_cmd:
5387 \int_case:nnTF \l_@@_head_cmd_int
5388 {
5389 { \@@_tex_use:n { the_char } }
5390 { \@@_prev_input:V \l_@@_head_tl }
5391 { \@@_tex_use:n { other_char } }
5392 { \@@_prev_input:V \l_@@_head_tl }
5393 { \@@_tex_use:n { char_given } }
5394 { \@@_prev_input:V \l_@@_head_tl }
5395 { \@@_tex_use:n { char_num } }
5396 {
5397 \@@_prev_input:V \l_@@_head_tl
5398 \@@_scan_int:
5399 }
5400 { \@@_tex_use:n { math_char_num } }
5401 {
5402 \@@_prev_input:V \l_@@_head_tl
5403 \@@_scan_int:
5404 }
5405 { \@@_tex_use:n { math_given } }
5406 { \@@_prev_input:V \l_@@_head_tl }
5407 { \@@_tex_use:n { delim_num } }
5408 { \@@_prev_input:V \l_@@_head_tl \@@_scan_int: }
5409 }
5410 {
5411 \@@_prev_input_gpop:N \l_@@_head_tl
5412 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5413 \tl_use:N \l_@@_head_tl \scan_stop:
5414 }
5415 {
5416 \@@_back_input:
5417 \@@_scan_left_brace:
5418 \@@_prev_input_gpop:N \l_@@_head_tl
5419 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5420 \gtl_gconcat:NNN \g_@@_output_gtl
5421 \g_@@_output_gtl \c_group_begin_gtl
5422 \tl_use:N \l_@@_head_tl \c_group_begin_token
5423 }
5424 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5425 }
5426 % \end{macrocode}
5427 %
5428 % \begin{macrocode}
5429 \@@_new_tex_cmd:nn { endv } % 9
5430 {
5431 \@@_mode_non_math:n
5432 {
5433 \@@_not_implemented:n { alignments }
5434 }
5435 }
5436 % \end{macrocode}
5437 %
5438 % Blank spaces are ignored in vertical and math modes in the same way as
5439 % \tn{relax} is in all modes. In horizontal mode, add them to the
5440 % output.
5441 % \begin{macrocode}
5442 \@@_new_tex_cmd:nn { blank_char } % 10
5443 {
5444 \mode_if_horizontal:T
5445 {
5446 \gtl_gput_right:Nn \g_@@_output_gtl { ~ }
5447 \l_@@_head_token
5448 }
5449 \@@_print_action:
5450 }
5451 % \end{macrocode}
5452 %
5453 % Letters and other characters leave vertical mode.
5454 % \begin{macrocode}
5455 \@@_new_tex_cmd:nn { the_char } % 11
5456 {
5457 \@@_mode_non_vertical:n
5458 {
5459 \tl_set:Ne \l_@@_tmpa_tl
5460 { ` \@@_token_to_char:N \l_@@_head_token }
5461 \mode_if_math:TF
5462 { \@@_char_in_mmode:V \l_@@_tmpa_tl }
5463 { \@@_char:V \l_@@_tmpa_tl }
5464 }
5465 }
5466 \@@_new_eq_tex_cmd:nn { other_char } { the_char } % 12
5467 % \end{macrocode}
5468 %
5469 % \begin{macrocode}
5470 \@@_new_tex_cmd:nn { par_end } % 13
5471 {
5472 \@@_mode_non_math:n
5473 {
5474 \mode_if_vertical:TF
5475 { \@@_par: }
5476 {
5477 % if align_state<0 then off_save;
5478 \@@_par_if_hmode:
5479 \mode_if_vertical:T
5480 { \mode_if_inner:F { \@@_build_page: } }
5481 }
5482 }
5483 }
5484 % \end{macrocode}
5485 %
5486 % ^^A todo: \dump only at bottom-level (\currentgrouptype=0)
5487 % \begin{macrocode}
5488 \@@_new_tex_cmd:nn { stop } % 14
5489 {
5490 \@@_mode_vertical:n
5491 {
5492 \mode_if_inner:TF
5493 { \@@_forbidden_case: }
5494 {
5495 % ^^A todo: unless its_all_over
5496 \int_gdecr:N \g_@@_ends_int
5497 \int_compare:nNnTF \g_@@_ends_int > 0
5498 {
5499 \@@_back_input:
5500 \@@_back_input:n
5501 {
5502 \@@_hbox:w to \tex_hsize:D { }
5503 \tex_vfill:D
5504 \tex_penalty:D - '10000000000 ~
5505 }
5506 \@@_build_page:
5507 \@@_print_action:e { End~everything! }
5508 }
5509 {
5510 \@@_print_outcome:
5511 \l_@@_head_token
5512 }
5513 }
5514 }
5515 }
5516 % \end{macrocode}
5517 %
5518 % \begin{macrocode}
5519 \@@_new_tex_cmd:nn { delim_num } % 15
5520 {
5521 \@@_mode_math:n
5522 {
5523 \@@_prev_input_gpush:N \l_@@_head_tl
5524 \@@_print_action:
5525 \@@_scan_int:
5526 \@@_prev_input_gpop:N \l_@@_head_tl
5527 \tl_use:N \l_@@_head_tl \scan_stop:
5528 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5529 }
5530 }
5531 % \end{macrocode}
5532 %
5533 % \subsubsection{Boxes: from 16 to 31}
5534 %
5535 % \begin{itemize}
5536 % \item |char_num=16| for \tn{char}
5537 % \item |math_char_num=17| for \tn{mathchar}
5538 % \item |mark=18| for \tn{mark} and \tn{marks}
5539 % \item |xray=19| for \tn{show}, \tn{showbox}, \tn{showthe},
5540 % \tn{showlists}, \tn{showgroups}, \tn{showtokens}, \tn{showifs}.
5541 % \item |make_box=20| for \tn{box}, \tn{copy}, \tn{lastbox},
5542 % \tn{vsplit}, \tn{vtop}, \tn{vbox}, and \tn{hbox}~(106).
5543 % \item |hmove=21| for \tn{moveright} and \tn{moveleft}.
5544 % \item |vmove=22| for \tn{lower} and \tn{raise}.
5545 % \item |un_hbox=23| for \tn{unhbox} and \tn{unhcopy}.
5546 % \item |unvbox=24| for \tn{unvbox}, \tn{unvcopy}, \tn{pagediscards},
5547 % and \tn{splitdiscards}.
5548 % \item |remove_item=25| for \tn{unpenalty}~(12), \tn{unkern}~(11),
5549 % \tn{unskip}~(10).
5550 % \item |hskip=26| for \tn{hfil}, \tn{hfill}, \tn{hss}, \tn{hfilneg},
5551 % \tn{hskip}.
5552 % \item |vskip=27| for \tn{vfil}, \tn{vfill}, \tn{vss}, \tn{vfilneg},
5553 % \tn{vskip}.
5554 % \item |mskip=28| for \tn{mskip}~(5).
5555 % \item |kern=29| for \tn{kern}~(1).
5556 % \item |mkern=30| for \tn{mkern}~(99).
5557 % \item |leader_ship=31| for \tn{shipout}~(99), \tn{leaders}~(100),
5558 % \tn{cleaders}~(101), \tn{xleaders}~(102).
5559 % \end{itemize}
5560 %
5561 % \tn{char} leaves vertical mode, then scans an integer operand, then
5562 % calls \cs{@@_char_in_mmode:n} or \cs{@@_char:n} depending on the mode.
5563 % See implementation of |the_char| and |other_char|.
5564 % \begin{macrocode}
5565 \@@_new_tex_cmd:nn { char_num } % 16
5566 {
5567 \@@_mode_non_vertical:n
5568 {
5569 \@@_prev_input_gpush:N \l_@@_head_tl
5570 \@@_print_action:
5571 \@@_scan_int:
5572 \@@_prev_input_gpop:N \l_@@_head_tl
5573 \mode_if_math:TF
5574 { \@@_char_in_mmode:e { \tl_tail:N \l_@@_head_tl } }
5575 { \@@_char:e { \tl_tail:N \l_@@_head_tl } }
5576 }
5577 }
5578 % \end{macrocode}
5579 %
5580 % Only allowed in math mode, \tn{mathchar} reads an integer operand, and
5581 % calls \cs{@@_mathchar:n}, which places the corresponding math
5582 % character in the \cs{g_@@_output_gtl}, and in the actual output.
5583 % \begin{macrocode}
5584 \@@_new_tex_cmd:nn { math_char_num } % 17
5585 {
5586 \@@_mode_math:n
5587 {
5588 \@@_prev_input_gpush:N \l_@@_head_tl
5589 \@@_print_action:
5590 \@@_scan_int:
5591 \@@_prev_input_gpop:N \l_@@_head_tl
5592 \@@_mathchar:e { \tl_tail:N \l_@@_head_tl }
5593 }
5594 }
5595 % \end{macrocode}
5596 %
5597 % \begin{macrocode}
5598 \@@_new_tex_cmd:nn { mark } % 18
5599 {
5600 \@@_prev_input_gpush:N \l_@@_head_tl
5601 \@@_print_action:
5602 \int_compare:nNnF \l_@@_head_char_int = 0
5603 { \@@_scan_int: }
5604 \@@_prev_input_gpush:
5605 \@@_scan_toks:NN \c_false_bool \c_true_bool
5606 \@@_prev_input_gpop:N \l_@@_tmpa_tl
5607 \@@_prev_input_gpop:N \l_@@_head_tl
5608 \@@_print_action:e
5609 { \tl_to_str:N \l_@@_head_tl \tl_to_str:N \l_@@_tmpa_tl }
5610 \tl_put_right:Ne \l_@@_head_tl
5611 { { \exp_not:N \exp_not:n \exp_not:V \l_@@_tmpa_tl } }
5612 \tl_use:N \l_@@_head_tl
5613 }
5614 % \end{macrocode}
5615 %
5616 % We now implement the primitives \tn{show}, \tn{showbox}, \tn{showthe},
5617 % \tn{showlists}, \tn{showgroups}, \tn{showtokens} and \tn{showifs}.
5618 % Those with no operand are sent to \TeX{} after printing the action.
5619 % Those with operands print first, then scan their operands, then are
5620 % sent to \TeX{}. The case of \tn{show} is a bit special, as its
5621 % operand is a single token, which cannot easily be put into the
5622 % the previous-input sequence in general. Since no expansion can occur,
5623 % simply grab the token and show it.
5624 % \begin{macrocode}
5625 \@@_new_tex_cmd:nn { xray } % 19
5626 {
5627 \@@_prev_input_gpush:N \l_@@_head_tl
5628 \@@_print_action:
5629 \int_case:nnF \l_@@_head_char_int
5630 {
5631 { 0 }
5632 { % show
5633 \@@_get_next:
5634 \@@_prev_input_gpop:N \l_@@_tmpa_tl
5635 \token_if_eq_meaning:NNTF
5636 \l_@@_head_token \@@_special_relax:
5637 {
5638 \exp_after:wN \exp_after:wN \exp_after:wN \l_@@_tmpa_tl
5639 \exp_after:wN \exp_not:N \l_@@_head_tl
5640 }
5641 { \gtl_head_do:NN \l_@@_head_gtl \l_@@_tmpa_tl }
5642 }
5643 { 2 }
5644 { % showthe
5645 \@@_get_x_next:
5646 \@@_rescan_something_internal:n { 5 }
5647 \@@_prev_input_gpop:N \l_@@_head_tl
5648 \exp_args:Ne \use:n % better display than \use:e
5649 { \tex_showtokens:D { \tl_tail:N \l_@@_head_tl } }
5650 }
5651 }
5652 { % no operand for showlists, showgroups, showifs
5653 \int_compare:nNnT \l_@@_head_char_int = 1 % showbox
5654 { \@@_scan_int: }
5655 \int_compare:nNnT \l_@@_head_char_int = 5 % showtokens
5656 { \@@_scan_toks:NN \c_false_bool \c_false_bool }
5657 \@@_prev_input_gpop:N \l_@@_head_tl
5658 \tl_use:N \l_@@_head_tl \scan_stop:
5659 }
5660 }
5661 % \end{macrocode}
5662 %
5663 % |make_box=20| for \tn{box}, \tn{copy}, \tn{lastbox},
5664 % \tn{vsplit}, \tn{vtop}, \tn{vbox}, and \tn{hbox}~(106).
5665 % \begin{macrocode}
5666 \@@_new_tex_cmd:nn { make_box } % 20
5667 {
5668 \@@_prev_input_gpush:
5669 \@@_back_input:
5670 \@@_do_box:N \c_false_bool
5671 }
5672 % \end{macrocode}
5673 %
5674 % \begin{macro}{\@@_do_move:}
5675 % Scan a dimension and a box, and perform the shift, printing the
5676 % appropriate action.
5677 % \begin{macrocode}
5678 \cs_new_protected:Npn \@@_do_move:
5679 {
5680 \@@_prev_input_gpush:N \l_@@_head_tl
5681 \@@_print_action:
5682 \@@_scan_normal_dimen:
5683 \@@_do_box:N \c_false_bool
5684 }
5685 % \end{macrocode}
5686 % \end{macro}
5687 %
5688 % |hmove=21| for \tn{moveright} and \tn{moveleft}.
5689 % \begin{macrocode}
5690 \@@_new_tex_cmd:nn { hmove } % 21
5691 {
5692 \mode_if_vertical:TF
5693 { \@@_do_move: } { \@@_forbidden_case: }
5694 }
5695 % \end{macrocode}
5696 %
5697 % |vmove=22| for \tn{lower} and \tn{raise}.
5698 % \begin{macrocode}
5699 \@@_new_tex_cmd:nn { vmove } % 22
5700 {
5701 \mode_if_vertical:TF
5702 { \@@_forbidden_case: } { \@@_do_move: }
5703 }
5704 % \end{macrocode}
5705 %
5706 % \begin{macro}{\@@_do_unpackage:}
5707 % \begin{macrocode}
5708 \cs_new_protected:Npn \@@_do_unpackage:
5709 {
5710 \@@_prev_input_gpush:N \l_@@_head_tl
5711 \@@_print_action:
5712 \@@_scan_int:
5713 \@@_prev_input_gpop:N \l_@@_head_tl
5714 \tl_use:N \l_@@_head_tl \scan_stop:
5715 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5716 }
5717 % \end{macrocode}
5718 % \end{macro}
5719 %
5720 % |un_hbox=23| for \tn{unhbox} and \tn{unhcopy}.
5721 % \begin{macrocode}
5722 \@@_new_tex_cmd:nn { un_hbox } % 23
5723 { \@@_mode_non_vertical:n { \@@_do_unpackage: } }
5724 % \end{macrocode}
5725 %
5726 % |unvbox=24| for \tn{unvbox}, \tn{unvcopy}, \tn{pagediscards}, and
5727 % \tn{splitdiscards}. The latter two take no operands, so we just let
5728 % \TeX{} do its thing, then we show the action.
5729 % \begin{macrocode}
5730 \@@_new_tex_cmd:nn { un_vbox } % 24
5731 {
5732 \@@_mode_vertical:n
5733 {
5734 \int_compare:nNnTF \l_@@_head_char_int > { 1 }
5735 { \l_@@_head_token \@@_print_action: }
5736 { \@@_do_unpackage: }
5737 }
5738 }
5739 % \end{macrocode}
5740 %
5741 % |remove_item=25| for \tn{unpenalty}~(12), \tn{unkern}~(11),
5742 % \tn{unskip}~(10). Those commands only act on \TeX{}'s box/glue data
5743 % structures, which \pkg{unravel} does not (and cannot) care about.
5744 % \begin{macrocode}
5745 \@@_new_tex_cmd:nn { remove_item } % 25
5746 { \l_@@_head_token \@@_print_action: }
5747 % \end{macrocode}
5748 %
5749 % \begin{macro}{\@@_do_append_glue:}
5750 % For \tn{hfil}, \tn{hfill}, \tn{hss}, \tn{hfilneg} and their vertical
5751 % analogs, simply call the primitive then print the action. For
5752 % \tn{hskip}, \tn{vskip} and \tn{mskip}, read a normal glue or a mu
5753 % glue (\cs{l_@@_head_char_int} is $4$ or~$5$), then call the
5754 % primitive with that operand, and print the whole thing as an action.
5755 % \begin{macrocode}
5756 \cs_new_protected:Npn \@@_do_append_glue:
5757 {
5758 \int_compare:nNnTF \l_@@_head_char_int < { 4 }
5759 { \tl_use:N \l_@@_head_tl \@@_print_action: }
5760 {
5761 \@@_prev_input_gpush:N \l_@@_head_tl
5762 \@@_print_action:
5763 \exp_args:Nf \@@_scan_glue:n
5764 { \int_eval:n { \l_@@_head_char_int - 2 } }
5765 \@@_prev_input_gpop:N \l_@@_head_tl
5766 \tl_use:N \l_@@_head_tl \scan_stop:
5767 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5768 }
5769 }
5770 % \end{macrocode}
5771 % \end{macro}
5772 %
5773 % |hskip=26| for \tn{hfil}, \tn{hfill}, \tn{hss}, \tn{hfilneg},
5774 % \tn{hskip}.
5775 % \begin{macrocode}
5776 \@@_new_tex_cmd:nn { hskip } % 26
5777 { \@@_mode_non_vertical:n { \@@_do_append_glue: } }
5778 % \end{macrocode}
5779 %
5780 % |vskip=27| for \tn{vfil}, \tn{vfill}, \tn{vss}, \tn{vfilneg},
5781 % \tn{vskip}.
5782 % \begin{macrocode}
5783 \@@_new_tex_cmd:nn { vskip } % 27
5784 { \@@_mode_vertical:n { \@@_do_append_glue: } }
5785 % \end{macrocode}
5786 %
5787 % |mskip=28| for \tn{mskip}~(5).
5788 % \begin{macrocode}
5789 \@@_new_tex_cmd:nn { mskip } % 28
5790 { \@@_mode_math:n { \@@_do_append_glue: } }
5791 % \end{macrocode}
5792 %
5793 % \begin{macro}{\@@_do_append_kern:}
5794 % See \cs{@@_do_append_glue:}. This function is used for the
5795 % primitives \tn{kern} and \tn{mkern} only.
5796 % \begin{macrocode}
5797 \cs_new_protected:Npn \@@_do_append_kern:
5798 {
5799 \@@_prev_input_gpush:N \l_@@_head_tl
5800 \@@_print_action:
5801 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_kern:D
5802 { \@@_scan_dimen:nN { 2 } \c_false_bool }
5803 { \@@_scan_dimen:nN { 3 } \c_false_bool }
5804 \@@_prev_input_gpop:N \l_@@_head_tl
5805 \tl_use:N \l_@@_head_tl \scan_stop:
5806 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5807 }
5808 % \end{macrocode}
5809 % \end{macro}
5810 %
5811 % |kern=29| for \tn{kern}~(1).
5812 % \begin{macrocode}
5813 \@@_new_tex_cmd:nn { kern } % 29
5814 { \@@_do_append_kern: }
5815 % \end{macrocode}
5816 %
5817 % |mkern=30| for \tn{mkern}~(99).
5818 % \begin{macrocode}
5819 \@@_new_tex_cmd:nn { mkern } % 30
5820 { \@@_mode_math:n { \@@_do_append_kern: } }
5821 % \end{macrocode}
5822 %
5823 % |leader_ship=31| for \tn{shipout}~(99), \tn{leaders}~(100),
5824 % \tn{cleaders}~(101), \tn{xleaders}~(102).
5825 % \begin{macrocode}
5826 \@@_new_tex_cmd:nn { leader_ship } % 31
5827 {
5828 \@@_prev_input_gpush:N \l_@@_head_tl
5829 \@@_print_action:
5830 \tl_if_head_eq_meaning:VNTF \l_@@_head_tl \tex_shipout:D
5831 { \@@_do_box:N \c_false_bool }
5832 { \@@_do_box:N \c_true_bool }
5833 }
5834 % \end{macrocode}
5835 %
5836 % \subsubsection{From 32 to 47}
5837 %
5838 % \begin{itemize}
5839 % \item |halign=32|
5840 % \item |valign=33|
5841 % \item |no_align=34|
5842 % \item |vrule=35|
5843 % \item |hrule=36|
5844 % \item |insert=37|
5845 % \item |vadjust=38|
5846 % \item |ignore_spaces=39|
5847 % \item |after_assignment=40|
5848 % \item |after_group=41|
5849 % \item |break_penalty=42|
5850 % \item |start_par=43|
5851 % \item |ital_corr=44|
5852 % \item |accent=45|
5853 % \item |math_accent=46|
5854 % \item |discretionary=47|
5855 % \end{itemize}
5856 %
5857 % \begin{macrocode}
5858 \@@_new_tex_cmd:nn { halign } % 32
5859 { \@@_not_implemented:n { halign } }
5860 \@@_new_tex_cmd:nn { valign } % 33
5861 { \@@_not_implemented:n { valign } }
5862 \@@_new_tex_cmd:nn { no_align } % 34
5863 { \l_@@_head_token \@@_print_action: }
5864 % \end{macrocode}
5865 %
5866 % \begin{macrocode}
5867 \@@_new_tex_cmd:nn { vrule } % 35
5868 { \@@_mode_non_vertical:n { \@@_do_rule: } }
5869 \@@_new_tex_cmd:nn { hrule } % 36
5870 { \@@_mode_vertical:n { \@@_do_rule: } }
5871 \cs_new_protected:Npn \@@_do_rule:
5872 {
5873 \@@_prev_input_gpush:N \l_@@_head_tl
5874 \@@_print_action:
5875 \@@_scan_alt_rule:
5876 \@@_prev_input_gpop:N \l_@@_head_tl
5877 \tl_use:N \l_@@_head_tl \scan_stop:
5878 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5879 }
5880 % \end{macrocode}
5881 %
5882 % \begin{macrocode}
5883 \@@_new_tex_cmd:nn { insert } % 37
5884 {
5885 \@@_prev_input_gpush:N \l_@@_head_tl
5886 \@@_print_action:
5887 \@@_scan_int:
5888 \@@_begin_insert_or_adjust:
5889 }
5890 \@@_new_tex_cmd:nn { vadjust } % 38
5891 {
5892 \mode_if_vertical:TF
5893 { \@@_forbidden_case: }
5894 {
5895 \@@_prev_input_gpush:N \l_@@_head_tl
5896 \@@_print_action:
5897 \@@_scan_keyword:nTF { pPrReE }
5898 \@@_begin_insert_or_adjust:
5899 }
5900 }
5901 \cs_new_protected:Npn \@@_begin_insert_or_adjust:
5902 {
5903 \@@_scan_left_brace:
5904 \@@_prev_input_gpop:N \l_@@_head_tl
5905 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5906 \gtl_gconcat:NNN \g_@@_output_gtl
5907 \g_@@_output_gtl \c_group_begin_gtl
5908 \tl_use:N \l_@@_head_tl \c_group_begin_token
5909 \@@_print_action:e
5910 { \tl_to_str:N \l_@@_head_tl \iow_char:N \{ }
5911 }
5912 % \end{macrocode}
5913 %
5914 % \begin{macrocode}
5915 \@@_new_tex_cmd:nn { ignore_spaces } % 39
5916 {
5917 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_ignorespaces:D
5918 {
5919 \@@_print_action:
5920 \@@_get_x_non_blank:
5921 \@@_set_cmd:
5922 \@@_do_step:
5923 }
5924 { \@@_not_implemented:n { pdfprimitive } }
5925 }
5926 % \end{macrocode}
5927 %
5928 % \begin{macrocode}
5929 \@@_new_tex_cmd:nn { after_assignment } % 40
5930 {
5931 \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_head_tl
5932 \@@_get_next:
5933 \gtl_gset_eq:NN \g_@@_after_assignment_gtl \l_@@_head_gtl
5934 \@@_print_action:e
5935 {
5936 Afterassignment:~\tl_to_str:N \l_@@_tmpa_tl
5937 \gtl_to_str:N \l_@@_head_gtl
5938 }
5939 }
5940 % \end{macrocode}
5941 %
5942 % Save the next token at the end of \cs{l_@@_after_group_gtl}, unless
5943 % we are at the bottom group level, in which case, the token is ignored
5944 % completely.
5945 % \begin{macrocode}
5946 \@@_new_tex_cmd:nn { after_group } % 41
5947 {
5948 \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_head_tl
5949 \@@_get_next:
5950 \int_compare:nNnTF \@@_currentgrouptype: = 0
5951 {
5952 \@@_print_action:e
5953 {
5954 Aftergroup~(level~0~=>~dropped):~
5955 \tl_to_str:N \l_@@_tmpa_tl
5956 \gtl_to_str:N \l_@@_head_gtl
5957 }
5958 }
5959 {
5960 \gtl_concat:NNN \l_@@_after_group_gtl
5961 \l_@@_after_group_gtl \l_@@_head_gtl
5962 \@@_print_action:e
5963 {
5964 Aftergroup:~\tl_to_str:N \l_@@_tmpa_tl
5965 \gtl_to_str:N \l_@@_head_gtl
5966 }
5967 }
5968 }
5969 % \end{macrocode}
5970 %
5971 % See \cs{@@_do_append_glue:}.
5972 % \begin{macrocode}
5973 \@@_new_tex_cmd:nn { break_penalty } % 42
5974 {
5975 \@@_prev_input_gpush:N \l_@@_head_tl
5976 \@@_print_action:
5977 \@@_scan_int:
5978 \@@_prev_input_gpop:N \l_@@_head_tl
5979 \tl_use:N \l_@@_head_tl \scan_stop:
5980 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
5981 }
5982 % \end{macrocode}
5983 %
5984 % \begin{macrocode}
5985 \@@_new_tex_cmd:nn { start_par } % 43
5986 {
5987 \mode_if_vertical:TF
5988 {
5989 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_noindent:D
5990 { \@@_new_graf:N \c_false_bool }
5991 { \@@_new_graf:N \c_true_bool }
5992 }
5993 {
5994 \int_compare:nNnT \l_@@_head_char_int = { 1 } % indent
5995 {
5996 \@@_hbox:w width \tex_parindent:D { }
5997 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
5998 }
5999 \@@_print_action:
6000 }
6001 }
6002 % \end{macrocode}
6003 %
6004 % \begin{macrocode}
6005 \@@_new_tex_cmd:nn { ital_corr } % 44
6006 {
6007 \mode_if_vertical:TF { \@@_forbidden_case: }
6008 { \l_@@_head_token \@@_print_action: }
6009 }
6010 % \end{macrocode}
6011 %
6012 % \begin{macro}{\@@_do_accent:}
6013 % \begin{macrocode}
6014 \cs_new_protected:Npn \@@_do_accent:
6015 {
6016 \@@_prev_input_gpush:N \l_@@_head_tl
6017 \@@_print_action:
6018 \@@_scan_int:
6019 \@@_do_assignments:
6020 \bool_if:nTF
6021 {
6022 \token_if_eq_catcode_p:NN
6023 \l_@@_head_token \c_catcode_letter_token
6024 ||
6025 \token_if_eq_catcode_p:NN
6026 \l_@@_head_token \c_catcode_other_token
6027 ||
6028 \int_compare_p:nNn
6029 \l_@@_head_cmd_int = { \@@_tex_use:n { char_given } }
6030 }
6031 { \@@_prev_input:V \l_@@_head_tl }
6032 {
6033 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_char:D
6034 {
6035 \@@_prev_input:V \l_@@_head_tl
6036 \@@_scan_int:
6037 }
6038 { \@@_break:w }
6039 }
6040 \@@_prev_input_gpop:N \l_@@_head_tl
6041 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6042 \tl_use:N \l_@@_head_tl \scan_stop:
6043 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6044 \@@_break_point:
6045 }
6046 % \end{macrocode}
6047 % \end{macro}
6048 %
6049 % \begin{macro}{\@@_do_math_accent:}
6050 % \TeX{} will complain if \cs{l_@@_head_tl} happens to start with
6051 % \tn{accent} (the user used \tn{accent} in math mode).
6052 % \begin{macrocode}
6053 \cs_new_protected:Npn \@@_do_math_accent:
6054 {
6055 \@@_prev_input_gpush:N \l_@@_head_tl
6056 \@@_print_action:
6057 \@@_scan_int:
6058 \@@_do_one_atom:
6059 }
6060 % \end{macrocode}
6061 % \end{macro}
6062 %
6063 % \begin{macrocode}
6064 \@@_new_tex_cmd:nn { accent } % 45
6065 {
6066 \@@_mode_non_vertical:n
6067 {
6068 \mode_if_math:TF
6069 { \@@_do_math_accent: } { \@@_do_accent: }
6070 }
6071 }
6072 % \end{macrocode}
6073 %
6074 % \begin{macrocode}
6075 \@@_new_tex_cmd:nn { math_accent } % 46
6076 { \@@_mode_math:n { \@@_do_math_accent: } }
6077 % \end{macrocode}
6078 %
6079 % \begin{macrocode}
6080 \@@_new_tex_cmd:nn { discretionary } % 47
6081 {
6082 \@@_mode_non_vertical:n
6083 {
6084 \int_compare:nNnTF \l_@@_head_char_int = { 1 }
6085 { \@@_output_head_token: }
6086 { \@@_do_choice: }
6087 }
6088 }
6089 % \end{macrocode}
6090 %
6091 % \subsubsection{Maths: from 48 to 56}
6092 %
6093 % \begin{itemize}
6094 % \item |eq_no=48|
6095 % \item |left_right=49|
6096 % \item |math_comp=50|
6097 % \item |limit_switch=51|
6098 % \item |above=52|
6099 % \item |math_style=53|
6100 % \item |math_choice=54|
6101 % \item |non_script=55|
6102 % \item |vcenter=56|
6103 % \end{itemize}
6104 %
6105 % \begin{macrocode}
6106 \@@_new_tex_cmd:nn { eq_no } % 48
6107 {
6108 \mode_if_math:TF
6109 {
6110 \mode_if_inner:TF
6111 { \@@_off_save: }
6112 {
6113 \int_compare:nNnTF \tex_currentgrouptype:D = { 15 }
6114 {
6115 \@@_box_hook:N \tex_everymath:D
6116 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6117 \l_@@_head_token
6118 \@@_box_hook_end:
6119 \int_set:Nn \l_@@_choice_int { 1 }
6120 }
6121 { \@@_off_save: }
6122 }
6123 }
6124 { \@@_forbidden_case: }
6125 }
6126 % \end{macrocode}
6127 %
6128 % \begin{macrocode}
6129 \@@_new_tex_cmd:nn { left_right } % 49
6130 {
6131 \@@_mode_math:n
6132 {
6133 \@@_prev_input_gpush:N \l_@@_head_tl
6134 \@@_print_action:
6135 \@@_scan_delimiter:
6136 \@@_prev_input_gpop:N \l_@@_head_tl
6137 \tl_if_head_eq_meaning:nNTF \l_@@_head_tl \tex_left:D
6138 {
6139 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6140 \tl_use:N \l_@@_head_tl \scan_stop:
6141 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6142 }
6143 {
6144 \int_case:nnF \tex_currentgrouptype:D
6145 {
6146 { 16 }
6147 {
6148 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6149 \@@_back_input_gtl:N \l_@@_after_group_gtl
6150 \tl_if_head_eq_meaning:nNTF \l_@@_head_tl \tex_middle:D
6151 {
6152 \tl_use:N \l_@@_head_tl \scan_stop:
6153 \gtl_clear:N \l_@@_after_group_gtl
6154 }
6155 { \tl_use:N \l_@@_head_tl \scan_stop: }
6156 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6157 }
6158 { 15 }
6159 { % todo: this is a TeX error
6160 \tl_use:N \l_@@_head_tl \scan_stop:
6161 }
6162 }
6163 { \@@_off_save: }
6164 }
6165 }
6166 }
6167 \cs_new_protected:Npn \@@_scan_delimiter:
6168 {
6169 \@@_get_x_non_relax:
6170 \@@_set_cmd:
6171 \int_case:nnF \l_@@_head_cmd_int
6172 {
6173 { \@@_tex_use:n { the_char } }
6174 { \@@_prev_input:V \l_@@_head_tl }
6175 { \@@_tex_use:n { other_char } }
6176 { \@@_prev_input:V \l_@@_head_tl }
6177 { \@@_tex_use:n { delim_num } }
6178 {
6179 \@@_prev_input:V \l_@@_head_tl
6180 \@@_scan_int:
6181 }
6182 }
6183 {
6184 \@@_back_input:
6185 \@@_tex_error:nV { missing-delim } \l_@@_head_tl
6186 \@@_prev_input:n { . }
6187 }
6188 }
6189 % \end{macrocode}
6190 %
6191 % \begin{macrocode}
6192 \@@_new_tex_cmd:nn { math_comp } % 50
6193 { \@@_mode_math:n { \@@_sub_sup: } }
6194 % \end{macrocode}
6195 %
6196 % \begin{macrocode}
6197 \@@_new_tex_cmd:nn { limit_switch } % 51
6198 { \@@_mode_math:n { \@@_output_head_token: } }
6199 \cs_new_protected:Npn \@@_output_head_token:
6200 {
6201 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6202 \l_@@_head_token
6203 \@@_print_action:
6204 }
6205 % \end{macrocode}
6206 %
6207 % \begin{macrocode}
6208 \@@_new_tex_cmd:nn { above } % 52
6209 { \@@_mode_math:n { \@@_not_implemented:n { above } } }
6210 % \end{macrocode}
6211 %
6212 % \begin{macrocode}
6213 \@@_new_tex_cmd:nn { math_style } % 53
6214 { \@@_mode_math:n { \@@_output_head_token: } }
6215 % \end{macrocode}
6216 %
6217 % \begin{macrocode}
6218 \@@_new_tex_cmd:nn { math_choice } % 54
6219 { \@@_mode_math:n { \@@_do_choice: } }
6220 \cs_new_protected:Npn \@@_do_choice:
6221 {
6222 \@@_prev_input_gpush:N \l_@@_head_tl
6223 \@@_print_action:
6224 \@@_scan_left_brace:
6225 \@@_prev_input_gpop:N \l_@@_head_tl
6226 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6227 \gtl_gconcat:NNN \g_@@_output_gtl
6228 \g_@@_output_gtl \c_group_begin_gtl
6229 \tl_use:N \l_@@_head_tl \c_group_begin_token
6230 \gtl_clear:N \l_@@_after_group_gtl
6231 \int_set:Nn \l_@@_choice_int { 1 }
6232 \@@_print_action:e
6233 { \tl_to_str:N \l_@@_head_tl \iow_char:N \{ }
6234 }
6235 % \end{macrocode}
6236 %
6237 % \begin{macrocode}
6238 \@@_new_tex_cmd:nn { non_script } % 55
6239 { \@@_mode_math:n { \@@_output_head_token: } }
6240 % \end{macrocode}
6241 %
6242 % \begin{macrocode}
6243 \@@_new_tex_cmd:nn { vcenter } % 56
6244 { \@@_mode_math:n { \@@_not_implemented:n { vcenter } } }
6245 % \end{macrocode}
6246 %
6247 % \subsubsection{From 57 to 70}
6248 %
6249 % \begin{itemize}
6250 % \item |case_shift=57|
6251 % \item |message=58|
6252 % \item |extension=59|
6253 % \item |in_stream=60|
6254 % \item |begin_group=61|
6255 % \item |end_group=62|
6256 % \item |omit=63|
6257 % \item |ex_space=64|
6258 % \item |no_boundary=65|
6259 % \item |radical=66|
6260 % \item |end_cs_name=67|
6261 % \item |char_given=68|
6262 % \item |math_given=69|
6263 % \item |last_item=70|
6264 % \end{itemize}
6265 %
6266 % \begin{macrocode}
6267 \@@_new_tex_cmd:nn { case_shift } % 57
6268 {
6269 \@@_prev_input_gpush:N \l_@@_head_tl
6270 \@@_scan_toks:NN \c_false_bool \c_false_bool
6271 \@@_prev_input_gpop:N \l_@@_tmpa_tl
6272 \exp_after:wN \@@_case_shift:Nn \l_@@_tmpa_tl
6273 }
6274 \cs_new_protected:Npn \@@_case_shift:Nn #1#2
6275 {
6276 #1 { \@@_back_input:n {#2} }
6277 \@@_print_action:e
6278 { \token_to_meaning:N #1 ~ \tl_to_str:n { {#2} } }
6279 }
6280 % \end{macrocode}
6281 %
6282 % \begin{macrocode}
6283 \@@_new_tex_cmd:nn { message } % 58
6284 {
6285 \@@_prev_input_gpush:N \l_@@_head_tl
6286 \@@_print_action:
6287 \@@_scan_toks_to_str:
6288 \@@_prev_input_gpop:N \l_@@_head_tl
6289 \tl_use:N \l_@@_head_tl
6290 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6291 }
6292 % \end{macrocode}
6293 %
6294 % Extensions are implemented in a later section.
6295 % \begin{macrocode}
6296 \@@_new_tex_cmd:nn { extension } % 59
6297 {
6298 \@@_prev_input_gpush:N \l_@@_head_tl
6299 \@@_print_action:
6300 \@@_scan_extension_operands:
6301 \@@_prev_input_gpop:N \l_@@_head_tl
6302 \tl_use:N \l_@@_head_tl \scan_stop:
6303 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6304 }
6305 % \end{macrocode}
6306 %
6307 % \begin{macrocode}
6308 \@@_new_tex_cmd:nn { in_stream } % 60
6309 {
6310 \@@_prev_input_gpush:N \l_@@_head_tl
6311 \@@_print_action:
6312 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_openin:D
6313 {
6314 \@@_scan_int:
6315 \@@_scan_optional_equals:
6316 \@@_scan_file_name:
6317 }
6318 { \@@_scan_int: }
6319 \@@_prev_input_gpop:N \l_@@_head_tl
6320 \tl_use:N \l_@@_head_tl \scan_stop:
6321 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6322 }
6323 % \end{macrocode}
6324 %
6325 % \begin{macrocode}
6326 \@@_new_tex_cmd:nn { begin_group } % 61
6327 {
6328 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6329 \l_@@_head_token
6330 \gtl_clear:N \l_@@_after_group_gtl
6331 \@@_print_action:
6332 }
6333 \@@_new_tex_cmd:nn { end_group } % 62
6334 {
6335 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
6336 \@@_back_input_gtl:N \l_@@_after_group_gtl
6337 \l_@@_head_token
6338 \@@_print_action:
6339 }
6340 % \end{macrocode}
6341 %
6342 % \begin{macrocode}
6343 \@@_new_tex_cmd:nn { omit } % 63
6344 { \l_@@_head_token \@@_print_action: }
6345 % \end{macrocode}
6346 %
6347 % \begin{macrocode}
6348 \@@_new_tex_cmd:nn { ex_space } % 64
6349 {
6350 \@@_mode_non_vertical:n
6351 { \l_@@_head_token \@@_print_action: }
6352 }
6353 % \end{macrocode}
6354 %
6355 % \begin{macrocode}
6356 \@@_new_tex_cmd:nn { no_boundary } % 65
6357 {
6358 \@@_mode_non_vertical:n
6359 { \l_@@_head_token \@@_print_action: }
6360 }
6361 % \end{macrocode}
6362 %
6363 % \begin{macrocode}
6364 \@@_new_tex_cmd:nn { radical } % 66
6365 { \@@_mode_math:n { \@@_do_math_accent: } }
6366 % \end{macrocode}
6367 %
6368 % \begin{macrocode}
6369 \@@_new_tex_cmd:nn { end_cs_name } % 67
6370 {
6371 \@@_tex_error:nV { extra-endcsname } \l_@@_head_tl
6372 \@@_print_action:
6373 }
6374 % \end{macrocode}
6375 %
6376 % See |the_char| and |other_char|.
6377 % \begin{macrocode}
6378 \@@_new_tex_cmd:nn { char_given } % 68
6379 {
6380 \@@_mode_non_vertical:n
6381 {
6382 \mode_if_math:TF
6383 { \@@_char_in_mmode:V \l_@@_head_char_int }
6384 { \@@_char:V \l_@@_head_char_int }
6385 }
6386 }
6387 % \end{macrocode}
6388 %
6389 % See |math_char_num|.
6390 % \begin{macrocode}
6391 \@@_new_tex_cmd:nn { math_given } % 69
6392 {
6393 \@@_mode_math:n
6394 { \@@_mathchar:e { \int_use:N \l_@@_head_char_int } }
6395 }
6396 % \end{macrocode}
6397 %
6398 % \begin{macrocode}
6399 \@@_new_tex_cmd:nn { last_item } % 70
6400 { \@@_forbidden_case: }
6401 % \end{macrocode}
6402 %
6403 % \subsubsection{Extensions}
6404 % ^^A todo: move this section.
6405 %
6406 % \begin{macro}{\@@_scan_extension_operands:}
6407 % \begin{macrocode}
6408 \cs_new_protected:Npn \@@_scan_extension_operands:
6409 {
6410 \int_case:nnF \l_@@_head_char_int
6411 {
6412 { 0 } % openout
6413 {
6414 \@@_scan_int:
6415 \@@_scan_optional_equals:
6416 \@@_scan_file_name:
6417 }
6418 { 1 } % write
6419 {
6420 \@@_scan_int:
6421 \@@_scan_toks:NN \c_false_bool \c_false_bool
6422 }
6423 { 2 } % closeout
6424 { \@@_scan_int: }
6425 { 3 } % special
6426 { \@@_scan_toks_to_str: }
6427 { 4 } % immediate
6428 { \@@_scan_immediate_operands: }
6429 { 5 } % setlanguage
6430 {
6431 \mode_if_horizontal:TF
6432 { \@@_scan_int: }
6433 { \@@_error:nnnnn { invalid-mode } { } { } { } { } }
6434 }
6435 { 6 } % pdfliteral
6436 {
6437 \@@_scan_keyword:nF { dDiIrReEcCtT }
6438 { \@@_scan_keyword:n { pPaAgGeE } }
6439 \@@_scan_pdf_ext_toks:
6440 }
6441 { 7 } % pdfobj
6442 {
6443 \@@_scan_keyword:nTF
6444 { rReEsSeErRvVeEoObBjJnNuUmM }
6445 { \@@_skip_optional_space: }
6446 {
6447 \@@_scan_keyword:nF { uUsSeEoObBjJnNuUmM }
6448 { \@@_scan_int: }
6449 \@@_scan_keyword:nT { sStTrReEaAmM }
6450 {
6451 \@@_scan_keyword:nT { aAtTtTrR }
6452 { \@@_scan_pdf_ext_toks: }
6453 }
6454 \@@_scan_keyword:n { fFiIlLeE }
6455 \@@_scan_pdf_ext_toks:
6456 }
6457 }
6458 { 8 } % pdfrefobj
6459 { \@@_scan_int: }
6460 { 9 } % pdfxform
6461 {
6462 \@@_scan_keyword:nT { aAtTtTrR }
6463 { \@@_scan_pdf_ext_toks: }
6464 \@@_scan_keyword:nTF { rReEsSoOuUrRcCeEsS }
6465 { \@@_scan_pdf_ext_toks: }
6466 \@@_scan_int:
6467 }
6468 { 10 } % pdfrefxform
6469 { \@@_scan_int: }
6470 { 11 } % pdfximage
6471 { \@@_scan_image: }
6472 { 12 } % pdfrefximage
6473 { \@@_scan_int: }
6474 { 13 } % pdfannot
6475 {
6476 \@@_scan_keyword:nTF
6477 { rReEsSeErRvVeEoObBjJnNuUmM }
6478 { \@@_scan_optional_space: }
6479 {
6480 \@@_scan_keyword:nT { uUsSeEoObBjJnNuUmM }
6481 { \@@_scan_int: }
6482 \@@_scan_alt_rule:
6483 \@@_scan_pdf_ext_toks:
6484 }
6485 }
6486 { 14 } % pdfstartlink
6487 {
6488 \mode_if_vertical:TF
6489 { \@@_error:nnnnn { invalid-mode } { } { } { } { } }
6490 {
6491 \@@_scan_rule_attr:
6492 \@@_scan_action:
6493 }
6494 }
6495 { 15 } % pdfendlink
6496 {
6497 \mode_if_vertical:T
6498 { \@@_error:nnnnn { invalid-mode } { } { } { } { } }
6499 }
6500 { 16 } % pdfoutline
6501 {
6502 \@@_scan_keyword:nT { aAtTtTrR }
6503 { \@@_scan_pdf_ext_toks: }
6504 \@@_scan_action:
6505 \@@_scan_keyword:nT { cCoOuUnNtT }
6506 { \@@_scan_int: }
6507 \@@_scan_pdf_ext_toks:
6508 }
6509 { 17 } % pdfdest
6510 { \@@_scan_pdfdest_operands: }
6511 { 18 } % pdfthread
6512 { \@@_scan_rule_attr: \@@_scan_thread_id: }
6513 { 19 } % pdfstartthread
6514 { \@@_scan_rule_attr: \@@_scan_thread_id: }
6515 { 20 } % pdfendthread
6516 { }
6517 { 21 } % pdfsavepos
6518 { }
6519 { 22 } % pdfinfo
6520 { \@@_scan_pdf_ext_toks: }
6521 { 23 } % pdfcatalog
6522 {
6523 \@@_scan_pdf_ext_toks:
6524 \@@_scan_keyword:n { oOpPeEnNaAcCtTiIoOnN }
6525 { \@@_scan_action: }
6526 }
6527 { 24 } % pdfnames
6528 { \@@_scan_pdf_ext_toks: }
6529 { 25 } % pdffontattr
6530 {
6531 \@@_scan_font_ident:
6532 \@@_scan_pdf_ext_toks:
6533 }
6534 { 26 } % pdfincludechars
6535 {
6536 \@@_scan_font_ident:
6537 \@@_scan_pdf_ext_toks:
6538 }
6539 { 27 } % pdfmapfile
6540 { \@@_scan_pdf_ext_toks: }
6541 { 28 } % pdfmapline
6542 { \@@_scan_pdf_ext_toks: }
6543 { 29 } % pdftrailer
6544 { \@@_scan_pdf_ext_toks: }
6545 { 30 } % pdfresettimer
6546 { }
6547 { 31 } % pdffontexpand
6548 {
6549 \@@_scan_font_ident:
6550 \@@_scan_optional_equals:
6551 \@@_scan_int:
6552 \@@_scan_int:
6553 \@@_scan_int:
6554 \@@_scan_keyword:nT { aAuUtToOeExXpPaAnNdD }
6555 { \@@_skip_optional_space: }
6556 }
6557 { 32 } % pdfsetrandomseed
6558 { \@@_scan_int: }
6559 { 33 } % pdfsnaprefpoint
6560 { }
6561 { 34 } % pdfsnapy
6562 { \@@_scan_normal_glue: }
6563 { 35 } % pdfsnapycomp
6564 { \@@_scan_int: }
6565 { 36 } % pdfglyphtounicode
6566 {
6567 \@@_scan_pdf_ext_toks:
6568 \@@_scan_pdf_ext_toks:
6569 }
6570 { 37 } % pdfcolorstack
6571 { \@@_scan_pdfcolorstack_operands: }
6572 { 38 } % pdfsetmatrix
6573 { \@@_scan_pdf_ext_toks: }
6574 { 39 } % pdfsave
6575 { }
6576 { 40 } % pdfrestore
6577 { }
6578 { 41 } % pdfnobuiltintounicode
6579 { \@@_scan_font_ident: }
6580 }
6581 { } % no other cases.
6582 }
6583 % \end{macrocode}
6584 % \end{macro}
6585 %
6586 % \begin{macro}{\@@_scan_pdfcolorstack_operands:}
6587 % \begin{macrocode}
6588 \cs_new_protected:Npn \@@_scan_pdfcolorstack_operands:
6589 {
6590 \@@_scan_int:
6591 \@@_scan_keyword:nF { sSeEtT }
6592 {
6593 \@@_scan_keyword:nF { pPuUsShH }
6594 {
6595 \@@_scan_keyword:nF { pPoOpP }
6596 {
6597 \@@_scan_keyword:nF { cCuUrRrReEnNtT }
6598 {
6599 \@@_error:nnnnn { color-stack-action-missing }
6600 { } { } { } { }
6601 }
6602 }
6603 }
6604 }
6605 }
6606 % \end{macrocode}
6607 % \end{macro}
6608 %
6609 % \begin{macro}{\@@_scan_rule_attr:}
6610 % \begin{macrocode}
6611 \cs_new_protected:Npn \@@_scan_rule_attr:
6612 {
6613 \@@_scan_alt_rule:
6614 \@@_scan_keyword:nT { aAtTtTrR }
6615 { \@@_scan_pdf_ext_toks: }
6616 }
6617 % \end{macrocode}
6618 % \end{macro}
6619 %
6620 % \begin{macro}{\@@_scan_action:}
6621 % \begin{macrocode}
6622 \cs_new_protected:Npn \@@_scan_action:
6623 {
6624 \@@_scan_keyword:nTF { uUsSeErR }
6625 { \@@_scan_pdf_ext_toks: }
6626 {
6627 \@@_scan_keyword:nF { gGoOtToO }
6628 {
6629 \@@_scan_keyword:nF { tThHrReEaAdD }
6630 { \@@_error:nnnnn { action-type-missing } { } { } { } { } }
6631 }
6632 }
6633 \@@_scan_keyword:nT { fFiIlLeE }
6634 { \@@_scan_pdf_ext_toks: }
6635 \@@_scan_keyword:nTF { pPaAgGeE }
6636 {
6637 \@@_scan_int:
6638 \@@_scan_pdf_ext_toks:
6639 }
6640 {
6641 \@@_scan_keyword:nTF { nNaAmMeE }
6642 { \@@_scan_pdf_ext_toks: }
6643 {
6644 \@@_scan_keyword:nTF { nNuUmM }
6645 { \@@_scan_int: }
6646 { \@@_error:nnnnn { identifier-type-missing } { } { } { } { } }
6647 }
6648 }
6649 \@@_scan_keyword:nTF { nNeEwWwWiInNdDoOwW }
6650 { \@@_skip_optional_space: }
6651 {
6652 \@@_scan_keyword:nT { nNoOnNeEwWwWiInNdDoOwW }
6653 { \@@_skip_optional_space: }
6654 }
6655 }
6656 % \end{macrocode}
6657 % \end{macro}
6658 %
6659 % \begin{macro}{\@@_scan_image:}
6660 % Used by \tn{pdfximage}.
6661 % \begin{macrocode}
6662 \cs_new_protected:Npn \@@_scan_image:
6663 {
6664 \@@_scan_rule_attr:
6665 \@@_scan_keyword:nTF { nNaAmMeEdD }
6666 { \@@_scan_pdf_ext_toks: }
6667 {
6668 \@@_scan_keyword:nT { pPaAgGeE }
6669 { \@@_scan_int: }
6670 }
6671 \@@_scan_keyword:nT { cCoOlLoOrRsSpPaAcCeE }
6672 { \@@_scan_int: }
6673 \@@_scan_pdf_ext_toks:
6674 }
6675 % \end{macrocode}
6676 % \end{macro}
6677 %
6678 % \begin{macro}{\@@_scan_immediate_operands:}
6679 % \begin{macrocode}
6680 \cs_new_protected:Npn \@@_scan_immediate_operands:
6681 {
6682 \@@_get_x_next:
6683 \@@_set_cmd:
6684 \int_compare:nNnTF
6685 \l_@@_head_cmd_int = { \@@_tex_use:n { extension } }
6686 {
6687 \int_compare:nNnTF
6688 \l_@@_head_char_int < { 3 } % openout, write, closeout
6689 { \@@_scan_immediate_operands_aux: }
6690 {
6691 \int_case:nnF \l_@@_head_char_int
6692 {
6693 { 7 } { \@@_scan_extension_operands_aux: } % pdfobj
6694 { 9 }
6695 {
6696 \@@_prepare_mag:
6697 \@@_scan_extension_operands_aux:
6698 } % pdfxform
6699 { 11 } { \@@_scan_extension_operands_aux: } %pdfximage
6700 }
6701 { \@@_scan_immediate_operands_bad: }
6702 }
6703 }
6704 { \@@_scan_immediate_operands_bad: }
6705 }
6706 \cs_new_protected:Npn \@@_scan_immediate_operands_aux:
6707 {
6708 \@@_prev_input:V \l_@@_head_tl
6709 \@@_scan_extension_operands:
6710 }
6711 \cs_new_protected:Npn \@@_scan_immediate_operands_bad:
6712 {
6713 \@@_back_input:
6714 \@@_prev_input_gpop:N \l_@@_head_tl
6715 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl ignored }
6716 \@@_prev_input_gpush:
6717 }
6718
6719 % \end{macrocode}
6720 % \end{macro}
6721 %
6722 % \begin{macro}{\@@_scan_pdfdest_operands:}
6723 % \begin{macrocode}
6724 \cs_new_protected:Npn \@@_scan_pdfdest_operands:
6725 {
6726 \@@_scan_keyword:nTF { nNuUmM }
6727 { \@@_scan_int: }
6728 {
6729 \@@_scan_keyword:nTF { nNaAmMeE }
6730 { \@@_scan_pdf_ext_toks: }
6731 { \@@_error:nnnnn { identifier-type-missing } { } { } { } { } }
6732 }
6733 \@@_scan_keyword:nTF { xXyYzZ }
6734 {
6735 \@@_scan_keyword:nT { zZoOoOmM }
6736 { \@@_scan_int: }
6737 }
6738 {
6739 \@@_scan_keyword:nF { fFiItTbBhH }
6740 {
6741 \@@_scan_keyword:nF { fFiItTbBvV }
6742 {
6743 \@@_scan_keyword:nF { fFiItTbB }
6744 {
6745 \@@_scan_keyword:nF { fFiItThHhH }
6746 {
6747 \@@_scan_keyword:nF { fFiItTvV }
6748 {
6749 \@@_scan_keyword:nTF
6750 { fFiItTrR }
6751 {
6752 \@@_skip_optional_space:
6753 \@@_scan_alt_rule:
6754 \use_none:n
6755 }
6756 {
6757 \@@_scan_keyword:nF
6758 { fFiItT }
6759 {
6760 \@@_error:nnnnn { destination-type-missing }
6761 { } { } { } { }
6762 }
6763 }
6764 }
6765 }
6766 }
6767 }
6768 }
6769 }
6770 \@@_skip_optional_space:
6771 }
6772 % \end{macrocode}
6773 % \end{macro}
6774 %
6775 % \subsubsection{Assignments}
6776 %
6777 % Quoting \texttt{tex.web}: ``Every prefix, and every command code that
6778 % might or might not be prefixed, calls the action procedure
6779 % |prefixed_command|. This routine accumulates a sequence of prefixes
6780 % until coming to a non-prefix, then it carries out the command.''
6781 % We define all those commands in one go, from
6782 % |max_non_prefixed_command+1=71| to |max_command=102|.
6783 % \begin{macrocode}
6784 \cs_set_protected:Npn \@@_tmp:w
6785 {
6786 \@@_prev_input_gpush:
6787 \@@_prefixed_command:
6788 }
6789 \int_step_inline:nnnn
6790 { \@@_tex_use:n { max_non_prefixed_command } + 1 }
6791 { 1 }
6792 { \@@_tex_use:n { max_command } }
6793 { \cs_new_eq:cN { @@_cmd_#1: } \@@_tmp:w }
6794 % \end{macrocode}
6795 %
6796 % \begin{macro}{\@@_prefixed_command:}
6797 % Accumulated prefix codes so far are stored as the last item of
6798 % the previous-input sequence.
6799 % \begin{macrocode}
6800 \cs_new_protected:Npn \@@_prefixed_command:
6801 {
6802 \int_while_do:nNnn
6803 \l_@@_head_cmd_int = { \@@_tex_use:n { prefix } }
6804 {
6805 \@@_prev_input:V \l_@@_head_tl
6806 \@@_get_x_non_relax:
6807 \@@_set_cmd:
6808 \int_compare:nNnF \l_@@_head_cmd_int
6809 > { \@@_tex_use:n { max_non_prefixed_command } }
6810 {
6811 \@@_prev_input_gpop:N \l_@@_tmpa_tl
6812 \@@_error:neeee { erroneous-prefixes }
6813 { \tl_to_str:N \l_@@_tmpa_tl }
6814 { \tl_to_str:N l_@@_head_tl }
6815 { } { }
6816 \@@_back_input:
6817 \@@_omit_after_assignment:w
6818 }
6819 }
6820 % ^^A todo: Discard non-\global prefixes if they are irrelevant
6821 % ^^A todo: Adjust for the setting of \globaldefs
6822 \cs_if_exist_use:cF
6823 { @@_prefixed_ \int_use:N \l_@@_head_cmd_int : }
6824 {
6825 \@@_error:nnnnn { internal } { prefixed } { } { } { }
6826 \@@_omit_after_assignment:w
6827 }
6828 \@@_after_assignment:
6829 }
6830 % \end{macrocode}
6831 % \end{macro}
6832 % We now need to implement prefixed commands, for command codes in the
6833 % range $[71,102]$, with the exception of |prefix=93|, which would have
6834 % been collected by the \cs{@@_prefixed_command:} loop.
6835 %
6836 % \begin{macro}{\@@_after_assignment:}
6837 % \begin{macro}{\@@_omit_after_assignment:w}
6838 % ^^A todo: simplify
6839 % \begin{macrocode}
6840 \cs_new_protected:Npn \@@_after_assignment:
6841 {
6842 \@@_back_input_gtl:N \g_@@_after_assignment_gtl
6843 \gtl_gclear:N \g_@@_after_assignment_gtl
6844 }
6845 \cs_new_protected:Npn \@@_omit_after_assignment:w
6846 #1 \@@_after_assignment: { }
6847 % \end{macrocode}
6848 % \end{macro}
6849 % \end{macro}
6850 %
6851 % \begin{macro}{\@@_prefixed_new:nn}
6852 % \begin{macrocode}
6853 \cs_new_protected:Npn \@@_prefixed_new:nn #1#2
6854 {
6855 \cs_new_protected:cpn
6856 { @@_prefixed_ \@@_tex_use:n {#1} : } {#2}
6857 }
6858 % \end{macrocode}
6859 % \end{macro}
6860 %
6861 % \begin{macro}{\@@_assign_token:n}
6862 % \begin{macrocode}
6863 \cs_new_protected:Npn \@@_assign_token:n #1
6864 {
6865 \@@_prev_input_gpop:N \l_@@_head_tl
6866 #1
6867 \tl_use:N \l_@@_head_tl \scan_stop:
6868 \@@_print_assigned_token:
6869 }
6870 % \end{macrocode}
6871 % \end{macro}
6872 %
6873 % \begin{macro}{\@@_assign_register:}
6874 % \begin{macrocode}
6875 \cs_new_protected:Npn \@@_assign_register:
6876 {
6877 \@@_prev_input_gpop:N \l_@@_head_tl
6878 \tl_use:N \l_@@_head_tl \scan_stop:
6879 \@@_print_assigned_register:
6880 }
6881 % \end{macrocode}
6882 % \end{macro}
6883 %
6884 % \begin{macro}{\@@_assign_value:nn}
6885 % \begin{macrocode}
6886 \cs_new_protected:Npn \@@_assign_value:nn #1#2
6887 {
6888 \tl_if_empty:nF {#1}
6889 {
6890 \@@_prev_input_gpush:N \l_@@_head_tl
6891 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
6892 #1
6893 \@@_prev_input_gpop:N \l_@@_head_tl
6894 }
6895 \@@_prev_input:V \l_@@_head_tl
6896 \tl_set_eq:NN \l_@@_defined_tl \l_@@_head_tl
6897 \@@_scan_optional_equals:
6898 #2
6899 \@@_assign_register:
6900 }
6901 % \end{macrocode}
6902 % \end{macro}
6903 %
6904 % \begin{macro}{\@@_assign_toks:}
6905 % \begin{macrocode}
6906 \@@_prefixed_new:nn { toks_register } % 71
6907 {
6908 \int_compare:nNnT \l_@@_head_char_int = 0
6909 { % \toks
6910 \@@_prev_input_gpush:N \l_@@_head_tl
6911 \@@_print_action:
6912 \@@_scan_int:
6913 \@@_prev_input_gpop:N \l_@@_head_tl
6914 }
6915 \@@_assign_toks:
6916 }
6917 \@@_prefixed_new:nn { assign_toks } % 72
6918 { \@@_assign_toks: }
6919 \cs_new_protected:Npn \@@_assign_toks:
6920 {
6921 \@@_prev_input_silent:V \l_@@_head_tl
6922 \@@_print_action:
6923 \tl_set_eq:NN \l_@@_defined_tl \l_@@_head_tl
6924 \@@_scan_optional_equals:
6925 \@@_get_x_non_relax:
6926 \@@_set_cmd:
6927 \int_compare:nNnTF
6928 \l_@@_head_cmd_int = { \@@_tex_use:n { toks_register } }
6929 {
6930 \@@_prev_input:V \l_@@_head_tl
6931 \int_compare:nNnT \l_@@_head_char_int = 0
6932 { \@@_scan_int: }
6933 }
6934 {
6935 \int_compare:nNnTF
6936 \l_@@_head_cmd_int = { \@@_tex_use:n { assign_toks } }
6937 { \@@_prev_input:V \l_@@_head_tl }
6938 {
6939 \@@_back_input:
6940 \@@_scan_toks:NN \c_false_bool \c_false_bool
6941 }
6942 }
6943 \@@_assign_register:
6944 }
6945 % \end{macrocode}
6946 % \end{macro}
6947 %
6948 % \begin{macrocode}
6949 \@@_prefixed_new:nn { assign_int } % 73
6950 { \@@_assign_value:nn { } { \@@_scan_int: } }
6951 \@@_prefixed_new:nn { assign_dimen } % 74
6952 { \@@_assign_value:nn { } { \@@_scan_normal_dimen: } }
6953 \@@_prefixed_new:nn { assign_glue } % 75
6954 { \@@_assign_value:nn { } { \@@_scan_normal_glue: } }
6955 \@@_prefixed_new:nn { assign_mu_glue } % 76
6956 { \@@_assign_value:nn { } { \@@_scan_mu_glue: } }
6957 \@@_prefixed_new:nn { assign_font_dimen } % 77
6958 {
6959 \@@_assign_value:nn
6960 { \@@_scan_int: \@@_scan_font_ident: }
6961 { \@@_scan_normal_dimen: }
6962 }
6963 \@@_prefixed_new:nn { assign_font_int } % 78
6964 {
6965 \@@_assign_value:nn
6966 { \@@_scan_font_int: } { \@@_scan_int: }
6967 }
6968 \@@_prefixed_new:nn { set_aux } % 79
6969 { % prevdepth = 1, spacefactor = 102
6970 \int_compare:nNnTF \l_@@_head_char_int = 1
6971 { \@@_assign_value:nn { } { \@@_scan_normal_dimen: } }
6972 { \@@_assign_value:nn { } { \@@_scan_int: } }
6973 }
6974 \@@_prefixed_new:nn { set_prev_graf } % 80
6975 { \@@_assign_value:nn { } { \@@_scan_int: } }
6976 \@@_prefixed_new:nn { set_page_dimen } % 81
6977 { \@@_assign_value:nn { } { \@@_scan_normal_dimen: } }
6978 \@@_prefixed_new:nn { set_page_int } % 82
6979 { \@@_assign_value:nn { } { \@@_scan_int: } }
6980 \@@_prefixed_new:nn { set_box_dimen } % 83
6981 {
6982 \@@_assign_value:nn
6983 { \@@_scan_int: } { \@@_scan_normal_dimen: }
6984 }
6985 % \end{macrocode}
6986 %
6987 % This is a variant of \cs{@@_assign_value:nn}, with a bit more complication
6988 % because the syntax of \tn{parshape} and of \eTeX{} primitives such as
6989 % \tn{interlinepenalties} is a bit different.
6990 % \begin{macrocode}
6991 \@@_prefixed_new:nn { set_shape } % 84
6992 {
6993 \@@_prev_input:V \l_@@_head_tl
6994 \tl_set_eq:NN \l_@@_defined_tl \l_@@_head_tl
6995 \tl_if_head_eq_meaning:VNTF \l_@@_defined_tl \tex_parshape:D
6996 {
6997 \@@_set_shape:NN 2 \@@_scan_normal_dimen:
6998 \@@_print_assigned_parshape:
6999 }
7000 {
7001 \@@_set_shape:NN 1 \@@_scan_int:
7002 \@@_print_assigned_set_shape:
7003 }
7004 }
7005 \cs_new_protected:Npn \@@_set_shape:NN #1#2
7006 {
7007 \@@_scan_optional_equals:
7008 \@@_prev_input_gpush:
7009 \@@_scan_int:
7010 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7011 \@@_prev_input_silent:V \l_@@_tmpa_tl
7012 \prg_replicate:nn
7013 { \int_max:nn { 0 } { #1 * \l_@@_tmpa_tl } }
7014 { \@@_prev_input_silent:n { ~ } #2 }
7015 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7016 \tl_use:N \l_@@_tmpa_tl \scan_stop:
7017 }
7018 % \end{macrocode}
7019 %
7020 % \begin{macrocode}
7021 \@@_prefixed_new:nn { def_code } % 85
7022 {
7023 \@@_assign_value:nn
7024 { \@@_scan_int: } { \@@_scan_int: }
7025 }
7026 \@@_prefixed_new:nn { def_family } % 86
7027 {
7028 \@@_assign_value:nn
7029 { \@@_scan_int: } { \@@_scan_font_ident: }
7030 }
7031 \@@_prefixed_new:nn { set_font } % 87
7032 {
7033 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7034 \tl_put_left:NV \l_@@_head_tl \l_@@_tmpa_tl
7035 \tl_use:N \l_@@_head_tl \scan_stop:
7036 \gtl_gput_right:NV \g_@@_output_gtl \l_@@_head_tl
7037 \@@_print_action:
7038 }
7039 \@@_prefixed_new:nn { def_font } % 88
7040 {
7041 \@@_prev_input_silent:V \l_@@_head_tl
7042 \@@_set_action_text:e { \tl_to_str:N \l_@@_head_tl }
7043 \@@_scan_r_token:
7044 \@@_print_action:e
7045 { \g_@@_action_text_str \tl_to_str:N \l_@@_defined_tl }
7046 \@@_scan_optional_equals:
7047 \@@_scan_file_name:
7048 \bool_gset_true:N \g_@@_name_in_progress_bool
7049 \@@_scan_keyword:nTF { aAtT }
7050 { \@@_scan_normal_dimen: }
7051 {
7052 \@@_scan_keyword:nT { sScCaAlLeEdD }
7053 { \@@_scan_int: }
7054 }
7055 \bool_gset_false:N \g_@@_name_in_progress_bool
7056 \@@_assign_token:n { }
7057 }
7058 % \end{macrocode}
7059 %
7060 % |register=89|, |advance=90|, |multiply=91|, |divide=92| are
7061 % implemented elsewhere. |prefix=93| is never needed (see explanation
7062 % above).
7063 %
7064 % |let|, |futurelet|
7065 % \begin{macrocode}
7066 \@@_prefixed_new:nn { let } % 94
7067 {
7068 \@@_prev_input_gpush:N \l_@@_head_tl
7069 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_let:D
7070 { % |let|
7071 \@@_scan_r_token:
7072 \@@_prev_input_get:N \l_@@_tmpa_tl
7073 \@@_print_action:e { \tl_to_str:N \l_@@_tmpa_tl }
7074 \@@_get_next:
7075 \bool_while_do:nn
7076 { \token_if_eq_catcode_p:NN \l_@@_head_token \c_space_token }
7077 { \@@_get_next: }
7078 \tl_if_eq:NNT \l_@@_head_tl \c_@@_eq_tl
7079 { \@@_get_next: }
7080 \token_if_eq_catcode:NNT \l_@@_head_token \c_space_token
7081 { \@@_get_next: }
7082 }
7083 { % |futurelet|
7084 \@@_scan_r_token:
7085 \@@_prev_input_get:N \l_@@_tmpa_tl
7086 \@@_print_action:e { \tl_to_str:N \l_@@_tmpa_tl }
7087 \@@_get_next:
7088 \gtl_set_eq:NN \l_@@_tmpb_gtl \l_@@_head_gtl
7089 \@@_get_next:
7090 \@@_back_input:
7091 \gtl_set_eq:NN \l_@@_head_gtl \l_@@_tmpb_gtl
7092 \@@_back_input:
7093 }
7094 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7095 \tl_put_right:Nn \l_@@_tmpa_tl { = ~ \l_@@_head_token }
7096 \@@_prev_input_gpop:N \l_@@_head_tl
7097 \use:e
7098 {
7099 \exp_not:V \l_@@_head_tl
7100 \tex_let:D \tl_tail:N \l_@@_tmpa_tl
7101 }
7102 \@@_print_assigned_token:
7103 }
7104 % \end{macrocode}
7105 %
7106 % \begin{macrocode}
7107 \@@_prefixed_new:nn { shorthand_def } % 95
7108 {
7109 \@@_prev_input_silent:V \l_@@_head_tl
7110 \tl_set:Ne \l_@@_prev_action_tl
7111 { \tl_to_str:N \l_@@_head_tl }
7112 \@@_scan_r_token:
7113 \@@_print_action:e
7114 { \l_@@_prev_action_tl \tl_to_str:N \l_@@_defined_tl }
7115 \exp_after:wN \cs_set_eq:NN \l_@@_defined_tl \scan_stop:
7116 \@@_just_print_assigned_token:
7117 \@@_scan_optional_equals:
7118 \@@_scan_int:
7119 \@@_assign_token:n { }
7120 }
7121 % \end{macrocode}
7122 %
7123 % \begin{macro}[EXP]{\@@_read_to_cs_safe:nTF, \@@_read_to_cs_safe:fTF}
7124 % After \tn{read} or \tn{readline}, find an int, the mandatory
7125 % keyword |to|, and an assignable token. The \tn{read} and
7126 % \tn{readline} primitives throw a fatal error in \tn{nonstopmode}
7127 % and in \tn{batchmode} when trying to read from a stream that is
7128 % outside $[0,15]$ or that is not open (according to \tn{ifeof}). We
7129 % detect this situation using \cs{@@_read_to_cs_safe:nTF} after
7130 % grabbing all arguments of the primitives. If reading is unsafe,
7131 % let the user know that \TeX{} would have thrown a fatal error.
7132 % \begin{macrocode}
7133 \@@_prefixed_new:nn { read_to_cs } % 96
7134 {
7135 \@@_prev_input_silent:V \l_@@_head_tl
7136 \@@_print_action:e { \tl_to_str:N \l_@@_head_tl }
7137 \@@_scan_int:
7138 \@@_scan_to:
7139 \@@_scan_r_token:
7140 \@@_prev_input_get:N \l_@@_tmpa_tl
7141 \@@_read_to_cs_safe:fTF
7142 { \@@_tl_first_int:N \l_@@_tmpa_tl }
7143 { \@@_assign_token:n { } }
7144 {
7145 \@@_prev_input_gpop:N \l_@@_head_tl
7146 \@@_tex_fatal_error:nV { cannot-read } \l_@@_head_tl
7147 }
7148 }
7149 \prg_new_conditional:Npnn \@@_read_to_cs_safe:n #1 { TF }
7150 {
7151 \int_compare:nNnTF { \tex_interactionmode:D } > { 1 }
7152 { \prg_return_true: }
7153 {
7154 \int_compare:nNnTF {#1} < { 0 }
7155 { \prg_return_false: }
7156 {
7157 \int_compare:nNnTF {#1} > { 15 }
7158 { \prg_return_false: }
7159 {
7160 \tex_ifeof:D #1 \exp_stop_f:
7161 \prg_return_false:
7162 \else:
7163 \prg_return_true:
7164 \fi:
7165 }
7166 }
7167 }
7168 }
7169 \cs_generate_variant:Nn \@@_read_to_cs_safe:nTF { f }
7170 % \end{macrocode}
7171 % \end{macro}
7172 %
7173 % \begin{macrocode}
7174 \@@_prefixed_new:nn { def } % 97
7175 {
7176 \@@_prev_input_get:N \l_@@_tmpa_tl
7177 \tl_set:NV \l_@@_defining_tl \l_@@_tmpa_tl
7178 \tl_put_right:NV \l_@@_defining_tl \l_@@_head_tl
7179 \@@_prev_input_gpush:N \l_@@_head_tl
7180 \int_compare:nNnTF \l_@@_head_char_int < 2
7181 { % def/gdef
7182 \@@_scan_r_token:
7183 \tl_put_right:NV \l_@@_defining_tl \l_@@_defined_tl
7184 \@@_scan_toks:NN \c_true_bool \c_false_bool
7185 }
7186 { % edef/xdef
7187 \@@_scan_r_token:
7188 \tl_put_right:NV \l_@@_defining_tl \l_@@_defined_tl
7189 \@@_scan_toks:NN \c_true_bool \c_true_bool
7190 }
7191 \@@_prev_input_gpop:N \l_@@_head_tl
7192 \@@_prev_input:V \l_@@_head_tl
7193 \@@_assign_token:n
7194 { \tl_set_eq:NN \l_@@_head_tl \l_@@_defining_tl }
7195 }
7196 % \end{macrocode}
7197 %
7198 % \tn{setbox} is a bit special: directly put it in
7199 % the previous-input sequence with the prefixes; the box code will take
7200 % care of things, and expects a single item containing what it needs to
7201 % do.
7202 % \begin{macrocode}
7203 \@@_prefixed_new:nn { set_box } % 98
7204 {
7205 \@@_prev_input:V \l_@@_head_tl
7206 \@@_scan_int:
7207 \@@_scan_optional_equals:
7208 \bool_if:NTF \g_@@_set_box_allowed_bool
7209 { \@@_do_box:N \c_false_bool }
7210 {
7211 \@@_error:nnnnn { improper-setbox } { } { } { } { }
7212 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7213 \@@_omit_after_assignment:w
7214 }
7215 }
7216 % \end{macrocode}
7217 %
7218 % ^^A todo: \hyphenation{...{...}...} recovers weirdly (no nesting).
7219 % \tn{hyphenation} and \tn{patterns}
7220 % \begin{macrocode}
7221 \@@_prefixed_new:nn { hyph_data } % 99
7222 {
7223 \@@_prev_input:V \l_@@_head_tl
7224 \@@_scan_toks:NN \c_false_bool \c_false_bool
7225 \@@_assign_token:n { }
7226 }
7227 % \end{macrocode}
7228 %
7229 % \begin{macrocode}
7230 \@@_prefixed_new:nn { set_interaction } % 100
7231 {
7232 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7233 \tl_put_left:NV \l_@@_head_tl \l_@@_tmpa_tl
7234 \tl_use:N \l_@@_head_tl \scan_stop:
7235 \@@_print_assignment:e { \tl_to_str:N \l_@@_head_tl }
7236 }
7237 % \end{macrocode}
7238 %
7239 % \begin{macrocode}
7240 \@@_prefixed_new:nn { letterspace_font } % 101
7241 {
7242 \@@_prev_input_silent:V \l_@@_head_tl
7243 \@@_set_action_text:e { \tl_to_str:N \l_@@_head_tl }
7244 \@@_scan_r_token:
7245 \@@_print_action:e
7246 { \g_@@_action_text_str \tl_to_str:N \l_@@_defined_tl }
7247 \exp_after:wN \cs_set_eq:NN \l_@@_defined_tl \@@_nullfont:
7248 \@@_just_print_assigned_token:
7249 \@@_scan_optional_equals:
7250 \@@_scan_font_ident:
7251 \@@_scan_int:
7252 \@@_assign_token:n { }
7253 }
7254 % \end{macrocode}
7255 %
7256 % \begin{macrocode}
7257 \@@_prefixed_new:nn { pdf_copy_font } % 102
7258 {
7259 \@@_prev_input_silent:V \l_@@_head_tl
7260 \@@_set_action_text:e { \tl_to_str:N \l_@@_head_tl }
7261 \@@_scan_r_token:
7262 \@@_print_action:e
7263 { \g_@@_action_text_str \tl_to_str:N \l_@@_defined_tl }
7264 \exp_after:wN \cs_set_eq:NN \l_@@_defined_tl \@@_nullfont:
7265 \@@_just_print_assigned_token:
7266 \@@_scan_optional_equals:
7267 \@@_scan_font_ident:
7268 \@@_assign_token:n { }
7269 }
7270 % \end{macrocode}
7271 %
7272 % Changes to numeric registers (\tn{count}, \tn{dimen}, \tn{skip},
7273 % \tn{muskip}, and commands with a built-in number).
7274 % \begin{macrocode}
7275 \@@_prefixed_new:nn { register } % 89
7276 { \@@_do_register:N 0 }
7277 \@@_prefixed_new:nn { advance } % 90
7278 { \@@_do_operation:N 1 }
7279 \@@_prefixed_new:nn { multiply } % 91
7280 { \@@_do_operation:N 2 }
7281 \@@_prefixed_new:nn { divide } % 92
7282 { \@@_do_operation:N 3 }
7283 % \end{macrocode}
7284 %
7285 % \begin{macro}{\@@_do_operation:N, \@@_do_operation_fail:w}
7286 % \begin{macrocode}
7287 \cs_new_protected:Npn \@@_do_operation:N #1
7288 {
7289 \@@_prev_input_silent:V \l_@@_head_tl
7290 \@@_print_action:
7291 \@@_get_x_next:
7292 \@@_set_cmd:
7293 \int_compare:nNnTF
7294 \l_@@_head_cmd_int > { \@@_tex_use:n { assign_mu_glue } }
7295 {
7296 \int_compare:nNnTF
7297 \l_@@_head_cmd_int = { \@@_tex_use:n { register } }
7298 { \@@_do_register:N #1 }
7299 { \@@_do_operation_fail:w }
7300 }
7301 {
7302 \int_compare:nNnTF
7303 \l_@@_head_cmd_int < { \@@_tex_use:n { assign_int } }
7304 { \@@_do_operation_fail:w }
7305 {
7306 \@@_prev_input:V \l_@@_head_tl
7307 \exp_args:NNf \@@_do_register_set:Nn #1
7308 {
7309 \int_eval:n
7310 {
7311 \l_@@_head_cmd_int
7312 - \@@_tex_use:n { assign_toks }
7313 }
7314 }
7315 }
7316 }
7317 }
7318 \cs_new_protected:Npn \@@_do_operation_fail:w
7319 {
7320 \@@_error:nnnnn { after-advance } { } { } { } { }
7321 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7322 \@@_omit_after_assignment:w
7323 }
7324 % \end{macrocode}
7325 % \end{macro}
7326 %
7327 % \begin{macro}{\@@_do_register:N, \@@_do_register_aux:Nn}
7328 % \begin{macrocode}
7329 \cs_new_protected:Npn \@@_do_register:N #1
7330 {
7331 \exp_args:NNV \@@_do_register_aux:Nn #1
7332 \l_@@_head_char_int
7333 }
7334 \cs_new_protected:Npn \@@_do_register_aux:Nn #1#2
7335 {
7336 \int_compare:nNnTF { \tl_tail:n {#2} } = 0
7337 {
7338 \@@_prev_input_gpush:N \l_@@_head_tl
7339 \@@_print_assignment:
7340 \@@_scan_int:
7341 \@@_prev_input_gpop:N \l_@@_head_tl
7342 \@@_prev_input_silent:V \l_@@_head_tl
7343 }
7344 {
7345 \@@_prev_input_silent:V \l_@@_head_tl
7346 \@@_print_assignment:
7347 }
7348 \tl_set_eq:NN \l_@@_defined_tl \l_@@_head_tl
7349 \exp_args:NNf \@@_do_register_set:Nn #1
7350 { \int_eval:n { #2 / 1 000 000 } }
7351 }
7352 % \end{macrocode}
7353 % \end{macro}
7354 %
7355 % \begin{macro}{\@@_do_register_set:Nn}
7356 % \begin{macrocode}
7357 \cs_new_protected:Npn \@@_do_register_set:Nn #1#2
7358 {
7359 \int_compare:nNnTF {#1} = 0
7360 { % truly register command
7361 \@@_scan_optional_equals:
7362 }
7363 { % \advance, \multiply, \divide
7364 \@@_scan_keyword:nF { bByY }
7365 { \@@_prev_input_silent:n { by } }
7366 }
7367 \int_compare:nNnTF {#1} < 2
7368 {
7369 \int_case:nnF {#2}
7370 {
7371 { 1 } { \@@_scan_int: } % count
7372 { 2 } { \@@_scan_normal_dimen: } % dim
7373 { 3 } { \@@_scan_normal_glue: } % glue
7374 { 4 } { \@@_scan_mu_glue: } % muglue
7375 }
7376 { \@@_error:neeee { internal } { do-reg=#2 } { } { } { } }
7377 }
7378 { \@@_scan_int: }
7379 \@@_assign_register:
7380 }
7381 % \end{macrocode}
7382 % \end{macro}
7383 %
7384 % The following is used for instance when making accents.
7385 % \begin{macrocode}
7386 \cs_new_protected:Npn \@@_do_assignments:
7387 {
7388 \@@_get_x_non_relax:
7389 \@@_set_cmd:
7390 \int_compare:nNnT
7391 \l_@@_head_cmd_int
7392 > { \@@_tex_use:n { max_non_prefixed_command } }
7393 {
7394 \bool_gset_false:N \g_@@_set_box_allowed_bool
7395 \@@_prev_input_gpush:
7396 \@@_prefixed_command:
7397 \bool_gset_true:N \g_@@_set_box_allowed_bool
7398 \@@_do_assignments:
7399 }
7400 }
7401 % \end{macrocode}
7402 %
7403 % \subsection{Expandable primitives}
7404 %
7405 % This section implements expandable primitives, which have the
7406 % following command codes:
7407 % \begin{itemize}
7408 % \item |undefined_cs=103| for undefined control sequences (not quite a
7409 % primitive).
7410 % \item |expand_after=104| for \tn{expandafter} and \tn{unless}.
7411 % \item |no_expand=105| for \tn{noexpand} and \tn{pdfprimitive}.
7412 % \item |input=106| for \tn{input}, \tn{endinput} and \tn{scantokens}.
7413 % \item |if_test=107| for the conditionals, \tn{if}, \tn{ifcat},
7414 % \tn{ifnum}, \tn{ifdim}, \tn{ifodd}, \tn[index=ifhmode]{if[vhm]mode},
7415 % \tn[index=iftdir]{if[tydm]dir},
7416 % \tn{ifinner}, \tn{ifvoid}, \tn[index=ifhbox]{if[hvtydm]box},
7417 % \tn{ifx}, \tn{ifeof}, \tn{iftrue}, \tn{iffalse}, \tn{ifcase},
7418 % \tn{ifdefined}, \tn{ifcsname}, \tn{iffontchar}, \tn{ifincsname},
7419 % \tn{ifprimitive}, \tn{ifabsnum}, \tn{ifabsdim}, \tn{ifjfont}, \tn{iftfont}.
7420 % \item |fi_or_else=108| for \tn{fi}, \tn{else} and \tn{or}.
7421 % \item |cs_name=109| for \tn{csname} and \tn{lastnamedcs}.
7422 % \item |convert=110| for \tn{number}, \tn{romannumeral}, \tn{string},
7423 % \tn{meaning}, \tn{fontname}, \tn{eTeXrevision}, \tn{pdftexrevision},
7424 % \tn{pdftexbanner}, \tn{pdffontname}, \tn{pdffontobjnum},
7425 % \tn{pdffontsize}, \tn{pdfpageref}, \tn{pdfxformname},
7426 % \tn{pdfescapestring}, \tn{pdfescapename}, \tn{leftmarginkern},
7427 % \tn{rightmarginkern}, \tn{pdfstrcmp}, \tn{pdfcolorstackinit},
7428 % \tn{pdfescapehex}, \tn{pdfunescapehex}, \tn{pdfcreationdate},
7429 % \tn{pdffilemoddate}, \tn{pdffilesize}, \tn{pdfmdfivesum},
7430 % \tn{pdffiledump}, \tn{pdfmatch}, \tn{pdflastmatch},
7431 % \tn{pdfuniformdeviate}, \tn{pdfnormaldeviate}, \tn{pdfinsertht},
7432 % \tn{pdfximagebbox}, \tn{jobname}, \tn{expanded}, and in
7433 % \LuaTeX{} \tn{directlua}, \tn{luaescapestring}, and in \XeTeX{}/(u)p\TeX{} \tn{Ucharcat}.
7434 % \item |the=111| for \tn{the}, \tn{unexpanded}, and \tn{detokenize}.
7435 % \item |top_bot_mark=112| \tn{topmark}, \tn{firstmark}, \tn{botmark},
7436 % \tn{splitfirstmark}, \tn{splitbotmark}, \tn{topmarks},
7437 % \tn{firstmarks}, \tn{botmarks}, \tn{splitfirstmarks}, and
7438 % \tn{splitbotmarks}.
7439 % \item |call=113| for macro calls, implemented by \cs{@@_macro_call:}.
7440 % \item |end_template=117| for \TeX{}'s end template.
7441 % \end{itemize}
7442 %
7443 % Let \TeX{} trigger an error.
7444 % \begin{macrocode}
7445 \@@_new_tex_expandable:nn { undefined_cs } % 103
7446 { \tl_use:N \l_@@_head_tl \@@_print_expansion: }
7447 % \end{macrocode}
7448 %
7449 % \begin{macro}{\@@_expandafter:, \@@_unless:, \@@_unless_bad:}
7450 % \begin{macrocode}
7451 \@@_new_tex_expandable:nn { expand_after } % 104
7452 {
7453 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_expandafter:D
7454 { \@@_expandafter: } { \@@_unless: }
7455 }
7456 \cs_new_protected:Npn \@@_expandafter:
7457 {
7458 \gtl_set_eq:NN \l_@@_tmpb_gtl \l_@@_head_gtl
7459 \@@_get_next:
7460 \gtl_concat:NNN \l_@@_head_gtl
7461 \l_@@_tmpb_gtl \l_@@_head_gtl
7462 \@@_prev_input_gpush_gtl:N \l_@@_head_gtl
7463 \@@_print_expansion:e { \gtl_to_str:N \l_@@_head_gtl }
7464 \@@_get_next:
7465 \@@_token_if_expandable:NTF \l_@@_head_token
7466 { \@@_expand_do:N \prg_do_nothing: }
7467 { \@@_back_input: }
7468 \@@_prev_input_gpop_gtl:N \l_@@_head_gtl
7469 \@@_set_action_text:e
7470 { back_input: ~ \gtl_to_str:N \l_@@_head_gtl }
7471 \gtl_pop_left:N \l_@@_head_gtl
7472 \@@_back_input:
7473 \@@_print_expansion:
7474 }
7475 \cs_new_protected:Npn \@@_unless:
7476 {
7477 \gtl_set_eq:NN \l_@@_tmpb_gtl \l_@@_head_gtl
7478 \@@_get_token:
7479 \int_compare:nNnTF
7480 \l_@@_head_cmd_int = { \@@_tex_use:n { if_test } }
7481 {
7482 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_ifcase:D
7483 { \@@_unless_bad: }
7484 {
7485 \tl_put_left:Ne \l_@@_head_tl
7486 { \gtl_head_do:NN \l_@@_tmpb_gtl \exp_not:N }
7487 \@@_expand_nonmacro:
7488 }
7489 }
7490 { \@@_unless_bad: }
7491 }
7492 \cs_new_protected:Npn \@@_unless_bad:
7493 {
7494 \@@_error:nnnnn { bad-unless } { } { } { } { }
7495 \@@_back_input:
7496 }
7497 % \end{macrocode}
7498 % \end{macro}
7499 %
7500 % \begin{macro}{\@@_noexpand:N, \@@_noexpand_after:, \@@_pdfprimitive:}
7501 % Currently not fully implemented.
7502 %
7503 % The argument of \cs{@@_noexpand:N} is \cs{prg_do_nothing:} when
7504 % \tn{noexpand} is hit by \tn{expandafter}; otherwise it is one of
7505 % various loop commands (\cs{@@_get_x_next:},
7506 % \cs{@@_get_x_or_protected:}, \cs{@@_get_token_xdef:},
7507 % \cs{@@_get_token_x:}) that would call \cs{@@_get_next:} and possibly
7508 % expand the token more. For these cases we simply stop after
7509 % \cs{@@_get_next:} and if the token is expandable we pretend its
7510 % meaning is \tn{relax}.
7511 %
7512 % The case of \tn{expandafter} (so \cs{prg_do_nothing:}) is tougher.
7513 % Do nothing if the next token is an explicit non-active character
7514 % (begin-group and end-group characters are detected by
7515 % \cs{l_@@_head_tl}, the rest by testing if the token is definable).
7516 % Otherwise the token must be marked with \cs{notexpanded:} (even if
7517 % the token is currently a non-expandable primitive, as its meaning
7518 % can be changed by the code skipped over by \tn{expandafter}). That
7519 % \cs{notexpanded:} marker should be removed if the token is taken as
7520 % the argument of a macro, but we fail to do that. We set the
7521 % \cs{notexpanded:\ldots{}} command to be a special \tn{relax} marker
7522 % to make it quickly recognizable in \cs{@@_get_next:}. This is
7523 % incidentally the same meaning used by \TeX{} for expandable commands.
7524 % \begin{macrocode}
7525 \@@_new_tex_expandable:nn { no_expand } % 105
7526 {
7527 \token_if_eq_meaning:NNTF \l_@@_head_token \tex_noexpand:D
7528 { \@@_noexpand:N }
7529 { \@@_pdfprimitive: }
7530 }
7531 \cs_new_protected:Npn \@@_noexpand:N #1
7532 {
7533 \@@_get_token:
7534 \cs_if_eq:NNTF #1 \prg_do_nothing:
7535 {
7536 \tl_if_empty:NTF \l_@@_head_tl
7537 { \@@_back_input: }
7538 {
7539 \exp_after:wN \@@_token_if_definable:NTF \l_@@_head_tl
7540 { \@@_noexpand_after: }
7541 { \@@_back_input: }
7542 }
7543 }
7544 {
7545 \@@_back_input:
7546 \@@_get_next:
7547 \@@_token_if_expandable:NT \l_@@_head_token
7548 { \cs_set_eq:NN \l_@@_head_token \@@_special_relax: }
7549 }
7550 }
7551 \cs_new_protected:Npn \@@_noexpand_after:
7552 {
7553 \group_begin:
7554 \@@_set_escapechar:n { 92 }
7555 \exp_args:NNc
7556 \group_end:
7557 \@@_noexpand_after:N
7558 { notexpanded: \exp_after:wN \token_to_str:N \l_@@_head_tl }
7559 }
7560 \cs_new_protected:Npn \@@_noexpand_after:N #1
7561 {
7562 \cs_gset_eq:NN #1 \@@_special_relax:
7563 \@@_back_input:n {#1}
7564 }
7565 \cs_new_protected:Npn \@@_pdfprimitive:
7566 { \@@_not_implemented:n { pdfprimitive } }
7567 % \end{macrocode}
7568 % \end{macro}
7569 %
7570 % \begin{macro}{\@@_endinput:, \@@_scantokens:, \@@_input:}
7571 % \begin{macrocode}
7572 \@@_new_tex_expandable:nn { input } % 106
7573 {
7574 \int_case:nnF \l_@@_head_char_int
7575 {
7576 { 1 } { \@@_endinput: } % \endinput
7577 { 2 } { \@@_scantokens: } % \scantokens
7578 }
7579 { % 0=\input
7580 \bool_if:NTF \g_@@_name_in_progress_bool
7581 { \@@_insert_relax: } { \@@_input: }
7582 }
7583 }
7584 \cs_new_protected:Npn \@@_endinput:
7585 {
7586 \group_begin:
7587 \msg_warning:nn { unravel } { endinput-ignored }
7588 \group_end:
7589 \@@_print_expansion:
7590 }
7591 \cs_new_protected:Npn \@@_scantokens:
7592 {
7593 \@@_prev_input_gpush:
7594 \@@_scan_toks:NN \c_false_bool \c_false_bool
7595 \@@_prev_input_gpop:N \l_@@_tmpa_tl
7596 \exp_last_unbraced:NNNo \tl_set_rescan:Nnn
7597 \l_@@_head_tl \prg_do_nothing: \l_@@_tmpa_tl
7598 \@@_back_input:V \@@_everyeof:w
7599 \@@_back_input:V \l_@@_head_tl
7600 \@@_print_expansion:e { \tl_to_str:N \l_@@_tmpa_tl }
7601 }
7602 \cs_new_protected:Npn \@@_input:
7603 {
7604 \@@_prev_input_gpush:N \l_@@_head_tl
7605 \@@_scan_file_name:
7606 \@@_prev_input_gpop:N \l_@@_head_tl
7607 \tl_set:Ne \l_@@_tmpa_tl { \tl_tail:N \l_@@_head_tl }
7608 \@@_file_get:nN \l_@@_tmpa_tl \l_@@_tmpa_tl
7609 \@@_back_input:V \l_@@_tmpa_tl
7610 \@@_print_expansion:e { \tl_to_str:N \l_@@_head_tl }
7611 }
7612 % \end{macrocode}
7613 % \end{macro}
7614 %
7615 % \begin{macro}{\@@_csname_loop:}
7616 % \begin{macrocode}
7617 \@@_new_tex_expandable:nn { cs_name } % 109
7618 {
7619 \int_compare:nNnTF \l_@@_head_char_int = 0
7620 {
7621 \@@_prev_input_gpush:N \l_@@_head_tl
7622 \@@_print_expansion:
7623 \@@_csname_loop:
7624 \@@_prev_input_silent:V \l_@@_head_tl
7625 \@@_get_lastnamedcs:
7626 \@@_prev_input_gpop:N \l_@@_head_tl
7627 \@@_back_input_tl_o:
7628 }
7629 {
7630 \@@_back_input:V \g_@@_lastnamedcs_tl
7631 \@@_print_expansion:e
7632 { \tl_to_str:N \l_@@_head_tl = \tl_to_str:N \g_@@_lastnamedcs_tl }
7633 }
7634 }
7635 \cs_new_protected:Npn \@@_csname_loop:
7636 {
7637 \@@_get_x_next:
7638 \@@_gtl_if_head_is_definable:NTF \l_@@_head_gtl
7639 {
7640 \cs_if_eq:NNF \l_@@_head_token \tex_endcsname:D
7641 {
7642 \@@_back_input:
7643 \@@_tex_error:nV { missing-endcsname } \l_@@_head_tl
7644 \tl_set:Nn \l_@@_head_tl { \tex_endcsname:D }
7645 }
7646 }
7647 {
7648 \@@_prev_input_silent:e
7649 { \@@_token_to_char:N \l_@@_head_token }
7650 \@@_csname_loop:
7651 }
7652 }
7653 \cs_new_protected:Npn \@@_get_lastnamedcs:
7654 {
7655 \group_begin:
7656 \@@_prev_input_get:N \l_@@_head_tl
7657 \tl_gset:No \g_@@_lastnamedcs_tl
7658 { \cs:w \exp_after:wN \@@_get_lastnamedcs_check:N \l_@@_head_tl }
7659 \group_end:
7660 }
7661 \cs_new:Npn \@@_get_lastnamedcs_check:N #1
7662 { \if_meaning:w \reverse_if:N #1 \use_i:nn \fi: }
7663 % \end{macrocode}
7664 % \end{macro}
7665 %
7666 % \begin{macrocode}
7667 \@@_new_tex_expandable:nn { convert } % 110
7668 {
7669 \@@_prev_input_gpush:N \l_@@_head_tl
7670 \@@_print_expansion:
7671 \int_case:nn \l_@@_head_char_int
7672 {
7673 0 \@@_scan_int:
7674 1 \@@_scan_int:
7675 2 \@@_convert_string:
7676 3 \@@_convert_meaning:w
7677 4 \@@_scan_font_ident:
7678 8 \@@_scan_font_ident:
7679 9 \@@_scan_font_ident:
7680 { 10 } \@@_scan_font_ident:
7681 { 11 } \@@_scan_int:
7682 { 12 } \@@_scan_int:
7683 { 13 } \@@_scan_pdf_ext_toks:
7684 { 14 } \@@_scan_pdf_ext_toks:
7685 { 15 } \@@_scan_int:
7686 { 16 } \@@_scan_int:
7687 { 17 } \@@_scan_pdfstrcmp:
7688 { 18 } \@@_scan_pdfcolorstackinit:
7689 { 19 } \@@_scan_pdf_ext_toks:
7690 { 20 } \@@_scan_pdf_ext_toks:
7691 { 22 } \@@_scan_pdf_ext_toks:
7692 { 23 } \@@_scan_pdf_ext_toks:
7693 { 24 }
7694 {
7695 \@@_scan_keyword:n { fFiIlLeE }
7696 \@@_scan_pdf_ext_toks:
7697 }
7698 { 25 } \@@_scan_pdffiledump:
7699 { 26 } \@@_scan_pdfmatch:
7700 { 27 } \@@_scan_int:
7701 { 28 } \@@_scan_int:
7702 { 30 } \@@_scan_int:
7703 { 31 } \@@_scan_pdfximagebbox:
7704 { 33 } \@@_scan_directlua:
7705 { 34 } \@@_scan_pdf_ext_toks:
7706 { 35 } \@@_scan_pdf_ext_toks:
7707 { 40 }
7708 {
7709 \@@_scan_int:
7710 \@@_prev_input_silent:n { ~ }
7711 \@@_scan_int:
7712 }
7713 }
7714 \@@_prev_input_gpop:N \l_@@_head_tl
7715 \@@_back_input_tl_o:
7716 }
7717 \cs_new_protected:Npn \@@_convert_string:
7718 {
7719 \@@_get_next:
7720 \tl_if_empty:NTF \l_@@_head_tl
7721 { \@@_prev_input:e { \gtl_to_str:N \l_@@_head_gtl } }
7722 { \@@_prev_input:V \l_@@_head_tl }
7723 }
7724 \cs_new_protected:Npn \@@_convert_meaning:w
7725 \@@_prev_input_gpop:N \l_@@_head_tl \@@_back_input_tl_o:
7726 {
7727 \@@_get_next:
7728 \tl_if_empty:NTF \l_@@_head_tl
7729 {
7730 \gtl_set_eq:NN \l_@@_tmpb_gtl \l_@@_head_gtl
7731 \@@_prev_input_gpop:N \l_@@_prev_input_tl
7732 \exp_args:NNV \gtl_put_left:Nn \l_@@_tmpb_gtl \l_@@_prev_input_tl
7733 \@@_prev_input_gpush_gtl:N \l_@@_tmpb_gtl
7734 \@@_print_action:e { \gtl_to_str:N \l_@@_tmpb_gtl }
7735 \@@_prev_input_gpop_gtl:N \l_@@_tmpb_gtl
7736 \tl_set:Ne \l_@@_tmpa_tl { \gtl_head_do:NN \l_@@_head_gtl \tex_meaning:D }
7737 \@@_back_input:V \l_@@_tmpa_tl
7738 \@@_print_expansion:e
7739 { \gtl_to_str:N \l_@@_tmpb_gtl = \tl_to_str:N \l_@@_tmpa_tl }
7740 }
7741 {
7742 \@@_prev_input:V \l_@@_head_tl
7743 \@@_prev_input_gpop:N \l_@@_head_tl
7744 \@@_back_input_tl_o:
7745 }
7746 }
7747 \cs_new_protected:Npn \@@_scan_pdfstrcmp:
7748 {
7749 \@@_scan_toks_to_str:
7750 \@@_scan_toks_to_str:
7751 }
7752 \cs_new_protected:Npn \@@_scan_pdfximagebbox:
7753 { \@@_scan_int: \@@_scan_int: }
7754 \cs_new_protected:Npn \@@_scan_pdfcolorstackinit:
7755 {
7756 \@@_scan_keyword:nTF { pPaAgGeE }
7757 { \bool_set_true:N \l_@@_tmpa_bool }
7758 { \bool_set_false:N \l_@@_tmpb_bool }
7759 \@@_scan_keyword:nF { dDiIrReEcCtT }
7760 { \@@_scan_keyword:n { pPaAgGeE } }
7761 \@@_scan_toks_to_str:
7762 }
7763 \cs_new_protected:Npn \@@_scan_pdffiledump:
7764 {
7765 \@@_scan_keyword:nT { oOfFfFsSeEtT } \@@_scan_int:
7766 \@@_scan_keyword:nT { lLeEnNgGtThH } \@@_scan_int:
7767 \@@_scan_pdf_ext_toks:
7768 }
7769 \cs_new_protected:Npn \@@_scan_pdfmatch:
7770 {
7771 \@@_scan_keyword:n { iIcCaAsSeE }
7772 \@@_scan_keyword:nT { sSuUbBcCoOuUnNtT }
7773 { \@@_scan_int: }
7774 \@@_scan_pdf_ext_toks:
7775 \@@_scan_pdf_ext_toks:
7776 }
7777 \sys_if_engine_luatex:T
7778 {
7779 \cs_new_protected:Npn \@@_scan_directlua:
7780 {
7781 \@@_get_x_non_relax:
7782 \token_if_eq_catcode:NNTF \l_@@_head_token \c_group_begin_token
7783 { \@@_back_input: }
7784 {
7785 \@@_scan_int:
7786 \@@_get_x_non_relax:
7787 }
7788 \@@_scan_pdf_ext_toks:
7789 }
7790 }
7791 % \end{macrocode}
7792 %
7793 % \begin{macro}{\@@_get_the:N}
7794 % |#1| is \cs{@@_get_token_xdef:} in \tn{edef} or \tn{xdef},
7795 % \cs{@@_get_token_x:} in \tn{message} and the like, and can be other
7796 % commands.
7797 % \begin{macrocode}
7798 \@@_new_tex_expandable:nn { the } % 111
7799 { \@@_get_the:N }
7800 \cs_new_protected:Npn \@@_get_the:N #1
7801 {
7802 \@@_prev_input_gpush:N \l_@@_head_tl
7803 \@@_print_expansion:
7804 \int_if_odd:nTF \l_@@_head_char_int
7805 { % \unexpanded, \detokenize
7806 \@@_scan_toks:NN \c_false_bool \c_false_bool
7807 \@@_prev_input_gpop:N \l_@@_head_tl
7808 \@@_set_action_text:e { \tl_to_str:N \l_@@_head_tl }
7809 }
7810 { % \the
7811 \@@_get_x_next:
7812 \@@_rescan_something_internal:n { 5 }
7813 \@@_prev_input_gpop:N \l_@@_head_tl
7814 \@@_set_action_text:e
7815 {
7816 \tl_head:N \l_@@_head_tl
7817 => \tl_tail:N \l_@@_head_tl
7818 }
7819 \tl_set:Ne \l_@@_head_tl
7820 { \exp_not:N \exp_not:n { \tl_tail:N \l_@@_head_tl } }
7821 }
7822 \cs_if_eq:NNTF #1 \@@_get_token_xdef:
7823 {
7824 \tl_put_right:NV \l_@@_defining_tl \l_@@_head_tl
7825 \@@_prev_input_silent:e { \l_@@_head_tl }
7826 \@@_print_action:
7827 }
7828 {
7829 \cs_if_eq:NNTF #1 \@@_get_token_x:
7830 {
7831 \exp_args:NNe \gtl_set:Nn \l_@@_tmpb_gtl { \l_@@_head_tl }
7832 \@@_prev_input_gtl:N \l_@@_tmpb_gtl
7833 }
7834 {
7835 \tl_set:Ne \l_@@_tmpa_tl { \exp_args:NV \exp_not:o \l_@@_head_tl }
7836 \@@_back_input:V \l_@@_tmpa_tl
7837 }
7838 \@@_print_expansion:
7839 }
7840 #1
7841 }
7842 % \end{macrocode}
7843 % \end{macro}
7844 %
7845 % \begin{macrocode}
7846 \@@_new_tex_expandable:nn { top_bot_mark } % 112
7847 { \@@_back_input_tl_o: }
7848 % \end{macrocode}
7849 %
7850 % \begin{macrocode}
7851 \@@_new_tex_expandable:nn { end_template } % 117
7852 { \@@_back_input_tl_o: }
7853 % \end{macrocode}
7854 %
7855 %
7856 % \subsubsection{Conditionals}
7857 %
7858 % ^^A todo: simply use \cs{@@_input_gpop:N} right away.
7859 % \begin{macro}{\@@_pass_text:}
7860 % \begin{macro}{\@@_pass_text_done:w}
7861 % \begin{macrocode}
7862 \cs_new_protected:Npn \@@_pass_text:
7863 {
7864 \@@_input_if_empty:TF
7865 { \@@_pass_text_empty: }
7866 {
7867 \@@_input_get:N \l_@@_tmpb_gtl
7868 \if_true:
7869 \if_case:w \gtl_head_do:NN \l_@@_tmpb_gtl \c_one_int
7870 \exp_after:wN \@@_pass_text_done:w
7871 \fi:
7872 \@@_input_gpop:N \l_@@_tmpb_gtl
7873 \exp_after:wN \@@_pass_text:
7874 \else:
7875 \use:c { fi: }
7876 \int_set:Nn \l_@@_if_nesting_int { 1 }
7877 \@@_input_gpop:N \l_@@_tmpb_gtl
7878 \exp_after:wN \@@_pass_text_nested:
7879 \fi:
7880 }
7881 }
7882 \cs_new_protected:Npn \@@_pass_text_done:w
7883 {
7884 \@@_get_next:
7885 \token_if_eq_meaning:NNT \l_@@_head_token \fi: { \if_true: }
7886 \else:
7887 }
7888 % \end{macrocode}
7889 % \end{macro}
7890 % \end{macro}
7891 %
7892 % \begin{macro}{\@@_pass_text_nested:}
7893 % Again, if there is no more input we are in trouble. The
7894 % construction otherwise essentially results in
7895 % \begin{quote}
7896 % \cs{if_true:} \cs{if_true:} \cs{else:} \meta{head} \\
7897 % \cs{int_decr:N} \cs{l_@@_if_nesting_int} \cs{use_none:nnnnn} \cs{fi:} \\
7898 % \cs{use_none:nnn} \cs{fi:} \\
7899 % \cs{int_incr:N} \cs{l_@@_if_nesting_int} \cs{fi:}
7900 % \end{quote}
7901 % If the \meta{head} is a primitive |\if...|, then the \cs{if_true:}
7902 % \cs{else:} ends with the second \cs{fi:}, and the nesting integer is
7903 % incremented before appropriately closing the \cs{if_true:}. If it
7904 % is a normal token or \tn{or} or \tn{else}, \cs{use_none:nnn} cleans
7905 % up, leaving the appropriate number of \cs{fi:}. Finally, if it is
7906 % \cs{fi:}, the nesting integer is decremented before removing most
7907 % \cs{fi:}.
7908 % \begin{macrocode}
7909 \cs_new_protected:Npn \@@_pass_text_nested:
7910 {
7911 \@@_input_if_empty:TF
7912 { \@@_pass_text_empty: }
7913 {
7914 \@@_input_get:N \l_@@_tmpb_gtl
7915 \if_true:
7916 \if_true:
7917 \gtl_head_do:NN \l_@@_tmpb_gtl \else:
7918 \int_decr:N \l_@@_if_nesting_int
7919 \use_none:nnnnn
7920 \fi:
7921 \use_none:nnn
7922 \fi:
7923 \int_incr:N \l_@@_if_nesting_int
7924 \fi:
7925 \@@_input_gpop:N \l_@@_unused_gtl
7926 \int_compare:nNnTF \l_@@_if_nesting_int = 0
7927 { \@@_pass_text: }
7928 { \@@_pass_text_nested: }
7929 }
7930 }
7931 % \end{macrocode}
7932 % \end{macro}
7933 %
7934 % \begin{macro}{\@@_pass_text_empty:}
7935 % \begin{macrocode}
7936 \cs_new_protected:Npn \@@_pass_text_empty:
7937 {
7938 \@@_error:nnnnn { runaway-if } { } { } { } { }
7939 \@@_exit_hard:w
7940 }
7941 % \end{macrocode}
7942 % \end{macro}
7943 %
7944 % \begin{macro}{\@@_cond_push:, \@@_cond_pop:}
7945 % \begin{macrocode}
7946 \cs_new_protected:Npn \@@_cond_push:
7947 {
7948 \tl_gput_left:Ne \g_@@_if_limit_tl
7949 { { \int_use:N \g_@@_if_limit_int } }
7950 \int_gincr:N \g_@@_if_depth_int
7951 \int_gzero:N \g_@@_if_limit_int
7952 }
7953 \cs_new_protected:Npn \@@_cond_pop:
7954 {
7955 \fi:
7956 \int_gset:Nn \g_@@_if_limit_int
7957 { \tl_head:N \g_@@_if_limit_tl }
7958 \tl_gset:Ne \g_@@_if_limit_tl
7959 { \tl_tail:N \g_@@_if_limit_tl }
7960 \int_gdecr:N \g_@@_if_depth_int
7961 }
7962 % \end{macrocode}
7963 % \end{macro}
7964 %
7965 % \begin{macro}{\@@_change_if_limit:nn}
7966 % \begin{macrocode}
7967 \cs_new_protected:Npn \@@_change_if_limit:nn #1#2
7968 {
7969 \int_compare:nNnTF {#2} = \g_@@_if_depth_int
7970 { \int_gset:Nn \g_@@_if_limit_int {#1} }
7971 {
7972 \tl_clear:N \l_@@_tmpa_tl
7973 \prg_replicate:nn { \g_@@_if_depth_int - #2 - 1 }
7974 {
7975 \tl_put_right:Ne \l_@@_tmpa_tl
7976 { { \tl_head:N \g_@@_if_limit_tl } }
7977 \tl_gset:Ne \g_@@_if_limit_tl
7978 { \tl_tail:N \g_@@_if_limit_tl }
7979 }
7980 \tl_gset:Ne \g_@@_if_limit_tl
7981 { \l_@@_tmpa_tl {#1} \tl_tail:N \g_@@_if_limit_tl }
7982 }
7983 }
7984 % \end{macrocode}
7985 % \end{macro}
7986 %
7987 % \begin{macrocode}
7988 \@@_new_tex_expandable:nn { if_test } % 107
7989 {
7990 \@@_cond_push:
7991 \exp_args:NV \@@_cond_aux:n \g_@@_if_depth_int
7992 }
7993 % \end{macrocode}
7994 %
7995 % \begin{macro}{\@@_cond_aux:nn}
7996 % \begin{macrocode}
7997 \cs_new_protected:Npn \@@_cond_aux:n #1
7998 {
7999 \int_case:nnF \l_@@_head_char_int
8000 {
8001 { 0 } { \@@_test_two_chars:nn { 0 } {#1} } % if
8002 { 1 } { \@@_test_two_chars:nn { 1 } {#1} } % ifcat
8003 { 12 } { \@@_test_ifx:n {#1} }
8004 { 16 } { \@@_test_case:n {#1} }
8005 { 20 } { \if_true: \@@_test_incsname:n {#1} }
8006 { 21 } { \if_true: \@@_test_pdfprimitive:n {#1} }
8007 }
8008 {
8009 \@@_prev_input_gpush:N \l_@@_head_tl
8010 \@@_print_expansion:
8011 \int_case:nn \l_@@_head_char_int
8012 {
8013 { 2 } % ifnum
8014 { \@@_test_two_vals:N \@@_scan_int: }
8015 { 3 } % ifdim
8016 { \@@_test_two_vals:N \@@_scan_normal_dimen: }
8017 { 4 } { \@@_scan_int: } % ifodd
8018 % { 5 } { } % if[hvm]mode, ifinner, if[tydm]dir
8019 { 9 } { \@@_scan_int: } % ifvoid, ifhbox, ifvbox etc
8020 { 13 } { \@@_scan_int: } % ifeof
8021 % { 14 } { } % iftrue
8022 % { 15 } { } % iffalse
8023 { 17 } { \@@_test_ifdefined: } % ifdefined
8024 { 18 } { \@@_test_ifcsname: } % ifcsname
8025 { 19 } % iffontchar
8026 { \@@_scan_font_ident: \@@_scan_int: }
8027 { 22 } % ifabsnum
8028 { \@@_test_two_vals:N \@@_scan_int: }
8029 { 23 } % ifabsdim
8030 { \@@_test_two_vals:N \@@_scan_normal_dimen: }
8031 { 24 } { \@@_scan_font_ident: } % ifjfont, iftfont
8032 }
8033 \@@_prev_input_gpop:N \l_@@_head_tl
8034 \@@_set_action_text:e { \tl_to_str:N \l_@@_head_tl }
8035 \l_@@_head_tl \scan_stop:
8036 \@@_cond_true:NNNn
8037 \else:
8038 \@@_cond_false:Nn
8039 \fi:
8040 {#1}
8041 }
8042 }
8043 % \end{macrocode}
8044 % \end{macro}
8045 %
8046 % \begin{macro}{\@@_cond_true:NNNn}
8047 % \begin{macrocode}
8048 \cs_new_protected:Npn \@@_cond_true:NNNn #1#2#3#4
8049 {
8050 \@@_change_if_limit:nn { 3 } {#4} % wait for else/fi
8051 \@@_print_expansion:e { \g_@@_action_text_str = true }
8052 }
8053 % \end{macrocode}
8054 % \end{macro}
8055 %
8056 % \begin{macro}
8057 % {\@@_cond_false:Nn, \@@_cond_false_loop:n, \@@_cond_false_common:}
8058 % \begin{macrocode}
8059 \cs_new_protected:Npn \@@_cond_false:Nn #1#2
8060 {
8061 \@@_cond_false_loop:n {#2}
8062 \@@_cond_false_common:
8063 \@@_print_expansion:e
8064 {
8065 \g_@@_action_text_str = false ~
8066 => ~ skip ~ to ~ \tl_to_str:N \l_@@_head_tl
8067 }
8068 }
8069 \cs_new_protected:Npn \@@_cond_false_loop:n #1
8070 {
8071 \@@_pass_text:
8072 \int_compare:nNnTF \g_@@_if_depth_int = {#1}
8073 {
8074 \token_if_eq_meaning:NNT \l_@@_head_token \or:
8075 {
8076 \@@_error:nnnnn { extra-or } { } { } { } { }
8077 \@@_cond_false_loop:n {#1}
8078 }
8079 }
8080 {
8081 \token_if_eq_meaning:NNT \l_@@_head_token \fi:
8082 { \@@_cond_pop: }
8083 \@@_cond_false_loop:n {#1}
8084 }
8085 }
8086 \cs_new_protected:Npn \@@_cond_false_common:
8087 {
8088 \token_if_eq_meaning:NNTF \l_@@_head_token \fi:
8089 { \@@_cond_pop: }
8090 { \int_gset:Nn \g_@@_if_limit_int { 2 } } % wait for fi
8091 }
8092 % \end{macrocode}
8093 % \end{macro}
8094 %
8095 % \begin{macro}{\@@_test_two_vals:N}
8096 % \begin{macrocode}
8097 \cs_new_protected:Npn \@@_test_two_vals:N #1
8098 {
8099 #1
8100 \@@_get_x_non_blank:
8101 \@@_tl_if_in:ooTF { < = > } \l_@@_head_tl { }
8102 {
8103 \@@_error:nnnnn { missing-equals } { } { } { } { }
8104 \@@_back_input:
8105 \tl_set:Nn \l_@@_head_tl { = }
8106 }
8107 \@@_prev_input:V \l_@@_head_tl
8108 #1
8109 }
8110 % \end{macrocode}
8111 % \end{macro}
8112 %
8113 % \begin{macro}{\@@_test_two_chars:nn, \@@_test_two_chars_get:n, \@@_test_two_chars_gtl:N}
8114 % \begin{macrocode}
8115 \cs_new_protected:Npn \@@_test_two_chars:nn #1
8116 {
8117 \exp_args:NNo \gtl_set:Nn \l_@@_head_gtl { \l_@@_head_tl }
8118 \@@_prev_input_gpush_gtl:N \l_@@_head_gtl
8119 \@@_print_expansion:
8120 \@@_test_two_chars_get:n {#1}
8121 \@@_test_two_chars_get:n {#1}
8122 \@@_prev_input_gpop_gtl:N \l_@@_head_gtl
8123 \@@_set_action_text:e { \gtl_to_str:N \l_@@_head_gtl }
8124 \gtl_pop_left_item:NNTF \l_@@_head_gtl \l_@@_head_tl { } { }
8125 \exp_args:No \tl_if_head_eq_meaning:nNT \l_@@_head_tl \reverse_if:N
8126 {
8127 \gtl_pop_left_item:NNTF \l_@@_head_gtl \l_@@_head_tl { } { }
8128 \tl_put_left:Nn \l_@@_head_tl { \reverse_if:N }
8129 }
8130 \gtl_pop_left:NN \l_@@_head_gtl \l_@@_tmpb_gtl
8131 \@@_test_two_chars_gtl:N \l_@@_tmpb_gtl
8132 \@@_test_two_chars_gtl:N \l_@@_head_gtl
8133 \l_@@_head_tl \scan_stop:
8134 \@@_cond_true:NNNn
8135 \else:
8136 \@@_cond_false:Nn
8137 \fi:
8138 }
8139 \cs_new_protected:Npn \@@_test_two_chars_get:n #1
8140 {
8141 \@@_get_x_next:
8142 \int_compare:nNnT {#1} = 0
8143 {
8144 \gtl_if_head_is_N_type:NF \l_@@_head_gtl
8145 { \gtl_set:Ne \l_@@_head_gtl { \gtl_to_str:N \l_@@_head_gtl } }
8146 }
8147 \@@_prev_input_gtl:N \l_@@_head_gtl
8148 \@@_print_action:e { \gtl_to_str:N \l_@@_head_gtl }
8149 }
8150 \cs_new_protected:Npn \@@_test_two_chars_gtl:N #1
8151 {
8152 \tl_put_right:Ne \l_@@_head_tl
8153 {
8154 \gtl_if_head_is_group_begin:NTF #1 { \c_group_begin_token }
8155 {
8156 \gtl_if_head_is_group_end:NTF #1 { \c_group_end_token }
8157 {
8158 \exp_not:N \exp_not:N
8159 \exp_not:f { \gtl_head_do:NN #1 \exp_stop_f: }
8160 }
8161 }
8162 }
8163 }
8164 % \end{macrocode}
8165 % \end{macro}
8166 %
8167 % \begin{macro}{\@@_test_ifx:n, \@@_test_ifx_str:NN, \@@_test_ifx_aux:NNN, \@@_test_ifx_aux:w}
8168 % The token equal to \tn{ifx} is pushed as a previous input to show an
8169 % action nicely, then retrieved as \cs{l_@@_tmpa_tl} after getting the
8170 % next two tokens as |tmpb| and |head|. Then we call
8171 % \cs{l_@@_tmpa_tl} followed by these two tokens. A previous
8172 % implementation made sure to get these tokens from unpacking the
8173 % |gtl|, presumably (I should have documented, now I might be missing
8174 % something) to deal nicely with the master counter in case these
8175 % tokens are braces. On the other hand we must take care of tokens
8176 % affected by \tn{noexpand} and whose current definition is
8177 % expandable, in which case the trustworthy \tn{meaning} is that of
8178 % the \cs{l_@@_head_token} or \cs{l_@@_tmpb_token} rather than that of
8179 % the token in \cs{l_@@_head_gtl} or \cs{l_@@_tmpb_gtl}.
8180 % \begin{macrocode}
8181 \cs_new_protected:Npn \@@_test_ifx:n #1
8182 {
8183 \@@_prev_input_gpush:N \l_@@_head_tl
8184 \@@_print_expansion:
8185 \@@_get_next:
8186 \gtl_set_eq:NN \l_@@_tmpb_gtl \l_@@_head_gtl
8187 \cs_set_eq:NN \l_@@_tmpb_token \l_@@_head_token
8188 \@@_get_next:
8189 \@@_prev_input_gpop:N \l_@@_tmpa_tl
8190 \@@_set_action_text:e
8191 {
8192 Compare:~ \tl_to_str:N \l_@@_tmpa_tl
8193 \@@_test_ifx_str:NN \l_@@_tmpb_token \l_@@_tmpb_gtl
8194 \@@_test_ifx_str:NN \l_@@_head_token \l_@@_head_gtl
8195 }
8196 \@@_test_ifx_aux:NNN \l_@@_tmpb_token \l_@@_tmpb_gtl
8197 \@@_test_ifx_aux:w
8198 \@@_cond_true:NNNn
8199 \else:
8200 \@@_cond_false:Nn
8201 \fi:
8202 {#1}
8203 }
8204 \cs_new:Npn \@@_test_ifx_str:NN #1#2
8205 {
8206 \token_if_eq_meaning:NNT #1 \@@_special_relax:
8207 { \iow_char:N \\notexpanded: }
8208 \gtl_to_str:N #2
8209 }
8210 \cs_new_protected:Npn \@@_test_ifx_aux:NNN #1#2#3
8211 {
8212 \token_if_eq_meaning:NNTF #1 \@@_special_relax:
8213 {
8214 \gtl_head_do:NN #2 \@@_token_if_expandable:NTF
8215 { #3 #1 } { \gtl_head_do:NN #2 #3 }
8216 }
8217 { \gtl_head_do:NN #2 #3 }
8218 }
8219 \cs_new:Npn \@@_test_ifx_aux:w
8220 {
8221 \@@_test_ifx_aux:NNN \l_@@_head_token \l_@@_head_gtl
8222 \l_@@_tmpa_tl
8223 }
8224 % \end{macrocode}
8225 % \end{macro}
8226 %
8227 % \begin{macro}{\@@_test_case:n, \@@_test_case_aux:nn}
8228 % ^^A todo: \ifcase\currentifbranch\show 0\or\show 1\else\show -\fi won't work correctly.
8229 % \begin{macrocode}
8230 \cs_new_protected:Npn \@@_test_case:n #1
8231 {
8232 \if_case:w 0 ~
8233 \@@_prev_input_gpush:N \l_@@_head_tl
8234 \@@_print_expansion:
8235 \bool_if:NT \g_@@_internal_debug_bool { \iow_term:n { {\ifcase level~#1} } }
8236 \@@_scan_int:
8237 \@@_prev_input_get:N \l_@@_head_tl
8238 \tl_set:Ne \l_@@_head_tl { \tl_tail:N \l_@@_head_tl }
8239 % ^^A does text_case_aux use prev_input_seq?
8240 \int_compare:nNnF { \l_@@_head_tl } = 0
8241 {
8242 \int_compare:nNnTF { \l_@@_head_tl } > 0
8243 { \fi: \if_case:w 1 ~ \or: }
8244 { \fi: \if_case:w -1 ~ \else: }
8245 }
8246 \exp_args:No \@@_test_case_aux:nn { \l_@@_head_tl } {#1}
8247 \@@_prev_input_gpop:N \l_@@_head_tl
8248 \@@_print_expansion:e { \tl_to_str:N \l_@@_head_tl }
8249 }
8250 \cs_new_protected:Npn \@@_test_case_aux:nn #1#2
8251 {
8252 \int_compare:nNnTF {#1} = 0
8253 { \@@_change_if_limit:nn { 4 } {#2} }
8254 {
8255 \@@_pass_text:
8256 \int_compare:nNnTF \g_@@_if_depth_int = {#2}
8257 {
8258 \token_if_eq_meaning:NNTF \l_@@_head_token \or:
8259 {
8260 \exp_args:Nf \@@_test_case_aux:nn
8261 { \int_eval:n { #1 - 1 } } {#2}
8262 }
8263 { \@@_cond_false_common: }
8264 }
8265 {
8266 \token_if_eq_meaning:NNT \l_@@_head_token \fi:
8267 { \@@_cond_pop: }
8268 \@@_test_case_aux:nn {#1} {#2}
8269 }
8270 }
8271 }
8272 % \end{macrocode}
8273 % \end{macro}
8274 %
8275 % \begin{macro}{\@@_test_incsname:n}
8276 % \begin{macrocode}
8277 \cs_new_protected:Npn \@@_test_incsname:n #1
8278 { \@@_not_implemented:n { ifincsname } }
8279 % \end{macrocode}
8280 % \end{macro}
8281 %
8282 % \begin{macro}{\@@_test_pdfprimitive:n}
8283 % \begin{macrocode}
8284 \cs_new_protected:Npn \@@_test_pdfprimitive:n #1
8285 { \@@_not_implemented:n { ifpdfprimitive } }
8286 % \end{macrocode}
8287 % \end{macro}
8288 %
8289 % \begin{macro}{\@@_test_ifdefined:}
8290 % \begin{macrocode}
8291 \cs_new_protected:Npn \@@_test_ifdefined:
8292 {
8293 \@@_input_if_empty:TF
8294 { \@@_pass_text_empty: }
8295 {
8296 \@@_input_gpop:N \l_@@_tmpb_gtl
8297 \@@_set_action_text:e
8298 {
8299 Conditional:~ \tl_to_str:N \l_@@_head_tl
8300 \gtl_to_str:N \l_@@_tmpb_gtl
8301 }
8302 \@@_prev_input:e
8303 {
8304 \gtl_if_tl:NTF \l_@@_tmpb_gtl
8305 { \gtl_head:N \l_@@_tmpb_gtl }
8306 { \gtl_to_str:N \l_@@_tmpb_gtl }
8307 }
8308 }
8309 }
8310 % \end{macrocode}
8311 % \end{macro}
8312 %
8313 % \begin{macro}{\@@_test_ifcsname:}
8314 % \begin{macrocode}
8315 \cs_new_protected:Npn \@@_test_ifcsname:
8316 {
8317 \@@_csname_loop:
8318 \@@_prev_input:V \l_@@_head_tl
8319 \@@_get_lastnamedcs:
8320 }
8321 % \end{macrocode}
8322 % \end{macro}
8323 %
8324 % \begin{macrocode}
8325 \@@_new_tex_expandable:nn { fi_or_else } % 108
8326 {
8327 \int_compare:nNnTF \l_@@_head_char_int > \g_@@_if_limit_int
8328 {
8329 \int_compare:nNnTF \g_@@_if_limit_int = 0
8330 {
8331 \int_compare:nNnTF \g_@@_if_depth_int = 0
8332 { \@@_error:nnnnn { extra-fi-or-else } { } { } { } { } }
8333 { \@@_insert_relax: }
8334 }
8335 { \@@_error:nnnnn { extra-fi-or-else } { } { } { } { } }
8336 }
8337 {
8338 \@@_set_action_text:
8339 \int_compare:nNnF \l_@@_head_char_int = 2
8340 {
8341 \@@_fi_or_else_loop:
8342 \@@_set_action_text:e
8343 {
8344 \g_@@_action_text_str \c_space_tl
8345 => ~ skip ~ to ~ \tl_to_str:N \l_@@_head_tl
8346 }
8347 }
8348 \@@_print_expansion:
8349 \@@_cond_pop:
8350 }
8351 }
8352 \cs_new_protected:Npn \@@_fi_or_else_loop:
8353 {
8354 \int_compare:nNnF \l_@@_head_char_int = 2
8355 {
8356 \@@_pass_text:
8357 \@@_set_cmd:
8358 \@@_fi_or_else_loop:
8359 }
8360 }
8361 % \end{macrocode}
8362 %
8363 % \subsection{User interaction}
8364 %
8365 % ^^A Not implemented yet: non-hash-doubling version.
8366 %
8367 % \subsubsection{Print}
8368 %
8369 % Let us start with the procedure which prints to the terminal: this
8370 % will help me test the code while I'm writing it.
8371 %
8372 % \begin{macro}{\@@_print_normalize_null:}
8373 % \begin{variable}{\l_@@_print_tl}
8374 % Change the null character to an explicit |^||^||@| in \LuaTeX{} to
8375 % avoid a bug whereby a null character ends a string prematurely.
8376 % \begin{macrocode}
8377 \tl_new:N \l_@@_print_tl
8378 \sys_if_engine_luatex:TF
8379 {
8380 \cs_new_protected:Npe \@@_print_normalize_null:
8381 {
8382 \tl_replace_all:Nnn \exp_not:N \l_@@_print_tl
8383 { \char_generate:nn { 0 } { 12 } }
8384 { \tl_to_str:n { ^ ^ @ } }
8385 }
8386 }
8387 { \cs_new_protected:Npn \@@_print_normalize_null: { } }
8388 % \end{macrocode}
8389 % \end{variable}
8390 % \end{macro}
8391 %
8392 % \begin{macro}{\@@_print:n, \@@_print:e, \@@_log:n}
8393 % \begin{macrocode}
8394 \cs_new_protected:Npn \@@_print:n #1
8395 {
8396 \tl_set:Nn \l_@@_print_tl {#1}
8397 \@@_print_normalize_null:
8398 \iow_term:e { \l_@@_print_tl }
8399 \tl_if_empty:NF \g_@@_output_file_tl
8400 { \iow_now:Ne \g_@@_iow { \l_@@_print_tl } }
8401 }
8402 \cs_generate_variant:Nn \@@_print:n { e }
8403 \cs_new_protected:Npn \@@_log:n #1
8404 {
8405 \tl_set:Nn \l_@@_print_tl {#1}
8406 \@@_print_normalize_null:
8407 \tl_if_empty:NTF \g_@@_output_file_tl
8408 { \iow_log:e { \l_@@_print_tl } }
8409 { \iow_now:Ne \g_@@_iow { \l_@@_print_tl } }
8410 }
8411 % \end{macrocode}
8412 % \end{macro}
8413 %
8414 % \begin{macro}{\@@_print_step:n}
8415 % Steps are printed or not according to the option value, unaffected
8416 % by a prompt such as |s10|.
8417 % \begin{macrocode}
8418 \cs_new_protected:Npn \@@_print_step:n #1
8419 {
8420 \int_compare:nNnF \g_@@_online_int < 0
8421 {
8422 \int_compare:nNnTF \g_@@_online_int = 0
8423 { \@@_log:n {#1} }
8424 { \@@_print:n {#1} }
8425 }
8426 }
8427 % \end{macrocode}
8428 % \end{macro}
8429 %
8430 % \begin{macro}{\@@_print_message:nn}
8431 % The message to be printed should come already detokenized, as~|#2|.
8432 % It will be wrapped to 80 characters per line, with~|#1| before each
8433 % line. The message is properly suppressed (or sent only to the log)
8434 % according to \cs{g_@@_current_online_int} so as to be sensitive to
8435 % the prompt.
8436 % \begin{macrocode}
8437 \cs_new_protected:Npn \@@_print_message:nn #1 #2
8438 {
8439 \int_compare:nNnF \g_@@_current_online_int < 0
8440 {
8441 \int_compare:nNnTF \g_@@_current_online_int = 0
8442 { \iow_wrap:nnnN { #1 #2 } { #1 } { } \@@_log:n }
8443 { \iow_wrap:nnnN { #1 #2 } { #1 } { } \@@_print:n }
8444 }
8445 }
8446 % \end{macrocode}
8447 % \end{macro}
8448 %
8449 % \begin{macro}{\@@_set_action_text:e}
8450 % \begin{macrocode}
8451 \cs_new_protected:Npn \@@_set_action_text:e #1
8452 {
8453 \group_begin:
8454 \@@_set_escapechar:n { 92 }
8455 \str_gset:Ne \g_@@_action_text_str {#1}
8456 \group_end:
8457 }
8458 % \end{macrocode}
8459 % \end{macro}
8460 %
8461 % \begin{macro}{\@@_set_action_text:}
8462 % \begin{macrocode}
8463 \cs_new_protected:Npn \@@_set_action_text:
8464 {
8465 \@@_set_action_text:e
8466 {
8467 \tl_to_str:N \l_@@_head_tl
8468 \tl_if_single_token:VT \l_@@_head_tl
8469 { = ~ \token_to_meaning:N \l_@@_head_token }
8470 }
8471 }
8472 % \end{macrocode}
8473 % \end{macro}
8474 %
8475 % \begin{macro}{\@@_print_state:}
8476 % \begin{macrocode}
8477 \cs_new_protected:Npn \@@_print_state:
8478 {
8479 \group_begin:
8480 \@@_set_escapechar:n { 92 }
8481 \tl_use:N \g_@@_before_print_state_tl
8482 \int_compare:nNnF \g_@@_current_online_int < 0
8483 {
8484 \@@_print_state_output:
8485 \@@_print_state_prev:
8486 \@@_print_state_input:
8487 }
8488 \group_end:
8489 }
8490 % \end{macrocode}
8491 % \end{macro}
8492 %
8493 % \begin{macro}{\@@_print_state_output:, \@@_print_state_output:n}
8494 % Unless empty, print |#1| with each line starting with \verb*+<|~+.
8495 % The \cs{@@_str_truncate_left:nn} function trims |#1| if needed, to
8496 % fit in a maximum of \cs{g_@@_max_output_int} characters.
8497 % \begin{macrocode}
8498 \cs_new_protected:Npn \@@_print_state_output:
8499 {
8500 \exp_args:Ne \@@_print_state_output:n
8501 { \gtl_to_str:N \g_@@_output_gtl }
8502 }
8503 \cs_new_protected:Npn \@@_print_state_output:n #1
8504 {
8505 \tl_if_empty:nF {#1}
8506 {
8507 \@@_print_message:nn { <| ~ } % |
8508 { \@@_str_truncate_left:nn {#1} { \g_@@_max_output_int } }
8509 }
8510 }
8511 % \end{macrocode}
8512 % \end{macro}
8513 %
8514 % \begin{macro}{\@@_print_state_prev:}
8515 % Never trim~|##1|.
8516 % \begin{macrocode}
8517 \cs_new_protected:Npn \@@_print_state_prev:
8518 {
8519 \seq_set_map_e:NNn \l_@@_tmpa_seq \g_@@_prev_input_seq
8520 { \@@_to_str:Nn ##1 }
8521 \seq_remove_all:Nn \l_@@_tmpa_seq { }
8522 \seq_if_empty:NTF \l_@@_tmpa_seq
8523 { \@@_print_message:nn { || ~ } { } }
8524 {
8525 \seq_map_inline:Nn \l_@@_tmpa_seq
8526 {
8527 \@@_print_message:nn { || ~ } {##1}
8528 }
8529 }
8530 }
8531 % \end{macrocode}
8532 % \end{macro}
8533 %
8534 % \begin{macro}{\@@_print_state_input:, \@@_print_state_input:n}
8535 % Print |#1| with each line starting with \verb*+|>~+. The
8536 % \cs{@@_str_truncate_right:nn} function trims |#1| if needed, to fit
8537 % in a maximum of \cs{g_@@_max_input_int} characters.
8538 % \begin{macrocode}
8539 \cs_new_protected:Npn \@@_print_state_input:
8540 {
8541 \exp_args:Ne \@@_print_state_input:n
8542 { \@@_input_to_str: }
8543 }
8544 \cs_new_protected:Npn \@@_print_state_input:n #1
8545 {
8546 \@@_print_message:nn { |> ~ } % |
8547 { \@@_str_truncate_right:nn {#1} { \g_@@_max_input_int } }
8548 }
8549 % \end{macrocode}
8550 % \end{macro}
8551 %
8552 % \begin{macro}{\@@_print_meaning:}
8553 % \begin{macrocode}
8554 \cs_new_protected:Npn \@@_print_meaning:
8555 {
8556 \@@_input_if_empty:TF
8557 { \@@_print_message:nn { } { Empty~input! } }
8558 {
8559 \@@_input_get:N \l_@@_tmpb_gtl
8560 \@@_print_message:nn { }
8561 {
8562 \gtl_head_do:NN \l_@@_tmpb_gtl \token_to_str:N
8563 = \gtl_head_do:NN \l_@@_tmpb_gtl \token_to_meaning:N
8564 }
8565 }
8566 }
8567 % \end{macrocode}
8568 % \end{macro}
8569 %
8570 % \begin{macro}{\@@_print_action:, \@@_print_action:e, \@@_print_assignment:, \@@_print_assignment:e, \@@_print_expansion:, \@@_print_expansion:e, \@@_print_action_aux:N}
8571 % Some of these commands are currently synonyms but we may decide to
8572 % make some options act differently on them.
8573 % \begin{macrocode}
8574 \cs_new_protected:Npn \@@_print_action:
8575 { \@@_print_action_aux:N \g_@@_trace_other_bool }
8576 \cs_new_protected:Npn \@@_print_action:e #1
8577 {
8578 \@@_set_action_text:e {#1}
8579 \@@_print_action:
8580 }
8581 \cs_new_protected:Npn \@@_print_assignment:
8582 { \@@_print_action_aux:N \g_@@_trace_assigns_bool }
8583 \cs_new_protected:Npn \@@_print_assignment:e #1
8584 {
8585 \@@_set_action_text:e {#1}
8586 \@@_print_assignment:
8587 }
8588 \cs_new_protected:Npn \@@_print_expansion:
8589 { \@@_print_action_aux:N \g_@@_trace_expansion_bool }
8590 \cs_new_protected:Npn \@@_print_expansion:e #1
8591 {
8592 \@@_set_action_text:e {#1}
8593 \@@_print_expansion:
8594 }
8595 \cs_new_protected:Npn \@@_print_action_aux:N #1
8596 {
8597 \int_gdecr:N \g_@@_nonstop_int
8598 \int_gincr:N \g_@@_step_int
8599 \bool_if:NT #1
8600 {
8601 \exp_args:Ne \@@_print_step:n
8602 {
8603 [=====
8604 \bool_if:NT \g_@@_number_steps_bool
8605 { ~ Step ~ \int_to_arabic:n { \g_@@_step_int } ~ }
8606 =====]~
8607 \int_compare:nNnTF
8608 { \str_count:N \g_@@_action_text_str }
8609 > { \g_@@_max_action_int }
8610 {
8611 \str_range:Nnn \g_@@_action_text_str
8612 { 1 } { \g_@@_max_action_int - 3 } ...
8613 }
8614 { \g_@@_action_text_str }
8615 }
8616 \@@_print_state:
8617 \@@_prompt:
8618 }
8619 }
8620 % \end{macrocode}
8621 % \end{macro}
8622 %
8623 % \begin{macro}{\@@_just_print_assigned_token:, \@@_print_assigned_token:, \@@_print_assigned_register:, \@@_print_assigned_parshape:, \@@_print_assigned_set_shape:}
8624 % \begin{macro}[EXP]{\@@_print_assigned_set_shape_aux:n}
8625 % \begin{macrocode}
8626 \cs_new_protected:Npn \@@_just_print_assigned_token:
8627 {
8628 \@@_print_assignment:e
8629 {
8630 Set~ \exp_after:wN \token_to_str:N \l_@@_defined_tl
8631 = \exp_after:wN \token_to_meaning:N \l_@@_defined_tl
8632 }
8633 }
8634 \cs_new_protected:Npn \@@_print_assigned_token:
8635 {
8636 \@@_after_assignment:
8637 \@@_just_print_assigned_token:
8638 \@@_omit_after_assignment:w
8639 }
8640 \cs_new:Npn \@@_print_assigned_aux_name:
8641 {
8642 Set~ \exp_after:wN \token_to_str:N \l_@@_defined_tl
8643 \tl_if_single:NT \l_@@_defined_tl
8644 { ( \exp_after:wN \token_to_meaning:N \l_@@_defined_tl ) }
8645 }
8646 \cs_new_protected:Npn \@@_print_assigned_register:
8647 {
8648 \@@_after_assignment:
8649 \exp_args:Ne \@@_print_assignment:e % needed to stringify a \toks
8650 {
8651 \exp_not:N \@@_print_assigned_aux_name:
8652 = \exp_not:N \tl_to_str:n { \@@_the:w \l_@@_defined_tl }
8653 }
8654 \@@_omit_after_assignment:w
8655 }
8656 \cs_new_protected:Npn \@@_print_assigned_parshape:
8657 {
8658 \@@_after_assignment:
8659 \tl_set:Nn \l_@@_tmpa_tl { \tex_parshapedimen:D }
8660 \@@_print_assignment:e
8661 {
8662 \@@_print_assigned_aux_name: = \@@_the:w \l_@@_defined_tl
8663 \int_step_function:nN { 2 * \l_@@_defined_tl }
8664 \@@_print_assigned_set_shape_aux:n
8665 }
8666 \@@_omit_after_assignment:w
8667 }
8668 \cs_new_protected:Npn \@@_print_assigned_set_shape:
8669 {
8670 \@@_after_assignment:
8671 \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_defined_tl
8672 \@@_print_assignment:e
8673 {
8674 \@@_print_assigned_aux_name:
8675 = \@@_the:w \l_@@_defined_tl 0 \exp_stop_f:
8676 \int_step_function:nN { \l_@@_defined_tl 0 }
8677 \@@_print_assigned_set_shape_aux:n
8678 }
8679 \@@_omit_after_assignment:w
8680 }
8681 \cs_new:Npn \@@_print_assigned_set_shape_aux:n #1
8682 { ~ \@@_the:w \l_@@_tmpa_tl #1 \exp_stop_f: }
8683 % \end{macrocode}
8684 % \end{macro}
8685 % \end{macro}
8686 %
8687 % \begin{macro}{\@@_print_welcome:}
8688 % Welcome message.
8689 % \begin{macrocode}
8690 \cs_new_protected:Npn \@@_print_welcome:
8691 {
8692 \@@_print_message:nn { }
8693 {
8694 \bool_if:NTF \g_@@_welcome_message_bool
8695 {
8696 \\
8697 ========~ Welcome~ to~ the~ unravel~ package~ ========\\
8698 \iow_indent:n
8699 {
8700 "<|"~ denotes~ the~ output~ to~ TeX's~ stomach. \\
8701 "||"~ denotes~ tokens~ waiting~ to~ be~ used. \\
8702 "|>"~ denotes~ tokens~ that~ we~ will~ act~ on. \\
8703 Press~<enter>~to~continue;~'h'~<enter>~for~help. \\
8704 }
8705 }
8706 { [=====~Start~=====] }
8707 }
8708 \@@_print_state:
8709 \@@_prompt:
8710 }
8711 % \end{macrocode}
8712 % \end{macro}
8713 %
8714 % \begin{macro}{\@@_print_outcome:}
8715 % Final message.
8716 % \begin{macrocode}
8717 \cs_new_protected:Npn \@@_print_outcome:
8718 { \@@_print_message:nn { } { [=====~End~=====] } }
8719 % \end{macrocode}
8720 % \end{macro}
8721 %
8722 % \subsubsection{Prompt}
8723 %
8724 % \begin{macro}{\@@_ior_str_get:NN, \@@_ior_str_get:Nc}
8725 % \begin{macrocode}
8726 \cs_new_protected:Npn \@@_ior_str_get:NN #1#2
8727 { \tex_readline:D #1 to #2 }
8728 \cs_generate_variant:Nn \@@_ior_str_get:NN { Nc }
8729 % \end{macrocode}
8730 % \end{macro}
8731 %
8732 % \begin{macro}{\@@_prompt:}
8733 % \begin{macrocode}
8734 \cs_new_protected:Npn \@@_prompt:
8735 {
8736 \int_compare:nNnF \g_@@_nonstop_int > 0
8737 {
8738 \group_begin:
8739 \@@_set_escapechar:n { -1 }
8740 \int_set:Nn \tex_endlinechar:D { -1 }
8741 \tl_use:N \g_@@_before_prompt_tl
8742 \@@_prompt_aux:
8743 \group_end:
8744 }
8745 }
8746 \cs_new_protected:Npn \@@_prompt_aux:
8747 {
8748 \clist_if_empty:NTF \g_@@_prompt_input_clist
8749 {
8750 \int_compare:nNnT { \tex_interactionmode:D } = { 3 }
8751 {
8752 \bool_if:NTF \g_@@_explicit_prompt_bool
8753 { \@@_ior_str_get:Nc \c_@@_prompt_ior }
8754 { \@@_ior_str_get:Nc \c_@@_noprompt_ior }
8755 { Your~input }
8756 \exp_args:Nv \@@_prompt_treat:n { Your~input }
8757 }
8758 }
8759 {
8760 \clist_gpop:NN \g_@@_prompt_input_clist \l_@@_tmpa_tl
8761 \group_begin:
8762 \@@_set_escapechar:n { 92 }
8763 \@@_print:e
8764 {
8765 \bool_if:NT \g_@@_explicit_prompt_bool { Your~input= }
8766 \tl_to_str:N \l_@@_tmpa_tl
8767 }
8768 \group_end:
8769 \exp_args:NV \@@_prompt_treat:n \l_@@_tmpa_tl
8770 }
8771 }
8772 \cs_new_protected:Npn \@@_prompt_treat:n #1
8773 {
8774 \tl_if_empty:nF {#1}
8775 {
8776 \str_case:enF { \tl_head:n {#1} }
8777 {
8778 { m } { \@@_print_meaning: \@@_prompt_aux: }
8779 { q }
8780 {
8781 \int_gset:Nn \g_@@_current_online_int { -1 }
8782 \int_gzero:N \g_@@_nonstop_int
8783 }
8784 { x }
8785 {
8786 \group_end:
8787 \@@_exit_hard:w
8788 }
8789 { X }
8790 {
8791 \tex_batchmode:D
8792 \tex_read:D -1 to \l_@@_tmpa_tl
8793 }
8794 { s } { \@@_prompt_scan_int:nn {#1}
8795 \@@_prompt_silent_steps:n }
8796 { o } { \@@_prompt_scan_int:nn {#1}
8797 { \int_gset:Nn \g_@@_current_online_int } }
8798 { C }
8799 {
8800 \use:e
8801 {
8802 \tl_gset_rescan:Nnn \exp_not:N \g_@@_tmpc_tl
8803 { \exp_not:N \ExplSyntaxOn } { \tl_tail:n {#1} }
8804 }
8805 \tl_gput_left:Nn \g_@@_tmpc_tl
8806 { \tl_gclear:N \g_@@_tmpc_tl }
8807 \group_insert_after:N \g_@@_tmpc_tl
8808 \group_insert_after:N \@@_prompt:
8809 }
8810 { | } % |
8811 { \@@_prompt_scan_int:nn {#1}
8812 \@@_prompt_vert:n }
8813 { u } { \@@_prompt_until:n {#1} }
8814 { a } { \@@_prompt_all: }
8815 }
8816 { \@@_prompt_help: }
8817 }
8818 }
8819 \cs_new_protected:Npn \@@_prompt_scan_int:nn #1
8820 {
8821 \tex_afterassignment:D \@@_prompt_scan_int_after:wn
8822 \l_@@_prompt_tmpa_int =
8823 \tl_if_head_eq_charcode:fNF { \use_none:n #1 } - { 0 }
8824 \use_ii:nn #1 \scan_stop:
8825 }
8826 \cs_new_protected:Npn \@@_prompt_scan_int_after:wn #1 \scan_stop: #2
8827 {
8828 #2 \l_@@_prompt_tmpa_int
8829 \tl_if_blank:nF {#1} { \@@_prompt_treat:n {#1} }
8830 }
8831 \cs_new_protected:Npn \@@_prompt_help:
8832 {
8833 \@@_print:n { "m":~meaning~of~first~token }
8834 \@@_print:n { "a":~print~state~again,~without~truncating }
8835 \@@_print:n { "s<num>":~do~<num>~steps~silently }
8836 \@@_print:n { "|<num>":~silent~steps~until~<num>~fewer~"||" }
8837 \@@_print:n { "u<text>":~silent~steps~until~the~input~starts~with~<text> }
8838 \@@_print:n
8839 { "o<num>":~1~=>~log~and~terminal,~0~=>~only~log,~-1~=>~neither.}
8840 \@@_print:n { "q":~semi-quiet~(same~as~"o-1") }
8841 \@@_print:n { "C<code>":~run~some~expl3~code~immediately }
8842 \@@_print:n { "x"/"X":~exit~this~instance~of~unravel/TeX }
8843 \@@_prompt_aux:
8844 }
8845 \cs_new_protected:Npn \@@_prompt_silent_steps:n #1
8846 {
8847 \int_compare:nNnF {#1} < 0
8848 {
8849 \int_gset:Nn \g_@@_current_online_int { -1 }
8850 \tl_gset:Nn \g_@@_before_prompt_tl
8851 {
8852 \int_gset_eq:NN \g_@@_current_online_int \g_@@_online_int
8853 \tl_gclear:N \g_@@_before_prompt_tl
8854 }
8855 \int_gset:Nn \g_@@_nonstop_int {#1}
8856 }
8857 }
8858 \cs_new_protected:Npn \@@_prompt_vert:n #1
8859 {
8860 \int_compare:nNnTF {#1} < { 0 }
8861 { \@@_prompt_vert:Nn > {#1} }
8862 { \@@_prompt_vert:Nn < {#1} }
8863 }
8864 \cs_new_protected:Npn \@@_prompt_vert:Nn #1#2
8865 {
8866 \int_gset:Nn \g_@@_current_online_int { -1 }
8867 \tl_gset:Nf \g_@@_before_print_state_tl
8868 {
8869 \exp_args:NNf \exp_stop_f: \int_compare:nNnTF
8870 { \int_eval:n { \@@_prev_input_count: - #2 } }
8871 #1 { \@@_prev_input_count: }
8872 {
8873 \int_gset:Nn \g_@@_nonstop_int
8874 { \int_max:nn { \g_@@_nonstop_int } { 2 } }
8875 }
8876 {
8877 \int_gset_eq:NN \g_@@_current_online_int \g_@@_online_int
8878 \tl_gclear:N \g_@@_before_print_state_tl
8879 }
8880 }
8881 }
8882 \cs_new_protected:Npn \@@_prompt_all:
8883 {
8884 \tl_gset:Ne \g_@@_tmpc_tl
8885 {
8886 \exp_not:n
8887 {
8888 \tl_gclear:N \g_@@_tmpc_tl
8889 \int_gset_eq:NN \g_@@_max_output_int \c_max_int
8890 \int_gset_eq:NN \g_@@_max_input_int \c_max_int
8891 \@@_print_state:
8892 \int_gdecr:N \g_@@_nonstop_int
8893 \@@_prompt:
8894 }
8895 \@@_prompt_all_aux:N \g_@@_max_output_int
8896 \@@_prompt_all_aux:N \g_@@_max_input_int
8897 }
8898 \group_insert_after:N \g_@@_tmpc_tl
8899 }
8900 \cs_new:Npn \@@_prompt_all_aux:N #1
8901 { \exp_not:n { \int_gset:Nn #1 } { \int_use:N #1 } }
8902 % \end{macrocode}
8903 % \end{macro}
8904 %
8905 % ^^A todo: I suspect a bug if given 'a' twice in a row
8906 %
8907 % \begin{macro}{\@@_prompt_until:n}
8908 % \begin{variable}{\g_@@_until_tl}
8909 % \begin{macrocode}
8910 \tl_new:N \g_@@_until_tl
8911 \cs_new_protected:Npn \@@_prompt_until:n #1
8912 {
8913 \tl_gset:Ne \g_@@_until_tl { \tl_tail:n {#1} }
8914 \int_gset:Nn \g_@@_current_online_int { -1 }
8915 \tl_gset:Nn \g_@@_before_print_state_tl
8916 {
8917 \@@_input_get_left:N \l_@@_tmpa_tl
8918 \use:e
8919 {
8920 \exp_not:N \tl_if_in:nnTF
8921 { \exp_not:N \@@:nn \tl_to_str:N \l_@@_tmpa_tl }
8922 { \exp_not:N \@@:nn \tl_to_str:N \g_@@_until_tl }
8923 }
8924 {
8925 \int_gzero:N \g_@@_nonstop_int
8926 \int_gset_eq:NN \g_@@_current_online_int \g_@@_online_int
8927 \tl_gclear:N \g_@@_before_print_state_tl
8928 }
8929 {
8930 \int_gset:Nn \g_@@_nonstop_int
8931 { \int_max:nn { \g_@@_nonstop_int } { 2 } }
8932 }
8933 }
8934 }
8935 % \end{macrocode}
8936 % \end{variable}
8937 % \end{macro}
8938 %
8939 % \subsubsection{Errors}
8940 %
8941 % \begin{macro}{\@@_not_implemented:n}
8942 % \begin{macrocode}
8943 \cs_new_protected:Npn \@@_not_implemented:n #1
8944 { \@@_error:nnnnn { not-implemented } {#1} { } { } { } }
8945 % \end{macrocode}
8946 % \end{macro}
8947 %
8948 % \begin{macro}{\@@_error:nnnnn, \@@_error:neeee}
8949 % Errors within a group to make sure that none of the \pkg{l3msg}
8950 % variables (or others) that may be currently in use in the code being
8951 % debugged are modified.
8952 % \begin{macrocode}
8953 \cs_new_protected:Npn \@@_error:nnnnn #1#2#3#4#5
8954 {
8955 \group_begin:
8956 \msg_error:nnnnnn { unravel } {#1} {#2} {#3} {#4} {#5}
8957 \group_end:
8958 }
8959 \cs_new_protected:Npn \@@_error:neeee #1#2#3#4#5
8960 {
8961 \group_begin:
8962 \msg_error:nneeee { unravel } {#1} {#2} {#3} {#4} {#5}
8963 \group_end:
8964 }
8965 % \end{macrocode}
8966 % \end{macro}
8967 %
8968 % \begin{macro}{\@@_tex_msg_new:nnn}
8969 % This stores a \TeX{} error message.
8970 % \begin{macrocode}
8971 \cs_new_protected:Npn \@@_tex_msg_new:nnn #1#2#3
8972 {
8973 \cs_new:cpn { @@_tex_msg_error_#1: } {#2}
8974 \cs_new:cpn { @@_tex_msg_help_#1: } {#3}
8975 }
8976 % \end{macrocode}
8977 % \end{macro}
8978 %
8979 % \begin{macro}{\@@_tex_error:nn, \@@_tex_error:nV}
8980 % Throw the |tex-error| message, with arguments: |#2| which triggered
8981 % the error, \TeX{}'s error message, and \TeX{}'s help text.
8982 % \begin{macrocode}
8983 \cs_new_protected:Npn \@@_tex_error:nn #1#2
8984 {
8985 \@@_error:neeee { tex-error }
8986 { \tl_to_str:n {#2} }
8987 { \use:c { @@_tex_msg_error_#1: } }
8988 { \use:c { @@_tex_msg_help_#1: } }
8989 { }
8990 }
8991 \cs_generate_variant:Nn \@@_tex_error:nn { nV }
8992 % \end{macrocode}
8993 % \end{macro}
8994 %
8995 % \begin{macro}{\@@_tex_fatal_error:nn, \@@_tex_fatal_error:nV}
8996 % Throw the |tex-fatal| error message, with arguments: |#2| which
8997 % triggered the fatal error, \TeX{}'s error message, and \TeX{}'s
8998 % help text.
8999 % \begin{macrocode}
9000 \cs_new_protected:Npn \@@_tex_fatal_error:nn #1#2
9001 {
9002 \@@_error:neeee { tex-fatal }
9003 { \tl_to_str:n {#2} }
9004 { \use:c { @@_tex_msg_error_#1: } }
9005 { \use:c { @@_tex_msg_help_#1: } }
9006 { }
9007 }
9008 \cs_generate_variant:Nn \@@_tex_fatal_error:nn { nV }
9009 % \end{macrocode}
9010 % \end{macro}
9011 %
9012 % \subsection{Keys}
9013 %
9014 % Each key needs to be defined twice: for its default setting and for
9015 % its setting applying to a single \cs{unravel}. This is due to the
9016 % fact that we cannot use grouping to keep settings local to a single
9017 % \cs{unravel} since the \meta{code} argument of \cs{unravel} may open
9018 % or close groups.
9019 % \begin{macrocode}
9020 \keys_define:nn { unravel/defaults }
9021 {
9022 explicit-prompt .bool_gset:N = \g_@@_default_explicit_prompt_bool ,
9023 internal-debug .bool_gset:N = \g_@@_default_internal_debug_bool ,
9024 max-action .int_gset:N = \g_@@_default_max_action_int ,
9025 max-output .int_gset:N = \g_@@_default_max_output_int ,
9026 max-input .int_gset:N = \g_@@_default_max_input_int ,
9027 number-steps .bool_gset:N = \g_@@_default_number_steps_bool ,
9028 online .int_gset:N = \g_@@_default_online_int ,
9029 output-file .code:n = {
9030 \int_gzero:N \g_@@_default_online_int
9031 \tl_gset:Nn \g_@@_default_output_file_tl {#1}
9032 } ,
9033 prompt-input .code:n
9034 = \@@_prompt_input:Nn \g_@@_default_prompt_input_clist {#1} ,
9035 trace-assigns .bool_gset:N = \g_@@_default_trace_assigns_bool ,
9036 trace-expansion .bool_gset:N = \g_@@_default_trace_expansion_bool ,
9037 trace-other .bool_gset:N = \g_@@_default_trace_other_bool ,
9038 welcome-message .bool_gset:N = \g_@@_default_welcome_message_bool ,
9039 }
9040 \keys_define:nn { unravel }
9041 {
9042 explicit-prompt .bool_gset:N = \g_@@_explicit_prompt_bool ,
9043 internal-debug .bool_gset:N = \g_@@_internal_debug_bool ,
9044 max-action .int_gset:N = \g_@@_max_action_int ,
9045 max-output .int_gset:N = \g_@@_max_output_int ,
9046 max-input .int_gset:N = \g_@@_max_input_int ,
9047 number-steps .bool_gset:N = \g_@@_number_steps_bool ,
9048 online .int_gset:N = \g_@@_online_int ,
9049 output-file .code:n = {
9050 \int_gzero:N \g_@@_online_int
9051 \tl_gset:Nn \g_@@_output_file_tl {#1}
9052 } ,
9053 prompt-input .code:n
9054 = \@@_prompt_input:Nn \g_@@_prompt_input_clist {#1} ,
9055 trace-assigns .bool_gset:N = \g_@@_trace_assigns_bool ,
9056 trace-expansion .bool_gset:N = \g_@@_trace_expansion_bool ,
9057 trace-other .bool_gset:N = \g_@@_trace_other_bool ,
9058 welcome-message .bool_gset:N = \g_@@_welcome_message_bool ,
9059 }
9060 % \end{macrocode}
9061 %
9062 % The |machine| and |trace| options are somewhat special so it is
9063 % clearer to define them separately. The code is identical for
9064 % |unravel/defaults| and |unravel| keys. To be sure of which options
9065 % are set, use |.meta:nn| and give the path explicitly.
9066 % \begin{macrocode}
9067 \tl_map_inline:nn { { /defaults } { } }
9068 {
9069 \keys_define:nn { unravel #1 }
9070 {
9071 machine .meta:nn =
9072 { unravel #1 }
9073 {
9074 explicit-prompt = false ,
9075 internal-debug = false ,
9076 max-action = \c_max_int ,
9077 max-output = \c_max_int ,
9078 max-input = \c_max_int ,
9079 number-steps = false ,
9080 welcome-message = false ,
9081 } ,
9082 mute .meta:nn =
9083 { unravel #1 }
9084 {
9085 trace-assigns = false ,
9086 trace-expansion = false ,
9087 trace-other = false ,
9088 welcome-message = false ,
9089 online = -1 ,
9090 }
9091 }
9092 }
9093 % \end{macrocode}
9094 %
9095 % \subsection{Main command}
9096 %
9097 % \begin{macro}{\unravel}
9098 % Simply call an underlying code-level command.
9099 % \begin{macrocode}
9100 \NewDocumentCommand \unravel { O { } +m } { \unravel:nn {#1} {#2} }
9101 % \end{macrocode}
9102 % \end{macro}
9103 %
9104 % \begin{macro}{\unravelsetup}
9105 % Simply call an underlying code-level command.
9106 % \begin{macrocode}
9107 \NewDocumentCommand \unravelsetup { m } { \unravel_setup:n {#1} }
9108 % \end{macrocode}
9109 % \end{macro}
9110 %
9111 % \begin{macro}{\unravel_setup:n}
9112 % Set keys, updating both default values and current values.
9113 % \begin{macrocode}
9114 \cs_new_protected:Npn \unravel_setup:n #1
9115 {
9116 \keys_set:nn { unravel/defaults } {#1}
9117 \keys_set:nn { unravel } {#1}
9118 }
9119 % \end{macrocode}
9120 % \end{macro}
9121 %
9122 % \begin{macro}{\unravel:nn, \@@:nn, \@@_unravel_marker:}
9123 % The command starts with \cs{@@_unravel_marker:} to detect nesting of
9124 % \tn{unravel} in \tn{unravel} and avoid re-initializing important
9125 % variables.
9126 % Initialize and setup keys. Initialize and setup other variables
9127 % including the input. Welcome the user. Then comes the main loop:
9128 % until the input is exhausted, print the current status and do one
9129 % step. The main loop is exited by skipping to the first
9130 % \cs{@@_exit_point:}, while some abort procedures jump to the second
9131 % (and last) one instead. If the main loop finished correctly, print
9132 % its outcome and finally test that everything is all right.
9133 % \begin{macrocode}
9134 \cs_new_protected:Npn \unravel:nn { \@@_unravel_marker: \@@:nn }
9135 \cs_new_eq:NN \@@_unravel_marker: \@@_special_relax:
9136 \cs_new_protected:Npn \@@:nn #1#2
9137 {
9138 \@@_init_key_vars:
9139 \keys_set:nn { unravel } {#1}
9140 \@@_init_vars:
9141 \@@_input_gset:n {#2}
9142 \@@_print_welcome:
9143 \@@_main_loop:
9144 \@@_exit_point:
9145 \@@_print_outcome:
9146 \@@_final_test:
9147 \@@_exit_point:
9148 }
9149 \cs_new_protected:Npn \unravel_get:nnN #1#2#3
9150 {
9151 \unravel:nn {#1} {#2}
9152 \tl_set:Ne #3 { \gtl_left_tl:N \g_@@_output_gtl }
9153 }
9154 % \end{macrocode}
9155 % \end{macro}
9156 %
9157 % \begin{macro}{\@@_init_key_vars:}
9158 % Give variables that are affected by keys their default values (also
9159 % controlled by keys).
9160 % \begin{macrocode}
9161 \cs_new_protected:Npn \@@_init_key_vars:
9162 {
9163 \sys_if_engine_luatex:T { \tl_gset:No \g_@@_lastnamedcs_tl { \tex_lastnamedcs:D } }
9164 \bool_gset_eq:NN \g_@@_explicit_prompt_bool \g_@@_default_explicit_prompt_bool
9165 \bool_gset_eq:NN \g_@@_internal_debug_bool \g_@@_default_internal_debug_bool
9166 \bool_gset_eq:NN \g_@@_number_steps_bool \g_@@_default_number_steps_bool
9167 \int_gset_eq:NN \g_@@_online_int \g_@@_default_online_int
9168 \tl_gset_eq:NN \g_@@_output_file_tl \g_@@_default_output_file_tl
9169 \clist_gset_eq:NN \g_@@_prompt_input_clist \g_@@_default_prompt_input_clist
9170 \bool_gset_eq:NN \g_@@_trace_assigns_bool \g_@@_default_trace_assigns_bool
9171 \bool_gset_eq:NN \g_@@_trace_expansion_bool \g_@@_default_trace_expansion_bool
9172 \bool_gset_eq:NN \g_@@_trace_other_bool \g_@@_default_trace_other_bool
9173 \bool_gset_eq:NN \g_@@_welcome_message_bool \g_@@_default_welcome_message_bool
9174 \int_gset_eq:NN \g_@@_max_action_int \g_@@_default_max_action_int
9175 \int_gset_eq:NN \g_@@_max_output_int \g_@@_default_max_output_int
9176 \int_gset_eq:NN \g_@@_max_input_int \g_@@_default_max_input_int
9177 \int_gzero:N \g_@@_nonstop_int
9178 \tl_gclear:N \g_@@_before_print_state_tl
9179 \tl_gclear:N \g_@@_before_prompt_tl
9180 }
9181 % \end{macrocode}
9182 % \end{macro}
9183 %
9184 % \begin{macro}{\@@_init_vars:}
9185 % Give initial values to variables used during the processing. These
9186 % have no reason to be modified by the user: neither directly nor
9187 % through keys.
9188 % \begin{macrocode}
9189 \cs_new_protected:Npn \@@_init_vars:
9190 {
9191 \int_gset_eq:NN \g_@@_current_online_int \g_@@_online_int
9192 \tl_if_eq:NNF \g_@@_output_file_tl \g_@@_current_output_file_tl
9193 {
9194 \iow_close:N \g_@@_iow
9195 \iow_open:Nn \g_@@_iow \g_@@_output_file_tl
9196 \tl_gset_eq:NN \g_@@_current_output_file_tl \g_@@_output_file_tl
9197 }
9198 \seq_gclear:N \g_@@_prev_input_seq
9199 \gtl_gclear:N \g_@@_output_gtl
9200 \int_gzero:N \g_@@_step_int
9201 \tl_gclear:N \g_@@_if_limit_tl
9202 \int_gzero:N \g_@@_if_limit_int
9203 \int_gzero:N \g_@@_if_depth_int
9204 \gtl_gclear:N \g_@@_after_assignment_gtl
9205 \bool_gset_true:N \g_@@_set_box_allowed_bool
9206 \bool_gset_false:N \g_@@_name_in_progress_bool
9207 \gtl_clear:N \l_@@_after_group_gtl
9208 }
9209 % \end{macrocode}
9210 % \end{macro}
9211 %
9212 % \begin{macro}{\@@_main_loop:, \@@_get_x_next_or_done:}
9213 % Loop forever, getting the next token (with expansion) and performing
9214 % the corresponding command. We use \cs{@@_get_x_next_or_done:},
9215 % which is basically \cs{@@_get_x_next:} but with a different
9216 % behaviour when there are no more tokens: running out of tokens here
9217 % is a successful exit of \cs{unravel}. Note that we cannot put the
9218 % logic into \cs{@@_main_loop:} because \cs{@@_expand_do:N} suppresses
9219 % the loop when a token is marked with \cs{notexpanded:}, and we don't
9220 % want that to suppress the main loop, only the expansion loop.
9221 % \begin{macrocode}
9222 \cs_new_protected:Npn \@@_get_x_next_or_done:
9223 {
9224 \@@_input_if_empty:TF { \@@_exit:w } { }
9225 \@@_get_next:
9226 \@@_token_if_expandable:NT \l_@@_head_token
9227 { \@@_expand_do:N \@@_get_x_next_or_done: }
9228 }
9229 \cs_new_protected:Npn \@@_main_loop:
9230 {
9231 \@@_get_x_next_or_done:
9232 \@@_set_cmd:
9233 \@@_do_step:
9234 \@@_main_loop:
9235 }
9236 % \end{macrocode}
9237 % \end{macro}
9238 %
9239 % \begin{macro}{\@@_do_step:}
9240 % Perform the action if the corresponding command exists. If that
9241 % command does not exist, complain, and leave the token in the output.
9242 % \begin{macrocode}
9243 \cs_new_protected:Npn \@@_do_step:
9244 {
9245 \@@_set_action_text:
9246 \bool_if:NT \g_@@_internal_debug_bool
9247 { \iow_term:e { Cmd:~\int_to_arabic:n { \l_@@_head_cmd_int } } }
9248 \cs_if_exist_use:cF
9249 { @@_cmd_ \int_use:N \l_@@_head_cmd_int : }
9250 { \@@_error:neeee { internal } { unknown-command } { } { } { } }
9251 }
9252 % \end{macrocode}
9253 % \end{macro}
9254 %
9255 % ^^A todo: improve error message
9256 % \begin{macro}{\@@_final_test:, \@@_final_bad:}
9257 % Make sure that the \cs{unravel} finished correctly. The error
9258 % message is a bit primitive.
9259 % \begin{macrocode}
9260 \cs_new_protected:Npn \@@_final_test:
9261 {
9262 \@@_input_if_empty:TF
9263 {
9264 \seq_if_empty:NTF \g_@@_prev_input_seq
9265 {
9266 \tl_if_empty:NTF \g_@@_if_limit_tl
9267 { \int_compare:nNnF \g_@@_if_limit_int = 0 { \@@_final_bad: } }
9268 { \@@_final_conditionals: }
9269 }
9270 { \@@_final_bad: }
9271 }
9272 { \@@_final_bad: }
9273 \@@_final_after_assignment:
9274 }
9275 \cs_new_protected:Npn \@@_final_bad:
9276 {
9277 \@@_error:nnnnn { internal }
9278 { the-last-unravel-finished-badly } { } { } { }
9279 }
9280 \cs_new_protected:Npn \@@_final_conditionals:
9281 {
9282 \group_begin:
9283 \msg_warning:nne { unravel } { dangling-conditionals }
9284 { \tl_count:N \g_@@_if_limit_tl }
9285 \group_end:
9286 \tl_greverse:N \g_@@_if_limit_tl
9287 \tl_gput_right:NV \g_@@_if_limit_tl \g_@@_if_limit_int
9288 \tl_gset:Ne \g_@@_if_limit_tl { \tl_tail:N \g_@@_if_limit_tl } % remove the {0}
9289 \prg_replicate:nn { \tl_count:N \g_@@_if_limit_tl } { \fi: }
9290 \tl_map_function:NN \g_@@_if_limit_tl \@@_final_cond_aux:n
9291 }
9292 \cs_new:Npn \@@_final_cond_aux:n #1
9293 {
9294 \int_case:nnF {#1}
9295 {
9296 { 2 } { \if_false: \else: }
9297 { 3 } { \if_true: }
9298 { 4 } { \if_case:w 0 ~ }
9299 }
9300 { \@@_final_bad: }
9301 }
9302 % \end{macrocode}
9303 % \end{macro}
9304 %
9305 % \begin{macro}{\@@_final_after_assignment:}
9306 % Salvage any remaining \tn{afterassignment} token.
9307 % \begin{macrocode}
9308 \cs_new_protected:Npn \@@_final_after_assignment:
9309 {
9310 \gtl_if_empty:NF \g_@@_after_assignment_gtl
9311 { \gtl_head_do:NN \g_@@_after_assignment_gtl \tex_afterassignment:D }
9312 }
9313 % \end{macrocode}
9314 % \end{macro}
9315 %
9316 % \subsection{Messages}
9317 %
9318 % \begin{macrocode}
9319 \msg_new:nnnn { unravel } { prev-input }
9320 { Internal~error:~unexpected~type~of~``prev_input''~entry. }
9321 {
9322 Found~type~#2~instead~of~#1~to~assign~to~variable~#3.~Contents:\\
9323 \iow_indent:n {#4}
9324 }
9325 \msg_new:nnn { unravel } { unknown-primitive }
9326 { Internal~error:~the~primitive~'#1'~is~not~known. }
9327 \msg_new:nnn { unravel } { extra-fi-or-else }
9328 { Extra~fi,~or,~or~else. }
9329 \msg_new:nnn { unravel } { missing-dollar }
9330 { Missing~dollar~inserted. }
9331 \msg_new:nnn { unravel } { unknown-expandable }
9332 { Internal~error:~the~expandable~command~'#1'~is~not~known. }
9333 \msg_new:nnn { unravel } { missing-font-id }
9334 { Missing~font~identifier.~\iow_char:N\\nullfont~inserted. }
9335 \msg_new:nnn { unravel } { missing-rparen }
9336 { Missing~right~parenthesis~inserted~for~expression. }
9337 \msg_new:nnn { unravel } { missing-cs }
9338 { Missing~control~sequence.~\iow_char:N\\inaccessible~inserted. }
9339 \msg_new:nnn { unravel } { missing-box }
9340 { Missing~box~inserted. }
9341 \msg_new:nnn { unravel } { missing-to }
9342 { Missing~keyword~'to'~inserted. }
9343 \msg_new:nnn { unravel } { improper-leaders }
9344 { Leaders~not~followed~by~proper~glue. }
9345 \msg_new:nnn { unravel } { extra-close }
9346 { Extra~right~brace~or~\iow_char:N\\endgroup. }
9347 \msg_new:nnn { unravel } { off-save }
9348 { Something~is~wrong~with~groups. }
9349 \msg_new:nnn { unravel } { hrule-bad-mode }
9350 { \iow_char\\hrule~used~in~wrong~mode. }
9351 \msg_new:nnn { unravel } { invalid-mode }
9352 { Invalid~mode~for~this~command. }
9353 \msg_new:nnn { unravel } { color-stack-action-missing }
9354 { Missing~color~stack~action. }
9355 \msg_new:nnn { unravel } { action-type-missing }
9356 { Missing~action~type. }
9357 \msg_new:nnn { unravel } { identifier-type-missing }
9358 { Missing~identifier~type. }
9359 \msg_new:nnn { unravel } { destination-type-missing }
9360 { Missing~destination~type. }
9361 \msg_new:nnn { unravel } { erroneous-prefixes }
9362 { Prefixes~appplied~to~non-assignment~command. }
9363 \msg_new:nnn { unravel } { improper-setbox }
9364 { \iow_char:N\\setbox~while~fetching~base~of~an~accent. }
9365 \msg_new:nnn { unravel } { after-advance }
9366 {
9367 Missing~register~after~\iow_char:N\\advance,~
9368 \iow_char:N\\multiply,~or~\iow_char:N\\divide.
9369 }
9370 \msg_new:nnn { unravel } { bad-unless }
9371 { \iow_char:N\\unless~not~followed~by~conditional. }
9372 \msg_new:nnn { unravel } { runaway-if }
9373 { Runaway~\iow_char:N\\if...~Exiting~\iow_char:N\\unravel }
9374 \msg_new:nnn { unravel } { runaway-macro-parameter }
9375 {
9376 Runaway~macro~parameter~\# #2~after \\\\
9377 \iow_indent:n {#1}
9378 }
9379 \msg_new:nnn { unravel } { runaway-text }
9380 { Runaway~braced~argument~for~TeX~primitive.~Exiting~\iow_char:N\\unravel }
9381 \msg_new:nnn { unravel } { extra-or }
9382 { Extra~\iow_char:N\\or. }
9383 \msg_new:nnn { unravel } { missing-equals }
9384 { Missing~equals~for~\iow_char:N\\ifnum~or~\iow_char:N\\ifdim. }
9385 \msg_new:nnn { unravel } { internal }
9386 { Internal~error:~'#1'.~\ Please~report. }
9387 \msg_new:nnn { unravel } { not-implemented }
9388 { The~following~feature~is~not~implemented:~'#1'. }
9389 \msg_new:nnn { unravel } { endinput-ignored }
9390 { The~primitive~\iow_char:N\\endinput~was~ignored. }
9391 \msg_new:nnn { unravel } { missing-something }
9392 { Something~is~missing,~sorry! }
9393 \msg_new:nnn { unravel } { nested-unravel }
9394 { The~\iow_char:N\\unravel~command~may~not~be~nested. }
9395 \msg_new:nnnn { unravel } { tex-error }
9396 { TeX~sees~"#1"~and~throws~an~error:\\\\ \iow_indent:n {#2} }
9397 {
9398 \tl_if_empty:nTF {#3}
9399 { TeX~provides~no~further~help~for~this~error. }
9400 { TeX's~advice~is:\\\\ \iow_indent:n {#3} }
9401 }
9402 \msg_new:nnnn { unravel } { tex-fatal }
9403 { TeX~sees~"#1"~and~throws~a~fatal~error:\\\\ \iow_indent:n {#2} }
9404 {
9405 \tl_if_empty:nTF {#3}
9406 { TeX~provides~no~further~help~for~this~error. }
9407 { TeX's~advice~is:\\\\ \iow_indent:n {#3} }
9408 }
9409 \msg_new:nnnn { unravel } { runaway-unravel }
9410 { Runaway~\iow_char:N\\unravel,~so~\iow_char:N\\relax~inserted. }
9411 {
9412 Some~TeX~command~expects~input~beyond~the~end~of~
9413 the~argument~of~\iow_char:N\\unravel.
9414 }
9415 \msg_new:nnn { unravel } { dangling-conditionals }
9416 { Attempting~to~issue~#1~dangling~conditionals. }
9417 % \end{macrocode}
9418 %
9419 % Some error messages from \TeX{} itself.
9420 % \begin{macrocode}
9421 \@@_tex_msg_new:nnn { forbidden-case }
9422 {
9423 You~can't~use~`\exp_after:wN \token_to_str:N \l_@@_head_tl'~in~
9424 \mode_if_vertical:TF { vertical }
9425 {
9426 \mode_if_horizontal:TF { horizontal }
9427 { \mode_if_math:TF { math } { no } }
9428 } ~ mode.
9429 }
9430 {
9431 Sorry,~but~I'm~not~programmed~to~handle~this~case;~
9432 I'll~just~pretend~that~you~didn't~ask~for~it.~
9433 If~you're~in~the~wrong~mode,~you~might~be~able~to~
9434 return~to~the~right~one~by~typing~`I\iow_char:N\}'~or~
9435 `I\iow_char:N\$'~or~`I\iow_char:N\\par'.
9436 }
9437 \@@_tex_msg_new:nnn { incompatible-mag }
9438 {
9439 Incompatible~magnification~
9440 ( \int_to_arabic:n { \@@_mag: } );~
9441 the~previous~value~will~be~retained
9442 }
9443 {
9444 I~can~handle~only~one~magnification~ratio~per~job.~So~I've~
9445 reverted~to~the~magnification~you~used~earlier~on~this~run.
9446 }
9447 \@@_tex_msg_new:nnn { illegal-mag }
9448 {
9449 Illegal~magnification~has~been~changed~to~1000~
9450 ( \int_to_arabic:n { \@@_mag: } )
9451 }
9452 { The~magnification~ratio~must~be~between~1~and~32768. }
9453 \@@_tex_msg_new:nnn { missing-number }
9454 { Missing~number,~treated~as~zero }
9455 {
9456 A~number~should~have~been~here;~I~inserted~`0'.~
9457 If~you~can't~figure~out~why~I~needed~to~see~a~number,~
9458 look~up~`weird~error'~in~the~index~to~The~TeXbook.
9459 }
9460 \@@_tex_msg_new:nnn { the-cannot }
9461 { You~can't~use~`\tl_to_str:N\l_@@_head_tl'~after~\iow_char:N\\the }
9462 { I'm~forgetting~what~you~said~and~using~zero~instead. }
9463 \@@_tex_msg_new:nnn { incompatible-units }
9464 { Incompatible~glue~units }
9465 { I'm~going~to~assume~that~1mu=1pt~when~they're~mixed. }
9466 \@@_tex_msg_new:nnn { missing-mu }
9467 { Illegal~unit~of~measure~(mu~inserted) }
9468 {
9469 The~unit~of~measurement~in~math~glue~must~be~mu.~
9470 To~recover~gracefully~from~this~error,~it's~best~to~
9471 delete~the~erroneous~units;~e.g.,~type~`2'~to~delete~
9472 two~letters.~(See~Chapter~27~of~The~TeXbook.)
9473 }
9474 \@@_tex_msg_new:nnn { missing-pt }
9475 { Illegal~unit~of~measure~(pt~inserted) }
9476 {
9477 Dimensions~can~be~in~units~of~em,~ex,~in,~pt,~pc,~
9478 cm,~mm,~dd,~cc,~nd,~nc,~bp,~or~sp;~but~yours~is~a~new~one!~
9479 I'll~assume~that~you~meant~to~say~pt,~for~printer's~points.~
9480 To~recover~gracefully~from~this~error,~it's~best~to~
9481 delete~the~erroneous~units;~e.g.,~type~`2'~to~delete~
9482 two~letters.~(See~Chapter~27~of~The~TeXbook.)
9483 }
9484 \@@_tex_msg_new:nnn { missing-lbrace }
9485 { Missing~\iow_char:N\{~inserted }
9486 {
9487 A~left~brace~was~mandatory~here,~so~I've~put~one~in.~
9488 You~might~want~to~delete~and/or~insert~some~corrections~
9489 so~that~I~will~find~a~matching~right~brace~soon.~
9490 (If~you're~confused~by~all~this,~try~typing~`I\iow_char:N\}'~now.)
9491 }
9492 \@@_tex_msg_new:nnn { extra-endcsname }
9493 { Extra~\token_to_str:c{endcsname} }
9494 { I'm~ignoring~this,~since~I~wasn't~doing~a~\token_to_str:c{csname}. }
9495 \@@_tex_msg_new:nnn { missing-endcsname }
9496 { Missing~\token_to_str:c{endcsname}~inserted }
9497 {
9498 The~control~sequence~marked~<to~be~read~again>~should~
9499 not~appear~between~\token_to_str:c{csname}~and~
9500 \token_to_str:c{endcsname}.
9501 }
9502 \@@_tex_msg_new:nnn { missing-delim }
9503 { Missing~delimiter~(.~inserted) }
9504 {
9505 I~was~expecting~to~see~something~like~`('~or~`\token_to_str:N\{'~or~
9506 `\token_to_str:N\}'~here.~If~you~typed,~e.g.,~
9507 `\{'~instead~of~`\token_to_str:N\{',~you~
9508 should~probably~delete~the~`\{'~by~typing~`1'~now,~so~that~
9509 braces~don't~get~unbalanced.~Otherwise~just~proceed.~
9510 Acceptable~delimiters~are~characters~whose~\token_to_str:c{delcode}~is~
9511 nonnegative,~or~you~can~use~`\token_to_str:c{delimiter}~<delimiter~code>'.
9512 }
9513 % \end{macrocode}
9514 %
9515 % Fatal \TeX{} error messages.
9516 % \begin{macrocode}
9517 \@@_tex_msg_new:nnn { cannot-read }
9518 { ***~(cannot~\iow_char:N\\read~from~terminal~in~nonstop~modes) }
9519 { }
9520 \@@_tex_msg_new:nnn { file-error }
9521 { ***~(job~aborted,~file~error~in~nonstop~mode) }
9522 { }
9523 \@@_tex_msg_new:nnn { interwoven-preambles }
9524 { (interwoven~alignment~preambles~are~not~allowed) }
9525 { }
9526 % \end{macrocode}
9527 %
9528 % Restore catcodes to their original values.
9529 % \begin{macrocode}
9530 \@@_setup_restore:
9531 % \end{macrocode}
9532 %
9533 % \begin{macrocode}
9534 %</package>
9535 % \end{macrocode}
9536 %
9537 % \end{implementation}
9538 %
9539 % \endinput