\ThisIsLanguage{C}
\input highlighting_common.tex

%%%%%%%%%%*******    Definition of colours and styles for each category    *******%%%%%%%%%%

\DefineColor{comment}{0, .5, 0}
\DefineColor{punctuator}{0.5, 0, 0}
\DefineColor{blue}{0,0,1} % Keyword
\DefineColor{typedef}{0, 0, .68}
\DefineColor{constant}{0.17, 0.57, 0.69} %enum constants and constexpr identifiers
\DefineColor{function}{0.31, 0.22, 0.08}
\DefineColor{tgfunction}{0.28, .1, 0.1}
\DefineColor{macro}{.5, 0, .5}
\DefineColor{pragma}{1, 0.5, 0.5}
\DefineColor{tag}{.4, 0.3, 0} %Struct, union and enum tags
\DefineColor{red}{1,0,0} %Strings
\DefineColor{orange}{0.8, 0.3, 0} %Character literals
\DefineGray{gray4}{0.33} %For obsolescent
\DefineColor{deprecated}{0.66, 0.66, 0.35} %For [deprecated] and the splice char

\TcodeEdefFormat{Punctuator}{\ColFill{punctuator}}
% Punctuators are set up at the end of this file
\TcodeEdefFormat{SpliceChar}{\ColFill{deprecated}} %A \ at end of line

%We use \color for comments and strings instead of \ColFill because they may contain hand crafted rules.
\TcodeEdefFormat{Comment}{\color{comment}}
\TcodeEdefFormat{String}{\color{red}}
\TcodeEdefFormat{CharLit}{\color{orange}}

\TCopyFormat{IntegerSuffix}{Number} %Tcode's default does nothing
\TCopyFormat{FloatingSuffix}{Number}

\TcodeEdefFormat{PPDirective}{\ColFill{blue}}
\TCopyFormat{PPOperator}{PPDirective}
\TcodeEdefFormat{Pragma}{\ColFill{pragma}}
\TcodeEdefFormat{PragmaValue}{\ColFill{pragma}}
\TcodeEdefFormat{PPParameter}{\ColFill{pragma}}

\TcodeEdefFormat{Keyword}{\ColFill{blue}}

\TcodeEdefFormat{Function}{\ColFill{function}}
\TcodeEdefFormat{TGFunction}{\ColFill{tgfunction}} %type generic functions
		\TCopyFormat{QGFunction}{TGFunction}

%Identifiers that are both function and TG-function, like acos, may be defined to either of them or to
%\FormatFuncTGFunc. But this is not defined. The user must redirect them to Function or to TGFunction.
%We route them by default to TGFunction.
\TcodeRedirect{FuncTGFunc}{TGFunction}

\TcodeEdefFormat{Typedef}{\ColFill{typedef}}
\TcodeEdefFormat{StandsForType}{\ColFill{typedef}}
\TcodeEdefFormat{Macro}{\ColFill{macro}}
\TCopyFormat{NamedIdent}{Macro} %__func__, errno, stdin...

\TcodeEdefFormat{Attribute}{\ColFill{tag}}
\TcodeEdefFormat{Struct}{\ColFill{tag}} %Struct tag
\TcodeEdefFormat{Union}{\ColFill{tag}} %Union tag
\TcodeEdefFormat{Enum}{\ColFill{tag}} %Enum tag
\TcodeEdefFormat{StrMember}{\ColFill{member}}
\TcodeEdefFormat{UnionMember}{\ColFill{member}}
\TcodeEdefFormat{EnumConst}{\ColFill{constant}}

\TcodeEdefFormat{Obsolete}{\ColFill{gray4}} %Obsolescent
\TcodeEdefFormat{Deprecated}{\ColFill{deprecated}} %Identifiers marked [deprecated]

%%%%%****    Setting up punctuators    ****%%%%%

\if*\TcodeLang*
  \def\MakePunctChar#1{\TcodeFormatSpecial{#1}{\FormatPunctuator}}
  \def\C@fwdSlash{{\FormatPunctuator /}}
  \catcode`<=13
  \def\NcodeAngleLong{\ifnum\catcode`<=\active \exP<\else{\FormatPunctuator\char`\<}\let\parsecode\@parsecode\fi\parsecode}%
  \catcode`<=12
\else
  \def\MakePunctChar#1{\TcodeFormatSpecial{#1}{\FormatCPunctuator}}
  \def\C@fwdSlash{{\FormatCPunctuator /}}
  \catcode`<=13
  \def\NcodeAngleLong{\ifnum\catcode`<=\active \exP<\else{\FormatCPunctuator\char`\<}\let\parsecode\@parsecode\fi\parsecode}%
  \catcode`<=12
\fi

\def\C@fwdslash{{\FormatPunctuator /}}
\MakePunctChar( \MakePunctChar) \MakePunctChar[ \MakePunctChar]
\MakePunctChar+ \MakePunctChar- \MakePunctChar*
\MakePunctChar| \MakePunctChar^
\MakePunctChar< \MakePunctChar> \MakePunctChar=
\MakePunctChar? \MakePunctChar: \MakePunctChar, \MakePunctChar;
\catcode`\&=12 \catcode`\~=12 \catcode`\%=12
\MakePunctChar& \MakePunctChar~ \MakePunctChar%
\catcode`\&=4 \catcode`\~=13 \catcode`\%=14

{\catcode`[=1 \catcode`]=2
\catcode`\{=12
\catcode`\}=12
\gdef\defpunctbraces[\MakePunctChar{\MakePunctChar}]
]

\exP\CodeHook\exP{\the\CodeHook\defpunctbraces \TcodeLetSpecial<\NcodeAngleLong}

\input C_subcategories.tex