summaryrefslogtreecommitdiff
path: root/web/latexspider/web.doc
blob: 65d9df1ca6e7832d0473d7e2359bb8493c5be746 (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
\iffalse % -*-latex-*-

%% Copyright D.Love, SERC Daresbury Laboratory, 1991
%% The `doc' version of this style is re-distributable and usuable
%% under conditions of the GNU copyleft, but please mark any changes,
%% list them here and report any major enhancements to the author.

% This is a self-documenting style.  To produce the documentation you
% might use a driver file like this:
% \def\webmacs{null} \documentstyle[a4,makeidx,newdoc,web]{article}
% \EnableCrossrefs \CodelineIndex
% \begin{document} \DocInput{web.sty} \PrintIndex
% \end{document}
% and run `makeindex -s gind.ist doc' in between passes.  You need
% Mittelbach's newdoc.sty at v1.6d or later.

% To produce the .sty file use `latex docstrip' to remove most of the
% comments.  Please don't distribute the .sty file without the .doc
% file. 
\fi

\iffalse %  hack RCS info into a sensible form:
\fi
\def\next$#1: #2/#3/#4 #5 ${\def\filedate{#4/#3/#2}\def\filetime{#5}}
\next$Date: 1991/06/19 10:28:40 $

\def\next$#1: #2 ${\def\fileversion{#2}}
\next$Revision: 1.2 $

% \title{A a \web{} style file for \LaTeX{}\thanks{This file is version
% \fileversion\ of \filedate}}
% \author{David Love\\[2ex]{\it SERC Daresbury Laboratory, Warrington
% WA4 4AD, UK}\\ \tt d.love@daresbury.ac.uk}
% \date{}
%
% \newcommand{\web}{{\tt WEB}}
% \newcommand{\weave}{{\tt WEAVE}}
% \newcommand{\tangle}{{\tt tangle}}
% \newcommand{\spider}{Spider}
% \MakeShortVerb{\"}

% \DoNotIndex{\/,\@date,\@ifundefined,\@makefnmark,\@starttoc}
% \DoNotIndex{\@topnum,\addpenalty,addvspace,\advance,aftergroup}
% \DoNotIndex{\begin,\begingroup,\bgroup,\char,\def,\egroup,\else,\end}
% \DoNotIndex{\endgroup,\fi,\fnsymbol,\hfil,\hfill,\hfilneg,\hss,\kern}
% \DoNotIndex{\let,\lineskip,\newcommand,\protect,\qquad,\quad,\relax}
% \DoNotIndex{\thanks,\thefootnote,\z@,\@M,\@thanks,\@thefnmark,\hbox}
% \DoNotIndex{\empty,\mbox}

% \maketitle
%
% \begin{abstract} \noindent
% This style file is for use with a version of the Spidery \weave\ system
% that has been adapted to use \LaTeX\ rather than plain \TeX\ for the
% formatting.  It is a first attempt.
%  \end{abstract}
%
% \section{Assumptions of \weave{} and the {\tt .web} file}
%
% We assume we're using the version of Spidery \weave{} \cite{spider}
% changed for \LaTeX\@.  This will write out
% \begin{quote}"\def\webmacs{"\meta{ext}"web.tex}",\end{quote}
% (where \meta{ext} is
% the \spider{} {\tt extension}), then the limbo section, then
% \begin{quote}"\begin{document}\maketitle" \end{quote}
% the latter to stop you forgetting it.  The "\webmacs" file will be
% included at the end of this style.
% After the index (if any), we get
% "\end{document}".  The user thus has to put the "\documentstyle"
% command in the limbo part and include "web" in the style options to
% get this stuff and can use other options as appropriate.  You're
% meant to use the "article" main style, although I think "report"
% would work too.
%
% \section{Strategy}
%
% The idea was to change the original \spider{} \TeX{} stuff as little
% as possible, although it has actually been changed quite
% substantially.  Changes are forced where there is a clash of macro 
% names; most of the original one-character control sequences are
% already used by \LaTeX, for instance.  Some features have been
% converted to a \LaTeX{} equivalent, 
% notably the table of contents mechanism, the title page, running
% header and double-columning for the index.  For safety, "\def"s have
% been replaced by "\newcommands" where possible since there are
% probably plenty of possibilities for name clashes.
% User-visible differences from the plain version are given in
% appendix~\ref{changes}.
%
% \section{Use with old webs}
%
% Examples of the use of this style with old webs using the plain
% conventions can be found in the accompanying changes files for
% {\tt weave.web} and {\tt spider.web}.  You can use the limbo section
% to check whether the generated ".tex" file is being run through
% \LaTeX\ or plain \TeX\ by doing something like this:
% \begin{quote}
% \begin{verbatim}
% \ifx\enddocument\undefined
%   % plain things
% \else
%   % LaTeX things
% \fi
% \end{verbatim}
% \end{quote}
%
% \section{Bugs}
% 
% Floats
% don't always come out where you'd expect due to interaction with
% \web's attempts to keep all of a module on one page if possible.
% "\str" and "\vstr", which 
% might well get used in a moving argument, are 
% fragile.  Module titles (after "@*") are moving arguments.  I think
% if you use \web's "|"\dots"|" construction in a 
% moving argument it will break and there's not much you can do about
% it. 
%
% \section{Code}
% \subsection{Preliminaries --- page layout}
%
% Let's announce ourselves as usual:
%    \begin{macrocode}
\typeout{Sub-style `web', version \fileversion\space of \filedate}
%    \end{macrocode}
% We don't want stretch between paragraphs.
%    \begin{macrocode}
\parskip \z@ 
%    \end{macrocode}
% \begin{macro}{\textwidth}\begin{macro}{\textheight}
% \begin{macro}{\oddsidemargin} \begin{macro}{\evensidemargin}
% The default page width should be large for \web\@.  This is for
% non-Americans (A4)---if you want to alter the page dimensions with a
% suitable style option put it {\em after\/} "web" in the
% "\documentstyle" list.  The width here is too big for decently
% readable text, but is
% still less than the $6.5''$ of the original.  Note that there's no
% point in trying to use "\marginpar" at
% this width since the margins have disappeared!  The "twoside" option
% will work sensibly if you care to use it.\DescribeMacro{twoside}  We
% want to avoid doing this when typesetting the documenttation, hence
% the test for "\DocInput".
%    \begin{macrocode}
\ifx\DocInput\undefined
\ifcase \@ptsize
   \textheight = 53 \baselineskip
\or
   \textheight = 47 \baselineskip
\or
   \textheight = 43 \baselineskip
\fi  \advance \textheight by \topskip
\textwidth=6.27in  \oddsidemargin=\z@  \evensidemargin=\z@
\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
% We use the "myheadings" page style with headings containing module
% information (see below).
%    \begin{macrocode}
\pagestyle{myheadings}
%    \end{macrocode}
% If we start off with a "\sectionmark" we won't miss the running
% header off the first page where it should appear.
%    \begin{macrocode}
\ifx\DocInput\undefined \sectionmark{1} \fi
%    \end{macrocode}
%
% \subsubsection{Font selection}
%
% \begin{macro}{\normal@font}
% We have to check whether we're in the old or new font selection scheme
% and set up appropriately.  "\normal@font" is invoked before the font
% changes for identifiers, reserved words and strings to make sure
% that they use the default series and shape in the new scheme.  This
% is actually only necessary if "\id", "\res" or "\str" is used in
% \TeX\ text that is being set in a different shape or series, not
% normally in the code.  If you use the new selection scheme you can
% do things like using Concrete or PostScript fonts easily.
%    \begin{macrocode}
\@ifundefined{selectfont}{%
     \let\normal@font=\relax}   % old scheme
   {% new scheme
     \def\normal@font{\series \mediumseriesdefault 
     \shape \normalshapedefault}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Front matter}
%
% We depart from the plain version here.  The first page (or pages, if
% the contents are very long) is produced with the "titlepage"
% environment.  The "\author", "\date" and
% "\title" \DescribeMacro{\title} can be specified
% as usual in \LaTeX\@.  Note that you now say
% "\title{"\meta{title}"}" rather than "\def\title{"\meta{title}"}" as
% in the plain version and this title will be used in the running
% header. 
% 
% \begin{macro}{\@maketitle}
% We'll re-define "\@maketitle" to include the "\topofcontents" and
% "\botofcontents" information, with the contents information in the
% middle.  The normal title, author and date will be put automatically
% at the top---"\topofcontents" is extra.  You get the titling and
% contents information automatically, since "\maketitle" is inserted
% by \weave{} immediately after "\begin{document}".  If you want to
% suppress it, "\let\maketitle=\relax" in the limbo part.
% 
% Of course, you have to make two
% passes to get the contents printed, unlike the original plain
% system.  This should not be much hardship as one usually reckons on
% running \LaTeX{} at least twice.  (Putting the titlepage at the back
% won't help, since the ".toc" file only exists after the ".aux" file
% has been read on the secind pass.  One could change the standard
% behaviour so that the ".toc" file was created at the end of the
% first pass, I guess.)
% We first test for "\DocInput" as above to
% avoid messing things up when typesetting the documentation.
%    \begin{macrocode}
\ifx\DocInput\undefined
\def\@maketitle{%
  \newpage  \thispagestyle{empty} \null
  \begin{center}
  {\LARGE \@title \par}  \vskip 1.5em
  {\large   \lineskip .5em
    \begin{tabular}[t]{c} \@author  \end{tabular} \par}                   
  \vskip 1em  {\large \@date}
  \end{center}
  \par   \vskip 1.5em
  \topofcontents  \tableofcontents  \par  \botofcontents \newpage }
\fi
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\maketitle}
% We change "\maketitle" to avoid the "\thispagestyle{plain}" that it
% otherwise contains, to set the page number to 1 at the end and to
% avoid losing the definitions of "\@title" and "\@author".
% ("\@title" is used in the running header.)
%    \begin{macrocode}
\ifx\DocInput\undefined
\def\maketitle{%
  \par \begingroup
    \pagenumbering{roman}  \setcounter{page}{0}
    \def\thefootnote{\fnsymbol{footnote}}
    \def\@makefnmark{\hbox to \z@ {$^{\@thefnmark}$\hss}}   
    \if@twocolumn  \twocolumn[\@maketitle]   
    \else  \newpage  \global\@topnum\z@  \@maketitle  \fi
    \@thanks
  \endgroup
  \setcounter{footnote}{0}  \pagenumbering{arabic}
  \let\maketitle\relax  \let\@maketitle\relax
  \gdef\@thanks{}\let\thanks\relax}
