From db5da0de14bec64bfb16b5624ee7be70840e225c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 18 May 2010 18:21:33 +0000 Subject: c-pascal missed files git-svn-id: svn://tug.org/texlive/trunk@18337 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/c-pascal/README.eng | 112 ++++++++++++++ Master/texmf-dist/tex/generic/c-pascal/cap_pyt.tex | 171 +++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 Master/texmf-dist/doc/generic/c-pascal/README.eng create mode 100644 Master/texmf-dist/tex/generic/c-pascal/cap_pyt.tex (limited to 'Master') diff --git a/Master/texmf-dist/doc/generic/c-pascal/README.eng b/Master/texmf-dist/doc/generic/c-pascal/README.eng new file mode 100644 index 00000000000..fda4ad032e0 --- /dev/null +++ b/Master/texmf-dist/doc/generic/c-pascal/README.eng @@ -0,0 +1,112 @@ +PCAP --- macro package for typesetting programs in Python, C and Pascal + +Derived from original CAP package by Michal Gulczynski. Any errors (bugs) +introduced are my own. + +Changes from CAP: +* Improved minor deficiencies (there was a space in front of every + "special" symbol) +* Made it easy to change the "output" (not \TeX's \output) routine (instead + of actually sending data to TeX, we use \@Output{...data...}) +* Added DVIPS color support (color \special's as used by DVIPS) +* Added a "state" watch --- enabling the output of some "special" symbols + in different colors depending on a state (like "_" as identifier, "<" and ">" + in directives, and so forth) +* Added Python language support with analogous commands of + \BeginPython, \EndPython, \InputPython + (see original file for C and Pascal versions; these are used in the same way) + + + +Original README.eng follows: + +====================================================================== + + CAP --- macro package for typesetting programs in C and Pascal + +====================================================================== + + + Contents +---------- +This macro package consists of three files: + cap_c.tex -- macros for typesetting programs in C + cap_pas.tex -- macros for typesetting programs in Pascal + cap_comm.tex -- helpful macros and declarations used for typesetting + programs in both languages; this file does not contain + any macros useful for a user + + + Programs in C +--------------- +There are two macros available in the cap_c.tex file: + + 1. \BeginC ... \EndC + Between these commands you may insert sorce code of any program + written in the C language. The text of the program will be + formatted using appropriate fonts. The macro recognises the + following elements of a program: + * keywords --- by default typeset in boldface + * texts --- everything inside single quotes; by default slanted + * comments --- both /*these...*/ and //these... , but not nested; + italic typewriter + * symbols --- operators, brackets, etc.; typewriter + * compiler directives --- typeset using slanted typewriter font + * identifiers --- everything that is none of the above; italic + The macro does not change the layout of a program. All + indentations are left as they are in the source program. No line + breaks are inserted. + NOTE: While compiling, the \BeginC ... \EndC macro reads the whole + program into TeX's memory. Therefore, you may expect problems when + typesetting huge programs in this way. In my configuration + (emTeX under DOS) everything works fine if the program is not bigger + than about 15KB. If you REALLY need to insert a vast program + directly into your TeX source file you will have to split + the program into smaller pieces, each inserted into a separate + pair \BeginC ... \EndC. + + 2. \InputC{filename} + Inserts a C program from a separate file. The program is formatted + as above. If you use DOS you need to remember that all backslashes + in the pathname should be replaced by slashes. + This macro has NO limitations for the size of the program --- it reads + the file line by line, so TeX should never run out of memory. + +The list of keywords can be easily found in the cap_c.tex file. I do not +guarantee that it is complete, so feel free to correct it if necessary. + + + Programs in Pascal +-------------------- +In order to typeset programs in Pascal you need to \input the cap_pas.tex +file. It contains two macros, as well: + + 1. \BeginPascal ... \EndPascal + + 2. \InputPascal{filename} + +They work similarly. They recognise the same elements of a Pascal program. +Both {this} and (*this*) kind of comment is accepted, but they cannot +be nested. In case of \BeginPascal ... \EndPascal size limitations are +similar as in C. + +The list of keywords was taken from Borland Delphi Help. If you need, you +may modify it. + + + Common +-------- +Fonts used to typeset programs are declared in the beginning of +the cap_comm.tex file. They are easy to redefine if necessary. + + + Note +------ +If you modify any of the files in any way, mark your changes, please. +I do not want to take responsibility for other people's modifications. + + +------------ + + Michal Gulczynski + mgulcz@we.tuniv.szczecin.pl diff --git a/Master/texmf-dist/tex/generic/c-pascal/cap_pyt.tex b/Master/texmf-dist/tex/generic/c-pascal/cap_pyt.tex new file mode 100644 index 00000000000..a15f89db620 --- /dev/null +++ b/Master/texmf-dist/tex/generic/c-pascal/cap_pyt.tex @@ -0,0 +1,171 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% PCAP --- Macros for typesetting programs in Python, C and Pascal% +% Micha\l{} Gulczy\'nski, Szczecin, Feb 1997 / Feb 1998 % +% mgulcz@we.tuniv.szczecin.pl % +% Python support: Danilo \v Segan, Beograd, Sep 2002 % +% mm01142@alas.matf.bg.ac.yu % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% version 1.2p +% Creation steps: +% 1. cp cap_pas.tex cap_pyt.tex +% 2. replace every occurence of "Pascal" with "Python" +% 3. Define keywords using ones defined in "python-mode.el" +% 4. Modify to support Python strings and comments +% 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\KeywordsPython{ +and assert break class continue def del elif else except exec for +from global if import in is lambda not or pass print raise return +while yield else except finally try +} +\catcode`\@ = 11 +% +% that's where we begin +% +\def\BeginPython{% + \@PrepareCPas + \@LetsStartPython +}% +% 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 +% \InputPascal. +\def\@InputPython#1{% + \message{(Python: #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 + \@WriteTextOfProgramPython + \if \neof\@InFile \repeat + \closein\@InFile + \endgroup % this group was begun by \@PrepareCPas + \endgroup % this group was begun by \InputPascal + \message{)}% +} +\def\InputPython{% + \begingroup + \catcode`\/ = 11 + \@InputPython +}% +% +% delimiter \EndC will be ordinary text +% +{ \catcode`\|=0 \catcode`\\=12 + |gdef|@LetsStartPython#1\EndPython{% + |gdef|@TextOfProgram{#1}% + |@WriteTextOfProgramPython + |endgroup % this group was begun by \@PrepareCPas + } +} +% +% macro \@TextOfProgram contains the whole text of program +% +\def\@WriteTextOfProgramPython{% + \expandafter\@ReadCharPython\@TextOfProgram\@EndOfProgram +} +% +% heart of the program -- the argument is a single char +% +\def\@ReadCharPython#1{% + % this macro calls itself until the argument #1 is \@EndOfProgram + \if\@Identical{\string#1}{\string\@EndOfProgram}% + \let\@WhatNext = \relax + \else + \let\@WhatNext = \@ReadCharPython + \global\@CharCode = `#1\relax + \ifcase \@WhereAmI + %%%%%%%%%%%%%%%%%%% + % \@NothingSpecial: + %%%%%%%%%%%%%%%%%%% + \ifnum \@PrevChar=`\( +% \ifnum \@CharCode=`\* +% \global\@WhereAmI = \@LongComment +% \@CommentState +% \fi + \@SymbolState\@Output{(}% + \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}{\KeywordsPython}% + \def\@Word{}% + \fi + \ifnum \@CharCode=`\# + \global\@WhereAmI = \@ShortComment + \@CommentState + \fi + \ifnum \@CharCode=`\" + \global\@WhereAmI = \@Text + \@TextState + \fi + \ifnum \@CharCode=`\( + \else + \@WriteChar{#1}% + \fi + \fi + \or + %%%%%%%%% + % \@Text: + %%%%%%%%% + \@WriteChar{#1}% + \ifnum \@CharCode=`\" + \global\@WhereAmI = \@NothingSpecial + \@SymbolState + \fi + \or + %%%%%%%%%%%%%% + % \@Directive: + %%%%%%%%%%%%%% + % there are no directives in Python, but i'll leave it + \or + %%%%%%%%%%%%%%%%% + % \@ShortComment: + %%%%%%%%%%%%%%%%% + \@WriteChar{#1}% + \ifnum \@CharCode=13 + \global\@WhereAmI = \@NothingSpecial + \@SymbolState + \fi + \or + %%%%%%%%%%%%%%%% + % \@LongComment: + %%%%%%%%%%%%%%%% + \@WriteChar{#1}% + \ifnum \@PrevChar=`\* + \ifnum \@CharCode=`\) + \global\@WhereAmI = \@NothingSpecial + \@SymbolState + \@CharCode = 32 + \fi + \fi + \fi + \global\@PrevChar = \@CharCode + \fi + \@WhatNext +} + +\ifx \@PrepareCPas \@Dont@Know@What@It@Is + \input cap_comm +\fi + +\catcode`\@ = 12 -- cgit v1.2.3