CWEBX(1)

πŸ’– CWEBX(1) πŸ’–

ok so this is the manual page for CWEBX, from the General Commands Manual section (that's section 1, bestie, the "just type it in your shell" section 🫢). Grab a snack, we're translating CWEB(x) into C and TeX and it's gonna be a whole vibe ✨


🌸 NAME 🌸

ctanglex, cweavex β€” translate CWEB(x) to C (or C++) and/or TeX πŸ’…


✨ SYNOPSIS ✨

ctanglex [ -bhpl ] [ +cs+ ] cwebfile[.w] [(changefile[.ch]|+|-)
[outputfile[.c]]]
cweavex [ -bhpx ] [ +cs+dtefauwm ] [ +isearchpath ] cwebfile[.w]
[(changefile[.ch]|+|-) [outputfile[.tex]]]

πŸ‘‘ DESCRIPTION πŸ‘‘

So here's the tea β˜•: ctanglex takes your CWEB(x) source document and turns it into a C program that you can compile the normal way, no cap. And the output file? It's stuffed with #line specifications, which means error reporting and debugging happen in terms of your CWEB(x) source file. iconic behaviour honestly πŸ’–

cweavex is the other half of the duo β€” it takes that same CWEB(x) file and turns it into a TeX file you can format and print the usual way. It handles all the typographic cuteness for you: page layout, indentation, italics, boldface, etc., etc., and it serves up extensive cross-reference information that it gathers automatically. it's giving ✨automatic✨ πŸ¦‹

CWEBx lets you write ONE single document containing everything you need β€” both to produce a compilable C program and to produce a well-formatted document describing that program in as much detail as the writer could possibly want. Obsessed. But heads up: if you're the user of CWEBx, you ought to have some familiarity with TeX, plus actual knowledge of C. both. no skipping πŸŽ€

🧚 The command line, explained 🧚

Your command line should have one, two, or three names on it. Let's break it down:

  • The first name is taken as the CWEB(x) file β€” and .w gets added if there's no extension. If that file can't be opened, the extension .web is tried instead. πŸ“
  • If there's a second name, it's a change file (and .ch gets added if there's no extension). Otherwise, the name of the CWEB(x) file with its extension replaced by .ch is tried as the change file name; and if there's no such file, no change file is used.
  • Instead of a change file you can specify - or +:
    • - means do not use a change file.
    • + means use a change file only if a file of the default name exists (exactly as if only one name was given).
  • The change file overrides parts of the CWEB(x) file, as described in the documentation. πŸ’€
  • A third name, if present, specifies the output file name explicitly. The default output file name is the CWEB(x) file's name with extension .c (for ctanglex) or .tex (for cweavex). And yes, that default extension also gets applied if a third name is given without an extension. periodt πŸ’…

⭐ Options, and how the toggling works ⭐

Options on the command line may be either turned on with + or off with -. Several characters can follow in the same argument, and they indicate several options turned on (or off) simultaneously. And here's the key part, bestie: the options are processed left to right, so a sequence like -b +b is equivalent to +b (which is the default). 🌈

  • +b β€” shows a banner line on your terminal.
  • +h β€” shows a happy message if the processing was successful. 😭 (we love a happy message)
  • +p β€” shows progress reports (starred module numbers) as the processing takes place.
  • If you say -bhp, you get no terminal output but error messages.
  • +c β€” emulates Levy/Knuth CWEB.
  • +s β€” prints statistics about memory usage at the end of a run (assuming the programs have been compiled with the -DSTAT switch, as they are by default on Debian systems).
  • ++ β€” by setting this option you can select the C++ language instead of C. πŸŽ€
  • -l β€” applicable to ctanglex only. When selected, the C output is made more readable for humans by omitting #line directives and preserving layout and comments. πŸ‘‘

πŸ’œ The cweavex-only options πŸ’œ

There are several other options applicable to cweavex only:

  • -x β€” omit the index and table of contents.
  • +d β€” causes cweavex to report problems encountered in parsing the program fragments.
  • +t β€” the index and module names will be written to separate files.
  • +e β€” the table of contents is forced to start on a new sheet when using a two-sided printer.
  • +f β€” changes the style in which programs are formatted: force a newline after every simple statement in the formatted output.
  • +a β€” also force a newline before every simple statement, even if it follows a label or a condition.
  • +u β€” changes the style so that a line break goes after { instead of before, thus preventing them from aligning with their matching } (this is the style of Levy/Knuth CWEB).
  • +w β€” puts a line break both before and after {, producing a more symmetric layout at the expense of some extra paper. πŸ“
  • +m β€” avoids forcing line breaks between successive declarations in a local block.
  • +isearchpath β€” lets you specify a place to look for header files, for when they're not found in the current directory. The string following the +i will be stored and prepended to a header file name if it can't be found otherwise (so the string should probably end with a pathname separator /). More than one such search path can be specified; they'll be tried in order from left to right. πŸ¦‹
ok so +f, +a, +u, +w, and +m are all about style β€” how programs get formatted. Pick your aesthetic, bestie πŸ’…

πŸ“‚ FILES πŸ“‚

  • /usr/share/texmf/macros/litprog/cwebxmac.tex β€” TeX macros used by cweavex output.
  • /usr/share/texmf/macros/litprog/cwebcmac.tex β€” TeX macros used in compatibility mode.
  • /usr/share/texmf/macros/litprog/cwebhmac.tex β€” TeX macros which can be input after cwebxmac to produce hyperlinks in the output.
  • /usr/share/doc/cwebx/manual.tex β€” The user manual source.
  • /usr/share/doc/cwebx/manual.tex β€” The user manual in DVI format.

πŸ” SEE ALSO πŸ”


πŸ‘‘ AUTHORS πŸ‘‘

Don Knuth wrote WEB for TeX and Pascal. Silvio Levy designed and developed CWEB by adapting the WEB conventions to C and by recoding everything in CWEB. Frank Jensen adapted the programs to ANSI/ISO C, and Marc van Leeuwen made numerous changes for version x3.0, and wrote a new manual. absolute legends, all of them 🫢


πŸ’€ BUGS πŸ’€

The syntactic support for C++ does not cover that language completely, so formatting of complex C++ code may be bad. πŸ™ˆ


and that's the whole page!! this one came from the CWEBX(1) page, dated 7/12/90 β€” ye olde but still serving looks πŸ’– mwah, go write some literate programs bestie 🌸

πŸ“¦ where this page comes from