diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/catc-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/catc-ini.mkiv | 191 |
1 files changed, 114 insertions, 77 deletions
diff --git a/Master/texmf-dist/tex/context/base/catc-ini.mkiv b/Master/texmf-dist/tex/context/base/catc-ini.mkiv index 269330a1bbd..9221d17c51f 100644 --- a/Master/texmf-dist/tex/context/base/catc-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/catc-ini.mkiv @@ -14,32 +14,66 @@ %D We've split the functionality of syst-cat.* over more files %D now so that we can load more selectively. -\registerctxluafile{catc-ini} {1.001} +\registerctxluafile{catc-ini}{1.001} %D A long standing wish has been the availability of catcode %D arrays. Because traditional \TEX\ does not provide this we %D implement a fake method in the \MKII\ file. There is some %D overlap in code with \MKII\ but we take that for granted. -\ifx\zerocount\undefined \chardef \zerocount= 0 \fi -\ifx\plusone \undefined \chardef \plusone = 1 \fi -\ifx\minusone \undefined \newcount\minusone \minusone =-1 \fi - -\chardef\escapecatcode = 0 -\chardef\begingroupcatcode = 1 -\chardef\endgroupcatcode = 2 -\chardef\mathshiftcatcode = 3 -\chardef\alignmentcatcode = 4 -\chardef\endoflinecatcode = 5 -\chardef\parametercatcode = 6 -\chardef\superscriptcatcode = 7 -\chardef\subscriptcatcode = 8 -\chardef\ignorecatcode = 9 -\chardef\spacecatcode = 10 -\chardef\lettercatcode = 11 -\chardef\othercatcode = 12 \chardef\other = 12 -\chardef\activecatcode = 13 \chardef\active = 13 -\chardef\commentcatcode = 14 +\setnewconstant\escapecatcode 0 +\setnewconstant\begingroupcatcode 1 +\setnewconstant\endgroupcatcode 2 +\setnewconstant\mathshiftcatcode 3 +\setnewconstant\alignmentcatcode 4 +\setnewconstant\endoflinecatcode 5 +\setnewconstant\parametercatcode 6 +\setnewconstant\superscriptcatcode 7 +\setnewconstant\subscriptcatcode 8 +\setnewconstant\ignorecatcode 9 +\setnewconstant\spacecatcode 10 +\setnewconstant\lettercatcode 11 +\setnewconstant\othercatcode 12 \let\other \othercatcode +\setnewconstant\activecatcode 13 \let\active\activecatcode +\setnewconstant\commentcatcode 14 +\setnewconstant\invalidcatcode 15 + +\setnewconstant\tabasciicode 9 +\setnewconstant\newlineasciicode 10 % don't confuse this one with \endoflineasciicode +\setnewconstant\formfeedasciicode 12 +\setnewconstant\endoflineasciicode 13 % somewhat messy but this can be the active \par +\setnewconstant\endoffileasciicode 26 +\setnewconstant\spaceasciicode 32 +\setnewconstant\hashasciicode 35 +\setnewconstant\dollarasciicode 36 +\setnewconstant\commentasciicode 37 +\setnewconstant\ampersandasciicode 38 +\setnewconstant\backslashasciicode 92 % `\\ +\setnewconstant\circumflexasciicode 94 +\setnewconstant\underscoreasciicode 95 +\setnewconstant\leftbraceasciicode 123 % `\{ +\setnewconstant\barasciicode 124 % `\| +\setnewconstant\rightbraceasciicode 125 % `\} +\setnewconstant\tildeasciicode 126 % `\~ +\setnewconstant\delasciicode 127 + +\bgroup + \catcode \tabasciicode \activecatcode \gdef\activetabtoken {^^I} + \gdef\outputnewlinechar {^^J} + \catcode \formfeedasciicode \activecatcode \gdef\activeformfeedtoken {^^L} + \catcode \endoflineasciicode \activecatcode \gdef\activeendoflinetoken{^^M} +\egroup + +% \endlinechar = \endoflineasciicode % appended to input lines +% \newlinechar = \newlineasciicode % can be used in write + +% rather special and used in writing to file: \let\par\outputnewlinechar + +\def\initializenewlinechar % operating system dependent + {\bgroup + \newlinechar\newlineasciicode + \xdef\outputnewlinechar{^^J}% + \egroup} \ifx\gobbleoneargument\undefined \long\def\gobbleoneargument#1{} \fi @@ -54,21 +88,20 @@ \def\newcatcodetable#1% {\global\advance\cctdefcounter\plusone \expandafter\xdef\csname @@ccn:\number\cctdefcounter\endcsname{\string#1}% logging - \global\chardef#1\cctdefcounter - \ctxlua{catcodes.register("\expandafter\gobbleoneargument\string#1",\number#1)}% - % we have two ways to access catcodetable numbers - \startruntimectxluacode tex.\expandafter\gobbleoneargument\string#1 = \number#1 ;\stopruntimectxluacode} + \newconstant#1% + #1\cctdefcounter + \ctxlua{catcodes.register("\expandafter\gobbleoneargument\string#1",\number#1)}} \newcatcodetable \scratchcatcodes \initcatcodetable\scratchcatcodes \newtoks \setdefaultcatcodes \setdefaultcatcodes - {\catcode`\\ \othercatcode - \catcode`\^^M \othercatcode - \catcode`\ \othercatcode - \catcode`\% \othercatcode - \catcode127 \othercatcode} + {\catcode\backslashasciicode\othercatcode + \catcode\endoflineasciicode\othercatcode + \catcode\spaceasciicode \othercatcode + \catcode\commentasciicode \othercatcode + \catcode\delasciicode \othercatcode} \long\normalprotected\def\startcatcodetable#1#2\stopcatcodetable {\bgroup @@ -78,6 +111,11 @@ \savecatcodetable#1\relax \egroup} +\def\permitcircumflexescape % to be used grouped + {\catcode\circumflexasciicode\superscriptcatcode} + +\let\permitcaretescape\permitcircumflexescape + \newcatcodetable\dummycatcodes \long\normalprotected\def\startextendcatcodetable#1#2\stopextendcatcodetable @@ -111,7 +149,7 @@ %D mechanism? Future versions of \MKIV\ might only use %D active characters for very special cases. -\chardef\activehackcode=`\~ +\setnewconstant\activehackcode \tildeasciicode %D Once a catcode is assigned, the next assignments will happen faster. @@ -187,7 +225,7 @@ \uppercase{\normalprotected\xdef~{\noexpand\catcodecommand{\number\cctcounterb}}}% \egroup} -\chardef\defaultcatcodetable\zerocount +\newconstant\defaultcatcodetable \def\catcodecommand#1% {\csname CCC:\number @@ -197,8 +235,7 @@ :\number#1\endcsname} %D \macros -%D {restorecatcodes, -%D beginrestorecatcodes,endrestorecatcodes} +%D {restorecatcodes,pushcatcodetable,popcatcodetable} %D %D We're not finished dealing \CATCODES\ yet. In \CONTEXT\ we %D use only one auxiliary file, which deals with tables of @@ -210,16 +247,19 @@ %D what the next macros do. Saving the catcodes can be %D disabled by saying \type{\localcatcodestrue}. +% quite likely we will define \unexpanded earlier on so +% that \normalprotected will go + \let\savedcatcodetable\relax \newcount\catcoderestorelevel -\def\pushcatcodetable +\normalprotected\def\pushcatcodetable {\advance\catcoderestorelevel\plusone \tracepushcatcodetable \expandafter\chardef\csname scct:\number\catcoderestorelevel\endcsname\currentcatcodetable} -\def\popcatcodetable +\normalprotected\def\popcatcodetable {\ifcase\catcoderestorelevel \showcatcodenestingerror \else @@ -228,22 +268,22 @@ \advance\catcoderestorelevel\minusone \fi} -\def\showcatcodenestingerror % can be overloaded +\normalprotected\def\showcatcodenestingerror % can be overloaded {\immediate\write16{}% \immediate\write16{Fatal error: catcode push/pop mismatch. Fix this!}\wait\end \immediate\write16{}} -\def\restorecatcodes % takes previous level +\normalprotected\def\restorecatcodes % takes previous level {\ifnum\catcoderestorelevel>\plusone \expandafter\catcodetable\csname scct:\number\numexpr\catcoderestorelevel-1\relax\endcsname \fi} \newtoks\everycatcodetable -\def\setcatcodetable#1% - {\catcodetable#1% - \the\everycatcodetable - \tracesetcatcodetable} +\normalprotected\def\setcatcodetable#1% + {\catcodetable#1% + \the\everycatcodetable + \tracesetcatcodetable} \def\dotracecatcodetable#1{\immediate\write16{[#1]}} @@ -272,46 +312,43 @@ \let\tracepushcatcodetable\empty \let\tracepopcatcodetable \empty -\def\beginrestorecatcodes{\pushcatcodetable} -\def\endrestorecatcodes {\popcatcodetable} - %D Handy for debugging: % \tracecatcodetables -%D Only in \MKIV\ (to be used when crossing pages with changed catcodes -%D in the current vector): -%D -%D \starttyping -%D \normalprotected\def\startcrap -%D {\bgroup -%D \pushcatcodes -%D \whitespace -%D \obeylines -%D \activatespacehandler\v!yes -%D \strut} -%D -%D \normalprotected\def\stopcrap -%D {\popcatcodes -%D \egroup} -%D \stoptyping - -\newcount\catcodetablelevel - -\def\pushcatcodes - {\bgroup - \global\advance\catcodetablelevel\plusone - \ifcsname @@ccf:\number\catcodetablelevel\endcsname \else - \global\advance\cctdefcounter\plusone - \expandafter\global\expandafter\chardef\csname @@ccf:\number\catcodetablelevel\endcsname\cctdefcounter - \fi - \catcodetable\ctxcatcodes - \expandafter\savecatcodetable\csname @@ccf:\number\catcodetablelevel\endcsname - \egroup - \expandafter\catcodetable\csname @@ccf:\number\catcodetablelevel\endcsname} - -\def\popcatcodes - {\global\advance\catcodetablelevel\minusone} +% D Only in \MKIV\ (to be used when crossing pages with changed catcodes +% D in the current vector): +% D +% D \starttyping +% D \normalprotected\def\startcrap +% D {\bgroup +% D \pushcatcodes +% D \whitespace +% D \obeylines +% D \activatespacehandler\v!yes +% D \strut} +% D +% D \normalprotected\def\stopcrap +% D {\popcatcodes +% D \egroup} +% D \stoptyping +% +% \newcount\catcodetablelevel +% +% \def\pushcatcodes +% {\bgroup +% \global\advance\catcodetablelevel\plusone +% \ifcsname @@ccf:\number\catcodetablelevel\endcsname \else +% \global\advance\cctdefcounter\plusone +% \expandafter\global\expandafter\chardef\csname @@ccf:\number\catcodetablelevel\endcsname\cctdefcounter +% \fi +% \catcodetable\ctxcatcodes +% \expandafter\savecatcodetable\csname @@ccf:\number\catcodetablelevel\endcsname +% \egroup +% \expandafter\catcodetable\csname @@ccf:\number\catcodetablelevel\endcsname} +% +% \def\popcatcodes +% {\global\advance\catcodetablelevel\minusone} \endinput |