summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/c-pascal
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-12 23:46:03 +0000
committerKarl Berry <karl@freefriends.org>2006-01-12 23:46:03 +0000
commit873660d1a83ece926fe7206288dda9c36b349c1b (patch)
treea48f77125c309a355b5d0eb58d6b24446abe9d62 /Master/texmf-dist/tex/generic/c-pascal
parent2939242967231097459df0fc3150fabc2f639111 (diff)
generic 1
git-svn-id: svn://tug.org/texlive/trunk@613 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/c-pascal')
-rw-r--r--Master/texmf-dist/tex/generic/c-pascal/cap.tex2
-rw-r--r--Master/texmf-dist/tex/generic/c-pascal/cap_c.tex177
-rw-r--r--Master/texmf-dist/tex/generic/c-pascal/cap_comm.tex188
-rw-r--r--Master/texmf-dist/tex/generic/c-pascal/cap_pas.tex166
4 files changed, 533 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/c-pascal/cap.tex b/Master/texmf-dist/tex/generic/c-pascal/cap.tex
new file mode 100644
index 00000000000..8c114f62912
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/c-pascal/cap.tex
@@ -0,0 +1,2 @@
+\input cap_c
+\input cap_pas
diff --git a/Master/texmf-dist/tex/generic/c-pascal/cap_c.tex b/Master/texmf-dist/tex/generic/c-pascal/cap_c.tex
new file mode 100644
index 00000000000..5501e94d312
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/c-pascal/cap_c.tex
@@ -0,0 +1,177 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 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 C.
+% 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\KeywordsC{
+void char int float double enum long short signed unsigned far near huge
+auto register extern static volatile inline const typedef
+new delete sizeof struct union
+for do while if else switch case default break continue return goto
+asm cdecl pascal interrupt
+class private public protected this friend virtual template operator
+catch throw try
+}
+\catcode`\@ = 11
+%
+% that's where we begin
+%
+\def\BeginC{%
+ \@PrepareCPas
+ \@LetsStartC
+}%
+% 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
+% \InsertC.
+\def\@InputC#1{%
+ \message{(C++: #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
+ \@WriteTextOfProgramC
+ \if \neof\@InFile \repeat
+ \closein\@InFile
+ \endgroup % this group was begun by \@PrepareCPas
+ \endgroup % this group was begun by \InputC
+ \message{)}%
+}
+\def\InputC{%
+ \begingroup
+ \catcode`\/ = 11
+ \@InputC
+}
+%
+% delimiter \EndC will be ordinary text
+%
+{ \catcode`\|=0 \catcode`\\=12
+ |gdef|@LetsStartC#1\EndC{%
+ |gdef|@TextOfProgram{#1}%
+ |@WriteTextOfProgramC
+ |endgroup % this group was begun by \@PrepareCPas
+ }
+}
+%
+% macro \@TextOfProgram contains the whole text of program
+%
+\def\@WriteTextOfProgramC{%
+ \expandafter\@ReadCharC\@TextOfProgram\@EndOfProgram
+}
+%
+% heart of the program -- the argument is a single char
+%
+\def\@ReadCharC#1{%
+ % this macro calls itself until the argument #1 is \@EndOfProgram
+ \if\@Identical{\string#1}{\string\@EndOfProgram}%
+ \let\@WhatNext = \relax
+ \else
+ \let\@WhatNext = \@ReadCharC
+ \global\@CharCode = `#1\relax
+ \ifcase \@WhereAmI
+ %%%%%%%%%%%%%%%%%%%
+ % \@NothingSpecial:
+ %%%%%%%%%%%%%%%%%%%
+ \ifnum \@PrevChar=`\/
+ \ifnum \@CharCode=`\/
+ \global\@WhereAmI = \@ShortComment
+ \CommentFont
+ \char47%
+ \else
+ \ifnum \@CharCode=`\*
+ \global\@WhereAmI = \@LongComment
+ \CommentFont
+ \fi
+ \fi
+ \char47%
+ \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}{\KeywordsC}%
+ \def\@Word{}%
+ \fi
+ \ifnum \@CharCode=`\#
+ \global\@WhereAmI = \@Directive
+ \DirectiveFont
+ \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:
+ %%%%%%%%%%%%%%
+ \@WriteChar{#1}%
+ \ifnum \@CharCode=13
+ \global\@WhereAmI = \@NothingSpecial
+ \SymbolFont
+ \fi
+ \or
+ %%%%%%%%%%%%%%%%%
+ % \@ShortComment:
+ %%%%%%%%%%%%%%%%%
+ \@WriteChar{#1}%
+ \ifnum \@CharCode=13
+ \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
diff --git a/Master/texmf-dist/tex/generic/c-pascal/cap_comm.tex b/Master/texmf-dist/tex/generic/c-pascal/cap_comm.tex
new file mode 100644
index 00000000000..3f407580b35
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/c-pascal/cap_comm.tex
@@ -0,0 +1,188 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 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 common definitions used in the CAP package.
+% It does not contain any useful macros itself.
+%
+
+
+%
+% macro that compares two strings
+%
+\def\@Identical#1#2{%
+ MG\fi
+ \edef\@FirstString{#1}%
+ \edef\@SecondString{#2}%
+ \ifx \@FirstString \@SecondString
+}
+%
+% font declarations
+%
+{% a tiny trick that lets TeX check if the user has PL fonts...
+ \catcode`\p = 12
+ \catcode`\l = 12
+ \catcode`\r = 12
+ \xdef\xxx{plr10}
+}
+\if\@Identical{\xxx}{\fontname\tenrm}
+ \font\tenttsl = plsltt10
+ \font\tenttit = plitt10
+\else
+ \font\tenttsl = cmsltt10
+ \font\tenttit = cmitt10
+\fi
+\let\IdentifierFont = \it
+\let\TextFont = \sl
+\let\KeywordFont = \bf
+\let\CommentFont = \tenttit
+\let\DirectiveFont = \tenttsl
+\let\SymbolFont = \tt
+\let\SpecialFont = \tt % some characters: { } < > _ \ and | are very
+ % special -- they exist only in tt fonts
+%
+% registers and constants used in the program
+%
+\newif\if@TempBool % temporary boolean
+\newread\@InFile % file read by \Insert macros
+\newcount\@CharCode % code of current character
+\newcount\@PrevChar % code of previous charater
+\newcount\@WhereAmI % one of the following values:
+\chardef\@NothingSpecial = 0
+\chardef\@Text = 1
+\chardef\@Directive = 2 % used only in C
+\chardef\@ShortComment = 3 % C: //... ; Pascal: (* ... *)
+\chardef\@LongComment = 4 % C: /* ... */; Pascal: { ... }
+%
+% I need a "not eof" function
+%
+\def\neof#1{%
+ MG\fi
+ \ifeof#1
+ \@TempBoolfalse
+ \else
+ \@TempBooltrue
+ \fi
+ \if@TempBool
+}
+%
+% macro for changing catcodes of some special characters
+%
+\def\@TurnSpecialCharsOff{%
+ \catcode`\/=12
+ \catcode`\~=12
+ \catcode`\#=12
+ \catcode`\$=12
+ \catcode`\%=12
+ \catcode`\^=12
+ \catcode`\&=12
+ \catcode`\_=12
+ \catcode`\\=12
+ \catcode`\{=12
+ \catcode`\}=12
+ \catcode`\ =12
+ \catcode`\^^M=12
+}
+%
+% macro that initiates all the variables
+%
+\def\@PrepareCPas{%
+ \begingroup
+ \parindent=0pt
+ \rightskip=0pt plus 1fil
+ \@TurnSpecialCharsOff
+ \def\@Word{}%
+ \@WhereAmI = \@NothingSpecial
+ \@PrevChar = 32
+ \SymbolFont
+}
+%
+% macro that outputs the char specified as the argument;
+% characters < > _ \ { | } are written with \SpecialFont
+%
+\def\@WriteChar#1{%
+ \def\@Check##1{%
+ \ifnum `#1=`##1
+ {\SpecialFont #1}%
+ \@TempBooltrue
+ \fi
+ }%
+ \@TempBoolfalse
+ \@Check{<}%
+ \@Check{>}%
+ \@Check{_}%
+ \@Check{\\}%
+ \@Check{\{}%
+ \@Check{\}}%
+ \@Check{|}%
+ \if@TempBool
+ \else
+ \ifnum `#1=13
+ \par\leavevmode
+ \else
+ \ifnum `#1=32
+ \hskip 1ex
+ \else
+ #1%
+ \fi
+ \fi
+ \fi
+}
+%
+% checks if word #1 is a keyword and writes it out;
+% #2 is a list of keywords separated with spaces
+%
+\def\@WriteWord#1#2{%
+ \if\@OnListOfKeywords{ #1 }{#2}%
+ {\KeywordFont #1}%
+ \else
+ {\IdentifierFont #1}%
+ \fi
+}
+%
+% checks if string #2 contains string #1
+%
+\def\@OnListOfKeywords#1#2{%
+ MG\fi
+ \edef\@ExpandedArgument{{#1}}%
+ \expandafter\@@OnListOfKeywords\@ExpandedArgument{#2}\relax
+}
+\def\@@OnListOfKeywords#1#2{%
+ \def\@CheckList##1#1##2\@EndOfList{%
+ \if\@Identical{##2}{}%
+ \@TempBoolfalse
+ \else
+ \@TempBooltrue
+ \fi
+ }%
+ \expandafter\@CheckList#2#1\@EndOfList\relax
+ \if@TempBool
+}
+%
+% checks if the specified character is a digit or a letter
+%
+\def\@DigitLetter#1{%
+ MG\fi
+ \@TempBoolfalse
+ \ifnum `\` < #1\relax % small letter?
+ \ifnum `\{ > #1\relax
+ \@TempBooltrue
+ \fi
+ \fi
+ \ifnum `\@ < #1\relax % capital letter?
+ \ifnum `\[ > #1\relax
+ \@TempBooltrue
+ \fi
+ \fi
+ \ifnum `\/ < #1\relax % digit?
+ \ifnum `\: > #1\relax
+ \@TempBooltrue
+ \fi
+ \fi
+ \if@TempBool
+}
+
+\endinput
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