%D \module
%D   [       file=catc-cys,
%D        version=2006.09.18,
%D          title=\CONTEXT\ Catcode Macros,
%D       subtitle=Extra Tables,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D We prefer to define relevant catcode tables in this file instead
%D of everywhere around.

\ifdefined \ctxcatcodes \else \newcatcodetable \ctxcatcodes \fi
\ifdefined \prtcatcodes \else \newcatcodetable \prtcatcodes \fi
\ifdefined \txtcatcodes \else \newcatcodetable \txtcatcodes \fi
%ifdefined \mthcatcodes \else \newcatcodetable \mthcatcodes \fi % math, not used, too tricky
\ifdefined \tpacatcodes \else \newcatcodetable \tpacatcodes \fi % { }
\ifdefined \tpbcatcodes \else \newcatcodetable \tpbcatcodes \fi % < >

\setnewconstant \doublecommentsignal "10FF25 %% < 110000 (last valid range)

\startcatcodetable \ctxcatcodes
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
  % \catcode\circumflexasciicode\superscriptcatcode
  % \catcode\underscoreasciicode\subscriptcatcode
  % \catcode\ampersandasciicode \alignmentcatcode
    \catcode\underscoreasciicode\othercatcode
    \catcode\circumflexasciicode\othercatcode
    \catcode\ampersandasciicode \othercatcode
    \catcode\backslashasciicode \escapecatcode
    \catcode\leftbraceasciicode \begingroupcatcode
    \catcode\rightbraceasciicode\endgroupcatcode
    \catcode\dollarasciicode    \mathshiftcatcode
    \catcode\hashasciicode      \parametercatcode
    \catcode\commentasciicode   \commentcatcode
    \catcode\tildeasciicode     \activecatcode
    \catcode\barasciicode       \activecatcode
\stopcatcodetable

\startcatcodetable \prtcatcodes
    \catcode\tabasciicode            \spacecatcode
    \catcode\endoflineasciicode      \endoflinecatcode
    \catcode\formfeedasciicode       \endoflinecatcode
    \catcode\spaceasciicode          \spacecatcode
    \catcode\endoffileasciicode      \ignorecatcode
    \catcode\circumflexasciicode     \superscriptcatcode     % candidate
    \catcode\underscoreasciicode     \lettercatcode
    \catcode\ampersandasciicode      \alignmentcatcode
%   \catcode\colonasciicode          \lettercatcode          % candidate
    \catcode\backslashasciicode      \escapecatcode
    \catcode\leftbraceasciicode      \begingroupcatcode
    \catcode\rightbraceasciicode     \endgroupcatcode
    \catcode\dollarasciicode         \mathshiftcatcode
    \catcode\hashasciicode           \parametercatcode
    \catcode\commentasciicode        \commentcatcode
    \catcode\atsignasciicode         \lettercatcode
    \catcode\exclamationmarkasciicode\lettercatcode
    \catcode\questionmarkasciicode   \lettercatcode
    \catcode\tildeasciicode          \activecatcode
    \catcode\barasciicode            \activecatcode
\stopcatcodetable

%startcatcodetable \mthcatcodes
%   \catcode\tabasciicode       \spacecatcode
%   \catcode\endoflineasciicode \endoflinecatcode
%  %\catcode\newlineasciicode   \spacecatcode
%   \catcode\formfeedasciicode  \endoflinecatcode
%   \catcode\spaceasciicode     \spacecatcode
%   \catcode\endoffileasciicode \ignorecatcode
%   \catcode\circumflexasciicode\superscriptcatcode
%   \catcode\underscoreasciicode\subscriptcatcode
%   \catcode\ampersandasciicode \alignmentcatcode
%   \catcode\backslashasciicode \escapecatcode
%   \catcode\leftbraceasciicode \begingroupcatcode
%   \catcode\rightbraceasciicode\endgroupcatcode
%   \catcode\dollarasciicode    \mathshiftcatcode
%   \catcode\hashasciicode      \parametercatcode
%   \catcode\commentasciicode   \commentcatcode
%  %\catcode\tildeasciicode     \activecatcode
%  %\catcode\barasciicode       \activecatcode
%stopcatcodetable

\startcatcodetable \tpacatcodes
    \catcode\tabasciicode       \othercatcode
    \catcode\endoflineasciicode \othercatcode
    \catcode\formfeedasciicode  \othercatcode
    \catcode\spaceasciicode     \othercatcode
    \catcode\endoffileasciicode \othercatcode
    \catcode\leftbraceasciicode \begingroupcatcode
    \catcode\rightbraceasciicode\endgroupcatcode
\stopcatcodetable

\startcatcodetable \tpbcatcodes
    \catcode\tabasciicode       \othercatcode
    \catcode\endoflineasciicode \othercatcode
    \catcode\formfeedasciicode  \othercatcode
    \catcode\spaceasciicode     \othercatcode
    \catcode\endoffileasciicode \othercatcode
    \catcode\lessthanasciicode  \begingroupcatcode
    \catcode\morethanasciicode  \endgroupcatcode
\stopcatcodetable

\startcatcodetable \txtcatcodes
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
    \catcode\backslashasciicode \escapecatcode
    \catcode\leftbraceasciicode \begingroupcatcode
    \catcode\rightbraceasciicode\endgroupcatcode
    \catcode\doublecommentsignal\commentcatcode
\stopcatcodetable

\letcatcodecommand \ctxcatcodes \barasciicode   \relax
\letcatcodecommand \ctxcatcodes \tildeasciicode \relax

     \catcodetable        \ctxcatcodes
\let \defaultcatcodetable \ctxcatcodes

% for the moment here:

\normalprotected\def\starttexcode
  {\pushcatcodetable
   \catcodetable\prtcatcodes}

\normalprotected\def\stoptexcode
  {\popcatcodetable}

\normalprotected\def\startcontextcode
  {\pushcatcodetable
   \catcodetable\ctxcatcodes}

\normalprotected\def\stopcontextcode
  {\popcatcodetable}

% not visible, only for special cases

\newcatcodetable \ctdcatcodes % context definitions

\startcatcodetable \ctdcatcodes
    \catcode\tabasciicode            \ignorecatcode
    \catcode\endoflineasciicode      \ignorecatcode
    \catcode\formfeedasciicode       \ignorecatcode
    \catcode\spaceasciicode          \ignorecatcode
    \catcode\endoffileasciicode      \ignorecatcode
    \catcode\circumflexasciicode     \superscriptcatcode     % candidate
    \catcode\underscoreasciicode     \lettercatcode
    \catcode\ampersandasciicode      \alignmentcatcode
%   \catcode\colonasciicode          \lettercatcode          % candidate
    \catcode\backslashasciicode      \escapecatcode
    \catcode\leftbraceasciicode      \begingroupcatcode
    \catcode\rightbraceasciicode     \endgroupcatcode
    \catcode\dollarasciicode         \mathshiftcatcode
    \catcode\hashasciicode           \parametercatcode
    \catcode\commentasciicode        \commentcatcode
    \catcode\atsignasciicode         \lettercatcode
    \catcode\exclamationmarkasciicode\lettercatcode
    \catcode\questionmarkasciicode   \lettercatcode
    \catcode\tildeasciicode          \activecatcode
    \catcode\barasciicode            \activecatcode
\stopcatcodetable

\normalprotected\def\startcontextdefinitioncode
  {\pushcatcodetable
   \catcodetable\ctdcatcodes}

\normalprotected\def\stopcontextdefinitioncode
  {\popcatcodetable}

\endinput
