% This is part of the Tcode kernel. Only intended to by input by it. %%%%%%**** A single format for all its argument: \f(ormat)code, \F(ormat)code, \ident, \IDENT, \FastIdent and \Fastfid ****%%%%%% %Format code with a given format. #1 is the format (e.g., \FormatMacro) \def\fcodeinit{\ifmmode\exP\hbox\fi\bgroup\SetFcodeCatcodes\MakeDefineFDollar} \protected\def\formatcode#1{\fcodeinit\catcode`\ =10 \the\ShortNcodeHook\f@code#1} \protected\def\Formatcode#1{\fcodeinit\the\ShortNcodeHook\F@code#1} \def\f@code#1#2{#1{\scantokensfixed{#2}}\egroup} %Does not carry a \relax because space has cat. 10 anyway. \def\F@code#1#2{#1{#2}\egroup} %The brace { also serves to break \ignorespaces (from \color) % \def\fcode#1{\exP\formatcode\csname Format\TcodeLang#1\endcsname} \def\Fcode#1{\exP\Formatcode\csname Format\TcodeLang#1\endcsname} %Guess the format from the argument (i.e., format a single identifier) \protected\def\ident{\ifIdboxed\bgroup\SetIdentCatcodes\the\ShortNcodeHook\ident@} \protected\def\IDENT{\ifIdboxed\bgroup\SetIdentCatcodes\the\ShortNcodeHook\IDENT@} \ifdefined\scantextokens \def\ident@#1{\WordToPrint\exP{\scantextokens{#1}} {\aftergroup\letFormatToApply\exP\aftergroup\csname Format\TcodeLang @#1\endcsname} \PrePrintHook \ifx\FormatToApply\undefined \exP\FormatOtherWords \else \exP\FormatToApply \fi {\the\WordToPrint}\egroup } \else \def\ident@#1{\endlinechar\m@ne \everyeof={}\edef\TheIdent{\scantokens{#1\noexpand}}\WordToPrint\exP{\TheIdent} {\aftergroup\letFormatToApply\exP\aftergroup\csname Format\TcodeLang @#1\endcsname} \PrePrintHook \ifx\FormatToApply\undefined \exP\FormatOtherWords \else \exP\FormatToApply \fi {\the\WordToPrint}\egroup } \fi \def\IDENT@#1{\condCsname Format\TcodeLang @#1\endcsname{\scantokensfixed{#1}}\egroup} % \FastIdent, \Fastfid. No \hbox (hence, no test for modes, nor \quitvmode). No rescan of the argument. Handles dollar. % Fastfid. ('f' = 'formatted'). Gets the format, e.g. \FormatMacro, as its first argument. FastIdent guesses it. \Fastfid is faster. % \Fastfid does not place extra braces around the word. So if you want your formatting macro to take it as argument, you have to write, e.g., % \Fastid\FormatNamedConstant{{true}} (note the extra pair of braces) \protected\def\FastIdent{\bgroup\SetIdentCatcodes\the\ShortNcodeHook\FastIdent@} \protected\def\Fastfid{\bgroup\SetIdentCatcodes\the\ShortNcodeHook\Fastfid@} \def\FastIdent@#1{\condCsname Format\TcodeLang @#1\endcsname #1\egroup} \def\Fastfid@#1#2{#1#2\egroup} %%%%%%**** Format each word of its argument: \ncode, \Ncode, \nscode ****%%%%%% % \@parsecode is the macro that keeps taking one token at a time. \end signals the end. %\nscode is like \ncode, but takes care of ignoring spaces before the {, as in \nscode {signed char}. \ncode is still needed for getting # right. \protected\def\ncode{\quitvmode\ifmmode\exP\hbox\fi\bgroup\SetncodeCatcodes\the\LongNcodeHook\n@code} \protected\def\nscode#1{\quitvmode\ifmmode\exP\hbox\fi\bgroup\SetncodeCatcodes\the\LongNcodeHook\n@code{#1}} \protected\def\Ncode{\quitvmode\ifmmode\exP\hbox\fi\bgroup\SetNcodeCatcodes\the\LongNcodeHook\N@code} \ifdefined\scantextokens \def\n@code#1{\exP\@parsecode\scantextokens{#1\end}\spacefactor\@m\egroup} \else \def\n@code#1{\endlinechar\m@ne\everyeof={}\exP\@parsecode\scantokens{#1\end}\spacefactor\@m\egroup} \fi \def\N@code#1{\@parsecode #1\end\spacefactor\@m\egroup}