\writestatus{loading}{Pretty Pseudo Code Verbatim}

\unprotect

\gdef\PSEUDOsetcontrols%
  {\saveprettycontrols
   \everyprettyend
     {\endPSEUDOsix}%
   \def\obeyedspace%
     {\endPSEUDOtypefour
      \oldobeyedspace}%
   \def\flushrestofverbatimline%
     {\endPSEUDOtypefour}%
   \let\obeytabs=\ignoretabs}

\gdef\setupprettyPSEUDOtype%
  {\def\prettyidentifier{PSEUDO}%
   \PSEUDOsetvariables
   \PSEUDOsetcontrols
   \PSEUDOsethandlers
   \PSEUDOsetspecials}

\gdef\PSEUDOsetvariables%
  {\global\let\PSEUDOsequence=\empty}

\gdef\PSEUDOsetspecials%
  {\setpretty`\%=1
   \setpretty`\$=3 \setpretty`\{=3 \setpretty`\}=3 \setpretty`\[=3
   \setpretty`\]=3 \setpretty`\(=3 \setpretty`\)=3 \setpretty`\==3
   \setpretty`\<=3 \setpretty`\>=3 \setpretty`\"=3 \setpretty`\-=3
   \setpretty`\+=3 \setpretty`\/=3 \setpretty`\|=3 \setpretty`\'=3
   \setpretty`\`=3 \setpretty`\_=3 \setpretty`\&=3 \setpretty`\~=3
   \setpretty`\.=3 \setpretty`\,=3 \setpretty`\:=3 \setpretty`\;=3
   \setpretty`\*=3 \setpretty`\\=3 \setpretty`\^=3 \setpretty`\#=5
   \setpretty`\1=3 \setpretty`\2=3 \setpretty`\3=3 \setpretty`\3=3
   \setpretty`\5=3 \setpretty`\6=3 \setpretty`\7=3 \setpretty`\8=3
   \setpretty`\9=3 \setpretty`\0=3
   \setpretty`\A=3 \setpretty`\B=3 \setpretty`\C=3 \setpretty`\D=3
   \setpretty`\E=3 \setpretty`\F=3 \setpretty`\G=3 \setpretty`\H=3 
   \setpretty`\I=3 \setpretty`\J=3 \setpretty`\K=3 \setpretty`\L=3
   \setpretty`\M=3 \setpretty`\N=3 \setpretty`\O=3 \setpretty`\P=3
   \setpretty`\Q=3 \setpretty`\R=3 \setpretty`\S=3 \setpretty`\T=3
   \setpretty`\U=3 \setpretty`\V=3 \setpretty`\W=3 \setpretty`\X=3 
   \setpretty`\Y=3 \setpretty`\Z=3
   \setpretty`\a=4 \setpretty`\b=4 \setpretty`\c=4 \setpretty`\d=4 
   \setpretty`\e=4 \setpretty`\f=4 \setpretty`\g=4 \setpretty`\h=4
   \setpretty`\i=4 \setpretty`\j=4 \setpretty`\k=4 \setpretty`\l=4
   \setpretty`\m=4 \setpretty`\n=4 \setpretty`\o=4 \setpretty`\p=4
   \setpretty`\q=4 \setpretty`\r=4 \setpretty`\s=4 \setpretty`\t=4
   \setpretty`\u=4 \setpretty`\v=4 \setpretty`\w=4 \setpretty`\x=4 
   \setpretty`\y=4 \setpretty`\z=4 \setpretty`\?=4 \setpretty`\!=4}

\gdef\PSEUDOsethandlers%
  {\installprettyhandler 1 \PSEUDOtypeone
   \installprettyhandler 2 \PSEUDOtypetwo
   \installprettyhandler 3 \PSEUDOtypethree
   \installprettyhandler 4 \PSEUDOtypefour}

\gdef\PSEUDOtypeone#1%
  {\ifnaturaltextext
     \let\next\naturaltextext
   \else
     \disableprettytrue\disableprettyafterwards
     \def\next%
      {\beginofpretty[\!!prettytwo]%
         {\prettyidentifierfont comment}%
       \endofpretty}%
   \fi
   \next}

\gdef\PSEUDOtypetwo#1%
  {\endPSEUDOtypefour
   \beginofpretty[\!!prettyone]\getpretty{#1}\endofpretty}

\gdef\PSEUDOtypethree#1%
  {\endPSEUDOtypefour
   \getpretty{#1}}

\gdef\endPSEUDOtypefour%
  {\ifx\PSEUDOsequence\empty\else
     \doifprettyidentifierelse{\PSEUDOsequence}{\PSEUDOidentifiers}
       {\beginofpretty[\!!prettytwo]%
          {\prettyidentifierfont\PSEUDOsequence}%
        \endofpretty}
       {\PSEUDOsequence}%
     \global\let\PSEUDOsequence=\empty
   \fi}

\gdef\PSEUDOtypefour#1%
  {\xdef\PSEUDOsequence{\PSEUDOsequence\getpretty{#1}}}

\gdef\PSEUDOmath#1%
  {\naturaltextext\mathematics{#1}\relax}

\gdef\PSEUDOtex#1%
  {\naturaltextext #1\relax}

\useprettyidentifiers \PSEUDOidentifiers \PSEUDOsetspecials
  for to do if then else while foreach

\definetyping[PSEUDO][\c!optie=PSEUDO]

\installprettytype [PSEUDO] [PSEUDO]
\installnewpretty U {\setupprettiesintype{PSEUDO}\setupprettytype}

\definepalet[PSEUDOcolorpretty] [colorpretty]
\definepalet[PSEUDOgraypretty] [graypretty]

\installprettyescape [PSEUDO] $ \PSEUDOmath% $
\installprettyescape [PSEUDO] - \PSEUDOtex

\protect

\endinput

% arch-tag: 10671de6-4b01-4b08-a438-34d99bbb6661
%      vim: set et sts=2 sw=2:
