1
\input texinfo @c -*-texinfo-*-
2
@def@ifhtml{@doignore{ifhtml}}
24
@tex`\hbox{\tt@@\char`\ }'@end tex
52
This file documents FWEB...
54
Copyright 1993--1998 John A. Krommes
56
Permission is granted to make and distribute verbatim
57
copies of this manual provided the copyright notice and
58
this permission notice are preserved on all copies.
61
Permission is granted to process this file through TeX
62
and print the results, provided the printed document
63
carries a copying permission notice identical to this
64
one except for the removal of this paragraph (this
65
paragraph not being relevant to the printed manual).
68
Permission is granted to copy and distribute modified
69
versions of this manual under the conditions for
70
verbatim copying, provided also that the section
71
entitled ``Copying'' is included exactly as in the original, and provided
72
that the entire resulting derived work is distributed
73
under the terms of a permission notice identical to this
76
Permission is granted to copy and distribute
77
translations of this manual into another language,
78
under the above conditions for modified versions,
79
except that this permission notice may be stated in a
80
translation approved by the author.
85
@subtitle A WEB system of structured documentation
86
@subtitle for multiple languages
87
@author By John A. Krommes
89
@vskip 0pt plus 1filll
90
Copyright @copyright{} 1993--1998 John A. Krommes
92
Permission is granted to make and distribute verbatim
93
copies of this manual provided the copyright notice and
94
this permission notice are preserved on all copies.
96
Permission is granted to copy and distribute modified
97
versions of this manual under the conditions for
98
verbatim copying, provided also that the section
99
entitled ``Copying'' is included exactly as in the original, and provided
100
that the entire resulting derived work is distributed
101
under the terms of a permission notice identical to this
104
Permission is granted to copy and distribute
105
translations of this manual into another language,
106
under the above conditions for modified versions,
107
except that this permission notice may be stated in a
108
translation approved by the author.
112
@node Top,Copying,(dir),(dir)
115
NOTE: Because of last-minute translation problems with texi2html
116
operating on the macro-expanded version of fweb.texi, user-defined macro
117
expansion has temporarily been turned off in this html version.
118
Multitable is also giving trouble, as is @samp in section names. These
119
are probably problems with texi2html; sorry for the inconvenience.
124
This Texinfo documentation describes @FWEB{} Version 1.61.
131
To learn about new features of this version, see @ref{V1.61}.
134
For a quick introduction to, and review of the structure of an @FWEB{}
135
source file, see @ref{Structure}.
138
If you used to receive e-mail information about @FWEB{} but don't any
139
longer, it's probably because you need to update your e-mail address in
140
the @code{fweb-users} mailing list. Subscription instructions can be
141
found in @ref{Support}.
144
Bug reports and suggestions are much appreciated, but are no longer
145
acknowledged individually. See @ref{Support}.
148
The next major release, @FWEB{} Version 2.00, is planned for
149
no earlier than January 1, 2000.
155
If you're perusing this documentation for the first time, try first
156
reading the discussion at just the top-level nodes in order to get a
157
general sense of what's here. Lower-level nodes have many details, but
158
most of them are unnecessary for the casual user.
160
One can obtained a TeX'd copy of the present documention by saying
161
@samp{texi2dvi fweb.texi}, assuming that the relevant @code{texinfo}
162
macros have been installed on one's system. (@file{texinfo.tex} and the
163
script @code{texi2dvi} are included in the standard GNU distributions.)
166
This documentation is now accessible on the World-Wide Web from
169
@url{http://w3.pppl.gov/~krommes/fweb_toc.html}.
172
Other sources of information about @FWEB{} are the archival files of
173
the @code{fweb-users} and @code{fweb-installers} mailing lists. To
174
learn how to obtain those, see @ref{Support}.
176
If you are learning @FWEB{} for the first time, you will probably find
177
that this (unfinished) manual is not sufficiently pedagogical. For
178
background, please refer to Knuth's book cited in @ref{Intro}. You
179
should also browse through @ref{Concepts}, in particular
183
The first part of this master menu lists the major nodes in this Info
184
document. The rest of the menu lists all of the lower-level nodes in
189
* Copying:: Your rights; NO WARRANTY.
190
* Intro:: An introduction to @FWEB{}.
191
* Concepts:: General concepts of WEB programming.
192
* Files:: Files used by @FWEB{}.
193
* Starting:: Command-line syntax and options
194
* @@ commands: AT commands. @FWEB{} commands.
195
* Comments:: Commenting styles.
196
* Languages:: Languages.
197
* Macros:: Macro definitions and preprocessing.
198
* Ratfor:: RATional FORtran.
199
* Documentation:: Features and hints about working with @FWEAVE{}.
200
* Index:: The index produced by @FWEB{}.
201
* Customization:: Customizing @FWEB{}, learning about parameters, etc.
202
* Hints:: Various usage tips, etc.
203
* New features:: New features/changes in the current version.
204
* Support:: Help, bug reports, etc.
205
* Installing:: Installing @FWEB{}.
206
* Concept index:: Significant concepts.
207
* Option and command index:: Command-line options, @@ commands, etc.
208
* Parameter index:: Style-file parameters.
210
--- The Detailed Node Listing ---
212
INTRODUCTION to @FWEB{}
214
* History:: History of literate programming.
215
* Features:: Special features of @FWEB{}.
219
* Processors:: @FTANGLE{} and @FWEAVE{}.
220
* Phases:: Phases of operation of the @FWEB{} processors.
221
* Structure:: The structure of a web.
222
* Modules:: Use of named and unnamed modules.
226
* Input files:: Input files.
227
* Output files:: Output files.
228
* Change files:: Change files.
232
* Completion:: Automatic file-name completion.
236
* Syntax:: Command-line syntax.
237
* Options:: Command-line options.
241
* Negating options:: How to invert the meaning of an option.
242
* -1:: Brief debugging mode.
243
* -2:: Verbose debugging mode.
244
* -@@: -AT. Display information about control codes.
245
* -A: -A_. Turn on ASCII translations.
246
* -B: -B_. Turn off audible beeps.
247
* -b:: Number blocks.
248
* -C: -C_. Set the color mode.
249
* -c:: Set global language to C.
250
* -c++: -cpp. Set global language to C++.
251
* -D: -D_. Display information about @FWEB{}'s reserved words.
252
* -d:: Convert unnumbered `do...enddo's to Fortran--77.
253
* -E: -E_. Change the delimiter of a file-name extension.
254
* -e:: Turn on automatic file-name completion.
255
* -F: -F_. Compare output files with old versions.
256
* -f:: Turn off module references for identifiers.
257
* -H: -H_. Scan #include files to format typedef and/or class commands.
258
* -h:: Where to get help.
259
* -I: -I_. Append a directory to search list for include files.
260
* -i:: Don't print contents of @@I include files.
261
* -i!:: Don't even read @@I include files.
262
* -j:: Inhibit multiple includes of the same file.
263
* -k:: Don't recognize lower-case forms of Fortran I/O keywords.
264
* -L: -L_. Select global language.
265
* -l:: Echo the input line.
266
* -M: -M_. Set output message level.
267
* -m:: Define an @FWEB{} macro.
268
* -m4:: Understand the m4 built-in commands.
269
* -m;:: Append pseudo-semicolons to @FWEB{} macro definitions.
270
* -n:: Set global language to Fortran--77.
271
* -n9:: Set global language to Fortran--90.
272
* -n@@;: -nAT;. For Fortran, supply pseudo-semicolons automatically (default).
273
* -n;:: For Fortran, supply actual semicolons automatically.
274
* -ncolon:: In Fortran, place statement labels on separate lines.
275
* -nb:: In Fortran, number the ifs and dos.
276
* -nC:: In Fortran, ignore single-line comments ('C', 'c', or '*').
277
* -np:: Print semicolons in woven Fortran output.
278
* -n\:: In Fortran--90, free-form syntax continued with '\\'.
279
* -n&:: In Fortran--90, free-form syntax continued with '&'.
280
* -n/:: In Fortran, recognize '//' as the start of a short comment.
281
* -n!:: In Fortran, make '!' denote the start of a short comment.
282
* -n):: In Fortran, reverse array indices.
283
* -o:: Turn off @FWEAVE{}'s mechanisms for overloading operators.
284
* -q:: Don't translate Ratfor.
285
* -P: -P_. Select TeX processor.
286
* -p:: Set style parameter.
287
* -r:: Set the global language to Ratfor--77.
288
* -r9:: Set the global language to Ratfor--90.
289
* -rb:: In Ratfor, number the ifs and dos.
290
* -rg:: Set |goto| parameters.
291
* -rk:: Suppress comments about Ratfor statement translation.
292
* -rK: -rK_. Write out comments about Ratfor statement translation.
293
* -r@@;: -rAT;. Turn on Ratfor's auto-semi mode, using pseudo-semicolons.
294
* -r;:: Turn on Ratfor's auto-semi mode, using actual semicolons.
295
* -r/:: In Ratfor, recognize '//' as the start of a short comment.
296
* -r!:: In Ratfor, make '!' denote the start of a short comment.
297
* -r):: In Ratfor, reverse array indices.
298
* -s:: Print statistics about memory usage.
299
* -T: -T_. Flag-setting commands for @FTANGLE{}.
300
* -t:: Truncate identifiers.
301
* -U: -U_. Convert reserved output tokens to lower case.
302
* -u:: Undefined a predefined or command-line macro.
303
* -V: -V_. Print version number.
304
* -v:: Make all comments verbatim.
305
* -W: -W_. Flag-setting commands for @FWEAVE{}.
306
* -w:: Change name of @FWEB{}'s macro package.
307
* -X: -X_. Print selected cross-reference information.
308
* -x:: Reduce or eliminate cross-reference information.
309
* -y:: Allocate dynamic memory.
310
* -Z: -Z_. Display default values of style-file parameters.
311
* -z:: Change name of style file.
312
* -.:: Don't recognize dot constants.
313
* -\:: Explicitly escape continued strings.
314
* -(: -lp. Continue parenthesized strings with backslashes.
315
* -colon:: Set starting automatic statement number
316
* ->:: Redirect tangled output.
317
* -=:: Redirect tangled output.
318
* -#:: Don't print comments about line numbers and module names
320
* -+: -plus. Don't interpret compound assignment operators.
321
* -/:: Recognize '//' as the start of a short comment.
322
* -!:: Make '!' denoted the start of a short comment.
324
* Info options:: Information options.
326
@samp{-T}: Flag-setting options for @FTANGLE{}
328
* -TD:: Permit processing of deferred macro definitions.
329
* -Tb:: Permit built-functions such as @code{$IF} to be redefined.
330
* -Tm:: Permib user-defined macros to be redefined.
331
* -Tv:: Don't print header info at top of output.
332
* -T%:: Don't retain trailing comments.
333
* -T#:: Don't insert @samp{#line} command after @samp{@@%}.
335
@samp{-W}: Flag-setting options for @FWEAVE{}
337
* -W@@: -WAT. Set module warning flag.
338
* -W1:: Completely cross-reference single-character identifiers.
339
* -W[:: Turn on processing of bracketed array indices.
340
* -WH: -WH_. Send extra arguments to the C preprocessor.
342
Commands that inhibit printing:
344
* -Wd: -Wnoprint. Don't print @@d or @@D in woven output.
345
* -Wf: -Wnoprint. Don't print @@f.
346
* -WF: -Wnoprint. Don't print @@F.
347
* -Wl: -Wnoprint. Don't print @@l.
348
* -Wm: -Wnoprint. Don't print @@m or @@M.
349
* -Wv: -Wnoprint. Don't print @@v.
350
* -Ww: -Wnoprint. Don't print @@w or @@W.
354
* @@0: AT0. Turn off debugging.
355
* @@1: AT1. Display irreducible scraps.
356
* @@2: AT2. Display detailed scrap reductions.
358
Literal control characters:
359
* @@@@: ATAT. Insert an '@@'.
360
* @@|: AT|. Vertical bar/optional line break.
362
Beginning of section:
363
* @@ : ATspace. Begin minor section.
364
* @@*: AT*. Begin major section.
366
Beginning of code part:
367
* @@<: AT<. Begin module name.
368
* @@>: AT>. End module name.
369
* @@A: ATA_. Begin code part.
370
* @@a: ATa. Begin code part and mark next identifier.
373
* @@B: ATB_. Insert left brace; suppress default insertion of breakpoint command.
374
* @@b: ATb. Insert breakpoint command.
375
* @@c: ATc. Set language to C.
376
* @@c++: ATcpp. Set language to C++.
377
* @@D: ATD_. Define outer macro.
378
* @@d: ATd. Define outer macro and mark it.
379
* @@E: ATE_. Treat next identifier as ordinary expression.
380
* @@e: ATe. Invisible expression.
381
* @@f: ATf. Format identifier or module name.
382
* @@I: ATI_. Include a WEB file, but don't print it.
383
* @@i: ATi. Include a WEB file.
384
* @@K: ATK_. Expand global RCS-like keyword.
385
* @@k: ATk. Expand local RCS-like keyword.
386
* @@L: ATL_. Set language.
387
* @@l: ATl. Specify limbo text.
388
* @@M: ATM_. Define an @FWEB{} macro.
389
* @@m: ATm. Define a @FWEB{} macro and mark it.
390
* @@N: ATN_. Turn on language-independent mode.
391
* @@n: ATn. Set language to Fortran--77.
392
* @@n9:ATn9. Set language to Fortran--90.
393
* @@O: ATO_. Open new output file (global scope).
394
* @@o: ATo. Open new output file (local scope).
395
* @@q: ATq. Turn off or on module and line information locally.
396
* @@R: ATR_. Treat next identifier as integer-like reserved word.
397
* @@r: ATr. Set language to Ratfor--77.
398
* @@r9: ATr9. Set language to Ratfor--90.
399
* @@u: ATu. Undefine an outer macro.
400
* @@v: ATv. Overload an operator.
401
* @@W: ATW_. Overload an identifier.
402
* @@x: ATx. Terminate ignorable material.
403
* @@y: ATy. End first part of change.
404
* @@z: ATz. Begin ignorable material.
407
* @@': ATquote. Convert single character to ASCII.
408
* @@": ATdquote. Convert string to ASCII.
411
* @@[: AT[. Mark next identifier as defined in this section.
414
* @@/*: AT/*. Begin a long verbatim comment.
415
* @@//: AT//. Begin a short verbatim comment.
416
* @@%: AT%. Ignore everything to next newline.
417
* @@?: AT?. Begin a compiler directive.
418
* @@(: ATlp. Begin a meta-comment.
419
* @@): AT). End a meta-comment.
422
* @@@{: ATlb. Insert left brace; suppress newlines in pretty-printing.
425
* @@_: AT_. Force an index entry to be underlined (marked as defined).
426
* @@-: AT-. Delete index entry for following identifier.
427
* @@+: ATplus. Force index entry for following identifier.
428
* @@^: AT^. Make index entry in Roman type.
429
* @@.: ATdot. Make index entry in typewriter type.
430
* @@9: AT9. Make index entry in format controlled by `\9'.
433
* @@t: ATt. Put control text into TeX \hbox.
434
* @@=: AT=. Pass control text verbatim to the output.
437
* @@comma: ATcomma. Insert a thin space.
438
* @@/: AT/. Insert a line break, preserving indentation.
439
* @@\: ATbs. Insert a line break and backspace.
440
* @@|: AT|_. Insert optional line break in an expression.
441
* @@#: AT#. Force line break with blank line.
442
* @@~: AT~. Cancel a line break (tie adjacent lines together).
443
* @@&: AT&. Join left and right items.
445
Pseudo (invisible) operators:
446
* @@e: ATe. Invisible expression.
447
* @@;: AT;. Invisible semicolon.
448
* @@colon: ATcolon. Invisible colon.
451
* @@!: AT!. Inhibit expansion for next macro.
455
* Invisible comments:: Skipping input material.
456
* Visible comments:: Comments in code mode.
457
* Temporary comments:: Temporarily commenting out code.
459
MACROS and PREPROCESSING
461
* Outer macros:: Macros copied to beginning of output file (@@d).
462
* FWEB macros:: Macros and built-in functions expanded by @FWEB{} (@@m).
463
* Macros and formatting:: How to format macros for pretty-printing.
464
* Preprocessing:: @FWEB{}'s preprocessing language (@@#if, etc.)
468
* Macro features:: Various points about @FWEB{} macros.
469
* Tokens:: Special tokens used in @FWEB{} macros.
470
* Built-in functions:: Macro-like functions built into @FWEB{}.
471
* Debugging with macros:: Debugging glitches, and their solutions.
473
Various features of @FWEB{} macros
475
* Variable arguments:: @FWEB{} macros with variable arguments.
476
* Recursion:: @FWEB{} macros may be recursive (proceed at your own risk).
477
* Macro protection:: Protecting @FWEB{} macros against redefinition.
482
* Strings and quotes:: Quoted and non-quoted strings.
483
* Protection:: By default, built-in functions may not be redefined.
485
INDIVIDUAL BUILT-IN FUNCTIONS
487
* $A:: Convert to ASCII.
488
* $ABS:: Absolute value.
489
* $ASSERT:: Assert a condition.
490
* $AUTHOR:: RCS global keyword; see $KEYWORD.
491
* $COMMENT:: Generate a comment.
492
* $DATE:: Today's date.
493
* $DATE_TIME:: RCS global keyword; see $KEYWORD.
495
* $DECR:: Decrement a macro.
496
* $DEFINE:: Define a (deferred) macro.
497
* $DO:: Macro @b{DO} loop.
498
* $DUMPDEF:: Dump macro definitions to the terminal.
499
* $E:: Base of the natural logarithms: 2.71828...
500
* $ERROR:: Send error message to output.
501
* $EVAL:: Evaluate an expression.
502
* $EXP:: Exponential function.
503
* $GETENV:: Get value of environment variable.
504
* $HEADER:: RCS global keyword; see $KEYWORD.
505
* $HOME:: The user's home directory.
506
* $ID:: RCS global keyword; see $KEYWORD.
507
* $IF:: Two-way conditional: ``If expression is true''
508
* $IFCASE:: n-way conditional.
509
* $IFDEF:: Two-way conditional: ``If macro is defined''
510
* $IFNDEF:: Two-way conditional: ``If macro is not defined''
511
* $IFELSE:: Two-way conditional: ``If macro1 equals macro2''
512
* $INCR:: Increment a macro.
513
* $INPUT_LINE:: Line number that begins current section.
514
* $KEYWORD:: Extract text of global RCS-like keyword.
515
* $L:: Change string to lower case.
516
* $L_KEYWORD:: Extract text of local RCS-like keyword.
517
* $LANGUAGE:: Identifier for current language.
518
* $LANGUAGE_NUM:: Number of current language.
519
* $LEN:: Length of string.
520
* $LOCKER:: RCS global keyword; see $KEYWORD.
521
* $LOG:: Natural logarithm.
522
* $LOG10:: Logarithm to the base 10.
523
* $M:: Define a (deferred) macro.
524
* $MAX:: Maximum of one or more elements.
525
* $MIN:: Minimum of one or more elements.
526
* $MODULE_NAME:: Name of present @code{web} module.
527
* $MODULES:: Total number of independent modules.
528
* $NAME:: RCS global keyword; see $KEYWORD.
529
* $OUTPUT_LINE:: Current line number of tangled output.
530
* $P:: The C preprocessor symbol @code{#} (an unquoted string).
532
* $POW:: Raise to a power.
533
* $PP:: The C preprocessor symbol @code{#} (a character).
534
* $RCSFILE:: RCS global keyword; see $KEYWORD.
535
* $REVISION:: RCS global keyword; see $KEYWORD.
536
* $ROUTINE:: Current Ratfor program, function, or subroutine.
537
* $SECTION_NUM:: Number of current section.
538
* $SECTIONS:: Maximum number of sections.
539
* $SOURCE:: RCS global keyword; see $KEYWORD.
540
* $SQRT:: Square root.
541
* $STATE:: RCS global keyword; see $KEYWORD.
542
* $STRING:: Expand argument, then stringize.
544
* $TIME:: The local time.
545
* $TRANSLIT:: Transliterate a string.
546
* $U:: Change string to upper case.
547
* $UNDEF:: Undefine an @FWEB{} macro.
548
* $UNQUOTE:: Remove quotes from string (leaving an unquoted string).
549
* $UNSTRING:: Remove quotes and string delimiters from string.
550
* $VERBATIM:: (Obsolete.)
551
* $VERSION:: @FWEB{} version number.
555
* Setting the language:: Setting the language.
557
Special hints and considerations for each language.
560
* Fortran:: Fortran--77 and Fortran--90.
561
* Ratfor: Ratfor_. RATional FORtran.
563
* Verbatim:: Literal mode.
567
* Syntax: RSyntax. Ratfor syntax.
568
* Commands:: Ratfor commands.
569
* Caveats:: Nuances about @FWEB{} Ratfor.
573
* Typesetting:: Woven output; TeX vs. LaTeX, etc.
574
* Pretty-printing:: Turning ugly input into beautiful output.
578
* Output:: Structure of the TeX output from @FWEAVE{}.
579
* fwebmac.sty:: The macro package used with @FWEAVE{}.
580
* LaTeX:: Specifics of the LaTeX support.
582
The macro package @file{fwebmac.sty}
584
* User macros:: Macros defined for user convenience.
585
* Fonts:: Useful font commands.
589
* Document class:: LaTeX's document class, options, etc.
590
* REVTeX:: The REV@TeX{} scientific macro package.
591
* Packages:: Special FWEB-related La@TeX{}2e packages.
592
* Sections:: Section numbering, spacing, etc.
593
* Index:LIndex. Technical details about multi-columns and the Index.
594
* Table of Contents:: The Table of Contents.
595
* Customizing LaTeX:: Conditional flags, etc.
596
* Inserting woven code:: How to insert @FWEAVE{}'s output into a La@TeX{} document.
598
La@TeX{} packages related to @FWEB{}
600
* fwebinsert:Inserting woven code. Enable insertion of woven code into a La@TeX{} document.
601
* fwebnum:Numbering. Number each section in ascending order.
602
* idxmerge:Merging indexes. Merge several stand-alone indexes.
604
Customizing La@TeX{}'s output
606
* Page references:: Indexing by page numbers.
607
* Headers:: The content of page headers.
608
* Numbering:: Various section numbering schemes.
612
* Alternatives:: Alternatives for various input tokens.
613
* Pseudo-operators:: Invisible parts of speech.
614
* Overloading:: Changing the appearance of various quantities.
618
* Internal index:: The self-contained index produced by @FWEB{}.
619
* Using makeindex:: Writing index data for use by @code{makeindex}.
620
* Merging indexes:: Using the @code{idxmerge} utility to merge indexes.
624
* Environment variables:: Environment or logical variables.
625
* Initialization:: Initialization file.
626
* Memory allocation:: Dynamic memory allocation.
627
* Style:: Style file.
631
* -yb:: Maximum bytes for identifiers, index entries, and module names.
632
* -ybs:: Size of the change buffer.
633
* -ycb:: Size of line buffer for C output.
634
* -ycf:: A Ratfor buffer.
635
* -ycg:: Another Ratfor buffer.
636
* -yd:: Increment for expanding the dots table.
637
* -ydt:: Maximum number of deferred macro tokens.
638
* -ydx:: Maximum number of deferred macro texts.
639
* -yid:: Maximum depth of file inclusion.
640
* -yif:: Maximum number of unique include-file names.
641
* -ykt:: Stack size for @FTANGLE{}.
642
* -ykw:: Stack size for @FWEAVE{}.
643
* -yll:: Line length for @FWEAVE{}'s output.
644
* -yln:: Maximum length of module names or strings.
645
* -ylb:: Maximum number of nested loops in Ratfor.
646
* -ylx:: Maximum length of expressions that can be expanded with
647
the post-increment operators of Fortran or Ratfor.
648
* -ym:: Maximum number of sections.
649
* -yma:: Maximum number of arguments to @FWEB{} macros.
650
* -ymb:: Size of the buffer for expanding @FWEB{} macros.
651
* -yn:: Maximum number of identifiers and module names.
652
* -ynf:: Maximum number of open output files.
653
* -yop:: Maximum number of entries in the table for operator
655
* -yr:: Maximum number of cross-references.
656
* -ys:: Maximum number of scraps.
657
* -ysb:: Size of style-file input-line buffer.
658
* -ytt:: Maximum number of tokens that @FTANGLE{} can process.
659
* -ytw:: Maximum number of tokens in the current section being
660
processed by @FWEAVE{}.
661
* -yx:: Maximum number of texts.
662
* -yxb:: Size of line buffer for @TeX{} output.
666
* Index params:: Customizing the Index.
667
* Module params:: Customizing the list of sections.
668
* Contents params:: Customizing the Table of Contents.
669
* Subscript params:: Customizing subscripting for cross-references.
670
* Fwebmac params:: Customizing behavior of @FWEB{}'s macros.
671
* Completion params:: Automatic selection of file extensions, etc.
672
* Control-code mappings:: Remapping @FWEB{}'s control codes (danger)!
673
* Color:: @FWEB{}'s color output.
674
* Miscellaneous params:: Other customizations.
676
Customizing @FWEAVE{}'s index
678
* delim_0: S_delim. Insert after identifier in index entry.
679
* delim_n: S_delim. Insert between section numbers in index entry.
681
* encap.infix: S_encap. Start the section number.
682
* encap.prefix: S_encap. @TeX{} macro to begin a section number.
683
* encap.suffix: S_encap. Ends the section number.
687
* index.collate: S_index. Collating sequence for the Index.
688
* index.postamble: S_index. @TeX{} material to end the Index.
689
* index.preamble: S_index. @TeX{} material to begin the Index.
690
* index.tex: S_index. Name of file holding the Index.
692
* item_0:: @TeX{} command to begin an index entry.
694
* language.prefix: S_language. Begin a language entry in the Index.
695
* language.suffix: S_language. End a language entry in the Index.
697
* lethead.prefix: S_lethead. Begin a letter group.
698
* lethead.suffix: S_lethead. End a letter group.
699
* lethead.flag: S_lethead. Control beginning of letter group.
701
* name: S_index. Name of index.
703
* underline.prefix: S_underline. Begin an underlined index entry.
704
* underline.suffix: S_underline. End an underlined index entry.
706
Customizing the module list
708
* modules.info: S_modules.
709
* modules.postamble: S_modules. @TeX{} commands to end module list.
710
* modules.preamble: S_modules. @TeX{} commands to begin module list.
711
* modules.tex: S_modules. Name of file containing list of modules.
713
Customizing the Table of Contents
715
* contents.postamble: S_contents. @TeX{} commands to end Table of Contents.
716
* contents.preamble: S_contents. @TeX{} commands to begin Table of Contents.
717
* contents.tex: S_contents. Name of contents file.
719
Customizing cross-reference subscripts
721
* mark_defined.generic_name: S_mark_defined.
722
* mark_defined.fcn_name: S_mark_defined.
723
* mark_defined.WEB_macro: S_mark_defined.
724
* mark_defined.outer_macro: S_mark_defined.
725
* mark_defined.exp_type: S_mark_defined.
726
* mark_defined.typedef_name: S_mark_defined.
728
Customizing the behavior of @file{fwebmac.sty} macros
730
* doc.preamble: S_LaTeX. Preamble for entire document.
731
* doc.postamble: S_LaTeX. Postamble for entire document.
733
* format_IDENTIFIER: S_format. Macro name for typesetting upper-case identifiers.
734
* format.reserved: S_format. Macro for reserved words.
735
* format.short_identifier: S_format. Macro for single-character identifiers.
736
* format_OUTER_MACRO: S_format. Macro for upper-case @samp{@@d} identifiers.
737
* format.outer_macro: S_format. Macro for lower-case @samp{@@d} identifiers.
738
* format_WEB_MACRO: S_format. Macro for upper-case @samp{@@m} identifiers.
739
* format.WEB_macro: S_format. Macro for lower-case @samp{@@m} identifiers.
740
* format.intrinsic: S_format. Macro for intrinsic library functions.
741
* format_KEYWORD: S_format. Macro for upper-case keywords.
742
* format.keyword: S_format. Macro for lower-case keywords.
743
* format.typewriter: S_format. Macro for strings.
744
* format.wildcard: S_format. Macro for user-defined index entries.
746
* indent.TeX: S_indent. Paragraph indentation for @TeX{} part.
747
* indent.code: S_indent. Paragraph indentation for code part.
749
* LaTeX.class: S_LaTeX. Specify the document class.
750
* LaTeX.class.options: S_LaTeX. Specify options for document class.
751
* LaTeX.package: S_LaTeX. Specify user package(s)
752
* LATeX.package.options: S_LaTeX. Specify options for user package(s).
754
Miscellaneous style-file parameters
756
* ASCII_fcn:: Routine for converting strings to ASCII.
757
* cchar:: Continuation character for Fortran.
758
* cdir_start:: @samp{@?} translates to this.
759
* line_char:: Comment char. for @FTANGLE{}'s @code{line} cmds.
760
* line_length: S_line_length.
762
* paren.len: -n). Length of one parenthesized index for @samp{-n)}.
763
* paren.levels: -n). Number of nested parentheses for @samp{-n)}.
764
* paren.num: -n). Number of permitted indices for @samp{-n)}.
766
* meta.top: S_meta_t. Material to precede tangled meta-comment.
767
* meta.prefix: S_meta_t. Begins each line of meta-comment.
768
* meta.bottom: S_meta_t. Material that follows the meta-comment.
770
* meta.top.hdr: S_meta_t. Like meta.top, but for info at start of file.
771
* meta.prefix.hdr: S_meta_t. As above.
772
* meta.bottom.hdr: S_meta_t. As above.
774
* outer.def: S_outer. @FTANGLE{} converts @samp{@@d} to this.
775
* outer.undef: S_outer. @FTANGLE{} converts @samp{@@u} to this.
777
* protect:: Protection character to end a continued line.
778
* suffix:: Suffixes for output files.
782
* macros:: Default name of the macro package to be
783
read in by @FWEAVE{}.
784
* limbo.begin: S_limbo. Default material to begin the limbo section.
785
* limbo.end: S_limbo. Default material to end the limbo section.
787
* meta.code.begin: S_meta_w.
788
* meta.code.end: S_meta_w.
790
* meta.TeX.begin: S_meta_w. @TeX{} material to begin @FWEAVE{}'s
791
output of a meta-comment.
792
* meta.TeX.end: S_meta_w. As above, but end the meta-comment.
794
* preamble.named: S_preamble. @TeX{} material to begin named section.
795
* preamble.unnamed: S_preamble. @TeX{} material to begin unnamed section.
799
* dot_constant.begin: S_dot_constant. Beginning character for dot constant.
800
* dot_constant.end: S_dot_constant. Ending character for dot constant.
802
* null_file:: Name of the null file.
804
Automatic file name completion
806
* Ext.web: S_Ext. Extensions for the web file.
807
* Ext.ch: S_Ext. Extensions for the change file.
808
* Ext.hweb: S_Ext. Extensions for include files.
809
* Ext.hch: S_Ext. Extensions for change files associated with
812
USAGE TIPS and SUGGESTIONS
814
* Converting:: Converting an existing code to @FWEB{}.
815
* Tips:: Usage tips and suggestions.
816
* Science:: Useful features for scientific programming.
827
@node Copying, Intro, Top, Top
828
@comment node-name, next, previous, up
830
@unnumbered @FWEB{} Copying Permissions
832
@FWEB{} is ``free.'' This means that everyone is free to use them and free to
833
redistribute them on a free basis. @FWEB{} operates under the terms
834
of the GNU General Public License; see, for example,
835
@ref{Distrib, , Distribution, emacs, The GNU Emacs Manual}.
837
Although it is hoped that @FWEB{} will be useful,
838
there is @emph{ABSOLUTELY NO WARRANTY}.
840
@node Intro, Concepts, Copying, Top
841
@comment node-name, next, previous, up
843
@chapter INTRODUCTION to @FWEB{}
845
@cindex Literate programming
846
@FWEB{} is a system for @dfn{literate programming}. It enables one to
847
maintain both documentation and source code in a single place (the
848
@code{web} file), and to explain the code in terms of a @dfn{web} of
849
very small fragments. Because @FWEB{} is intimately integrated with
850
@TeX{}, one gains many advantages such as book-quality typesetting and
851
extensive cross-referencing facilities. A simple example program is
852
described in @ref{Structure}.
855
@FWEB{} was originally intended for scientific programming (the 'F'
856
stands for @sc{Fortran}), and is in wide use in that arena; however, it
857
has much broader applicability. It is an extension of Knuth's WEB
858
system that handles the specific languages C, C++, Fortran (both F77 and
859
F90), @sc{Ratfor}, and (in a limited fashion) @TeX{} itself. It also
860
attempts to implement a WYSIWYG language-independent mode as well as a
861
(closely-related but not identical) verbatim `language'. @emph{The
862
language-independent features are highly experimental} and are not
865
The origins and philosophy of literate programming are described in the
866
very enjoyable book by D. E. Knuth, @cite{Literate Programming} (Center for
867
the Study of Language and Information, Leland Stanford Junior
872
was written in Pascal, and it formatted Pascal code.
873
Silvio Levy introduced @sc{Cweb},
875
a WEB system written in C for C. @FWEB{}
878
(by now, substantial) modification of version 0.5 of @sc{Cweb} that was
879
graciously supplied by Levy. It also borrows various ideas from the
880
works of Ramsey and Briggs on language-independent webs.
882
The original WEB's worked with Plain @TeX{}. More recently, many users
883
have turned to Lamport's La@TeX{} because of its ease of use and
884
higher-level features. Excellent and extensive development of La@TeX{} has been
885
accomplished, as described by Goossens, Mittelbach, and Samarin, @cite{The
886
La@TeX{} Companion} (Addison--Wesley, Reading, MA, 1994).
887
The present version of @FWEB{} is intended to be used with
888
La@TeX{} (La@TeX{}2e, in particular); Plain @TeX{} is no longer supported.
891
* History:: History of literate programming.
892
* Features:: Special features of @FWEB{}.
895
@node History, Features, Intro, Intro
896
@comment node-name, next, previous, up
898
@section History of WEB and literate programming
899
(To be completed; see Knuth's book, cited in @ref{Intro}.)
901
@node Features, , History, Intro
902
@comment node-name, next, previous, up
904
@section Features of @FWEB{}
906
@FWEB{} is distinguished from its relatives in several respects:
911
@FWEB{} introduces the concept of a @emph{current language}
912
(@pxref{Languages}), so more than one compiler language can be processed
913
in a single @FWEB{} run. For example, mixtures of C++ and
914
@sc{Fortran} are common in modern scientific programming.
917
@FWEB{} understands the syntaxes of several of the more important
918
compiler languages: C, C++, @sc{Fortran} (both F77 and F90),
919
@sc{Ratfor}, and @TeX{}. For other languages, @FWEB{} can work in a
920
language-independent mode that essentially weaves and tangles the source
921
code verbatim, but still provides the user with the powerful @sc{web}
922
features related to @sc{TeX} documentation, module names, macro
926
@FWEB{} contains a built-in @sc{Ratfor} (@sc{RATional} @sc{FORtran})
927
translator. @xref{Ratfor}.
930
@FWEB{} has a built-in C-like @emph{macro preprocessor}. This is
931
especially useful for @sc{Fortran} and @sc{Ratfor}, which have no predefined
932
preprocessor. However, certain extensions such as variable numbers of arguments
933
make the @FWEB{} preprocessor sometimes useful even for C and C++.
934
@xref{Macros} and @ref{Preprocessing}.
937
Many aspects of @FWEB{}'s behavior, default strings, etc. can be
938
customized by means of setting parameters in a @code{makeindex}-like
939
@emph{style file} (by default, @file{fweb.sty}). @xref{Style}.
944
@node Concepts, Files, Intro, Top
945
@comment node-name, next, previous, up
947
@chapter WEB CONCEPTS
949
The principle concepts of @sc{WEB} programming are laid out in Knuth's book,
950
the reference to which was given in @ref{Intro}. @FWEB{} follows most
951
conventions introduced by @sc{web} and @sc{Cweb}, except that the names
952
of some commands have been changed for consistency, symmetry, and/or
956
* Processors:: @FTANGLE{} and @FWEAVE{}.
957
* Phases:: Phases of operation of the @FWEB{} processors.
958
* Structure:: The structure of a web.
959
* Modules:: Use of named and unnamed modules.
962
@node Processors, Phases, Concepts, Concepts
963
@comment node-name, next, previous, up
965
@section The @FWEB{} processors: @FWEAVE{} and @FTANGLE{}
967
@cindex Processors, @FWEB{}
968
Following Knuth's original design, @FWEB{} consists of two processors,
969
@FTANGLE{} and @FWEAVE{}. Both operate on a single source file, say
970
@file{test.web}. @FTANGLE{} produces compilable code, say @file{test.c},
971
whereas @FWEAVE{} produces a @TeX{} file, @file{test.tex}, that can
972
(in principle) be processed with either @TeX{} or La@TeX{}. (If a file
973
@file{test.tex} already exists, @FWEAVE{} will ask for confirmation
974
before overwriting it if it does not think that the file was created by
975
a previous run of @FWEAVE{}.)
977
The output file produced by @FTANGLE{} is not intended for human eyes
978
(or for editors!); it is for compiling only. All changes to the code
979
should be made to the @code{web} file, since changes made directly to
980
the output file would be overwritten the next time the @code{web} source
981
is tangled. In an attempt to discourage messing with @FTANGLE{}'s
982
output file, all unnecessary spaces are deliberately removed.
984
@cindex Makefiles, using
985
A common way of integrating @FWEB{} into ones program development is to
986
do all compilations through a @code{make} file, into which one puts an
987
extra dependency line that explains how to produce the compilable output
988
file from the @code{web} source. For example,
998
With this approach, one is not so tempted to edit @file{test.c}.
1000
@FWEB{} development is now based on La@TeX{}; Plain @TeX{} is no longer
1001
supported. For detailed descriptions of the La@TeX{} support, see @ref{LaTeX}.
1004
@node Structure, Modules, Phases, Concepts
1005
@comment node-name, next, previous, up
1007
@section The structure of a web
1009
@cindex Web, structure
1010
An @FWEB{} source file is structured into @dfn{sections}, which
1011
correspond to logical subunits of the code (either a function or a
1012
fragment of a function).
1014
Each section consists of three @dfn{parts}, each of which is optional:
1016
@cindex Part, @TeX{}
1017
@cindex Part, definition
1027
definition part; and
1034
When @FTANGLE{} outputs code, it can combine
1035
the code parts of (possibly noncontiguous) sections into
1036
larger units called @dfn{modules}, as explained in @ref{Modules}.
1038
With the aid of sections, one's possibly huge and logically complex code
1039
can be broken down into bite-sized pieces, each one easily
1040
comprehensible. Since sections may correspond to only a small part of a
1041
function or subroutine, 1000-line main programs (they still exist!)
1042
should become a thing of the past.
1044
Since sections can be combined into modules, there is no
1045
need for sections that must be physically contiguous in the output file
1046
to be contiguous in the source file. This allows for great flexibility
1047
in structuring the documentation of the code.
1049
@subsubsection A simple example
1051
@cindex Example, of @FWEB{} file
1052
A simple example of an @FWEB{} source file consisting of three sections is as
1057
@@n/ % Set FWEB language to Fortran, and recognize short // comments.
1059
\Title@{example.web@} % \Title is an FWEB TeX macro.
1060
\author@{J. A. Krommes@} % \author is a LaTeX macro.
1063
This code is intended to illustrate the use of the |write| statement.
1064
It also provides a simple example of the \FWEB\ macro preprocessor.
1066
@@m A_CONSTANT 1.2345 // \FWEB\ preprocessor macro definition.
1073
@@ The computational routine is pretty boring.
1076
write(*,*) 'Macro value = ', A_CONSTANT
1083
Commands to @FWEB{} are begun by the @samp{@@} symbol (@pxref{AT
1084
commands}). In this example, the first command, @samp{@@n}, sets the
1085
global language to @sc{Fortran}-77. One should always begin one's code
1086
with a language-setting command.
1088
In this example, the language command is invoked with an optional
1089
argument @samp{/}. That is necessary in @sc{Fortran} in order to tell
1090
@FWEB{} to use the short (single-line) comment form beginning with
1091
@samp{//}, which otherwise conflicts with the concatenation operator.
1094
For more information about languages, see @ref{Languages}. For a fuller
1095
discussion of optional arguments, see @ref{Setting the language}.
1098
@cindex Sections, named
1099
@cindex Sections, unnamed
1100
The @samp{@@*} command begins a @dfn{major} or @dfn{named section}
1101
(corresponding to La@TeX{}'s @code{\section} command); this command is
1102
followed by the section name, terminated by a period. (The period is
1103
essential; if it is omitted, weird errors may result.) Major sections
1104
are entered in an automatically generated Table of Contents. They are
1105
also printed at the top of each output page. If the full section name
1106
is too long to so print, one can shorten it with an optional argument,
1110
@@* [INTRO]INTRODUCTION.
1113
The command @samp{@@*@i{n}} (not illustrated in the above example)
1114
begins a major (sub)section of level @i{n}, where @samp{@@*0} is
1115
equivalent to the simple @samp{@@*}, @samp{@@*1} indicates a subsection,
1116
and @samp{@@*2} indicates a subsubsection. The highest
1117
permissible major level is 2 (a subsubsection). Such subsections are
1118
also entered in the Table of Contents. For more information, see
1123
As the example demonstrates, the name of the very last section, which
1124
should be starred, should be @samp{\INDEX}. Note the backslash;
1125
@samp{\INDEX} is a @TeX{} macro. This command tells @FWEAVE{} to
1126
write out the index in a special two-column format. By default,
1127
@samp{\INDEX} expands to @samp{INDEX}, but this name can be overridden
1128
by the style-file parameter @samp{index.name} (@pxref{S_index}). For
1129
more discussion of @FWEB{}'s indexing facilities, see @ref{Index}.
1131
Minor (@dfn{unnamed}) sections are begun by @ASP{} (``at-space'');
1132
these have no associated names and are not entered into the Table of
1133
Contents. A newline counts as a space.
1135
@subsubsection The @TeX{} part
1137
@cindex Commentary, optional
1138
@cindex Part, @TeX{}
1139
All sections begin with (optional) @TeX{} commentary. That can just be
1140
straight text; to input that, no knowledge of @TeX{} is required. It
1141
can also include mathematical exposition or any of the other advanced
1142
features offered by @TeX{}.
1144
Whenever @FWEB{} is in @TeX{} mode, one can temporarily shift into @dfn{code mode}
1146
@cindex Vertical bars
1147
@cindex Code, typesetting
1149
code within vertical bars. That code is typeset just like code in the
1150
code part (see below), except that newlines are replaced by spaces.
1151
Thus, one can say things like
1154
Consider the C code fragment `|@@c for(i=0; i<10; i++)@{@}|', which ...
1157
(If the global language were C instead of @sc{Fortran}, the @samp{@@c} inside
1158
the vertical bars would not be necessary.)
1159
The ability to switch back and forth between text mode and code mode at
1160
will allows for a very convenient and flexible style of exposition.
1162
@subsubsection The definition part
1164
@cindex Part, definition
1165
The @TeX{} part is followed by an
1166
optional @dfn{definition part}. The beginning of the definition part is
1167
signaled by the appearance of any one of the commands @samp{@@d}, @samp{@@f},
1168
@samp{@@m}, @samp{@@v}, or @samp{@@W} (explained later).
1169
In the previous example, the first section has a
1170
definition part consisting of one @FWEB{} macro definition (@samp{@@m}); the
1171
second section has no definition part. For more information, see @ref{Macros}.
1173
(Failure to appreciate how easy it is to shift from part to part can get
1174
one into trouble. For example, don't write documentation such as
1175
@samp{Consider the @@m command}, because the @samp{@@m} will inadvertently
1176
terminate the documentation part and begin the definition part. What
1177
one needs to do here is to use the literal @samp{@@}, as in
1181
@subsubsection The code part
1184
An unnamed @dfn{code part} is begun by @samp{@@a}. A named code part is begun
1185
by the appearance of a module name, such as @samp{@@<Global
1186
variables@@>}, followed by an equals sign; see @ref{Modules}. Within
1187
the code part, one can place any sequence of code or code fragments
1188
(they need not be complete subroutines) that are valid for the current
1189
language. (Setting the language is described in @ref{Languages}.) The
1190
code part is terminated by the next appearance of @samp{@@*} or @ASP{}
1191
(which signal the beginning of a new section), or by the end of file.
1193
@subsubsection The limbo section
1195
@cindex Section, limbo
1196
@cindex Limbo section
1197
The portion of the source file before the first section (i.e., before
1198
the first @samp{@@*} or @ASP{}) is called @dfn{in limbo} or
1199
@dfn{the limbo section}.
1200
@cindex Limbo section
1201
The only @samp{@@} commands that are allowed in limbo (in addition to
1202
@samp{@@@@}, which stands for the character @samp{@@} and is allowed
1203
anywhere) are the language-changing commands, and one of those, such as
1204
@samp{@@c}, should appear. Other text in limbo is ignored by @FTANGLE{}
1205
and is copied by @FWEAVE{} to the @code{tex} output file. Thus, one can make or
1206
issue @TeX{} macro definitions in limbo that override the defaults in
1207
@FWEB{}'s macro package @file{fwebmac.sty}. In the above example, see
1208
the @code{\Title} command. This is defined in @file{fwebmac.sty}, and
1209
basically issues La@TeX{}'s @code{\title} command.
1211
(Another way of getting @TeX{} text into the limbo section is by means of
1212
the @samp{@@l} command; see @ref{ATl}.)
1214
La@TeX{} users may need to know that @TeX{} commands in limbo are
1215
executed @emph{after} the @samp{\begin@{document@}} command (which is
1216
issued automatically in @file{fwebmac.sty}). For more information, see
1219
@node Modules, , Structure, Concepts
1220
@comment node-name, next, previous, up
1225
The code parts of (possibly noncontiguous) sections can be combined into
1226
@dfn{modules}. For @FWEAVE{}, this is a @emph{logical} combination, for
1227
purposes of cross-referencing different pieces of the code. But for
1228
@FTANGLE{}, the combination is physical; @FTANGLE{}'s output proceeds module
1231
Modules can be @dfn{named} or @dfn{unnamed}. There is exactly one
1232
unnamed module. The fundamental operation of @FTANGLE{} is that
1235
@emph{@FTANGLE{} outputs the unnamed module}.
1238
That output goes to a compilable file with an extension appropriate to
1239
the current language.
1241
The contents of a module, either unnamed or named, consists of a mixture
1242
of code and comments. @FTANGLE{} ignores the comments; @FWEAVE{}
1243
treats them as @TeX{} text. Within any @TeX{} text, including comments,
1244
constructions delimited by @samp{|...|} signify a temporary shift into
1245
code mode. (In the present design, one cannot enclose a comment within
1248
@subsection The unnamed module
1250
The unnamed code module
1251
@cindex Unnamed module
1252
@cindex Module, unnamed
1253
is introduced by the command @samp{@@a}. Subsequent
1254
uses of @samp{@@a} accrete code to the unnamed module.
1255
To repeat, the fundamental operation of @FTANGLE{} is that
1258
@emph{@FTANGLE{} outputs the unnamed module}.
1262
Thus, there must be at least one @samp{@@a} in the source file or
1263
@FTANGLE{} will output nothing.
1265
(Why is the command called @samp{@@a}? Historically, it was the first
1266
letter of the alphabet, as befits its prominent status. However, one
1267
can also think of it as ``accrete.'')
1269
@subsection Named modules
1271
@cindex Named module
1272
@cindex Module, named
1273
Named modules represent logically-connected fragments of code.
1275
A module name is specified by the construction
1278
@@< @i{Arbitrary @TeX{} text} @@>
1282
Leading and trailing white space around the name text is ignored. The
1283
name text can include the @samp{|...|} construction, which tells
1284
@FWEAVE{} to typeset a code fragment. Thus, module names can be
1285
highly explicit---for example,
1288
@@< Check that |x >= 0.0|; |abort| if not @@>
1291
To define a named module, replace the @samp{@@a} that begins the unnamed code
1292
part of a section by @samp{@@< @i{module name} @@>=}. If one uses this
1293
construction with the same name in a later section, the effect is to
1294
@emph{accrete} to the contents of the module. Thus, a named module
1295
might ultimately consist of the code from sections 2, 5, and 9, for
1298
To use a named module, simply use the name anywhere in a code part;
1299
@FTANGLE{} will insert the contents of the module at the point where the
1300
name is used. For example,
1304
@@ Here's how to use a named module.
1307
@@< Inner loop @@>@@;
1309
@@ Here's how to define a named module. Definitions may occur after use.
1317
There are several details to notice about the above example. First,
1318
@FWEAVE{} considers module names to be simple expressions (such as the
1319
single identifier @var{x}). In C, expressions are made into complete
1320
statements (as is required in the body of a @b{for} statement) by
1321
appending a semicolon. In this case, a @emph{pseudo-semicolon}
1322
@samp{@@;} is appropriate; for more discussion of that,
1325
Second, after a name has appeared once in full, it may be
1326
abbreviated by a unique prefix followed by three periods, as demonstrated in
1327
the above example. By convention, a complete module name cannot be a
1328
subset of another. For example, @samp{@@<Test@@>} and @samp{@@<Test of
1329
graphics@@>} will elicit an error message.
1331
Commonly, the first unnamed section in the code indicates its modular
1332
structure. For example, a C code might begin with
1338
@@<Include files@@>@@;
1340
@@<Function prototypes@@>@@;
1341
@@<Global variables@@>@@;
1345
Subsequently one can accrete to the above named sections, as often as
1346
desired and in any order. This way, definitions of global variables can
1347
be introduced anywhere in the @code{web} source file as logical and pedagogical
1348
exposition dictates, but will
1349
be guaranteed to appear at the top of the code. Function prototypes
1350
could be handled this way as well; alternatively, they could all be
1351
collected into one section, perhaps at the end of the source file. (The
1352
above organization still guarantees that they will appear at the
1353
beginning of the output.) Functions could be introduced one at a time
1354
in subsequent unnamed sections.
1356
Very rarely, one might try the following construction:
1361
@@< @i{Left side} @@> = @@< @i{Right side} @@>@@;
1364
Here the intent is to construct an assignment statement. However, this
1365
will be flagged as an error because @FWEB{} thinks one is trying to
1366
define the named module @samp{@@<@i{Left side}@@>}, which one shouldn't be
1367
doing while in code mode. To make it work, just put the invisible
1368
expression @samp{@@e} (@pxref{ATe}) before the equals sign.
1370
@node Phases, Structure, Processors, Concepts
1371
@comment node-name, next, previous, up
1373
@section Phases of processing
1375
The @FWEB{} processors perform their work in several distinct phases.
1376
(The following is somewhat technical. Scan it, then use it for
1377
reference later if necessary.)
1379
@subsection The phases of @FTANGLE{}
1381
@cindex Phases, of @FTANGLE{}
1382
@FTANGLE{} has two phases. In phase 1, the source file is read; in phase
1383
2, compilable code is written out in the order specified by the web.
1385
More specifically, phase 1
1390
discards @TeX{} documentation;
1393
tokenizes the source;
1396
expands @FWEB{} preprocessor commands such as @samp{@@#if}
1397
(@pxref{Preprocessing});
1400
expands @samp{@@'...'} (@pxref{ATquote}), @samp{@@"..."} (@pxref{ATdquote}),
1401
and the binary notation @samp{0b...} (@pxref{C}) [in @sc{Fortran}, also
1402
the octal notation @samp{0...} and the hexadecimal notation @samp{0x...}];
1405
stores code text in appropriate modules;
1408
memorizes macro definitions (@samp{@@d} and @samp{@@m})
1409
(@pxref{ATd} and @ref{ATm}).
1418
outputs outer macro definitions (@samp{@@d});
1421
outputs the unnamed module (@samp{@@a});
1424
expands @FWEB{} macros (@samp{@@m});
1427
expands built-in macros such as @samp{$IF} or @samp{$PI}
1428
(@pxref{Built-in functions});
1431
translates @sc{Ratfor} statements (@pxref{Ratfor}).
1435
@subsection The phases of @FWEAVE{}
1437
@cindex Phases, of @FWEAVE{}
1438
@FWEAVE{} has three phases. In phase 1, the source file is read and
1439
cross-reference information is collected. In phase 2, the source file
1440
is read again, then pretty-printed with some cross-reference
1441
information. (For discussion of pretty-printing, see
1442
@ref{Pretty-printing}.) In phase 3, an automatically-generated Index,
1443
List of Modules, and Table of Contents are written.
1445
More specifically, phase 1
1450
tokenizes and stores identifiers and module names;
1453
collects cross-reference information (including, in C and C++, the
1454
scanning of @samp{#include} files for @samp{typedef} and/or @samp{class}
1455
declarations (@pxref{-H_});
1458
stores limbo text definitions made with @samp{@@l} (@pxref{ATl});
1461
collects information about overloaded operators (@samp{@@v}) and
1462
identifiers (@samp{@@W}). @xref{ATv} and @ref{ATW_}.
1474
outputs special @TeX{} macros for overloaded operators;
1477
copies @TeX{} material directly to output;
1480
treats material between vertical bars (@samp{|...|}) as code to be
1484
tokenizes and stores contents of each code section;
1487
analyzes code syntax and converts it to appropriate @TeX{} macros.
1491
Phase 3 writes out cross-reference information. (To eliminate some of
1492
that, see @ref{-x}.) Specifically, it
1497
writes out the Index (@file{INDEX.tex} by default, but see @ref{Output
1498
files} and @ref{Index params});
1501
writes out a list of named modules (@file{MODULES.tex} by default, but
1502
see @ref{Output files} and @ref{Module params});
1505
writes out macros to generate the Table of Contents. (Table of Contents
1506
information is actually processed by La@TeX{}, not @FWEAVE{}. The
1507
information is written to the @file{aux} file.)
1513
@node Files, Starting, Concepts, Top
1514
@comment node-name, next, previous, up
1519
@FWEB{} works with a variety of files. File names have the form
1520
@samp{[path]/root[.ext]}, where the brackets denote optional. Here the slash
1521
is called the @dfn{prefix end character}. Since this character differs
1523
operating systems, it can be changed by system installers in @file{custom.h}
1524
(@pxref{Customization}).
1525
The character that initiates the file-name extension (normally a period)
1526
can be changed with the @samp{-E} command-line option (@pxref{-E_}).
1530
* Input files:: Input files.
1531
* Output files:: Output files.
1532
* Change files:: Change files.
1535
@node Input files,Output files,Files,Files
1536
@comment node-name, next, previous, up
1538
@section Input files
1540
@cindex Files, input
1541
@FWEB{} reads files with a variety of default extensions.
1545
@file{.fweb} --- Initialization file (optional; for setting up default options
1546
used for all runs). This file is always in the user's home directory.
1547
@xref{Initialization}.
1550
@file{fweb.sty} --- Style file (optional; for customizing the behavior
1551
of a particular @code{web} file or group of files). @xref{Style}. This
1553
the directory of the @code{web} file that is being tangled unless that
1554
is changed by environment variable @code{FWEB_STYLE_DIR}. The basic
1555
name can be changed by the @samp{-z} option (@pxref{-z}).
1557
A sample @file{fweb.sty} file is provided with the @FWEB{} distribution.
1559
@file{@i{name}.web} --- Source file.
1561
@file{@i{name}.ch} --- Change file (optional; for making incremental changes
1562
to a @code{web} source file). @xref{Change files}.
1564
@file{@i{name}.hweb} --- Code included into web file with @samp{@@i}
1566
Include files are searched for in the path set by the environment
1567
variable @code{FWEB_INCLUDES} and/or the @samp{-I} option (@pxref{-I_}).
1568
If that path is empty, then the current directory is searched.
1570
@file{@i{name}.hch} --- Optional change file for include file.
1574
* Completion:: Automatic file-name completion.
1577
@node Completion,,Input files,Input files
1578
@comment node-name, next, previous, up
1580
@subsection Automatic file-name completion
1582
@cindex File-name completion
1583
@cindex Completion, automatic file-name
1584
Automatic completion of input file names is turned on by the @samp{-e}
1585
command-line option (@pxref{-e}). When this option is in effect, input
1587
include no period (have no extension) are completed automatically
1588
according to the contents of the following style-file entries:
1591
@multitable { for include file} {Style-file entry} {Default}
1593
@r{Type of file} @tab @r{Style-file entry} @tab @r{Default}
1595
@r{WEB file} @tab @code{ext.web} @tab @code{web}
1597
@r{Change file} @tab @code{ext.ch} @tab @code{ch}
1599
@r{Include file} @tab @code{ext.hweb} @tab @code{hweb}
1601
@r{Change file for include file} @tab @code{ext.hch} @tab @code{hch}
1605
More than one extension may be specified, as a space-delimited
1606
list---e.g., @samp{ext.web = "web wb"}; the first one that matches is used.
1608
@node Output files,Change files,Input files,Files
1609
@comment node-name, next, previous, up
1611
@section Output files
1613
@cindex Files, output
1614
@FWEAVE{} writes a variety of output files.
1617
@file{@i{name}.tex} --- Woven output to be processed with La@TeX{}.
1619
@file{CONTENTS.tex} --- Temporary file that accumulates
1620
Table-of-Contents information. (For La@TeX{}, the @file{aux} file is
1622
@findex CONTENTS.tex
1624
@file{INDEX.tex} --- Temporary file that stores indexing information.
1627
@file{MODULES.tex} --- Temporary files that stores module list.
1632
@cindex Output files, changing names of
1633
The names of the three temporary files can be changed with style-file
1634
parameters (@pxref{Style}). Commonly, one may put into the style file
1635
@file{fweb.sty} commands such as
1640
contents.tex "#.cts"
1644
The @samp{#} is replaced by the root name of the @code{web} file.
1646
@FTANGLE{} writes files of the form
1649
@file{@i{name}.@i{ext}} --- Compilable output file.
1652
The extensions for the compilable output file(s) have certain defaults,
1653
but can be changed by style-file parameters according to the following
1657
@multitable {Fortran-77} {style-file entry} {unix default} {non-unix default}
1659
@r{Language} @tab @r{Style-file entry} @tab @r{@sc{unix} default} @tab @r{non-@sc{unix} default}
1661
C @tab @code{suffix.C} @tab @code{c} @tab @code{c}
1663
C++ @tab @code{suffix.Cpp} @tab @code{C} @tab @code{C}
1665
Fortran--77 @tab @code{suffix.N} @tab @code{f} @tab @code{for}
1667
Fortran--90 @tab @code{suffix.N90} @tab @code{f90} @tab @code{for90}
1669
Ratfor--77 @tab @code{suffix.R} @tab @code{r} @tab @code{rat}
1671
Ratfor--90 @tab @code{suffix.R90} @tab @code{r90} @tab @code{rat90}
1673
TeX @tab @code{suffix.X} @tab @code{sty} @tab @code{sty}
1675
VERBATIM @tab @code{suffix.V} @tab @code{mk} @tab @code{mk}
1679
For example, to change the default extension for a C++ file from
1680
@samp{C} to @samp{c++}, put into @file{fweb.sty} the line
1686
@node Change files,,Output files,Files
1687
@comment node-name, next, previous, up
1689
@section Change files
1691
@cindex Files, change
1692
The primary input to the @FWEB{} processors is the @file{test.web}
1693
source file. However, a @dfn{change file} @file{test.ch} can also be
1694
specified. A change file consists of instances of the following
1699
(One or more lines of text, EXACTLY as in the web file. Copy these
1700
lines with an editor; don't type them from scratch.)
1707
The change-file mechanism allows one to insert local changes or test new
1708
code without physically modifying the original web file.
1710
To specify a change file, use its name as the second file name on the
1711
command line. The extension @samp{.ch} is assumed by default. For
1719
processes @file{test.web} with the change file @file{test.ch}.
1723
In addition to @samp{@@x}, @samp{@@y}, and @samp{@@z}, the only
1724
@samp{@@} commands allowed in a change file are language-changing
1725
commands such as @samp{@@c} and the special commands @samp{@@[} and
1726
@samp{@@]}. The command @samp{@@[} is used for column-oriented
1727
languages such as @sc{Fortran}--77 and means @dfn{switch into code
1728
mode}. Similarly, @samp{@@]} means @dfn{switch out of code mode}.
1730
All @samp{@@} commands in a change file must begin in column 1. Lines
1731
not beginning with @samp{@@} are ignored, so may be used as comments.
1732
Comments may also be included on the @samp{@@x}, @samp{@@y}, and/or
1735
@node Starting, AT commands, Files, Top
1736
@comment node-name, next, previous, up
1738
@chapter RUNNING @FWEB{}
1740
@FWEB{} has a @sc{unix}-style command-line syntax. There are many
1741
command-line options, but few or none of these are necessary for
1742
standard appplications. Proceed in blissful ignorance until you need to
1743
do something tricky, then scan the list of options to see if they can
1746
Commonly-used command-line options can be placed into the initialization
1747
file @file{.fweb} (@pxref{Options}) that resides in one's home directory.
1749
A @dfn{style file} (patterned after the utility @code{makeindex};
1750
@pxref{Style}) can be associated with each manuscript or collection of
1751
related manuscripts in order to customize their appearance. This file
1752
is read @emph{after} the command-line options are processed, except that
1753
the @samp{-p} option gets special treatment; see @ref{-p}.
1756
* Syntax:: Command-line syntax.
1757
* Options:: Command-line options.
1760
@node Syntax, Options, Starting, Starting
1761
@comment node-name, next, previous, up
1763
@section Command-line syntax
1765
The command-line syntax is
1766
@cindex Syntax, command-line
1769
@{ftangle | fweave@} [-option...] webfile[.web] [changefile[.ch]]
1772
A file name is anything that doesn't begin with a @samp{-}, except that
1773
a lone hyphen stands for the special file name
1774
@file{stdin}, which means `read from the standard input.' (This should
1775
not be used except for very special effects.)
1778
Command-line options begin with a @samp{-}. File names and options can
1779
be intermixed, or the
1780
options may appear after the file names. The first file name
1781
encountered is the web source file; the second, if it exists, is
1782
the change file (@pxref{Change files}). [When no change file is
1783
specified, @FWEB{} attempts
1784
to read from the null file (@file{/dev/null} on @sc{unix} systems). This
1785
name should be specified when @FWEB{} is installed
1786
(@pxref{Customization}), or can be set in the style file @file{fweb.sty}.
1789
The web file is shown as required since one is normally processing a
1790
source. However, some of the information options (@pxref{Info options})
1791
will work without specifying any file name. For example, one can obtain a
1792
list of all of the style-file parameters and their default values by saying
1793
@w{@samp{ftangle -Z}}.
1795
@node Options, , Syntax, Starting
1796
@comment node-name, next, previous, up
1798
@section Command-line options
1800
Command-line options may be put, one per line, into the initialization file
1801
@file{.fweb} (which is always in the user's home directory).
1802
In that file, options beginning with a hyphen are processed @emph{before}
1803
the command-line options (so command-line options can override the
1804
defaults). To force an option to be processed @emph{after} the
1805
command-line options, preface it with an ampersand
1806
rather than a hyphen; this is rarely necessary.
1808
To make sense of the plethora of options, it helps to know that options
1809
beginning with @samp{n} are related to @sc{Fortran}; those beginning
1810
with @samp{r} are related to @sc{Ratfor}. Some flags that can be set
1811
separately for those two languages also have a global option that sets the
1812
flags for both languages simultaneously; cf. @samp{-n/}, @samp{-r/}, and
1815
Some options take arguments. For example, an @FWEB{} macro can be
1816
defined from the command line by saying something like @samp{-mIBMPC=1}.
1817
Unlike many @sc{unix} utilities, @emph{no spaces are allowed between any
1818
option and its argument.} For example, if one says @samp{-m IBMPC},
1819
@FWEB{} will think that @file{IBMPC} is a file name.
1822
* Negating options:: How to invert the meaning of an option.
1823
* -1:: Brief debugging mode.
1824
* -2:: Verbose debugging mode.
1825
* -@@: -AT. Display information about control codes.
1826
* -A: -A_. Turn on ASCII translations.
1827
* -B: -B_. Turn off audible beeps.
1828
* -b:: Number blocks.
1829
* -C: -C_. Set the color mode.
1830
* -c:: Set global language to C.
1831
* -c++: -cpp. Set global language to C++.
1832
* -D: -D_. Display information about @FWEB{}'s reserved words.
1833
* -d:: Convert unnumbered `do...enddo's to Fortran--77.
1834
* -E: -E_. Change the delimiter of a file-name extension.
1835
* -e:: Turn on automatic file-name completion.
1836
* -F: -F_. Compare output files with old versions.
1837
* -f:: Turn off module references for identifiers.
1838
* -H: -H_. Scan #include files to format typedef and/or class commands.
1839
* -h:: Where to get help.
1840
* -I: -I_. Append a directory to search list for include files.
1841
* -i:: Don't print contents of @@I include files.
1842
* -i!:: Don't even read @@I include files.
1843
* -j:: Inhibit multiple includes of the same file.
1844
* -k:: Don't recognize lower-case forms of Fortran I/O keywords.
1845
* -L: -L_. Select global language.
1846
* -l:: Echo the input line.
1847
* -M: -M_. Set output message level.
1848
* -m:: Define an @FWEB{} macro.
1849
* -m4:: Understand the m4 built-in commands.
1850
* -m;:: Append pseudo-semicolons to @FWEB{} macro definitions.
1851
* -n:: Set global language to Fortran--77.
1852
* -n9:: Set global language to Fortran--90.
1853
* -n@@;: -nAT;. For Fortran, supply pseudo-semicolons automatically (default).
1854
* -n;:: For Fortran, supply actual semicolons automatically.
1855
* -ncolon:: In Fortran, place statement labels on separate lines.
1856
* -nb:: In Fortran, number the ifs and dos.
1857
* -nC:: In Fortran, ignore single-line comments ('C', 'c', or '*').
1858
* -np:: Print semicolons in woven Fortran output.
1859
* -n\:: In Fortran--90, free-form syntax continued with '\\'.
1860
* -n&:: In Fortran--90, free-form syntax continued with '&'.
1861
* -n/:: In Fortran, recognize '//' as the start of a short comment.
1862
* -n!:: In Fortran, make '!' denote the start of a short comment.
1863
* -n):: In Fortran, reverse array indices.
1864
* -o:: Turn off @FWEAVE{}'s mechanisms for overloading operators.
1865
* -q:: Don't translate Ratfor.
1866
* -P: -P_. Select TeX processor.
1867
* -p:: Set style parameter.
1868
* -r:: Set the global language to Ratfor--77.
1869
* -r9:: Set the global language to Ratfor--90.
1870
* -rb:: In Ratfor, number the ifs and dos.
1871
* -rg:: Set |goto| parameters.
1872
* -rk:: Suppress comments about Ratfor statement translation.
1873
* -rK: -rK_. Write out comments about Ratfor statement translation.
1874
* -r@@;: -rAT;. Turn on Ratfor's auto-semi mode, using pseudo-semicolons.
1875
* -r;:: Turn on Ratfor's auto-semi mode, using actual semicolons.
1876
* -r/:: In Ratfor, recognize '//' as the start of a short comment.
1877
* -r!:: In Ratfor, make '!' denote the start of a short comment.
1878
* -r):: In Ratfor, reverse array indices.
1879
* -s:: Print statistics about memory usage.
1880
* -T: -T_. Flag-setting commands for @FTANGLE{}.
1881
* -t:: Truncate identifiers.
1882
* -U: -U_. Convert reserved output tokens to lower case.
1883
* -u:: Undefined a predefined or command-line macro.
1884
* -V: -V_. Print version number.
1885
* -v:: Make all comments verbatim.
1886
* -W: -W_. Flag-setting commands for @FWEAVE{}.
1887
* -w:: Change name of @FWEB{}'s macro package.
1888
* -X: -X_. Print selected cross-reference information.
1889
* -x:: Reduce or eliminate cross-reference information.
1890
* -y:: Allocate dynamic memory.
1891
* -Z: -Z_. Display default values of style-file parameters.
1892
* -z:: Change name of style file.
1893
* -.:: Don't recognize dot constants.
1894
* -\:: Explicitly escape continued strings.
1895
* -(: -lp. Continue parenthesized strings with backslashes.
1896
* -colon:: Set starting automatic statement number
1897
* ->:: Redirect tangled output.
1898
* -=:: Redirect tangled output.
1899
* -#:: Don't print comments about line numbers and module names
1901
* -+: -plus. Don't interpret compound assignment operators.
1902
* -/:: Recognize '//' as the start of a short comment.
1903
* -!:: Make '!' denoted the start of a short comment.
1905
* Info options:: Information options.
1908
@node Negating options,-1,Options,Options
1909
@comment node-name, next, previous, up
1911
@subsection Negating options
1913
@cindex Options, negating
1914
To negate a command-line option, use an extra hyphen. For example,
1915
@samp{--v} means `Don't make all comments verbatim.' This kind of
1916
construction isn't used very often, but it is useful if an option such
1917
as @samp{-v} is turned on in the @file{.fweb} initialization file and
1918
one wishes to turn it off for just one run.
1920
@node -1,-2,Negating options,Options
1921
@comment node-name, next, previous, up
1923
@subsection @samp{-1}: Turn on brief debugging mode (@FWEAVE{})
1927
This option tells @FWEAVE{} to display irreducible scrap sequences.
1928
@cindex Scrap, irreducible
1930
A @dfn{scrap} is a part of speech. The expression @samp{x + y} consists of
1931
three scraps: @samp{x} (an expression), @samp{+} (a binary operator),
1932
and @samp{y} (an expression). @FWEAVE{} contains @dfn{production rules}
1933
such as ``replace the combination @samp{expr binop expr} with
1934
@samp{expr}.'' If all goes well, the result of @FWEAVE{}'s reduction
1935
process is ultimately just one scrap, such as @samp{function}. If
1936
@FWEAVE{} is left with more than one scrap at the end of a section,
1937
this is called an @dfn{irreducible scrap sequence}; @samp{-1} displays
1940
Irreducible scrap sequences can arise either because the programmer made
1941
a mistake or because @FWEAVE{} has not been taught the proper grammar.
1943
@cindex Output, changing appearance of
1944
While @FWEAVE{} is reducing the scraps, it appends @TeX{} macros that
1945
ultimately produce the pretty-printed output. Frequently people ask how
1946
to change the appearance of that output. Fundamentally, this is not
1947
possible at present; the grammar rules and the associated @TeX{} are
1948
hard-coded. A completely general, user-customizable scheme is very
1949
complex and daunting; it has not been attempted.
1951
This brief debugging mode can be turned on more locally by means of the
1952
@samp{@@1} command. @xref{AT1}.
1954
@node -2,-AT,-1,Options
1955
@comment node-name, next, previous, up
1957
@subsection @samp{-2}: Turn on verbose debugging mode (@FWEAVE{})
1961
This option tells @FWEAVE{} to display detailed reductions of the
1962
scraps as it does the pretty-printing. (For a discussion of scraps, see
1963
@ref{-1}.) Sometimes @FWEAVE{} fails spectacularly at
1964
pretty-printing a section, either because of a syntax error on the
1965
part of the user or because of a bug in @FWEAVE{}'s logic. This
1966
option helps one (usually the system developer!) to figure out why.
1968
This feature can be turned on more locally by means of the @samp{@@2}
1969
command. @xref{AT2}.
1971
@node -AT, -A_, -2, Options
1972
@comment node-name, next, previous, up
1974
@subsection @samp{-@@}: Display the control-code mappings
1977
@cindex Options, information
1978
This option supplies information about the @samp{@@} control codes
1979
(@pxref{AT commands}). It shows the associated style-file parameters
1980
that can be used to remap the codes (but @emph{don't do that!}), and it
1981
displays the precedence. (Some codes such as @samp{@@@@} may be used
1982
anywhere; others such as @samp{@@*} begin
1983
a new section or part of section. Codes that begin the definition part
1984
are labelled by @samp{[D]}; codes that begin the code part are labelled
1985
by @samp{[C]}; codes that begin a new section are labelled by
1988
The option produces two columns of output: the first is sorted
1989
numerically, the second alphabetically. The notation @samp{USED_BY_OTHER}
1990
means that this command is ignored by whatever processor (@FTANGLE{}
1991
or @FWEAVE{}) is currently being run, but may be used by the other
1992
processor. (For technical reasons, a very few commands such as
1993
@samp{@@i} do not show up in this output at present.)
1995
If one says just @samp{-@@}, information about all control codes is
1996
produced. Selected control codes may be queried by listing them after
1997
the @samp{-@@}. For example, to learn about the commands @samp{@@~} and
1998
@samp{@@a}, say @samp{-@@~a}. Remember to quote certain characters on
1999
@sc{unix} systems---e.g., @samp{-@@'*?'}. If a command is used by
2000
neither processor, its description will be replaced by a question mark.
2002
@node -A_,-B_,-AT,Options
2003
@comment node-name, next, previous, up
2005
@subsection @samp{-A}: Turn on ASCII translations
2008
This option is used primarily for debugging. @FWEB{} works
2009
internally with the ASCII character set. If @FWEB{} is run on a
2010
non-ASCII machine (notably IBM mainframes), translations to and from the
2011
internal ASCII are done automatically; on an ASCII machine, these
2012
translations are unnecessary and are not performed unless the @samp{-A}
2015
@node -B_, -b, -A_, Options
2016
@comment node-name, next, previous, up
2018
@subsection @samp{-B}: Turn off audible beeps
2022
@FWEB{} sometimes beeps the terminal when it encounters certain errors. The
2023
@samp{-B} option turns off the beeps, replacing them by a printed
2026
(This option is sometimes called the ``marriage-saver,'' after the
2027
situation that prompted a user's request for this feature.)
2029
@node -b,-C_,-B_,Options
2030
@comment node-name, next, previous, up
2032
@subsection @samp{-b}: Number blocks (@FWEAVE{})
2035
@cindex Numbering blocks
2036
@cindex Blocks, numbering
2037
Number @b{do} and @b{if} blocks in woven @sc{Fortran} and @sc{Ratfor} output.
2038
This feature is particularly useful in @sc{Fortran}-77 to help correlate
2039
the beginnings and ends of long blocks (but note that appropriate use of
2040
literate programming techniques can keep all of one's blocks short!).
2041
Output something like the following is produced, where the comments are
2042
inserted automatically by the @samp{-b} option:
2045
do i=1,10 // Block 1
2046
do j=1,10 // Block 2
2047
if(i==j) then // Block 3
2057
The precise form of the block comment that is emitted can be changed by
2058
redefining the macro @code{\Wblock} in @file{fwebmac.sty}.
2061
@node -C_, -c, -b, Options
2062
@comment node-name, next, previous, up
2065
@subsection @samp{-C}: Set the color mode
2067
@cindex Color, setting
2068
The option @samp{-C@var{n}} sets the color mode to @var{n}, where the
2069
color modes are, briefly,
2086
These modes, and color output in general, are described more thoroughly
2089
For obscure technical reasons, this command is processed differently
2090
than all other command-line options. In the present incomplete
2091
implementation, @emph{the color mode must be set on the command line},
2092
not in @file{.fweb}! To work around this annoyance, @sc{unix} users
2093
could alias commands such as @w{@samp{ftangle -C1}}.
2095
@node -c, -cpp, -C_, Options
2096
@comment node-name, next, previous, up
2099
@subsection @samp{-c}: Set global language to C
2101
@cindex Language, setting
2102
Usually the global language (@ref{Languages}) is set to C by means of
2103
the command @samp{@@c} in limbo, rather than using @samp{-c} on the
2104
command line. However, one may need to use the command-line option
2105
@samp{-c} if a subsequent command-line option is language-dependent.
2106
See, for example, the discussion of the option @samp{-D} in @ref{-D_}.
2108
@node -cpp, -D_, -c, Options
2109
@comment node-name, next, previous, up
2111
@subsection @samp{-c++}: Set global language to C++
2114
For more information, see the discussion of @samp{-c} in @ref{-c}.
2116
@node -D_, -d, -cpp, Options
2117
@comment node-name, next, previous, up
2119
@subsection @samp{-D}: Display reserved words
2122
@cindex Options, information
2123
@cindex Reserved words
2124
@cindex Words, reserved
2125
@cindex Intrinsic functions
2126
@cindex Functions, intrinsic
2127
@cindex Keywords, I/O
2128
@cindex I/O keywords
2129
This information option displays the list of reserved words for the
2130
language currently in force. (For the purposes of this option,
2131
`reserved words' include ``true'' reserved words such as @samp{int};
2132
they also include the names of intrinsic functions such as @samp{sin}
2133
and, for @sc{Fortran} and @sc{Ratfor}, I/O keywords such as
2134
@samp{IOSTAT}.) Thus, to see the reserved words for @sc{Ratfor}--90,
2142
(For this option one must set the language on the command line, because
2143
the @samp{-D} option is processed before the limbo section of the web file is
2146
If one says @samp{-Dabc}, one will get just the reserved words that begin with
2149
If one says @samp{-D*}, one will get all reserved words for all languages.
2151
The @samp{-D} may be followed by a list of one or more optional letters
2152
enclosed in square brackets. (For @sc{unix} systems, don't forget to
2153
quote the brackets, as they mean something special to the shell.) The
2154
letters represent which kind of reserved word to display; they may be
2155
@samp{i} (`intrinsic'), @samp{k} (`keyword'), or @samp{r} (`reserved').
2156
Thus, to see a list of the @sc{Fortran} keywords, say @samp{-D[k]}. To
2157
see a list of the intrinsic functions for C++ that begin with @samp{s},
2158
say @samp{-Lc++ -D[i]s}.
2160
@node -d,-E_,-D_,Options
2161
@comment node-name, next, previous, up
2163
@subsection @samp{-d}: Convert do...enddo
2166
@emph{(This option is obsolete.)}
2168
@node -E_,-e,-d,Options
2169
@comment node-name, next, previous, up
2171
@subsection @samp{-E}: Change the delimiter of a file-name extension
2174
The standard delimiter for file-name extensions is a period, as in
2175
@file{test.web}. To change this character to a comma, for example, say
2176
@samp{-E,}. This feature is required by at least one perverse system.
2178
@node -e,-F_,-E_,Options
2179
@comment node-name, next, previous, up
2181
@subsection @samp{-e}: Turn on automatic file-name completion
2184
When the @samp{-e} option is in effect, @FWEB{} attempts to be helpful in
2185
figuring out what file name one intends. For any input file name that
2186
has no extension (no embedded period), @FWEB{} completes the name by adding
2187
the extension contained in the style-file parameter listed in the
2191
@r{Type of file} @r{Style-file entry} @r{Default}
2192
WEB file @code{ext.web} @code{web}
2193
Change file @code{ext.ch} @code{ch}
2194
Include file @code{ext.hweb} @code{hweb}
2196
for include file @code{ext.hch} @code{hch}
2200
More than one extension may be specified, as a space-delimited
2201
list---e.g., @samp{ext.web = "web wb"}; the first one that matches is used.
2203
@node -F_,-f,-e,Options
2204
@comment node-name, next, previous, up
2206
@subsection @samp{-F}: Compare output files with old versions (@FTANGLE{})
2209
When the @samp{-F} option is in effect, @FTANGLE{} writes its output
2210
to a temporary file (or files) instead of to its ultimate
2211
destination such as @file{test.c} and/or @file{test.f}. After all
2212
output is written, the temporary files are compared with the old version
2213
of the files, if they exist. If the files are identical, the
2214
appropriate temporary file is deleted; otherwise, the temporary file is
2215
renamed, effectively overwriting the old version. This feature avoids
2216
updating the time stamp on the file unnecessarily, so a @code{make} file won't
2217
recompile the output unless it really has to.
2219
Note that with this option in effect, if one uses the @sc{unix} utility
2220
@code{touch} to force processing of a group of files, but the @code{web}
2221
sources are never changed, the @code{make} file will continue to tangle
2222
the sources no matter how many times it is run, since @FTANGLE{} will
2223
never update the time stamp on the files. This is harmless, but
2224
annoying. To get things back in sync, do a run without the @samp{-F}.
2226
The location of the temporary file as well as details of the renaming
2227
procedure are determined by the automatic configuration script
2228
@code{./configure} during
2229
installation of the processors. The script first looks for
2230
the (non-ANSI) function @code{tempnam}.
2232
If it finds it, it uses it to place
2233
the temporary file in the directory that @FWEB{} would normally use for
2234
output in the absence of the @samp{-F} option. (That is usually the current
2235
directory.) If @code{tempnam} is not available, the ANSI routine
2236
@code{tmpnam} is used.
2238
That places the temporary file in a directory
2239
determined by the system.
2241
To implement the renaming, the @code{rename} function is used. That may fail
2242
if @code{tmpnam} placed the temporary file on a different device. If so, an
2243
attempt is made to force the rename by using the @code{system} routine to
2244
issue a @code{mv} command. Terminal output indicates the progress of the
2245
renaming. An asterisk following an output file name indicates that
2246
@code{rename} did not succeed, but the @code{mv} command did.
2248
Some of the above-mentioned file names and system commands are
2249
system-dependent; see @ref{Customization}.
2251
@node -f,-H_,-F_,Options
2252
@comment node-name, next, previous, up
2254
@subsection @samp{-f}: Turn off module references for identifiers (@FWEAVE{})
2257
In an attempt to be helpful, @FWEAVE{} appends subscripts to many
2258
identifiers indicating in which section they are first defined
2259
(@pxref{Subscript params}). Sometimes these result in output that is
2260
too cluttered and confusing. The @samp{-f} option turns off the
2261
subscripting operations.
2263
@node -H_,-h,-f,Options
2264
@comment node-name, next, previous, up
2266
@subsection @samp{-H}: Scan C/C++ include files (@FWEAVE{})
2272
@cindex Include files, scanning
2273
For C or C++, the @samp{-H} option tells @FWEAVE{} to do a phase-1 scan
2274
of @code{#include} files for @samp{typedef} and/or @samp{class}
2275
declarations. This removes the necessity of including many redundant
2276
@samp{@@f} format statements (@pxref{ATf}), which would otherwise be
2277
necessary in order that the code be pretty-printed correctly. For
2278
example, if one uses the @samp{-H} option with the code
2283
#include <Complex.h>
2287
the identifier @b{Complex} will be properly formatted as a reserved
2288
word (in boldface), as though one had said @samp{@@f Complex int}.
2290
In addition to the basic @samp{-H}, there are several more detailed
2296
Make index entries only for double-quoted include files.
2298
Make index entries for all include files.
2300
Retain temporary files generated by the preprocessor.
2304
By default, index entries are not made for variables that are read
2305
during such scans. If one says @samp{-Hx}, index entries will be made
2306
only for include files whose names are enclosed in double quotes rather
2307
than angle brackets, such as @samp{#include "myheader.h"}
2308
(usually these are defined by the user and reside in the local
2309
directory). If one says @samp{-HX}, index entries will be made for all
2310
include files. This can generate many entries, since system header
2311
files may be complicated and may include other files as well.
2313
This command is implemented as follows. When @FWEAVE{} reads an
2314
@code{#include} statement, it issues a @code{system} command to run the
2315
C preprocessor on the included file. Output from the preprocessor is
2316
written to a temporary file, which @FWEAVE{} scans.
2318
By default, the C preprocessor will look in certain default paths for
2319
the included files. To add to those defaults, use one or more @samp{-I}
2320
options @emph{after} the @samp{-H}. These colon-delimited lists are
2321
concatenated to the contents of the environment variable
2322
@code{FWEB_HDR_INCLUDES}, if that is defined. The entire list is then
2323
passed as multiple @samp{-I} options to the preprocessor.
2325
This command, new with version 1.53, is @emph{highly experimental} and
2326
incomplete. The installation script attempts to determine what command
2327
to use to run the preprocessor, but that is not guaranteed to work in
2328
general. @samp{-H} has been tested only with @code{gcc}.
2330
To send arguments to the C preprocessor, see @ref{-WH_}.
2332
The @samp{-H} mechanism uses temporary files to do its work. By
2333
default, those are deleted after use. However, for debugging purposes,
2334
one can force those to be retained by saying @samp{-Hr}. That option
2335
also has the side effect of displaying the actual command line that was
2336
sent to the preprocessor.
2338
@node -h,-I_,-H_,Options
2339
@comment node-name, next, previous, up
2341
@subsection @samp{-h}: Get help
2344
If just @samp{-h} is typed, a message is printed saying where further
2345
help is available. It refers one to the various information options
2346
(@pxref{Info options}) and the on-line documentation
2347
(@pxref{Support}). If the stand-alone @code{info} program (the GNU
2348
hypertext browser) is installed, one can enter
2349
@samp{info FWEB} at this time by typing @samp{?} or a space-separated
2350
list of @FWEB{} menu items such as @samp{Macros FWEB built-in $PI}.
2351
In fact, since @samp{$PI} appears in the detailed node listing, one can
2352
simply type @samp{$PI}. More generally, one can type anything that
2353
@code{info} accepts on its command line (the option @samp{-f FWEB} is
2356
One can bypass the printed message and directly enter @code{info} by
2357
specifying the @code{info} arguments as arguments to @samp{-h}. For
2358
example, on a @sc{unix} system, one could type @samp{-h'\$PI'}. Here
2359
the dollar sign must be escaped because it has special significance to
2360
the shell, and the quotes are necessary in order to preserve that escape
2361
character as the argument is supplied to @code{info}. To get to the
2362
top-level @FWEB{} info directory, type
2363
@samp{-h.} or @samp{-h'?'}.
2365
@node -I_,-i,-h,Options
2366
@comment node-name, next, previous, up
2368
@subsection @samp{-I}: Append to search list for include files
2371
@cindex Include files, finding
2372
The fundamental search list for @dfn{include files} (read in via @samp{@@i} or
2373
@samp{@@I}) is defined by the environment variable @code{FWEB_INCLUDES},
2374
which is a colon-delimited list such as
2377
setenv FWEB_INCLUDES .:/usr/fweb:/other/stuff
2381
The @samp{-I} option appends to this list.
2383
For information about include files, see @ref{ATi}.
2385
@node -i,-i!,-I_,Options
2386
@comment node-name, next, previous, up
2388
@subsection @samp{-i}: Don't print @samp{@@I} include files (@FWEAVE{})
2392
@cindex Include files, skipping
2393
@cindex Include files, indexing
2394
If a web file is included via @samp{@@I} (@pxref{ATI_}),
2402
then the @samp{-i} option means to read and process the web file, but don't
2403
print its contents. This option is often used for large files of macro
2404
definitions, formats, or @b{typedef} statements that must be included at the
2405
beginning of even very short web files; it clutters things up to print
2406
such header files all of the time. (C and C++ programmers will find that the
2407
@samp{-H} option substantially reduces the need to include such header
2408
files; see @ref{-H_}.)
2410
Note that files included via @samp{@@i} (lower case) do not respond to
2411
@samp{-i} or @samp{-i!}.
2413
By default, identifiers that are referenced in non-printed include files
2414
are not cross-referenced or indexed in any way. To force them to be
2415
cross-referenced, say @samp{-ix} instead of @samp{-i}. In the present
2416
implementation, the cross-reference information for such non-printed
2417
files is presented in the form
2418
@samp{#@i{n}}, where @i{n} is the integer section number. (The La@TeX{}
2419
section label is undefined for sections in non-printed files.)
2421
The option @samp{-i!} means skip the include files completely. This is
2422
usually not very useful.
2424
@node -i!,-j,-i,Options
2425
@comment node-name, next, previous, up
2427
@subsection @samp{-i!}: Don't read @samp{@@I} include files
2429
If a web file is included via @samp{@@I}, for example
2436
then the @samp{-i!} option means to ignore such files completely. This option
2437
is seldom useful; the @samp{-i} option (@pxref{-i}) is more often used.
2439
@node -j,-k,-i!,Options
2440
@comment node-name, next, previous, up
2442
@subsection @samp{-j}: Inhibit multiple includes
2445
@cindex Include files, inhibiting
2446
File inclusion via @FWEB{}'s @samp{@@i} command suffers from a design
2447
deficiency: they cannot be inhibited by means of @FWEB{}'s
2448
preprocessor commands. (The reason is that @samp{@@i} is processed very
2449
early in the input stage, before tokenization. This design decision was
2450
inherited from @sc{Cweb}, and is very difficult to change.) A
2451
particularly annoying situation arises when the same file is included
2452
multiple times; various array space may be eaten up unnecessarily. The
2453
@samp{-j} option inhibits such multiple includes.
2455
@node -k,-L_,-j,Options
2456
@comment node-name, next, previous, up
2458
@subsection @samp{-k}: Don't recognize lower-case forms of keywords
2461
By definition, in @sc{Fortran} and @sc{Ratfor}, a keyword is one of the
2462
parameters such as @code{IOSTAT} used in the parameter list of an I/O
2463
statement. For example,
2466
open(21, FILE=file_name, STATUS='old', IOSTAT=io_flag)
2469
Such keywords are typeset in @code{typewriter type} to better highlight them.
2470
In @sc{Fortran}, these keywords are case-insensitive. However,
2471
note that certain of the lower-case forms---in particular, @samp{end},
2472
@samp{read}, and @samp{write}---have other special meanings, and one can
2473
in principle use any of these keywords as ordinary variables in other parts of
2474
the code; however, @FWEB{} identifiers can have just one meaning
2475
throughout the code. By default, the lower-case forms are also
2476
recognized as keywords (except for the three special identifiers just
2477
mentioned), so one shouldn't use those as regular variables. To cause
2478
only the upper-case forms to be recognized, use the @samp{-k} option.
2480
@node -L_,-l,-k,Options
2481
@comment node-name, next, previous, up
2483
@subsection @samp{-L}: Select global language
2486
To select a global language from the command line, say @samp{-L@i{l}},
2487
where @i{l} is one of @code{@r{@{}c,c++,n,n9,r,r9,v,x@r{@}}}. @xref{Languages}.
2489
Usually, the global language is set via an @samp{@@} command in limbo,
2490
not on the command line. However, one may need to use a command-line
2491
option such as @samp{-L_} if a subsequent command-line option is
2492
language-dependent. See, for example, the discussion of the option
2493
@samp{-D} in @ref{-D_}.
2495
@node -l,-M_,-L_,Options
2496
@comment node-name, next, previous, up
2498
@subsection @samp{-l}: Echo input line
2501
The option @samp{-l@i{[mmm[:nnn]]}} echoes the input lines constructed
2503
driver between lines @i{mmm} and @i{nnn}. Missing @i{nnn} means echo to
2504
the end of file. Missing @i{mmm} means echo from the beginning.
2506
This option is useful as a debugging tool (usually by the system
2507
developer). It is often used to verify that the input driver is
2508
inserting semicolons correctly. For @sc{Fortran}--77, it is also useful to
2509
verify that comments are being processed correctly.
2511
@node -M_, -m, -l, Options
2512
@comment node-name, next, previous, up
2514
@subsection @samp{-M}: Set output message level
2516
@cindex Message level
2517
@cindex Level, message
2519
By default, @FWEB{} is relatively verbose; as it proceeds, it prints
2520
messages about what files it is reading and writing, numbers of the
2521
starred sections, line numbers, etc. However, different levels of
2522
verbosity can be set by the command @samp{-M@i{level}}, where the level
2523
may be 0 (least verbose) through 4 (most verbose; the default), as
2524
described in the following table:
2530
Like level 1, but the start-up banner is not printed. If @FWEB{} runs
2531
to completion with no errors, nothing at all will be printed.
2534
Print only error messages.
2537
Print error and warning messages.
2540
Print errors, warnings, and short information messages (excluding
2541
starred section numbers and line numbers).
2549
The start-up banner, which includes the version number, is printed for
2550
all message levels except 0. For level 0, one can use the @samp{-V}
2551
option to request the start-up banner. @xref{-V_}.
2553
This option is very recent, and may not be fully debugged for obscure
2554
combinations of command-line options. Please report any annoyances.
2556
Another way of discriminating message types is via color output.
2559
@node -m,-m4,-M_,Options
2560
@comment node-name, next, previous, up
2562
@subsection @samp{-m}: Define @FWEB{} macro (@FTANGLE{})
2565
The command-line construction
2571
defines the @FWEB{} macro @code{A} as though the definition
2578
had appeared in the first definition part of the web file.
2580
One can also say @samp{-m'A(x) x'}, where the quotes are removed by the
2581
shell. That is, an @samp{=} appearing @emph{immediately} after the
2582
macro name (or argument list, if there is one) plays the role of the
2583
space in the conventional definition. Thus, carefully distinguish the forms
2586
-m'A(x)=x' // @r{A(x) expands to @samp{x}}
2587
-m'A(x) =x' // @r{A(x) expands to @samp{=x}}
2588
-m'A(x)==x' // @r{Precisely equivalent to the previous example.}
2591
The equals sign is permitted only with command-line macro definitions,
2592
not with @samp{@@m} commands (@pxref{ATm}) in the definition parts of
2595
@node -m4,-m;,-m,Options
2596
@comment node-name, next, previous, up
2598
@subsection @samp{-m4}: Understand @code{m4} built-in commands
2601
@cindex Preprocessor, m4
2602
This tells @FWEAVE{} to properly format the reserved words of the @code{m4}
2603
preprocessor. The use of that preprocessor is @emph{not recommended} in
2604
conjunction with @FWEB{}; use @FWEB{}'s built-in C-like preprocessor
2607
@node -m;,-n,-m4,Options
2608
@comment node-name, next, previous, up
2610
@subsection @samp{-m;}: Append pseudo-semicolons
2613
When @samp{-m;} is in effect, the construction @samp{@@;} is appended
2614
automatically to all @FWEB{} macro definitions.
2616
@emph{This option is not recommended.} Please insert the @samp{@@;} by
2617
hand when necessary, as in
2620
@@m SET(x,y) x=1; y=2@@;
2621
@@m TEST(x) if(x) y; else z@@;
2624
@node -n,-n9,-m;,Options
2625
@comment node-name, next, previous, up
2627
@subsection @samp{-n}: Set global language to @sc{Fortran}--77
2630
This is @FWEB{}'s default, so it generally does not need to be used
2631
explicitly. (See also the discussion of @ref{-L_}.) However, variants
2632
of this option, as described below, may be useful.
2634
See also @ref{Languages} and @ref{Fortran}.
2636
@node -n9,-nAT;,-n,Options
2637
@comment node-name, next, previous, up
2639
@subsection @samp{-n9}: Set global language to @sc{Fortran}--90
2642
@xref{Languages} and @ref{Fortran}; see also the discussion of @samp{-L}
2645
@node -nAT;, -n;, -n9, Options
2646
@comment node-name, next, previous, up
2648
@subsection @samp{-n@@;}: Supply automatic pseudo-semicolons [@sc{Fortran}]
2651
@cindex Pseudo-semicolons, automatic
2652
@cindex Automatic pseudo-semicolons
2653
(Don't forget that a semicolon has special meaning to @sc{unix} shells,
2654
so you'll probably have to quote this command: @samp{-n'@@;'}.)
2656
This is the default mode of operation for free-form @sc{Fortran}-90; the
2657
input driver automatically appends a pseudo-semicolon (invisible) to
2658
each logical line of source code. Since it is the default, one doesn't
2659
have to use it unless one wishes to negate it (@pxref{Negating
2660
options}). In that case, it is best to place the @samp{--n@@;} command
2661
in the source file, as @samp{@@n9[--n@@;]}. If one places it on the
2662
command line, be sure to set the language first: @code{-n9 --n@@;}.
2664
For free-format @sc{Fortran}-90, when @samp{-n@@;} is in effect (the
2665
default), @samp{-np} is also turned on. @xref{-np}.
2667
For further discussion, see the companion command @ref{-n;}.
2669
@node -n;,-ncolon,-nAT;,Options
2670
@comment node-name, next, previous, up
2672
@subsection @samp{-n;}: Supply automatic semicolons [@sc{Fortran}]
2675
@cindex Semicolons, automatic
2676
@cindex Automatic semicolons
2677
(Don't forget that a semicolon has special meaning to @sc{unix} shells,
2678
so you'll probably have to quote this command: @samp{-n';'}.)
2680
This command functions the same as @samp{-n@@;} (@pxref{-nAT;}, except
2682
(visible) semicolons rather than pseudo-semicolons are appended. This
2683
is the default mode of operation for @sc{Fortran}-77 (and for that
2684
language, it cannot be turned off by negation).
2686
The distinction between @samp{-n@@;} and @samp{-n;} has to do with what
2687
is visible on output. In @sc{Fortran}-77, semicolons are not printed by
2688
default since that seemed to annoy many users. However, that causes
2689
trouble with @sc{Fortran}-90 code containing multiple statements per
2696
If @samp{-np} is not used, then the semicolon in the above
2697
example is not printed, hindering legibility. Thus, the default mode of
2698
operation for free-format @sc{Fortran}-90 is @samp{-n@@;} and
2699
@samp{-np}. This turns the above example into @samp{a = b; c = d@@;}
2700
and displays it correctly.
2702
When @samp{-n;} is used, semicolons will not be printed by default.
2703
To force them to be printed, use the @samp{-np} option (@pxref{-np}).
2705
Do not insert semicolons by hand in @sc{Fortran}-77; they are always
2706
inserted automatically. If you have terminated @sc{Fortran}-90
2707
statements by hand, turn off auto-semis by @samp{-n;} (and use
2708
@samp{-np} at your discretion).
2710
The following table summarizes the defaults for auto-semi insertion and
2711
semicolon printing in @sc{Fortran}, both fixed and free formats (`N/A'
2712
means `not applicable'):
2715
@multitable {F90}{Fixed}{ `-nA; -np' }
2717
@item @tab Fixed @tab Free
2718
@item F77 @tab @samp{-n;} @tab N/A
2719
@item F90 @tab @samp{-n;} @tab @samp{-n@@; -np}
2725
@node -ncolon,-nb,-n;,Options
2726
@comment node-name, next, previous, up
2728
@subsection @samp{-n:}: Put statement label on separate line [@sc{Fortran}]
2731
By default, in @sc{Fortran} statement labels are placed on the same
2732
line, and backspaced from, the command that is being labeled, as in
2738
This can look ugly if the label is very long. The command @samp{-n:}
2739
places the label on a separate line, as is done automatically for
2747
If neither of these options appeals to you, you could try redefining the
2748
macro @code{\Wlbl}, found with some discussion in @file{fwebmac.web}.
2749
That macro is emitted only when @samp{-n:} is @emph{not} used.
2752
@node -nb,-nC,-ncolon,Options
2753
@comment node-name, next, previous, up
2755
@subsection @samp{-nb}: Number @b{if}s and @b{do}s [@sc{Fortran}] (@FWEAVE{})
2758
@cindex Numbering blocks
2759
@cindex Blocks, numbering
2760
In the woven output, extra comments are added to help one correlate the
2761
block structure of the code. For more discussion, see @ref{-b}.
2763
@node -nC, -np, -nb, Options
2764
@comment node-name, next, previous, up
2766
@subsection @samp{-nC}: Ignore single-line comments [@sc{Fortran}]
2769
@cindex Comments, ignore single-line Fortran
2770
Ignore, at the input-driver stage, comment lines beginning with
2771
@samp{C}, @samp{c}, or @samp{*}.
2773
Interpretation: In the usual mode of operation, the @sc{Fortran}-77 input
2774
driver makes a heroic attempt to mix the original single-line column-1
2775
commenting style with the @FWEB{} style (@samp{/*...*/} and
2776
@samp{//}). It converts single-line comments to the @samp{/*...*/}
2777
style and passes them along to the innards of the processors.
2779
Problems sometimes arise when converting an existing @sc{Fortran} code
2780
to @FWEB{}. Such codes may have very large blocks of code or
2781
documentation commented out with a @samp{C} in column 1. Special @TeX{}
2782
characters in those comments can cause problems for @FWEAVE{};
2783
sometimes @FTANGLE{} gets confused as well. The @samp{-nC} option
2784
short-circuits these problems by simply throwing all such lines away at
2785
the input driver stage.
2787
This option is not a recommended long-term solution. Instead, consider
2794
In @FWEB{}, blocks of code should be commented out with the
2795
preprocessor commands @code{@@#if 0...@@#endif}; see @ref{Temporary
2799
Textual comments for documentation should be converted to the standard
2800
@FWEB{} commenting style.
2803
If one has a block of code prefaced by an extremely long comment,
2804
replace that by a named module and put the comment into the @TeX{} part
2810
@node -np,-n\,-nC,Options
2811
@comment node-name, next, previous, up
2813
@subsection @samp{-np}: Print semicolons [@sc{Fortran}] (@FWEAVE{})
2816
@cindex Semicolons, printing
2817
Although the @sc{Fortran} input driver automatically terminates logical
2818
lines with semicolons (@sc{Fortran}-77; see @ref{-n;}) or pseudo-semicolons
2819
(@sc{Fortran}-90; see @ref{-nAT;}) so that the innards of @FWEAVE{}
2820
can process them correctly, the semicolons are not printed by default.
2821
To make actual semicolons be printed, use the @samp{-np} option.
2823
@samp{-np} is turned on automatically for free-format @sc{Fortran}-90 when
2824
@samp{-n@@;} is in effect (the default). For more discussion, see
2827
@node -n\,-n&,-np,Options
2828
@comment node-name, next, previous, up
2830
@subsection @samp{-n\}: Free-form syntax continued by backslash
2833
@cindex Syntax, free-form
2834
In @sc{Fortran}--90, this turns on free-form syntax and sets the continuation
2835
character to be the backslash (as it would be in C). For example,
2847
In the tangled output the backslash is converted into @sc{Fortran}-90's
2848
standard continuation character, the ampersand.
2852
@node -n&,-n/,-n\,Options
2853
@comment node-name, next, previous, up
2855
@subsection @samp{-n&}: Free-form syntax continued by ampersand
2858
@cindex Syntax, free-form
2859
In @sc{Fortran}--90, this turns on free-form syntax and sets the continuation
2860
character to be the ampersand. For example,
2872
For @sc{Fortran}-90, free-form syntax continued by the ampersand is
2873
@FWEB{}'s default, so one probably will not need to use @samp{-n&}
2878
@node -n/,-n!,-n&,Options
2879
@comment node-name, next, previous, up
2881
@subsection @samp{-n/}: Recognize short comments [@sc{Fortran}]
2884
The standard @FWEB{} notation for a short comment (one terminated by
2885
the next newline) is @samp{// ...}. However, in @sc{Fortran} the
2886
@samp{//} denotes concatenation by default. To make it denote a short
2887
comment, use the @samp{-n/} option. One can do this in the @file{.fweb}
2888
file (@pxref{Customization}) or with the language-setting command in
2889
limbo, as in @samp{@@n/}.
2892
In @FWEB{}, one may always use @samp{\/} for concatenation, so there's
2893
no penalty for using @samp{-n/}.
2894
@cindex Concatenation
2897
@node -n!,-n),-n/,Options
2898
@comment node-name, next, previous, up
2900
@subsection @samp{-n!}: Make @samp{!} denote short comment [@sc{Fortran}]
2903
@cindex Comments, @sc{Fortran}
2904
In @sc{Fortran}-90, @samp{!} starts a short comment. However,
2905
by default @FWEB{} usurps @samp{!} for the logical not, as in
2906
@samp{if(x != y)}. To force it to recognize @samp{!} as a comment, use
2907
@samp{-n!}. However, the recommended style is to use @FWEB{}'s
2908
standard convention that @samp{//} denotes the start of a short
2909
comment (@pxref{-n/}). See also @ref{-!} and @ref{-r!}.
2911
In @sc{Fortran}-77, to include the exclamation point inside a string,
2912
escape it with a backslash, as in
2915
s = "A \! inside a string"
2918
This possibly annoying restriction arises because the unduly complicated
2919
@sc{Fortran} input driver does some preprocessing of the @sc{Fortran}
2920
source before it feeds it to the cores of the processors.
2922
@node -n), -o, -n!, Options
2923
@comment node-name, next, previous, up
2925
@subsection @samp{-n)}: Reverse array indices [@sc{Fortran}] (@FTANGLE{})
2928
This @emph{somewhat experimental} flag permits @sc{Fortran} programmers to
2929
use C-style array indices.
2930
Conversions such as the following are made (during the output phase of
2934
a(k)(i) @r{=>} a(i,k)
2935
a(k)(i,j) @r{=>} a(i,j,k)
2936
a(k)(j)(i) @r{=>} a(i,j,k)
2939
[No spaces may intervene between @samp{)} and @samp{(}; effectively,
2940
@samp{)(} is treated as one token for the purposes of @samp{-n)}.]
2941
This feature permits convenient definitions of macros that deal with
2942
multi-dimensional vectors.
2944
Unfortunately, @FTANGLE{} doesn't fully understand the syntax of the
2945
source code---and never will, unless it is fully integrated with a
2946
compiler. It will therefore be confused by situations like the
2947
following @sc{Fortran} example:
2950
dimension x(0:4)(1:2) // @r{OK}
2951
character*90 ch(4) // @r{OK}
2952
write(6,*) ((x(i)(j),i=1,2), j=3,4) // @r{Will reverse incorrectly.}
2953
c = ch(4)(3:4) // @r{Shouldn't reverse, but will.}
2956
One solution, due to Charles Karney, is to insert a space to prevent
2957
@samp{)(} from being recognized as a single token. However,
2958
since ordinary white space is eaten on input, one must resort to
2959
something like the following (@samp{$UNQUOTE} is a built-in @FWEB{}
2960
function; @pxref{$UNQUOTE}):
2963
@@m SP $UNQUOTE(' ')
2965
dimension x(0:4)(1:2)
2967
write(6,*) SP ((x(i)(j),i=1,2), j=3,4)
2971
This option is controlled by the three style-file parameters
2972
@samp{paren.len}, @samp{paren.num}, and @samp{paren.nest}. (@xref{Style}.)
2973
@samp{paren.len} is the default number of bytes to be allocated for each
2974
index; if an index is longer than this number, the current length is
2975
increased by this number and storage is automatically reallocated.
2976
@samp{paren.num} is the maximum number of allowed indices; for example,
2977
when processing @samp{a(i)(j)(k)}, @samp{paren.num} is 3.
2978
@samp{paren.nest} is the maximum parenthesis nesting level. In the
2979
example @samp{x(a(i)(j)(k))}, @samp{paren.nest} is 2. If either of the
2980
last two parameters is exceeded, a message will be issued asking you to
2981
increase the appropriate value.
2983
@node -o,-q,-n),Options
2984
@comment node-name, next, previous, up
2986
@subsection @samp{-o}: Don't overload operators
2989
@cindex Operators, overloading
2990
This option inhibits the operator-overloading feature invoked by the
2991
command @samp{@@v} (@pxref{Overloading}).
2993
@node -q,-P_,-o,Options
2994
@comment node-name, next, previous, up
2996
@subsection @samp{-q}: Don't translate @sc{Ratfor}
2999
@emph{(This option is obsolete.)}
3001
@node -P_,-p,-q,Options
3002
@comment node-name, next, previous, up
3004
@subsection @samp{-P}: Select @TeX{} processor
3007
@cindex Processor, @TeX{}
3008
@cindex Processor, La@TeX{}
3009
Say @samp{-PT} or @samp{-PL} to inform @FWEAVE{} that its output will
3010
be processed by @TeX{} or La@TeX{}, respectively. Beginning with
3011
Version 1.50, the default processor is LaTeX (@samp{-PL}). If you
3012
always use @TeX{}, it's easiest to put @samp{-PT} into the @file{.fweb}
3013
initialization file.
3015
@emph{Please note that @samp{-PT} is no longer supported; @FWEB{}
3016
development is now based exclusively on La@TeX{}.}
3018
@node -p,-r,-P_,Options
3019
@comment node-name, next, previous, up
3021
@subsection @samp{-p}: Buffer up a style-file entry
3024
This option specifies a style-file entry (@pxref{Style}). Its argument
3025
is exactly the same as a line that one may put into the local @FWEB{}
3026
style file. Thus, if in @file{fweb.sty} one would say
3027
@samp{entry="value"}, the form of the @samp{-p} option would be
3028
@samp{-pentry='"value"'}. (The single quotes are required on a
3029
@sc{unix} system because the double quotes have special significance to
3032
This option can be used either in the @file{.fweb} initialization file
3033
(@pxref{Initialization}), to record style-file entries that are common
3034
to all runs, or on the command line, to override a local style-file
3035
entry for a single run. This behavior is a consequence of the following
3036
order of processing style parameters:
3041
@samp{-p} options in @file{.fweb};
3044
entries in the local style file @file{fweb.sty};
3047
@samp{-p} options on the command line.
3052
@node -r,-r9,-p,Options
3053
@comment node-name, next, previous, up
3055
@subsection @samp{-r}: Set global language to @sc{Ratfor}--77
3057
@xref{Languages} and @ref{Ratfor}. See also @ref{-L_}.
3060
@node -r9,-rg,-r,Options
3061
@comment node-name, next, previous, up
3063
@subsection @samp{-r9}: Set global language to @sc{Ratfor}--90
3065
@xref{Languages} and @ref{Ratfor}. See also @ref{-L_}.
3068
@node -rg,-rk,-r9,Options
3069
@comment node-name, next, previous, up
3071
@subsection @samp{-rg}: Set @b{goto} parameters
3074
This obscure option is used for configuring @sc{Ratfor} (and really
3075
should be a style-file parameter). (Discussion not finished.)
3077
@node -rk,-rK_,-rg,Options
3078
@comment node-name, next, previous, up
3080
@subsection @samp{-rk}: Suppress comments about @sc{Ratfor} translation (@FTANGLE{})
3083
By default, the @sc{Ratfor} translator writes comments about what command it
3084
is translating. The @samp{-rk} option suppresses those comments. Arguments
3085
to this option allows one to suppress comments about only particular
3086
commands, according to the following list:
3096
p @r{---} repeat, until
3104
For example, one can say @samp{-rkrb} to suppress comments about the
3105
@b{return} and @b{break} statements.
3107
@node -rK_,-rAT;,-rk,Options
3108
@comment node-name, next, previous, up
3110
@subsection @samp{-rK}: Write comments about @sc{Ratfor} translation (@FTANGLE{})
3113
This is the negative of @samp{-rk} (@pxref{-rk}); it forces comments
3114
about particular @sc{Ratfor} commands.
3116
@node -rAT;, -r;, -rK_, Options
3117
@comment node-name, next, previous, up
3119
@subsection @samp{-r@@;}: Turn on auto-semi mode using pseudo-semis [@sc{Ratfor}]
3122
Please don't use this option (it may not work). Insert semicolons by
3123
hand in your @sc{Ratfor} code, just as one does in C.
3125
@node -r;, -rb, -rAT;, Options
3126
@comment node-name, next, previous, up
3128
@subsection @samp{-r;}: Turn on auto-semi mode using actual semis [@sc{Ratfor}]
3131
Please don't use this option (it may not work). Insert semicolons by
3132
hand in your @sc{Ratfor} code, just as one does in C.
3134
@node -rb,-r/,-r;,Options
3135
@comment node-name, next, previous, up
3137
@subsection @samp{-rb}: Number @b{if}s and @b{do}s [@sc{Ratfor}]
3140
@cindex Numbering blocks
3141
@cindex Blocks, numbering
3142
In the woven output, extra comments are added to help one correlate the
3143
block structure of the code. For more discussion, see @ref{-b}.
3145
@node -r/,-r!,-rb,Options
3146
@comment node-name, next, previous, up
3148
@subsection @samp{-r/}: Recognize short comments [@sc{Ratfor}]
3151
The standard @FWEB{} notation for a short comment is @samp{// ...}.
3152
However, in @sc{Ratfor} the @samp{//} denotes concatenation by default.
3153
To make it denote a short comment, use the @samp{-r/} option. For
3154
concatenation, use @samp{\/}.
3156
For an example, see @ref{-n/}.
3158
@node -r!,-r),-r/,Options
3159
@comment node-name, next, previous, up
3161
@subsection @samp{-r!}: Make @samp{!} denote short comment [@sc{Ratfor}]
3164
See the corresponding discussion of @samp{-!} in @ref{-!} and @ref{-n!}.
3166
In @sc{Fortran}-77, to include the exclamation point inside a string,
3167
escape it with a backslash, as in
3170
s = "A \! inside a string"
3173
@node -r), -s, -r!, Options
3174
@comment node-name, next, previous, up
3176
@subsection @samp{-r)}: Reverse array indices [@sc{Ratfor}] (@FTANGLE{})
3179
See the corresponding discussion of @samp{-n)} in @ref{-n)}.
3181
@node -s, -T_, -r), Options
3182
@comment node-name, next, previous, up
3184
@subsection @samp{-s}: Print statistics
3188
@cindex Statistics, printing
3189
@samp{-s} prints statistics about memory usage at the end of the run.
3191
@samp{-sm} prints statistics about memory usage at the end of the run, just
3192
as does @samp{-s}; it also prints information about dynamic memory
3193
allocations as they occur. @samp{-sm@i{nnn}} displays allocations of nnn bytes
3194
or more; if @i{nnn} is missing, 10000 is assumed.
3196
@node -T_, -t, -s, Options
3197
@comment node-name, next, previous, up
3199
@subsection @samp{-T}: Flag-setting options for @FTANGLE{}
3201
This is a family of options that set miscellaneous flags appropriate
3202
only for @FTANGLE{}.
3205
* -TD:: Permit processing of deferred macro definitions.
3206
* -Tb:: Permit built-functions such as @code{$IF} to be redefined.
3207
* -Tm:: Permib user-defined macros to be redefined.
3208
* -Tv:: Don't print header info at top of output.
3209
* -T%:: Don't retain trailing comments.
3210
* -T#:: Don't insert @samp{#line} command after @samp{@@%}.
3213
@node -TD, -Tb, -T_, -T_
3214
@comment node-name, next, previous, up
3216
@subsubsection @samp{-TD}: Permit processing of deferred macro definitions
3219
@cindex Macros, deferred
3220
@dfn{Deferred macro definitions} are @samp{@@m} (or, equivalently,
3221
@samp{@@#define}) commands that appear in the code part rather than
3222
the usual definition part. These definitions are evaluated during the
3223
output (phase 2), and can cause confusion when used with the
3224
preprocessor commands, which are evaluated during the input (phase 1).
3225
Because of this confusion, deferred macro definitions are prohibited by
3226
default. To permit them, use the @samp{-TD} option (then be prepared
3227
to make some obscure programming errors).
3229
@node -Tb, -Tm, -TD, -T_
3230
@comment node-name, next, previous, up
3232
@subsubsection @samp{-Tb}: Permit built-functions to be redefined
3235
@cindex built-in functions, redefining
3237
By default, built-in functions such as @code{$IF} (@pxref{Built-in functions})
3238
may not be redefined by an @code{@@m} command. To allow this extremely
3239
dangerous operation, use the @samp{-Tb} option.
3241
@node -Tm, -Tv, -Tb, -T_
3242
@comment node-name, next, previous, up
3244
@subsubsection @samp{-Tm}: Permit user macros to be redefined
3247
@cindex macros, redefining
3249
By default, user macros may not be redefined by an @code{@@m} command.
3250
To permit this, use the @samp{-Tm} option. Note that many functions
3251
described under @ref{Built-in functions}, such as @code{$PI}, are in fact
3252
implemented as macros.
3254
@node -Tv, -T%, -Tm, -T_
3255
@comment node-name, next, previous, up
3257
@subsubsection @samp{-Tv}: Don't print header info
3260
@cindex Header comments, printing
3261
By default, @FTANGLE{} attempts to be helpful and writes some
3262
information about the command line, input and change files, etc.@ at the
3263
beginning of the output file. This information can be deleted by means
3264
of the @samp{-Tv} flag. [This is done automatically when the @samp{-F}
3265
flag (@pxref{-F_}) is in effect, since the header information includes a
3266
time stamp that would defeat a successful file comparison.]
3268
@node -T%, -T#, -Tv, -T_
3269
@comment node-name, next, previous, up
3271
@subsubsection @samp{-T%}: Don't retain trailing comments (@TeX{})
3274
@cindex Comments, @TeX{}
3275
Unless the @samp{-v} option is used, comments are generally deleted by
3276
@FTANGLE{} as it writes the output file. However, in the @TeX{}
3277
language such deletions can change the behavior of the output (by
3278
introducing extra spaces). Therefore, @TeX{} comments that do not
3279
begin a line are always retained unless the @samp{-T%} option is used.
3280
This option has no effect for languages other than @TeX{}.
3282
@node -T#, , -T%, -T_
3283
@comment node-name, next, previous, up
3285
@subsubsection @samp{-T#}: Don't insert @samp{#line} command after @samp{@@%}
3288
If the @samp{@@%} command (@pxref{AT%}) is used to comment out a line,
3289
it eats the trailing newline. An undesirable consequence of this is
3290
that, if nothing is done, the subsequent line numbering will be
3291
misunderstood by a debugger, at least until @FWEB{} inserts a
3292
@samp{#line} command for some reason. To prevent this, @FWEB{}
3293
inserts by default an implicit @samp{@@#line} command
3294
(@pxref{Preprocessing}) after each @samp{@@%} that begins a line. To
3295
prevent this from happening (possibly because the feature doesn't work
3296
correctly, in which case you should report it; @pxref{Support}), use the
3299
@node -t, -U_, -T_, Options
3300
@comment node-name, next, previous, up
3302
@subsection @samp{-t}: Truncate identifiers
3305
@cindex Identifiers, truncating
3306
The truncation option enables one to use a wider character set for
3307
identifiers than the language compiler will accept. The standard
3308
example is vanilla-flavored @sc{Fortran}-77, which doesn't allow the underscore.
3309
If one says @samp{`-tn6@{_@}}', underscores will be removed from all
3310
identifiers, then the result will be truncated to length 6. If the
3311
truncation procedure results in non-unique identifiers, these are
3314
@node -U_, -u, -t, Options
3315
@comment node-name, next, previous, up
3317
@subsection @samp{-U}: Convert reserved output tokens to lower case (@FTANGLE{})
3320
@cindex Tokens, upper-case
3321
Particularly during @sc{Ratfor} expansion, certain tokens such as
3322
@samp{DO} are output by @FTANGLE{} in upper case. The @samp{-U}
3323
option forces such tokens to be produced in lower case.
3325
@node -u,-V_,-U_,Options
3326
@comment node-name, next, previous, up
3328
@subsection @samp{-u}: Undefine @FWEB{} macro (@FTANGLE{})
3331
@samp{-uA} undefines the @FWEB{} macro @samp{A} previously defined on the
3332
command line (or in @file{.fweb}) via @samp{-m}.
3334
@emph{CAUTION}: This option can also undefine built-in
3335
functions such as @code{$IF}. Don't do that, since built-ins can use other
3336
built-ins behind the scenes; undefining one can cause very strange behavior.
3338
@node -V_, -v, -u, Options
3339
@comment node-name, next, previous, up
3341
@subsection @samp{-V}: Print @FWEB{} version number
3343
@cindex Version number
3345
This flag requests the startup banner, which includes the @FWEB{}
3346
version number, to be printed. This is usually done anyway, so it
3347
is only relevant when the message level is 0 (@pxref{-M_}).
3349
@node -v,-W_,-V_,Options
3350
@comment node-name, next, previous, up
3352
@subsection @samp{-v}: Make all comments verbatim (@FTANGLE{})
3355
@cindex Comments, verbatim
3356
By default, comments are not passed to the tangled output. With @samp{-v},
3357
all comments are included verbatim in the tangled output. Since there's
3358
generally no harm in this, one might want to put this option into
3359
@file{.fweb} (@pxref{Initialization}).
3361
@node -W_,-w,-v,Options
3362
@comment node-name, next, previous, up
3364
@subsection @samp{-W}: Flag-setting options for @FWEAVE{}
3367
This is a family of options that set miscellaneous flags appropriate
3369
Options such as @samp{-W[} and @samp{-Wf} can be combined as @samp{-W[f}.
3372
* -W@@: -WAT. Set module warning flag.
3373
* -W1:: Completely cross-reference single-character identifiers.
3374
* -W[:: Turn on processing of bracketed array indices.
3375
* -WH: -WH_. Send extra arguments to the C preprocessor.
3377
Commands that inhibit printing:
3379
* -Wd: -Wnoprint. Don't print @@d or @@D in woven output.
3380
* -Wf: -Wnoprint. Don't print @@f.
3381
* -WF: -Wnoprint. Don't print @@F.
3382
* -Wl: -Wnoprint. Don't print @@l.
3383
* -Wm: -Wnoprint. Don't print @@m or @@M.
3384
* -Wv: -Wnoprint. Don't print @@v.
3385
* -Ww: -Wnoprint. Don't print @@w or @@W.
3388
@node -WAT, -W1, -W_, -W_
3389
@comment node-name, next, previous, up
3391
@subsubsection @samp{-W@@}: Set module warning flag.
3394
@cindex Modules, warning level for
3395
@cindex Warning level for modules
3397
@FWEAVE{} can check module names for the possible anomalous conditions of
3398
``never used'' or ``multiple uses.'' These correspond to a module
3399
warning level, as in the following numbered list:
3410
The module warning flag is the bitwise OR of the desired warning
3411
levels; warning messages are printed only when the relevant bits are
3412
turned on. By default, it is 1, so only messages about never-used
3413
modules are printed. The @samp{-W@@@i{flag}} overrides the default.
3414
For example, to get messages only about multiple uses, say @samp{-W@@2};
3415
to get no messages, say @samp{-W@@0}. One can put such an option into the
3416
@file{.fweb} initialization file (@pxref{Initialization}).
3418
@FWEAVE{} will always complain about module names that are never defined.
3421
@node -W1, -W[, -WAT, -W_
3422
@comment node-name, next, previous, up
3424
@subsubsection @samp{-W1}: Cross-reference single-character identifiers
3427
@cindex Identifiers, single-character
3428
By default, @FWEB{} does not index uses of single-character
3429
identifiers (following Knuth's original design). (It does index their
3430
definitions.) To get complete cross-reference information for
3431
single-character identifiers, use the @samp{-W1} option.
3433
@node -W[, -WH_, -W1, -W_
3434
@comment node-name, next, previous, up
3436
@subsubsection @samp{-W[}: Process bracketed array indices
3439
@cindex Brackets, active
3440
This @emph{experimental} option makes square brackets behave like
3441
parentheses in the context of array indices.
3443
In @sc{Fortran}, @FTANGLE{} will just replace the brackets by parentheses.
3444
In C, the brackets will be left alone.
3447
@FWEAVE{}, however, will typeset the indices according
3448
to the @file{fwebmac.sty} macro @samp{\WARRAY}. This macro takes one
3449
argument, which is just the array index or indices. (In C, indexing
3450
like @samp{a[i][j][k]} generates the argument @samp{i,j,k}.) By
3451
default, @samp{\WARRAY} just surrounds its argument with brackets.
3452
However, the user may change its definition to get special effects such
3453
as superscripted or subscripted indices. A simple example macro
3454
@samp{\WSUB} is provided in @file{fwebmac.sty}; one can say
3455
@samp{\let\WARRAY\WSUB} in the limbo section to have bracketed indices
3456
print as subscripts.
3458
This feature may not work when the contents of the brackets
3459
are too complicated (so that @FWEAVE{} tries to typeset them by going
3460
in and out of math mode).
3462
For more information, experts can see @file{fwebmac.web}, command @code{\WXA}.
3465
@node -WH_, -Wnoprint, -W[, -W_
3466
@comment node-name, next, previous, up
3468
@subsubsection @samp{-WH}: Send additional arguments to the C preprocessor
3471
@cindex Preprocessor, sending additional arguments to
3472
When the @samp{-H} option (@pxref{-H_}) is used, the C preprocessor is
3473
invoked to scan include header files for @b{typedef}'s and @b{class}
3474
declarations. That is called with a standard set of options.
3475
(Presently, @code{gcc} is actually called to invoke the preprocessor; it
3476
is sent the options @samp{-E}, @samp{-P}, and @samp{-I}.) Occasionally
3477
it may be necessary to send additional options. Those can be specified
3478
as the (string) argument to @samp{-WH}. Thus, to define two macros to the
3479
preprocessor, one could say either of
3482
-WH-Dtest1=1 -WH-Dtest2=2
3483
-WH"-Dtest1=1 -Dtest2=2"
3486
The first form shows that @samp{-WH} accretes to earlier uses. The
3487
second form shows how to handle embedded blanks (in a @sc{unix} shell).
3488
Then, if one were programming in C, use of @samp{-H} would issue the
3492
gcc -E -P -Dtest1=1 -Dtest2=2
3496
@node -Wnoprint, , -WH_, -W_
3497
@comment node-name, next, previous, up
3499
@subsubsection @samp{-WdfFlmvw}: Don't print various things in woven output
3502
The printing of selected definition-part commands can be suppressed as
3506
-Wd @r{--- outer definitions (@samp{@@d} or @samp{@@D})}
3507
-Wf @r{--- format statements (@samp{@@f})}
3508
-WF @r{--- format statements (@samp{@@F})}
3509
-Wl @r{--- limbo text definitions (@samp{@@l})}
3510
-Wm @r{--- FWEB macro definitions (@samp{@@m} or @samp{@@M})}
3511
-Wv @r{--- operator overloads (@samp{@@v})}
3512
-Ww @r{--- identifier overloads (@samp{@@w} or @samp{@@W})}
3516
When these options used, associated cross-referencing is suppressed
3518
@cindex Cross-references, suppressing
3520
@node -w,-x,-W_,Options
3521
@comment node-name, next, previous, up
3523
@subsection @samp{-w}: Change name of macro package (@FWEAVE{})
3526
The option @samp{-w} means ``Don't print @samp{\input fwebmac.sty} as
3527
the first line of the @file{.tex} output file.'' The option
3528
@samp{-w@i{fname}} means ``Print @samp{\input fname} as the first line.''
3529
For example, when working with REV@TeX{} (@pxref{REVTeX}), one needs to
3530
say @samp{-wrwebmac.sty}.
3532
This option can be used for special effects when one is trying to obtain
3533
behavior different from that defined by @FWEB{}'s macro package
3534
@file{fwebmac.sty} (@pxref{fwebmac.sty}). However, try to not do that.
3535
Please submit requests for such behavior modifications to the developer;
3538
@node -x,-X_,-w,Options
3539
@comment node-name, next, previous, up
3541
@subsection @samp{-x}: Eliminate or reduce cross-reference information (@FWEAVE{}).
3544
@cindex Cross-references, eliminating
3545
Cross-reference information (for @FWEAVE{}) includes the Table of Contents
3546
('c'), the Index ('i'), and the Module List ('m'). The option @samp{-x}
3547
eliminates all of that information. The option @samp{-x@i{letters}}
3548
eliminates the piece of information corresponding to each letter in the
3549
list. For example, @samp{-xim} eliminates the Index and the Module List.
3551
Another possibility is to say @samp{-xu}, which prevents
3552
cross-references from unnamed sections (begun with @samp{@@a} or
3553
@samp{@@A}) from appearing in the Index.
3555
@node -X_,-y,-x,Options
3556
@comment node-name, next, previous, up
3558
@subsection @samp{-X}: Print selected cross-reference information (@FWEAVE{})
3561
When used with any of the arguments @samp{cim}, this option is the
3562
opposite of @samp{-x}. @xref{-x}.
3564
The option @samp{-XI} tells @FWEAVE{} to write its index
3565
cross-references to a file formatted for input by the @code{makeindex}
3566
utility. This feature facilitates creation of a master index that spans
3567
several individual @code{web} files. For more discussion, see
3568
@ref{Using makeindex}.
3570
The construction @samp{-XI} stands alone; one may not mix the @samp{I}
3571
with the list @samp{cim}. Also, this option is overridden by
3572
@samp{-xi}, which suppresses output of all index information.
3574
@node -y,-Z_,-X_,Options
3575
@comment node-name, next, previous, up
3577
@subsection @samp{-y}: Allocate dynamic memory
3580
@cindex Memory allocation
3581
@cindex Allocation, memory
3582
This option changes the default size for a dynamically allocated memory
3583
buffer. The buffers are indicated by a one- or two-character
3584
abbreviation such as @samp{op}. For example, the option @samp{-yop200}
3585
allocates 200 units for the @samp{op} buffer.
3587
To query the default allocations, just say @samp{-y}.
3589
When @FWEB{} runs out of space, it usually (but not always) issues a
3590
message telling one which @samp{-y} command to use in order to increase
3591
the allocations. (Someday it will reallocate automatically.) One may
3592
wish to add some such options to the @file{.fweb} file.
3594
For a more detailed discussion of memory allocation and a menu of the
3595
various dynamic arrays, see @ref{Memory allocation}.
3597
@node -Z_,-z,-y,Options
3598
@comment node-name, next, previous, up
3600
@subsection @samp{-Z}: Display default style-file parameters
3603
@cindex Options, information
3604
The information option @samp{-Zabc} prints to the screen the default
3605
contents of the style-file parameters beginning with @samp{abc}. Just
3606
@samp{-Z} prints everything.
3608
After printing the defaults, the @samp{-p} options (@pxref{-p}) and the
3609
style file @file{fweb.sty} are processed. If that processing has
3610
overridden any of the defaults, the parameters are printed again,
3611
preceded by an asterisk.
3613
To see only the parameters that have been modified from the defaults,
3616
The @samp{-Z} option behaves slightly differently for color escape
3617
sequences than for other parameters; see @ref{Color}.
3620
@node -z,-.,-Z_,Options
3621
@comment node-name, next, previous, up
3623
@subsection @samp{-z}: Change name of style file
3626
@cindex Style file, changing name of
3627
The command @samp{-znew.sty} changes the default style-file name
3628
@file{fweb.sty} to @file{new.sty}. The command @samp{-z} (with no
3629
argument) means ``Don't read any style file.''
3631
Normally the style file is read from the same directory in which the
3632
@code{web} source file resides (or from the path defined by the
3633
environment variable @code{FWEB_STYLE_DIR}). To force @code{fweb.sty}
3634
to be read from the current directory, say @samp{-z.}.
3636
@node -.,-\,-z,Options
3637
@comment node-name, next, previous, up
3639
@subsection @samp{-.}: Don't recognize dot constants
3642
@cindex Dot constants, recognizing
3643
If this command is used, the processors will not understand that
3644
constructions such as @samp{.LT.} are operators in @sc{Fortran} or
3645
@sc{Ratfor}. This command is useful if one is trying to modernize the
3646
source code to use @FWEB{} conventions such as @samp{<} instead of
3649
@node -\,-lp,-.,Options
3650
@comment node-name, next, previous, up
3652
@subsection @samp{-\}: Explicitly escape continued strings
3655
@cindex Strings, long
3656
@cindex Strings, continuing
3657
In @FWEB{}, long strings are continued with the backslash. Normally,
3658
the continuation of the string must start in the first column of the
3659
next line; otherwise, spurious blanks will be introduced. However, when
3660
the @samp{-\} option is in effect, @FWEB{} expects that the
3661
continuation will also begin with the backslash, and it will ignore
3662
leading white space and the backslash. (This feature was inspired by
3663
@sc{Fortran}-90.) Thus, in the example
3670
the effective string is @code{"This is continued"} when @samp{-\} is in
3673
Note that this option affects all strings in the source file; one cannot
3676
@node -lp,-colon,-\,Options
3677
@comment node-name, next, previous, up
3679
@subsection @samp{-(}: Continue parenthesized strings with backslashes
3682
@cindex Strings, parenthesized
3683
This option is like @samp{-\} (@pxref{-\}), but it refers to certain
3684
strings that are not normally quoted, such as the arguments of
3685
@samp{ifelse} commands in @code{m4}.
3687
@node -colon,->,-lp,Options
3688
@comment node-name, next, previous, up
3690
@subsection @samp{-:}: Set starting automatic statement number
3693
@cindex Statement numbers, automatic
3694
This option is useful for @sc{Fortran} and @sc{Ratfor}. Symbolic
3695
statement labels that are defined with the @samp{#:0} macro command
3696
(@ref{Tokens}; @ref{Fortran}), as in @samp{@@m EXIT #:0}, are incremented
3697
starting with the default of 90000. To change this to, e.g., 789, say
3700
@node ->,-=,-colon,Options
3701
@comment node-name, next, previous, up
3703
@subsection @samp{->}: Redirect output (@FTANGLE{})
3706
@cindex Ouput, redirecting
3707
This changes the name of @FTANGLE{}'s output file. If no name is
3708
given, output is redirected to the terminal.
3710
This command has no effect for @FWEAVE{}.
3712
Although the appearance of this command is highly intuitive, it may be
3713
hard to type quickly. An equivalent command is @samp{-=} (@pxref{-=}).
3715
@node -=,-#,->,Options
3716
@comment node-name, next, previous, up
3718
@subsection @samp{-=}: Redirect output (@FTANGLE{})
3721
@cindex Ouput, redirecting
3722
Equivalent to @samp{->} (@pxref{->}), and faster to type on many keyboards.
3724
@node -#,-plus,-=,Options
3725
@comment node-name, next, previous, up
3727
@subsection @samp{-#}: Turn off comments about line and section numbers (@FTANGLE{})
3730
By default, tangled output includes comments about the line and section
3731
numbers corresponding to the current piece of code. To eliminate this
3732
clutter, say @samp{-#}. (But note that the line-number information is very
3733
useful for debugging in C and C++, as it enables the debugger to display
3734
the source line in the web file.)
3736
In some cases, bugs in tangled output, particularly from @sc{Fortran}, can be
3737
eliminated by using @samp{-#}. (But please report the bug anyway;
3740
In some cases, it is useful to turn off the line- and section-number
3741
information locally. This can be done with the @samp{@@q} command.
3744
@node -plus,-/,-#,Options
3745
@comment node-name, next, previous, up
3747
@subsection @samp{-+}: Don't interpret compound assignment operators
3750
@cindex Assignment operators, compound
3751
Both @sc{Ratfor} and @sc{Fortran} attempt to translate the commands
3752
@samp{++}, @samp{--}, @samp{+=}, @samp{-=}, @samp{*=}, and @samp{/=}
3753
into code that behaves as their C/C++ counterparts. To turn this feature off,
3757
Notice that in @sc{Fortran}-90 @samp{/=} is a token for ``not equal,''
3758
so if you want to use that you must turn off the compound assignment
3759
operators with use @samp{-+}. However, a better solution is to leave
3760
them turned on and use @FWEB{}'s standard @samp{!=} token for ``not equal.''
3762
See also @ref{-ylx}.
3764
@node -/,-!,-plus,Options
3765
@comment node-name, next, previous, up
3767
@subsection @samp{-/}: Recognize short comments (@sc{Fortran} & @sc{Ratfor})
3771
@cindex Comments, short
3772
If this command is not used with the @sc{Fortran}-like languages, the
3773
@samp{//} construction will be interpreted
3774
as concatenation rather than as the beginning of a short comment.
3776
Concatenation can be signified with @FWEB{}'s token@samp{\/}, so no
3777
penalty is incurred for using @samp{-/}.
3779
One way of invoking this option is with the global language command,
3780
such as @samp{@@n/}. Another is to put the command into the
3781
initialization file @file{.fweb}.
3783
See also @ref{-n/} and @ref{-r/}.
3785
@node -!,Info options,-/,Options
3786
@comment node-name, next, previous, up
3788
@subsection @samp{-!}: Make @samp{!} denote short comment (@sc{Fortran} & @sc{Ratfor})
3791
@cindex Comments, short
3792
This option is not recommended; use @FWEB{}'s standard @samp{//} to
3793
begin short comments.
3795
To include the exclamation point inside a string, escape it with a
3799
s = "A \! inside a string"
3802
@node Info options,,-!,Options
3803
@comment node-name, next, previous, up
3805
@subsection Information options
3807
@cindex Options, information
3808
@cindex Information options
3809
Several of the command-line options can be used to elicit information
3810
about the initial state of @FWEB{}.
3813
@samp{-@@} displays information about the control codes. @xref{-AT}.
3815
@samp{-D} displays information about reserved words. @xref{-D_}.
3817
@samp{-y} displays default dynamic memory allocations. @xref{-y}.
3819
@samp{-Z} displays default values of style-file parameters. @xref{-Z_}.
3822
The @samp{-h} option reminds one about these information options; it
3823
also provides convenient access to the GNU @code{info} browser.
3826
@node AT commands,Comments,Starting,Top
3827
@comment node-name, next, previous, up
3829
@chapter @FWEB{} COMMANDS
3831
All @FWEB{} commands begin with the character @samp{@@}. It is recommended
3832
that these begin in column 1 if possible. This is required in some
3833
cases [e.g., the @samp{@@x}, @samp{@@y}, and @samp{@@z} in change files
3834
(@pxref{Change files}), or column-oriented @sc{Fortran}-77 processing].
3836
Some of these control codes may be used anywhere; others begin a new
3837
part of the current section. (For a discussion of sections and parts,
3838
see @ref{Structure}.) For a quick summary of the control-code mappings
3839
and to see which codes begin new parts, say @samp{ftangle -@@}.
3844
* @@0: AT0. Turn off debugging.
3845
* @@1: AT1. Display irreducible scraps.
3846
* @@2: AT2. Display detailed scrap reductions.
3848
Literal control characters:
3849
* @@@@: ATAT. Insert an '@@'.
3850
* @@|: AT|. Vertical bar/optional line break.
3852
Beginning of section:
3853
* @@ : ATspace. Begin minor section.
3854
* @@*: AT*. Begin major section.
3856
Beginning of code part:
3857
* @@<: AT<. Begin module name.
3858
* @@>: AT>. End module name.
3859
* @@A: ATA_. Begin code part.
3860
* @@a: ATa. Begin code part and mark next identifier.
3863
* @@B: ATB_. Insert left brace; suppress default insertion of breakpoint command.
3864
* @@b: ATb. Insert breakpoint command.
3865
* @@c: ATc. Set language to C.
3866
* @@c++: ATcpp. Set language to C++.
3867
* @@D: ATD_. Define outer macro.
3868
* @@d: ATd. Define outer macro and mark it.
3869
* @@E: ATE_. Treat next identifier as ordinary expression.
3870
* @@e: ATe. Invisible expression.
3871
* @@f: ATf. Format identifier or module name.
3872
* @@I: ATI_. Include a WEB file, but don't print it.
3873
* @@i: ATi. Include a WEB file.
3874
* @@K: ATK_. Expand global RCS-like keyword.
3875
* @@k: ATk. Expand local RCS-like keyword.
3876
* @@L: ATL_. Set language.
3877
* @@l: ATl. Specify limbo text.
3878
* @@M: ATM_. Define an @FWEB{} macro.
3879
* @@m: ATm. Define a @FWEB{} macro and mark it.
3880
* @@N: ATN_. Turn on language-independent mode.
3881
* @@n: ATn. Set language to Fortran--77.
3882
* @@n9:ATn9. Set language to Fortran--90.
3883
* @@O: ATO_. Open new output file (global scope).
3884
* @@o: ATo. Open new output file (local scope).
3885
* @@q: ATq. Turn off or on module and line information locally.
3886
* @@R: ATR_. Treat next identifier as integer-like reserved word.
3887
* @@r: ATr. Set language to Ratfor--77.
3888
* @@r9: ATr9. Set language to Ratfor--90.
3889
* @@u: ATu. Undefine an outer macro.
3890
* @@v: ATv. Overload an operator.
3891
* @@W: ATW_. Overload an identifier.
3892
* @@x: ATx. Terminate ignorable material.
3893
* @@y: ATy. End first part of change.
3894
* @@z: ATz. Begin ignorable material.
3896
Conversion to ASCII:
3897
* @@': ATquote. Convert single character to ASCII.
3898
* @@": ATdquote. Convert string to ASCII.
3900
Forward referencing:
3901
* @@[: AT[. Mark next identifier as defined in this section.
3904
* @@/*: AT/*. Begin a long verbatim comment.
3905
* @@//: AT//. Begin a short verbatim comment.
3906
* @@%: AT%. Ignore everything to next newline.
3907
* @@?: AT?. Begin a compiler directive.
3908
* @@(: ATlp. Begin a meta-comment.
3909
* @@): AT). End a meta-comment.
3912
* @@@{: ATlb. Insert left brace; suppress newlines in pretty-printing.
3915
* @@_: AT_. Force an index entry to be underlined (marked as defined).
3916
* @@-: AT-. Delete index entry for following identifier.
3917
* @@+: ATplus. Force index entry for following identifier.
3918
* @@^: AT^. Make index entry in Roman type.
3919
* @@.: ATdot. Make index entry in typewriter type.
3920
* @@9: AT9. Make index entry in format controlled by `\9'.
3923
* @@t: ATt. Put control text into TeX \hbox.
3924
* @@=: AT=. Pass control text verbatim to the output.
3927
* @@comma: ATcomma. Insert a thin space.
3928
* @@/: AT/. Insert a line break, preserving indentation.
3929
* @@\: ATbs. Insert a line break and backspace.
3930
* @@|: AT|_. Insert optional line break in an expression.
3931
* @@#: AT#. Force line break with blank line.
3932
* @@~: AT~. Cancel a line break (tie adjacent lines together).
3933
* @@&: AT&. Join left and right items.
3935
Pseudo (invisible) operators:
3936
* @@e: ATe. Invisible expression.
3937
* @@;: AT;. Invisible semicolon.
3938
* @@colon: ATcolon. Invisible colon.
3941
* @@!: AT!. Inhibit expansion for next macro.
3944
@node AT0, AT1, AT commands, AT commands
3945
@comment node-name, next, previous, up
3947
@section Debugging commands
3949
Several commands provide localized versions of the @samp{-1} and
3950
@samp{-2} options related to debugging of pretty-printing.
3952
@subsection @samp{@@0}: Turn off debugging
3956
This cancels the effect of a previous @samp{@@1} or @samp{@@2}
3957
(see @ref{AT1} and @ref{AT2}). The @samp{@@0} command should appear in a
3958
different section from the @samp{@@1} or @samp{@@2} commands.
3960
@node AT1, AT2, AT0, AT commands
3961
@comment node-name, next, previous, up
3963
@subsection @samp{@@1}: Display irreducible scraps
3967
This is a local version of the command-line option @samp{-1}
3968
(@pxref{-1}); refer to that discussion for more information.
3970
@node AT2, ATAT, AT1, AT commands
3971
@comment node-name, next, previous, up
3973
@subsection @samp{@@2}: Display detailed reductions of the scraps
3977
This is a local version of the command-line option @samp{-2}
3978
(@pxref{-2}); refer to that discussion for more information.
3980
@node ATAT, AT|, AT2, AT commands
3981
@comment node-name, next, previous, up
3983
@section Literal control characters
3985
Several commands insert specific characters.
3987
@subsection @samp{@@@@}: The character @samp{@@}
3990
@samp{@@@@} inserts the single character @samp{@@}.
3992
Don't forget to double the @samp{@@} even inside strings. For example,
3993
the @FWEB{} source line
3996
puts("'@@@@' is represented by `@@@@@@@@'");
4003
puts("'@@' is represented by `@@@@'");
4006
@node AT|,ATspace,ATAT,AT commands
4007
@comment node-name, next, previous, up
4009
@subsection @samp{@@|}: Literal vertical bar, or optional line break
4012
@cindex Bar, vertical
4013
@cindex Vertical bar
4014
In the @TeX{} (documentation) part of a section, @samp{@@|} inserts a
4015
vertical bar. This is useful inside La@TeX{} verbatim environments. (A
4016
simple bar would signal a shift into code mode, which is probably not
4017
what one wants.) For an example, see @ref{AT|_}.
4019
@cindex Line break, optional
4020
In a code part, @samp{@@|} inserts an optional line break in an
4024
@samp{f(a,b,@@|c+d,...)}.
4027
This helps @TeX{} to break the line at an appropriate place. If the
4028
line does not need to be broken, the command does nothing. [Compare
4029
@samp{@@|} with @samp{@@\} (@pxref{ATbs}) and @samp{@@/} (@pxref{AT/}),
4030
which always break the line.]
4032
@node ATspace, AT*, AT|, AT commands
4033
@comment node-name, next, previous, up
4035
@section Beginning of section
4037
Sections are begun by either @samp{@@*} or @ASP{}.
4039
@subsection @samp{@@ }: Begin minor section
4042
@cindex Section, beginning minor
4043
@ASP{}@ begins a new minor (unstarred or unnamed) section that is not entered
4044
into the Table of Contents. For example,
4047
@@ This is an example of a minor (unnamed) section. (No entry is made
4048
in the Table of Contents.)
4055
@node AT*, AT<, ATspace, AT commands
4056
@comment node-name, next, previous, up
4058
@subsection @samp{@@*}, @samp{@@*@i{n}}: Begin major section
4061
@cindex Section, beginning major
4062
@cindex Major section, beginning
4063
@cindex Table of contents, entries for
4064
@samp{@@*} begins a new major (starred) section (of level 0). The
4065
command must be followed by the name of the section (entry in the Table
4066
of Contents), followed by a period. (If a period appears in the name
4067
itself, it must be protected by braces.)
4069
@cindex Major section, optional argument for
4070
@cindex Section names, long
4071
@cindex Section names, short
4072
The section name is also used as a running head on the output pages. To
4073
deal with the possibility that the full name may be too long, the
4074
section name may be preceded by an optional argument enclosed in
4075
brackets. If it is present, the optional argument is used as the
4076
running head. (If a period appears as part of the optional argument, it
4077
must be protected by braces.)
4079
@cindex Subsection, beginning major
4080
@cindex Major subsection
4081
If @samp{@@*} is followed by a digit @i{n}, it begins a new major
4082
(sub)section of level @i{n}. This is also entered into the Table of Contents.
4083
Thus, the complete syntax to begin a major section is
4086
@@*@i{n} [Short name]Full name.
4092
@@* MAIN PROGRAM. This begins a major section (of level 0).
4098
@@*1 [Input routines\dots]A very long section name that essentially
4099
means ``input routines.'' Now follow some subroutines.
4106
For La@TeX{}, the highest permissible major level is 2 (a subsubsection).
4108
Section names can contain reasonably arbitrary @TeX{} text, including
4109
font-changing commands and other macros. However, it is necessary to
4110
understand that @emph{fragile} commands (in the sense of La@TeX{}) may
4111
not work because the section name is used in various contexts (e.g., as
4112
a page header). If a macro in a section name doesn't work properly,
4113
try preceding it with @samp{\protect}.
4115
@FWEAVE{} converts @samp{@@*} commands to section numbers. For a
4116
discussion of section numbering, see @ref{Numbering}.
4118
@node AT<, AT>, AT*, AT commands
4119
@comment node-name, next, previous, up
4121
@section Beginning of code part
4123
The code part is begun by the appearance of either @samp{@@a} or
4124
@samp{@@< @i{Module name} @@>=}.
4126
@subsection @samp{@@<}: Begin module name
4129
@cindex Module name, beginning
4130
@samp{@@<} begins a module name, which has the form
4131
@samp{@@< @i{@TeX{} text} @@>}. (Module names inside @FWEB{} macro definitions
4132
begin with @samp{@@#}, not @samp{@@<}.)
4134
@node AT>, ATA_, AT<, AT commands
4135
@comment node-name, next, previous, up
4137
@subsection @samp{@@>}: End module name
4140
@cindex Module name, ending
4141
@samp{@@>} ends a module name, of the form @samp{@@< @i{@TeX{} text} @@>}.
4143
Technically, @samp{@@>} is not a command; rather, it is a delimiter
4144
that terminates @samp{@@<}. An unmatched @samp{@@>} is simply ignored
4145
(after a warning message is issued).
4147
@node ATA_, ATa, AT>, AT commands
4148
@comment node-name, next, previous, up
4150
@subsection @samp{@@A}: Begin code part of unnamed section
4153
@cindex Code part, beginning unnamed
4154
@samp{@@A} begins the code part of an unnamed section. For example,
4157
@@ In an unnamed section, the code part begins with @samp{@@a} or @samp{@@A}.
4163
For more discussion of the distinction between @samp{@@A} and
4164
@samp{@@a}, see @ref{ATa}.
4166
@node ATa, ATB_, ATA_, AT commands
4167
@comment node-name, next, previous, up
4169
@subsection @samp{@@a}: Begin code part of unnamed section, and mark
4172
@cindex Code part, beginning unnamed
4173
@samp{@@a} begins the code part of an unnamed section (just as does
4174
@samp{@@A}), and in addition marks the next unreserved identifier it
4175
finds as defined in this section. Precisely,
4178
@samp{@@a} == @samp{@@A@@[}
4181
Originally, @FWEB{} did not contain the @samp{@@A} command, so when
4182
the functionality of automatically marking the next unreserved
4183
identifier (@pxref{AT[}) was added, it was natural to add it to @samp{@@a}. A
4184
reasonable style of coding is to always use @samp{@@a} if you don't know
4185
any better; if you sometime run into trouble, you can then change
4186
selected @samp{@@a}s to @samp{@@A}s. For example, it is appropriate to
4187
use @samp{@@a} if one codes one function per section. E.g.,
4198
Here the @samp{@@a} marks @samp{subrtn} as defined in this section; if
4199
that identifier is used elsewhere, it will be subscripted with the
4200
section number. (To turn this feature off, use @samp{-f}; see @ref{-f}.)
4201
However, if a section contains an arbitrary code fragment, the code part should
4202
probably begin with @samp{@@A}. E.g.,
4211
If one had used @samp{@@a} here, the @code{x} would have been marked as
4212
defined here, which is not what one wants.
4215
@node ATB_, ATb, ATa, AT commands
4216
@comment node-name, next, previous, up
4218
@section Control codes b--z
4220
@subsection @samp{@@B}: Suppress insertion of breakpoint command
4223
@cindex Breakpoints, suppressing
4224
@cindex Left brace, inserting
4225
This is for detailed debugging of @FWEB{} codes. It inserts a left
4226
brace and suppresses the insertion of a breakpoint command. See the
4227
discussion of @samp{@@b} in @ref{ATb}.
4229
@node ATb, ATc, ATB_, AT commands
4230
@comment node-name, next, previous, up
4232
@subsection @samp{@@b}: Insert a breakpoint command
4235
@cindex Breakpoints, inserting
4236
(Discussion to be finished. Useful only for very intimate debugging of
4237
@FWEB{} codes. In these days of safe sex, such intimacy may not be
4240
See also @ref{ATB_}.
4242
@node ATc, ATcpp, ATb, AT commands
4243
@comment node-name, next, previous, up
4245
@subsection @samp{@@c}: Set language to C
4248
The command @samp{@@c} is a shorthand for @samp{@@Lc}. For a discussion
4249
of language commands in limbo, see @ref{ATL_}.
4251
@xref{Languages} and @ref{C}.
4253
@node ATcpp, ATD_, ATc, AT commands
4254
@comment node-name, next, previous, up
4256
@subsection @samp{@@c++}: Set language to C++
4259
The command @samp{@@c++} is a shorthand for @samp{@@Lc++}. For a discussion
4260
of language commands in limbo, see @ref{ATL_}.
4262
@xref{Languages} and @ref{Cpp}.
4264
@node ATD_, ATd, ATcpp, AT commands
4265
@comment node-name, next, previous, up
4268
@cindex Outer macro, defining
4269
@subsection @samp{@@D}: Define outer macro
4271
@emph{This command begins the definition part.}
4273
@samp{@@D} defines an outer macro. For more discussion, see @ref{Outer macros}.
4280
will be tangled to the beginning of the output file as @samp{#define A 1}.
4282
@node ATd, ATE_, ATD_, AT commands
4283
@comment node-name, next, previous, up
4285
@subsection @samp{@@d}: Define outer macro, and mark
4288
@emph{This command begins the definition part.}
4290
@samp{@@d} defines an outer macro (just as @samp{@@D} does), and also marks the
4291
next identifier as defined in the present section. It is equivalent to
4294
@samp{@@d} == @samp{@@D@@[}
4300
The distinction between @samp{@@d} and @samp{@@D} is analagous to the
4301
distinction between @samp{@@a} and @samp{@@A}. @xref{ATa}.
4303
@node ATE_, ATf, ATd, AT commands
4304
@comment node-name, next, previous, up
4306
@subsection @samp{@@E}: Treat next identifier as ordinary expression (@FWEAVE{})
4309
For formatting purposes, treat the next identifier as an ordinary
4312
This command is useful in pretty-printing certain kinds of macro
4313
constructions. Further discussion is given in @ref{Macros and
4316
@node ATf, ATi, ATE_, AT commands
4317
@comment node-name, next, previous, up
4319
@subsection @samp{@@f}: Format identifier or module name
4322
@cindex Identifier, formatting
4323
@emph{This command begins the definition part.}
4328
@@f identifier old_identifier
4332
makes @FWEAVE{} treat @i{identifier} like @i{old_identifier}. For example,
4339
says to treat the variable @code{mytype} just as @code{int} is treated
4340
(e.g., as a reserved word in C or C++).
4342
Traditionally, C programmers needed to use this command to format
4343
identifiers that were defined in @code{#include} files. This annoying
4344
redundancy has now been eliminated by means of the @samp{-H} command,
4345
which tells @FWEAVE{} to scan @code{#include} files automatically.
4348
The @i{old_identifier} may be one of the following special names, which
4349
insert extra spaces according to the positions of the underscores and
4350
behave as the part of speech indicated by the base names:
4361
These are useful for dealing with certain macro constructions. For
4367
@@m ADD(x, y) ((x) PLUS (y))
4370
Without the format command, the @samp{ADD} macro will pretty-print
4371
without spaces before and after the @samp{PLUS}.
4373
When the current language is @TeX{}, the format command can be used to
4374
change a category code according to the format
4377
@@f `TeXchar new_cat_code
4381
Difficulties may ensue if one try to change the category code of
4382
@samp{@@} in this way; a fully operational @sc{web} for @TeX{} is quite
4383
difficult and has been neither accomplished nor attempted.
4385
@node ATi, ATI_, ATf, AT commands
4386
@comment node-name, next, previous, up
4388
@subsection @samp{@@i}: Include file (unconditional)
4391
@cindex File, including web
4399
the file @file{test.hweb} is inserted at the present point of the web file. By
4400
default, the current directory is searched. Files can be included from
4401
other directories by means of the @code{FWEB_INCLUDES} environment variable
4402
and/or the @samp{-I} command-line option.
4403
See @ref{Environment variables} and @ref{-I_}.
4405
In principle, the included file may contain any fragment of source text.
4406
However, it is best to make it a complete section (begun by @samp{@@*}
4407
or @ASP{}) if at all possible.
4409
Unfortunately, the @samp{@@i} command cannot be commented out or
4410
conditionally included by use of an @FWEB{} preprocessor command.
4411
That is because @samp{@@i} is processed very early in the parsing
4412
process. (Consider: @samp{@@i} could include @TeX{} text, but the
4413
preprocessor is only active in the definition and code parts.)
4415
Include commands may be nested to a depth set by the option
4416
@samp{-yid}. @xref{-yid}.
4418
@cindex Include file, printing name of
4420
@cindex Include file, formatting name of
4422
In the woven output, if a section comes from an include file, the name
4423
of the include file is printed in square brackets as the first text of
4424
the @TeX{} part. To inhibit printing of that name, say
4430
in the limbo section. To change the way that name is formatted,
4431
redefine the macro @samp{\WIFfmt}, whose single argument is the name of
4432
the include file. (It is not called when there is no current include
4433
file.) The default definition is
4436
\def\WIFfmt#1@{[@{\tt#1@}]@}
4440
@node ATI_, ATK_, ATi, AT commands
4441
@comment node-name, next, previous, up
4443
@subsection @samp{@@I}: Include file (conditional)
4446
@cindex File, including web
4447
This command behaves like @samp{@@i} if the command-line option
4448
@samp{-i} is not used. If it is used, then the contents of the included
4449
file is not printed in the woven output.
4450
@xref{-i} and @ref{-i!}.
4452
@node ATK_, ATk, ATI_, AT commands
4453
@comment node-name, next, previous, up
4455
@subsection @samp{@@K}: Extract global RCS-like keyword
4457
The construction @samp{@@K @i{Keyword} @@>} accesses the value of a global
4458
RCS-like keyword. (For more discussion of such keywords, see @ref{ATz}.)
4459
The command is treated differently by @FTANGLE{} and @FWEAVE{}
4460
depending on its location in the source file.
4462
@FWEAVE{} will expand the construction
4463
in the limbo section and @TeX{} parts only. The value is not surrounded
4474
\def\ID@{Id = \.@{"@@K Id @@>"@}@}
4476
@@ \ID. This is a @@K Id @@>.
4484
@@ \ID. This is a test.
4487
and when La@TeX{} is run the macro @code{\ID} will expand to @samp{Id =
4488
\.@{"Test"@}}. The quotes are not necessary in the macro definition;
4489
they are included only to emphasize that in this (limbo) context the
4490
@samp{@@K} construction can effectively be put inside a string. This is
4491
possible because the routine that copies the limbo section simply copies
4492
characters; it does not tokenize anything.
4494
@FWEAVE{} does not expand @samp{@@K} constructions in the definition
4495
or code parts; it merely gives them a symbolic representation.
4497
@FTANGLE{}, on the other hand, expands @samp{@@K} constructions in the
4498
definition or code parts (during input). The values are surrounded by
4499
quotes. (As usual, @FTANGLE{} ignores material in the limbo section
4502
For @FTANGLE{}, the built-in function @samp{$KEYWORD}
4503
(@pxref{$KEYWORD}) behaves essentially as does @samp{@@K}, except that
4504
it is expanded during output, not input. @FWEAVE{} does not expand
4507
The command @samp{@@k} behaves as does @samp{@@K} except that it
4508
accesses local keywords, not global ones. @xref{ATk}.
4510
@node ATk, ATL_, ATK_, AT commands
4511
@comment node-name, next, previous, up
4513
@subsection @samp{@@k}: Access local RCS-like keyword
4515
The construction @samp{@@k keyword} behaves as @samp{@@K} does
4516
(@pxref{ATK_}), except it accesses local keywords (defined at the top of
4519
@node ATL_, ATl, ATk, AT commands
4520
@comment node-name, next, previous, up
4522
@subsection @samp{@@L}: Set language
4525
@cindex Language, setting
4526
@samp{@@Ll} sets the language to @i{l}, where @i{l} is one of
4527
@samp{@{c,c++,n,n9,r,r9,v,x@}}.
4530
There are shorthand forms of this command for some languages; see
4531
@samp{@@c} (@ref{ATc}), @samp{@@c++} (@ref{ATcpp}), @samp{@@n}
4532
(@ref{ATn}), @samp{@@n9} (@ref{ATn9}), @samp{@@r} (@ref{ATr}), and
4533
@samp{@@r9} (@ref{ATr9}).
4535
Generally, the global language should be set in the limbo section by
4536
means of @samp{@@L}, @samp{@@c}, etc.@ rather on the command line by
4537
options such as @samp{-L} or @samp{-c}.
4539
@node ATl, ATM_, ATL_, AT commands
4540
@comment node-name, next, previous, up
4542
@subsection @samp{@@l}: Specify limbo text
4545
@emph{This command begins the definition part.}
4547
Limbo text is material that @FWEAVE{} should output before
4548
the start of the first section.
4553
@@l "\\def\\A@{abc@}"
4556
Note that @samp{\\} stands for a backslash. In general, characters must be
4557
escaped just as in C [so that one can include things like @samp{\n}
4558
(newline) in the definitions].
4560
Limbo text may also be typed directly into the limbo section; in that
4561
case, no escapes are necessary since one is typing ordinary @TeX{} text.
4562
Sometimes, however, the @samp{@@l} command is useful for pedagogical
4563
purposes, as the limbo material can then be defined at the point where
4564
the logical discussion is made.
4566
@node ATM_, ATm, ATl, AT commands
4567
@comment node-name, next, previous, up
4569
@subsection @samp{@@M}: Define @FWEB{} macro
4572
@emph{This command begins the definition part.}
4574
For a detailed discussion of @FWEB{} macros, see @ref{Macros}.
4576
@node ATm, ATN_, ATM_, AT commands
4577
@comment node-name, next, previous, up
4579
@subsection @samp{@@m}: Define @FWEB{} macro, and mark
4582
@emph{This command begins the definition part.}
4584
@samp{@@m} defines an @FWEB{} macro, and also marks the next identifier
4585
as defined here. It is equivalent to
4588
@samp{@@m} == @samp{@@M@@[}
4593
For a detailed discussion of @FWEB{} macros, see @ref{Macros}.
4595
The distinction between @samp{@@m} and @samp{@@M} is analagous to the
4596
distinction between @samp{@@a} and @samp{@@A}. @xref{ATa}.
4598
@node ATN_, ATn, ATm, AT commands
4599
@comment node-name, next, previous, up
4601
@subsection @samp{@@N}: Turn on N mode
4604
@emph{This command must appear before the code part.} Generally, this
4605
means immediately before @samp{@@a}. @emph{Do not use this command in
4606
limbo; use @samp{@@Lv} instead.}
4608
The N mode invokes language-independent behavior within the scope of
4609
a particular language. The scoping rules are the same as for language
4610
changes; i.e., using @samp{@@N} within a given section produces
4611
language-independent behavior for that section and for any modules first
4612
referenced in that section.
4614
Fundamentally, @dfn{language-independent} behavior essentially means a literal
4615
transcription of the input to the output. For example, it inhibits
4616
blank compression by @FTANGLE{} and tells @FWEAVE{} to turn off
4617
``pretty-printing'' (instead, the output is printed in typewriter type
4618
within a @samp{\begin@{verbatim@}...\end@{verbatim@}} environment).
4620
There are some subtleties with this mode (not to mention the likelihood
4625
@FWEB{} macros and built-in
4626
functions will normally be expanded even in the N mode. To inhibit
4627
expansion of a particular identifier, place @samp{@@!} before the
4628
identifier. For example,
4639
expands to @samp{A = 1}.
4642
Blank lines are significant. The N mode is ended by the appearance of
4643
the @samp{@@*} or @ASP{} denoting the start of the next section. If
4644
that were preceded by one or more blank lines, those would show up in
4645
both the tangled and woven output. They might or might not be
4646
significant in the tangled output, but they almost certainly will look
4647
ugly in the woven output. To avoid this, use the command @samp{@@%%},
4648
which deletes the remainder of the current line and all immediately
4649
following empty lines. For example,
4663
If the N mode is invoked from a compiler-like language such as @sc{Fortran},
4664
cross-referencing of variables is done as usual. However, if the
4665
language is @sc{verbatim} (which turns on the N mode automatically), no
4666
cross-referencing is done. (Identifiers are still recognized according
4667
to @FWEB{}'s rules. Those rules as currently implemented may be
4668
essentially meaningless for some languages; in the future, provision may
4669
be made for generalizing these rules by the user.) To force an
4670
identifier to be placed into the Index, precede it by @samp{@@+}.
4673
A module name must be within the scope of an @samp{@@N} the first time
4674
the name is seen, if it is ever to be within such scope. Thus, the
4675
following does not work properly:
4678
@@ Consider the module @@<Test@@>. (Not yet within scope of \.@{@@N@}.)
4686
What happens is that the N mode is not restored after the code-part use
4687
of @samp{@@<Test@@>}. This is a bug. There are very tricky design
4688
issues to be dealt with here.
4692
@node ATn, ATn9, ATN_, AT commands
4693
@comment node-name, next, previous, up
4695
@subsection @samp{@@n}: Set language to @sc{Fortran}--77
4698
@sc{Fortran}-77 is @FWEB{}'s default language, so this command is usually not
4699
strictly necessary. However, it is good practice to include it, so a
4700
user looking at the @code{web} file can tell immediately what language
4701
it is supposed to process.
4703
For more discussion of languages, see @ref{ATL_} and @ref{Languages}.
4705
@node ATn9, ATO_, ATn, AT commands
4706
@comment node-name, next, previous, up
4708
@subsection @samp{@@n9}: Set language to @sc{Fortran}--90
4711
For more discussion of languages, see @ref{ATL_} and @ref{Languages}.
4713
For hints about @FWEB{} programming in @sc{Fortran}, see @ref{Fortran}.
4715
@node ATO_, ATo, ATn9, AT commands
4716
@comment node-name, next, previous, up
4718
@subsection @samp{@@O}: Open output file (global scope)
4721
@cindex File, opening output
4722
A statement of the form
4725
@@O @i{new_output_file_name}
4729
changes the name of @FTANGLE{}'s output file. This change remains
4730
in effect for the duration of the file, or until another @samp{@@O} is
4731
encountered. (If that occurs, the previously open file is closed.)
4733
This command is expanded during output, so it must appear in the code part.
4735
For an example of using the @samp{@@O} command to produce both C header
4736
files (@samp{.h}) and source files (@samp{.c}), see the discussion in
4739
To change the name of the output file locally (for just the present
4740
section), see @ref{ATo}.
4742
@node ATo, ATq, ATO_, AT commands
4743
@comment node-name, next, previous, up
4745
@subsection @samp{@@o}: Open output file (local scope)
4748
@cindex File, opening output
4749
This behaves like @samp{@@O}, except that the new file name is in effect only
4750
for the current section. A subsequent @samp{@@o} issued in a different
4751
section but for the same file name accretes material to the file.
4753
An annoying problem arises in C programming when @samp{@@o}s are used to create
4754
multiple source files that are subsequently compiled under the control
4755
of a @code{Makefile}. Remember that by default line-number information
4756
is written into the C files. This means that a change in the @code{web}
4757
file code for one source file can affect all of the others, because the
4758
line numbering in the @code{web} file changes. Therefore, a trivial change to
4759
the code for just one source file can cause all of the others to be
4762
As long as one desires debugging information relative to the original
4763
@code{web} file, there is really no solution to this problem; one needs
4764
the proper line information in each file in order to work with the
4765
debugger, so if line numbers change the sources must be recompiled. One
4766
can, of course, turn off the line numbering with the command-line option
4767
@samp{-#} (@pxref{-#}), but then debugger statements will refer to the
4768
tangled C code, which is undesirable. A better partial solution is to
4769
use @samp{@@q} (@pxref{ATq}) to turn off the line numbering for output
4770
code that is currently stable. In the following example, the code for
4771
each file is put into a module, then the modules are output in the
4772
unnamed section; it is assumed that the programmer is currently
4773
making changes to the code for @file{file2.c}:
4789
For very large projects, another solution is to maintain multiple
4790
@code{web} source files. To avoid losing the substantial benefits of
4791
the automatic index, refer to the discussion in @ref{Merging indexes} to
4792
learn how to create a master index that contains information about
4793
several @code{web} files.
4796
@node ATq, ATR_, ATo, AT commands
4797
@comment node-name, next, previous, up
4799
@subsection @samp{@@q}: Turn off module and line info locally
4802
@cindex Line numbering, turning off
4803
The command-line option @samp{-#} (@pxref{-#}) turns off comments about
4804
module and line numbers globally, for the entire code. However, in some
4805
cases one wants to turn that off in just a small block of code. One
4806
important example arises in @sc{Fortran}. Consider
4811
x = @@<Some action@@>
4818
This example will tangle to something like
4829
Unfortunately, the information comments have created invalid code that
4832
The @samp{@@q} command solves this problem by turning off or on the
4833
information comments locally. @samp{@@q0} turns them off; @samp{@@q1}
4834
turns them on. Thus, if one rewrites the above example as
4840
x = @@<Some action@@>
4852
For another use of the @samp{@@q} command, see @ref{ATo}.
4854
@node ATR_, ATr, ATq, AT commands
4855
@comment node-name, next, previous, up
4857
@subsection @samp{@@R}: Treat next identifier as integer-like reserved
4861
For formatting purposes, treat the next identifier as an integer-like
4864
This command is useful in pretty-printing certain kinds of macro
4865
constructions. Further discussion is given in @ref{Macros and
4868
@node ATr, ATr9, ATR_, AT commands
4869
@comment node-name, next, previous, up
4871
@subsection @samp{@@r}: Set language to @sc{Ratfor}--77
4874
@xref{ATL_} and @ref{Languages}.
4876
@node ATr9, ATu, ATr, AT commands
4877
@comment node-name, next, previous, up
4879
@subsection @samp{@@r9}: Set language to @sc{Ratfor}--90
4882
@xref{ATL_} and @ref{Languages}.
4884
@node ATu, ATv, ATr9, AT commands
4885
@comment node-name, next, previous, up
4887
@subsection @samp{@@u}: Undefine outer macro
4890
@cindex Outer macros, undefining
4891
@emph{This command begins the definition part.}
4893
@samp{@@u} is the inverse of @samp{@@d}. For example, in C the command
4894
@samp{@@u A} tangles to @samp{#undef A}.
4896
@node ATv, ATW_, ATu, AT commands
4897
@comment node-name, next, previous, up
4899
@subsection @samp{@@v}: Overload operator
4902
@cindex Operators, overloading
4903
@emph{This command begins the definition part.}
4905
@samp{@@v} is used to change the woven appearance of an operator. If
4906
one defines a new operator, for example by a statement such as
4909
interface operator(.BETA.)
4912
in @sc{Fortran}-90, one should also use an @samp{@@v} in the definition
4916
@@v .BETA. "\\beta" +
4919
For a detailed discussion of overloading (the output appearance of)
4920
operators, see @ref{Overloading}.
4922
@node ATW_, ATx, ATv, AT commands
4923
@comment node-name, next, previous, up
4925
@subsection @samp{@@W}: Overload identifier
4928
@cindex Identifiers, overloading
4929
@emph{This command begins the definition part.}
4931
For a detailed discussion of overloading (the output appearance of)
4932
identifiers, see @ref{Overloading}.
4934
@node ATx, ATy, ATW_, AT commands
4935
@comment node-name, next, previous, up
4937
@subsection @samp{@@x}: Terminate ignorable material, or begin material to be changed
4940
In a change file, this command begins material to be changes; see
4943
In @code{web} source files, this command has a different use;
4944
see the discussion of the @samp{@@z} command (@pxref{ATz}).
4946
@node ATy, ATz, ATx, AT commands
4947
@comment node-name, next, previous, up
4949
@subsection @samp{@@y}: Begin change material
4952
The @samp{@@y} command is permitted only in change files. @xref{Change
4955
@node ATz, ATquote, ATy, AT commands
4956
@comment node-name, next, previous, up
4958
@subsection @samp{@@z}: Begin ignorable material, or terminate change
4961
@FWEB{} files may begin with the construction
4971
where the @samp{@@z} occupies the very first two characters of the file, and
4972
where the @samp{@@z} and @samp{@@x} must begin in column 1.
4973
Material between the @samp{@@z} and @samp{@@x} is @dfn{pure commentary} and is
4974
ignored by both processors, with one exception.
4980
@cindex RCS-like keyword
4981
@cindex Keyword, RCS-like
4982
The exception is that an RCS-like line (RCS stands for
4983
``revision-control system'') with syntax
4986
$Keyword: Text of Keyword $
4989
(at least one blank after the colon, and at least one before the last
4990
dollar sign; @sc{unix} users, see @samp{man ident}) is parsed, and the
4991
text of the @code{Keyword} is made
4992
available to the control codes @samp{@@K} (@pxref{ATK_}) and @samp{@@k}
4993
(@pxref{ATk}) as well as to @FTANGLE{}'s built-in function @code{$KEYWORD}
4996
A distinction is made between keywords that are found in the ignorable
4997
commentary at the beginning of the master web file, which are called
4998
@dfn{global keywords}, and ones that are found at the beginning of files
4999
included via @samp{@@i}, which are called @dfn{local keywords}.
5001
The commands that access RCS-like keywords function as follows:
5006
@samp{$KEYWORD(Keyword)} accesses a global keyword. It is a built-in
5008
expanded by @FTANGLE{} (during output) into the quoted character
5009
string @code{"Text of Keyword"}.
5012
@samp{@@K} and @samp{@@k} are expanded during input. @samp{@@K}
5013
accesses a global keyword, whereas @samp{@@k} accesses a local keyword.
5016
In the limbo section or a @TeX{} part, @FWEAVE{} will expand @samp{@@K
5017
Keyword @@>} into @code{Text of Keyword} (without the surrounding
5018
quotes), and similarly for @samp{@@k}. (The intention is that the
5019
expanded text can be used as bodies of @TeX{} macros.)
5020
@FWEAVE{} will also print the
5021
values of global keywords at the end of its output, whether or not they
5022
are referenced by @samp{@@K}.
5025
Elsewhere @FWEAVE{} will just print the keyword name itself,
5026
surrounded by double angle brackets. If the keyword was local
5027
(@samp{@@k}), the brackets will carry the subscript 0.
5030
@FTANGLE{} treats the global command @samp{@@K Keyword @@>}
5031
essentially like it does @samp{$Keyword}, except that the construction
5032
is expanded on input rather than output.
5035
@FTANGLE{} expands the command @samp{@@k keyword @@>} on input,
5036
generating a quoted string containing the value of the local keyword.
5041
The command @samp{@@z} is also used in change files to end a change.
5042
@xref{Change files}.
5044
@node ATquote, ATdquote, ATz, AT commands
5045
@comment node-name, next, previous, up
5047
@section Conversion to ASCII
5049
@cindex ASCII, converting to
5050
Several commands are useful for generating machine-independent code.
5051
For example, @FWEB{} works internally with the ASCII character set, so
5052
uses these commands heavily to convert from the possibly non-ASCII
5053
native character set of the machine on which @FWEB{} is running.
5055
@subsection @samp{@@'}: Convert character to ASCII
5058
The construction @samp{@@'c'} converts @samp{c} to its ASCII value. In
5059
C and C++, it is converted to octal; for example, @samp{@@'A'} is output
5060
as @samp{0101}. In @sc{Fortran} and @sc{Ratfor}, it is converted to decimal; the
5061
previous example would be output as @samp{65}.
5063
If the native character set of one's machine is ASCII, the conversion
5064
will not be done unless the @samp{-A} command-line option is used.
5067
@node ATdquote, AT[, ATquote, AT commands
5068
@comment node-name, next, previous, up
5070
@subsection @samp{@@"}: Convert string to ASCII
5073
The construction @samp{@@"abc"} converts the enclosed string to its ASCII
5074
representation. For example, in C and C++
5075
@samp{@@"abc"} will be output as @samp{"\141\142\143"}.
5078
In @sc{Fortran} and @sc{Ratfor}, no such simple mechanism exists in the
5079
language, so a function call is issued. For example, the previous
5080
example would be output as @samp{ASCIIstr('abc')}. The user is
5081
responsible for defining the function @samp{ASCIIstr}. The name of this
5082
function can be changed by the style-file entry @samp{ASCII_fcn}.
5085
If the native character set of one's machine is ASCII, the conversion
5086
will not be done unless the @samp{-A} command-line option is used.
5089
@node AT[, AT/*, ATdquote, AT commands
5090
@comment node-name, next, previous, up
5092
@section Forward referencing
5094
@cindex References, forward
5096
@subsection @samp{@@[}: Mark as defined
5099
This command marks the next (non-reserved) identifier that appears after
5100
the @samp{@@[} as being defined in the current section. It is usually
5101
issued automatically; for example, @samp{@@a} is equivalent to
5102
@samp{@@A@@[}, @samp{@@d} is equivalent to @samp{@@D@@[}, and @samp{@@m}
5103
is equivalent to @samp{@@M@@[}.
5105
If the appropriate style-file parameter @code{mark_defined.???} is 1,
5106
this command causes any appearance of the identifier to be subscripted
5107
with a section number. For more information, see @ref{Subscript params}.
5109
The utility of this command can be seen from the characteristic
5113
@@ This is section 5.
5114
@@a @@% Issues an implicit @@[, which marks |test| as defined in section 5.
5119
@@ This is section 6.
5122
call test // This will print as $|test|_5$.
5126
The @samp{@@[} command should be distinguished from @samp{@@_}
5128
latter causes the index entry for the identifier to be underlined; the
5129
former possibly causes the identifier to be subscripted by a section
5130
number. One may wish to turn off the subscripts because they become too
5131
cluttered; however, the underlined index entries remain useful and
5134
@node AT/*, AT//, AT[, AT commands
5135
@comment node-name, next, previous, up
5139
@FWEB{} supports a variety of commenting styles borrowed from C, C++,
5140
and @TeX{}. For more discussion, see @ref{Comments}.
5144
@subsection @samp{@@/*}: Begin long verbatim comment
5147
The following comment is copied to the tangled output. (By default,
5148
comments are not copied.) If you desire all comments to be so copied,
5149
use @samp{-v}. @xref{-v}.
5151
@node AT//, AT%, AT/*, AT commands
5152
@comment node-name, next, previous, up
5154
@subsection @samp{@@//}: Begin short verbatim comment
5157
See the discussion of @samp{@@/*} in @ref{AT//}.
5159
@node AT%, AT?, AT//, AT commands
5160
@comment node-name, next, previous, up
5162
@subsection @samp{@@%}: Ignorable comment
5166
@cindex Comments, ignorable
5167
If any line in a web source code contains the command @samp{@@%}, all
5168
remaining material on that line (to and including the newline character)
5169
is ignored by the input driver and never processed at all.
5171
A stronger form of this command is @samp{@@%%}. This deletes the
5172
current line as well any empty lines that immediately follow. This command
5173
is particularly useful when the N mode is in effect. @xref{ATN_}.
5175
Line-numbering problems can arise when these commands are used. For a
5176
discussion, see @ref{-T#}.
5178
@node AT?, ATlp, AT%, AT commands
5179
@comment node-name, next, previous, up
5181
@subsection @samp{@@?}: Begin compiler directive
5184
@cindex Compiler directives
5185
The remainder of the line is processed as a compiler directive. Optional
5186
material may be inserted automatically at the beginning of the tangled
5187
output line by means of the style-file option @code{cdir_start}.
5188
@xref{Miscellaneous params}.
5190
@node ATlp, AT), AT?, AT commands
5191
@comment node-name, next, previous, up
5193
@subsection @samp{@@(}: Begin meta-comment
5196
Material between @samp{@@(} and @samp{@@)} is treated in the N mode.
5206
Style-file parameters allow optional material to be insert at the
5207
beginning and end of the meta-comment, and at the beginning of each line
5208
of output. For more information, see the style-file parameters
5209
beginning with @samp{meta} (@pxref{Miscellaneous params}).
5211
@node AT), ATlb, ATlp, AT commands
5212
@comment node-name, next, previous, up
5214
@subsection @samp{@@)}: End meta-comment
5217
See the discussion of @samp{@@(}, @ref{ATlp}.
5219
@node ATlb, AT_, AT), AT commands
5220
@comment node-name, next, previous, up
5222
@section Special left brace
5224
The command @samp{@@@{} is useful in C/C++ programming to beautify some
5225
of the pretty-printing. It translates into a left brace, but also
5226
suppresses the automatic insertion of newlines into the subsequent
5227
function body or block. This is desirable for very short functions, such
5228
as simple constructors in C++. For example,
5237
C(int i0) @@@{i = i0;@}
5241
Here the function will be typeset as
5248
rather than the default
5257
@node AT_, AT-, ATlb, AT commands
5258
@comment node-name, next, previous, up
5260
@section Index entries
5262
@cindex Indexing commands
5263
Although most information for the Index is gathered automatically, in
5264
some situations it must be done by hand.
5266
@subsection @samp{@@_}: Force index entry to be underlined
5269
@cindex Index entries, underlining
5270
This command applies to the next identifier that appears after the
5271
@samp{@@_}. The index entry for that identifier will be underlined.
5272
(By convention, this means `defined' or `declared'.)
5274
This command is usually issued automatically. For example, the index
5275
entries for the variables @samp{i} and @samp{j} in the C statement
5276
@samp{int i, j;} will be underlined, since @FWEAVE{} understands
5277
enough of the syntax to know that variables are being defined. Macro
5278
definitions (begun by
5279
@samp{@@D} or @samp{@@M}) will also be underlined automatically.
5281
@node AT-, ATplus, AT_, AT commands
5282
@comment node-name, next, previous, up
5284
@subsection @samp{@@-}: Delete index entry
5287
@cindex Index entries, deleting
5288
This command applies to the next identifier that appears after the
5289
@samp{@@-}; it prevents an index entry associated with that identifier
5290
from being made. This might be useful when the N mode is in effect.
5292
@node ATplus, AT^, AT-, AT commands
5293
@comment node-name, next, previous, up
5295
@subsection @samp{@@+}: Force index entry
5298
@cindex Index entries, forcing
5299
This command applies to the next identifier that appears after the
5300
@samp{@@+}; it forces an index entry for that identifier. It is
5301
particularly useful when the language is @sc{verbatim}, since
5302
cross-referencing is turned off in that case.
5304
@node AT^, ATdot, ATplus, AT commands
5305
@comment node-name, next, previous, up
5307
@subsection @samp{@@^}: Make index entry (Roman type)
5310
@cindex Index entries, Roman type
5311
To insert one's own index entry in Roman type, say @samp{@@^@i{My entry}@@>}.
5313
@node ATdot, AT9, AT^, AT commands
5314
@comment node-name, next, previous, up
5316
@subsection @samp{@@.}: Make index entry (typewriter type)
5319
@cindex Index entries, typewriter type
5320
To insert one's own index entry in typewriter type, say @samp{@@.@i{My
5323
@node AT9, ATt, ATdot, AT commands
5324
@comment node-name, next, previous, up
5326
@subsection @samp{@@9}: Make index entry (user-defined format)
5329
@cindex Index entries, user format
5330
The construction @samp{@@9@i{Text}@@>} is used to create an index entry in a
5331
format defined by the user. It is associated with the macro @code{\9}, which
5332
will be called during @TeX{}'s processing of the Index as
5333
@code{\9@{@i{Text}@}}. The user must define @code{\9} according to the format
5339
where argument @samp{#1} is the text between @samp{@@9} and @samp{@@>}.
5340
For example, to print that text in a sans serif font, say
5343
\def\9#1@{@{\sf #1@}@}
5346
(Note the extra level of braces to prevent the font command from propagating.)
5348
@node ATt, AT=, AT9, AT commands
5349
@comment node-name, next, previous, up
5351
@section Control text
5353
@cindex Control text
5354
@cindex Text, control
5355
@dfn{Control text} is material terminated by @samp{@@>}; it must be all
5356
on one line and must not contain any @samp{@@}s.
5358
@subsection @samp{@@t}: Put control text into a @TeX{} \hbox (@FWEAVE{})
5361
When @FWEAVE{} sees the command @samp{@@t@i{control text}@@>}, it packages
5362
the control text into an @code{\hbox} and ships it to the output. This
5363
command is ignored by @FTANGLE{}.
5365
@node AT=, ATcomma, ATt, AT commands
5366
@comment node-name, next, previous, up
5368
@subsection @samp{@@=}: Pass control text verbatim to the output
5371
For @FTANGLE{}, the command @samp{@@=@i{control text}@@>} sends the control
5372
text to the output exactly as input. @FWEAVE{} highlights the control
5373
text by drawing a box around it.
5375
@node ATcomma, AT/, AT=, AT commands
5376
@comment node-name, next, previous, up
5380
@cindex Spacing commands
5382
The spacing commands are used to refine @FWEAVE{}'s pretty-printed
5383
output. Generally it's not necessary to bother with these until one is
5384
putting the final touches on a code.
5386
@subsection @samp{@@,}: Insert a thin space
5389
@cindex Spacing, thin space
5390
Extra spacings are sometimes necessary when working with unusual macro
5391
constructions. @samp{@@,} inserts a thin space, analogous to @TeX{}'s
5394
An example where explicit spacing would be necessary is as follows:
5400
@@m A(x,y) x @@, OP @@, y
5407
Without the @samp{@@,}'s, the body of the @code{A} macro will weave as
5408
the unappealing @samp{xOPy}. This occurs because although @code{OP} is
5409
defined to be a binary operator, @FWEAVE{} thinks of it as just a mere
5410
expression, and one of its fundamental production rules is to
5411
concatenate expressions with no intervening expressions.
5413
This demonstrates that situations arise in which one needs to override
5414
@FWEAVE{}'s default processing. But for the above example, there is
5415
actually a better solution. Instead of using the @samp{@@,}'s, include
5416
the format command @samp{@@f OP $_BINOP_}. @xref{ATf}.
5418
@node AT/, ATbs, ATcomma, AT commands
5419
@comment node-name, next, previous, up
5421
@subsection @samp{@@/}: Force a line break, preserving indentation.
5424
@cindex Line break, forcing
5425
This command is used to override @FWEAVE{}'s natural inclinations.
5426
For example, if one wants each piece of a declaration to appear on a
5427
separate line, one can say
5436
This command preserves the natural indentation that would have happened
5437
if @FWEAVE{} or La@TeX{} had broken a long line spontaneously. Thus, the
5438
declared variables are indented in the above example. To remove that
5439
indent, use @samp{@@\} instead. @xref{ATbs}.
5441
Try to use the line-break commands sparingly---i.e., let @FWEAVE{} do
5443
Often, if lines run together in an unexpected or unreadable way,
5444
it's because @FWEAVE{} wasn't able to parse the relevant block of
5445
code, perhaps because it didn't understand that some variable in an
5446
include file has a special meaning. In such cases, trying to fix things
5447
with @samp{@@/} is the wrong solution. Either use @samp{@@f}
5448
(@pxref{ATf}) or @samp{-H} (@pxref{-H_}).
5450
Distinguish the @samp{@@/} command from @samp{@@|} (@pxref{AT|}), which
5451
inserts an optional breakpoint into an expression.
5453
@node ATbs, AT|_, AT/, AT commands
5454
@comment node-name, next, previous, up
5456
@subsection @samp{@@\}: Force a line break, then indent
5459
@cindex Line break, forcing with indent
5460
The @samp{@@\} command behaves like @samp{@@/} (@pxref{AT/}), except
5461
that it backspaces one notch after the line break. This usually has the
5462
effect of undoing the natural indentation that would have been inserted
5463
had a long line been spontaneously broken. One common case where the
5464
@samp{@@\} command might be used would be to put the return type of a C
5465
function on a separate line:
5473
It would be nice to have @FWEAVE{} do that automatically.
5474
Unfortunately, the syntax of a function isn't recognized until the
5475
opening braces are sensed; by that time, the declaration part of the
5476
statement has already been processed. This is one example of the fact
5477
that the @FWEB{} processors are much less intelligent and sophisticated
5478
than language compilers. A clever (and simple) idea for getting around
5479
this kind of problem is lacking at this point.
5481
@node AT|_, AT#, ATbs, AT commands
5482
@comment node-name, next, previous, up
5484
@subsection @samp{@@|}: Literal vertical bar, or optional line break
5487
@cindex Bar, vertical
5488
@cindex Vertical bar
5489
In the @TeX{} (documentation) part of a section, @samp{@@|} inserts a
5490
vertical bar. Here's a La@TeX{} example:
5494
The constructions @@|x@@| and |x| are very different.
5499
You might wish to try this out to see what @FWEAVE{} produces.
5501
@cindex Line break, optional
5502
In a code part, @samp{@@|} inserts an optional line break in an expression.
5504
@node AT#, AT~, AT|_, AT commands
5505
@comment node-name, next, previous, up
5507
@subsection @samp{@@#}: Blank line
5510
@samp{@@#} forces a line break with some extra vertical white space.
5512
that @emph{blank lines in the source are significant}, so this command should
5513
seldom if ever be necessary.
5515
if @samp{@@#} is immediately followed by a letter (e.g., @samp{@@#if}),
5516
it is assumed that a preprocessor command is beginning. @xref{Preprocessing}.
5519
@node AT~, AT&, AT#, AT commands
5520
@comment node-name, next, previous, up
5522
@subsection @samp{@@~}: Cancel line break
5525
@cindex Line break, canceling
5526
@samp{@@~} is analogous to @TeX{}'s @samp{~} (tie); it prevents a line
5527
break, which @FWEAVE{} usually inserts after each complete statement
5528
it recognizes. For example,
5531
printf("Working..."); @@~ fflush(stdout);
5535
@node AT&, ATe, AT~, AT commands
5536
@comment node-name, next, previous, up
5538
@subsection @samp{@@&}: Join items
5541
@cindex Joining items
5542
@cindex Items, joining
5543
During @FWEAVE{}'s output, @samp{@@&} joins the items to either side
5544
with no spaces or line breaks inbetween.
5546
This command must be distinguished from the preprocessor construction
5547
@code{##} (paste tokens together). In a macro definition, @samp{a##bc}
5548
creates the single identifier @samp{abc}. If one said @samp{a@@&bc},
5549
two identifiers would be output with no spaces separating them. In
5550
simple cases, the results may look identical, but consider how things
5551
would differ if @code{abc} were itself an @FWEB{} macro that should
5554
@node ATe, AT;, AT&, AT commands
5555
@comment node-name, next, previous, up
5557
@section Pseudo (invisible) operators
5559
@cindex Pseudo-operators
5560
@cindex Operators, pseudo-
5561
Pseudo- or invisible operators are ignored by @FTANGLE{} and not
5562
printed by @FWEAVE{}; however, they retain grammatical significance
5563
that helps out @FWEAVE{} in its attempts to understand the syntax.
5565
@subsection @samp{@@e}: Pseudo-expression
5567
@cindex Pseudo-expression
5568
@cindex Expression, pseudo
5570
@samp{@@e} is an invisible expression (`pseudo-expression')
5571
(@pxref{Pseudo-operators}). It is
5572
sometimes useful in situations where @FWEAVE{}'s pretty-printing has
5573
broken down because it didn't properly understand the language syntax.
5574
If, for example, @FWEAVE{} failed to properly parse the C statement
5581
one might get things to work properly by saying
5587
In this particular case, one is patching up a deficiency (all right, a
5588
bug) in @FWEAVE{}'s ``production rules.'' (This particular bug may no
5589
longer exist.) However, there are other situations in which the use of
5590
@samp{@@e} might be necessary. Consider, for example, the C macro
5597
Here the replacement text of the macro is @samp{= x}, which by itself is
5598
not a valid construction in C. When the @samp{-1} or @samp{-2} options
5599
are used, @FWEAVE{} will report an ``irreducible
5600
scrap sequence'' in this situation (although it may typeset it correctly
5601
anyway). To eliminate the warning message, say instead
5604
#define A(x) @@e = x
5607
Now the fragment @samp{@@e = x} is interpreted as a valid expression.
5609
@node AT;, ATcolon, ATe, AT commands
5610
@comment node-name, next, previous, up
5612
@subsection @samp{@@;}: Pseudo-semicolon
5614
@cindex Pseudo-semicolon
5615
@cindex Semicolon, pseudo
5617
@samp{@@;} is an invisible semicolon. These are often used in C
5618
programming to terminate a module name that expands to a compound
5619
statement. Carefully compare the uses of @samp{@@;} and @samp{;} in the
5626
@@<Compound statement@@>@@;
5628
@@<Simple statement@@>;
5630
@@ This compound statement ends with a brace, but is used as an
5639
@@ This fragment does not end with a semicolon, so one must be
5646
Here is a case for which the pseudo-semicolon is not necessary. Consider
5650
@@ The code fragment |x = y| ...
5653
If the @samp{-1} is turned on, one might think that @FWEAVE{} would
5654
report an ``irreducible scrap sequence'' because @samp{x = y} is an
5655
expression but not a complete statement. (Turning on @samp{-2}
5656
demonstrates this.) However, it is not necessary to say @samp{|x = y@@;|}
5657
because the warning message is not issued if the parsing reduces to just
5658
one unresolved scrap.
5660
On the other hand, @samp{|goto done|} does not reduce to just one
5661
unresolved scrap, so say @samp{|goto done@@;|} in cases such as this.
5662
@xref{Pseudo-operators}.
5664
In some situations, pseudo-semicolons are inserted automatically. An
5665
important case is free-format @sc{Fortran}-90. There the language
5666
syntax says that newlines terminate statements (except when there's a
5667
trailing ampersand). However, newlines are thrown away before tokenized
5668
text is seen by @FWEAVE{}'s parser (and in any event would just be
5669
interpreted as white space). Therefore, by default newlines that
5670
terminate statements are replaced by pseudo-semicolons, so the parsing
5673
In the @sc{Fortran}-90 case, one could also insert pseudo-semicolons or
5674
actual semicolons by hand, and some users prefer that. The
5675
possibilities are controlled by the options @samp{-n@@;} (@pxref{-nAT;})
5676
and @samp{-n;} (@pxref{-n;}).
5679
@cindex Pseudo-semicolons, automatic
5680
@cindex Automatic pseudo-semicolons
5682
@node ATcolon, AT!, AT;, AT commands
5683
@comment node-name, next, previous, up
5685
@subsection @samp{@@:}: Pseudo-colon
5687
@cindex Pseudo-colon
5688
@cindex Colon, pseudo
5690
@samp{@@:} is an invisible colon (@pxref{Pseudo-operators}).
5691
It can be helpful in formatting certain C constructions correctly. For
5692
example, if one has a named module defined as
5702
then one can use it as a case construction followed by the usual colon,
5714
@node AT!, , ATcolon, AT commands
5715
@comment node-name, next, previous, up
5717
@section Miscellaneous commands
5719
@subsection @samp{@@!}: Inhibit macro expansion
5722
@cindex Macros, inhibiting expansion of
5723
@FWEB{} macros and built-in functions are always expanded by default.
5724
This may not be desirable, particularly in the N mode. To inhibit
5725
expansion of an individual identifier, preface it by @samp{@@!}.
5727
@node Comments,Languages,AT commands,Top
5730
@comment node-name, next, previous, up
5732
@chapter COMMENTING STYLES
5734
@FWEB{} allows a variety of commenting styles. The visible comments are in
5735
the font @code{\cmntfont}, which defaults to @code{\mainfont}, a
5736
ten-point Roman font.
5737
@cindex Commenting styles
5741
* Invisible comments:: Skipping input material.
5742
* Visible comments:: Comments in code mode.
5743
* Temporary comments:: Temporarily commenting out code.
5746
@node Invisible comments,Visible comments,Comments,Comments
5747
@comment node-name, next, previous, up
5749
@section Invisible comments
5751
@cindex Comments, invisible
5754
If a source or include file begins with @samp{@@z} (in the very first
5755
two characters of the file), then all material is skipped until and
5756
including a line beginning in column 1 with @samp{@@x} [except that
5757
lines of the form @w{@samp{$Keyword: text of keyword $}} are processed; see
5758
@ref{$KEYWORD}, @ref{ATK_} (source files), or @ref{ATk} (include
5762
All material until and including the next newline is completely ignored.
5765
As @samp{@@%}, but also skip blank lines that immediately follow the current line.
5772
Author: J. A. Krommes
5774
@@c @@% This sets the global language to C.
5778
@node Visible comments, Temporary comments, Invisible comments, Comments
5779
@comment node-name, next, previous, up
5781
@section Visible comments
5783
@cindex Comments, visible
5785
@samp{/* ... */} is a long comment (it may extend over several lines).
5787
@samp{// ...} is a short comment (terminated by the next newline).
5789
@samp{@@(...@@)} is a meta-comment. Meta-comments are a localized form
5790
of the N mode (@pxref{Languages}). Tangled meta-comments are begun by
5791
the contents of the style-file entry @samp{meta.top} and terminated by
5792
@samp{meta.bottom}. Each line of the meta-comment is begun by
5793
@samp{meta.prefix}. Woven meta-comments are begun by
5794
@samp{meta_code.begin} and ended by @samp{meta_code.end}.
5795
@xref{Miscellaneous params}.
5802
call get_input // Read the parameter file.
5803
/* Process information. Comments like this
5804
can be split over several lines. */
5806
Meta-comments provide a poor-person's alignment feature
5816
@emph{The use of meta-comments is not recommended;} they are only
5817
marginally supported. Use ordinary long comments
5818
instead. Inside of them, use the various powerful features of @TeX{} or
5819
La@TeX{} (such as @code{\halign} or
5820
@code{\begin@{verbatim@}} @code{...} @code{\end@{verbatim@}}) to format
5821
your comment appropriately.
5823
@node Temporary comments, , Visible comments, Comments
5824
@comment node-name, next, previous, up
5826
@section Temporary comments
5828
@cindex Comments, temporary
5829
@cindex Code, temporarily commenting out
5831
During development, one frequently desires to temporarily comment out a
5832
section of code. C programmers sometimes try to do this by enclosing the
5833
code in @code{/*...*/}, but this is @emph{not} good
5834
style for several reasons. First, it is impossible if the code itself
5835
includes comments, since comments do not nest in C. Second, @FWEAVE{}
5836
will treat the commented code as @TeX{} rather than C code and will (at best)
5837
format it very poorly. In fact, La@TeX{} will frequently complain,
5838
because the commented code might contain characters such as underscores
5839
that @TeX{} expects to be in math mode. (Those are dealt with
5840
automatically when @FWEAVE{} is in code mode.) The trivial example
5841
@w{@samp{/* a_b; */}} is sufficient to illustrate this point.
5843
The proper way of commenting out sections of code is to use preprocessor
5844
constructions: @code{#if 0...#endif} in C, or more generally @code{@@#if
5845
0...@@#endif} (usable in all languages). (The @FWEB{} preprocessor is
5846
described in @ref{Preprocessing}.) With this method, there is no
5847
trouble with nested comments, and @FWEAVE{} will continue to format
5848
the code as code, so the documentation will make sense.
5850
For @sc{Fortran} programmers converting an existing code to @FWEB{},
5851
the @samp{-nC} option (@pxref{-nC}) may be helpful.
5853
@node Macros,Ratfor,Languages,Top
5854
@comment node-name, next, previous, up
5856
@chapter MACROS and PREPROCESSING
5858
@FWEB{} offers a built-in preprocessor facility, especially useful for
5859
@sc{Fortran} programmers. It is closely patterned after the C/C++
5860
preprocessor, but with some extensions such as variable numbers of
5861
arguments. In addition, there are some built-in functions that provide
5862
functionality that cannot be emulated by user-defined macros.
5864
When working with a language such as C that has its own preprocessor,
5865
the question arises when to use that and when to use @FWEB{}'s
5866
facilities. The answer generally comes with experience. Remember that
5867
@FWEB{}'s macros have been expanded by the time the tangled output
5868
file is produced, whereas language-specific preprocessor commands are
5869
just passed through to that file.
5871
If you're a @sc{Fortran} programmer, @emph{strongly} consider the use of
5872
@FWEB{}'s macro facilities; they will simplify your present and future
5873
life by creating more legible codes and reducing programming errors by
5874
eliminating redundant pieces of code. C/C++ programmers may also
5875
appreciate the preprocessor extensions.
5877
In addition to conventional macro processing, @FWEB{} also offers the
5878
convenience of certain built-in functions that behave in many ways like
5879
macros. As a trivial example, the value of @PI{} is available through
5880
the built-in function @samp{$PI}. Built-in functions are described in
5881
@ref{Built-in functions}. They can be useful to programmers in all languages.
5883
@FWEB{} recognizes two kinds of macros: @dfn{outer macros}, and @dfn{WEB
5884
macros} (@dfn{inner macros}). Control codes associated with either of
5885
these kinds normally begin the definition part. However, @FWEB{}
5886
macros are sometimes allowed in the code part as well; see @ref{FWEB macros}.
5888
Macros are expanded by @FTANGLE{} only; @FWEAVE{} merely prints
5889
them as they occur in the source file.
5894
* Outer macros:: Macros copied to beginning of output file (@@d).
5895
* FWEB macros:: Macros and built-in functions expanded by @FWEB{} (@@m).
5896
* Macros and formatting:: How to format macros for pretty-printing.
5897
* Preprocessing:: @FWEB{}'s preprocessing language (@@#if, etc.)
5900
@node Outer macros,FWEB macros,Macros,Macros
5901
@comment node-name, next, previous, up
5903
@section Outer macros
5905
@cindex Macros, outer
5906
Outer macros provide a shorthand way of invoking macro definitions in
5907
the source language; they are not expanded by @FWEB{}. Outer macros are
5908
defined by @samp{@@d} (@pxref{ATd}) or @samp{@@D}
5909
(@pxref{ATD_}). They may be placed in any definition part. @FTANGLE{}
5910
collects them during phase 1; during phase 2, they are simply copied in
5911
order of their appearance to the beginning of the output file. This is
5912
most useful for C or C++ codes; it's a quick way of typing
5913
@samp{#define} when the positioning of the @samp{#define} is
5933
The keyword into which the @samp{@@d} is translated is
5934
language-dependent; it is controlled by the style-file parameter
5935
@samp{outer_def}. @xref{Miscellaneous params}.
5937
Outer macros can be undefined by @samp{@@u}. The translation is
5938
controlled by the style-file parameter @samp{outer_undef}.
5939
@xref{Miscellaneous params}.
5941
The default behavior, in which the outer macro definitions are just
5942
copied to the top of the output file, is fine for simple applications.
5943
However, often C programmers prefer to maintain their macro definitions
5944
in a header file such as @file{test.h}. One way of accomplishing this is to
5945
redirect @FTANGLE{}'s output from the command line, as in
5946
@samp{ftangle test -=test.h}, then use an @samp{@@O} command immediately
5947
after the first @samp{@@a} in the @code{web} file to open up
5948
@file{test.c}. A more complicated variant of this allows additional
5949
information to be placed into the header file, as in the following example:
5954
We assume command-line redirection into \.@{test.h@} (`\.@{-=test.h@}').
5956
@@d A 1 // This will go into \.@{test.h@}.
5959
@@<Header material@@>@@; // Also goes into \.@{test.h@}.
5960
@@O test.c // Remaining unnamed sections go into \.@{test.c@}.
5962
@@ Header material may be defined as needed throughout the code, but
5963
with this design it will all go into \.@{test.h@}.
5965
@@<Header material@@>=
5969
@@<Global variables@@>@@;
5973
@node FWEB macros,Macros and formatting,Outer macros,Macros
5974
@comment node-name, next, previous, up
5976
@section @FWEB{} macros
5978
@cindex Macros, @FWEB{}
5979
@FWEB{} macros (sometimes called @dfn{inner macros}) are defined by
5980
@samp{@@m} (@pxref{ATm}) or @samp{@@M}
5981
(@pxref{ATM_}). These should normally be placed in the definition
5991
z3 = CUBE(x) + CUBE(y)
5994
(the appearance of an @samp{@@m} in the documentation part begins the
5995
definition part). They are collected during
5996
@FTANGLE{}'s phase 1 and effectively placed at the top of the unnamed
5997
section, so they are all known during the output in phase 2.
5999
In unusual situations when macros are being conditionally defined and/or
6000
undefined, the order of processing a macro definition becomes
6001
significant. If the command-line option @samp{-TD} is used, then
6002
@FWEB{} macros may be used in the code part as well; they are then
6003
called @dfn{deferred macros}. These definitions will be processed during
6004
phase 2 in the order that the code sections are processed, which may not
6005
be the same as the physical order in the source file.
6007
@emph{The use of deferred macros is highly discouraged}, for the
6008
following reason. @FWEB{} macros are often used in conjunction with
6009
the @FWEB{} preprocessor commands. @emph{Preprocessor commands are
6010
always processed during phase 1}, so they do not interact properly with
6011
deferred macros. It is for this reason that deferred macros are
6012
normally prohibited from appearing in the code part.
6015
* Macro features:: Various points about @FWEB{} macros.
6016
* Tokens:: Special tokens used in @FWEB{} macros.
6017
* Built-in functions:: Macro-like functions built into @FWEB{}.
6018
* Debugging with macros:: Debugging glitches, and their solutions.
6021
@node Macro features, Tokens, FWEB macros, FWEB macros
6022
@comment node-name, next, previous, up
6024
@subsection Various features of @FWEB{} macros
6029
Fundamentally, @FWEB{} macros follow the syntax for ANSI C. There are
6030
also a few extensions, notably the possibility of variable (optional) arguments
6031
(@pxref{Variable arguments}) and some additional preprocessing tokens
6035
Adjacent strings in macro text are automatically concatenated.
6041
EXTENSIONS of ANSI-C MACRO SYNTAX
6043
* Variable arguments:: @FWEB{} macros with variable arguments.
6044
* Recursion:: @FWEB{} macros may be recursive (proceed at your own risk).
6045
* Macro protection:: Protecting @FWEB{} macros against redefinition.
6049
@node Variable arguments, Recursion, Macro features, Macro features
6050
@comment node-name, next, previous, up
6052
@subsubsection @FWEB{} macros with variable arguments
6054
@cindex Macros, with variable arguments
6055
@cindex Variable arguments
6056
An important extension to the ANSI-C syntax is to allow macros with
6057
variable (optional) arguments. @FWEB{} macros with a variable number of arguments
6058
are indicated by an ellipsis, as in
6061
@@m VAR(x,y,z,...) text
6064
The tokens @samp{#0} (number of variable arguments), @samp{#@i{n}}
6065
(value of the @i{n}th optional argument), and @samp{#.} (comma-delimited list of
6066
the optional arguments) are useful in this context.
6068
@node Recursion, Macro protection, Variable arguments, Macro features
6069
@comment node-name, next, previous, up
6071
@subsubsection Recursion
6074
ANSI C does not permit recursive macros (for good reason). Thus, in the
6081
the identifier @code{recurse} simply expands as `@code{recurse}', not as
6082
an infinite loop. However, in @FWEB{} recursion may be useful in
6083
conjunction with some of the built-in functions
6084
(@pxref{Built-in functions}). To permit a macro to be recursive, say @samp{@@m*}.
6086
@emph{No formal support is provided for recursive macros!} If they
6087
don't work, or suddenly stop working in a new release, @emph{you're on
6090
@node Macro protection, , Recursion, Macro features
6091
@comment node-name, next, previous, up
6093
@subsubsection Protecting macros against redefinition
6095
@cindex Macros, redefinition of
6096
Normally an @FWEB{} macro can be redefined at will. The example
6103
is permissible, but probably not a good idea. If you want to ensure
6104
that a crucial macro definition is never redefined inadvertently, say
6111
That is called @dfn{protecting} the macro.
6113
@FWEB{}'s built-in functions and macros (beginning with @samp{$}) are
6114
protected by default; see
6115
@ref{Protection}. To override that protection, use the command-line
6116
options @samp{-Tb} (@ref{-Tb}; for built-in functions) or @samp{-Tm}
6117
(@ref{-Tm}; for macros).
6120
@node Tokens, Built-in functions, Macro features, FWEB macros
6121
@comment node-name, next, previous, up
6123
@subsection Special tokens
6125
@cindex Macros, special tokens for
6126
The following special tokens may be used in the text of @FWEB{} macro
6129
@subsubsection ANSI C-compatible tokens
6132
## @r{--- Paste tokens on either side to form a new identifier.}
6133
#@i{parameter} @r{--- Convert parameter to string (without expansion).}
6139
@@m FORTRAN(type, name) type _##name()
6140
@@m TRACE(where) puts("At " #where)
6142
FORTRAN(int, fcalc); // @r{Expands to @samp{int _fcalc();}}
6143
TRACE(predictor); // @r{Expands to @samp{puts("At " "predictor");}}
6146
@subsubsection Extensions to ANSI C macro syntax
6148
The most frequently used extensions are the following ones associated
6149
with variable arguments: @samp{#0}, @samp{#@i{n}}, and @samp{#.}.
6150
@sc{Fortran}-77 users should also employ @samp{#:0} to allow symbolic
6151
rather than numeric statement labels. Try not to use the other
6152
extensions; they are experimental, complicated, and unlikely to work in
6155
In the following list, the forms @samp{#@{n@}} and @samp{#[n]} may not
6156
work correctly in complicated situations. This is a design deficiency
6157
that may be corrected someday.
6162
Like @samp{#@i{parameter}}, but pass a quoted string through unchanged.
6164
Don't expand argument.
6166
Convert parameter to a single-quoted string (no expansion).
6168
Convert parameter to a double-quoted string (no expansion).
6170
Number of variable arguments.
6172
n-th variable argument, counting from 1.
6174
Like @samp{#0}, but the argument may be a macro expression known at run time.
6176
Like @samp{#@i{n}}, but the argument may be a macro expression.
6178
The total number of arguments (fixed + variable). (The
6179
argument inside the brackets may be a macro expression.)
6181
The @i{n}th argument (including the fixed ones), counting
6182
from 1. (The argument inside the brackets may be a macro expressions.
6184
Comma-separated list of all variable arguments.
6186
Unique statement number (expanded in phase 1).
6188
Unique statement number for each invocation of this macro (expanded in phase 2).
6190
Begin a module name.
6192
Internal comma; doesn't delimit macro argument.
6196
A few examples of the more important of these tokens are as follows:
6200
@@m FPRINTF(fmt,...) fprintf(fp,fmt,#.)
6201
// Use the whole list of variable args.
6202
@@m B(...) printf("There were %i arguments\n", #0)
6203
// Use the number of var args.
6207
@@m DONE #:0 // Symbolic statement label in @sc{Fortran}.
6215
@node Built-in functions, Debugging with macros, Tokens, FWEB macros
6216
@comment node-name, next, previous, up
6218
@subsection Built-in functions
6220
@cindex Functions, built-in
6221
Built-in functions behave in most ways like macros. In some cases
6222
they actually are macros, but other times they implement functions that a
6223
user could not define. They all begin with a dollar sign and are in
6226
In using these built-ins, confusion may arise regarding the order of
6227
expansion of various arguments. When they are implemented as macros,
6228
they are subject to the same ANSI-C preprocessor rules as other
6229
@FWEB{} macros, which is that all arguments are fully expanded before
6230
generating the replacement text of the macro. When they are directly
6231
implemented as a primitive function, however, that rule may not apply.
6232
For example, @code{$IF} expands only its first argument during its first
6233
pass of processing; depending on the results of that expansion, it then
6234
expands @emph{either} its second or third argument, but not both.
6236
The built-in function @code{$DUMPDEF} can be used to understand and
6237
debug the action of the built-in functions. @xref{$DUMPDEF}.
6239
In the original @FWEB{} design, built-in functions began with an
6240
underscore. This usage conflicts with the conventions for reserved
6241
words in ANSI C, and has been eliminated. @emph{All @FWEB{} built-ins
6242
now begin with a dollar sign.}
6244
@emph{No user-defined macro should begin with a dollar sign!} It might
6245
interfere with the functioning of some internal built-in function.
6249
GENERAL INFORMATION ABOUT BUILT-IN FUNCTION DESIGN
6251
* Strings and quotes:: Quoted and non-quoted strings.
6252
* Protection:: By default, built-in functions may not be redefined.
6254
INDIVIDUAL BUILT-IN FUNCTIONS
6256
* $A:: Convert to ASCII.
6257
* $ABS:: Absolute value.
6258
* $ASSERT:: Assert a condition.
6259
* $AUTHOR:: RCS global keyword; see $KEYWORD.
6260
* $COMMENT:: Generate a comment.
6261
* $DATE:: Today's date.
6262
* $DATE_TIME:: RCS global keyword; see $KEYWORD.
6264
* $DECR:: Decrement a macro.
6265
* $DEFINE:: Define a (deferred) macro.
6266
* $DO:: Macro @b{DO} loop.
6267
* $DUMPDEF:: Dump macro definitions to the terminal.
6268
* $E:: Base of the natural logarithms: 2.71828...
6269
* $ERROR:: Send error message to output.
6270
* $EVAL:: Evaluate an expression.
6271
* $EXP:: Exponential function.
6272
* $GETENV:: Get value of environment variable.
6273
* $HEADER:: RCS global keyword; see $KEYWORD.
6274
* $HOME:: The user's home directory.
6275
* $ID:: RCS global keyword; see $KEYWORD.
6276
* $IF:: Two-way conditional: ``If expression is true''
6277
* $IFCASE:: n-way conditional.
6278
* $IFDEF:: Two-way conditional: ``If macro is defined''
6279
* $IFNDEF:: Two-way conditional: ``If macro is not defined''
6280
* $IFELSE:: Two-way conditional: ``If macro1 equals macro2''
6281
* $INCR:: Increment a macro.
6282
* $INPUT_LINE:: Line number that begins current section.
6283
* $KEYWORD:: Extract text of global RCS-like keyword.
6284
* $L:: Change string to lower case.
6285
* $L_KEYWORD:: Extract text of local RCS-like keyword.
6286
* $LANGUAGE:: Identifier for current language.
6287
* $LANGUAGE_NUM:: Number of current language.
6288
* $LEN:: Length of string.
6289
* $LOCKER:: RCS global keyword; see $KEYWORD.
6290
* $LOG:: Natural logarithm.
6291
* $LOG10:: Logarithm to the base 10.
6292
* $M:: Define a (deferred) macro.
6293
* $MAX:: Maximum of one or more elements.
6294
* $MIN:: Minimum of one or more elements.
6295
* $MODULE_NAME:: Name of present @code{web} module.
6296
* $MODULES:: Total number of independent modules.
6297
* $NAME:: RCS global keyword; see $KEYWORD.
6298
* $OUTPUT_LINE:: Current line number of tangled output.
6299
* $P:: The C preprocessor symbol @code{#} (an unquoted string).
6301
* $POW:: Raise to a power.
6302
* $PP:: The C preprocessor symbol @code{#} (a character).
6303
* $RCSFILE:: RCS global keyword; see $KEYWORD.
6304
* $REVISION:: RCS global keyword; see $KEYWORD.
6305
* $ROUTINE:: Current Ratfor program, function, or subroutine.
6306
* $SECTION_NUM:: Number of current section.
6307
* $SECTIONS:: Maximum number of sections.
6308
* $SOURCE:: RCS global keyword; see $KEYWORD.
6309
* $SQRT:: Square root.
6310
* $STATE:: RCS global keyword; see $KEYWORD.
6311
* $STRING:: Expand argument, then stringize.
6313
* $TIME:: The local time.
6314
* $TRANSLIT:: Transliterate a string.
6315
* $U:: Change string to upper case.
6316
* $UNDEF:: Undefine an @FWEB{} macro.
6317
* $UNQUOTE:: Remove quotes from string (leaving an unquoted string).
6318
* $UNSTRING:: Remove quotes and string delimiters from string.
6319
* $VERBATIM:: (Obsolete.)
6320
* $VERSION:: @FWEB{} version number.
6323
@node Strings and quotes, Protection, Built-in functions, Built-in functions
6324
@comment node-name, next, previous, up
6326
@subsubsection Strings and quotes
6328
@cindex String, definition of
6329
@cindex String, quoted
6330
@cindex String, unquoted
6332
Several of the built-in functions expect or return a string argument.
6333
Examples include @code{$STRING} (@pxref{$STRING}), @code{$UNQUOTE}
6334
(@pxref{$UNQUOTE}), and @code{$UNSTRING} (@pxref{$UNSTRING}).
6335
In understanding the operation of those functions, it is important to
6336
understand just what a string means in the @FWEB{} context. As usual,
6337
it is a vector of characters. However, @emph{those need not be
6338
delimited by quotes}, although they may be. Internally, a string is
6339
represented by the construction @i{sqc...cqs}, where @i{s} is a special
6340
string delimiter never seen by the user, @i{q} is an optional quote
6341
character (either single or double quote depending on the language), and
6342
@i{c} is an ordinary character. Whether or not the quotes are present,
6343
the string delimiters inhibit macro expansion.
6345
The difference between @code{$UNQUOTE} and @code{$UNSTRING} can now be
6346
stated as follows. Given a quoted string such as @code{"abc"} (in C),
6350
@samp{$UNQUOTE} removes the quote characters @i{q}, leaving @i{sabcs} (still a
6354
@samp{$UNSTRING} removes both the quote characters @i{q} and the string
6355
delimiters @i{s}, leaving @i{abc} (a collection of three characters). This
6356
collection is @emph{not} tokenized; it does @emph{not} represent the
6357
single identifier name @code{abc} (and therefore is not very useful).
6358
@code{$UNSTRING} is primarily used internally.
6362
The built-ins @code{$P} (@pxref{$P}) and @code{$PP} (@pxref{$PP}), which
6363
both generate the preprocessor character @samp{#}, provide a good
6364
illustration of the differences between @code{$UNQUOTE} and
6365
@code{$UNSTRING}. Consider @sc{Fortran} as an example. Essentially,
6366
@code{$P} is defined as @samp{$UNQUOTE('#')}, which is internally
6367
@i{s@t{#}s}. When this single-character string is sent to the output, it is
6368
treated like any other expression and therefore would appear in column 7
6369
or greater even if the construction appeared at the very beginning of
6370
the line. On the other hand, @code{$PP} is (essentially) defined as
6371
@samp{$UNSTRING('#')}, which is internally the single character @t{#}.
6372
Because this character is not a string, the @sc{Fortran} output driver
6373
treats it as a special control character, defined in this case to force
6374
the character into the first column.
6376
@node Protection, $A, Strings and quotes, Built-in functions
6377
@comment node-name, next, previous, up
6379
@subsubsection Redefining built-in functions
6381
By default, built-in functions are @dfn{protected}---that is, they may not be
6382
redefined by an @code{@@m} command. (To do so cavalierly invites many
6383
kinds of weird disasters.) If it is absolutely necessary to redefine a
6384
built-in function, use the command-line option @samp{-Tb} (@pxref{-Tb}).
6386
Many of @FWEB{}'s ``built-in functions'' are in fact ordinary macros
6387
that are implemented in terms of lower-level built-ins. An example is
6388
@code{$POW} (@pxref{$POW}), which is constructed from the built-in
6389
function @code{$EVAL} (@pxref{$EVAL}). By default, such macros are also
6390
protected against redefinition; to override, use the option @samp{-Tm}
6393
@node $A, $ABS, Protection, Built-in functions
6394
@comment node-name, next, previous, up
6396
@subsubsection @code{$A}: Convert to ASCII
6399
@cindex ASCII, converting to
6400
@samp{$A(@i{string})} is the built-in equivalent of @samp{@@'...'} or
6401
@samp{@@"..."}. (See @ref{ATquote} and @ref{ATdquote}.)
6402
Note the extra parentheses required by the built-in.
6404
@code{$A} first expands its argument, in case it is a macro defined as a
6407
@node $ABS,$ASSERT,$A,Built-in functions
6408
@comment node-name, next, previous, up
6410
@subsubsection @code{$ABS}: Absolute value
6413
@cindex Absolute value
6414
@cindex Macros, absolute value of
6415
@samp{$ABS(@i{expression})} returns the absolute value of the macro
6416
expression. It is a macro implemented in terms of @code{$IF} and @code{$EVAL}.
6418
@node $ASSERT,$AUTHOR,$ABS,Built-in functions
6419
@comment node-name, next, previous, up
6421
@subsubsection @code{$ASSERT}: Assert a condition
6424
@cindex Asserting a condition
6425
@cindex Condition, asserting
6426
@samp{$ASSERT(@i{expression})} evaluates the macro expression. If the
6427
expression is false, an error message is printed and the run aborts.
6429
This built-in is useful for ensuring that @FWEB{} macros required by
6430
the code are properly initialized. Because it is expanded during the
6431
output phase, it must appear in the @emph{code
6432
part} (not in the definition part).
6434
@node $AUTHOR, $COMMENT, $ASSERT, Built-in functions
6435
@comment node-name, next, previous, up
6437
@subsubsection @code{$AUTHOR}: Value of RCS global keyword @code{Author}
6441
Equivalent to @samp{$KEYWORD(Author)}. @xref{$KEYWORD}.
6443
@node $COMMENT,$DATE,$AUTHOR,Built-in functions
6444
@comment node-name, next, previous, up
6446
@subsubsection @code{$COMMENT}: Generate a comment
6449
@cindex Comments, generating
6450
@samp{$COMMENT}(@i{string}) generates a comment in the output file.
6452
This function is sometimes useful in conjunction with the processing of
6453
@FWEB{} macros, since ordinary comments are removed when macros are
6454
processed. For example, if one says
6459
@@m M "abc" $COMMENT("Test")
6464
the tangled output will be @samp{m= "abc"/* Test */}
6466
@node $DATE,$DATE_TIME,$COMMENT,Built-in functions
6467
@comment node-name, next, previous, up
6469
@subsubsection @code{$DATE}: Today's date
6472
@cindex Date, generating the
6473
@samp{$DATE} generates a string consisting of the date in the form
6474
@code{"August 16, 2001"}. It is implemented as a macro that calls other
6475
macros and primitive functions.
6477
@node $DATE_TIME, $DAY, $DATE, Built-in functions
6478
@comment node-name, next, previous, up
6480
@subsubsection @code{$DATE_TIME}: Value of RCS global keyword @code{Date}
6485
Equivalent to @samp{$KEYWORD(Date)}. @xref{$KEYWORD}.
6487
@node $DAY,$DECR,$DATE_TIME,Built-in functions
6488
@comment node-name, next, previous, up
6490
@subsubsection @code{$DAY}: The day
6493
@cindex Day, generating the
6494
@samp{$DAY} generates a string consisting of the day of the week, such
6495
as @code{"Monday"}. It is implemented as a macro that calls other
6496
macros and primitive functions.
6498
@node $DECR,$DEFINE,$DAY,Built-in functions
6499
@comment node-name, next, previous, up
6501
@subsubsection @code{$DECR}: Decrement a macro
6504
@cindex Macros, decrementing
6505
@samp{$DECR(@var{N})} redefines the numeric macro @var{N} to be one less
6506
than its previous value. (If @var{N} does not simplify to a number, an
6507
error results.) In other words, in the language of C the effect is to
6510
The two-argument form @samp{$DECR(@var{N,m})} executes the equivalent of
6511
@samp{@i{N} -= @i{m}}.
6513
@node $DEFINE,$DO,$DECR,Built-in functions
6514
@comment node-name, next, previous, up
6516
@subsubsection @code{$DEFINE}: Deferred macro definition
6519
@cindex Macros, defining
6520
@samp{$DEFINE} behaves like the @FWEB{} macro command @code{@@m}, but
6521
it is intended to appear in the @emph{code} part, not the definition part (so
6522
it is processed during @emph{output}, not input). Thus, the code fragment
6537
(Notice how the @samp{@@%} command was used to kill an unwanted newline,
6538
analogous to the @samp{dnl} macro in @code{m4}.)
6540
In the above example, one could also say @samp{$DEFINE(A=1)}.
6541
To define a macro with arguments, say something like
6542
@samp{$DEFINE(A(x)x*x)}. Do @emph{not} say @samp{$DEFINE(A(x)=x*x)}, as
6543
in this case the equals sign will be included in the macro expansion.
6544
One must use the equals sign as a means of preventing parentheses from
6545
being interpreted as an argument in examples like
6551
This expands to @samp{(x)}.
6553
A completely equivalent shorthand notation for @code{$DEFINE} is
6556
@node $DO,$DUMPDEF,$DEFINE,Built-in functions
6557
@comment node-name, next, previous, up
6559
@subsubsection @code{$DO}: Macro do loop
6562
@cindex Macros, repetitively defining
6563
@samp{$DO(@i{macro,imin,imax[,di]})@{...@}} repetitively defines
6564
@i{macro} as would the @sc{Fortran} statement @samp{do macro =
6565
imin,imax,di}. For example,
6575
generates the three statements
6583
In general, the macro name used as loop counter should @emph{not} be
6584
explicitly defined as a macro prior to the @code{$DO}. If it is not, it
6585
will remain undefined after the end of the iteration.
6587
Instead of the delimiting braces, parentheses may be used. These may be
6588
useful to help @FWEAVE{} format certain constructions correctly.
6590
Nested delimiters are handled correctly. The delimiters are required
6591
even if only a single statement is to expanded.
6594
@code{$DO} is implemented in terms of a command @code{$UNROLL}.
6595
However, if one says something like @samp{$DUMPDEF($UNROLL(0,5,1))},
6596
@FWEB{} will respond that @code{$UNROLL} is not an @FWEB{} macro.
6597
Rather, @code{$UNROLL} is processed like expandable commands in
6598
@sc{Ratfor} such as @code{while}. This implies that it cannot be
6599
redefined as ordinary macros or built-in functions can be.
6601
@node $DUMPDEF,$E,$DO,Built-in functions
6602
@comment node-name, next, previous, up
6604
@subsubsection @code{$DUMPDEF}: Dump macro definitions to the terminal
6607
@cindex Debugging macros
6608
@cindex Macros, debugging
6609
In the call @samp{$DUMPDEF(@i{m1, m2, ...})}, @i{m1}, @i{m2}, and so on
6610
are macro calls (with arguments if appropriate). Two lines of output
6611
are generated for each argument. Line 1 is the macro definition; line 2
6612
is its expansion using the provided arguments.
6614
One can use this built-in to debug one's own macros, or to find out the
6615
secrets of @FWEB{}'s built-ins. As an example, if one says
6618
$DUMPDEF($EVAL(2^^4))@@%
6621
it responds with the two lines
6624
$EVAL($0) = $$EVAL($0)
6628
(The @code{$@i{n}} notation indicates the @i{n}-th argument of the macro.)
6629
If one replaces @code{$EVAL} with @code{$$EVAL} in the above
6630
@code{$DUMPDEF}, it will respond
6633
$$EVAL($0) = <built-in>
6638
The purpose of code such as @samp{$EVAL($0) = $$EVAL($0)} is to ensure
6639
that the argument of @code{$EVAL} is expanded if it contains macros; the
6640
primitive function @code{$$EVAL} does not do that expansion
6643
Names indicated as @samp{<built-in>} by @code{$DUMPDEF} may be redefined
6644
as ordinary macros, but this is in general a @emph{very bad idea}; other
6645
parts of @FWEB{} may mysteriously stop working.
6647
@node $E, $ERROR, $DUMPDEF, Built-in functions
6648
@comment node-name, next, previous, up
6650
@subsubsection @code{$E}: Base of the natural logarithms
6653
@cindex Logarithms, natural
6654
The expression @samp{$E} returns @var{e}, the base of the natural
6655
logarithms, to the default machine precision.
6656
The expression @samp{$E(@i{iprec})} returns @var{e} to the decimal precision
6657
@var{iprec} (which must be less than 50).
6659
@node $ERROR, $EVAL, $E, Built-in functions
6660
@comment node-name, next, previous, up
6662
@subsubsection @code{$ERROR}: Send error message to output
6665
@cindex Error messages, printing
6666
@samp{$ERROR(@i{string})} prints an error message in @FWEB{}'s
6669
@node $EVAL, $EXP, $ERROR, Built-in functions
6670
@comment node-name, next, previous, up
6672
@subsubsection @code{$EVAL}: Evaluate a macro expression
6675
@cindex Expressions, evaluating
6676
@cindex Macros, evaluating
6677
@samp{$EVAL(@i{expression})} uses @FWEB{}'s macro-expression evaluator
6678
(@pxref{Preprocessing}) to reduce the macro expression to its simplest
6679
form. An attempt to perform arithmetic on combinations of non-macro
6680
identifiers and numbers generates a warning message.
6682
@node $EXP, $GETENV, $EVAL, Built-in functions
6683
@comment node-name, next, previous, up
6685
@subsubsection @code{$EXP}: Exponential function
6688
@cindex Exponentiation
6689
@samp{$EXP(@i{x})} returns
6694
@var{e} to the power @var{x}.
6697
@node $GETENV, $HEADER, $EXP, Built-in functions
6698
@comment node-name, next, previous, up
6700
@subsubsection @code{$GETENV}: Get value of environment variable
6703
@cindex Environment, obtaining the
6704
@cindex Environment variables
6705
@samp{$GETENV(@var{name})} returns a string consisting of the current
6706
value of the environment variable @var{name}. (Under VMS, logical names
6707
behave like environment variables.)
6709
The argument to @code{$GETENV} need not be a string (double-quoted), but
6710
it may be if necessary to avoid the expansion of a macro.
6712
@node $HEADER, $HOME, $GETENV, Built-in functions
6713
@comment node-name, next, previous, up
6715
@subsubsection @code{$HEADER}: Value of RCS global keyword @code{Header}
6720
Equivalent to @samp{$KEYWORD(Header)}. @xref{$KEYWORD}.
6722
@node $HOME,$ID,$HEADER,Built-in functions
6723
@comment node-name, next, previous, up
6725
@subsubsection @code{$HOME}: The user's home directory
6728
@samp{$HOME} is a convenience macro equivalent to @samp{$GETENV(HOME)}.
6730
@node $ID, $IF, $HOME, Built-in functions
6731
@comment node-name, next, previous, up
6733
@subsubsection @code{$ID}: Value of RCS global keyword @code{Id}
6736
@cindex Identification
6737
Equivalent to @samp{$KEYWORD(Id)}. @xref{$KEYWORD}.
6739
@node $IF,$IFCASE,$ID,Built-in functions
6740
@comment node-name, next, previous, up
6742
@subsubsection @code{$IF}: Two-way conditional
6745
@cindex Conditional, two-way
6746
@code{$IF} is a primitive function (not a macro) that is the code-part
6747
version of @samp{@@#if}.
6751
$IF(@i{expr}, @i{action-if-true}, @i{action-if-false})
6754
The @i{expr} is an @FWEB{} macro expression that must reduce to 0
6755
(false) or 1 (true). First that argument is expanded. If it is true,
6756
@i{action-if-true} is expanded; otherwise @i{action-if-false} is expanded.
6758
There may be peculiarities with this and the other built-in @code{$IF}
6759
function having to do with the order of expansion when the actions
6760
contain macros whose arguments themselves are macros. Therefore, do not
6761
use them unless absolutely necessary.
6763
@emph{Do not redefine} @code{$IF} or any other built-in conditionals, as they
6764
are used internally to @FWEB{}.
6766
@node $IFCASE,$IFDEF,$IF,Built-in functions
6767
@comment node-name, next, previous, up
6769
@subsubsection @code{$IFCASE}: n-way conditional
6772
@cindex Conditional, n-way
6773
This primitive built-in behaves like @TeX{}'s @samp{\ifcase} command.
6777
$IFCASE(@i{expr}, @i{case-0}, @i{case-1}, ...,@i{case-n-1}, @i{default})
6780
If @i{expr} reduces to an integer between 0 and @emph{n-1},
6781
inclusively, the appropriate case is selected; otherwise, the default
6787
$IFCASE(2, zero, one, two, default) @r{=>} `two'
6788
$IFCASE(2, zero, one, three) @r{=>} `three'
6789
$IFCASE(2, zero, one) @r{=>} `one'
6792
@node $IFDEF,$IFNDEF,$IFCASE,Built-in functions
6793
@comment node-name, next, previous, up
6795
@subsubsection @code{$IFDEF}: Two-way conditional
6798
@cindex Conditional, two-way
6799
This built-in primitive is the code-part version of @samp{@@#ifdef}.
6803
$IFDEF(@var{macro}, @i{action-if-defined},@i{action-if-not-defined})
6806
@node $IFNDEF,$IFELSE,$IFDEF,Built-in functions
6807
@comment node-name, next, previous, up
6809
@subsubsection @code{$IFNDEF}: Two-way conditional
6812
@cindex Conditional, two-way
6813
This built-in primitive is the code-part version of @samp{@@#ifndef}.
6814
The syntax is @samp{$IFNDEF(@var{macro}, @i{action-if-not-defined},
6815
@i{action-if-defined})}.
6817
@node $IFELSE,$INCR,$IFNDEF,Built-in functions
6818
@comment node-name, next, previous, up
6820
@subsubsection @code{$IFELSE}: Two-way conditional
6823
@cindex Conditional, two-way
6824
The syntax of this built-in primitive is @samp{$IFELSE(@i{expr1},
6825
@i{expr2}, @i{action-if-equal}, @i{action-if-not-equal})}. The
6826
expansions of @i{expr1} and @i{expr2} are compared on a byte-by-byte
6827
basis. If they are equal, the first action is taken, otherwise the
6828
second action is taken.
6834
$IFELSE("abc", S, yes, no)
6837
evaluates to @samp{yes}.
6839
@node $INCR,$INPUT_LINE,$IFELSE,Built-in functions
6840
@comment node-name, next, previous, up
6842
@subsubsection @code{$INCR}: Increment a macro
6845
@cindex Macros, incrementing
6846
@samp{$INCR(@var{N})} redefines the numeric macro @var{N} to be one greater
6847
than its previous value. (If @var{N} does not simplify to a number, an
6848
error results.) In other words, in the language of C the effect is to
6849
say @samp{@var{N}++}.
6851
The two-argument form @samp{$INCR(@var{N,m})} executes the equivalent of
6852
@samp{@var{N} += @var{m}}.
6854
@node $INPUT_LINE,$KEYWORD,$INCR,Built-in functions
6855
@comment node-name, next, previous, up
6857
@subsubsection @code{$INPUT_LINE}: Line number that begins current section
6860
@cindex Input line, number of
6861
@samp{$INPUT_LINE} is the number of the line in the @code{web} source file
6862
that @emph{begins the current section} (not the source line in which the
6863
@code{$INPUT_LINE} command appears). Compare @code{$OUTPUT_LINE},
6866
@node $KEYWORD, $L, $INPUT_LINE, Built-in functions
6867
@comment node-name, next, previous, up
6869
@subsubsection @code{$KEYWORD}: Value of global RCS-like keyword
6872
@cindex Keyword, RCS
6873
@cindex RCS-like keyword
6874
@samp{$KEYWORD} provides a built-in function alternative to the use of
6875
@samp{@@K} in a code part. (@pxref{ATK_}).
6877
@samp{$KEYWORD(@i{Keyword})} extracts (as a character string) the text of an
6878
RCS-like keyword defined in the ignorable commentary between @samp{@@z}
6879
and @samp{@@x} at the beginning of the web source file (@pxref{ATz}).
6880
(@dfn{RCS} stands for ``revision-control system.'') The general syntax
6881
is (@sc{unix} users, see @samp{man ident})
6884
$@i{Keyword}: @r{text of keyword} $
6897
char author[] = $KEYWORD(Author);
6903
char author[] = "krommes";
6906
In this example, @samp{$Author} is one of the standard RCS keywords.
6907
However, any keyword that fits the syntax
6908
@samp{$@i{keyword}: @i{contents} $} can be accessed by @samp{$KEYWORD}.
6909
(At least one blank is necessary before and after @i{contents}.)
6910
The argument of @samp{$KEYWORD} need not be quoted, but it may be. In
6911
either event, the output is a quoted string.
6913
Keywords extracted from ignorable commentary at the beginning of a web
6914
file are called @dfn{global} and are known throughout the code.
6915
Distinguish these from @dfn{local} keywords extracted from ignorable
6916
commentary at the beginning of an include (@samp{@@i}) file. Such
6917
keywords are known only during the time that file is being read and are
6918
accessible via @samp{@@k} (@pxref{ATk}).
6920
For convenience, built-ins are defined for some standard RCS global keywords.
6924
$AUTHOR @r{=>} $KEYWORD(Author)
6925
$DATE_TIME @r{=>} $KEYWORD(Date)
6926
$HEADER @r{=>} $KEYWORD(Header)
6927
$ID @r{=>} $KEYWORD(Id)
6928
$LOCKER @r{=>} $KEYWORD(Locker)
6929
$NAME @r{=>} $KEYWORD(Name)
6930
$RCSFILE @r{=>} $KEYWORD(RCSfile)
6931
$REVISION @r{=>} $KEYWORD(Revision)
6932
$SOURCE @r{=>} $KEYWORD(Source)
6933
$STATE @r{=>} $KEYWORD(State)
6936
There are no such abbreviations for local keywords, because such
6937
abbreviations would be expanded during output whereas it is necessary to
6938
recognize and expand the local keywords during input. Presumably such local
6939
keywords will be used rarely, if at all.
6941
@node $L,$L_KEYWORD,$KEYWORD,Built-in functions
6942
@comment node-name, next, previous, up
6944
@subsubsection @code{$L}: Change to lower case
6948
@cindex Case, changing
6949
@samp{$L(@var{string})} changes @var{string} to lower case. The argument is
6950
first expanded in case it is a macro.
6952
@node $L_KEYWORD, $LANGUAGE, $L, Built-in functions
6953
@comment node-name, next, previous, up
6955
@subsubsection @code{$L_KEYWORD}: Value of local RCS-like keyword
6958
@cindex Keyword, RCS
6959
@cindex RCS-like keyword
6960
For most purposes, @samp{$L_KEYWORD} behaves as @samp{@@k}
6961
(@pxref{ATk}). It is still under development and should not be used yet.
6963
@samp{$L_KEYWORD("@i{Keyword}")} extracts (as a character string) the text of
6964
an RCS-like keyword defined in the ignorable commentary between
6965
@samp{@@z} and @samp{@@x} at the beginning of a file included via
6966
@samp{@@i}. @samp{$L_KEYWORD("@i{local keyword}")} is expanded during
6967
input, and the results are known only during the time the include file
6970
Note that the argument of @samp{$L_KEYWORD} must be a quoted string.
6971
For more discussion of the distinction between local and global
6972
keywords, please see @ref{ATz} and @ref{$KEYWORD}.
6974
It is expected that local keywords will rarely be used, as
6975
fundamental revision-control information should presumably be extracted
6976
from the top of the master web file.
6978
@node $LANGUAGE,$LANGUAGE_NUM,$L_KEYWORD,Built-in functions
6979
@comment node-name, next, previous, up
6981
@subsubsection @code{$LANGUAGE}: Identifier for current language
6984
@cindex Language, determining the
6985
This expands to an identifier that denotes the current language, as
6989
@multitable {..VERBATIM..} {LANGUAGE}
6990
@item Language @tab @code{$LANGUAGE}
6991
@item C @tab @code{$C}
6992
@item C++ @tab @code{$CPP}
6993
@item Fortran @tab @code{$N}
6994
@item Fortran-90 @tab @code{$N90}
6995
@item Ratfor @tab @code{$R}
6996
@item Ratfor-90 @tab @code{$R90}
6997
@item TeX @tab @code{$X}
6998
@item VERBATIM @tab @code{$V}
7003
Note that this outputs identifiers, not @FWEB{} macros. They are intended
7004
to be used in @code{$IF} or @code{$IFELSE} statements such as
7007
$IF($LANGUAGE==$C, @i{C-text}, @i{other-text})
7010
For multiway switches, the @code{$LANGUAGE_NUM} built-in is more useful;
7011
see @ref{$LANGUAGE_NUM}.
7013
@node $LANGUAGE_NUM,$LEN,$LANGUAGE,Built-in functions
7014
@comment node-name, next, previous, up
7016
@subsubsection @code{$LANGUAGE_NUM}: Number of current language
7018
@findex $LANGUAGE_NUM
7019
@cindex Language number
7020
@cindex Language, determining
7021
@samp{$LANGUAGE_NUM} expands to an integer that uniquely defines the
7022
current language, as follows:
7025
@multitable {..VERBATIM..} {LANGUAGE_NUM}
7026
@item Language @tab @code{$LANGUAGE_NUM}
7027
@item C @tab @code{0}
7028
@item C++ @tab @code{1}
7029
@item Fortran @tab @code{2}
7030
@item Fortran-90 @tab @code{3}
7031
@item Ratfor @tab @code{4}
7032
@item Ratfor-90 @tab @code{5}
7033
@item TeX @tab @code{6}
7034
@item VERBATIM @tab @code{7}
7039
This built-in is useful in conjunction with an @code{$IFCASE}
7040
construction; see @ref{$IFCASE}.
7042
@node $LEN, $LOCKER, $LANGUAGE_NUM, Built-in functions
7043
@comment node-name, next, previous, up
7045
@subsubsection @code{$LEN}: Length of string
7048
@cindex String length
7049
@cindex Length of string
7050
@samp{$LEN(@var{string})} returns the length of @var{string} in bytes. If
7051
@var{string} is not surrounded by quotes, it is interpreted as if it were
7052
quoted (so it is not expanded if it is a macro). Thus, in the example
7060
the value returned is 2, not 5.
7062
To expand the argument before taking the length, one can say something
7066
@@m $XLEN(s) $LEN(s)
7069
@node $LOCKER, $LOG, $LEN, Built-in functions
7070
@comment node-name, next, previous, up
7072
@subsubsection @code{$LOCKER}: Value of RCS global keyword @code{Locker}
7076
Equivalent to @samp{$KEYWORD(Locker)}. @xref{$KEYWORD}.
7078
@node $LOG, $LOG10, $LOCKER, Built-in functions
7079
@comment node-name, next, previous, up
7081
@subsubsection @code{$LOG}: Natural logarithm
7084
@cindex Logarithms, natural
7085
@samp{$LOG(@i{x})} returns
7090
the natural logarithm of @i{x}.
7093
@node $LOG10, $M, $LOG, Built-in functions
7094
@comment node-name, next, previous, up
7096
@subsubsection @code{$LOG10}: Logarithm to the base 10
7099
@cindex Logarithms, base 10
7100
@samp{$LOG10(@i{x})} returns
7105
the logarithm to the base 10 of @i{x}.
7108
@node $M, $MAX, $LOG10, Built-in functions
7109
@comment node-name, next, previous, up
7111
@subsubsection @code{$M}: Define a deferred macro
7114
@cindex Macros, defining
7115
@code{$M} is equivalent to @code{$DEFINE}. @xref{$DEFINE}.
7117
@node $MAX,$MIN,$M,Built-in functions
7118
@comment node-name, next, previous, up
7120
@subsubsection @code{$MAX}: Maximum of a list
7124
@samp{$MAX(@i{x1},@i{x2},...)} returns the maximum of the list of arguments.
7125
(There must be at least one argument.)
7127
@node $MIN,$MODULE_NAME,$MAX,Built-in functions
7128
@comment node-name, next, previous, up
7130
@subsubsection @code{$MIN}: Minimum
7134
@samp{$MIN(@i{x1},@i{x2},...)} returns the minimum of the list of arguments.
7135
(There must be at least one argument.)
7137
@node $MODULE_NAME,$MODULES,$MIN,Built-in functions
7138
@comment node-name, next, previous, up
7140
@subsubsection @code{$MODULE_NAME}: Name of present @code{web} module
7142
@findex $MODULE_NAME
7143
@cindex Module, name of
7144
@samp{$MODULE_NAME} returns the name of the present @code{web} module. If the
7145
present module is unnamed, it returns the string @code{"unnamed"}.
7147
@node $MODULES,$NAME,$MODULE_NAME,Built-in functions
7148
@comment node-name, next, previous, up
7150
@subsubsection @code{$MODULES}: Total number of independent modules
7153
@cindex Modules, number of
7154
@samp{$MODULES} gives the total number of independent modules---that is,
7155
the number of independent module names, plus 1 for the unnamed module.
7157
@node $NAME, $OUTPUT_LINE, $MODULES, Built-in functions
7158
@comment node-name, next, previous, up
7160
@subsubsection @code{$NAME}: Value of RCS global keyword @code{Name}
7163
Equivalent to @samp{$KEYWORD(Name)}. @xref{$KEYWORD}.
7165
@node $OUTPUT_LINE,$P,$NAME,Built-in functions
7166
@comment node-name, next, previous, up
7168
@subsubsection @code{$OUTPUT_LINE}: Current line number of tangled output
7170
@findex $OUTPUT_LINE
7173
This returns the current line number of the tangled output. Contrast
7174
this with @code{$INPUT_LINE}, @ref{$INPUT_LINE}.
7176
@node $P,$PI,$OUTPUT_LINE,Built-in functions
7177
@comment node-name, next, previous, up
7179
@subsubsection @code{$P}: The C preprocessor symbol
7184
@cindex Preprocessor symbol
7185
@code{$P} is (essentially) a synonym for @samp{$UNQUOTE("#")}
7186
(@pxref{$UNQUOTE}). It is useful for constructing @FWEB{} macro
7187
definitions that expand to C preprocessor statements. For example,
7196
Another version of the preprocessor symbol is @code{$PP} (@pxref{$PP}).
7197
For most purposes, @code{$P} and @code{$PP} will behave in exactly the
7198
same way. The difference between them is that @code{$P} is treated as a
7199
string (without surrounding quotes), whereas @code{$PP} is treated as a
7200
character. The character nature of @code{$PP} is used by @sc{Fortran}
7201
to reset the column number to 1, so C-like preprocessor commands appear
7202
there rather than in column 7.
7204
For further discussion of strings and the differences between @code{$P}
7205
and @code{$PP}, see @ref{Strings and quotes}.
7207
@node $PI, $POW, $P, Built-in functions
7208
@comment node-name, next, previous, up
7210
@subsubsection @code{$PI}: Pi
7214
The expression @samp{$PI} returns
7215
@PI{} to the default machine
7216
precision. The expression @samp{$PI(@i{iprec})} returns
7223
to the decimal precision @var{iprec} (which must be less than 50).
7225
@node $POW, $PP, $PI, Built-in functions
7226
@comment node-name, next, previous, up
7228
@subsubsection @code{$POW}: Exponentiation
7231
@cindex Exponentiation
7232
@samp{$POW(@i{x,y})} generates
7237
@i{x} raised to the power @i{y}.
7239
(It is a macro defined in terms of @code{$EVAL} (@pxref{$EVAL}) and the
7240
exponentiation operator.)
7242
@node $PP, $RCSFILE, $POW, Built-in functions
7243
@comment node-name, next, previous, up
7245
@subsubsection @code{$PP}: The C preprocessor symbol
7250
@cindex Preprocessor symbol
7251
@code{$PP} is shorthand for @samp{$UNSTRING($P)} (@pxref{$P}), or
7252
(essentially) a synonym for @samp{$UNSTRING("#")} (@pxref{$UNSTRING}).
7253
It is useful, particularly in @sc{Fortran}, for constructing @FWEB{}
7254
macro definitions that expand to C preprocessor statements. For an
7255
example, see @ref{$P}. For a detailed discussion of the difference
7256
between @samp{$P} and @samp{$PP}, see @ref{Strings and quotes}.
7258
@node $RCSFILE, $REVISION, $PP, Built-in functions
7259
@comment node-name, next, previous, up
7261
@subsubsection @code{$RCSFILE}: Value of RCS global keyword @code{$RCSfile}
7266
Equivalent to @samp{$KEYWORD(RCSfile)}. @xref{$KEYWORD}.
7268
@node $REVISION, $ROUTINE, $RCSFILE, Built-in functions
7269
@comment node-name, next, previous, up
7271
@subsubsection @code{$REVISION}: Value of RCS global keyword @code{Revision}
7275
Equivalent to @samp{$KEYWORD(Revision)}. @xref{$KEYWORD}.
7277
@node $ROUTINE,$SECTION_NUM,$REVISION,Built-in functions
7278
@comment node-name, next, previous, up
7280
@subsubsection @code{$ROUTINE}: Current function (@sc{Ratfor} only)
7283
@cindex Program unit
7284
When @sc{Ratfor} is the current language, @code{$ROUTINE} expands to a
7285
string built of the name of the current program, function, or
7286
subroutine. This function is not useful for other languages, for which
7287
it expands to the null string.
7289
@node $SECTION_NUM,$SECTIONS,$ROUTINE,Built-in functions
7290
@comment node-name, next, previous, up
7292
@subsubsection @code{$SECTION_NUM}: Number of current @FWEB{} section
7294
@findex $SECTION_NUM
7295
@cindex Section number, current
7296
@samp{$SECTION_NUM} returns an integer greater than 0 that is the
7297
integer number of the current @code{web} section. (This is not the
7298
La@TeX{} section number such as 3.4.)
7300
@node $SECTIONS,$SOURCE,$SECTION_NUM,Built-in functions
7301
@comment node-name, next, previous, up
7303
@subsubsection @code{$SECTIONS}: Maximum section number
7306
@cindex Section number, maximum
7307
@samp{$SECTIONS} is the maximum section number as understood by
7310
@node $SOURCE, $SQRT, $SECTIONS, Built-in functions
7311
@comment node-name, next, previous, up
7313
@subsubsection @code{$SOURCE}: Value of RCS global keyword @code{Source}
7316
Equivalent to @samp{$KEYWORD(Source)}. @xref{$KEYWORD}.
7318
@node $SQRT, $STATE, $SOURCE, Built-in functions
7319
@comment node-name, next, previous, up
7321
@subsubsection @code{$SQRT}: Square root
7325
@cindex Root, square
7326
@samp{$SQRT(@i{x})} returns
7331
the square root of @i{x}.
7333
It is a convenience macro defined in terms of @code{$POW}. @xref{$POW}.
7335
@node $STATE, $STRING, $SQRT, Built-in functions
7336
@comment node-name, next, previous, up
7338
@subsubsection @code{$STATE}: Value of RCS global keyword @code{State}
7342
Equivalent to @samp{$KEYWORD(State)}. @xref{$KEYWORD}.
7344
@node $STRING, $STUB,$STATE, Built-in functions
7345
@comment node-name, next, previous, up
7347
@subsubsection @code{$STRING}: Expand, then stringize
7350
@cindex String, quoting a
7351
@samp{$STRING(@i{s})} expands its argument if it is a macro, then makes
7352
the expansion into a quoted string. If the argument is already a quoted
7353
string, it is returned unchanged.
7355
@node $STUB,$TIME,$STRING,Built-in functions
7356
@comment node-name, next, previous, up
7358
@subsubsection @code{$STUB}: Trap for missing module
7361
@cindex Modules, missing
7362
When a missing module is detected, @FTANGLE{} inserts the command
7363
@samp{$STUB(@i{module_name})} into the output code. The built-in
7364
@code{$STUB} expands to a function call appropriate to the current
7365
language. For example, in C it expands to @samp{missing_mod}, in
7366
@sc{Fortran} it expands to @samp{call nomod}.
7368
@node $TIME,$TRANSLIT,$STUB,Built-in functions
7369
@comment node-name, next, previous, up
7371
@subsubsection @code{$TIME}: The time
7375
@samp{$TIME} returns a string consisting of the local time in the form
7378
@node $TRANSLIT,$U,$TIME,Built-in functions
7379
@comment node-name, next, previous, up
7381
@subsubsection @code{$TRANSLIT}: Transliteration
7384
@cindex Transliteration
7385
The macro @samp{$TRANSLIT(@var{s}, @var{from}, @var{to})} interprets each of
7387
as strings (without expanding anything). Then @var{s} is modified by
7388
replacing any of the characters found in @var{from} by the
7389
corresponding characters in @var{to}. If @var{to} is shorter than
7390
@var{from}, then the excess characters in @var{from} are deleted from
7391
@var{s}. As a limiting case, if @var{to} is empty, then all the
7392
characters in @var{from} are deleted from @var{s}. For example,
7393
@samp{$TRANSLIT(s, aeiou, 12345)} replaces the vowels in @var{s} by the
7394
corresponding digits, and @samp{$TRANSLIT(s, aeiou, )} deletes all the
7395
vowels. The backslash may be used to escape a character, as in ANSI C.
7396
For example, @samp{$TRANSLIT("a\\"\\\\d", "d\\\\a\\"", "D,A'")}
7397
translates into @samp{A',D}. Here one had to explicitly enclose strings
7398
involving @samp{\\"} in double quotes in order to avoid a complaint
7399
about an unterminated string.
7402
@node $U,$UNDEF,$TRANSLIT,Built-in functions
7403
@comment node-name, next, previous, up
7405
@subsubsection @code{$U}: Change to upper case
7408
@cindex Case, changing
7410
@samp{$U(@i{string})} changes @i{string} to upper case.
7412
@node $UNDEF,$UNQUOTE,$U,Built-in functions
7413
@comment node-name, next, previous, up
7415
@subsubsection @code{$UNDEF}: Undefine a macro
7418
@cindex Macros, undefining
7419
@samp{$UNDEF(@i{macro})} undefines an @FWEB{} macro.
7421
@node $UNQUOTE,$UNSTRING,$UNDEF,Built-in functions
7422
@comment node-name, next, previous, up
7424
@subsubsection @code{$UNQUOTE}: Remove quotes from string
7427
@cindex Strings, unquoting
7428
@samp{$UNQUOTE(@var{string})} returns @var{string} without its surrounding
7429
quotes. (However, the resulting construction is still treated as a
7430
string; no macro expansion is done.)
7432
For a more detailed discussion and a comparison with @code{$UNSTRING}
7433
(@pxref{$UNSTRING}), see @ref{Strings and quotes}.
7435
@node $UNSTRING, $VERBATIM, $UNQUOTE, Built-in functions
7436
@comment node-name, next, previous, up
7438
@subsubsection @code{$UNSTRING}: Convert string into characters
7441
@samp{$UNSTRING(@var{string})} removes quotes from the string, if they are
7442
present, and treats the result as a collection of characters. No
7443
tokenization is done, so macro expansion does not operate on those
7446
For a more detailed discussion and a comparison with @code{$UNQUOTE}
7447
(@pxref{$UNQUOTE}), see @ref{Strings and quotes}.
7449
@node $VERBATIM, $VERSION, $UNSTRING, Built-in functions
7450
@comment node-name, next, previous, up
7452
@subsubsection @code{$VERBATIM}: (Obsolete)
7455
This was an old name for @code{$UNQUOTE} (@pxref{$UNQUOTE}). Please
7456
remove all references to this macro from existing codes.
7458
@node $VERSION,,$VERBATIM,Built-in functions
7459
@comment node-name, next, previous, up
7461
@subsubsection @code{$VERSION}: Present @FWEB{} version number
7464
@cindex Version, of FWEB
7465
@samp{$VERSION} returns a string built out of the @FWEB{} version
7466
number, such as @code{"1.61"}.
7468
@node Debugging with macros, , Built-in functions, FWEB macros
7469
@comment node-name, next, previous, up
7471
@subsection Debugging with macros
7473
@cindex Macros, debugging with
7476
If an @FWEB{} macro expands to more than one output line, debugging
7477
can be a bit confusing if the debugger (e.g., @code{gdb}) displays lines
7478
in the @code{web} source file instead of the output file (as it normally
7479
does for C and C++). While single-stepping through the code, the
7480
debugger will incorrectly step the screen display for each output line
7481
even if the macro call occupies just one line in the source file. To
7482
localize the debugger's confusion, insert a @samp{@@#line} command after
7483
the macro call. For example,
7487
@@ Example of a macro that expands to several output lines.
7488
@@m UPDATE(i, delta_i)
7496
// More code. The debugger will be in sync from here on.
7500
An alternative for highly confusing situations is to use the @samp{-#}
7501
option (@pxref{-#}).
7503
Another potentially confusing situation occurs when @samp{@@%} is used
7504
to comment out a line. @FWEB{} deals with the line-number problem
7505
that arises here automatically; see @ref{-T#}.
7507
@node Macros and formatting, Preprocessing, FWEB macros, Macros
7508
@comment node-name, next, previous, up
7510
@cindex Macros, formatting
7511
@FWEAVE{} makes a valiant attempt to pretty-print
7512
(@pxref{Pretty-printing}) the definitions of
7513
both outer macros and @FWEB{} macros in a reasonable way. However, this
7514
can be a formidable task, because macro syntax can be essentially
7515
arbitrary. Consider, for example, the following definition:
7519
@@d GET(type) type get_##type()
7521
GET(int)@{@}@@; // @r{Expands into @samp{int get_int()@{@}}.}
7524
The problem is that the identifier @samp{type} is used in two different
7525
ways: as the type of a reserved word (the second @samp{type}), and as
7526
an ordinary expression (the third @samp{type}). The first @samp{type} has both
7527
meanings simultaneously. Unfortunately, within any particular language
7528
@FWEAVE{} associates one unique type or @dfn{ilk} with each identifier.
7530
One solution to this problem is to use the @samp{@@R} command
7531
(@pxref{ATR_}), which changes the ilk of the very next identifier to
7535
@@d GET(type) @@R type get_##type()@@;
7538
will format correctly. An alternative solution uses the related command
7540
changes the ilk of the very next identifier to an ordinary expression.
7545
@@d GET(type) type get_##@@Etype()@@;
7548
Other types of troublesome situations involve spaces. When @FWEB{}
7549
understands the syntax, it inserts spaces automatically to make the
7550
output pleasing. Consider, however, the (somewhat contrived) example
7561
Here @FWEAVE{} will consider @samp{x} and @samp{y} to be ordinary
7562
identifiers (simple expressions), and will abut them with no intervening
7563
spaces, which is confusing to read. The solution is to insert a space
7564
manually with @samp{@@,}:
7570
(Whether one should write macros like this at all is a separate issue.)
7571
For a related example, see the discussion of @ref{ATcomma}.
7573
@node Preprocessing,,Macros and formatting,Macros
7574
@comment node-name, next, previous, up
7576
@section Preprocessing
7578
@cindex Macros, preprocessing
7579
@cindex Preprocessing
7580
Generally, the @FWEB{} preprocessor commands follow a syntax identical
7581
to their C/C++ counterparts. The one exception is the @samp{@@#line}
7582
command. Whereas the C command takes a line number and file name as
7583
arguments, the @FWEB{} command takes no arguments; its expansion
7584
automatically inserts the current line number and file name. This
7585
command should be necessary only in rare circumstances. One of those
7586
involves situations in which an @FWEB{} macro expands to more than one
7587
output line; see @ref{Debugging with macros}.
7589
The @FWEB{} preprocessor commands may appear in either the definition or the
7590
code parts. But @emph{BEWARE: No matter where they appear, they are expanded
7591
during INPUT, not output.} (This is probably a design flaw.) For more
7592
discussion, see @ref{FWEB macros}.
7603
The syntax of each command is as follows:
7608
--- Insert a @code{#line} command.
7610
@item @@#define @var{identifier}
7611
--- Define an FWEB macro; equivalent to @samp{@@m}.
7612
@item @@#undef @var{identifier}
7613
--- Undefine an FWEB macro.
7615
@item @@#ifdef @var{identifier}
7616
--- Is FWEB macro defined? Equivalent to @w{@samp{@@#if defined identifier}}.
7617
@item @@#ifndef @var{identifier}
7618
--- Is FWEB macro not defined? Equivalent to @w{@samp{@@#if !defined identifier}}.
7620
@item @@#if @i{expression}
7621
@item @@#elif @i{expression}
7627
In the @samp{@@#if} statement, the @i{expression} may contain @FWEB{}
7628
macros, but must ultimately evaluate to a number. If that number is
7629
zero, the expression is false; otherwise, it is true.
7631
@cindex Expression evaluation
7632
The @i{expression} following constructions such as @samp{@@#if} is
7633
evaluated by a built-in expression evaluator that can also be used for
7634
other purposes, such as in macro expansion. Its behavior is again
7635
motivated by expression
7636
evaluation in ANSI C; it is not quite as general, but should be more than
7637
adequate. (One design flaw that will be fixed someday is that the order
7638
of expression evaluation is not necessarily left-to-right, as it is in C.)
7639
It supports both integer and floating-point arithmetic (with type
7640
promotion from integer to floating-point if necessary), and the ANSI
7641
@code{defined} operator. Operators with the highest precedence
7642
(see table below) are evaluated first; as usual, parentheses override the
7643
natural order of evaluation. The unary operator @code{defined}
7645
precedence; all the other unary operators have the next highest (and equal)
7646
precedence; then come the binary operators. When the operator exists in C,
7647
the action taken by @FWEB{} is precisely that that the C compiler would take.
7648
Arithmetic is done in either @b{long} or @b{double} variables, as
7649
implemented by the C compiler that compiled @FTANGLE{}. (This was the
7650
easy choice, not necessarily the most desirable one.)
7652
The operators, listed from highest precedence to lowest, are as
7655
(printed documentation only):
7661
\gdef\expr{{\it expr}}
7663
\chardef\TL=`\~% Tilde in a string: '\.\~'.
7664
\gdef\^{\ifmmode\raise0.45ex\hbox{$\,\scriptstyle\mathchar"25E\,$}%
7667
$$\def\<{{\rm ,$\,$}}
7668
\def\mod{\Mathop{mod}}
7669
\vtop{\halign{\tt\quad#\quad\hfil&\ ---\
7670
\vtop{\hsize=0.75\hsize\noindent\hang \strut#\strut}\hfil\cr
7671
\noalign{\medskip\leftline{@b{Unary operators}:}\smallskip}
7672
defined&@code{defined} is a unary operator that acts on identifier tokens.
7673
@samp{defined id} or equivalently @samp{defined(id)} evaluates to~1 (true) if
7674
the identifier is defined as an @sc{Fweb} macro;
7675
to~0 (false) otherwise. The construction @samp{@@\#if defined A} works the
7676
same way as @w{@samp{@@\#ifdef A}}, but one can use @samp{defined} in
7679
\hbox{@code{@@\#if defined(A) || defined(B)}}.
7681
(The parentheses around the macro names are optional.)
7682
With the advent of @samp{defined}, the
7683
@sc{Fweb} preprocessor statements @samp{@@\#ifdef} and @samp{@@\#ifndef}
7684
become redundant, but are often useful shorthands.\cr
7686
!&Logical \hbox{\.{NOT}}. \.{!\expr} evaluates to~0 if \.{\expr}
7687
is nonzero, and evaluates to~1 if \.{\expr} is~0.\cr
7688
\TL&One's complement of an integer. For example, $\.{\TL0} =
7690
\noalign{\medskip\leftline{@b{Binary operators}:}\smallskip}
7691
\^\^&Exponentiation (all languages). $2\hbox{\.{\^\^}}3 = 8$.\cr
7692
\^\<**&Exponentiation (@sc{Fortran} or @sc{Ratfor}).\cr
7693
*\</\<\%&Multiplication, division, and modulus:
7694
`\.{$a$ \% $b$}' means `$a \hbox{ mod } b$'; for example, \.{5 \% 3 = 2}. \cr
7695
+\<-&The usual plus and minus.\cr
7696
<<&`\.{$a$ << $b$}' means shift integer~$a$ left $b$~bits. $1 \ll
7698
>>&As above, but right-shift. $7 \gg 2 = 1$.\cr
7699
<\<<=\<>\<>=&Evaluates to~1 if the inequality holds, to~0 otherwise.
7700
E.g., `\.{(2.0 < 3.0)}' evaluates to~1.\cr
7701
==\<!=&`\.{$a$==$b$}' (`\.{$a$!=$b$'}) evaluates to~1 (0) if $a$
7702
equals~$b$; evaluates to~0 (1) otherwise.\cr
7703
\amp&Bitwise \hbox{\.{AND}}. The truth table is \.{0b1100 \amp{
7704
}0b1010 = 0b1000}.\cr
7705
\^&Bitwise \.{EXCLUSIVE OR} (C). (For @sc{Fortran}, use `\.{.xor.}'.)
7707
table is {\.{0b1100}~\.{.xor.}~\.{0b1010 = 0b0110}}.\cr
7708
|&Bitwise~\hbox{\.{OR}}. The truth table is \.{0b1100 | 0b1010 =
7710
\amp\amp&Logical~\hbox{\.{AND}}.\ `\.{$a$ \amp\amp{ }$b$}'
7711
evaluates to~1 if both~$a$ and~$b$ are true (nonzero).\cr
7712
||& Logical~\.{OR}. `\.{$a$ || $b$}' evaluates to~1 if either~$a$ or~$b$
7715
Note in particular the use of the single caret, which is
7716
language-dependent: it is an
7717
exponentiation operator for @sc{Fortran} (just as in @TeX{}), but is the
7718
exclusive-or operator for~C. Also, note that the bitwise operators
7719
should almost never be used. For
7720
logic, almost always one will be using @samp{==}, @samp{!=}, @samp{\&\&},
7724
@node Languages,Macros,Comments,Top
7725
@comment node-name, next, previous, up
7730
@cindex Language, global
7731
@FWEB{} has the ability to work with more than one source language
7732
during a single run. The language in effect at the beginning of the
7733
first section defines the @emph{global language}. Further language
7734
changes within a section have scope local to that section.
7736
Usually, `language' means a compiler language like @sc{Fortran} or C.
7737
These languages will be ``pretty-printed'' by @FWEAVE{}.
7738
Pretty-printing can be inhibited by turning on the N mode (globally,
7739
with the command-line option @samp{-N}; locally, with @samp{@@N}) or by
7740
selecting the @sc{verbatim} `language'; in both of these cases, the input
7741
text is echoed literally to the output of both @FTANGLE{} and
7744
`Language' is a stronger concept than `mode'. For example, when a
7745
language is selected, the extension of the tangled output file is
7746
changed appropriately---for example, if @file{test.web} contains C code
7747
(that is, contains the command @samp{@@c}), @file{test.web} tangles into
7748
@file{test.c} (compressing blanks and otherwise (deliberately) making
7749
the tangled output relatively unreadable) and @FWEAVE{} pretty-prints
7750
using the C syntax. Turning on the N mode does not affect the language;
7751
@FTANGLE{} copies the source code literally into @file{test.c} (no
7752
blank compression or other modifications), and @FWEAVE{} typesets the
7753
source code within a verbatim environment (no pretty-printing). When
7754
the @sc{verbatim} language is selected, the N mode is turned on
7755
automatically, but @FTANGLE{} writes its output to a file with a
7756
special default extension that can be customized in the style file.
7757
@xref{Miscellaneous params}.
7760
* Setting the language:: Setting the language.
7762
Special hints and considerations for each language.
7765
* Fortran:: Fortran--77 and Fortran--90.
7766
* Ratfor: Ratfor_. RATional FORtran.
7768
* Verbatim:: Literal mode.
7771
@node Setting the language, C, Languages, Languages
7772
@comment node-name, next, previous, up
7774
@section Setting the language
7776
@cindex Language, setting
7777
The most general form of a language command is
7780
@@@i{[}L@i{]ltext}[@i{options}]
7784
where @i{l} is a language symbol, @i{text} is converted into the
7785
option @samp{-@i{l}text}, and @i{options} have the same syntax as on the
7788
The language symbols must be in lower case; they are
7791
@multitable{..VERBATIM..}{cpp}
7792
@item C @tab @code{c}
7793
@item C++ @tab @code{c++}
7794
@item Fortran-77 @tab @code{n}
7795
@item Fortran-90 @tab @code{n9}
7796
@item Ratfor-77 @tab @code{r}
7797
@item Ratfor-90 @tab @code{r9}
7798
@item TeX @tab @code{x}
7799
@item VERBATIM @tab @code{v}
7803
An example of a command with the optional @i{text} field is @samp{@@n/}.
7804
By definition, this is equivalent to @samp{@@n[-n/]}. Thus, it both sets
7805
the language and invokes a command-line option.
7807
As another example, @samp{@@n9} really means @samp{@@n[-n9]}. Thus the
7808
language is first set to @sc{Fortran}, then reset to @sc{Fortran}-90.
7809
One doesn't need to worry about this detail.
7816
means set the language to @sc{Fortran}--90 and use free-form syntax with the
7817
ampersand as the continuation character. (This construction is now
7820
The brackets may contain more than one space-delimited option.
7822
A language command should appear somewhere in limbo, before the start of
7823
the first section. The language in effect at the beginning of the first
7824
section defines the global language. For historical reasons, the
7825
default language is @sc{Fortran}-77, but @emph{do not rely on this;
7826
always include a language command}.
7828
Language commands may be used within sections, but the new language
7829
remains in force only for that section. The language of a named module
7830
is inherited from the language in effect at the time the name is first
7831
used. Thus, in the following example, the global language is
7832
@sc{Fortran}--77, but an arbitrary number of C functions can be placed into a
7833
C-language module with just one @samp{@@c} language-changing command.
7852
@FTANGLE{} will write two output files for this example---e.g.,
7853
@file{test.f} and @file{test.c}. Particularly note that one did not
7854
need an @samp{@@c} command in the last section because the language was
7855
C when @samp{@@<C@@>} was first encountered.
7857
@section Special hints and considerations for each language
7859
One important thing to keep in mind is that in @FWEB{} an identifier
7860
may have, for each language, precisely one meaning throughout the
7861
document. This restriction is not necessarily in accord with the
7862
syntaxes of the various source languages. See, for example, the
7863
discussions in @ref{Cpp} and @ref{Fortran}.
7865
@node C, Cpp, Setting the language, Languages
7866
@comment node-name, next, previous, up
7868
@subsection Special considerations for C
7876
@cindex Binary notation
7877
@cindex Notation, binary
7878
@FTANGLE{} treats the construction @samp{0b...} as a binary notation
7879
that it expands to an unsigned decimal number. Thus, @samp{0b101}
7880
expands to 5 and @samp{0b1111111111111111} expands to 65535.
7883
@FWEAVE{} processes @b{typedef} statements during phase one, so they will
7884
format properly even if they are used in a documentation part before
7885
they are defined in a code part.
7888
The @samp{-H} option helps one to deal with identifiers defined in
7889
header files. @xref{-H_}.
7893
@cindex Tags, structure
7894
Note that in C structure and enum tags do not define a new type, so the
7895
tag name does not get highlighted in boldface, underlined in the index,
7896
etc. (That is, if one says @samp{struct S @{...@};}, one can't say
7897
@samp{S s;}, one must say @samp{struct S s;}.) This is a good reason
7898
for using C++, where such tags do define a new type.
7904
@node Cpp,Fortran,C,Languages
7905
@comment node-name, next, previous, up
7907
@subsection Special considerations for C++
7914
All of the items in the previous section (@pxref{C}) still apply.
7917
The @samp{@@@{} command is very useful for beautifying very short
7918
definitions of member functions such as constructors. @xref{ATlb}
7921
Essentially, @FWEAVE{} has only one name space, global to the entire
7922
code; those names do not obey any concept of scope. In various
7923
situations in C and C++, however, multiple namespaces are used, or the
7924
interpretation of a name changes according to its scope. Thus, the
7925
design of @FWEAVE{} imposes a few restrictions on one's programming
7926
style. (Remember, @FWEAVE{} doesn't know nearly as much as a language
7929
One example in C++ has to do with formal types in templates. Consider
7930
the following example:
7933
template <class Type>
7941
In order that the class definition be typeset correctly, @samp{Type}
7942
must be understood to be a reserved word like @b{int}, and that is
7943
correctly figured out by the first @b{class} command. However,
7944
according to C++, the scope of @samp{Type} is local to the class
7945
definition; unfortunately, @FWEAVE{} does not respect that locality and will
7946
always treat @samp{Type} as an @b{int} from the point of the
7947
@samp{class Type} construction to the end of the source code. Thus, one
7948
should use such dummy variables as @samp{Type} only as formal template
7949
parameters, never as ordinary variables.
7953
@node Fortran,Ratfor_,Cpp,Languages
7954
@comment node-name, next, previous, up
7956
@subsection Special considerations for @sc{Fortran}
7958
@cindex Hints, @sc{Fortran}
7959
@cindex @sc{Fortran} hints
7961
@subsubsection Items for both @sc{Fortran}-77 and @sc{Fortran}-90
7966
@cindex Binary notation
7967
@cindex Notation, binary
7968
@cindex Octal notation
7969
@cindex Notation, octal
7970
@cindex Hexadecimal notation
7971
@cindex Notation, hexadecimal
7972
@FTANGLE{} will translate into unsigned decimal numbers the binary
7973
notation @samp{0b...}, the octal notation @samp{0...}, and the
7974
hexadecimal notation @samp{0x...}. Thus, @samp{0b101} expands to 5,
7975
@samp{0101} expands to 65, and @samp{0x101} expands to 257.
7978
Don't use the column 1 @samp{C} commenting convention. Use @samp{/*
7979
... */} or @samp{// ...}.
7982
For compiler directives, use @samp{@@?} (@pxref{AT?}), not a @samp{C} in
7986
If you are going to use the recommended @samp{// ...} convention for
7987
short comments, you must say @samp{@@n/} (@pxref{-n/}) or
7988
@samp{@@n9[-n/]} as your language command. Otherwise, \FWEB\ will treat
7989
the @samp{//} as \@sc{Fortran's} standard token for concatenation. (You
7990
may always use @samp{\/} for concatenation.)
7993
@cindex Code, temporarily commenting out
7994
If you want to completely comment out a whole block of code,
7995
use the preprocessor construction @samp{@@#if 0...@@#endif}
7996
(@pxref{Preprocessing}). Don't put a comment character at the beginning
7997
of each line; that prevents @FWEAVE{} from formatting the code
7998
sensibly and can be annoying to undo. With the preprocessor form, one
7999
can also implement conditional comments by using @FWEB{} preprocessor
8000
macros: e.g., @samp{@@#if(DEBUG)...@@#endif}.
8002
Pre-@FWEB{} codes may have such blocks commented out with a @samp{C}
8003
in column 1. Those should be converted to the preprocessor
8004
construction. However, if you're in a real hurry, temporarily use the
8005
@samp{-nC} option (@pxref{-nC}) to kill those lines very early in the
8006
processing, before they can give you all kinds of trouble.
8009
@cindex Comments, short
8010
An unfortunate byproduct of using @samp{//} for short comments is that,
8011
in general, format constructions like @code{format(//)} won't work. (It
8012
will work if one uses @samp{-nC}; see @ref{-nC}.) Alternatively, one
8013
can say @code{format(/ /)}.
8016
Consecutive lines commented out with a @samp{C}, @samp{c}, @samp{*}, or
8017
@samp{!} in column 1 are converted into a single comment before
8018
processing by @FWEB{}. Large blocks of such lines (common in
8019
pre-@FWEB{} code) may overflow @FWEB{}'s tables. To avoid that,
8020
insert blank lines between some of the comments. Better, however, is to
8021
move most such blocks out of the code part to the @TeX{} part of the
8022
section. It's most readable to have only a few very short comments
8023
interspersed in the code.
8025
To help with conversion of existing codes, the command-line option
8026
@samp{-nC} can be used to completely ignore comment lines.
8029
@samp{@@} commands should, by and large, start in column 1. That's not
8030
necessary for short module names that fit on one line. However, a long
8031
module name that must be broken across lines must begin in column 1, as
8038
@@<This is a module name
8039
broken across lines@@>@@;
8042
Failure to do this results in a spurious semicolon being inserted in the
8043
middle of the name. This happens because the @sc{Fortran}-77 input driver
8044
does various low-level manipulations of the source before it presents it
8045
to the innards of @FWEB{}; it's not tokenizing the source at that time
8046
and doesn't understand all of the @FWEB{} syntax such as module names.
8049
Define symbolic statement labels with @samp{#:0}
8050
(@pxref{Tokens}). Such names should be followed by a colon. Thus,
8069
By default, statement labels are @code{\llap}'d from the body of the
8070
statement. With this convention, long labels can extend too far into
8071
the left margin. Instead, try the command-line option @samp{-n:}
8072
(@pxref{-ncolon}), which puts them on a separate line. Alternatively, one
8073
can redefine the macro @code{\Wlbl}, found with some discussion in
8078
@cindex Keywords, I/O
8080
As a suggestion, use upper case for I/O keywords such as @code{IOSTAT}.
8081
However, by default the lower-case forms are also recognized. To permit
8082
only upper case, use @samp{-k} (@pxref{-k}). Note that although there
8083
is a command @samp{-nk}, it is unfortunately not related to @samp{-k}.
8086
@cindex Exponentiation
8087
One may use @samp{^} as an alternative for the exponentiation operator
8092
@cindex Assignment operators, compound
8093
@FWEB{} attempts to be helpful and tries to expand the operators
8094
@samp{++}, @samp{--}, @samp{+=}, @samp{-=}, @samp{*=}, and @samp{/=}
8095
in a way compatible with the usage in C and C++. For example, it
8096
expands @w{@samp{x += y}} into @w{@samp{x = x + (y)}}. This feature can be a
8097
great time-saver and also makes the code substantially more legible; it
8098
is strongly recommended. To turn off this feature, use the option
8099
@samp{-+}. @xref{-plus}.
8102
Notice that in @sc{Fortran}-90 @samp{/=} is a token for ``not equal,''
8103
so if you want to use that you must use the @samp{-+} option. However,
8104
a better solution is to use @samp{!=}, @FWEB{}'s preferred operator
8110
By default, the operators @code{.true.} and @code{.false.} will weave as
8111
caligraphic T and F. That appearance be changed by redefining the macros
8112
@code{\WTRUE} and @code{\WFALSE} in @file{fwebmac.sty} or in the limbo
8113
section of your source file.
8117
If @FTANGLE{} messes up and outputs incorrect @sc{Fortran} code, try
8118
tangling with the command-line option @samp{-#} (@pxref{-#}) (and then
8119
report the problem.)
8123
@subsubsection Items specific to @sc{Fortran}-77 and fixed-form @sc{Fortran-90}
8128
@cindex Semicolons, automatic
8129
@cindex Automatic semicolons
8130
By default, when processing the code part the
8131
@sc{Fortran} driver inserts semicolons automatically at the end of each
8132
logical statement. Thus, the core of @FWEB{} is presented with a
8133
uniform syntax. However, when one escapes into code mode by using
8134
vertical bars, those semicolons aren't inserted, so something that
8135
appears a first glance to be complete statement may not be formatted as
8136
one might expect. Thus, the construction @samp{|5: continue|} doesn't
8137
format quite properly (the colon disappears); this problem is solved by
8138
putting a semicolon after the @samp{continue}. Also, if one is talking
8139
about multiple statements (for example, with a shift into code mode
8140
during @TeX{} documentation), there's no choice but to insert the
8141
semicolon between statements. For example, @w{@samp{|a = b; c = d;|}}.
8145
@subsubsection Items specific to @sc{Fortran}-90
8150
@cindex Syntax, free-form
8151
If @sc{Fortran}-90 is selected (@pxref{-n9}), the default is
8152
@emph{free-form} syntax (lines are continued by a trailing ampersand).
8153
However, automatic line breaking is done in a way compatible with
8154
fixed-form syntax as well.
8158
With free-form syntax, comment lines in the tangled output file begin
8159
with @samp{!}. But such lines are not recognized on input unless
8160
@samp{-n!} is used. @xref{-n!}.
8163
@cindex Pseudo-semicolons, automatic
8164
@cindex Automatic pseudo-semicolons
8165
Beginning with Version 1.61, by default (pseudo-)semicolons are automatically
8166
inserted in free-form \Fortran-90 code, as one would expect. For more
8167
discussion, see @ref{-nAT;} and @ref{-n;}.
8173
@node Ratfor_,TeX,Fortran,Languages
8174
@comment node-name, next, previous, up
8176
@subsection Special considerations for @sc{Ratfor}
8178
For some warnings about @sc{Ratfor}, see @ref{Caveats}.
8180
@node TeX, Verbatim, Ratfor_, Languages
8181
@comment node-name, next, previous, up
8183
@subsection Special considerations for TeX
8185
@cindex Hints, @TeX{}
8186
@cindex @TeX{} hints
8187
@samp{@@Lx} is supported only to the extent that @code{fwebmac.sty} can
8188
be generated correctly from @code{fwebmac.web}. You are welcome to
8189
experiment, but you may encounter difficulties (which you should report;
8194
@node Verbatim, , TeX, Languages
8195
@comment node-name, next, previous, up
8197
@subsection Special considerations for the @sc{verbatim} language
8199
Unfortunately, the @sc{VERBATIM} language is not fully debugged.
8200
Therefore, it is not recommended for general use.
8203
@node Ratfor,Documentation,Macros,Top
8204
@comment node-name, next, previous, up
8206
@chapter @sc{Ratfor}
8209
@cindex @sc{Fortran}, Rational
8210
@cindex Rational @sc{Fortran}
8211
``@sc{Ratfor}'' stands for ``@sc{RATional} @sc{FORtran}.'' It endows
8213
C-like syntax. Certain loop and other constructions (such as
8214
@samp{switch} or @samp{i++}) that are not allowed in @sc{Fortran} are allowed
8215
in @sc{Ratfor}; @FWEB{} translates those into proper @sc{Fortran}.
8217
Although @sc{Ratfor} is a definite improvement over @sc{Fortran}, it certainly
8218
does not have the power of C (e.g., elegant pointer notation) or C++
8219
(e.g., classes). Many advantages accrue by taking the time to learn C.
8220
@sc{Ratfor} offers a gentle transition. (It is not supported very
8224
* Syntax: RSyntax. Ratfor syntax.
8225
* Commands:: Ratfor commands.
8226
* Caveats:: Nuances about @FWEB{} Ratfor.
8229
@node RSyntax, Commands, Ratfor, Ratfor
8230
@comment node-name, next, previous, up
8232
@section @sc{Ratfor} syntax
8234
A sample @sc{Ratfor} program is
8258
The concluding brace of a function is translated into an @b{END}
8259
statement. Note the use of semicolons to terminate statements, braces
8260
to delimit compound statements, @samp{<} instead of @samp{.LT.}, the
8261
C-like @b{for} construction, and the @samp{k++} expression.
8263
Constructions like @samp{k++} or @samp{k -= l + 1} must be used with
8264
great care. They translate to statements involving @samp{=} signs, so they
8265
can be used only where simple statements are allowed, not essentially
8266
anywhere as in C (for example, they cannot be used as function
8269
@node Commands,Caveats,RSyntax,Ratfor
8270
@comment node-name, next, previous, up
8272
@section @sc{Ratfor} commands
8274
@subsection @sc{Ratfor}--77 commands
8276
@cindex @sc{Ratfor} commands
8278
break; // @r{Used with @code{case} or to break out of loops, as in C.}
8279
case i: // @r{Used with @code{switch}.}
8280
default: // @r{Used with @code{case}, as in C.}
8281
do ...; @{...@} // @r{Note the semicolon (unnecessary if followed by a compound stmt).}
8282
else @{...@} // @r{Used after @code{if} as in C.}
8283
for(a;b;c) @{...@} // @r{As in C.}
8284
if(condition) @{...@}
8285
next; // @r{Equivalent to C's |continue| statement; go to bottom of loop.}
8286
repeat @{...@} until(condition); // @r{Equivalent to C's @code{do @{...@} while();}}
8287
return expression; // @r{As in C.}
8288
switch(expression) @{...@} // @r{As in C.}
8289
while(condition) @{...@} // @r{Like C's @code{while}.}
8292
@subsection Additional @sc{Ratfor}--90 commands
8296
interface name @{...@}
8297
interface operator(op) @{...@}
8298
interface assignment(assgnmnt) @{...@}
8303
where(expression) @{...@}
8306
@node Caveats,,Commands,Ratfor
8307
@comment node-name, next, previous, up
8309
@section Caveats about @sc{Ratfor}
8311
@cindex @sc{Ratfor}, caveats about
8312
The version of @sc{Ratfor} built into @FWEB{} differs slightly from its @sc{unix}
8318
Numeric statement labels must be followed by a colon; they should
8319
be first on their line. (Use symbolic statement labels instead; see the
8320
discussion of @samp{#:0} in @ref{Tokens}.)
8323
The quoting convention for characters and strings follows that
8324
of C: Single-quote single characters, double-quote strings.
8327
In a @b{switch}, cases fall through to the next case unless
8328
terminated by @b{break} (just as in C).
8331
The @b{do} statement must be terminated by a semicolon if
8332
followed by a simple statement. (It's unnecessary if followed by a left
8333
brace that begins a compound statement.)
8336
Use @t{&&} and @t{||} for the logical AND and OR.
8339
Do not use an @b{end} statement at the very end of a @sc{Ratfor} program
8340
unit; it is added automatically by @FWEB{} when the closing brace is sensed.
8345
@node Documentation,Index,Ratfor,Top
8346
@comment node-name, next, previous, up
8348
@chapter DOCUMENTATION
8351
@cindex Documentation format
8352
@FWEB{} uses La@TeX{} to produce its documentation. Plain @TeX{}
8353
is no longer supported.
8355
It is not necessary to be very familiar with La@TeX{} in order to use
8356
@FWEB{} effectively. @FWEB{} does complicated things behind
8357
the scenes, relieving the programmer of many burdens. If you don't need
8358
complicated mathematics, one needs to know virtually no La@TeX{} at all
8359
in order to document a section of code. And if you do need to typeset
8360
math, consider that La@TeX{} makes this daunting task about as simple as
8363
If you're an @FWEB{} beginner, don't bother diving into the details of
8364
this section until you really need to.
8367
* Typesetting:: Woven output; TeX vs. LaTeX, etc.
8368
* Pretty-printing:: Turning ugly input into beautiful output.
8371
@node Typesetting, Pretty-printing, Documentation, Documentation
8372
@comment node-name, next, previous, up
8374
@section Typesetting
8377
@FWEB{}'s ``new look'' (beginning with version 1.40) is designed
8378
to work only with La@TeX{}. The new look is more
8379
book-like, following ideas from Briggs' @code{nuweb}. By default, it
8380
uses default La@TeX{} section numbers such as 1.5.32; however, sections
8381
may be numbered with consecutive integers by specifying the La@TeX{}2e package
8382
@code{fwebnum}; see @ref{Numbering}.
8385
* Output:: Structure of the TeX output from @FWEAVE{}.
8386
* fwebmac.sty:: The macro package used with @FWEAVE{}.
8387
* LaTeX:: Specifics of the LaTeX support.
8390
@node Output, fwebmac.sty, Typesetting, Typesetting
8391
@comment node-name, next, previous, up
8393
@subsection @FWEAVE{}'s OUTPUT
8395
When one says @samp{fweave test}, the file @file{test.tex} is created.
8396
Some @TeX{} commands contained in this file are created automatically;
8397
others are copied from the web source file. They are organized into several
8398
sequential groups, as follows.
8403
@code{\input} command to read in @FWEAVE{}'s macro package.
8406
By default, the initial input command is @samp{\input fwebmac.sty}
8407
(@pxref{fwebmac.sty}). The name of the macro package can be changed
8409
the @samp{-w} command-line option, but that is dangerous and useful only for
8410
very special effects. @xref{-w}.
8413
@code{\Wbegin} command.
8415
The @code{\Wbegin} macro sets up certain defaults (which can be overridden in
8416
the limbo section). In La@TeX{}, it also issues the
8417
@samp{\documentclass@{article@}} and @samp{\begin@{document@}} commands.
8420
Limbo text from the style-file parameter @code{limbo.begin}. @xref{S_limbo}.
8423
Limbo text from @samp{@@l} commands. @xref{ATl}.
8426
User's limbo section.
8429
Limbo text from the style-file parameter @code{limbo.end}.
8433
@TeX{} commands for individual WEB sections.
8436
@code{\input} command to read in the index data file.
8439
@code{\input} command to read in the module-list data file.
8442
@code{\Winfo} command (summarizes some status information).
8445
@code{\Wcon} command (generates the Table of Contents, and ends the run).
8451
@node fwebmac.sty, LaTeX, Output, Typesetting
8452
@comment node-name, next, previous, up
8454
@subsection The macro package @file{fwebmac.sty}
8457
@FWEAVE{} works in conjunction with the macro package
8458
@file{fwebmac.sty}, which is always read into the @file{.tex} file by
8459
default. This file is (overly) complicated, so one should not mess with
8460
it unless in dire emergency. Most of its commands are intended for
8461
behind-the-scenes processing. However, some features may be of general
8462
interest; these are described in the items below.
8464
For the most part, macros used internally by @file{fwebmac.sty} begin
8465
with an uppercase @samp{W}. If you are worried about macro conflicts, a
8466
complete list of the macros appearing in @file{fwebmac.sty} can be found
8467
in the Index produced by weaving @file{fwebmac.web}.
8470
* User macros:: Macros defined for user convenience.
8471
* Fonts:: Useful font commands.
8474
@node User macros, Fonts, fwebmac.sty, fwebmac.sty
8475
@comment node-name, next, previous, up
8477
@subsubsection User macros
8479
For the user's convenience, @file{fwebmac.sty} defines a variety of
8480
macros such as @samp{\FWEB}, @samp{\Fortran}, etc. Refer to
8481
@file{fwebmac.web} for a complete list.
8483
@FWEAVE{} usurps various common single-character macros such as @samp{\.} for
8484
its own purposes. So the user can still access their original
8485
definitions, those are @samp{\let} equal to alternative commands
8486
such as @samp{\period}. For example, commands such as the following are
8487
executed in @code{fwebmac.sty}:
8505
(Some of the more inscrutable synonyms are for historical reasons.)
8507
For the most up-to-date and detailed information, refer to @file{fwebmac.web}.
8509
@node Fonts, , User macros, fwebmac.sty
8510
@comment node-name, next, previous, up
8512
@subsubsection Fonts
8515
Several fonts have been declared.
8521
@samp{\titlefont} (large sans serif),
8524
@samp{\ttitlefont} (large typewriter),
8527
@samp{\SC} (small caps),
8530
@samp{\Csc} (Caps/small caps), and
8533
@samp{\tentex} (@TeX{}'s extended character set).
8539
For illustrations and further details, see @file{fwebmac.web}.
8541
To typeset a string of characters in typewriter type, one may use the
8542
@samp{\.} macro. (More precisely, the name of this macro is the value
8543
of the style-file parameter @code{format.typewriter}. For more
8544
information, see @ref{S_format}.)
8545
When using this, one must escape the special
8546
characters @samp{ \#%$^_@{@}~&}, as in @samp{\.@{\\alpha@}}. (@FWEAVE{}
8547
does that escaping automatically when typesetting strings in code mode.)
8548
You may wish to surround @samp{\.@{...@}} with an @samp{\hbox}; that is
8549
not done by default because @FWEAVE{} uses special trickery to break
8550
long strings in code mode automatically, and that breaking would be
8551
inhibited by an @samp{\hbox}.
8553
@node LaTeX, , fwebmac.sty, Typesetting
8554
@comment node-name, next, previous, up
8556
@subsection La@TeX{} support
8560
Original La@TeX{} support (through version 1.30) was substantially
8561
incomplete in that La@TeX{}'s @code{\output} routine was usurped by the
8562
relatively simple one used for @FWEB{}'s @TeX{} support. However,
8563
beginning with version 1.40, full La@TeX{} support is provided (and
8564
Plain @TeX{} is @emph{not} supported); version 1.50 supports La@TeX{}2e.
8565
La@TeX{}'s @code{\output} routine is used, as are its sectioning
8566
commands (with minor changes), Table-of-Contents facilities, etc.
8568
The following discussion is based on La@TeX{}2e. If La@TeX{}2e is not
8569
installed, @FWEAVE{} recognizes that fact and issues the
8570
@samp{\documentstyle} command instead of @samp{\documentclass}.
8571
@findex \documentstyle
8573
Users are strongly encouraged to upgrade to La@TeX{}2e. A useful book
8574
that describes the present state of La@TeX{} is Goossens, Mittelbach,
8575
and Samarin, @cite{The La@TeX{} Companion} (Addison--Wesley, Reading, MA,
8579
* Document class:: LaTeX's document class, options, etc.
8580
* REVTeX:: The REV@TeX{} scientific macro package.
8581
* Packages:: Special FWEB-related La@TeX{}2e packages.
8582
* Sections:: Section numbering, spacing, etc.
8583
* Index:LIndex. Technical details about multi-columns and the Index.
8584
* Table of Contents:: The Table of Contents.
8585
* Customizing LaTeX:: Conditional flags, etc.
8586
* Inserting woven code:: How to insert @FWEAVE{}'s output into a La@TeX{} document.
8589
@node Document class, REVTeX, LaTeX, LaTeX
8590
@comment node-name, next, previous, up
8592
@subsubsection La@TeX{}'s document class
8594
@findex \documentclass
8595
An @FWEB{}/La@TeX{} document is set up with the @samp{\Wbegin}
8596
command, issued automatically by @FWEAVE{}. See the summary at the
8597
end of this section for the essence of what the @samp{\Wbegin} command
8600
@FWEAVE{} uses @code{\documentclass@{article@}} by default. In
8601
principle, the document class can be changed by the @FWEB{} style-file
8602
option @samp{LaTeX.class}; see @ref{Fwebmac params}. However,
8603
@emph{@FWEAVE{} has not been tested with most other document classes}.
8604
It will probably not work with most document classes that redefine the
8605
sectioning commands from those of @code{\documentclass@{article@}}.
8606
However, it @emph{may} work with the @code{revtex} scientific macro
8607
package. @xref{REVTeX}.
8609
To incorporate class options---i.e., to obtain the effect of
8610
@samp{\documentclass[myoptions]@{article@}}---use the style-file parameter
8611
@code{LaTeX.class.options}, as in
8612
@cindex Class options
8613
@cindex Options, class
8616
LaTeX.class.options "myoptions"
8619
To get two-sided printing, for example, one would say
8620
@cindex Printing, two-sided
8623
LaTeX.class.options "twoside"
8627
@cindex User packages
8628
@cindex Packages, user
8629
To specify user packages---i.e., to obtain the effect of
8630
@samp{\usepackage[pkgoptions]@{pkgname@}}---use the style-file parameters
8631
@code{LaTeX.package} and @code{LaTeX.package.options}, as in
8634
LaTeX.package "pkgname"
8635
LaTeX.package.options "pkgoptions"
8638
For example, to indent the first line of every section and to permit the
8639
use of the @code{multicol} package (the latter is a useful way of
8640
substantially cutting down on white space), say
8643
LaTeX.package "indentfirst,multicol"
8646
Note that specifying @code{LaTeX.package} and
8647
@code{LaTeX.package.options} results in the execution (by the
8648
@code{\Wbegin} macro) of precisely @emph{one} line of the form
8651
\usepackage[myoptions]@{mypackages@}
8654
Sometimes one instead needs to have multiple @code{\usepackage} lines,
8658
\usepackage[option1]@{package1@}
8659
\usepackage[option2]@{package2@}
8662
To get this effect, one can put these commands explicitly into the
8663
style-file parameter @code{doc.preamble} (see discussion two paragraphs
8667
doc.preamble = "\\usepackage[option1]@{package1@}\
8668
\\usepackage[option2]@{package2@}"
8671
@TeX{} commands in the user's limbo section of the @code{web} source
8672
file will be processed @emph{after} the @code{\begin@{document@}}
8673
command. Limbo commands from the style file can be inserted before
8674
and/or after those in the limbo section with the aid of the style-file
8675
parameters @samp{limbo.begin} and @samp{limbo.end}; see @ref{S_limbo}.
8677
If there is a compelling reason to insert one's own La@TeX{}
8678
commands between the @samp{\usepackage} and @samp{\begin@{document@}}
8679
commands, one may use the style-file parameter @samp{doc.preamble},
8680
whose value is a string consisting of La@TeX{} commands (empty by
8681
default). Those commands are processed immediately before
8682
@samp{\begin@{document@}}. One use of @samp{doc.preamble} is to inhibit
8683
@FWEB{}'s tendency to keep a section together on one page. To make it
8684
break more readily in the middle of sections (particularly useful for
8685
multicolumn output), say
8688
doc.preamble "\\secpenalty=0"
8691
In summary, the beginning of the file output by @FWEAVE{} looks like
8692
the following, where @samp{<parameter>} means the contents of the
8693
style-file string called @samp{parameter}:
8697
\Wbegin@{many obscure arguments@}
8699
Optional TeX commands copied from user's limbo section
8705
The @samp{\Wbegin} command essentially does the following:
8708
\documentclass[<LaTeX.class.options>]@{<LaTeX.class>@}
8709
\usepackage[<LaTeX.package.options>]@{<LaTeX.package>@}
8714
For precise information about how @samp{\Wbegin} works, see
8715
@code{fwebmac.web}. If you feel that macro absolutely needs to be
8716
changed, please inform the developer (@pxref{Support}).
8718
@node REVTeX, Packages, Document class, LaTeX
8719
@comment node-name, next, previous, up
8721
@subsubsection Using REV@TeX{}
8723
REV@TeX{} is the standard macro package used for formatting scientific
8724
papers submitted to the American Physical Society, the American
8725
Institute of Physics, and some European journals. It modifies the
8726
sectioning commands of @code{\documentclass@{article@}} and provides
8727
various other useful macros.
8729
Unfortunately, as of August, 1998, REV@TeX{} is not fully compatible
8730
with La@TeX{}2e; it must be invoked with
8731
@code{\documentstyle@{revtex@}}, not @code{\documentclass}. This is
8732
annoying, because @FWEB{}'s macros in @file{fwebmac.sty} default to
8733
@code{\documentclass} if they recognize that La@TeX{}2e is loaded.
8735
To use REV@TeX{}, uncomment the line in @file{fwebmac.sty} that says
8736
@code{\useREVTeXtrue}. (One cannot say @samp{\useREVTeXtrue} in the
8737
limbo section of one's @code{web} source, because the document class has
8738
already been selected by that time.) You may wish to rename the
8739
resulting file, say to @file{rwebmac.sty}, so it can be loaded in place
8740
of the standard @file{fwebmac.sty}. To do that, one would use the
8741
command-line option @samp{-wrwebmac.sty} (see @ref{-w}).
8743
Saying @code{\useREVTeXtrue} selects @code{\documentstyle} rather than
8744
@code{\documentclass}. To implement a standard command such as
8745
@code{\documentstyle[aps,my_macros]@{revtex@}}, use the style-file
8746
(@file{fweb.sty}) parameters @code{LaTeX.style} and
8747
@code{LaTeX.options}, as in
8750
LaTeX.style "revtex"
8751
LaTeX.options "aps,my_macros"
8754
Here @file{my_macros.sty} would be a user's macro package loaded in
8755
addition to those of REV@TeX{} and @FWEB{}.
8757
REV@TeX{} support is extremely recent. There may be glitches; please
8758
report those. In a pinch, if La@TeX{} stops while processing a
8759
REV@TeX{} file produced by @FWEAVE{}, try typing `s' (scroll mode) to
8760
force it to continue; you might get usable output.
8762
@node Packages, Sections, REVTeX, LaTeX
8763
@comment node-name, next, previous, up
8765
@subsubsection La@TeX{} packages related to @FWEB{}
8767
The following packages are supplied with the @FWEB{} distribution and
8768
can be used to achieve special effects. Packages are invoked by giving
8769
their names as arguments to the @code{LaTeX.package} command; see
8775
@code{fwebinsert} --- Enables insertion of woven code into a La@TeX{}
8777
@xref{Inserting woven code}.
8780
@code{fwebnum} --- Number each section in ascending integer order.
8784
@code{idxmerge} --- Merge several stand-alone indexes. @xref{Merging indexes}.
8790
* fwebinsert:Inserting woven code. Enable insertion of woven code into a La@TeX{} document.
8791
* fwebnum:Numbering. Number each section in ascending order.
8792
* idxmerge:Merging indexes. Merge several stand-alone indexes.
8795
@node Sections, LIndex, Packages, LaTeX
8796
@comment node-name, next, previous, up
8798
@subsubsection Sections in La@TeX{}
8800
@cindex La@TeX{} section
8803
@findex \subsubsection
8804
@FWEB{}'s sectioning commands @samp{@@*} and @samp{@@*@i{n}}
8806
La@TeX{}'s section commands such as @code{\section} (@i{n}=0),
8807
@code{\subsection} (@i{n}=1), and
8808
@code{\subsubsection} (@i{n}=2). During La@TeX{}'s processing of the
8809
@code{.tex} file, it
8810
keeps track of the maximum depth achieved by @samp{@@*@i{n}}. This number is
8811
written as the last item in the @file{aux} file. During the next
8813
that number is used to map the untitled @ASP{} commands to the next most
8814
insignificant sectioning command. That level of sectioning command is
8815
slightly redefined from La@TeX{}'s default, so don't try to redefine it.
8817
The previous scheme means that it may be necessary to run La@TeX{} as
8818
many as three times in order to resolve all sectioning and
8819
cross-reference information correctly. You should be warned in such
8820
cases. If not, you will recognize difficulties by noting that the Table
8821
of Contents or section numbering is incomplete.
8823
The @file{aux} file is also used by both processors to generate
8824
appropriate error messages that refer to the La@TeX{} section number
8825
instead of the internal one.
8827
A discussion of alternative section-numbering schemes is given in
8830
@node LIndex, Table of Contents, Sections, LaTeX
8831
@comment node-name, next, previous, up
8833
@subsubsection La@TeX{}'s index.
8837
@findex \beforeindex
8840
The Index should be the last section of the code, and should be begun by the command @samp{@@* \INDEX.}. For more
8841
information, see @ref{S_index}.
8843
The challenge of typesetting the Index is to get it into two-column mode
8844
in the best possible way. In the original Plain-@TeX{} @FWEB{},
8845
special code was provided for this. With La@TeX{}, however, one wants
8846
to use standard features.
8848
@cindex @code{multicol}, using
8849
@cindex Package, @code{multicol}
8850
@findex multicol.sty
8852
The best solution is to use the user package @code{multicol}. If that
8853
is loaded by means of the style-file statement @samp{LaTeX.package
8854
"multicol"}, then any text typed by the user following the @samp{@@*
8855
\INDEX.} command will
8856
be typeset in single-column mode, after which two-column mode is
8857
entered. If it is not loaded, a @samp{\twocolumn} command is issued
8858
@emph{before} the index section is begun (in order to get the Index
8859
started on a new page).
8861
More precisely, what happens is the following. When the @samp{@@*
8862
\INDEX.} command is recognized, essentially the following operations are
8863
performed, where the results are bracketed in the form @samp{[multicol :
8867
\beforeindex [\newpage : \twocolumn]
8868
[print INDEX section heading]
8869
\startindex [\begin@{multicols@}@{2@} : \medskip]
8870
\Wfin [\end@{multicols@} : \relax]
8873
(Use of the asymmetrical name @samp{\Wfin} is for historical reasons.)
8875
@cindex Columns, multiple
8876
The positioning of @samp{\beforeindex} suggests a way of printing the
8877
entire document in two-column mode. If one enters multi-column mode in
8878
the limbo section, then @samp{\beforeindex} can be used to terminate it.
8879
It is best to do this at the @emph{end} of the limbo section; otherwise
8880
user macro definitions in the limbo section must be made @code{\global} in order
8881
that they remain defined in the Index. The relevant commands can be
8882
placed in the style file:
8885
LaTeX.package "multicol"
8887
doc.preamble "\\secpenalty=0"
8889
limbo.end "\\def\\beforeindex@{\\end@{multicols@}\\newpage@}\n\
8890
\\begin@{multicols@}@{2@}\n\
8894
Just to repeat, use only the first command to get just the Index printed
8895
in two-column format; use the second and third ones to make the entire
8896
document two-column.
8898
@node Table of Contents, Customizing LaTeX, LIndex, LaTeX
8899
@comment node-name, next, previous, up
8901
@subsubsection La@TeX{}'s Table of Contents
8903
@cindex Contents, table of
8904
@cindex Table of Contents
8906
La@TeX{} uses the @file{aux} file to accumulate the information for the
8909
When La@TeX{} is used, the Table of Contents appears at the front of the
8910
document by default (beginning with version 1.61). This is accomplished
8911
by setting the default value of the style-file parameter
8912
@code{limbo.end} to @code{"\\FWEBtoc"}, where @code{\FWEBtoc} is defined
8913
in @file{fwebmac.sty}. If you initialize @code{limbo.end} yourself in
8914
@file{fweb.sty}, you should include @code{"\\FWEBtoc"} at the end of
8915
that initialization if you want the Table of Contents to appear in the
8916
beginning. Otherwise, it will appear at the end.
8918
In essence, the Table of Contents is produced by the La@TeX{} commands
8921
\pagenumbering@{roman@}
8930
@findex \topofcontents
8931
@findex \botofcontents
8935
By default, the @FWEB{} hooks @code{\topofcontents} and
8936
@code{\botofcontents} are empty,
8937
but they may be used in special circumstances to override the usual
8938
behavior. One can set the parameters for @code{\maketitle} in the limbo
8939
section in the usual La@TeX{} way, except that it is better to use
8940
@FWEB{}'s @code{\Title} macro instead of @code{\title}:
8943
\Title@{MYCODE.WEB@}
8945
\date@{January 1, 2001@}
8948
By default, the argument of the @code{\Title} macro is printed both on
8949
the title page and as a running headline in the document. The default
8950
font for the title is @code{\ttitlefont}; that for the running headline
8951
is @code{\large\tt}. However, @code{\Title} has one optional argument
8952
that allows one to override the running headline, perhaps by specifying
8956
\Title[@i{Short title}]@{@i{Long title}@}
8959
to make the running headline be @samp{\large\tt @i{Short title}} and the
8960
title-page title be @samp{\ttitlefont @i{Long title}}.
8962
The \@FWEB{} @code{\Title} macro calls La@TeX{}'s @code{\title} macro
8963
with the long title as its argument.
8964
By default, @FWEAVE{} uses (in the @samp{\Wbegin} macro)
8969
\date@{\today\\[3pt]\Time@}%
8973
Section numbers in the Table of Contents are produced by the La@TeX{}
8974
macro @code{\numberline}. La@TeX{}'s default definition is inadequate
8975
when section numbers are very large; they extend to the right and can
8976
overwrite the section name. The macro is redefined more appropriately
8977
when the package @code{fwebnum} (@pxref{Numbering}) is used.
8979
@node Customizing LaTeX, Inserting woven code, Table of Contents, LaTeX
8980
@comment node-name, next, previous, up
8982
@subsubsection Customizing La@TeX{}'s output
8984
Several (@TeX{}) flags are provided to change the appearance of the final
8985
La@TeX{} document. (This appearance is a bit experimental, and it is
8986
fair to say that not everything may be fully debugged; please report
8987
problems.) These are (@samp{...} means either @samp{true} or @samp{false})
8993
@code{\pagerefs...} (index references by pages or section numbers);
8997
@code{\numberTeX...} (number the beginning of unnamed TeX parts);
9001
@code{\numberdefs...} (number the beginning of the definition part);
9005
@code{\numbercode...} (number the beginning of the code part).
9010
The defaults for these flags are
9020
If desired, one may override these in the limbo section.
9021
(They are defined using Plain @TeX{}'s @samp{\newif} rather than the
9022
equivalent La@TeX{} command because they may also be used when La@TeX{}
9025
@code{\numberTeX} is on the verge of obsolescence. Try to not use it;
9026
never use it in conjunction with the package @code{fwebnum}.
9030
* Page references:: Indexing by page numbers.
9031
* Headers:: The content of page headers.
9032
* Numbering:: Various section numbering schemes.
9035
@node Page references, Headers, Customizing LaTeX, Customizing LaTeX
9036
@comment node-name, next, previous, up
9038
@subsection Page references
9041
@cindex Page numbers
9042
@cindex Sections, numbering
9043
When one says @samp{\pagerefstrue} (La@TeX{} only), index references are
9044
made by page numbers rather than module numbers or La@TeX{} section
9045
numbers. If there is more than one section per page, they are
9046
identified by @samp{a}, @samp{b}, @samp{c}, etc., such as @samp{section
9047
17b}. (Presently, this will not work correctly when @code{multicol} is
9048
used for the body of the document.)
9050
The information necessary to process page references in this way is
9051
written into the @file{aux} file. As is usual with La@TeX{}, several runs
9052
may be required for the references to be fully consistent with the
9055
@node Headers, Numbering, Page references, Customizing LaTeX
9057
@subsection Page headers
9060
@cindex Page headers
9061
The very top (header) line on each page of @FWEAVE{}'s output contains
9062
several pieces of information:
9067
the current section name or document title;
9073
the range of La@TeX{} section numbers on the
9074
page (these are preceded by the
9084
the range of integer section numbers as understood internally by
9085
@FWEAVE{} (those are in square brackets and preceded by the @samp{#} sign).
9089
@node Numbering, , Headers, Customizing LaTeX
9090
@comment node-name, next, previous, up
9092
@subsection Section numbering schemes
9094
@cindex Sections, numbering
9095
@cindex Package, @code{fwebnum}
9097
The @FWEB{} commands @samp{@@*} and @ASP{} are translated by
9098
complicated magic into La@TeX{} commands such as @code{\section},
9099
@code{\subsection}, etc. By default, use of
9100
@code{\documentclass@{article@}} then produces Dewey-decimal section
9101
numbers such as 2.13.4 (subsubsection 4 of subsection 13 of section 2).
9102
When the section tree is very deep, these numbers can look somewhat obtrusive.
9104
An alternative scheme (that of the original @sc{web}) is to merely
9105
number each section in ascending integer order, beginning with 1. This
9106
can be done by specifying the package @code{fwebnum}, as in
9109
LaTeX.package = "fwebnum"
9112
This package is supplied with the @FWEB{} distribution; it is still
9113
somewhat experimental.
9115
By default, @code{fwebnum} numbers all sections, including unnamed
9116
ones. To prohibit numbering of unnamed sections, use the package option
9117
@code{dontnumberunnamed}, as in
9120
LaTeX.package.options = "dontnumberunnamed"
9123
This option will eventually make @code{\numberTeX} obsolete; do not use
9124
@code{\numberTeX} in conjunction with @code{fwebnum}.
9126
@node Inserting woven code, , Customizing LaTeX, Packages
9127
@comment node-name, next, previous, up
9129
@subsubsection Package @code{fwebinsert}: Inserting @FWEAVE{}'s output into a La@TeX{} document
9131
@cindex FWEB output, inserting into LaTeX document
9132
@findex fwebinsert.sty
9133
Beginning with version 1.61, it is (barely) possible to insert the
9134
@TeX{} output woven by @FWEAVE{} into a La@TeX{} document. For
9135
example, a code listing could be an appendix to a dissertation, or a
9136
handbook on numerical methods could insert fragments of code formatted
9139
Suppose one has the file @file{test.web} and used @FWEAVE{} to create
9140
@file{test.tex}. Unfortunately, it does @emph{not} work to simply
9141
@code{\input test.tex} into a La@TeX{} document, because by
9142
default @file{test.tex} operates in a ``stand-alone'' mode and tries to
9143
issue a @code{\begin@{document@}} command.
9145
Instead, one must use the package @code{fwebinsert} and the special
9146
input command @code{\FWEBinput}, as in the following example. There are
9147
two important steps.
9152
Use @FWEAVE{} to create @file{test.tex}.
9153
[You may wish to use the @samp{-x} flag
9154
(@pxref{-x}) to prevent some of the lists at the end, such as the index
9155
or module list, from being printed.]
9158
Now @samp{latex test} until all of the section numbering is up-to-date.
9159
(This step is necessary because information in the @file{aux} file is
9160
used in processing the section headings.)
9164
Now @file{test.tex} is ready to be inserted in a code like the
9168
\documentclass@{article@}
9169
\usepackage@{fwebinsert@}
9175
The body of the document.
9184
Note that the @samp{@@*} commands in @file{test.web} are converted into
9185
La@TeX{} sectioning commands such as @code{\section}. The above example
9186
works correctly because the first @samp{@@*} in @file{test.web} is
9187
equivalent to a @code{\section} (level 0) command, which should indeed
9188
immediately follow an @code{\appendix} command. Suppose, however, that
9189
you wanted to input @file{test.web} as part of the body of the above
9190
example, and wanted the @samp{@@*}s to be treated as subsections (level
9191
1) rather than sections. To tell @code{fwebinsert} what level number to
9192
assign to the @samp{@@*}s, provide that number as an optional argument
9193
to @code{\FWEBinput}, as in the following example:
9196
\documentclass@{article@}
9197
\usepackage@{fwebinsert@}
9203
The body of the document.
9205
\FWEBinput[1]@{test@}
9210
Alternatively, say @code{\FWEBlevel@{1@}} before the @code{\FWEBinput}.
9211
(The optional argument construction merely calls @code{\FWEBlevel}.)
9213
Here are some caveats about @code{fwebinsert}:
9218
Implementing this package was tricky. It may work in simple
9219
circumstances, but it is not fully debugged.
9222
The @code{\FWEBinput} command surrounds the included @TeX{} code with
9223
@code{\begingroup}...@code{\endgroup}, in an attempt to prevent various
9224
macro conflicts. As it stands, the command @code{\fwebinput} is
9225
@code{\let} equal to @code{\FWEBinput}. If necessary, one could redefine
9226
@code{\fwebinput} to not include the enclosing
9227
@code{\begingroup}...@code{\endgroup}.
9230
For anything except level-0 inclusions, one should have just one
9231
@code{\FWEBinput} command following each sectioning command. (This is a
9236
One is supposed to be able to use the package @code{fwebnum}
9237
(@pxref{Numbering}) in
9238
conjunction with @code{fwebinsert}. One can apply that to either the
9239
included file (via a @code{LaTeX.package} entry in @file{fweb.sty}), the
9240
including file (via a @code{\usepackage} command), or both. Try out
9241
these various combinations to see what emerges.
9245
@node Pretty-printing, , Typesetting, Documentation
9246
@comment node-name, next, previous, up
9248
@section Pretty-printing
9250
@cindex Pretty-printing
9251
@dfn{Pretty-printing} refers to @FWEAVE{}'s attempt to typeset and
9252
highlight the code in a readable way. This is usually done
9253
automatically for all of the compiler-like languages such as C.
9254
However, it can be inhibited by turning on the N mode with
9255
@samp{@@N} or by using the @sc{verbatim} language (selected with @samp{@@Lv}).
9257
Pretty-printing is one of those topics that can arouse strong passions:
9258
your idea of what's esthetic may not be mine. Unfortunately,
9259
@FWEB{}'s formatting rules are mostly hard-coded, so if, for example,
9261
the way braces are arranged in typeset C code, you're mostly stuck.
9262
Most directly, this possibly undesirable choice comes from design
9263
decisions made by previous authors. It also makes @FWEAVE{} very
9264
fast, and enables certain complicated tricks that seem difficult or
9265
impossible to accomplish with a completely customizable approach. The
9266
latter seems quite formidable, and has not been attempted---a good
9267
thesis project for the 21st century.
9270
* Alternatives:: Alternatives for various input tokens.
9271
* Pseudo-operators:: Invisible parts of speech.
9272
* Overloading:: Changing the appearance of various quantities.
9275
@node Pseudo-operators, Overloading, Alternatives, Pretty-printing
9276
@comment node-name, next, previous, up
9278
@subsection Pseudo-operators
9280
@cindex Pseudo-operators
9281
Pseudo-operators behave like a particular part of speech for the
9282
purposes of @FWEAVE{}'s formatting, but are invisible on output; they
9283
are ignored by @FTANGLE{}. The pseudo-operators are
9286
@@e @r{--- pseudo-expression. @xref{ATe}.}
9287
@@; @r{--- pseudo-semicolon. @xref{AT;}.}
9288
@@: @r{--- pseudo-colon. @xref{ATcolon}.}
9291
@node Alternatives, Pseudo-operators, Pretty-printing, Pretty-printing
9292
@comment node-name, next, previous, up
9294
@subsection Alternatives for various input tokens
9296
@FWEAVE{} translates various input constructions into allegedly more
9297
readable symbols---for example, in @sc{Fortran} it translates
9298
@samp{.LT.} into @samp{<}.
9300
The printed documentation contains a table of what one can type on
9301
input, and what @FWEAVE{} will output.
9306
what one can type on input, and what @sc{Fweave} will typeset. The first entry
9307
is standard @sc{Fortran}; the parenthesized material is an allowable input
9308
alternative. (In most cases,
9309
the pretty input alternatives follow C's~convention.)
9311
\def\i(#1,#2){{\tt #1} \def\temp{#2}\ifx\temp\empty\else({\tt #2})\fi}
9312
\def\htop#1{\vtop{\halign{##\hfil&$\to \hbox{##}$\hfil\cr#1}}}
9319
\def\EQV{\mathrel{?{=}}}
9320
\def\NEQV{\not\equiv}
9326
\i(.le.,<=) & $\WL$\cr
9327
\i(.eq.,==) & $\WS$\cr
9328
\i(.ne.,!=,<>) & $\WI$\cr
9330
\i(.ge.,>=) & $\WG$\cr
9331
\i(.and.,\amp\amp) & $\WW$\cr}
9334
\i(.or.,||) & $\WV$\cr
9335
\i(.neqv.,) & $\NEQV$\cr
9336
\i(.xor.,) & $\NEQV$\cr
9337
\i(.eqv.,) & $\EQV$\cr
9338
\i(.not.,!) & $\WR$\cr
9339
\noalign{\smallskip}
9340
\i(**,\^) & {\tt (a+b)\^(c+d)} $\to (a+b)^{c+d}$\cr
9341
\i(//,\BS/) & $\SlSl$\cr
9343
These same conventions are allowed in @sc{Ratfor} mode. Note that in @sc{Fortran}
9344
and @sc{Ratfor} @samp{//} is interpreted by default as the concatenation
9345
symbol, not the start of a short comment.
9346
To override that default, use one of the command-line options @samp{-n/},
9347
@samp{-r/}, or @samp{-/},
9348
or use a language-changing command of the form @samp{@@n/}.
9352
@node Overloading, , Pseudo-operators, Pretty-printing
9353
@comment node-name, next, previous, up
9355
@subsection Overloading operators and identifiers
9358
For special effects in the woven output, there are commands to help
9359
one change the appearance of operators and identifiers.
9361
@subsubsection Overloading operators
9363
@cindex Overloading operators
9364
@cindex Operators, overloading
9365
A feature common to both C++ and @sc{Fortran}--90 is @dfn{operator overloading},
9366
the ability to extend or redefine the definition of an operator such as
9368
or @samp{=}. @sc{Fortran--90} even allows one to define new @dfn{dot
9369
operators}---for example, one might define the operator @samp{.IN.} to test
9370
for inclusion in a set. In a nontrivial extension of the original design,
9371
@FWEAVE{} allows one to define how overloaded
9372
operators should appear on output.
9375
\gdef\.#1{{\tt #1}}%
9376
\def\\#1{\leavevmode\hbox{\it#1\/\kern.05em}}%
9377
For example, in the opinion of the author it is much more readable
9378
to read `$\&{if}\.(x \in \\{set}\.)$' than `\&{if}\.(x\ \.{.IN.}\
9381
Indeed, this feature can be used even when the compiler language itself
9382
does not permit overloading in order to customize the appearance of the
9385
The @samp{@@v} control code is used to change the appearance of an operator.
9389
@@v new_operator_symbol_or_name "TeX material" old_operator
9393
This means ``Display the new operator according to the @i{@TeX{}
9394
material}, but treat it like the old operator---e.g., unary or binary---for
9395
formatting purposes. The
9396
quoted @TeX{} material is treated just like a C string, so if
9397
one wants to include a backslash one must escape it with another backslash.
9398
For example, one can make an equals sign display on output as
9399
a large left arrow by saying
9402
@@v = "\\Leftarrow" =
9406
Two @sc{Fortran} examples are
9409
@@v .FALSE. "\\.@{.FALSE.@}" .FALSE.
9413
This feature can go a long way toward enhancing readability of the woven
9414
output, particularly when operators are actually being overloaded. It can
9415
also lead to arbitrarily bizarre output that no-one else will understand.
9416
As usual, restraint is advised.
9418
@subsubsection Overloading identifiers
9420
@cindex Overloading identifiers
9421
@cindex Identifiers, overloading
9422
Although operator overloading is quite useful, it does not allow one to
9423
change the appearance of identifiers. In its most general form, such a
9424
facility becomes quite complicated; one must endow @FWEAVE{} with a
9425
macro-processing facility analogous to that of @FTANGLE{}. This has
9427
done yet (maybe it will be someday). In the meantime, one has the
9429
which provides a restricted form of such a facility. @emph{This
9430
command is experimental, and not firmly established. Changes in usage
9431
and/or syntax may be made in future versions.}
9433
The most general form of the @samp{@@W} command is
9436
@@W identifier "replacement text"
9440
This means: Replace any references to @i{identifier} in the
9441
woven output with the @i{replacement text}.
9443
A more restrictive form is
9446
@@W identifier \newmacro
9450
which replaces references to @i{identifier} with a call to
9451
@code{\newmacro}. (Note that there are no quotes in this form.)
9453
The shortest form is
9460
which replaces references to @i{identifier} with a call to
9461
@code{\identifier}. For example, the identifier @i{x} normally appears in
9462
woven output as @samp{\.@{\Wshort\@{x\@}@}}. If one says
9469
one will instead get the macro reference @samp{\x}, which could
9470
be defined to give a variety of special effects. (However, one may need
9471
some rather intimate understanding of @FWEAVE{}'s output in order to
9472
ensure that things always work correctly.)
9474
One of the important uses of this facility is to expedite special
9475
formatting of array references. This subject is discussed separately below
9476
in the section on ``Special array formatting'' (sorry, that isn't here
9477
yet), where an example is given.
9480
@node Index, Customization, Documentation, Top
9481
@comment node-name, next, previous, up
9483
@chapter @FWEB{}'s INDEX.
9485
@FWEB{} has several powerful indexing facilities:
9490
It sorts and writes its own self-contained (@dfn{internal}) index, including
9491
cross-references to all the variables as well as items inserted by the
9495
It can write its cross-reference information to a file formatted for use
9496
by the @code{makeindex} utility. This feature facilitates creation of a
9497
master index that contains information about several @code{web} files.
9503
* Internal index:: The self-contained index produced by @FWEB{}.
9504
* Using makeindex:: Writing index data for use by @code{makeindex}.
9505
* Merging indexes:: Using the @code{idxmerge} utility to merge indexes.
9508
@node Internal index, Using makeindex, Index, Index
9509
@comment node-name, next, previous, up
9511
@section @FWEB{}'s self-generated index
9513
One of the most useful features of
9514
@FWEB{} is that it automatically generates an Index of all variable
9516
can also insert one's own index
9517
entries by using the commands
9522
@samp{@@^} (entry in Roman type; see
9526
@samp{@@.} (entry in typewriter type; see @ref{ATdot}), and
9529
@samp{@@9} (user-defined format; see @ref{AT9}).
9534
(More discussion to be completed.)
9536
@node Using makeindex, Merging indexes, Internal index, Index
9537
@comment node-name, next, previous, up
9539
@section Creating a stand-alone index with @code{makeindex}
9541
@cindex Index, stand-alone
9542
@cindex Makeindex, using
9543
In addition to the internal index described in the previous section
9544
(@pxref{Internal index}), @FWEAVE{} can write the index data to a file
9545
formatted for later, stand-alone processing by the @code{makeindex}
9546
utility. (Several such indexes can be merged together; see @ref{Merging
9547
indexes}.) The procedure is simple, although the following discussion goes
9548
into some rather arcane details.
9550
@subsection Creating a stand-alone index: Summary
9552
As a quick reference for those who have already read the details in the
9553
next subsection, the procedure to print a stand-alone index with
9554
@code{makeindex} is as follows. First, create, if necessary, a file
9555
@file{index.tex} that @code{\input}s @file{index.ind}. (A skeleton
9556
is illustrated in the next subsection.) Then:
9559
fweave -XI test.web @r{% Creates test.idx and test.sty.}
9560
makeindex -s test.sty -o index.ind test.idx @r{% Creates index.ind.}
9564
If you're not happy with the @code{\pg} macro supplied in
9565
@file{fwebmac.sty}, define it yourself in @file{index.tex}.
9567
In this procedure, note the use of the @samp{-XI} option and the use of
9568
a different root name (@file{index} here) for the output file.
9570
@subsection Creating a stand-alone index: Details
9573
To create an index file in a form suitable for later stand-alone
9574
processing by @code{makeindex}, use the @samp{-XI} option to
9575
@FWEAVE{}. If the @code{web} file is @file{test.web}, the default
9576
name of the @code{makeindex} output file is @file{test.idx}. (This name
9577
can be overridden by the style-file parameter @code{makeindex.out}.) Run
9578
@code{makeindex} on @file{test.idx} to create the La@TeX{} file
9579
@file{index.ind} (see following discussion for details). A stand-alone
9580
index can then be produced by saying @samp{latex index}, where a skeleton
9581
version of @file{index.tex} would be
9584
% index.tex --- skeleton for printing a stand-alone index.
9585
\documentclass@{article@}
9586
\usepackage@{fwebmac@}
9590
\input@{\jobname.ind@}
9595
(In practice, a more involved procedure will probably be followed; see below.)
9597
@cindex Style file, for makeindex
9598
Usually @code{makeindex} works in conjunction with a style file. [In
9599
fact, the syntax of @FWEB{}'s style file (@pxref{Style}) was motivated
9600
by that of @code{makeindex}.] When the @samp{-XI} option (@pxref{-X_}) is used,
9601
@FWEAVE{} will @emph{create} an appropriate style file for
9602
@code{makeindex}. (The default name of @file{test.sty} can be overridden
9603
by the style-file parameter @code{makeindex.sty}.) To run
9604
@code{makeindex} on the index data for @file{test.web} and create the
9605
output file @file{index.ind}, one would thus say
9608
makeindex -s test.sty -o index.ind test[.idx]
9611
It's important to use the @samp{-o} option with a name different than
9612
the original file name, because it simplifies the construction of the
9613
skeleton file @file{index.tex} that prints the stand-alone index.
9615
@FWEAVE{} writes @file{test.sty} because the contents of that file may
9616
depend on parameter settings in @FWEB{}'s style file @file{fweb.sty}.
9617
@FWEB{}'s style vocabulary includes all parameters understood by
9618
@code{makeindex}. If a @code{makeindex} parameter is called
9619
@samp{param}, one references it in @file{fweb.sty} by
9620
@samp{makeindex.param}. Thus, to change the @samp{headings_flag} of
9621
@code{makeindex}, one would put into @file{fweb.sty} a line like
9622
@samp{makeindex.headings_flag = 1}. To see a list of all
9623
@code{makeindex}-related parameters, say @samp{fweave -Zmakeindex}
9624
(@pxref{-Z_}). Remember, @emph{do all @code{makeindex} customizations
9625
in @file{fweb.sty}; the actual style file @file{test.sty} that will be
9626
read by @code{makeindex} is written automatically by @FWEAVE{}.}
9628
The @file{.idx} file will contain a list of entries that begin with
9629
@samp{\indexentry} (more precisely, the value of the parameter
9630
@samp{makeindex.keyword}). The general form is
9633
\indexentry@{sort key:identifier expression|macro@}@{page number@}
9639
\indexentry@{istream:"\>@{istream@}|pg@{@}@{@}@}@{1@}
9640
\indexentry@{main:"\>@{main@}|pg@{@}\underline@}@{1@}
9641
\indexentry@{pow:"\@@@{pow@}|pg@{@}@{@}@}@{2@}
9642
\indexentry@{z:"\"|z|pg@{@}\underline@}@{2@}
9645
Here the colon is the value of @samp{makeindex.actual}; it separates the
9646
sort key (before the colon) from the actual expression to be printed.
9647
The macros such as @samp{\>} typeset the identifiers in the appropriate
9648
way, depending on their use in the code. Note that the backslashes are
9649
quoted with the value of @samp{makeindex.quote}, which is by default the
9652
Although one might guess that the typesetting macros such as @samp{\>}
9653
would be defined in @file{fwebmac.sty}, that is not true. Rather, for
9654
various technical reasons they
9655
are equated to macros in @file{fwebmac.sty} as one of the operations of
9656
the @samp{\Wbegin} macro that is executed at the beginning of every
9657
@code{tex} file output by @FWEAVE{}. For example, @samp{\Wbegin} does
9658
the equivalent of @samp{\let\>\Wid}. Unfortunately, without further
9659
action that equating would be forgotten by a La@TeX{} run made on the
9660
output @file{index.ind} of @code{makeindex}. For that reason, @FWEAVE{}
9661
appends the appropriate @samp{\Wequate} macro to the end of
9662
@samp{makeindex.preamble}. This is one specific instance that
9663
necessitates that @FWEAVE{} write the @code{makeindex} style file.
9665
Each of the @samp{\indexentry}s contains the encapsulation character
9666
@samp{|} (the value of @samp{makeindex.encap}). By the conventions of
9667
@code{makeindex}, everything between the encapsulation character and the
9668
closing right brace defines a macro expression that acts on the page
9669
number. E.g., the general form above generates the command
9670
@samp{\macro@{@i{page number}@}}. The specific macro construction
9671
output by @FWEAVE{} is
9674
\pg@{@}@{@i{possible action macro}@}@{@i{page number}@}
9677
Here the name @samp{pg} is the value of @samp{makeindex.page}. The
9678
@dfn{action macro} is something like @samp{\underline}, which would be
9679
used by @FWEAVE{} to underline the page number to indicate where a
9680
variable is defined. A default definition of @samp{\pg} is given is
9681
@file{fwebmac.sty}. It is a three-argument macro,
9682
@samp{\def\pg#1#2#3@{...@}}, where the arguments are as follows:
9686
#1 @r{--- Integer file identification number}
9687
#2 @r{--- Action macro.}
9688
#3 @r{--- Page number.}
9691
The definition should contain the construction @samp{#2@{#3@}}---i.e.,
9692
the page number must be the argument of the action macro. The first
9693
argument is left empty in the @file{.idx} file written by @FWEAVE{}.
9694
This can be filled in later by the utility @code{idxmerge}
9695
(@pxref{Merging indexes}) that merges the indices
9696
from several @code{web} files. For example, in a master index one might
9697
ultimately print page numbers like @samp{II.5}, where @samp{II} refers to
9698
a file such as @file{test2.web}. To aid this merging process, the root
9699
name of the @code{web} file is written as a comment at the top of the
9700
@file{.idx} file output by @FWEAVE{}.
9702
@node Merging indexes, , Using makeindex, Index
9703
@comment node-name, next, previous, up
9705
@section Using the @code{idxmerge} utility to merge indexes
9707
@cindex Indexes, merging
9708
@findex idxmerge.sty
9709
In a large project, one may maintain and work with several @FWEB{}
9710
files. It may be useful to produce a global index that spans all of
9711
those files. To this end, the utility @code{idxmerge} and associated
9712
La@TeX{} package @code{idxmerge} are supplied with
9713
the @FWEB{} distribution.
9715
@subsection Using @code{idxmerge}: Summary
9717
As quick reference for those who have already plowed through the
9718
following details, here is a summary of the procedure. To print a
9719
stand-alone index by merging the indexes from several @code{web}
9720
sources, do the following. First, create, if necessary, a file
9721
@file{index.tex} that @code{\input}s @file{index.ind}. Then:
9724
fweave -XI test1.web
9725
fweave -XI test2.web
9726
fweave -XI test3.web
9728
idxmerge -oindex test1.idx test2.idx test3.idx
9729
% Creates index.ind and index-names.tex.
9730
makeindex -s test1.sty index
9734
Note the use of the @samp{-XI} option. For further background, see the
9735
previous section, @ref{Using makeindex}.
9737
@subsection Using @code{idxmerge}: Details
9739
Suppose one has three files, @file{test1.web}, @file{test2.web}, and
9740
@file{test3.web}. To use @code{idxmerge}, weave each of the files
9741
separately, using the @samp{-XI} option to create @file{test*.idx} and
9742
@file{test*.sty}. Then say
9745
idxmerge -oindex test1.idx test2.idx test3.idx
9748
This creates two output files: @file{index.idx}, and
9749
@file{index-names.tex}. @code{idxmerge} first sorts the list of file
9750
names. It then writes one entry into @file{index-names.tex} for each
9754
\idxname@{@var{n}@}@{file_name@var{n}@}
9757
This file can be @code{\input} by the @code{\topofindex} command (for an
9758
example, see the La@TeX{}2e package @code{idxmerge}) (supplied with
9759
the @FWEB{} distribution) and used to create a list of the merged files.
9763
Then it merges the @code{\indexentry} commands from each of the input
9764
files into @file{index.idx}, filling in the integer file identifier @var{n}
9765
(the position of the file in the sorted list) into the first argument of
9766
the @code{\pg} macro. One can now say
9769
makeindex -s test1.sty index
9772
This creates @file{index.ind}, which can be processed by, for example,
9773
a simple modification of the simple La@TeX{} template given above in
9774
@ref{Using makeindex}. The only difference is that the package
9775
@code{idxmerge} was used; in that file, the macros @code{\topofindex}
9776
and @code{\idxname} are appropriately defined to print out a numbered
9777
list of the merged files to cross-reference into the numerical file- and
9778
page-number entries in the body of the index. Here is an example
9779
(provided in the @FWEB{} distribution):
9782
% index.tex --- skeleton for printing a stand-alone index.
9783
\documentclass@{article@}
9784
\usepackage@{fwebmac,idxmerge@}
9788
\input@{\jobname.ind@}
9794
@node Customization, Hints, Index, Top
9795
@comment node-name, next, previous, up
9797
@chapter CUSTOMIZATION
9799
@cindex Customization
9800
@cindex Customizing @FWEB{}
9801
@cindex @FWEB{}, customizing
9802
The default behavior of @FWEB{} can be changed in a variety of ways.
9807
@sc{unix} environment variables (logical variables in VMS) affect path or
9811
An initialization file resides in the home directory.
9814
A style file resides in the current directory.
9818
The initialization file (usually called @file{.fweb}) is intended to contain
9819
command-line options (one per line) that are to be used in every run.
9820
@xref{Initialization}.
9822
The style file (called @file{fweb.sty} by default; see @ref{-z}) is
9823
intended to provide more local customization, perhaps
9824
differing for each source file and group of source files. The style
9825
file does not contain command-line
9826
options; rather, it contains parameter settings that override
9827
@FWEB{}'s defaults. The @samp{-p} option (@pxref{-p})
9828
may be used to specify a style-file entry in @file{.fweb} (i.e., a
9829
global value for all source files) or on the
9830
command line (i.e., a value used for a single run).
9832
The order of processing is:
9837
Evaluate environment variables. @xref{Environment variables}.
9840
Read @file{.fweb} and remember its contents; sort those into three
9841
groups: options beginning with @samp{-}, beginning with @samp{&}, and
9842
beginning with a letter (file names) . @xref{Initialization}.
9845
Process @file{.fweb} options beginning with @samp{-} (or @samp{+}, for
9846
backward compatibility), except for @samp{-p}.
9849
Read and process command-line options, except for @samp{-p}. @xref{Options}.
9852
Process remaining @file{.fweb} options (either file names, or options
9853
beginning with @samp{&}).
9856
Process any @samp{-p} options from @file{.fweb}. @xref{-p}.
9859
Process the style file. @xref{Style}.
9862
Process any @samp{-p} options from the command line.
9867
Unfortunately, because not all options are processed immediately when
9868
they are read, errors may not show up when one expects. For example,
9869
nothing is actually processed while @file{.fweb} is being read; its
9870
contents are just being stored. It
9871
could therefore happen that a syntax error in entering a @samp{-p}
9872
option in @file{.fweb} may not be reported until after the style file
9873
has been read, possibly confusing the user as to the source of the
9877
* Environment variables:: Environment or logical variables.
9878
* Initialization:: Initialization file.
9879
* Memory allocation:: Dynamic memory allocation.
9880
* Style:: Style file.
9883
@node Environment variables,Initialization,Customization,Customization
9884
@comment node-name, next, previous, up
9886
@section Environment variables
9888
@cindex Environment variables
9889
@cindex Variables, environment
9891
@code{FWEB_HDR_INCLUDES} --- Colon-delimited list of directories for the
9892
C preprocessor (in the form of @code{gcc}) to
9893
search for @samp{#include} header files. This is used in conjunction
9894
with the @samp{-H} option; see @ref{-H_}. (One can append to this list
9895
by means of the @samp{-I} option, provided that option comes
9896
@emph{after} the @samp{-H}; see @ref{-I_}.)
9897
@findex FWEB_HDR_INCLUDES
9899
@code{FWEB_INCLUDES} --- Colon-delimited list of directories to search for
9900
@samp{@@i} include files. (One can append to this list by means of the
9901
@samp{-I} option, provided that option comes @emph{before} any use of
9902
@samp{-H}; see @ref{-I_}.)
9903
@findex FWEB_INCLUDES
9905
@code{FWEB_INI} --- Name of the initialization file. If not defined, either
9906
@file{.fweb} or @file{fweb.ini} is chosen, depending on the machine. The
9907
initialization file always resides in @code{$HOME}.
9911
@code{FWEB_STYLE_DIR} --- Directory in which the style file resides. If not
9912
defined, the current directory is used.
9913
@findex FWEB_STYLE_DIR
9915
@node Initialization,Memory allocation,Environment variables,Customization
9916
@comment node-name, next, previous, up
9918
@section Initialization
9920
Although some aspects of @FWEB{}'s behavior are hard-coded, many can
9921
be changed and/or initialized by the user.
9923
@subsection The initialization file
9925
@cindex Initialization file
9926
@cindex File, initialization
9927
@cindex @FWEB{}, initializing
9929
On startup, @FWEB{} attempts to read an initialization file. This always
9930
resides in the user's home directory. It is usually called @file{.fweb}
9931
(@file{fweb.ini} on personal computers). The default file name can be
9932
overridden by the environment variable @code{FWEB_INI}.
9934
One may put into @file{.fweb} any option that might be used as a
9935
command-line option. (Presently, there must be just one entry per
9936
line.) If the option begins with a @samp{-} (or a @samp{+} for backward
9937
compatibility), it is processed @emph{before} the actual command-line
9938
options; if it begins with @samp{&} or is a file name, it is processed
9939
after. Generally, @file{.fweb} options should begin with @samp{-} so
9940
that one may override them from the command line. The @samp{%} sign
9941
begins a comment terminated by the end-of-line.
9943
@node Memory allocation,Style,Initialization,Customization
9944
@comment node-name, next, previous, up
9946
@subsection Memory allocation
9948
@cindex Memory allocation
9949
@cindex Allocation, memory
9950
The command-line option @samp{-y} (@pxref{-y}) is used to change the
9951
default allocation for a dynamic array. The arrays have a one- or
9952
two-character abbreviation denoted by @i{aa}. Some error messages will
9953
use this abbreviation when suggesting that one increase a default
9954
allocation. To query the present allocations of variable @i{aa}, just say
9955
@samp{-y@i{aa}}. To query everything, say @samp{-y}.
9957
This whole scheme is somewhat annoying. In most cases, dynamic arrays
9958
should be reallocated automatically. That can be done without too much
9959
difficulty, but I was reluctant to try it for Version 1.61 in fear of
9960
breaking something. Please wait for the year 2000.
9962
If one uses @samp{-y} to examine the maximum permitted values of these
9963
parameters, one will note the magic number 10239 appearing
9964
occasionally. This number is a bit less than 64K/5; it is a signature
9965
of an inherently 32-bit design that goes back to Knuth. Unfortunately,
9966
this number can't be increased without some radical redesign. Wait for
9970
* -yb:: Maximum bytes for identifiers, index entries, and module names.
9971
* -ybs:: Size of the change buffer.
9972
* -ycb:: Size of line buffer for C output.
9973
* -ycf:: A Ratfor buffer.
9974
* -ycg:: Another Ratfor buffer.
9975
* -yd:: Increment for expanding the dots table.
9976
* -ydt:: Maximum number of deferred macro tokens.
9977
* -ydx:: Maximum number of deferred macro texts.
9978
* -yid:: Maximum depth of file inclusion.
9979
* -yif:: Maximum number of unique include-file names.
9980
* -ykt:: Stack size for @FTANGLE{}.
9981
* -ykw:: Stack size for @FWEAVE{}.
9982
* -yll:: Line length for @FWEAVE{}'s output.
9983
* -yln:: Maximum length of module names or strings.
9984
* -ylb:: Maximum number of nested loops in Ratfor.
9985
* -ylx:: Maximum length of expressions that can be expanded with
9986
the post-increment operators of Fortran or Ratfor.
9987
* -ym:: Maximum number of sections.
9988
* -yma:: Maximum number of arguments to @FWEB{} macros.
9989
* -ymb:: Size of the buffer for expanding @FWEB{} macros.
9990
* -yn:: Maximum number of identifiers and module names.
9991
* -ynf:: Maximum number of open output files.
9992
* -yop:: Maximum number of entries in the table for operator
9994
* -yr:: Maximum number of cross-references.
9995
* -ys:: Maximum number of scraps.
9996
* -ysb:: Size of style-file input-line buffer.
9997
* -ytt:: Maximum number of tokens that @FTANGLE{} can process.
9998
* -ytw:: Maximum number of tokens in the current section being
9999
processed by @FWEAVE{}.
10000
* -yx:: Maximum number of texts.
10001
* -yxb:: Size of line buffer for @TeX{} output.
10004
@node -yb, -ybs, Memory allocation, Memory allocation
10005
@comment node-name, next, previous, up
10007
@subsubsection @samp{-yb}: Maximum bytes for identifiers, index entries, and module names
10011
Unique identifiers, index entries, and module names are stored
10012
contiguously in a large memory area, the size of which is controlled by
10013
@samp{-yb}. The default may need to be increased for very large source
10014
files, or decreased to squeeze things into a personal computer. See
10017
@node -ybs, -ycb, -yb, Memory allocation
10018
@comment node-name, next, previous, up
10020
@subsubsection @samp{-ybs}: Size of the change buffer, in bytes
10024
Information from change files is read into the change buffer, whose size
10025
is controlled by @samp{-ybs}. It should not be necessary to change this
10026
unless an error message specifically tells one to do so.
10028
@node -ycb, -ycf, -ybs, Memory allocation
10029
@comment node-name, next, previous, up
10031
@subsubsection @samp{-ycb}: Size of line buffer for C output, in bytes
10035
@FTANGLE{} outputs lines of a fixed maximum length. It attempts to
10036
split them in a reasonable way, dependent on the language. When it
10037
absolutely can't figure out how to split the line, it will issue a
10038
warning message and split it anyway. The @samp{-ycb} option controls
10039
the maximum output line length for C and C++.
10041
The analogous command @samp{-yxb} controls the output line length for
10042
@TeX{} and the verbatim mode. @xref{-yxb}.
10044
@node -ycf, -ycg, -ycb, Memory allocation
10045
@comment node-name, next, previous, up
10047
@subsubsection @samp{-ycf}: Size of a Ratfor buffer, in bytes
10051
The sizes of buffers used by @sc{Ratfor} for constructing messages about
10052
the commands it is expanding are controlled by @samp{-ycf} and @samp{-ycg}.
10054
@node -ycg, -yd, -ycf, Memory allocation
10055
@comment node-name, next, previous, up
10057
@subsubsection @samp{-ycg}: Size of another Ratfor buffer, in bytes
10061
The sizes of buffers used by @sc{Ratfor} for constructing messages about
10062
the commands it is expanding are controlled by @samp{-ycf} and @samp{-ycg}.
10064
@node -yd, -ydt, -ycg, Memory allocation
10065
@comment node-name, next, previous, up
10067
@subsubsection @samp{-yd}: Increment for expanding the dots table
10071
The ``dots'' table is used for @sc{Fortran} to hold information relating
10072
to ``dot'' operators such as @samp{.NE.}. In @sc{Fortran--90},
10073
additional such operators can be added by the program, so the table can
10074
grow dynamically. The @samp{-yd} option controls how many additional
10075
entries are made available each time the table size needs to be
10078
@node -ydt, -ydx, -yd, Memory allocation
10079
@comment node-name, next, previous, up
10081
@subsubsection @samp{-ydt}: Maximum number of deferred macro tokens
10085
Deferred @FWEB{} macros are ones defined in the code part rather in
10086
the definition part. (Their use is normally prohibited; see @ref{-TD}.)
10087
@samp{-ydt} controls how many bytes are set aside for the storage of
10088
these replacement text of those macros. See also @ref{-ydx}.
10090
@node -ydx, -yid, -ydt, Memory allocation
10091
@comment node-name, next, previous, up
10093
@subsubsection @samp{-ydx}: Maximum number of deferred macro texts
10097
@samp{-ydx} controls how many deferred macros are permitted. See also
10100
@node -yid, -yif, -ydx, Memory allocation
10101
@comment node-name, next, previous, up
10103
@subsubsection @samp{-yid}: Maximum depth of file inclusion
10107
Files included by @samp{@@i} can themselves contain @samp{@@i} commands,
10108
to a nesting level controlled by @samp{-yid}.
10110
@node -yif, -ykt, -yid, Memory allocation
10111
@comment node-name, next, previous, up
10113
@subsubsection @samp{-yif}: Maximum number of unique include-file names
10117
The number of unique file names appearing in @samp{@@i} commands is
10118
controlled by @samp{-yif}.
10120
@node -ykt, -ykw, -yif, Memory allocation
10121
@comment node-name, next, previous, up
10123
@subsubsection @samp{-ykt}: Stack size for @FTANGLE{}
10127
@FTANGLE{} uses a stack to deal with the web of module names---i.e., a
10128
named section can refer to another module name. The size of this stack
10129
is controlled by @samp{-ykt}.
10131
@node -ykw, -yll, -ykt, Memory allocation
10132
@comment node-name, next, previous, up
10134
@subsubsection @samp{-ykw}: Stack size for @FWEAVE{}
10138
@FWEAVE{}'s stack handles the possibilities that code mode can be
10139
embedded in a module name, or vice versa. The maximum nesting level for
10140
such mode changes is controlled by @samp{-ykw}.
10142
@node -yll, -yln, -ykw, Memory allocation
10143
@comment node-name, next, previous, up
10145
@subsubsection @samp{-yll}: Line length for @FWEAVE{}'s output, in bytes
10149
@samp{-yll} controls the length of each line in the @code{.tex} file
10150
output by @FWEAVE{}.
10152
@node -yln, -ylb, -yll, Memory allocation
10153
@comment node-name, next, previous, up
10155
@subsubsection @samp{-yln}: Maximum length of module names or strings, in bytes
10159
When each module name or string is parsed, it is stored temporarily in a
10160
buffer whose length is controlled by @samp{-yln}.
10162
@node -ylb, -ylx, -yln, Memory allocation
10163
@comment node-name, next, previous, up
10165
@subsubsection @samp{-ylb}: Maximum number of nested loops in @sc{Ratfor}
10169
In @sc{Ratfor}, various loops such as @samp{while} are translated into
10170
their @sc{Fortran} equivalents. @samp{-ylb} controls the maximum
10171
nesting level of such expandable constructions.
10173
@node -ylx, -ym, -ylb, Memory allocation
10174
@comment node-name, next, previous, up
10176
@subsubsection @samp{-ylx}: Maximum length of expressions that can be expanded with the post-increment operators of @sc{Fortran} or @sc{Ratfor}
10180
@sc{Fortran} and @sc{Ratfor} can expand expressions such as @samp{x(i) +=
10181
dx} into their @sc{Fortran} counterparts such as @samp{x(i) = x(i) + dx}.
10182
It does so in a very straightforward way, by copying the expression to
10183
the left of the equals sign. @samp{-ylx} controls the maximum size of
10186
@node -ym, -yma, -ylx, Memory allocation
10187
@comment node-name, next, previous, up
10189
@subsubsection @samp{-ym}: Maximum number of sections
10193
@samp{-ym} limits the maximum number of sections, both named and
10194
unnamed. (Each unnamed section is counted separately.) The absolute
10195
maximum number of sections is 10239, probably one of the most stringent
10196
restrictions in @FWEB{}'s design. (This number is a bit less than 1/5
10199
@node -yma, -ymb, -ym, Memory allocation
10200
@comment node-name, next, previous, up
10202
@subsubsection @samp{-yma}: Maximum number of arguments to @FWEB{} macros
10206
The maximum number of arguments to @FWEB{} macros (defined by
10207
@samp{@@m}) is limited by @samp{-yma}.
10209
@node -ymb, -yn, -yma, Memory allocation
10210
@comment node-name, next, previous, up
10212
@subsubsection @samp{-ymb}: Size of the buffer for expanding @FWEB{} macros
10216
The expansion of each @FWEB{} macro is done in a buffer whose size is
10217
controlled by @samp{-ymb}. (In some situations, particularly in
10218
@sc{Ratfor}, more than one such buffer can be open at once.)
10220
@node -yn, -ynf, -ymb, Memory allocation
10221
@comment node-name, next, previous, up
10223
@subsubsection @samp{-yn}: Maximum number of identifiers and module names
10227
A structure is associated with each unique identifier and module name.
10228
The maximum number of such structures is controlled by @samp{-yn}. See
10231
@node -ynf, -yop, -yn, Memory allocation
10232
@comment node-name, next, previous, up
10234
@subsubsection @samp{-ynf}: Maximum number of open output files
10238
In addition to @FTANGLE{}'s usual output file---e.g.,
10239
@code{test.c}---additional files may be opened by means of the
10240
@samp{@@O} (@pxref{ATO_}) or @samp{@@o} (@pxref{ATo}) commands.
10241
Depending on the situation, some of these files may remain open
10242
simultaneously. The maximum number of such files is controlled by @samp{-ynf}.
10244
@node -yop, -yr, -ynf, Memory allocation
10245
@comment node-name, next, previous, up
10247
@subsubsection @samp{-yop}: Maximum number of entries in the table for operator overloading.
10251
In @FWEAVE{}, the appearance of an operator can be changed
10252
(@dfn{overloaded}) by means of the @samp{@@v} command (@pxref{ATv}). Each
10253
such operator is entered into a table, the maximum size of which is
10254
controlled by @samp{-yop}.
10256
@node -yr, -ys, -yop, Memory allocation
10257
@comment node-name, next, previous, up
10259
@subsubsection @samp{-yr}: Maximum number of cross-references
10263
The Index cross-reference information (in which sections each identifier
10264
is used or defined) is maintained in a large array of structures, one
10265
structure for each cross-reference. The maximum number of
10266
cross-references is controlled by @samp{-yr}.
10268
@node -ys, -ysb, -yr, Memory allocation
10269
@comment node-name, next, previous, up
10271
@subsubsection @samp{-ys}: Maximum number of scraps
10275
The maximum number of scraps is controlled by @samp{-ys}. For a
10276
discussion of scraps, see @ref{-1}.
10278
@node -ysb, -ytt, -ys, Memory allocation
10279
@comment node-name, next, previous, up
10281
@subsubsection @samp{-ysb}: Size of style-file input-line buffer
10285
The maximum length of each input line of the style file (@code{fweb.sty}
10286
by default) is controlled by @samp{-ysb}.
10288
@node -ytt, -ytw, -ysb, Memory allocation
10289
@comment node-name, next, previous, up
10291
@subsubsection @samp{-ytt}: Maximum number of tokens that @FTANGLE{} can process
10295
A @dfn{token} is an identifier, numerical constant, operator, etc.
10296
@FTANGLE{} must read in and store all tokens in the entire source
10297
file, because they can be output in a different order than they are
10298
input. The maximum number of tokens is controlled by @samp{-ytt}.
10300
@node -ytw, -yx, -ytt, Memory allocation
10301
@comment node-name, next, previous, up
10303
@subsubsection @samp{-ytw}: Maximum tokens in the current section being processed by @FWEAVE{}.
10307
Unlike @FTANGLE{}, @FWEAVE{} need only read in one section at a
10308
time. The maximum number of tokens in any section is controlled by
10311
@node -yx, -yxb, -ytw, Memory allocation
10312
@comment node-name, next, previous, up
10314
@subsubsection @samp{-yx}: Maximum number of texts
10318
For @FTANGLE{}, a @dfn{text} is either the replacement text of a macro, or
10319
the contents of a named section. The maximum number of such texts is
10320
controlled by @samp{-yx}.
10322
For @FWEAVE{}, a @dfn{text} is a phrase that arises from combining primitive
10323
scraps during the translation stage of phase 2.
10325
For both processors, the absolute maximum number of texts is 10239.
10327
@node -yxb, , -yx, Memory allocation
10328
@comment node-name, next, previous, up
10330
@subsubsection @samp{-yxb}: Size of line buffer for @TeX{} and verbatim output
10334
This option is like @samp{-ycb} (@pxref{-ycb}), but controls the size of
10335
the output line for the @TeX{} (@samp{@@Lx}) and verbatim (@samp{@@Lv})
10338
@node Style,,Memory allocation,Customization
10339
@comment node-name, next, previous, up
10341
@section The Style file
10344
@cindex File, style
10346
A @dfn{style file} (default name @file{fweb.sty}) may reside in the
10347
user's current directory (or the directory specified by the environment
10348
variable @code{FWEB_STYLE_DIR}). The default name can be changed by the
10349
command-line option @samp{-z} (@pxref{-z}).
10351
The style file is processed after all command-line options have been
10352
processed, except that the command-line option @samp{-p} (@pxref{-p})
10353
gets special treatment. Note that that option buffers up style-file
10354
entries (i.e., one may use more than one @samp{-p} option). @samp{-p}
10355
options placed in @file{.fweb} are treated as residing in a temporary
10356
file that is read just @emph{before} the local style file; thus, those behave
10357
as `global' style-file entries that will be overridden by a matching
10358
entry in the local style file. @samp{-p} options on the command line
10359
will be processed @emph{after} the local style file, thus override
10360
corresponding options in either @file{.fweb} or the local style file.
10362
To summarize the previous discussion, the local style file is intended
10363
to contain settings that are common to a particular source file.
10364
Settings common to all source files can be put into @file{.fweb} by
10365
means of the @samp{-p} option. To override a setting for a single run,
10366
use a @samp{-p} option on the command line.
10368
Style-file entries have the form
10371
@var{keyword} @i{[}=@i{]} @var{value}
10374
The equals sign is always optional. The @samp{value} is usually a
10375
double-quoted string, but may sometimes be an integer or a single-quoted
10376
character. For example,
10379
LaTeX.class.options = "twoside"
10380
LaTeX.package "indentfirst,multicol"
10381
mark_defined.fcn_name 0
10383
color.error = "red"
10384
Color.red = "\e[01;31m"
10387
The syntax is completely free-form. Periods within keywords are
10388
precisely equivalent to underscores, but are useful heuristically for
10389
associating a structure-like hierarchy to some of the commands.
10390
Non-printable characters in strings can be specified as octal constants
10391
(e.g., @samp{\033}), hexadecimal constants (e.g., @samp{\x1B}), or one
10392
of the ANSI escape sequences @samp{\a}, @samp{\b}, @samp{\f}, @samp{\n},
10393
@samp{\r}, @samp{\t}, and @samp{\v}. The non-ANSI escape sequence
10394
@samp{\e} (escape) is also supported; that is particularly useful for
10395
color processing (@pxref{Color}).
10397
Various of the style-file parameters take a language subscript. Those
10422
Thus, @code{line_char.N} is the comment character for @FTANGLE{}'s
10423
@code{line} commands (@pxref{line_char}), for @sc{Fortran}-77 code.
10425
Unfortunately, the descriptions of the parameters aren't all completed
10426
yet. To query the default values, say @samp{ftangle -Z} (see @ref{-Z_}).
10429
* Index params:: Customizing the Index.
10430
* Module params:: Customizing the list of sections.
10431
* Contents params:: Customizing the Table of Contents.
10432
* Subscript params:: Customizing subscripting for cross-references.
10433
* Fwebmac params:: Customizing behavior of @FWEB{}'s macros.
10434
* Completion params:: Automatic selection of file extensions, etc.
10435
* Control-code mappings:: Remapping @FWEB{}'s control codes (danger)!
10436
* Color:: @FWEB{}'s color output.
10437
* Miscellaneous params:: Other customizations.
10440
@node Index params,Module params,Style,Style
10441
@comment node-name, next, previous, up
10443
@subsection Customizing @FWEAVE{}'s index
10445
In the following, @samp{???} denotes the name of various subparameters.
10448
* delim_0: S_delim. Insert after identifier in index entry.
10449
* delim_n: S_delim. Insert between section numbers in index entry.
10451
* encap.infix: S_encap. Start the section number.
10452
* encap.prefix: S_encap. @TeX{} macro to begin a section number.
10453
* encap.suffix: S_encap. Ends the section number.
10457
* index.collate: S_index. Collating sequence for the Index.
10458
* index.postamble: S_index. @TeX{} material to end the Index.
10459
* index.preamble: S_index. @TeX{} material to begin the Index.
10460
* index.tex: S_index. Name of file holding the Index.
10462
* item_0:: @TeX{} command to begin an index entry.
10464
* language.prefix: S_language. Begin a language entry in the Index.
10465
* language.suffix: S_language. End a language entry in the Index.
10467
* lethead.prefix: S_lethead. Begin a letter group.
10468
* lethead.suffix: S_lethead. End a letter group.
10469
* lethead.flag: S_lethead. Control beginning of letter group.
10471
* name: S_index. Name of index.
10473
* underline.prefix: S_underline. Begin an underlined index entry.
10474
* underline.suffix: S_underline. End an underlined index entry.
10477
@node S_index, S_delim, Index params, Index params
10478
@comment node-name, next, previous, up
10480
@subsubsection @code{index.@i{???}}
10483
@cindex Index, name of
10485
@code{index.name} is the name of the index section. This string is used
10486
in @code{\Wbegin} to initialize the @TeX{} macro @code{\INDEX}. The
10487
index section is recognized by matching, for a starred section, the
10488
actual section name against the contents of @code{\INDEX}. When they
10489
match, a new page and two-column mode are begun. These rules imply that
10490
the last section of one's source file can be titled @samp{\INDEX}, as in
10497
@code{index.tex} is the name of the file into which the Index is
10498
written. The character @samp{#} is translated into the root name of the web
10499
file, as for example @samp{#.ndx}.
10501
@vindex index.preamble
10502
@code{index.preamble} are @TeX{} commands that begin the Index.
10504
@vindex index.postamble
10505
@code{index.postamble} are @TeX{} commands that end the Index.
10507
@vindex index.collate
10508
@code{index.collate} specifies the collating sequence for the Index.
10510
@node S_delim, S_encap, S_index, Index params
10511
@comment node-name, next, previous, up
10513
@subsubsection @code{delim_@i{?}}
10516
@code{delim_0} is the string to insert after the identifier in an index
10520
@code{delim_n} is the string to insert between two section numbers in an
10523
@node S_encap, group_skip, S_delim, Index params
10524
@comment node-name, next, previous, up
10526
@node group_skip, item_0, S_encap, Index params
10527
@comment node-name, next, previous, up
10529
@subsubsection @code{group_skip}
10532
@code{group_skip} is a string of @TeX{} commands to insert between
10535
@node item_0, S_language, group_skip, Index params
10536
@comment node-name, next, previous, up
10538
@subsubsection @code{item_0}
10541
@code{item_0} is the @TeX{} command to begin an index entry.
10543
@node S_language, S_lethead, item_0, Index params
10544
@comment node-name, next, previous, up
10546
@subsubsection @code{language.@i{???}}
10548
@vindex language.prefix
10549
@vindex language.suffix
10550
@code{language.prefix} begins a language entry.; @code{language.suffix}
10553
@node S_lethead, S_underline, S_language, Index params
10554
@comment node-name, next, previous, up
10556
@subsubsection @code{lethead.@i{???}}
10558
@vindex lethead.prefix
10559
@vindex lethead.suffix
10560
@vindex lethead.flag
10561
@code{lethead.prefix} begins a letter group; @code{lethead.suffix} ends
10562
one. The flag @code{lethead.flag} controls the format of the letter
10563
group: if it is zero, nothing is inserted; if it is positive, an
10564
upper-case letter is inserted; if it is negative, a lower-case letter is
10568
@node S_underline, , S_lethead, Index params
10569
@comment node-name, next, previous, up
10571
@subsubsection @code{underline.@i{???}}
10573
@vindex underline.prefix
10574
@code{underline.prefix} is the @TeX{} command to begin an underlined
10577
@vindex underline.suffix
10578
@code{underline.suffix} is the @TeX{} command to end an underlined index
10582
@node Module params,Contents params,Index params,Style
10583
@comment node-name, next, previous, up
10585
@subsection Customizing the module list
10588
* modules.info: S_modules.
10589
* modules.postamble: S_modules. @TeX{} commands to end module list.
10590
* modules.preamble: S_modules. @TeX{} commands to begin module list.
10591
* modules.tex: S_modules. Name of file containing list of modules.
10594
@node S_modules, , Module params, Module params
10595
@comment node-name, next, previous, up
10597
@vindex modules.tex
10598
@code{modules.tex} is the name of the file into which the module names
10601
@vindex modules.preamble
10602
@code{modules.preamble} is a string of @TeX{} commands to begin the list
10605
@vindex modules.postamble
10606
@code{modules.postamble} is a string of @TeX{} commands to end the list
10609
@vindex modules.info
10610
@code{modules.info} is the name of the @TeX{} macro that formats the
10611
command line and related information.
10613
@node Contents params,Subscript params,Module params,Style
10614
@comment node-name, next, previous, up
10616
@subsection Customizing the Table of Contents
10619
* contents.postamble: S_contents. @TeX{} commands to end Table of Contents.
10620
* contents.preamble: S_contents. @TeX{} commands to begin Table of Contents.
10621
* contents.tex: S_contents. Name of contents file.
10624
@node S_contents, , Contents params, Contents params
10625
@comment node-name, next, previous, up
10627
@vindex contents.tex
10628
@code{contents.tex} is the name of the file into which the Table of
10629
Contents is written.
10631
@vindex contents.preamble
10632
@code{contents.preamble} is the @TeX{} string that begins printing the
10635
@vindex contents.postamble
10636
@code{contents.postamble} is the @TeX{} string that ends the Table of
10639
@node Subscript params,Fwebmac params,Contents params,Style
10640
@comment node-name, next, previous, up
10642
@subsection Customizing cross-reference subscripts
10645
@cindex Subscript, bullet
10646
When @FWEAVE{} pretty-prints code, it can attach cross-reference
10647
subscripts to various kinds of identifiers such as function or macro
10652
for a subscript indicates that the name was defined in the
10654
The actual marking of the cross reference is done by
10655
the command @samp{@@[} (@pxref{AT[}). This is usually done
10656
implicitly; for example, the commands @samp{@@a}, @samp{@@d}, and
10657
@samp{@@m} issue an implicit @samp{@@[}. (See the discussion of
10658
@samp{@@a} in @ref{ATa}.) In C, various declarations of
10659
variables also result in such an implicit mark.
10661
Various nuances in the type (possibly underlined) used for the
10662
subscript give a hint about what kind of identifier @FWEAVE{} thinks
10663
it's working with. For more information about the typesetting
10664
conventions, see the definition of the
10665
primitive macro @samp{\W@@IN} in @file{fwebmac.web}.]
10666
@cindex Bullet subscript
10667
The following flags select which identifiers are so subscripted.
10669
To see the default values of these parameters, say @samp{ftangle
10670
-Zmark_defined}. To turn off the subscripting operations completely, use the
10671
@samp{-f} option (@pxref{-f}).
10674
* mark_defined.generic_name: S_mark_defined.
10675
* mark_defined.fcn_name: S_mark_defined.
10676
* mark_defined.WEB_macro: S_mark_defined.
10677
* mark_defined.outer_macro: S_mark_defined.
10678
* mark_defined.exp_type: S_mark_defined.
10679
* mark_defined.typedef_name: S_mark_defined.
10682
@node S_mark_defined, , Subscript params, Subscript params
10683
@comment node-name, next, previous, up
10685
@vindex mark_defined.typedef_name
10686
@vindex mark_defined.exp_type
10687
@vindex mark_defined.outer_macro
10688
@vindex mark_defined.WEB_macro
10689
@vindex mark_defined.fcn_name
10690
@vindex mark_defined.generic_name
10691
(Discussion to be completed.)
10693
@node Fwebmac params,Completion params,Subscript params,Style
10694
@comment node-name, next, previous, up
10696
@subsection Customizing the behavior of @file{fwebmac.sty} macros
10698
@findex fwebmac.web
10699
To some extent, the behavior of @FWEB{}'s macro package
10700
@file{fwebmac.sty} can be changed by means of the following parameters.
10701
(Please try not to actually edit @file{fwebmac.sty} itself; it is
10702
produced automatically from @file{fwebmac.web}. And please don't edit
10706
* doc.preamble: S_LaTeX. Preamble for entire document.
10707
* doc.postamble: S_LaTeX. Postamble for entire document.
10709
* format_IDENTIFIER: S_format. Macro name for typesetting upper-case identifiers.
10710
* format.reserved: S_format. Macro for reserved words.
10711
* format.short_identifier: S_format. Macro for single-character identifiers.
10712
* format_OUTER_MACRO: S_format. Macro for upper-case @samp{@@d} identifiers.
10713
* format.outer_macro: S_format. Macro for lower-case @samp{@@d} identifiers.
10714
* format_WEB_MACRO: S_format. Macro for upper-case @samp{@@m} identifiers.
10715
* format.WEB_macro: S_format. Macro for lower-case @samp{@@m} identifiers.
10716
* format.intrinsic: S_format. Macro for intrinsic library functions.
10717
* format_KEYWORD: S_format. Macro for upper-case keywords.
10718
* format.keyword: S_format. Macro for lower-case keywords.
10719
* format.typewriter: S_format. Macro for strings.
10720
* format.wildcard: S_format. Macro for user-defined index entries.
10722
* indent.TeX: S_indent. Paragraph indentation for @TeX{} part.
10723
* indent.code: S_indent. Paragraph indentation for code part.
10725
* LaTeX.class: S_LaTeX. Specify the document class.
10726
* LaTeX.class.options: S_LaTeX. Specify options for document class.
10727
* LaTeX.package: S_LaTeX. Specify user package(s)
10728
* LATeX.package.options: S_LaTeX. Specify options for user package(s).
10731
@node S_format, S_indent, Fwebmac params, Fwebmac params
10732
@comment node-name, next, previous, up
10734
@subsubsection @code{format.@i{???}}
10736
The @code{format} parameters are strings that specify the macro to be
10737
used to pretty-print various kinds of identifiers. These macro names
10738
are usually written automatically by @FWEAVE{}, but they may also be
10739
used directly by the user in the @TeX{} documentation. One can see
10740
their default values by typing @samp{ftangle -Zformat.}. For example,
10741
the default value for @code{format.typewriter} is @code{"\\."}.
10743
The macro names defined by the @code{format} fields are @emph{not}
10744
defined in @file{fwebmac.sty}. They are @emph{dummy names}, and can be
10745
changed to any other name not already in use without affecting the
10746
operation of @FWEB{}. This ability is necessary because other
10747
packages might usurp macros like @code{\.} for their own purposes.
10749
Thus, @FWEAVE{} normally writes out the macro @code{\.} to typeset a
10750
string. Suppose, however, that some user package uses @code{\.} for
10751
something else. (One might realize this when @sc{LaTeX} crashes
10752
when it encounteres a @code{\.} that was written automatically by
10753
@FWEAVE{}.) To fix this problem, put into @file{fweb.sty} the lines
10756
format_KEYWORD = "\\WTT"
10757
format_keyword = "\\WTT"
10758
format_typewriter = "\\WTT"
10761
Here @code{\WTT} can be any name not already in use; @emph{you need not (and
10762
should not)} give a definition for @code{\WTT}.
10764
Macros like @code{\.} or @code{\WTT} are given their values during the
10765
execution of the @code{\Wbegin} macro that begins the output from
10766
@FWEAVE{}. The style-file values are written as arguments to that
10767
macro, and essentially a command like @code{\let\.\Wtypewriter} is
10768
executed, where the internal macro @code{\Wtypewriter} is defined in
10769
@file{fwebmac.sty}. If you want to change the way @FWEB{} typesets a
10770
particular kind of identifier, you must redefine the @emph{internal}
10771
macro name, not the one used in the @code{format} parameters.
10773
Here are the internal macros used by @file{fwebmac.sty} to typeset the
10774
various kinds of identifiers. The associated style-file parameters are
10775
shown in parentheses.
10779
@vindex format.short_id
10780
@vindex format.outer_macro
10781
@vindex format.WEB_macro
10782
@vindex format.reserved
10783
@vindex format.RESERVED
10784
@vindex format.intrinsic
10785
@vindex format.keyword
10786
@vindex format.KEYWORD
10787
@vindex format.typewriter
10793
ordinary identifiers (@code{format.id})
10796
completely upper-case ordinary identifiers (@code{format.ID})
10799
single-character ordinary identifiers (@code{format.short_id})
10802
outer macros (@code{format.outer_macro})
10805
completely upper-case outer macros (@code{format.outer_macro})
10808
FWEB macros (@code{format.WEB_macro})
10811
completely upper-case FWEB macros (@code{format.WEB_macro})
10814
reserved words (@code{format.reserved})
10817
completely upper-case reserved words (@code{format.RESERVED})
10820
library/intrinsic function names (@code{format.intrinsic})
10823
certain Fortran keywords (@code{format.keyword})
10826
completely upper-case keywords (@code{format.KEYWORD})
10829
character strings (@code{format.typewriter})
10835
@node S_indent, S_LaTeX, S_format, Fwebmac params
10836
@comment node-name, next, previous, up
10838
@subsubsection @code{indent.@i{???}}
10841
@code{indent.TeX} specifies paragraph indentation for the @TeX{} part.
10843
@vindex indent.code
10844
@code{indent.code} specifies similar indentation for the code part.
10846
@node S_LaTeX, , S_indent, Fwebmac params
10847
@comment node-name, next, previous, up
10849
@subsubsection @code{LaTeX.@i{???}}
10851
@vindex LaTeX.class
10852
For La@TeX{}2e, the default document class can be overridden by
10853
@code{LaTeX.class}. The default class is @code{article}, and @FWEB{}
10854
has not been tested with other document classes, except minimally with
10855
@code{revtex} (@pxref{REVTeX}).
10857
@vindex LaTeX.class.options
10858
Options to the document class can be specified by
10859
@code{LaTeX.class.options}.
10861
User packages can be given by @code{LaTeX.package}.
10863
@vindex LaTeX.package
10864
@vindex LaTeX.package.options
10865
Options to user packages can be specified by
10866
@code{LaTeX.package.options}. There may be just one
10867
@code{LaTeX.package} command and just one @code{LaTeX.package.options}
10868
command. If it is necessary to issue multiple such commands, then put
10869
them into @code{doc.preamble}. See the discussion in @ref{Document
10872
@vindex LaTeX.style
10873
@vindex LaTeX.options
10874
When running under La@TeX{} prior to La@TeX{}2e (or with REVTeX; see
10875
@ref{REVTeX}), the document is
10876
(effectively) begun by the command
10877
@code{\documentstyle[options]@{style@}}. The options field can be
10878
specified by @code{LaTeX.options}; the style field by
10879
@code{LaTeX.style}.
10882
@node Control-code mappings, Color, Completion params, Style
10883
@comment node-name, next, previous, up
10885
@subsection Remapping control codes
10887
Control-code remappings are sophisticated and unwise. They are mostly
10888
intended for the developer, so are not explained here.
10890
@node Color, Miscellaneous params, Control-code mappings, Style
10891
@comment node-name, next, previous, up
10893
@subsection Color output
10896
In the design of @FWEB{}, provision has been made for writing various
10897
messages to the terminal in color---e.g., serious error messages might
10898
appear in red. This feature was motivated by the color @code{ls} of Linux.
10899
It is installed automatically if the @code{termcap} library is present.
10901
@cindex Message types
10902
@cindex Color, and message types
10903
Messages output from @FWEB{} are ranked according to an internal message-type
10904
table; each type can be associated with a color that can be changed
10905
in the style file. Presently, the message types (hopefully
10906
self-explanatory) are
10907
@cindex Message types
10908
@vindex color.ordinary
10909
@vindex color.program_name
10910
@vindex color.mod_name
10912
@vindex color.warning
10913
@vindex color.error
10914
@vindex color.fatal
10915
@vindex color.mod_num
10916
@vindex color.line_num
10917
@vindex color.in_file
10918
@vindex color.include_file
10919
@vindex color.out_file
10920
@vindex color.timing
10941
The associated style-file parameters are the above names prefaced by
10942
@samp{color.}---e.g., @code{color.warning}. Each of those has a default
10943
value, such as @code{color.error = "red"}. Those defaults can be
10944
displayed by saying @samp{ftangle -Zcolor}.
10946
What the color actually means in practice depends on the @dfn{color
10947
mode}, set by the @samp{-C} option (@pxref{-C_}). That selects one of
10948
several primitive palettes, as follows:
10954
@strong{No color}; ordinary black-and-white output. This is the default (and the
10955
mode used when the @code{termcap} library is not present).
10958
@cindex Color, ANSI
10959
@cindex Color mode, ANSI
10960
@strong{ANSI color}. With a color terminal that supports ANSI color escape
10961
sequences, one has available the following colors: @code{"black"},
10962
@code{"red"}, @code{"green"}, @code{"yellow"}, @code{"blue"},
10963
@code{"magenta"}, @code{"cyan"}, @code{"white"}, and @code{"default"}.
10964
These are displayed with bold attribute (that is, bright, not dim).
10965
@samp{"default"} stands for the usual black on white background, or vice
10969
@cindex Color mode, bilevel
10970
@strong{Bilevel}. This is for terminals that don't support true color,
10971
but do support a double-bright mode and reverse video. Colors are
10972
mapped onto various combinations of those two display attributes,
10973
according to an internally defined scheme. For example, @code{"red"} is
10974
mapped onto the pair of escape sequences @samp{md}, @samp{mr}
10975
(double-bright mode in reverse video).
10978
@cindex Color mode, trilevel
10979
@strong{Trilevel}. As above, but adds underlining capability.
10982
@cindex Color mode, user-defined
10983
@strong{User-defined colors}. This implements a minimal set of defaults. It is
10984
intended that the user add definitions in the style file to override
10991
@cindex Escape sequences, ANSI
10992
@vindex Color.black
10994
@vindex Color.green
10995
@vindex Color.yellow
10997
@vindex Color.magenta
10999
@vindex Color.white
11000
@vindex Color.default
11002
The mechanism is intended to work with systems that support the
11003
@code{termcap} library. The terminal is controlled by writing
11004
appropriate escape sequences to it. The style-file parameters that
11005
store the escape sequences are the color name preceded by @samp{Color.}
11006
(note the upper case @samp{C})---e.g., @samp{Color.red}. For cases like
11007
reverse video (standard termcap abbreviation @samp{mr}), the escape
11008
sequences are determined by querying the termcap database (usually
11009
@file{/etc/termcap}) through the @code{termcap} library functions. For
11010
ANSI color (color mode = 1), ANSI escape sequences are hard-coded into
11011
@FWEB{}. One can see the escape sequences @FWEB{} assigns to colors by
11012
saying @samp{ftangle -ZColor}.
11014
For any non-zero color mode, one can override @FWEB{}'s default choices
11015
for color mappings and escape sequences by redefining one or more of the
11016
@code{Color} parameters in the style file. The escape sequences can
11017
either be specified in raw form---e.g., for color mode = 1, a
11018
default is @code{Color.red = "\e[01;31m"}---or in the form of a sequence
11019
of two-character abbreviations that are defined in the termcap
11020
documentation---e.g., for modes 2 and 3, the default is @code{Color.red
11021
= "mdmr"}. (When one displays that with the @samp{-Z} option, @FWEB{}
11022
will display the actual escape sequences that it determines from the termcap
11023
database, not the abbreviations. For both input and output, note that
11024
one may use the non-ANSI escape sequence @samp{\e} to represent the
11025
escape character @samp{\033}.)
11027
When one says @samp{-ZColor}, for color modes 1--3 all of the
11028
parameters are listed as modified, even if the user redefines none.
11029
That occurs because the defaults are overwritten internally when the
11033
@FWEB{}'s configuration script attempts to determine whether the termcap
11034
library is present; if not, they link in dummy termcap routines
11035
(@file{termcap0.web}). To override this behavior, change the
11036
appropriate lines in @file{defaults.mk}, produced by the command
11037
@code{./configure}.
11039
Color message output is not fully debugged (it's a frill, after all), so
11040
some messages that should reasonably be colored may not be so in the
11043
@node Miscellaneous params,,Color,Style
11045
@comment node-name, next, previous, up
11047
@subsection Miscellaneous style-file parameters
11049
There are a variety of miscellaneous parameters.
11054
* ASCII_fcn:: Routine for converting strings to ASCII.
11055
* cchar:: Continuation character for Fortran.
11056
* cdir_start:: @samp{@?} translates to this.
11057
* line_char:: Comment char. for @FTANGLE{}'s @code{line} cmds.
11058
* line_length: S_line_length.
11060
* paren.len: -n). Length of one parenthesized index for @samp{-n)}.
11061
* paren.levels: -n). Number of nested parentheses for @samp{-n)}.
11062
* paren.num: -n). Number of permitted indices for @samp{-n)}.
11064
* meta.top: S_meta_t. Material to precede tangled meta-comment.
11065
* meta.prefix: S_meta_t. Begins each line of meta-comment.
11066
* meta.bottom: S_meta_t. Material that follows the meta-comment.
11068
* meta.top.hdr: S_meta_t. Like meta.top, but for info at start of file.
11069
* meta.prefix.hdr: S_meta_t. As above.
11070
* meta.bottom.hdr: S_meta_t. As above.
11072
* outer.def: S_outer. @FTANGLE{} converts @samp{@@d} to this.
11073
* outer.undef: S_outer. @FTANGLE{} converts @samp{@@u} to this.
11075
* protect:: Protection character to end a continued line.
11076
* suffix:: Suffixes for output files.
11080
* macros:: Default name of the macro package to be
11081
read in by @FWEAVE{}.
11082
* limbo.begin: S_limbo. Default material to begin the limbo section.
11083
* limbo.end: S_limbo. Default material to end the limbo section.
11085
* meta.code.begin: S_meta_w.
11086
* meta.code.end: S_meta_w.
11088
* meta.TeX.begin: S_meta_w. @TeX{} material to begin @FWEAVE{}'s
11089
output of a meta-comment.
11090
* meta.TeX.end: S_meta_w. As above, but end the meta-comment.
11092
* preamble.named: S_preamble. @TeX{} material to begin named section.
11093
* preamble.unnamed: S_preamble. @TeX{} material to begin unnamed section.
11095
For both processors:
11097
* dot_constant.begin: S_dot_constant. Beginning character for dot constant.
11098
* dot_constant.end: S_dot_constant. Ending character for dot constant.
11100
* null_file:: Name of the null file.
11103
@node ASCII_fcn, cchar, Miscellaneous params, Miscellaneous params
11104
@comment node-name, next, previous, up
11106
@subsubsection @code{ASCII_Fcn}
11111
@node cchar, cdir_start, ASCII_fcn, Miscellaneous params
11112
@comment node-name, next, previous, up
11114
@subsubsection @code{cchar}
11117
Continuation character for @sc{Fortran} code output.
11119
@node cdir_start, line_char, cchar, Miscellaneous params
11120
@comment node-name, next, previous, up
11122
@subsubsection @code{cdir_start}
11125
This parameter has the form @code{cdir_start.@i{l}}, where @i{l} is one of
11126
@samp{C}, @samp{Cpp}, @samp{N}, @samp{N90}, @samp{R}, @samp{R90},
11127
@samp{X}, or @samp{V}. The contents of this parameter is written
11128
immediately after the @samp{@@?} that begins a compiler directive.
11130
@node line_char, S_line_length, cdir_start, Miscellaneous params
11131
@comment node-name, next, previous, up
11133
@subsubsection @code{line_char.@i{l}} (@FTANGLE{})
11136
By default, @FTANGLE{} outputs comments indicating line numbers in the
11137
@code{web} file from which the tangled output comes. (This information
11138
can be used by debuggers, especially those for C and C++, to correlate
11139
error messages to the @code{web} source.) The @code{line_char}
11140
parameter sets the comment character that begins the line comment.
11142
@node S_line_length, S_meta_t, line_char, Miscellaneous params
11143
@comment node-name, next, previous, up
11145
@subsubsection @code{line_length.@i{l}} (@FTANGLE{})
11147
@vindex line_length
11148
This parameter is used by the @sc{Fortran}-like languages to control the
11149
length of the output line in the @file{.f} file produced by
11150
@FTANGLE{}. For @sc{Fortran}-77, its default value is the venerable
11151
72. For @sc{Fortran}-90, its default is 73. Using that value makes it
11152
possible to generate code that is compatible with both fixed- and
11153
free-form format (by continuing lines with an trailing ampersand in
11154
column 73 and another ampersand in column 6 of the next line).
11156
@node S_meta_t, S_outer, S_line_length, Miscellaneous params
11157
@comment node-name, next, previous, up
11159
@subsubsection @code{meta.@i{???.?}}, @code{meta.@i{???}.hdr.@i{?}} (@FTANGLE{})
11161
These parameters customize the treatment of meta-comments.
11162
Fundamentally, meta-comments consist of material enclosed by
11163
@samp{@@(...@@)}. The header information usually written at the top of
11164
the file output by @FTANGLE{} (@pxref{-Tv}) is also treated as a
11165
meta-comment. For that header material, a separate set of parameters is
11166
provided, such as @code{meta.top.hdr}.
11169
@vindex meta.top.hdr
11170
@code{meta.top.@var{l}} specifies text that precedes material enclosed by
11171
@samp{@@(...@@)}. Here @var{l} is one of the standard language subscripts
11172
(@pxref{Style}) such as @code{N90}.
11174
@vindex meta.prefix
11175
@vindex meta.prefix.hdr
11176
@code{meta.prefix.@var{l}} begins each line of the meta-comment.
11178
@vindex meta.bottom
11179
@vindex meta.bottom.hdr
11180
@code{meta.bottom.@var{l}} specifies text that follows the meta-comment.
11182
@node S_outer, protect, S_meta_t, Miscellaneous params
11183
@comment node-name, next, previous, up
11185
@subsubsection @code{outer.@i{???}}
11188
@vindex outer.under
11189
@FTANGLE{} converts @samp{@@d} (@pxref{ATd}) to @code{outer.def}, and
11190
@samp{@@u} (@pxref{ATu}) to @code{outer.undef}.
11192
@node protect, suffix, S_outer, Miscellaneous params
11193
@comment node-name, next, previous, up
11195
@subsubsection @code{protect.?}
11198
The strings @code{protect.@var{l}} specify the protection character(s) to end
11201
@node suffix, macros, protect, Miscellaneous params
11202
@comment node-name, next, previous, up
11204
@subsubsection @code{suffix.?}
11207
The extension for the files output by @FTANGLE{} is specified by
11208
@code{suffix.@var{l}}.
11211
@node macros, S_limbo, suffix, Miscellaneous params
11212
@comment node-name, next, previous, up
11214
@subsubsection @code{macros}
11217
The default name of the macro package to be read in. [This is usually
11218
@file{fwebmac.sty} (@pxref{fwebmac.sty}), but can be overridden by the
11219
command-line option @samp{-w}; see @ref{-w}.]
11221
@node S_limbo, S_meta_w, macros, Miscellaneous params
11222
@comment node-name, next, previous, up
11224
@subsubsection @code{limbo.begin}, @code{limbo.end}
11226
@vindex limbo.begin
11227
@samp{limbo.begin} is @TeX{} material to be printed at the beginning of
11228
the limbo section, just before the text from @samp{@@l} commands. @xref{ATl}.
11229
(This command was previous called just @samp{limbo}, and that still
11233
Similarly, @samp{limbo.end} is printed at the end of the limbo section.
11235
Thus, the beginning of the file output by @FWEAVE{} looks like this:
11241
[contains \documentclass, \usepackage, <doc.preamble>, \begin@{document@}]
11244
[contents of any @@l commands]
11245
[user's TeX commands from the limbo section]
11249
The @samp{limbo.end} command is useful for printing the entire document
11250
in two-column format. For more discussion, see @ref{LIndex}.
11252
@node S_meta_w, S_preamble, S_limbo, Miscellaneous params
11253
@comment node-name, next, previous, up
11255
@subsubsection @code{meta.@i{???}} (@FWEAVE{})
11260
@node S_preamble, S_dot_constant, S_meta_w, Miscellaneous params
11261
@comment node-name, next, previous, up
11263
@subsubsection @code{preamble.@i{???}}
11265
@vindex preamble.named
11266
@vindex preamble.unnamed
11267
Additional @TeX{} material can be inserted at the beginning of a named
11268
section with @code{preamble.named} and at the beginning of an unnamed
11269
one with @code{preamble.unnamed}.
11271
@node S_dot_constant, null_file, S_preamble, Miscellaneous params
11272
@comment node-name, next, previous, up
11274
@subsubsection @code{dot_constant.@i{???.?}}
11276
@vindex dot_constant.begin
11277
@vindex dot_constant.end
11278
In @sc{Fortran}, `dot' constants such as @code{.LT.} are begun and ended by
11279
periods. In special circumstances, the beginning and ending characters
11280
may be modified by @code{dot_constant.begin.@var{l}} and
11281
@code{dot_constant.end.@var{l}}.
11283
@node null_file, , S_dot_constant, Miscellaneous params
11284
@comment node-name, next, previous, up
11286
@subsubsection @code{null_file}
11289
The name of the null file or device. For more discussion, see
11290
@ref{Change files}.
11292
@node Completion params,Control-code mappings,Fwebmac params,Style
11293
@comment node-name, next, previous, up
11295
@subsection Automatic file name completion
11298
* Ext.web: S_Ext. Extensions for the web file.
11299
* Ext.ch: S_Ext. Extensions for the change file.
11300
* Ext.hweb: S_Ext. Extensions for include files.
11301
* Ext.hch: S_Ext. Extensions for change files associated with
11305
@node S_Ext, , Completion params, Completion params
11306
@comment node-name, next, previous, up
11313
For more information, see @ref{-e}.
11315
@node Hints, New features, Customization, Top
11316
@comment node-name, next, previous, up
11318
@chapter USAGE TIPS and SUGGESTIONS
11320
In this section are collected various tips and suggestions to help one make
11321
full use of @FWEB{}. Additional hints broken down by each supported
11322
source language can be found in @ref{Languages}.
11325
* Converting:: Converting an existing code to @FWEB{}.
11326
* Tips:: Usage tips and suggestions.
11327
* Science:: Useful features for scientific programming.
11330
@node Converting, Tips, Hints, Hints
11331
@comment node-name, next, previous, up
11333
@section Converting an existing code to @FWEB{}
11335
@cindex Converting an existing code to @FWEB{}
11336
@cindex Code, converting to @FWEB{}
11337
To convert an existing code to @FWEB{}, one should do the
11338
following. (The following simple procedure assumes that one puts all the
11339
subroutines into the unnamed module. However, other more elaborate schemes
11345
Place invisible commentary
11346
about the author, version, etc. at the beginning of the source file by
11347
bracketing it with @samp{@@z...@@x}. The @samp{@@z} must be the first two
11348
characters of the file.
11351
Next, set the language by including a command such as @samp{@@n} or
11355
Place an @samp{@@a} command (switch into unnamed code) before each
11356
program unit (e.g., main @b{program}, @b{subroutine}, or @b{function}).
11359
Before each @samp{@@a}, place an @samp{@@*} or @ASP{} command,
11360
followed by @TeX{} documentation about that particular section of code.
11363
If you have program units longer than about twelve lines, either
11364
make them function calls, if you can afford the overhead and can impart
11365
sufficient information via the function name, or break them up into shorter
11366
fragments by using named modules. Insert the command @samp{@@<Name of
11367
module@@>} in place of the fragment you're replacing, then put that
11368
fragment somewhere else, prefaced by
11369
@ASP{} and @samp{@@<Name of module@@>=}.
11372
Make sure your comments are valid @TeX{}. (One can't have things
11373
like raw underscores or dollar signs in comments, since those cause @TeX{}
11374
to take special actions.)
11377
Beautify and clarify your documentation by using code mode
11378
(enclosing stuff between vertical bars) liberally within your @TeX{}.
11381
After you've seen the woven output, you may need to go back and
11382
format a few identifiers or section names so that @FWEAVE{} understands them
11383
properly, or you may need to insert some pseudo-semicolons (@samp{@@;}),
11384
pseudo-expressions (@samp{@@e}), or pseudo-colons (@samp{@@:})
11385
(@pxref{Pseudo-operators}).
11388
Consider using @FWEB{}'s built-in macro preprocessor (@pxref{Macros})
11389
to make your code more readable---for example, replace raw numerical
11390
constants by symbolic names.
11393
Scientific programmers may benefit from built-in macro-like functions
11394
like @code{$PI}; see @ref{Built-in functions}.
11397
If you are a @sc{Fortran} user, for ultimate readability
11398
consider converting to @sc{Ratfor}. The initial annoyance is getting rid of
11399
column-6 continuations. With the aid of a good editor, this can be done
11400
simply. For example, in @code{emacs} one can replace the regular expression
11401
[carriage return, five spaces, something not equal to space, tab, or 0]
11402
with [backslash, carriage return, six spaces]:
11405
M-x replace-regexp RET
11406
C-q C-j \.@{\ \ \ \ \ @}[\^\.\ tab 0]RET
11407
\\\\ C-q C-j \.@{\ \ \ \ \ \ @}RET
11411
Get rid of the keywords such as @b{then} or @b{end if} in favor
11412
of braces. Change singly-quoted character strings to doubly-quoted
11413
ones. The @samp{-nC} option (@pxref{-nC}) may be helpful.
11417
@node Tips, Science, Converting, Hints
11418
@comment node-name, next, previous, up
11420
@cindex Suggestions
11421
@cindex Programming tips
11423
@section Programming tips and other suggestions
11428
Learn how to use the GNU @code{info} browser to access the on-line
11432
Read the list of new features and changes for the last several
11433
releases. @xref{New features}.
11436
Periodically check @code{ftp.pppl.gov:/pub/fweb/READ_ME} for bug
11437
reports and other news. Make bug reports! @xref{Support}.
11440
If you have a color terminal, try the option @samp{-C1} (@pxref{-C_},
11444
Any option in @file{.fweb} that is intended to be processed @emph{after}
11445
the command-line options should begin with @samp{&} rather than
11446
@samp{-}. (This is rarely necessary.)
11447
@xref{Initialization}
11450
Put standard command-line options into @file{.fweb}. Also put there
11451
standard style parameters---e.g.,
11454
-pindex.tex "#.ndx"
11455
-pmodules.tex "#.mds"
11456
-pcontents.tex "#.cts"
11460
Learn how to use the style file. @xref{Style}.
11463
Use the info options @samp{-@@}, @samp{-D}, @samp{-y}, and @samp{-Z}
11464
to find out about various internal @FWEB{} tables (control codes,
11465
reserved words, memory allocations, and style-file parameters).
11466
@xref{Info options}.
11469
Begin all @FWEB{} sources with invisible commentary
11470
bracketed by @samp{@@z...@@x}.
11474
Always include an explicit language-setting command in the limbo
11475
section. Under normal circumstances, do not set the language from the
11480
Keep sections quite short.
11481
Knuth suggests a dozen lines. That's
11482
quite hard to achieve sometimes, but almost never should a section be more
11483
than a page long. If a block of code is longer than that, split it up
11484
using named modules.
11487
It's easy to define macros from the command line to expedite
11488
conditional preprocessing.
11492
Use the preprocessor construction @samp{@@#if 0...@@#endif} to
11493
comment out unwanted code.
11494
@xref{Preprocessing}.
11497
For logical operations with the preprocessor, use @samp{||}, not @samp{|}.
11500
It's conventional to identify the ends of long preprocessor
11501
constructions as follows:
11511
To debug an errant @FWEB{} macro, use the built-in function
11516
Use @samp{@@?} for compiler directives. @xref{AT?}.
11517
Use the style-file parameters @samp{cdir_start} to specify
11518
information that will be written out at the beginning of the line.
11522
Stick to the standard @FWEB{} commenting style @samp{/*...*/} or
11523
@samp{//...}. Don't use alternatives such as @sc{Fortran}'s column 1
11524
convention; these may not work or may not be supported someday.
11528
The meta-comment feature @samp{@@(...@@)} provides a poor-person's
11529
alignment feature. But it doesn't work very well, and it's not in the
11530
spirit of @TeX{}; learn to use @samp{\halign} or the La@TeX{} alternatives.
11533
In @sc{Fortran}, use @samp{#:0} to declare readable alphabetic statement
11534
labels. See @ref{Tokens} and @ref{-colon}.
11537
When mixing languages, define the language of a module at the highest
11538
possible level---e.g., in the unamed module, not after @samp{@@<...@@>=}.
11541
Use La@TeX{}. Plain @TeX{} is no longer supported. Upgrade to
11542
La@TeX{}2e. @xref{LaTeX}.
11545
If you are reading this documentation from printed pages, make sure it's
11546
also installed as an Info package on your system so it can be read
11547
interactively with @code{emacs}. You can also read it through a
11548
World-Wide Web browser such as Netscape. For the address, see
11554
@node Science, , Tips, Hints
11555
@comment node-name, next, previous, up
11557
@cindex Scientific programming
11559
@section Features for scientific programming
11561
@FWEB{} contains a few features particularly intended for scientific
11566
Several built-in functions generate numerical constants. See @samp{$PI}
11567
(@ref{$PI}) and @samp{$E} (@ref{$E}).
11570
Several built-in functions perform mathematical manipulations. See
11571
@samp{$EXP} (@ref{$EXP}), @samp{$POW} (@ref{$POW}), @samp{$SQRT}
11572
(@ref{$SQRT}), @samp{$LOG} (@ref{$LOG}), @samp{$LOG10} (@ref{$LOG10}),
11573
@samp{$MAX} (@ref{$MAX}), and @samp{$MIN} (@ref{$MIN}).
11576
The do-loop macro @samp{$DO} may be useful. @xref{$DO}.
11579
C-style array indices can be used by means of the @samp{-n)} option.
11583
An active bracket feature helps improve the appearance of
11584
woven code that uses subscripts and/or superscripts heavily. @xref{-W[}.
11588
@node New features, Support, Hints, Top
11589
@comment node-name, next, previous, up
11591
@chapter NEW FEATURES
11593
@cindex Features, new
11595
This info documentation is now accessible on the World-Wide Web; see
11598
Some things that have been added or changed in recent releases are
11599
described in the following.
11609
@node V1.61, V1.53, New features, New features
11610
@comment node-name, next, previous, up
11612
@section Version 1.61
11614
@subsection Updates to documentation (v1.61)
11620
@FWEB{} supports color modes in which messages to the terminal can
11621
appear in colors chosen by the user; see @ref{Color}. The color mode is
11622
set by the new command-line option @samp{-C} (@pxref{-C_}).
11625
A previously undocumented feature is that for the C-like and
11626
Fortran-like languages, @FTANGLE{} expands the binary notation
11627
@samp{0b...} to an unsigned decimal number. @xref{Phases}.
11632
@subsection Redefined commands (v1.61)
11634
@cindex Commands, redefined
11635
@cindex Redefined commands, version 1.61
11637
A few obscure commands have been slightly redefined. Sorry about that,
11638
but it makes for more symmetry and ease of recall, and/or solves some
11639
technical problems.
11645
Although it was never documented, previous versions permitted either
11646
lower or upper case for the @samp{@@} commands that set the
11647
language---e.g., both @samp{@@c} and @samp{@@C} worked. Now only the
11648
lower-case forms work. (The upper-case forms may have other meanings.)
11651
The style-file parameter @samp{Ext_delimiter} now begins with an
11652
upper-case @samp{E}; formerly it was lower-case.
11655
The behavior of the optional argument of the @code{\Title} macro has
11656
been slightly redefined. The new, more symmetrical form is
11659
\Title[Short title]@{Long title@}
11662
where @code{Long title} is printed on the title page and @code{Short
11663
title} is used for the running header within the document. @xref{Table
11667
The line-break commands @samp{@@/} and @samp{@@\} (formerly identical)
11668
now behave slightly differently. @samp{@@/} breaks the line just as it
11669
would if the line had been too long and been spontaneously broken.
11670
@xref{AT/}. @samp{@@\} backspaces one unit of indentation after
11671
breaking the line. @xref{ATbs}. Usually, one should use @samp{@@/}
11672
(sorry; I was previously recommending @samp{@@\}. For an example in
11673
which it is natural to use @samp{@@\}, see @ref{ATbs}.
11676
The names of some of the code-typesetting macros in @code{fwebmac.sty}
11677
have been changed to conform to the convention that they should all
11678
start with @samp{W}. This change will be invisible to you unless you
11679
happen to have user macros of your own that start that way or (perish
11680
the thought) you have redefined low-level and obscure code in
11681
@file{fwebmac.sty}.
11686
@subsection New features (v1.61)
11688
@cindex Features, version 1.61
11689
This release adds some features for managing large projects, including
11690
(i) the @code{idxmerge} utility that merges indexes produced by several
11691
@FWEB{} files, (ii) a mechanism for accessing RCS-like information in
11692
the ignorable commentary at the beginning of the file, and (iii) the
11693
ability to include @FWEAVE{}-formatted code into a standard La@TeX{}
11694
document. It also fixes a variety of miscellaneous bugs.
11700
A stand-alone index file suitable for processing by @code{makeindex} can
11701
be produced by the @samp{-XI} option. @xref{Using makeindex}.
11704
Stand-alone indexes produced by @samp{-XI} can be merged with the
11705
@code{idxmerge} utility. @xref{Merging indexes}.
11708
@FWEAVE{}-formatted code can be included in a standard La@TeX{}2e
11709
document by means of the @code{fwebinsert} package.
11710
@xref{Inserting woven code}.
11713
Revision-control-system (RCS) information that appears in the ignorable
11714
commentary between the optional @samp{@@z} and @samp{@@x} that begin an
11715
@FWEB{} file (@pxref{ATz}) is accessible in the body of the file
11716
through the built-in function @code{$KEYWORD} (@pxref{$KEYWORD}) and the
11717
new commands @samp{@@K} (@pxref{ATK_}) and @samp{@@k} (@pxref{ATk}).
11718
These features can access RCS-like keywords that are not known to RCS
11719
itself, as long as they fit the proper syntax (@pxref{ATz}).
11722
The @samp{-h} option now permits easy access to the GNU @code{info} browser if
11723
it is installed. @xref{-h}.
11726
Underscored versions of built-in functions have been removed!!! E.g.,
11727
use @code{$IF}, not @code{_IF}. This change was warned about in the
11731
Single-character identifiers can now be completely cross-referenced via
11732
the @samp{-W1} option. @xref{-W1}.
11735
Some module warning messages can be eliminated with the @samp{-W@@}
11736
option. @xref{-WAT}.
11739
The @samp{@@q} command (still experimental) has been added to locally
11740
turn on or off the the line and module comments in the tangled output.
11744
The level of verbosity of @FWEB{}'s informational messages can be
11745
controlled with the @samp{-M} option. @xref{-M_}.
11748
C/C++ programmers may find the command @samp{@@@{} useful. @xref{ATlb}.
11751
The @samp{-nC} option has been added for @sc{Fortran} users; it kills
11752
commented lines at a very early stage in the processing. This can be
11753
useful when converting existing codes to @FWEB{}.
11757
@sc{Fortran}-90 (@pxref{-n9}) now defaults to free-form syntax.
11760
As of the non-beta Version 1.61, free-form @sc{Fortran}-90 now inserts
11761
semicolons automatically in the code part. Thus, textbook
11762
@sc{Fortran}-90 examples will weave correctly without the annoyance of
11763
explicitly terminating each statement with a semicolon. (If you prefer
11764
to put in the semicolons explicitly, use @samp{--n;} to turn off the
11765
auto-insertion.) @xref{-n;}
11768
The default meaning of the @samp{-k} option was changed; now both lower-
11769
and upper-case forms of @sc{Fortran} I/O keywords are recognized.
11773
Various changes were made to internal code in @file{fwebmac.sty}. This
11774
should not affect anyone @emph{unless} you have redefined @code{fwebmac}
11775
macros. If so, you'll have to compare your versions with the present
11776
ones. For example, colons as argument delimiters in @code{\def}s have
11780
It is now (barely) possible to use @code{\documentstyle@{revtex@}}
11781
instead of the default @code{\documentclass@{article@}}. @xref{REVTeX}.
11786
@subsection Significant bugs (v1.61)
11788
@cindex Bugs, version 1.61
11792
Perhaps the most significant bug is that some high-order (>= 128)
11793
characters in strings may not typeset or be processed correctly. This
11794
may be an issue for some users of foreign-language packages. The
11795
difficulty arises from a design decision made by a previous author.
11796
This has at least partly been fixed, but I eschewed a substantial
11797
overhaul for fear of breaking other things.
11802
@node V1.53, V1.52, V1.61, New features
11803
@comment node-name, next, previous, up
11805
@section Version 1.53
11807
@cindex Features, version 1.53
11808
This release fixes a relatively small number of obscure bugs in
11809
@code{fweb-1.52-beta}. A few minor enhancements were also made. They include
11815
Sections can be numbered by consecutive integers rather than LaTeX's
11816
default Dewey-decimal form by saying
11819
LaTeX.package = "fwebnum"
11825
The @samp{-H} option (experimental and incomplete) was added.
11826
For C and C++, this option tells @FWEAVE{} to scan @code{#include}
11827
files for @samp{typedef} and/or @samp{class} definitions. @xref{-H_}.
11830
The @samp{-k} option was added. This tells @sc{Fortran} and @sc{Ratfor}
11831
to understand the lower-case forms of I/O keywords such as
11832
@samp{iostat} (with the exception of @samp{read}, @samp{write}, and
11833
@samp{end}). @xref{-k}.
11836
The @samp{-n:} option was added. This tells @sc{Fortran} to place
11837
statement labels on a separate line, which is useful when the labels are
11838
relatively long. (By default, @sc{Fortran} labels are placed on the
11839
same line as the thing they are labeling, which looks good for short
11840
labels.) @xref{-ncolon}
11843
The preprocessor command @samp{@@#line} was added. For C code, this
11844
adds an explicit @samp{#line} command to the tangled output file. This
11845
helps to keep the line numbers between debugger and source file in sync
11846
when an @FWEB{} preprocessor statement expands to several lines.
11847
@xref{Debugging with macros}.
11849
An implicit @samp{@@#line} command is added after each @samp{@@%}
11850
(@pxref{AT%}) that begins a line (this keeps line numbering correct).
11851
To override this, use the option @samp{-T#}. @xref{-T#}.
11854
@samp{-p} (style-file) options (@pxref{-p}) on the command line are now
11855
processed @emph{after} the local style file. @xref{Style}.
11858
The functionality of the @samp{-D} command was enhanced to include
11859
optional arguments that limit the information that will be listed. @xref{-D_}.
11864
@node V1.52, V1.50, V1.53, New features
11865
@comment node-name, next, previous, up
11867
@section Version 1.52
11869
@cindex Features, version 1.52
11870
This release was issued only as a beta version. It consists mostly of
11871
bug fixes. However, there are a few other interesting points.
11876
@code{fwebmac.sty} was enhanced to warn the user to run La@TeX{} again
11877
when the section numbering hasn't yet been brought up to date. I'm not
11878
sure I've covered all the bases, but before it didn't complain at all.
11881
C++ classes are now formatted (identified as reserved words) on the first
11882
pass, so forward references such as
11885
@@ The class |C|...
11891
will now work. Note that @b{typedef} has done this for a while, although
11892
there are still a few glitches.
11895
For two years, the documentation has described two control codes as
11899
@@~ --- inhibit line break.
11900
@@+ --- force an index entry.
11903
Apparently the code had these definitions inverted; it has now been brought
11904
up to date with the documentation. Fortunately these commands are
11905
evidently not heavily used, since no one complained.
11908
@code{fwebmac.sty} was further reworked to interact properly with the
11909
user package @code{multicol}. If in @code{fweb.sty} one says
11910
@samp{LaTeX.package "multicol"}, then the two-column index is done with
11911
@code{multicol}; this gives various improvements over the
11912
@code{\twocolumn} format that was used previously. Furthermore, it's
11913
possible to use @samp{multicol} to do one's entire document in
11914
two-column format. This turned out to be relatively simple, but one
11915
needs to get the commands in the proper order. See @ref{LIndex} for more
11916
details. Two-column format substantially cuts down the white space; I
11917
saved about 50% on a 200-page code.
11919
One known glitch with @FWEB{}/@code{multicol} is that if one selects
11920
page-number cross-references instead of La@TeX{} section numbers, page
11921
references such as 98c don't get the 'c' correct. This is presumably not a big
11922
deal. At this point, assume that the use of @code{multicol} is highly
11926
Further bugs in the C and C++ production rules were fixed.
11931
@node V1.50, V1.40, V1.52, New features
11932
@comment node-name, next, previous, up
11934
@section Version 1.50
11936
@cindex Features, version 1.50
11940
The syntax for entries in the initialization file @file{.fweb}
11941
(@pxref{Initialization}) has been
11942
modified (in a way that is as backward-compatible as possible).
11943
Previously, @samp{+} meant process the option before the command-line
11944
options, @samp{-} meant process it after. This convention was somewhat
11945
hard to remember, given the statement that any command-line option could
11946
be put into @file{.fweb}; furthermore, just about everything in
11947
@file{.fweb} should, in fact, be processed before the command-line
11948
options. So now both @samp{+} and @samp{-} mean the same thing, namely
11949
process before (and the @samp{+} notation should fade away as time goes
11950
on). If you explicitly want something to be processed after
11951
all command-line options for some tricky reason, begin it with @samp{&}.
11952
I.e., scan your @samp{.fweb} file for any line beginning with @samp{-}
11953
and replace that with @samp{&}.
11956
The La@TeX{} processor (@samp{-PL}) is now the default.
11959
The experimental @file{fwebmacL.sty} macro package supplied with version
11960
1.40 has been substantially reworked and is now the default
11961
@file{fwebmac.sty}. Remove any reference to @file{fwebmacL.sty} from
11962
your @file{.fweb} file.
11965
Support for La@TeX{}2e is now provided. @xref{LaTeX}.
11968
The style-file parameter @code{index.name} was added. This is the
11969
section name to be given to the Index (@pxref{Index}), which should be
11970
the last major (starred) section. It becomes the contents of the macro
11971
@code{\INDEX}. Therefore, one can end one's source file by saying
11978
The @samp{$IF...} class of built-in functions was reworked. They should
11979
now be more robust, recursive, and intuitive. Simple uses of these
11980
functions should work as before. However, complicated uses that
11981
depended on tricky things about the order of expansion of arguments may
11982
require revision. Carefully compare the descriptions of these functions
11983
in the documentation (e.g., see @ref{$IF}) with your usage of them in
11984
any pre-existing code.
11986
In some cases, if a previous constructions using @code{$IF} no longer works, it
11987
might work if you say
11990
@@m $IF(a,b,c) $$IF(a,b,c)
11993
and then use @code{$$IF} in your code. (This forces an extra level of macro
11994
expansion.) The same remark goes for @code{$DEFINE}.
11996
The old forms @samp{_IF} etc. no longer work; convert to @samp{$IF}.
11999
The option @samp{-j} was added. This inhibits multiple inclusions via
12000
@samp{@@i} of the same include file.
12004
One now has the ability to change the comment character that begins
12005
@FTANGLE{}'s @samp{line} command. In the style file, say, e.g.,
12012
to change the default @samp{*line} output by @FTANGLE{} in @sc{Fortran}
12013
mode to @samp{#line}. This could be useful if one runs the C
12014
preprocessor on the tangled @sc{Fortran} output.
12017
@FWEAVE{}'s processing of @b{typedef} statements in C and C++ was
12021
@FWEB{} should now be able to process C++ templates and exception handling,
12022
at least in simple situations. The typesetting of C++ references (e.g.,
12023
@samp{int&}) was also improved. Please report any difficulties.
12026
There were various miscellaneous obscure bug fixes.
12031
@node V1.40, , V1.50, New features
12032
@comment node-name, next, previous, up@section Version 1.40
12034
@section Version 1.40
12036
@cindex Features, version 1.40
12040
@emph{The meaning of @samp{@@+} has changed.} (SORRY!) Formerly, this
12041
inhibited a line break; that function is now performed by @samp{@@~}.
12042
The new meaning of @samp{@@+} is to force an index entry (the opposite
12043
of @samp{@@-}, which inhibits an index entry).
12045
If you have large codes using the old @samp{@@+} that you do not wish to
12046
convert, you can recover the old mappings by placing the following
12047
commands into @file{fweb.sty}:
12051
no_line_break = "+"
12055
However, please try to make the
12056
conversion; the new codes are intended to be more symmetrical and easier
12060
@emph{Built-in functions now begin with @samp{$}, not @samp{_}.} The
12061
underscore prefix was a bad design decision; it introduces conflicts
12062
with ANSI C in certain circumstances. To ease conversion, the old forms
12063
are still understood. Thus, one can use @samp{$EVAL} and @samp{_EVAL}
12064
interchangably. However, @emph{do not use} the underscore forms; they
12065
will be deleted in future releases.
12068
@emph{Full La@TeX{} support.} @FWEB{} no longer usurps La@TeX{}'s
12069
@code{\output} routine, and La@TeX{}'s sectioning commands,
12070
Table-of-Contents commands, etc. are used. The appearance of the woven
12071
output is changed to be more book-like. (This is an experiment.)
12074
@emph{Verbatim language.} @samp{@@Lv} selects a language-independent format.
12078
@emph{Language-independent mode.} The N mode inhibits pretty-printing,
12079
blank compression, etc.; source code is essentially copied literally
12080
from input to output. This mode is turned on automatically by the
12081
@sc{verbatim} language, but it can also be used with the other languages. It
12082
is turned on by the command-line option @samp{-N} or the local command
12083
@samp{@@N}. @xref{ATN_}.
12086
@emph{Writing of temporary files.} When the @samp{-F} command-line option is
12087
in effect, tangled output is written to temporary files instead of the
12088
final target files, and the temporary files are compared to the last
12089
version of the target files on disk. If there is no change, the target
12090
files are not updated. This avoid unnecessary recompilation if only the
12091
documentation, not the code, was changed. @xref{-F_}.
12094
@emph{Converting output tokens to lower case.} @xref{-U_}.
12097
@emph{The built-in functions @samp{$E} and @samp{$PI}.} @xref{$E},
12101
@emph{The built-in functions @samp{$EXP}, @samp{$LOG}, and
12102
@samp{$LOG10}.} @xref{$EXP}, @ref{$LOG}, and @ref{$LOG10}.
12105
@emph{@samp{$MAX} and @samp{$MIN} generalized to take arbitrary list of
12106
arguments.} @xref{$MAX}, @ref{$MIN}.
12109
@emph{The marriage-saver option}. In response to a serious user
12110
request, see @ref{-B_}.
12115
@node Support, Installing, New features, Top
12116
@comment node-name, next, previous, up
12122
@FWEB{} is supported by John Krommes, @email{krommes@@princeton.edu}.
12123
This project is a definitively @emph{spare-time activity}!!! Bug
12124
reports submitted with very short test files will be verified, although
12125
not necessarily in real time. For very simple fixes, a change file may
12126
be provided. Generally, however, bugs are not fixed until the next
12127
release. Releases occur intermittently, depending on my many other
12128
professional obligations.
12130
Suggestions are very welcome. Many of @FWEB{}'s current features were
12131
incorporated in response to users' requests. However, the queue for
12132
future improvements is long; nothing may happen immediately. The next
12133
major release of @FWEB{}, Version 2.00, is planned for approximately the
12134
year 2000. (You may be relieved to know that, to the best of my
12135
knowledge, @FWEB{} does not suffer from the Y2K bug.)
12137
This info documentation is now accessible on the World-Wide Web from
12140
@url{http://w3.pppl.gov/~krommes/fweb_toc.html}.
12143
You can subscribe to one or both of two @FWEB{} mailing lists,
12144
@code{fweb-users} and @code{fweb-installers}. To subscribe, send e-mail
12145
to @email{majordomo@@pppl.gov}. In the @emph{body} of the message, say, e.g.,
12148
@code{subscribe fweb-users}
12151
You will receive introductory information describing how these lists are
12152
intended to be used. To unsubscribe at any time, substitute
12153
@code{unsubscribe} for @code{subscribe} in the above instructions.
12155
Archive files containing the messages sent to the @FWEB{} mailing
12159
@code{ftp.pppl.gov:/pub/fweb/archive/fweb-@{users,installers@}.archive}.
12162
In addition to anonymous @code{ftp}, these files may be obtained by
12163
sending a message to @code{majordomo@@pppl.gov} of the form
12166
@code{get fweb-users fweb-users.archive}.
12169
@node Installing, Concept index, Support, Top
12170
@comment node-name, next, previous, up
12172
@appendix Installing @FWEB{}
12174
Here is the bare-bones installation procedure for @sc{unix} users:
12176
@cindex Installing @FWEB
12179
Download the @code{zgip}-compressed @code{tar} file from
12180
@code{ftp.pppl.gov:/pub/fweb}.
12181
The name of the file contains the version number---e.g.,
12182
@file{fweb-1.61.tar.gz}.
12187
get fweb-1.61.tar.gz
12192
Uncompress and unpack the tar file:
12195
gunzip fweb-1.61.tar.gz
12196
tar -xf fweb-1.61.tar
12199
If the GNU @code{tar} is installed, these two steps can be combined into
12202
gtar -xzf fweb-1.61.tar.gz
12205
Unpacking creates the directory @file{fweb-1.61}, with at least the two
12206
subdirectories @file{Web} and @file{Manual}.
12209
Change to the new @file{Web} subdirectory and run the configuration script.
12216
@file{./configure} is an @code{sh} script. It attempts to figure out
12217
various local system features automatically, then generates the three
12218
files @file{defaults.mk}, @file{config.h}, and @file{custom.h}; those
12219
are used in the @code{make}. For further information about the
12220
operation of @file{./configure}, see @file{fweb-1.61/READ_ME.FWEB}.
12223
Make and install the release:
12226
make @i{[}CFLAGS='@i{special compiler flags}'@i{]}
12230
If @code{gcc} is available, it will be used in the @code{make}; in that
12231
case, the default @code{CFLAGS} should be sufficient. If another
12232
compiler is used, ensure that it is run in ANSI-compatible mode, not the
12233
old-style Kernighan and Ritchie.
12235
@FWEB{} compiles on my system without any warnings with
12236
@w{@samp{gcc -ansi -pedantic}}. Please report any compiler warnings
12237
from an allegedly ANSI-C environment.
12241
@node Concept index, Option and command index, Installing, Top
12242
@comment node-name, next, previous, up
12244
@unnumbered Concept index
12248
@node Option and command index, Parameter index, Concept index, Top
12250
@unnumbered Option and command index
12254
@node Parameter index, , Option and command index, Top
12255
@comment node-name, next, previous, up
12257
@unnumbered Parameter index