\fi
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\@title} \begin{macro}{\@author}
% We better define these in case they're not supplied:
%    \begin{macrocode}
\let\@title=\empty  \let\@author=\empty
%    \end{macrocode}
%    \end{macro}    \end{macro}
% \begin{macro}{\tableofcontents}
% "\tableofcontents" is re-defined to produce a header saying
% ``Section'' and ``Page'' a bit like the plain version, although the
% section (module) number is at the left.
%    \begin{macrocode}
\def\tableofcontents{%
  \noindent Section \hfill Page \par  \@starttoc{toc}}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\topofcontents} \begin{macro}{\botofcontents}
% The "\topofcontents" material that comes between the title\slash author
% information and the contents list and the "\botofcontents" stuff
% that comes after the contents list are empty initially.  I'm not
% sure it's worth preserving them.
%    \begin{macrocode}
\def\topofcontents{}  \def\botofcontents{}
%    \end{macrocode}
%    \end{macro}    \end{macro}
% \begin{macro}{\ttitlefont} \begin{macro}{\titlefont}
% These are just for compatibility with the plain version---they
% should probably go.
%    \begin{macrocode}
\let\ttitlefont=\tt  \let\titlefont=\rm
%    \end{macrocode}
%    \end{macro}    \end{macro}
%
% \subsection{Prettyprinting stuff}
% \subsubsection{Identifiers, reserved words and strings}
% 
%    \begin{macro}{\id}\begin{macro}{\ida}\begin{macro}{\idfont}
% Multi-letter identifiers are set by the macro "\id" in font "\idfont",
% which is italic by default i.e., \id{identifier}.
% One-letter identifiers are
% actually set by "\ida" in math italic as they are supposed to look
% better that way (\ida{a} rather than \id{a}).
%    \begin{macrocode}
\newcommand{\id}[1]{\mbox{\idfont #1\/\kern.05em}}
\newcommand{\ida}[1]{\mbox{$ #1 $}}
\newcommand{\idfont}{\normal@font \it}
%    \end{macrocode}
%    \end{macro}    \end{macro}    \end{macro}
%    \begin{macro}{\reservedfont}\begin{macro}{\res}
%  Reserved words are set by macro "\res", using "\reservedfont" which
%  is bold by default i.e., \res{reserved}.
%    \begin{macrocode} 
\newcommand{\reservedfont}{\normal@font \bf}
\newcommand{\res}[1]{\mbox{\reservedfont#1\/}}
%    \end{macrocode}
%    \end{macro}\end{macro}
% 
%    \begin{macro}{\str}
% Typewriter type is used for strings, set by "\str" i.e.,
% \str{string}.  The definitions of the escaped characters 
% are given below.  I don't understand why the ampersand is treated
% like this, since "\&" is defined anyway, but quotes and "^" are
% escaped to avoid 
% ligatures.\footnote{{\tt \char`\^} and {\tt \char`\~} form ligatures
% in PostScript virtual fonts as well as "'".}  It's necessary to do a
% "\def" of "\^" rather than just 
% "\let\^\CF" to avoid an error with the use of "\^" not matching its
% definition.   Note the use of "\@tempa" below rather than "\XX" as
% used in the same situation elsewhere---using "\XX", "\str" breaks if
% it is used in, say, a comment.
%    \begin{macrocode} 
\def\str#1{%
  \ifmmode \gdef\@tempa{\null$\null}\else \gdef\@tempa{}\fi
  \@tempa {%
  \let\\=\BS  \let\'=\RQ  \let\`=\LQ  \let\{=\LB  \let\}=\RB
  \let\~=\TL  \let\ =\SP  \let\&=\AM  \def\^{{\tt \char`\^}}%
  \leavevmode \normal@font\tt #1}\@tempa}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\AM} \begin{macro}{\BS} \begin{macro}{\LB}
% \begin{macro}{\LQ} \begin{macro}{\RB} \begin{macro}{\UL}
% \begin{macro}{\TL}
% Here are the definitions of the control sequences for strings.  The
% plain version redefined "\#", "\$", "\%" and "\^" globally.  "\$"
% isn't used by awk or C \web s, and has been removed.  The others are
% done only in code, using "\startcodehook" (below).
%    \begin{macrocode}
\chardef\AM=`\&                 % ampersand
\chardef\BS=`\\                 % backslash
\chardef\LB=`\{                 % left brace
\def\LQ{{\tt\char'22}}          % left quote
\chardef\RB=`\}                 % right brace
\def\RQ{{\tt\char'23}}          % right quote
\def\UL{{\tt\char`\_}}          % underline character in a string
\def\TL{{\tt\char`\~}}          % tilde 
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
%    \end{macro}
% \begin{macro}{\SP}
% Strings may be rather long and we want some way of breaking
% them, so
% "\SP" produces a visible space (\str{\SP}) and also adds a discretionary
% break afterwords.  If a break occurs, the line is ended with a
% backslash.  Spaces are probably the most sensible place to break
% strings, especially if they are messages, but one could consider
% doing the same thing for other of the macros above e.g., "\BS" might
% check if the next character was "n" and insert a discretionary break
% after that.
%    \begin{macrocode} 
\newcommand{\SP}{\char`\ \discretionary{\hbox{\char`\\}}{}{}}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\vstr}
% This does a verbatim string (from "@=") using the existing \LaTeX
% nology rather than the original definition to put a frame around it
% (\vstr{string}). 
%    \begin{macrocode}
\newcommand{\vstr}[1]{\kern 2pt \fbox{\str{#1}}\kern 2pt}
\setlength{\fboxsep}{2pt}
%    \end{macrocode}
%    \end{macro}
%
% \begin{macro}{\const}
% This looks after setting octal, hex or decimal constants.  The first
% thing in its argument may be one of the control sequences in the
% example on the left,
% producing the result in the middle:
% \[\begin{tabular}{lll}
% "\const{\$10}" & $\const{\$10}$ & (long) \\
% "\const{\_10}" & $\const{\_10}$ & (power of ten)\\
% "\const{\~10}" & $\const{\~10}$ & (octal) \\
% "\const{\^AB10}" & $\const{\^AB10}$ & (hex) \\
% \end{tabular}\]
% \DeleteShortVerb{\"}
%    \begin{macrocode}
\def\const#1{{%
  \def\?{\kern.2em}%
  \def\${\ell}% long
  \def\_{\RealConstFormat{\aftergroup}}% power of ten
  \def\~{\hbox{\rm \char'23\kern-.2em \it \aftergroup\?\aftergroup}}% octal
%    \end{macrocode}
% The \verb+"+ here was originally \verb+\char'175+ which,
% unfortunately, is different in PostScript virtual fonts and Computer
% Modern: 
%    \begin{macrocode}
  \def\^{\hbox{\rm "\tt \aftergroup}}% hex
  #1}}                          % (\def{\const})
%    \end{macrocode}
%    \end{macro}
% \MakeShortVerb{\"}
%    \begin{macro}{\RealConstFormat}
% I prefer to re-define the decimal style
% to print as the more code-like `$\mbox{\rm e}10$'.  You can
% do this by using the hook "\RealConstFormat" in your Spider "macros"
% section: 
% \begin{quote} "\newcommand{\RealConstFormat}{\mbox{\rm e}}" .\end{quote}
% For a go at a Fortran web, I hacked the lexing so that an "e" or "d" in
% a real or double-precision constant was transmitted verbatim into the
% argument of "\const" instead of "\_" and re-defined "\const" to ensure
% this was set in roman.
%    \begin{macrocode}
\newcommand{\RealConstFormat}{\cdot 10^}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{Indentation and breaks}
%
% \begin{macro}{\ind}
% This counter stores the current indentation in ems.
%    \begin{macrocode} 
\newcount\ind
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\bak} \begin{macro}{\bakk}
% These backspace one and two ems respectively.
%    \begin{macrocode} 
\newbox\bak  \setbox\bak=\hbox to \m@ne em{}
\newbox\bakk \setbox\bakk=\hbox to -2em{}
%    \end{macrocode}
%    \end{macro}\end{macro}
% \begin{macro}{\0}
%  A forced break, as from "@/":
%    \begin{macrocode}
\def\0{%
  \ifmmode
    \ifinner$\par\hangindent\ind em\noindent\kern\ind em\ignorespaces$\fi
  \else
    \par\hangindent\ind em\noindent \kern\ind em\ignorespaces 
  \fi}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\1}
% Indent one more notch:
%    \begin{macrocode}
\newcommand{\1}{\global\advance\ind by 1 \hangindent\ind em}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\2}
% Indent one less notch:
%    \begin{macrocode}
\newcommand{\2}{\global\advance\ind by \m@ne }
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\3}
%  An optional break within a statement, as from "@|":
%    \begin{macrocode}
\newcommand{\3}[1]{\hfil \penalty#10 \hfilneg}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\4}
% Backspace one notch:
%    \begin{macrocode}
\newcommand{\4}{\copy\bak}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\5}
% Optional break:
%    \begin{macrocode}
\newcommand{\5}{\hfil \penalty \m@ne  \hfilneg \kern 2.5em \copy\bakk
  \ignorespaces} 
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\6}
% A forced break with no indentation:
%    \begin{macrocode}
\def\6{\ifmmode \else \par
  \hangindent\ind em\startline \ignorespaces \fi}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\startline}
% This is used by "\code" as well as "\6" above.
%    \begin{macrocode}
\def\startline{\noindent \count255=\ind \advance\count255 by -2
  \hskip\count255 em}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\7}
%  A forced break and a little extra vertical space, as from "@#": 
%    \begin{macrocode}
\newcommand{\7}{\Y\6}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\8}
% No indentation.  It works only in code, not in "|"\dots"|".
%    \begin{macrocode}
\newcommand{\8}{\unskip}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\J}
% \tangle's join operation ("@&"):
%    \begin{macrocode}
\newcommand{\J}{\str{@\&}}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\C}
% This looks after comments.  The hooks are inserted because comments
% aren't code (see below).
%    \begin{macrocode}
\def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi
   \XX \hfil \penalty \m@ne\hfilneg\quad % original spider
   $\commentbegin\,$\endcodehook{#1}\startcodehook$\,
   \commentend$\XX}
%    \end{macrocode}
% \end{macro}
%
%    \subsection{Modules}
%
% \begin{macro}{\onmaybe} \begin{macro}{\maybe} \begin{macro}{\ifon}
% These switches are concerned with only printing changed sections if
% so desired.
%    \begin{macrocode}
\def\onmaybe{\let\ifon=\maybe}  \let\maybe=\iftrue  \newif\ifon
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}
%    \begin{macro}{\M}
% Beginning of an un-starred section:
%    \begin{macrocode}
\outer\def\M#1.{%
  \MN#1.\ifon\vfil\penalty-100\vfilneg
  \vskip12ptminus3pt \startsection \ignorespaces}
%    \end{macrocode}
% \end{macro}
%    \begin{macro}{\startsection}  \begin{macro}{\lapstar}
% Some auxilliary definitions:
%    \begin{macrocode}
\def\startsection{\Q \noindent {\let\*=\lapstar \bf \modstar.\quad }}
\newcommand{\lapstar}{\rlap{*}}
%    \end{macrocode}
%    \end{macro}    \end{macro}
%    \begin{macro}{\N}
% This introduces a starred section (where "#2" is the title).   We
% have to check the title with "\headcheck" for a leading 
% character indicating a subsection.  Then we write a contents entry,
% change the running header and set the title in bold.  "\old@S" is
% used in the header rather than "\S" since "\S" is probably
% wrongly-defined at this point (see below).
%    \begin{macrocode}
\outer\def\N#1.#2.{%
  \MN#1.\headcheck#2\headcheck
  \typeout{*\modno} % progress report
  \addcontentsline{toc}{\headcheck@type}
    {\hbox to 2em{\modno\hfill} \quad \theopen \relax \themodtitle}
  \markboth{% running headline
    {\protect\small \qquad\uppercase{\ignorespaces\themodtitle}}
      \hfill {\protect\small \@title}\qquad{\rm \old@S \modno}}
    {\rm \old@S \modno\qquad {\protect\small \@title}\hfill
      {\protect\small \uppercase{\ignorespaces\themodtitle\qquad}}}
  \ifon\startsection {\bf \ignorespaces \themodtitle.\quad }\ignorespaces}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MN}

% Here is some common code for "\M" and "\N"\@.
% It sets
% "\sectionmark" for the headers and defines cross-referencing
% information for the current module.
% It also
% looks after the decision about whether or not to set this module if it
% is not starred.
%    \begin{macrocode}
\def\MN#1.{%
  \par {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}%
  \ifx\modno\modstar \onmaybe \else \ontrue \fi 
  \sectionmark{\modno} 
%    \end{macrocode}
% The following code for setting the currentlabel to the module number
% is a variation on that in {\tt latex.tex}.
%    \begin{macrocode}
  \let\@tempa\protect
  \def\protect{\noexpand\protect\noexpand}%
  \def\@currentlabel{#1}%
  \let\protect\@tempa} % def\MN
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\note} \begin{macro}{\A}
% Auxilliary macros.  "\A" is for cross-references for multiply
% defined section names.
%    \begin{macrocode}
\def\note#1#2.{\Y \noindent {\hangindent 2em \footnotesize
  \baselineskip 10pt#1 #2.\par}}
\newcommand{\A}{\note{See also}}
%    \end{macrocode}
% \end{macro} \end{macro}
%
% \subsubsection{Processing special section headings}
% 
% This complicated stuff, introduced with \spider{} and modified for the
% \LaTeX{} version, is to allow an inital =, 1, 2, 3 or 4 in 
% starred module titles to indicate a hierarchy.  Their effect is as follows:
% \[ \begin{tabular}{c|c|c}
% Introduction & Page eject? & Indentation in contents\\ \hline
% "@*=" & yes & 0 \\
% "@*1" & yes & 2 em \\
% "@*2" & no  & 2 em \\
% "@*3" & yes & 4 em \\
% "@*4" & no  & 4 em \\
% \end{tabular} \]
% "@*=" also suppresses a following page eject and emboldens the
% table of contents entry and puts some extra vertical space before
% it.  Normal starred sections have no indentation in the contents and
% don't do anything special about page breaks.
%
% \begin{macro}{\l@part} \begin{macro}{\l@norm} \begin{macro}{\l@num}
% Two new sorts of contents entry are defined here and the `part'
% type re-defined.  (See "latex.tex" for details of how this works.)
% "\l@part" determines the t.o.c.\ entry for a "@*=" section,
% "\l@norm" the entry for a normal starred section and "\l@num" that
% for a numbered section.  Some penalties are inserted (the normal
% values for the main style) in case the t.o.c.\ extends over more
% than one page.  The "\headcheck@type" definition is used in the
% sectioning commands to write the t.o.c.\ entry.
%    \begin{macrocode}
\def\l@part{\addpenalty{\@secpenalty}
   \addvspace{3pt plus 1pt}     % space above part line
   \@dottedtocline{0}{\z@ }{4em}}
\def\l@norm{\addpenalty{\@secpenalty}
   \@dottedtocline{0}{\z@ }{4em}}
\def\l@num{\@dottedtocline{0}{0em}{4em}}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begin{macro}{\ifcancel} \begin{macro}{\ifnextchar}
% \begin{macro}{\ifnch} \begin{macro}{\makethechar}
% Here's the tricky stuff, presented without further comment!
%    \begin{macrocode}
\newif\ifcancel  \cancelfalse
\def\ifnextchar#1#2#3{%
  \let\@tempe=#1\def\@tempa{#2}\def\@tempb{#3}\@ifnch}
\def\@ifnch{%
  \ifx \@tempc \@tempe\let\@tempd\@tempa
  \else \let\@tempd\@tempb
  \fi
  \@tempd}
\def\makethechar#1{\let\@tempc=#1}
%    \end{macrocode}
% \end{macro} \end{macro} \end{macro} \end{macro}
% \begin{macro}{\headcheck}
% ~
%    \begin{macrocode}
\def\headcheck#1#2\headcheck{%
  \makethechar{#1}%
  \def\theskipper{\vfil\penalty-100 % skip before new module
    \vfilneg\vskip12ptminus3pt}%
  \def\theopen{}% opening skip in toc entry
  \def\thetocskip{}% vertical skip before toc entry
  \def\themodtitle{{#2}}%
  \def\headcheck@type{num}%
  \ifnextchar={%
    \def\theskipper{\newpage}  \canceltrue
    \def\headcheck@type{part}       \def\theopen{\bf}%
    \def\thetocskip{\vskip 3pt plus 1in \penalty-100 
      \vskip \z@  plus -1in}% 
    }{\ifnextchar1{%
      \cancelfalse      \def\theskipper{\newpage}%
      \def\theopen{\hskip2em}%
    }{\ifnextchar2{%
      \cancelfalse      \def\theopen{\hskip2em}%
    }{\ifnextchar3{%
      \cancelfalse      \def\theskipper{\newpage}%
      \def\theopen{\hskip4em}%
    }{\ifnextchar4{%
      \cancelfalse      \def\theopen{\hskip4em}%
    }{% else 
      \ifcancel\else \def\theskipper{\newpage}\fi
      \cancelfalse      \def\headcheck@type{norm}%
      \def\themodtitle{#1{#2}}%
    }}}}}%
    \theskipper }
%    \end{macrocode}
% \end{macro}
%
%    \subsubsection{Starting and ending code sections}
%
% \begin{macro}{\code}
% This takes us into code mode.  The old version used infinite hyphen
% penalty which stopped the discretionary breaks in strings.  Extra
% space is put after ";" with the "\sfcode". 
%    \begin{macrocode}
\newcommand{\code}{%
  \rightskip=\z@  plus 100pt minus 10pt
  \sfcode`;=3000    \pretolerance \@M
  \hyphenpenalty 9999  \exhyphenpenalty \@M
  \global\ind=2 \1 \startline
%    \end{macrocode}
% \DescribeMacro{\@}
% The original says that every web must define "\?", where "?" is the
% at-sign.  Since "\@" is used for end-of-sentence space in \LaTeX, we
% make sure this is only done in code mode.  We need the old and new
% definitions, "\old@" and "\code@", between which to switch.
% \spider{} unfortunately uses "\S" instead of "\equiv" and the awk
% and C \web s assume that "\%" and "\#" translate to typewriter
% versions, so we have to define these properly in code mode too.
% \DescribeMacro{\startcodehook} \DescribeMacro{\endcodehook}
% For convenience, we define token registers
% "\startcodehook" and "\endcodehook" for this sort of purpose when we
% go into and out of code mode.  These might be altered by the
% \spider\ description if appropriate.
%    \begin{macrocode}
  \startcodehook} % \def\code
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\old@}\begin{macro}{\code@}\begin{macro}{\old@S}
% \begin{macro}{\old@percent} \begin{macro}{\old@hash}
% Let's store the original definitions of these:
%    \begin{macrocode}
\let\old@=\@   \let\old@S=\S  \let\old@percent=\%  
\let\old@hash=\#
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\code@}\begin{macro}{\tt@percent}\begin{macro}{\tt@hash}
% And here are replacements for use in code mode.
%    \begin{macrocode}
\chardef\code@=`\@  
\def\tt@percent{\hbox{\tt\char`\%}}  \def\tt@hash{\hbox{\tt\char`\#}}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begin{macro}{\startcodehook}\begin{macro}{\endcodehook}
% Here are the hooks.  Should these be token registers?
%    \begin{macrocode}  
\def\startcodehook{\let\@=\code@  \let\S=\equiv  \let\%=\tt@percent
  \let\#=\tt@hash  \def\^{\hbox{\tt\char`\^}}}
