From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- web/latexspider/weave.ltx | 700 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 700 insertions(+) create mode 100644 web/latexspider/weave.ltx (limited to 'web/latexspider/weave.ltx') diff --git a/web/latexspider/weave.ltx b/web/latexspider/weave.ltx new file mode 100644 index 0000000000..7b5454fee6 --- /dev/null +++ b/web/latexspider/weave.ltx @@ -0,0 +1,700 @@ +% This is `weave.ltx' to fix spidery weave for LaTeX. See +% `web.doc' for some comments about how it works. + +% changes copyright D.Love, SERC Daresbury Laboratory +% (d.love@daresbury.ac.uk) under the same conditions as the Spider +% distribution. + +%$Header: /home/users0/fx/ltxspiderweb/master/weave.ltx,v 1.4 91/03/22 11:24:35 fx Exp $ + + l 11 (remove \batchmode so we can see what's happening) +@x +% Here is TeX material that gets inserted after \input webmac + +\message{Entering \string\batchmode...} +\batchmode +@y +% Here is TeX material that gets inserted after \documentstyle[web]... + +% we turn off batch mode for debugging purposes + +%\message{Entering \string\batchmode...} +%\batchmode +@z + + l 16 (swicth for LaTeX or plain) +@x +\def\hang{\hangindent 3em\indent\ignorespaces} +\font\ninerm=cmr9 +\let\mc=\ninerm % medium caps +\def\cee{C} +\def\Pascal{Pascal} +\def\PASCAL{Ada} +\def\pb{$\.|\ldots\.|$} % C brackets (|...|) +\def\v{\.{\char'174}} % vertical (|) in typewriter font +\def\dleft{[\![} \def\dright{]\!]} % double brackets +\mathchardef\RA="3221 % right arrow +\mathchardef\BA="3224 % double arrow +\def\({} % kludge for alphabetizing certain module names + +\def\title{Spidery WEAVE} +\def\contentspagenumber{1} % should be odd +\def\topofcontents{\null\vfill + \titlefalse % include headline on the contents page + \def\rheader{\hfil} + \centerline{\titlefont The {\ttitlefont Spidery WEAVE} processor} + \vfill} +\pageno=\contentspagenumber \advance\pageno by 1 +\let\maybe=\iftrue +@y +\ifx \enddocument\undefined % are we using LaTeX? + \font\ninerm=cmr9 % no... + \let\mc=\ninerm % medium caps + +\def\title{Spidery WEAVE} +\def\contentspagenumber{1} % should be odd +\def\topofcontents{\null\vfill + \titlefalse % include headline on the contents page + \def\rheader{\hfil} + \centerline{\titlefont The {\ttitlefont Spidery WEAVE} processor} + \vfill} + \pageno=\contentspagenumber \advance\pageno by 1 +\def\LaTeX{{\rm L\kern-.36em\raise.3ex\hbox{\sc a}\kern-.15em + T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}% +\else % yes... + \documentstyle[web]{article} + \let\.=\str % new name + \title{Spidery WEAVE} \date{} +\fi + +\def\hang{\hangindent 3em\indent\ignorespaces} +\def\cee{C} +\def\Pascal{Pascal} +\def\PASCAL{Ada} +\def\pb{$\.|\ldots\.|$} % C brackets (|...|) +\def\v{\.{\char'174}} % vertical (|) in typewriter font +\def\dleft{[\![} \def\dright{]\!]} % double brackets +\mathchardef\RA="3221 % right arrow +\mathchardef\BA="3224 % double arrow +\def\({} % kludge for alphabetizing certain module names + +\let\maybe=\iffalse % only changed sections -- perhaps you + % want to change this if you're + % weaving WEAVE for the first time + +@z + + l 39 +@x +@* Introduction. +\.{CWEAVE} has a fairly straightforward outline. It operates in +three phases: first it inputs the source file and stores cross-reference +data, then it inputs the source once again and produces the \TeX\ output +file, and finally it sorts and outputs the index. It can be compiled +with certain optional flags, |DEBUG| and |STAT|, the latter being used +to keep track of how much of \.{WEAVE}'s resources were actually used. +@y +@* Introduction. +\.{CWEAVE} has a fairly straightforward outline. It operates in +three phases: first it inputs the source file and stores cross-reference +data, then it inputs the source once again and produces the \TeX\ output +file, and finally it sorts and outputs the index. It can be compiled +with certain optional flags, |DEBUG| and |STAT|, the latter being used +to keep track of how much of \.{WEAVE}'s resources were actually used. + +This version has changes to make it work with \LaTeX{} as the +formatter, rather than plain \TeX\@@. The sections which are changed +for \LaTeX{} are indicated by |#ifdef LaTeX|, so you can define the +|LaTeX| switch when you compile it. You could generate a new +\.{weave.web} using \.{wmerge} or \.{tie} which you could use for +either plain or \LaTeX, since the limbo section will check for the +existence of \.{\\enddocument} (which presumably indicates \LaTeX). +@z + + l 361 +@x +@d underline = @'176 /* this code will be intercepted without confusion */ +@d param = @'177 /* ASCII delete will not appear */ +/* identifier =200 or octal @'310 */ +@#/* following three must be conseccutive for indexing to work */ +@d xref_roman = (identifier+roman) /* control code for `\.{@@\^}' */ +@y +@d underline = @'176 /* this code will be intercepted without confusion */ +@d param = @'177 /* ASCII delete will not appear */ +/* identifier =200 or octal |@'310| */ +@#/* following three must be consecutive for indexing to work */ +@d xref_roman = (identifier+roman) /* control code for `\.{@@\^}' */ +@z + + l 1140 +@x + for (k=p->byte_start; kbyte_start; k + +@u copy_limbo() +@z + + l 1172 +@x + if (c!='z' && c!='Z') { + out(at_sign); + if (c!=at_sign) err_print("! Double @@ required outside of sections"); +@.Double \AT! required...@> + } + } + } +} +@y + if (c!='z' && c!='Z') { + out(at_sign); + if (c!=at_sign) err_print("! Double @@ required outside of sections"); +@.Double \AT! required...@> + } + } + } +#ifdef LaTeX + out_str("\n\\begin{document}\\maketitle\n"); +#endif LaTeX +} +@z + + l 1368 +@x +\.{\\mathrel\{} and \.{\\mathbin\{}, respectively. +Also |math_op| to \.{\\mathop\{}. +Other control sequences in the \TeX\ output will be `\.{\\\\\{}$\,\ldots\,$\.\}' +surrounding identifiers, `\.{\\\&\{}$\,\ldots\,$\.\}' surrounding +reserved words, `\.{\\.\{}$\,\ldots\,$\.\}' surrounding strings, +@y +\.{\\mathrel\{} and \.{\\mathbin\{}, respectively. +Also |math_op| to \.{\\mathop\{}. +Other control sequences in the plain \TeX\ output will be `\.{\\\\\{}$\,\ldots\,$\.\}' +surrounding identifiers, `\.{\\\&\{}$\,\ldots\,$\.\}' surrounding +reserved words, `\.{\\.\{}$\,\ldots\,$\.\}' surrounding strings, +@z + + l 1374 +@x +`\.{\\X$n$:}$\,\ldots\,$\.{\\X}' surrounding module names, where +|n| is the module number. + +@d math_bin = @'205 /* should these be octal or decimal? */ +@y +`\.{\\X$n$:}$\,\ldots\,$\.{\\X}' surrounding module names, where +|n| is the module number. +@^\LaTeX{}@> +In the \LaTeX\ output we'll have `\.{\\id\{}$\,\ldots\,$\.\}' +surrounding identifiers, `\.{\\res\{}$\,\ldots\,$\.\}' surrounding +reserved words, `\.{\\str\{}$\,\ldots\,$\.\}' surrounding strings, +`\.{\\cee\{}$\,\ldots\,$\.\}$\,$|force|' surrounding comments, and +`\.{\\X$n$:}$\,\ldots\,$\.{\\X}' surrounding module names, where +|n| is the module number. +@.\\id@>@.\\res@>@.\\str@> + +@d math_bin = @'205 /* should these be octal or decimal? */ +@z + + l 1472 +@x +\yskip\item{$\bullet$}ASCII codes and special codes like |force| and +|math_rel| represent themselves; + +\item{$\bullet$}|id_flag+p| represents \.{\\\\\{{\rm identifier $p$}\}}; + +\item{$\bullet$}|res_flag+p| represents \.{\\\&\{{\rm identifier $p$}\}}; + +\item{$\bullet$}|mod_flag+p| represents module name |p|; + +\item{$\bullet$}|tok_flag+p| represents token list number |p|; + +\item{$\bullet$}|inner_tok_flag+p| represents token list number |p|, to be +translated without line-break controls. +@y +\begin{itemize} +\item ASCII codes and special codes like |force| and +|math_rel| represent themselves; + +\item |id_flag+p| represents \.{\\\\\{{\rm identifier $p$}\}} in the +plain \TeX\ version or \.{\\str\{{\rm identifier $p$}\}} in the \LaTeX\ +version; + +\item |res_flag+p| represents \.{\\\&\{{\rm identifier $p$}\}} in +plain or \.{\\id\{{\rm identifier $p$}\}}; + +\item |mod_flag+p| represents module name |p|; + +\item |tok_flag+p| represents token list number |p|; + +\item |inner_tok_flag+p| represents token list number |p|, to be +translated without line-break controls. +\end{itemize} +@z + + l 1501 +@x + else for (j=*p; j<*(p+1); j++) { + r=*j%id_flag; + switch (*j/id_flag) { + case 1: printf("\\{"); print_id((name_dir+r)); printf("}"); break; + /* |id_flag| */ +@y + else for (j=*p; j<*(p+1); j++) { + r=*j%id_flag; +#ifdef LaTeX + switch (*j/id_flag) { + case 1: printf("\id{"); print_id((name_dir+r)); printf("}"); break; + /* |id_flag| */ + case 2: printf("\res{"); print_id((name_dir+r)); printf("}"); break; + /* |res_flag| */ + case 3: printf("<"); print_id((name_dir+r)); printf(">"); break; + /* |mod_flag| */ + case 4: printf("[[%d]]",r); break; /* |tok_flag| */ + case 5: printf("|[[%d]]|",r); break; /* |inner_tok_flag| */ + default: @; + } +@.\\id@>@.\\res@> +#else + switch (*j/id_flag) { + case 1: printf("\\{"); print_id((name_dir+r)); printf("}"); break; + /* |id_flag| */ +@z + + l 1512 +@x + default: @; + } + } +} +@y + default: @; + } +#endif LaTeX + } +} +@z + + l 2075 +@x + +@= +if (next_control==constant) app_str("\\O{"); +@.\\O@> +@y + +@= +#ifdef LaTeX +if (next_control==constant) app_str("\\const{"); +@.\\const@> +else if (next_control==string) app_str("\\str{"); +@.\\str@> +else app_str("\\vstr{"); +@.\\vstr@> +#else +if (next_control==constant) app_str("\\O{"); +@.\\O@> +@z + + l 2079 +@x +@.\\.@> +else app_str("\\={"); +@.\\=@> +while (id_first +else app_str("\\={"); +@.\\=@> /* verbatim string */ +#endif LaTeX +while (id_first + +@ The output process uses a stack to keep track of what is going on at +@z + + l 2394 +@x +looks slightly better if set in a math-italic font instead of a (slightly +narrower) text-italic font. Thus we output `\.{\\\char'174a}' but +`\.{\\\\\{aa\}}'. + +@= +out('\\'); +if (a==identifier) + if (length(cur_name)==1) out('|')@; +@.\\|@> +@y +looks slightly better if set in a math-italic font instead of a (slightly +narrower) text-italic font. Thus we output `\.{\\\char'174a}' but +`\.{\\\\\{aa\}}'. In \LaTeX\ we use `\.{\\ida a}' and `\.{\\id\{aa\}}'. +@^\LaTeX{}@> + +@= +#ifdef LaTeX +out('\\'); +if (a==identifier) + if (length(cur_name)==1) out_str("ida "); +@.\\ida@> + else out_str("id"); +@.\\id@> +else out_str("res"); /* |a==res_word| */ +@.\\res@> +#else +out('\\'); +if (a==identifier) + if (length(cur_name)==1) out('|')@; +@.\\|@> +@z + + l 2045 +@x +else out('&')@; /* |a==res_word| */ +@.\\\&@> +if (length(cur_name)==1) out((cur_name->byte_start)[0])@; +else out_name(cur_name); +@y +else out('&')@; /* |a==res_word| */ +@.\\\&@> +#endif LaTeX +if (length(cur_name)==1) out((cur_name->byte_start)[0])@; +else out_name(cur_name); +@z + + l 2430 +@x +the largest one is used. A line break also occurs in the output file, +except at the very end of the translation. The very first line break +is suppressed (i.e., a line break that follows `\.{\\Y\\P}'). + +@= { +@y +the largest one is used. A line break also occurs in the output file, +except at the very end of the translation. The very first line break +is suppressed (i.e., a line break that follows `\.{\\Y\\code}'). +@^\LaTeX{}@> + +@= { +@z + + l 2442 +@x + if ((a!=' ' && abig_force) { + if (save_mode==outer) { + if (out_ptr>out_buf+3 && strncmp(out_ptr-3,"\\Y\\P",4)==0) + goto reswitch; + @; +@y + if ((a!=' ' && abig_force) { + if (save_mode==outer) { +#ifdef LaTeX + if (out_ptr>out_buf+3 && strncmp(out_ptr-3,"\\Y\\code",4)==0)@^\LaTeX{}@>@.\\code@> +#else + if (out_ptr>out_buf+3 && strncmp(out_ptr-3,"\\Y\\P",4)==0) +#endif LaTeX + goto reswitch; + @; +@z + + l 2632 +@x + +@ @= { +out_str("\\O{\\~"); + while ('0'<=*loc && *loc<'8') out(*loc++); +out('}'); +@y + +@ @= { +#ifdef LaTeX +out_str("\\code{\\~"); /* this occurrence of \.{\~} is OK for \LaTeX\ since +the control sequence is only defined within the scope of the \.{\\code} +macro */@^\LaTeX{}@>@.\\code@> +#else +out_str("\\O{\\~"); +#endif LaTeX + while ('0'<=*loc && *loc<'8') out(*loc++); +out('}'); +@z + + l 2638 +@x + +@ @= { +out_str("\\O{\\^"); + while (isxdigit(*loc)) { + out(islower(*loc) ? toupper(*loc):*loc); +@y + +@ @= { +#ifdef LaTeX +out_str("\\code{\\^"); /* OK for \LaTeX{} as above */ +@^\LaTeX{}@>@.\\code@> +#else +out_str("\\O{\\^"); +#endif LaTeX + while (isxdigit(*loc)) { + out(islower(*loc) ? toupper(*loc):*loc); +@z + + l 2662 +@x + +@ The |finish_C| procedure outputs the translation of the current +scraps, preceded by the control sequence `\.{\\P}' and followed by the +control sequence `\.{\\par}'. It also restores the token and scrap +memories to their initial empty state. +@y + +@ The |finish_C| procedure outputs the translation of the current +scraps, preceded by the control sequence `\.{\\P}' (`\.{\\code}' in +\LaTeX{}) and followed by the@^\LaTeX{}@> +control sequence `\.{\\par}'. It also restores the token and scrap +memories to their initial empty state. +@z + + l 2674 +@x +{ + text_pointer p; /* translation of the scraps */ + out_str("\\P"); app_tok(force); app_scrap(SP_ignore_scrap,no_math); + p=translate(); +@.\\P@> +@y +{ + text_pointer p; /* translation of the scraps */ +#ifdef LaTeX + out_str("\\code"); app_tok(force); app_scrap(SP_ignore_scrap,no_math); +@.\\code@>@^\LaTeX{}@> +#else + out_str("\\P"); app_tok(force); app_scrap(SP_ignore_scrap,no_math); +#endif LaTeX + p=translate(); +@.\\P@> +@z + + l 2710 +@x + token following the parameter list@>; + if (next_control==@`=') { + small_app('\\'); small_app('S'); /* equivalence sign */ + @@; + } else { +@y + token following the parameter list@>; + if (next_control==@`=') { +#ifdef LaTeX +@^\LaTeX{}@>@.\\equiv@> + small_app('\\'); app_str("equiv"); +#else + small_app('\\'); small_app('S'); /* equivalence sign */ +#endif LaTeX + @@; + } else { +@z + + l 2823 +@x + this_module=name_dir; /*so we won't give cross-reference info here*/ +} +app_str("\\S"); /* output an equivalence sign */ +@.\\S@> +app_str("{}$"); +small_app(force); +@y + this_module=name_dir; /*so we won't give cross-reference info here*/ +} +#ifdef LaTeX +app_str("\\equiv");@^\LaTeX{}@>@.\\equiv@> +#else +app_str("\\S"); /* output an equivalence sign */ +@.\\S@> +#endif LaTeX +app_str("{}$"); +small_app(force); +@z + + l 2950 +@x +if (no_xref) { + finish_line(); + out_str("\\vfill\\end"); + finish_line(); +} +@y +if (no_xref) { + finish_line(); +#ifdef LaTeX + out_str("\\end{document}");@^\LaTeX{}@>@.\\end{document}@> +#else + out_str("\\vfill\\end"); +#endif LaTeX + finish_line(); +} +@z + + l 2958 +@x + finish_line(); @; + } + finish_line(); out_str("\\inx"); finish_line(); +@.\\inx@> + @; + @; + out_str("\\fin"); finish_line(); +@.\\fin@> + @; + out_str("\\con"); finish_line(); +@.\\con@> +} +@y + finish_line(); @; + } +#if 0 + finish_line(); out_str("\\begin{theindex}"); finish_line(); +#endif + finish_line(); out_str("\\inx"); finish_line(); +@.\\inx@> + @; + @; +#if 0 + out_str("\\end{theindex}\\fin"); finish_line(); +#endif + out_str("\\fin"); finish_line(); +@.\\fin@> + @; + out_str("\\con\\end{document}"); finish_line(); +@.\\con@> +} +@z + + l 3137 +@x +@ @= +switch (cur_name->ilk) { + case normal: if (length(cur_name)==1) out_str("\\|"); + else out_str("\\\\"); break; +@y +@ @= +switch (cur_name->ilk) { +#ifdef LaTeX# + case normal: if (length(cur_name)==1) out_str("\\ida "); + else out_str("\\id"); break; +@^\LaTeX{}@>@.\\ida@>@.\\id@> +#else + case normal: if (length(cur_name)==1) out_str("\\|"); + else out_str("\\\\"); break; +@z + + l 3141 +@x +@.\\|@> +@.\\\\@> + case roman: break; + case wildcard: out_str("\\9"); break; +@.\\9@> + case typewriter: out_str("\\."); break; +@.\\.@> +@y +@.\\|@> +@.\\\\@> +#endif LaTeX + case roman: break; + case wildcard: out_str("\\9"); break; +@.\\9@> +#ifdef LaTeX + case typewriter: out_str("\\str"); break; +@.\\str@> + default: out_str("\\res"); +@.\\res@>@^\LaTeX{}@> +#else + case typewriter: out_str("\\."); break; +@.\\.@> +@z + + l 3148 +@x + default: out_str("\\&"); +@.\\\&@> +} +out_name(cur_name); +@y + default: out_str("\\&"); +@.\\\&@> +#endif LaTeX +} +out_name(cur_name); +@z + + l 3152 +@x + +@ Section numbers that are to be underlined are enclosed in +`\.{\\[}$\,\ldots\,$\.]'. + +@= +@y + +@ Section numbers that are to be underlined are enclosed in +`\.{\\[}$\,\ldots\,$\.]' or `\.{\\underline}$\,\ldots\,$\.\}' in \LaTeX{}. +@^\LaTeX{}@> + +@= +@z + + l 3159 +@x + out_str(", "); cur_val=cur_xref->num; + if (cur_val + cur_xref=cur_xref->xlink; +} while (cur_xref!=xmem); +@y + out_str(", "); cur_val=cur_xref->num; + if (cur_val@^\LaTeX{}@> +#else + else {out_str("\\["); out_mod(cur_val%def_flag); out(']');} +@.\\[@> +#endif LaTeX + cur_xref=cur_xref->xlink; +} while (cur_xref!=xmem); +@z -- cgit v1.2.3