Debian Codegraph @

texmf-dist/doc/latex/cweb-latex/src/cweave-spec.tex

raw
1 % $DocId: cweave-spec.tex,v 1.8 1995/09/12 22:56:02 schrod Exp $
2 %------------------------------------------------------------
3
4 %
5 % specification of CWEAVE/TeX interface
6 %
7 % [LaTeX]
8 % (history at end)
9
10
11 % This file is either a subdocument of the style doc or a document on
12 % its own. In the former case it's a chapter, in the latter it's a
13 % ``normal'' LaTeX progltx document.
14 % If it's a subdocument, this file will be included after
15 % \begin{document}. We can detect this: \document redefines
16 % \documentclass to be \@twoclasseserror. Then we also have to define
17 % how this document is ended: Either by \endinput or by an additional
18 % revision log.
19 % Of course, this test works only if LaTeX 2e is used for processing.
20
21 \expandafter\ifx \csname @twoclasseserror\endcsname \documentclass
22
23 \let\endSubDocument=\endinput
24
25 \chap The interface between \cweave{} and \TeX{}.
26 \label{sec:cweave-spec}
27
28 \else
29
30 \let\endSubDocument=\relax
31
32 \documentclass{progltx}
33
34 \usepackage{cweb-doc} % additional document-specific markup
35 \usepackage{a4-9} % Tschichold's A4 layout
36
37
38 \begin{document}
39
40 \title{The Interface between \cweave{} and \TeX{}}
41 \author{Joachim Schrod%
42 \thanks{Email: \texttt{[email protected]}}%
43 }
44 \RCSdate $DocDate: 1995/09/12 22:56:02 $
45
46 \maketitle
47
48 \sect
49
50 \fi
51
52
53
54
55 Here we present all tags output by \cweave{}%
56 \footnote{This information refers to \cweb{}~3.4. Differences to
57 other 3.x versions of \cweave{} are minor and can be ignored in
58 our context. See the revision log of the complete interface specs
59 document for more information.}
60 in an ordered fashion. First we look at those
61 tags which are part of the `protected interface,' i.e., they are
62 visible to a \cweb{} user, but he must not use them. Then we consider
63 the private tags, some are used in the documentation part, others
64 are needed to typeset program code, and there are a few tags for
65 typesetting special characters in strings.
66
67
68 \sect Some tags output by \cweave{} are part of the protected
69 interface even though they are not prefixed by |cweb|. We'll present
70 them in the order they'll arrive in the document instance.
71
72 The following table specifies in the second column if this tag takes
73 arguments. If the entry is non-empty, it's either a number listing
74 just how many arguments are expected; then usual argument passing is
75 used. Or it displays the context required.
76 %
77 \begin{cseqtab}
78 |\ATL| & \verb*|#1 #2 | & \cweb{} operator: |@l|
79 && (how to output non-ASCII chars in \ctangle{})
80 && \arg1 hex code of mapped character
81 && \arg2 string output by \ctangle{}
82 |\M| & 1 & \cweb{} structure tag: start of a chunk
83 && \arg1 chunk number
84 |\N| & |#1#2#3.| & \cweb{} structure tag: start of a section
85 && \arg1 section rank, $0 \le |#1| \le 10$
86 && \arg2 chunk number
87 && \arg3 section title
88 |\PB| & 1 & restricted program mode material
89 && \arg1 program code
90 |\Y| & & between major pieces of a program part
91 |\B| & & start program material
92 |\fi| & & \cweb{} structure tag: end of a chunk
93 |\9| & 1 & index entry, user defined layout
94 && \arg1 text of index entry
95 \end{cseqtab}
96
97 |\ATL| does only appear in front of the very first chunk. The
98 chunk number is an explicit \TeX{} number which might be followed
99 by a `changed flag' (see chunk~\ref{sec:text-tag.priv}). Note the
100 usage of |\fi|, ie, each chunk must open an according |\if|. |\PB|
101 might appear within its own argument (created by restricted program
102 mode material in a refinement name within restricted program mode).
103
104 |\9| deserves a further explanation: It is expected, though not
105 defined, that it expands to an empty token list. The parameter will
106 be a sort key, actually; the real key to be typeset will appear
107 afterwards. So a \cweb{} user might index \TeX{} as
108 `|@:TeX}{\TeX@>|', the index will feature it in the ``T''~chunk,
109 not in the ``|\|''~chunk.
110
111 With the exception of |\PB| the tags above will not appear in math mode.
112
113
114 \sect The following tags might appear to be public ones, but they
115 are, in fact, never used. That's because they will be placed after
116 the |\fi| which terminates the last chunk. Our problem is that we
117 have to produce the information which were produced by these tags in
118 the Plain macros. Namely the optional lists poses us the problems. We
119 must read behind the document end to gather the information which
120 lists to produce.
121
122 %% This label is used in cweb.doc
123 \label{spec:sec:docend}
124
125 We can depend on the following rules.
126 %
127 \begin{enumerate}
128
129 \item If |\end| is found, there will be no other of these tags.
130
131 \item |\ch| comes first, but is optional.
132
133 \item |\inx\fin| come next, they are mandatory.
134
135 \item |\con| is optional again; if it is found it's the very last
136 token to look at in this document.
137
138 \end{enumerate}
139 %
140 \begin{fixme}
141
142 Perhaps |\inx| should be defined as |\end{document}|, and both |\ch|
143 and |\inx| should be added to the protected interface. Then the user
144 may simply omit |\end{document}|. But we should take care of a
145 possible occurence anyhow.
146
147 \end{fixme}
148
149 Here are the tags mentioned in this chunk, and their respective
150 meaning in the Plain version:
151 %
152 \begin{cseqtab}
153 |\ch| & |#1.| & Note which chunks are changed
154 && \arg1 list of chunk numbers, like in |\U| and such.
155 |\inx| & & Create index
156 |\fin| & & Create the table of refinement names
157 |\con| & & Create the table of contents
158 |\end| & & output if index and all lists were suppressed
159 \end{cseqtab}
160
161
162
163 \sect \label{sec:text-tag.priv}
164 Some tags appear only in special circumstances and may therefore be
165 considered as private tags. The largest part of them concern the tagging of
166 program code, we'll have a look at them later. First we present the
167 tags used in other areas.
168
169 Lists of chunk numbers occurs on several places: At the chunk
170 start (where the list has actually only one element), within
171 refinement names, in the identifier index, and for cross reference
172 purposes. Cross references can be made at the end of a chunk, and
173 in the refinement name list at the very end. Everywhere where a
174 chunk number can occur it can be followed by a tag which shows that
175 this chunk was changed by the changefile.
176 %
177 \begin{cseqtab}
178 |\*| & & tag after chunk number: this chunk is changed.
179 \end{cseqtab}
180
181 Within the identifier index we have also special tags. The identifiers
182 are tagged like in the program mode, ie, with |\\| and |\&|. Remember
183 that |\9|, listed above, appears also in the index.
184 %
185 \begin{cseqtab}
186 |\I| & \verb*|#1, | & start of an index entry
187 && \arg1 index entry
188 |\[| & |#1]| & underlined chunk number in index
189 && \arg1 chunk number
190 |\.| & 1 & |@.| index entry
191 && \arg1 index entry
192 \end{cseqtab}
193
194 In the list of refinement names the entries are marked similar to
195 the index entries. But note that |\I| has no arg here.
196 %
197 \begin{cseqtab}
198 |\I| & & start of a new refinement name
199 \end{cseqtab}
200
201
202 \sect \label{sec:prog-tag}
203 OK, now we can have a look at the large amount of tags used
204 for tagging program code. First, we have those which represent
205 directly C or \C++ tokens.
206 %
207 \begin{cseqtab}
208 |\?| & & C operator: conditional expression
209 |\AND| & & C operator: logical and
210 |\CM| & & C operator: binary complement
211 |\DC| & & \C++ operator: scope resolution
212 |\E| & & C operator: equivalence
213 && and equivalence sign after refinement name on it's definition
214 |\G| & & C operator: greater or equal
215 |\GG| & & C operator: shift right
216 |\I| & & C operator: not equal
217 |\K| & & C operator: assignment
218 |\LL| & & C operator: shift left
219 |\MG| & & C operator: pointer to struct component
220 |\MGA| & & \C++ operator: pointer to pointer to member
221 |\MM| & & C operator: decrement
222 |\MOD| & & C operator: modulo (actually, remainder)
223 |\NULL| & & `quoted' identifier
224 |\OR| & & C operator: binary or
225 |\PA| & & \C++ operator: pointer to member
226 |\PP| & & C operator: increment
227 |\R| & & C operator: logical negation
228 |\this| & & `quoted' identifier
229 |\TeX| & & `customized' identifier
230 |\V| & & C operator: logical or
231 |\W| & & C operator: logical and
232 |\XOR| & & C operator: binary exclusive or
233 |\Z| & & C operator: less or equal
234 \end{cseqtab}
235
236 Other tokens have variable parts, passed as arguments.
237 %
238 \begin{cseqtab}
239 |\.| & 1 & C string
240 && \arg1 string
241 |\)| & & discretionary break between string parts
242 |\&| & 1 & reserved identifier
243 && \arg1 identifier
244 |\\| & 1 & ``normal'' identifier with more than one chars
245 && \arg1 identifier
246 \verb"\|" & 1 & ``normal'' identifier with one char
247 && \arg1 character
248 |\C| & 1 & C comment
249 && \arg1 comment text
250 |\MRL| & 1 & C operator: combined binary operators
251 && \arg1 operators, |\K| must print as `$=$'
252 |\SHC| & 1 & \C++ comment
253 && \arg1 comment text
254 |\T| & 1 & numeric constants
255 && \arg1 constant
256 |\X| & |#1: #2\X| & refinement name
257 && \arg1 chunk number
258 && \arg2 refinement name
259 \end{cseqtab}
260 %
261 The refinement name (second argument of |\X|) may be a file name
262 tagged by `|\.|'. Then the name must be set like a C~string.
263
264 \cweb{} itself introduces its own operators:
265 %
266 \begin{cseqtab}
267 |\ATH| & & |@h| (place the preprocessor definitions here)
268 |\D| & & |@d| (define macro)
269 |\F| & & |@f| (format identifier like another one)
270 |\J| & & |@&| (join)
271 |\vb| & 1 & |@=| (pass arg verbatim by \ctangle{})
272 && \arg1 string
273 \end{cseqtab}
274
275 And we have some tags used for cross referencing. Chunk
276 cross-referencing (actually, for program parts) is started with some
277 tag, then follows a list of chunk numbers.
278 %
279 \begingroup
280 \hfuzz=22pt % 21.76602pt too wide (with a4-9.sty)
281 \begin{cseqtab}
282 |\A| & & one add-on definition (``See also chunk'')
283 |\As| & & more than one add-on definition (``See also chunks'')
284 |\ET| & & separator between the last two numbers if there are only two
285 |\ETs| & & separator between the last two numbers if there are more than two
286 |\Q| & & the chunk where it is cited (``This code is cited in chunk'')
287 |\Qs| & & more than one chunk where it is cited (``This code is cited in chunk'')
288 |\U| & & used in one chunk (``This code is used in chunk'')
289 |\Us| & & used in more than one chunk (``This code is used in chunks'')
290 \end{cseqtab}
291 \endgroup
292
293 Program code must be indented according to its structure. Each
294 ``larger'' statement is typeset as one paragraph, usually only one
295 line long. The basic indentation of the next statement may be
296 incremented and decremented in given units. If a statement has to be
297 broken in more than one line nevertheless, a hanging indentation is
298 added to the basic indentation for the subsequent lines. One can mark
299 an `optional' statement start, ie, some kind of optional paragraph
300 start. If a line break must be inserted it should be inserted here and
301 no hanging indentation should be added to the basic indentation.
302 %
303 \begin{cseqtab}
304 |\1| & & future stmts indented one more unit
305 |\2| & & future stmts indented one less unit
306 |\3| & 1 & optional line break within a statement
307 && \arg1 digit, penalty for line break
308 |\4| & & backspace one indentation unit
309 |\5| & & optional line break or small space (between run-in statements)
310 |\6| & & line break
311 |\7| & & line break and additional vertical space
312 |\8| & & line is a preprocessor directive (must be issued at start of line)
313 \end{cseqtab}
314
315
316 \sect Some args are designated as strings above. Within these args the
317 following tags are used to represent special characters:
318 %
319 \begin{cseqtab}
320 \verb*|\ | & & space
321 |\&| & & ampersand
322 |\\| & & backslash
323 |\^| & & hat
324 |\_| & & underscore
325 |\{| & & left brace
326 |\}| & & right brace
327 |\~| & & tilde
328 \end{cseqtab}
329
330
331 \sect Last, we have tags which are used in their ``standard''
332 \LaTeX{} meaning. We don't have much work with them:
333 %
334 \begin{cseqtab}
335 |\#| & & hash mark in program or in string
336 |\$| & & dollar
337 |\%| & & percent
338 |\{| & & block start (is set in math mode)
339 |\}| & & block end (is set in math mode)
340 |\,| & & thin space (like the \LaTeX{} default)
341 |\langle| & & left delimiter in include directives, or in templates
342 |\le| & & C operator: less or equal
343 |\ldots| & & Function protoypes: Variable number of arguments
344 |\rangle| & & right delimiter in include directives, or in templates
345 \end{cseqtab}
346
347
348
349
350 \endSubDocument
351
352
353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
354
355 \vskip \PltxPreSectSkip
356
357 \begin{rcslog}
358 $DocLog: cweave-spec.tex,v $
359 \Revision 1.8 1995/09/12 22:56:02 schrod
360 |cweave -x| doesn't output |\vfill| in front of |\end| any more.
361 Change noticed in \cweb{} 3.4.
362
363 \Revision 1.7 1995/08/29 01:40:24 schrod
364 Checked the interface description for \cweb{}~3.4.
365
366 \Revision 1.6 1995/08/25 19:09:57 schrod
367 Cleaned up terminology: Chunks are not named sections any more.
368 Explicate possible range of section ranks.
369
370 \Revision 1.5 1995/08/08 00:14:26 schrod
371 Updated to \LaTeXe{}, the |cweb| style is now a document class. Used
372 my standard templates for that, no changes in functionality.
373
374 \Revision 1.4 1993/06/17 15:09:28 schrod
375 \cweb{} 3.0 was released officially on June 16, 1993. Mentioned in
376 the documentation that this version is needed for the |cweb| style.
377
378 \Revision 1.3 1993/06/14 17:50:14 schrod
379 Clarify the occurence pattern of the lists after the last section:
380 which are optional, the expected order, etc.
381
382 Changed `cseq' to `tag'. On this level of abstraction (that's the
383 specification!), we're still not considering \TeX{}nical details.
384
385 \Revision 1.2 1993/06/14 15:40:02 schrod
386 Adapted to April 93 changes to \cweave{}: |\N| has three parameters
387 (added group level), |\M| param is no data-tag any more, |\Z| and
388 |\MRL| are new.
389
390 Added further explanation of |\9| and |\X|.
391
392 Replaced `program part name' by `refinement name'.
393
394 \Revision 1.1 1993/04/09 15:00:37 schrod
395 Initial revision
396
397 \end{rcslog}
398
399
400
401 \end{document}
402
403 % LocalWords: