summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex')
-rw-r--r--Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex166
1 files changed, 166 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex b/Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex
new file mode 100644
index 00000000000..b7d7813d426
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex
@@ -0,0 +1,166 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% CAP --- Macros for typesetting programs in C and Pascal %
+% Micha\l{} Gulczy\'nski, Szczecin, Feb 1997 / Feb 1998 %
+% mgulcz@we.tuniv.szczecin.pl %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% version 1.2
+% This file contains macros for typesetting programs in Pascal.
+% It belongs to the CAP package. Do not distribute separately.
+%
+% All font definitions are located in the cap_comm.tex file.
+%
+
+%
+% set of keywords; they must be separated with spaces
+% a space must precede the first one and follow the last one, too
+%
+\def\KeywordsPascal{
+and as asm array begin case class const constructor destructor
+div do downto else end except exports file finally for function goto
+if implementation in inherited inline initialization interface is label
+library mod nil not object of or packed procedure program property
+raise record repeat set shl shr string then to try type unit until
+uses var while with xor
+}
+\catcode`\@ = 11
+%
+% that's where we begin
+%
+\def\BeginPascal{%
+ \@PrepareCPas
+ \@LetsStartPascal
+}%
+% Some people in Poland use so-called ``slash notation''
+% to represent certain Polish letters --- in this situation
+% slash is an active character. On the other hand we use slash
+% in pathnames: directory/subdirectory/file. I made this part
+% sooo complicated, bacause I had to neutralise slash in
+% \InsertPascal.
+\def\@InputPascal#1{%
+ \message{(Pascal: #1}%
+ \openin\@InFile = #1
+ \@PrepareCPas
+ % The file is read line by line and each line is typeset
+ % just like a separate program. Therefore the size of program
+ % typeset using this macro is (almost) unlimited.
+ \loop
+ \global\read\@InFile to \@TextOfProgram
+ \@WriteTextOfProgramPascal
+ \if \neof\@InFile \repeat
+ \closein\@InFile
+ \endgroup % this group was begun by \@PrepareCPas
+ \endgroup % this group was begun by \InputPascal
+ \message{)}%
+}
+\def\InputPascal{%
+ \begingroup
+ \catcode`\/ = 11
+ \@InputPascal
+}%
+%
+% delimiter \EndC will be ordinary text
+%
+{ \catcode`\|=0 \catcode`\\=12
+ |gdef|@LetsStartPascal#1\EndPascal{%
+ |gdef|@TextOfProgram{#1}%
+ |@WriteTextOfProgramPascal
+ |endgroup % this group was begun by \@PrepareCPas
+ }
+}
+%
+% macro \@TextOfProgram contains the whole text of program
+%
+\def\@WriteTextOfProgramPascal{%
+ \expandafter\@ReadCharPascal\@TextOfProgram\@EndOfProgram
+}
+%
+% heart of the program -- the argument is a single char
+%
+\def\@ReadCharPascal#1{%
+ % this macro calls itself until the argument #1 is \@EndOfProgram
+ \if\@Identical{\string#1}{\string\@EndOfProgram}%
+ \let\@WhatNext = \relax
+ \else
+ \let\@WhatNext = \@ReadCharPascal
+ \global\@CharCode = `#1\relax
+ \ifcase \@WhereAmI
+ %%%%%%%%%%%%%%%%%%%
+ % \@NothingSpecial:
+ %%%%%%%%%%%%%%%%%%%
+ \ifnum \@PrevChar=`\(
+ \ifnum \@CharCode=`\*
+ \global\@WhereAmI = \@LongComment
+ \CommentFont
+ \fi
+ (%
+ \fi
+ % the longest possible string containing only letters and digits
+ % is either a keyword or an identifier
+ \if\@DigitLetter{\@CharCode}%
+ \edef\@Word{\@Word#1}%
+ \else
+ \if\@Identical{\@Word}{}%
+ \else
+ \@WriteWord{\@Word}{\KeywordsPascal}%
+ \def\@Word{}%
+ \fi
+ \ifnum \@CharCode=`\{
+ \global\@WhereAmI = \@ShortComment
+ \CommentFont
+ \fi
+ \ifnum \@CharCode=`\'
+ \global\@WhereAmI = \@Text
+ \TextFont
+ \fi
+ \ifnum \@CharCode=`\(
+ \else
+ \@WriteChar{#1}%
+ \fi
+ \fi
+ \or
+ %%%%%%%%%
+ % \@Text:
+ %%%%%%%%%
+ \@WriteChar{#1}%
+ \ifnum \@CharCode=`\'
+ \global\@WhereAmI = \@NothingSpecial
+ \SymbolFont
+ \fi
+ \or
+ %%%%%%%%%%%%%%
+ % \@Directive:
+ %%%%%%%%%%%%%%
+ % there are no directives in Pascal, but i'll leave it
+ \or
+ %%%%%%%%%%%%%%%%%
+ % \@ShortComment:
+ %%%%%%%%%%%%%%%%%
+ \@WriteChar{#1}%
+ \ifnum \@CharCode=`\}
+ \global\@WhereAmI = \@NothingSpecial
+ \SymbolFont
+ \fi
+ \or
+ %%%%%%%%%%%%%%%%
+ % \@LongComment:
+ %%%%%%%%%%%%%%%%
+ \@WriteChar{#1}%
+ \ifnum \@PrevChar=`\*
+ \ifnum \@CharCode=`\)
+ \global\@WhereAmI = \@NothingSpecial
+ \SymbolFont
+ \@CharCode = 32
+ \fi
+ \fi
+ \fi
+ \global\@PrevChar = \@CharCode
+ \fi
+ \@WhatNext
+}
+
+\ifx \@PrepareCPas \@Dont@Know@What@It@Is
+ \input cap_comm
+\fi
+
+\catcode`\@ = 12