Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2025 Valentin Dao
4 %
5 % This file may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.3 of this license or (at your option) any later
8 % version. The latest version of this license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3c or later is part of all distributions of
13 % LaTeX version 2008-05-04 or later.
14 %
15 % This work has the LPPL maintenance status 'maintained'
16 % and the current maintainer is Valentin Dao ([email protected]).
17 %
18 % This work consists of the files xmeaning.ins and xmeaning.dtx.
19 %
20 % The repository of this work can be found at:
21 %
22 % https://github.com/ankaa3908/xmeaning
23 %
24 % \fi
25 % \iffalse
26 %<*readme>
27 %</readme>
28 %
29 %<*driver>
30 \documentclass{l3doc}
31 \usepackage{intexgral}
32 \usepackage{codedescribe}
33 \lstset{gobble=2}
34 \usepackage{xmeaning}
35 \PkgInfoSetAliases
36
37 \begin{document}
38 \DocInput{xmeaning.dtx}
39 \end{document}
40 %</driver>
41 % \fi
42 %
43 % \PkgInfoGet{xmeaning}{author}{\fileauthor}
44 % \PkgInfoGet{xmeaning}{version}{\fileversion}
45 % \PkgInfoGet{xmeaning}{date}{\filedate}
46 % \PkgInfoGet{xmeaning}{creation}{\filecreationdate}
47 %
48 % \date{Released \filecreationdate}
49 %
50 % \title{^^A
51 % The xmeaning package^^A
52 % \thanks{This file describes v\fileversion, published \filedate.}
53 % }
54 %
55 % \author{^^A
56 % \fileauthor^^A
57 % \thanks{E-mail: \href{mailto:[email protected]}{\ttfamily [email protected]}}
58 % }
59 %
60 % \maketitle
61 %
62 % \begin{abstract}
63 % The \tsobj[pkg]{xmeaning} package's main objective is to enhance the \tsobj[macro]{\meaning} primitive by enlarging the amount of given informationG. It requires \tsobj[pkg]{expl3} as well as \tsobj[pkg]{pkginfograb}. Please note that this package is considered to be highly experimental for the moment.
64 % \end{abstract}
65 %
66 % \subsection*{Limitations}
67 %
68 % The \tsobj[macro]{\xmeaning} macro will fail under certain precise circumstances:
69 % \begin{enumerate}
70 % \item If the parameter text \emph{or} the replacement text of a macro contains \enquote{\verb|->|}.
71 % \item If you use \tsobj[macro]{\xmeaning} for a constant defined using \tsobj[macro]{\chardef} or \tsobj[macro]{\mathchardef}.
72 % \end{enumerate}
73 %
74 % Whether the compilation stops or succeeds, but with erroneous results, completely depends on what the argument is.
75 %
76 % \begin{codedescribe}[macro]{\xmeaning}
77 % \begin{codesyntax}[macro]
78 % \tsmacro{\xmeaning*}{list of tokens}
79 % \end{codesyntax}
80 % On its simplest form, \tsobj[macro]{\xmeaning} has a strictly similar usage to that of \tsobj[macro]{\meaning}. The main argument can either correspond to a character or a control sequence. With \tsobj[pkg]{xmeaning}, it is possible to specify a list of tokens to display all their meanings, avoiding the need to repeat the macro. Unlike the \TeX\ primitive, which doesn't always provide useful information, \tsobj[macro]{\xmeaning} is capable of recognising 5 \emph{token classes} among:
81 % \begin{describelist}{option}
82 % \describe{Characters}{A unique token.}
83 % \describe{Character definitions}{A control sequence declared with \tsobj[macro]{\chardef} or \tsobj[macro]{\mathchardef}.}
84 % \describe{\TeX\ registers}{Control sequences representing boxes, counts\dots}
85 % \describe{expl3 data types}{All the variable types implemented by \LaTeX3.}
86 % \describe{Macros}{A macro, or any control sequence that doesn't fall into the previous classes.}
87 % \end{describelist}
88 % By \emph{class}, we mean that the macro will produce an output adapted to each token type. Its starred variant will display the meaning of all auxiliary macros as described later.
89 % \end{codedescribe}
90 %
91 % \section{Characters}
92 %
93 % Unlike the \tsobj[macro]{meaning} primitive, which gives us only little information regarding characters, the package lists all there is to know about them.
94 % \begin{itemize}
95 % \item Character code, with its ASCII, Unicode, octal and hexadecimal representations.
96 % \item Category codes.
97 % \item Upper or lower case code (depending on the case of the queried character)\textsuperscript\dagger.
98 % \item Space factor code\textsuperscript\dagger.
99 % \item Delimiter code.
100 % \item Math code\textsuperscript\dagger.
101 % \end{itemize}
102 %
103 % \begingroup
104 % \small\textsuperscript\dagger\ These codes will be displayed only if they are not null.
105 % \endgroup
106 %
107 % For math code, the package goes beyond simply displaying it, as it analyses it according to its functioning as described in the \TeX book. The same applies to the delimiter code if it is not 0. Furthermore, it is not necessary to escape special characters with a backslash. The macro may produce incorrect results if you pass it an argument that is not recognised by the encoding. If you are using an engine other than \hologo{XeLaTeX} or \hologo{LuaLaTeX}, keep this in mind.
108 %
109 % \begin{codestore}[char]
110 % \xmeaning o
111 % \end{codestore}
112 %
113 % \tsdemo*{char}
114 %
115 % \section{Character definitions}
116 %
117 % The package calls any character defined by \tsobj[macro]{\chardef} and \tsobj[macro]{\mathchardef} a \emph{character definition}. The advantage over the primitive \tsobj[macro]{\meaning} is that here the glyph is produced, allowing you to see the concrete result of the control sequence. It is precisely for this reason that constants defined with these two macros do not work (for example, certain plain\TeX\ constants such as \tsobj[macro]{\z@}, \tsobj[macro]{\@M}\dots). They correspond to numbers and not to real characters. Since the package cannot tell the difference, it will attempt to typeset a glyph with a character code that is certainly outside those defined by the font table. It also indicates whether the character should be used in text mode or math mode.
118 %
119 % \begin{codestore}[chardef]
120 % \xmeaning{\%, \gamma}
121 % \end{codestore}
122 %
123 % \tsdemo*{chardef}
124 %
125 % \section{Registers}
126 %
127 % For registers, the package simply displays its type as well as its content.
128 %
129 % \begin{codestore}[register]
130 % \newtoks\temptoks
131 % \temptoks={Token register}
132 % \xmeaning\temptoks
133 % \end{codestore}
134 %
135 % \tsdemo*{register}
136 %
137 % \section{Data types}
138 %
139 % \LaTeX3 data types are much more complex than registers. That is why a few more entries compared to registers are present. \tsobj[macro]{\xmeaning} will fail if the naming conventions for data types are not followed.
140 %
141 % \begin{codestore}[data types]
142 % \ExplSyntaxOn
143 % \tl_new:N \l_my_token_tl
144 % \tl_set:Nn \l_my_token_tl { Token~data~type }
145 % \xmeaning\l_my_token_tl
146 % \ExplSyntaxOff
147 % \end{codestore}
148 %
149 % \tsdemo*{data types}
150 %
151 % \section{Macros}
152 %
153 % The package produces a very complete output for macros, where the following information is typeset:
154 %
155 % \begin{itemize}
156 % \item The name of the macro.
157 % \item The type of macro.
158 % \item The prefix of the macro (\tsobj[macro]{\long}, \tsobj[macro]{\protected}, and \tsobj[macro]{\outer})\textsuperscript\dagger.
159 % \item The parameter text\textsuperscript\dagger.
160 % \item The replacement text\textsuperscript\dagger.
161 % \end{itemize}
162 %
163 % \begingroup
164 % \small
165 % \textsuperscript\dagger
166 % Here too, these elements are only displayed if they are present. For primitives, they will always be absent.
167 % \endgroup
168 %
169 % \vspace*{\baselineskip}
170 %
171 % The macro \emph{type} can be one of the following:
172 % \begin{itemize}
173 % \item \TeX primitive.
174 % \item \TeX macro.
175 % \item \tsobj[pkg]{expl3} primitive.
176 % \item \tsobj[pkg]{expl3} macro.
177 % \item argument specifier \tsobj[pkg]{expl3}, with distinction of the \emph{unbraced} variants.
178 % \item \tsobj[pkg]{expl3} identity macro.
179 % \item \tsobj[pkg]{xparse} macro.
180 % \end{itemize}
181 %
182 % \begin{codestore}[macros]
183 % \xmeaning{\kern, \newcommand}
184 % \end{codestore}
185 %
186 % \tsdemo*{macros}
187 %
188 % \section{Exhaustive meaning}
189 %
190 % With the starred variant of \tsobj[macro]{\xmeaning}, it is possible to ask the package to display the meaning of all the auxiliary macros that make up the main argument. There is, however, no magical formula for knowing in advance what these auxiliary macros will be. The package therefore assumes that standard programming conventions are followed and, using a brute-force method, recursively applies \tsobj[macro]{\xmeaning} to all of the following macros:
191 %
192 % \begin{itemize}
193 % \item \tsobj[macro]{\foo}\tsobj[meta]{\textvisiblespace}.
194 % \item \tsobj[macro]{\foo}\tsobj[meta]{\textvisiblespace code} (for macros defined with \tsobj[pkg]{xparse}).
195 % \item \tsobj[macro]{\foo}\tsobj[meta]{A-Z} (\verb|\fooA|, \verb|\fooB|\dots).
196 % \item \tsobj[meta]{A-Z}\tsobj[macro]{\foo} (\verb|\Afoo|, \verb|\Bfoo|\dots).
197 % \item Nesting of \emph{@} (\verb|\@foo|, \verb|\f@oo|\dots \verb|\foo@|).
198 % \item Replacement of \emph{o} and \emph{a} by \emph{@} (\verb|\f@@|, \verb|\b@r|).
199 % \item \tsobj[macro]{\foo}\tsobj[meta]{@Roman numeral} (\verb|\foo@ii|).
200 % \item \tsobj[meta]{\_\_}\tsobj[macro]{\foo} (for internal macros of \tsobj[pkg]{expl3}).
201 % \end{itemize}
202 %
203 % This method does not guarantee that if several macros are found, they are related to each other. Nor is it certain that auxiliary macros will be found even after applying all these rules, which are not absolute (after all, everyone is free to name their macros as they see fit).
204 %
205 % \begin{codestore}[exhaustive]
206 % \xmeaning*{\newcommand, \integral}
207 % \end{codestore}
208 %
209 % \tsdemo*{exhaustive}
210 %
211 % \newpage
212 %
213 % \section{Implementation}
214 %
215 % \begin{macrocode}
216 %<*package>
217 %<@@=xmeaning_pkg>
218
219 \NeedsTeXFormat{LaTeX2e}
220 \RequirePackage{expl3}[2025-05-14]
221 \RequirePackage{pkginfograb}
222 \pkginfograbProvidesExplPackage{xmeaning}
223 {
224 name = {xmeaning} ,
225 author = {Valentin Dao},
226 date = {2025-12-18},
227 creation = {2025-12-18},
228 version = {v0.1.0} ,
229 description = {Enhanced implementation of the \string\meaning\ primitive.}
230 }
231
232 \@ifpackagelater{expl3}{2025-05-14}{}
233 {
234 \PackageError { xmeaning } { Support~package~expl3~too~old }
235 {
236 expl3~version~too~old~
237 'xmeaning'~requires~a~version~later~than:~2025-05-14.
238 \MessageBreak
239 Loading~xmeaning~will~abort.
240 }
241 \tex_endinput:D
242 }
243
244 \cs_new:Npn \@@_char_value_delcode:n #1 {
245 \tex_number:D \tex_delcode:D #1 \scan_stop:
246 }
247
248 \cs_new_protected:Npn \@@_tex_halign:n #1 {
249 \tex_halign:D { #1 }
250 }
251
252 \cs_generate_variant:Nn \regex_if_match:nnTF { neTF }
253 \cs_generate_variant:Nn \regex_match_case:nn { ne }
254 \cs_generate_variant:Nn \regex_match_case:nnF { neF }
255 \cs_generate_variant:Nn \regex_extract_all:nnN { neN }
256 \cs_generate_variant:Nn \int_to_hex:n { e }
257 \cs_generate_variant:Nn \int_from_hex:n { e }
258 \cs_generate_variant:Nn \int_case:nn { Vn }
259 \cs_generate_variant:Nn \tl_range:nnn { nnV }
260 \cs_generate_variant:Nn \char_generate:nn { en }
261 \cs_generate_variant:Nn \token_if_cs:NTF { cTF }
262 \cs_generate_variant:Nn \clist_put_right:Nn { Nf }
263 \cs_generate_variant:Nn \int_compare_p:nNn { nNV }
264
265 \int_new:N \l_@@_char_math_fam_int
266 \int_new:N \l_@@_char_math_slot_int
267 \int_new:N \l_@@_small_variant_family_int
268 \int_new:N \l_@@_small_variant_position_int
269 \int_new:N \l_@@_big_variant_family_int
270 \int_new:N \l_@@_big_variant_position_int
271
272 \bool_new:N \l_@@_undefined_cs_bool
273 \bool_set_false:N \l_@@_undefined_cs_bool
274 \bool_new:N \l_@@_exhaustive_meaning_bool
275 \bool_set_false:N \l_@@_exhaustive_meaning_bool
276
277 \tl_new:N \l_@@_register_type_tl
278
279 \skip_new:N \l_@@_meaning_skip
280
281 \skip_set:Nn \l_@@_meaning_skip { 6pt + 3pt - 2pt }
282
283 \cs_new_protected:Npn \@@_print_clist:c #1
284 {
285 \begin{enumerate}
286 \clist_map_inline:cn { #1 }
287 {
288 \item ##1
289 }
290 \end{enumerate}
291 }
292
293 \cs_new_protected:Npn \@@_print_seq:c #1
294 {
295 \begin{enumerate}
296 \seq_map_inline:cn { #1 }
297 {
298 \item ##1
299 }
300 \end{enumerate}
301 }
302
303 \cs_new_protected:Npn \@@_print_prop:c #1
304 {
305 \prop_map_inline:cn { #1 }
306 { ##1~->~##2\tex_par:D }
307 }
308
309 \cs_new_protected:Npn \@@_character_meaning:N #1 {
310 \int_set:Nn \l_tmpa_int { \int_eval:n { `#1 } }
311 \tl_set:Ne \l_tmpb_tl { \int_to_Hex:n { \l_tmpa_int } }
312 \tl_set:Ne \l_@@_utf_eight_representation_tl
313 {
314 U+
315 \prg_replicate:nn { \int_eval:n { 4 - \tl_count:N \l_tmpb_tl } } { 0 }
316 \tl_use:N \l_tmpb_tl
317 }
318 \@@_tex_halign:n { \tex_hfil:D##&\c_space_tl=\c_space_tl\vbox_top:n{\raggedright##}\tex_cr:D
319 Glyph & \token_to_meaning:N #1\tex_cr:D
320 Category~code & \token_to_catcode:N #1\tex_cr:D
321 Character~code & \int_use:N \l_tmpa_int\tex_cr:D
322 Unicode & \tl_use:N \l_@@_utf_eight_representation_tl\tex_cr:D
323 Octal & \int_to_oct:n { \l_tmpa_int }\tex_cr:D
324 Hexadecimal & \int_to_hex:n { \l_tmpa_int }\tex_cr:D
325 \bool_if:nF
326 {
327 \int_compare_p:nNn { \char_value_uccode:n { `#1 } } = { 0 }
328 ||
329 \int_compare_p:nNV { \char_value_uccode:n { `#1 } } = \l_tmpa_int
330 }
331 {
332 Uppercase~code & \char_value_uccode:n { `#1 }~(\char_generate:nn { \char_value_uccode:n { `#1 } } { 11 })\tex_cr:D
333 }
334 \bool_if:nF
335 {
336 \int_compare_p:nNn { \char_value_lccode:n { `#1 } } = { 0 }
337 ||
338 \int_compare_p:nNV { \char_value_lccode:n { `#1 } } = \l_tmpa_int
339 }
340 {
341 Lowercase~code & \char_value_lccode:n { `#1 }~(\char_generate:nn { \char_value_lccode:n { `#1 } } { 11 })\tex_cr:D
342 }
343 Space~factor~code & \char_value_sfcode:n { `#1 } \tex_cr:D
344 Math~code & \int_to_hex:e { \char_value_mathcode:n { `#1 } }
345 \sys_if_engine_luatex:TF
346 {
347 \int_set:Nn \l_tmpb_int { \Umathcharclass`#1 }
348 \int_set:Nn \l_@@_char_math_fam_int { \Umathcharfam`#1 }
349 \int_set:Nn \l_@@_char_math_slot_int { \Umathcharslot`#1 }
350 }
351 {
352 \exp_args:NNe \int_set:Nn \l_tmpb_int
353 { \tl_head:e { \int_to_hex:e { \char_value_mathcode:n { `#1 } } } }
354 \exp_args:NNe \int_set:Nn \l_@@_char_math_fam_int
355 { \exp_args:Ne \tl_item:nn { \int_to_hex:e { \char_value_mathcode:n { `#1 } } } { 2 } }
356 \exp_args:NNe \int_set:Nn \l_@@_char_math_slot_int
357 {
358 \int_from_hex:e {
359 \exp_args:Ne
360 \tl_range:nnn
361 { \int_to_hex:e { \char_value_mathcode:n { `#1 } } }
362 { 3 }
363 { 4 }
364 }
365 }
366 }\tex_par:D
367 Class:~
368 \int_case:Vn \l_tmpb_int
369 {
370 { 0 } { Ordinary }
371 { 1 } { Large~operator }
372 { 2 } { Binary~operation }
373 { 3 } { Relation }
374 { 4 } { Opening }
375 { 5 } { Closing }
376 { 6 } { Punctuation }
377 { 7 } { Variable~family }
378 }\tex_par:D
379 Math~family:~\int_use:N \l_@@_char_math_fam_int\tex_par:D
380 Font~position:~\int_use:N \l_@@_char_math_slot_int\tex_cr:D
381 \int_compare:nNnF { \number\delcode`#1 } < { 0 }
382 {
383 Delimiter~code &
384 \int_set:Nn \l_@@_small_variant_family_int
385 {
386 \tl_head:e {
387 \@@_char_value_delcode:n { `#1 }
388 }
389 }
390 \exp_args:NNe
391 \int_set:Nn \l_@@_small_variant_position_int
392 {
393 \exp_args:Ne
394 \tl_range:nnn
395 { \@@_char_value_delcode:n { `#1 } }
396 { 2 }
397 { 3 }
398 }
399 \exp_args:NNe
400 \int_set:Nn \l_@@_big_variant_family_int
401 {
402 \exp_args:Ne
403 \tl_item:nn
404 { \@@_char_value_delcode:n { `#1 } }
405 { 4 }
406 }
407 \exp_args:NNe
408 \int_set:Nn \l_@@_big_variant_position_int
409 {
410 \exp_args:Ne
411 \tl_range:nnn
412 { \@@_char_value_delcode:n { `#1 } }
413 { 5 }
414 { 6 }
415 }
416 \@@_char_value_delcode:n { `#1 } \tex_par:D
417 Small~variant~family:~\int_use:N \l_@@_small_variant_family_int \tex_par:D
418 Small~variant~position:~\int_use:N \l_@@_small_variant_position_int \tex_par:D
419 Big~variant~family:~\int_use:N \l_@@_big_variant_family_int \tex_par:D
420 Big~variant~position:~\int_use:N \l_@@_big_variant_position_int
421 }
422 \tex_crcr:D
423 }
424 }
425
426 \cs_new_protected:Npn \@@_register_meaning:n #1 {
427 \regex_extract_all:neN { \\([a-z]+)(\d+) } { \cs_meaning:c { #1 } } \l_tmpa_seq
428 \str_case_e:nnF { \seq_item:Nn \l_tmpa_seq { 2 } }
429 {
430 { toks } { \tl_set:Nn \l_@@_register_type_tl { token } }
431 { dimen } { \tl_set:Nn \l_@@_register_type_tl { dimension } }
432 }
433 { \tl_set:Ne \l_@@_register_type_tl { \seq_item:Nn \l_tmpa_seq { 2 } } }
434 \@@_tex_halign:n { \tex_hfil:D##&\c_space_tl=\c_space_tl\vbox_top:n{\raggedright##}\tex_cr:D
435 Register~name & \c_backslash_str #1 \tex_cr:D
436 Type & \tl_use:N \l_@@_register_type_tl\ (no.~\seq_item:Nn \l_tmpa_seq { 3 })\tex_cr:D
437 Content & \exp_last_unbraced:Ne \tex_the:D { \use:c { #1 } }
438 \tex_crcr:D
439 }
440 }
441
442 \cs_new_protected:Npn \@@_data_type_meaning:n #1 {
443 \@@_tex_halign:n { \tex_hfil:D##&\c_space_tl=\c_space_tl\vbox_top:n{\raggedright##}\tex_cr:D
444 Variable & \slshape \str_use:N \c_backslash_str \tl_to_str:n { #1 } \tex_cr:D
445 Data~type & \str_case_e:nn { \seq_item:Nn \l_tmpb_seq { 4 } }
446 {
447 { tl } { token }
448 { str } { string }
449 { seq } { sequence }
450 { int } { integer }
451 { fp } { floating~point }
452 { flag } { flag }
453 { clist } { comma~list }
454 { prop } { property~list }
455 { dim } { dimension }
456 { intarray } { integer~array }
457 { fparray } { floating~point~array }
458 { bitset } { bitset }
459 { cctab } { category~code~table }
460 { bool } { boolean }
461 { regex } { regular~expression }
462 { ior } { input/output~read~stream }
463 { iow } { input/output~write~stream }
464 { box } { box }
465 { coffin } { coffin }
466 } \tex_cr:D
467 Content &
468 \exp_last_unbraced:Ne
469 \scan_stop:
470 {
471 \str_case_e:nn { \seq_item:Nn \l_tmpb_seq { 4 } }
472 {
473 { tl } { \exp_not:N \tl_use:c }
474 { str } { \exp_not:N \str_use:c }
475 { seq } { \exp_not:N \@@_print_seq:c }
476 { int } { \exp_not:N \int_use:c }
477 { fp } { \exp_not:N \fp_use:c }
478 { flag } { \exp_not:N \flag_height:c }
479 { clist } { \exp_not:N \@@_print_clist:c }
480 { prop } { \exp_not:N \@@_print_prop:c }
481 { dim } { \exp_not:N \dim_use:c }
482 { bitset } { \exp_not:N \bitset_use:c }
483 { bool } { \exp_not:N \bool_to_str:c }
484 { box } { \exp_not:N \box_use:c }
485 }
486 }
487 { #1 }\tex_cr:D
488 Scope & \str_case_e:nn { \seq_item:Nn \l_tmpb_seq { 2 } }
489 {
490 { g } { global }
491 { l } { local }
492 { c } { constant }
493 } \tex_cr:D
494 Use & \int_case:nn { \int_eval:n { \tl_count:e { \seq_item:Nn \l_tmpb_seq { 3 } } } }
495 {
496 { 1 } { public }
497 { 2 } { private }
498 }
499 \tex_crcr:D
500 }
501 }
502
503 \cs_new_protected:Npn \@@_chardef_meaning:n #1 {
504 \regex_extract_all:neN { \\(math)?char"([0-9A-Z]+) } { \cs_meaning:c { #1 } } \l_tmpa_seq
505 \@@_tex_halign:n { \tex_hfil:D##&\c_space_tl=\c_space_tl\vbox_top:n{\raggedright##}\tex_cr:D
506 Character~definition & \c_backslash_str #1 \tex_cr:D
507 Glyph &
508 \tl_if_empty:eTF { \seq_item:Nn \l_tmpa_seq { 2 } }
509 { \char\exp_last_unbraced:Ne"{ \seq_item:Nn \l_tmpa_seq { 3 } } }
510 { $ \mathchar\exp_last_unbraced:Ne"{ \seq_item:Nn \l_tmpa_seq { 3 } } $ }
511 \tex_cr:D
512 Mode & \tl_if_empty:eTF { \seq_item:Nn \l_tmpa_seq { 2 } } { text } { math }
513 \tex_crcr:D
514 }
515 }
516
517 \cs_new_protected:Npn \@@_macro_meaning:n #1 {
518 \@@_tex_halign:n { \tex_hfil:D##&\c_space_tl=\c_space_tl\vbox_top:n{\raggedright##}\tex_cr:D
519 Control~sequence &
520 \tl_set:Nn \l_tmpa_tl { #1 }
521 \tl_replace_all:Nnn \l_tmpa_tl { ~ } { \textvisiblespace }
522 \slshape \str_use:N \c_backslash_str \tl_use:N \l_tmpa_tl \tex_cr:D
523 Type &
524 \exp_args:Nc \token_if_macro:NT { #1 }
525 {
526 \regex_match_case:nnF
527 {
528 { \w+:[NnVvcofexTFwD]* } { expl3~macro }
529 { :{2}[NnVvcofexTFwD]_unbraced } { expl3~argument~specifier~(unbraced~type) }
530 { :{2}[NnVvcofexTFwD]\Z } { expl3~argument~specifier }
531 { :{3} } { expl3~identity~macro }
532 { [a-zA-Z]\s code } { xparse~macro }
533 }
534 { #1 }
535 { \TeX\ macro }
536 }
537 \exp_args:Nc \token_if_primitive:NT { #1 }
538 {
539 \regex_if_match:nnTF { tex\_\w+:D } { #1 }
540 { expl3~primitive }
541 { \TeX\ primitive }
542 }
543 \tex_cr:D
544 \exp_args:Nc \token_if_primitive:NF { #1 }
545 {
546 \tl_if_empty:eF { \exp_args:Nc \cs_prefix_spec:N { #1 } }
547 { Prefix & \exp_args:Nc \cs_prefix_spec:N { #1 } \tex_cr:D }
548 }
549 \exp_args:Nc \token_if_primitive:NF { #1 }
550 {
551 \tl_if_empty:eF { \exp_args:Nc \cs_parameter_spec:N { #1 } }
552 { Parameters & \exp_args:Nc \cs_parameter_spec:N { #1 } \tex_cr:D }
553 }
554 \exp_args:Nc \token_if_primitive:NF { #1 }
555 { Replacement~text & \cs_replacement_spec:c { #1 } }
556 \tex_crcr:D
557 }
558 }
559
560 \cs_new_protected:Npn \@@_control_sequence_meaning:n #1 {
561 \cs_if_exist:cTF { #1 }
562 {
563 \regex_extract_all:nnNTF { \A(g|l|c)(_{1,2})\w*_([a-z]*) } { #1 } \l_tmpb_seq
564 { \@@_data_type_meaning:n { #1 } }
565 {
566 \regex_match_case:neF
567 {
568 { \\(math)?char"([0-9A-Z]+) } { \@@_chardef_meaning:n { #1 } }
569 { \\[a-z]+\d+ } { \@@_register_meaning:n { #1 } }
570 }
571 { \cs_meaning:c { #1 } }
572 { \@@_macro_meaning:n { #1 } }
573 }
574 }
575 {
576 \bool_set_true:N \l_@@_undefined_cs_bool
577 \bool_if:NF \l_@@_exhaustive_meaning_bool
578 { Undefined }
579 }
580 }
581
582 \cs_new_protected:Npn \@@_xmeaning_ii:n #1 {
583 \group_begin:
584 \ttfamily
585 \frenchspacing
586 \clist_set:Nn \l_tmpa_clist { #1 }
587 \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
588 \seq_map_inline:Nn \l_tmpa_seq
589 {
590 \token_if_cs:NTF ##1
591 { \exp_args:Ne \@@_control_sequence_meaning:n { \cs_to_str:N ##1 } }
592 { \@@_character_meaning:N ##1 }
593 \bool_if:NF \l_@@_undefined_cs_bool
594 { \skip_vertical:N \l_@@_meaning_skip }
595 }
596 \group_end:
597 }
598
599 \cs_new:Npn \@@_xmeaning_tl_map:nw #1#2#3 \q_stop
600 {
601 \str_if_eq:nnTF { #2 } { #1 }
602 { @ }
603 { #2 }
604 \tl_if_empty:nF { #3 }
605 { \@@_xmeaning_tl_map:nw { #1 } #3 \q_stop }
606 }
607
608 \cs_new:Npn \@@_xmeaning_replace_a_tokens:n #1
609 { \__xmeaning_tl_map:nw { a } #1 \q_stop }
610
611 \cs_new:Npn \@@_xmeaning_replace_o_tokens:n #1
612 { \__xmeaning_tl_map:nw { o } #1 \q_stop }
613
614 \cs_new_protected:Npn \@@_xmeaning_i:n #1 {
615 \group_begin:
616 \bool_set_true:N \l_@@_exhaustive_meaning_bool
617 \ttfamily
618 \frenchspacing
619 \clist_set:Nn \l_tmpa_clist { #1 }
620 \clist_map_inline:Nn \l_tmpa_clist
621 {
622 \clist_clear:N \l_tmpb_clist
623 \tl_set:Ne \l_tmpa_tl
624 {
625 \token_if_cs:NTF ##1
626 { \cs_to_str:N ##1 }
627 { ##1 }
628 }
629 \clist_put_right:Nf \l_tmpb_clist { \l_tmpa_tl\c_space_tl }
630 \clist_put_right:Nf \l_tmpb_clist { \l_tmpa_tl\c_space_tl code}
631 \clist_put_right:Ne \l_tmpb_clist { end\l_tmpa_tl}
632 \exp_args:NNe \int_set:Nn \l_tmpa_int { \tl_count:V \l_tmpa_tl }
633 \int_step_inline:nn { 26 }
634 {
635 \clist_put_right:Ne \l_tmpb_clist { \int_to_Alph:n { ####1 } \l_tmpa_tl, }
636 \clist_put_right:Ne \l_tmpb_clist { \l_tmpa_tl \int_to_Alph:n { ####1 }, }
637 }
638 \int_step_inline:nn { 10 }
639 { \clist_put_right:Ne \l_tmpb_clist { \l_tmpa_tl @\int_to_roman:n { ####1 } } }
640 \int_step_inline:nnn { 0 } { \l_tmpa_int }
641 {
642 \clist_put_right:Ne \l_tmpb_clist
643 {
644 \exp_args:NV \tl_range:nnn { \l_tmpa_tl } { 1 } { ####1 }
645 @
646 \exp_args:NV \tl_range:nnV { \l_tmpa_tl } { \int_eval:n{ ####1+1 } } \l_tmpa_int
647 }
648 }
649 \tl_if_in:NnT \l_tmpa_tl { a }
650 {
651 \clist_put_right:Ne \l_tmpb_clist
652 { \exp_args:NV \@@_xmeaning_replace_a_tokens:n \l_tmpa_tl }
653 }
654 \tl_if_in:NnT \l_tmpa_tl { o }
655 {
656 \clist_put_right:Ne \l_tmpb_clist
657 { \exp_args:NV \@@_xmeaning_replace_o_tokens:n \l_tmpa_tl }
658 }
659 \clist_put_right:Ne \l_tmpb_clist
660 { __\l_tmpa_tl }
661 \@@_xmeaning_ii:n { ##1 }
662 \clist_map_inline:Nn \l_tmpb_clist
663 { \exp_args:Nc \@@_xmeaning_ii:n { ####1 } }
664 }
665 \group_end:
666 }
667
668 \NewDocumentCommand{\xmeaning}{ s m }{
669 \IfBooleanTF{#1}
670 { \@@_xmeaning_i:n { #2 } }
671 { \@@_xmeaning_ii:n { #2 } }
672 }
673
674 \ExplSyntaxOff
675 % \end{macrocode}