summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/literate/progdoc.tex
blob: 92d4693c019454e0a368b547eca5bb83da0fd8df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
% This is MAKEPROG.WEB                    as of 29 Nov 88
%---------------------------------------------------------
% (c) 1988 by J.Schrod.
%        Major parts of this program have been taken from TANGLE.WEB
%           by D.E.Knuth, which is not copyrighted.

%
% Version 1.0 was released in November, 1988.
%


\def\title{MAKEPROG (V\version)}
\def\version{1.0}
\def\years{1988}

\font\ninerm=cmr9
\let\mc=\ninerm % medium caps for names like EBCDIC

\def\hang{\hangindent 3em\indent\ignorespaces}
\def\item#1{                             % fixed item of 30pt width
   {\parskip=0pt\endgraf\noindent}%      % new line
   \hangindent 30pt %
   \hbox to 30pt{\hfil#1\kern 1em}%
   \ignorespaces                         % ignore following blanks
   }

\def\PASCAL{Pascal}
\def\MAKEPROG{\leavevmode\hbox{\mc MAKEPROG\/}}
\def\ASCII{\leavevmode\hbox{\mc ASCII\/}}
\mathchardef\BA="3224      % double arrow as relation

\def\topofcontents{\null\vfill
   \centerline{\titlefont The MAKEPROG processor}
   \vskip 15pt
   \centerline{(Version \version)}
   \vskip 2cm}
\def\botofcontents{\vfill
   \hangindent 3em
   \noindent $\copyright$ \years{} by J.~Schrod.\hfil\break
   All rights reserved.
   \par \vskip 1ex
   \noindent The source of this program may be used for
   noncommercial purposes, but credits must be given to the origin.
   \par}





@* Introduction.                                            % sect.    1

\noindent This program converts a documentation file to a
program file, i.e.\ all files between \.{\\beginprog} and
\.{\\endprog} are copied verbatim.  It was written by
J.~Schrod in September, 1987.  This program is written in
\.{WEB}.

The program uses a few features of the local \PASCAL\
compiler that may need to be changed in other installations:

\item{1)} Case statements have a default.

\item{2)} Input-output routines may need to be adapted for
use with a particular character set and/or for printing
messages on the user's terminal.

\noindent System-dependent portions of \MAKEPROG{} can be
identified by looking at the entries for `system
dependencies' in the index below.
@!@^system dependencies@>

\noindent The ``banner line'' defined here should be changed
whenever \MAKEPROG{} is modified.  The copyright notice must
not be changed.

@d banner=='This is MAKEPROG, Version 1.0.'
@d copy_right=='    (c) 1988 by J.Schrod.'
@d rights_res=='        All rights reserved.'


% from progdoc.doc   05 Dec 88
%------------------------------
% These lines were inserted by hand (not with MAKEPROG).
\chardef\escape=0
\chardef\letter=11
\chardef\other=12
%\chardef\active=13              % is defined in Plain already

\chardef\atcode=\catcode`\@
\chardef\uscode=\catcode`\_

\catcode`\@=\letter
\catcode`\_=\letter
\font\tentex=cmtex10            % typewriter extended ASCII 10pt
\let\ttex=\tentex               % only for PLAIN with base size 10pt

\def\setup_verbatim{%
   \def\do##1{\catcode`##1\other}\dospecials
   \parskip\z@skip \parindent\z@
   \obeylines \obeyspaces \obeytabs \frenchspacing
   \ttex
   }

\let\tab=\space
\begingroup
   \catcode`\^^I=\active%       % Attention: no tabs!
   \gdef\obeytabs{\catcode`\^^I=\active\def^^I{\tab}}
   \global\let^^I=\tab%         % if an active tab appears in a \write
\endgroup
\let\origvert=|
\chardef\vbar=`\|

\catcode`\|=\active

\def|{%
   \leavevmode
   \hbox\bgroup
      \let\par\space \setup_verbatim
      \let|\egroup
   }
\newif\if@print

\def\beginprog{%
   \endgraf
   \bigbreak
   \begingroup
      \setup_verbatim \catcode`\|\other
      \@printtrue
      \ignore_rest_line
   }
\let\end_verbatim=\endgroup             % internal command !
\begingroup
   \obeylines%          % ^^M is active! ==> every line must end with %
   \gdef\ignore_rest_line#1^^M{\set_next_line}%
   \gdef\set_next_line#1^^M{\do_set{#1}}%
\endgroup

\def\do_set#1{%
   \endgraf
   \check_print{#1}%
   \if@print  \indent \print_char#1\end_line\end_line
   \else  \let\set_next_line\end_verbatim
   \fi
   \set_next_line
   }
\let\end_line=\relax
\begingroup
\obeyspaces\obeytabs
\gdef\check_print#1{\cut_at_tab#1^^I\end_line}
\gdef\cut_at_tab#1^^I#2\end_line{\check_first_part#1 \end_line}
\gdef\check_first_part#1 #2\end_line{\do_check{#1}}
\endgroup
\def\do_check#1{%
   \def\@line{#1}%
   \ifx \@line\@endverbatim  \@printfalse
   \fi
   }

{\catcode`\|=\escape  \catcode`\\=\other % | is temporary escape char
   |gdef|@endverbatim{\endprog}
}                       % he \endgroup can't be used
\newcount\char_count  \char_count\@ne

\def\print_char#1#2\end_line{%
   \print_first_char{#1}%
   \print_rest_of_line{#2}%
   }
{\obeytabs\gdef\@tab{^^I}}

\def\print_first_char#1{%
   \def\@char{#1}%
   \advance \char_count\@ne
   \ifx \@char\@tab  \print_tab
   \else  \@char
   \fi
   }
\newcount\count_mod_viii
\def\mod_viii#1{%
   \count@ #1\relax  \count_mod_viii\count@
   \divide \count@ 8\relax
   \multiply \count@ 8\relax
   \advance \count_mod_viii -\count@
   }
\def\print_tab{%
   \loop  \space \mod_viii\char_count
      \ifnum \count_mod_viii>\z@
         \advance \char_count\@ne
   \repeat
   }
\def\print_rest_of_line#1{%
   \def\@line{#1}%
   \ifx \@line\empty  \char_count\@ne
        \def\next##1\end_line{\relax}%
   \else  \let\next\print_char
   \fi
   \next#1\end_line
   }