\def\endcodehook{\let\@=\old@  \let\S=\old@S  \let\%=\old@percent
  \let\#=\old@hash  \def\^##1{{\accent94 ##1}}}
%    \end{macrocode}
%  \end{macro}\end{macro}
% \begin{macro}{\Q}
% This gets us out of code mode, setting things back to normal.
%    \begin{macrocode}
\def\Q{\rightskip=\z@   \sfcode`;=1500  \pretolerance 200  
  \endcodehook}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\CD} \begin{macro}{\DC}
% Web text in "|"\dots"|" is woven into text surrounded by
% "\CD"\dots"\DC"\@.  The original definition didn't bother with the
% grouping if not in math mode, but it's convenient now that the hooks
% need to be added.
%    \begin{macrocode}
\def\DC{\endcodehook \egroup}
\def\CD{\relax
  \ifmmode \hbox\fi \bgroup \startcodehook}
%    \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\U}
% This provides a cross-reference for uses of sections.
%    \begin{macrocode}
\newcommand{\U}{\note{This code is used in}} 
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\X}
% This does modules which introduce the code.  Note the usage:
% "\X"\meta{module number}":"\meta{module name}"\X".
%    \begin{macrocode}
\def\X#1:#2\X{%
  \ifmmode \gdef\XX{\null$\null}\else \gdef\XX{}\fi
  \XX$\langle\,$#2{\footnotesize \kern.5em #1}$\,\rangle$\XX }
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\XF}
% This is for a file module (from "@("):
%    \begin{macrocode}
\def\XF#1:#2\XF{%
  \ifmmode \gdef\XX{\null$\null}\else \gdef\XX{}\fi
  \XX {\tt (#2{\footnotesize \kern.5em #1})}\XX}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\Y} \begin{macro}{\yskip}
% This does a vertical skip by "\yskip", used in "\note" and "\7".
%    \begin{macrocode}
\newcommand{\Y}{\par\yskip}
\let\yskip=\smallskip
%    \end{macrocode}
%    \end{macro}\end{macro}
%    
% \subsection{Definitions and formats}
% 
% \begin{macro}{\D} \begin{macro}{\F} \begin{macro}{\defin}
% "\D" and "\F" deal with macro and format definitions from "@d" and
% "@f" respectively.
%    \begin{macrocode}
\newcommand{\D}{\defin{define}} % macro definition
\newcommand{\F}{\defin{format}} % format definition
\newcommand{\defin}[1]{\global\advance\ind by 2 \1\res{#1 }}
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}
% 
% \subsection{Miscellaneous symbols}
% 
% \begin{macro}{\DO} \begin{macro}{\G} \begin{macro}{\I}
% \begin{macro}{\K} \begin{macro}{\L} \begin{macro}{\R} 
% \begin{macro}{\TI} \begin{macro}{\V} \begin{macro}{\W}
% Here are some miscellaneous symbols.  I think these should really be
% defined in the \spider\ descriptions that need them, but they are
% assumed by the current webs.
%    \begin{macrocode}
\newcommand{\DO}{\hbox{\sl\char'044}}    % slant dollar sign (used by awkweb)
\let\G=\ge                      % greater than or equal sign
\let\I=\ne                      % unequal sign
\let\K=\gets                    % left arrow
\let\L=\le                      % less than or equal sign
\let\R=\lnot                    % logical not
\let\TI=\sim                    % tilde
\let\V=\lor                     % logical or
\let\W=\land                    % logical and
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
%    \end{macro}\end{macro}\end{macro}
% \begin{macro}{\vert} \begin{macro}{\amp} \begin{macro}{\PP}
% \begin{macro}{\*} 
% And some more:  (n.b., the plain \TeX{} definitions of "\vert"
% and "\*" are over-written, as expected by spidery \weave---maybe this
% should be changed).
%    \begin{macrocode}
\def\vert{|}   \let\amp=\&   \let\PP=\P   \let\*=*
%    \end{macrocode}
%    \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\AT!}
% \changes{v1.2}{10/6/91}{Re-instate trailing !.}
% This is the `at sign in control
% text'.  I dn't know why it has the trailing "!", but it apears to
% have bene intentional in the plain version.
%    \begin{macrocode}
\def\AT!{@}
%    \end{macrocode} 
%    \end{macro}
%
% \subsection{Indexing}
%
% \begin{macro}{\ch}
% This is used trivially at the start of the index in the case of
% changes: 
%    \begin{macrocode} 
\def\ch{\note{The following sections were changed by the change file:}
  \let\*=\relax}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\inx} \begin{macro}{\:}
% The index is set in two-column mode.
% Each item in each index is introduced by "\:".  This is a \LaTeX{}
% macro but is unlikely to get used in the index and so is preserved
% from the original.
%    \begin{macrocode}
\def\inx{%
  \typeout{Index:}
  \begin{multicols}{2}
  \parskip \z@  plus .5pt
  \parfillskip \z@  plus .6\hsize % try to avoid almost empty lines
  \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
  \rm  \tolerance \@M  \let\*=\lapstar
  \hyphenpenalty \@M \parindent=\z@  }
%    \end{macrocode}
% \end{macro}\end{macro}
%    \begin{macro}{\fin}
% This finishes off the name index and starts off the module index.
% "\:" acts as in "\inx".  The modules may be
% qualified with "\U", which cross-references section uses.  The page
% header is changed appropriately.
%    \begin{macrocode}
\def\fin{%
  \end{multicols}  \newpage
  \parfillskip \z@  plus 1fil
  \markboth{{\protect\small NAMES OF THE SECTIONS}\hfill 
      {\protect\small\@title}}
    {{\protect\small\@title}\hfill
    {\protect\small NAMES OF THE SECTIONS\quad}}
  \typeout{Section names:}
  \def\note##1##2.{\quad{\footnotesize##1 ##2.}}
  \def\U{\note{Used in}}%
  \def\:{\par\hangindent 2em}\let\*=*}
%    \end{macrocode}
%    \end{macro}
% \begin{macro}{\con}
% This finishes everything off, rather trivially.  (It used to make
% the contents page.)
%    \begin{macrocode}
\newcommand{\con}{\end{document}}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Including other files}
%
% \DescribeEnv{multicols}
% We need the {\tt multicols} environment to make a two-column index
% without a forced page break.
%    \begin{macrocode}
\input{multicol.sty}
%    \end{macrocode}
% \DescribeMacro{\webmacs}
% Finally we include the macros defined by \spider.  Doing things this way
% means that \spider{} can override things done in this file for the
% \web{} system of a particular language (like the
% definition of "\res", for instance) and the limbo section can do
% further overriding for a particular web file.  If we're using this
% file to document itself, "\webmacs" should have been defined in the
% driver file to be "null"!
%    \begin{macrocode}
\input{\webmacs}
%    \end{macrocode}
% "\webmacs" is no further use and we might as well save the space.
%    \begin{macrocode}
\let\webmacs=\empty
%    \end{macrocode}
%
% \appendix
% \section{Changes from the plain version}\label{changes}
%
% \begin{description}
% \item[{\tt \BS.}] becomes "\str";
% \item[{\tt \BS\char`\^}] has been removed from the global
% definitions (where it was assumed by the "c.spider" translation for
% "^") and put in limbo in "weave.ch";
% \item[{\tt \BS\%}, {\tt \BS\#} and {\tt \BS\$}] also removed from global
% definitions and put in "\startcodehook"; 
% \item[{\tt \BS\char`\~}] removed globally since it doesn't seem to be used;
% \item[{\tt \BS\BS} and {\tt \BS|}] become "\id" and "\ida" respectively;
% \item[{\tt \BS\&}] becomes "\res";
% \item[{\tt \BS B} and {\tt \BS T}] (for controlled comments) removed
% since no controlled comments in \spider;
% \item[{\tt \BS)}] (string pool check sum) removed;
% \item[{\tt \BS]}] (sign for forced line break) appears not be be
% used, so removed;
% \item[{\tt \BS=}] becomes "\vstr";
% \item[{\tt \BS H}] (hat) removed since it seems not to be used and
% clashes with \LaTeX;
% \item[{\tt \BS Z}] replaced by \LaTeX{} contents stuff;
% \item[{\tt \BS lheader} and {\tt \BS rheader}] replaced by \LaTeX{} marks;
% \item[output routine stuff] all gone;
% \item[{\tt \BS rhead}] no longer relevant---use the \LaTeX{} mark
% mechanism; 
% \item[{\tt \BS title}] should be called as a macro with the title as
% its argument rather than "\def"ed; 
% \item[{\tt \BS contentspagenumber}, {\tt \BS contentsfile} and {\tt
% \BS readcontents}] no longer relevant;
% \item[{\tt \BS pagewidth}, {\tt \BS pageheight} and {\tt \BS
% fullpageheight}] no longer relevant---use the \LaTeX\ equivalents;
% \item[{\tt \BS pageshift}] no longer relevant---use "twoside" option;
% \item[verbatim macros] no longer relevant;
% \item[{\tt \BS iftitle}] removed---use "\pagestyle{empty}" to
% suppress page header.
% \end{description}
%
% \begin{thebibliography}{1}
% \bibitem{spider} N. Ramsey, {\sl Comm. ACM}, {\bf 32} (1989) 1051
% \end{thebibliography}