% This file is only intended to be input by Tcode_Ccode.tex

%%%   Comments   %%%

\exP\def\csname CComment/\endcsname{\bgroup\global\let\CContinueInTheMiddle\SetupCCommentLine\SetupCCommentLine\CCommentLine}
\exP\def\csname CComment*\endcsname{\bgroup\global\let\CContinueInTheMiddle\SetupCCommentOld\SetupCCommentOld\CCommentOld}

%Definition for inline environments
\def\CCommentLine#1\end{//#1\egroup\@parsecode\end}

\catcode`\^^M=13 %
\def\CCommentLineM#1^^M{//#1\egroup\@parsecode^^M} %Definition for Code
\def\CCommentOld#1*/{/*#1*/\egroup\@parsecode}
\catcode`\^^M=5 %

{%local-global in order to avoid \csFormat defining the c.s.
\xdef\SetupCCommentLineNoEsc{\csFormat{Comment}}
\xdef\SetupCCommentOldNoEsc{\csFormat{CommentOld}}
}
%Add \SetEscapeChar to the setup of Comment lines, and so { and } to work like in TeX.
\toks0={\catcode`\{=1 \catcode`\}=2 }
\edef\SetupCCommentLineEsc{\expandonce\SetupCCommentLineNoEsc \the\toks0 \expandonce\MakeAtEscape}
\edef\SetupCCommentOldEsc{\expandonce\SetupCCommentOldNoEsc \the\toks0 \expandonce\MakeAtEscape}

% ... and make it the default.
\let\SetupCCommentLine\SetupCCommentLineEsc
\let\SetupCCommentOld\SetupCCommentOldEsc

%By default @ acts as escape and { } group. This deactivates that.
\def\CodeNoEscInComments{
  \let\SetupCCommentLine\SetupCCommentLineNoEsc
  \let\SetupCCommentOld\SetupCCommentOldNoEsc
}
\def\CodeEscInComments{
  \let\SetupCCommentLine\SetupCCommentLineEsc
  \let\SetupCCommentOld\SetupCCommentOldEsc
}
%Names with "C" within, for multilingual documents and users who prefer it that way
\let\CodeNoEscInCComments\CodeNoEscInComments
\let\CodeEscInCComments\CodeEscInComments