4

Donald Knuth has a large number of programs to read on his page. But they are mostly in a "strange" CWEB format...

What could be the best way to make them appropriately readable in Windows?

SamB
  • 8,218
  • 5
  • 44
  • 52
Max Galkin
  • 16,264
  • 9
  • 63
  • 108

2 Answers2

5

Less than five minutes of Googling brings this up: http://www.literateprogramming.com/cweb_download.html

Jim Puls
  • 72,152
  • 10
  • 71
  • 78
  • Is there a better way, without the need to install TeX on my machine? – Max Galkin Jun 15 '09 at 16:45
  • 2
    Given that the CWEB source is written in a TeX variant, I'd say probably not. However, TeX is free and not particularly bloated, so having to install it is no big deal. – David Thornley Jun 15 '09 at 17:17
4

The way I find most convenient to read a CWEB program is by running cweave (manpage) on the .w source file to generate a .tex file, and then running pdfetex to get a nice hyperlinked PDF. Pictorially:

     `.W SOURCE   ----(cweave)---->   .TEX   ----(pdfetex)---->   PDF`

As you would be aware, the structure of a CWEB program is itself sort of hyperlinked (with sections referring other sections). Having a nice, linked PDF is a sheer pleasure to read, specially if the programs have been written by Don Knuth himself!

The following setup would involve some effort on your part (and MBs of download), but I hope you'll like the final result:

  • Install Cygwin (for any serious Windows programmer, I think installing cygwin is a no-brainer). Make sure you install the Typesetting related packages (tex, pdfetex, amstex and all that). If cygwin gives you an option to install CWEB, do that too.
  • If you don't get cweave and ctangle with cygwin, download the sources and build/install those.

Once cygwin and cweb have been installed, do the following to any .w program you wish to study (I'm taking an example of bdd12.w):

  • Run cweave like so: cweave bdd12.w This should generate a bdd12.tex file.
  • Then run pdfetex like so: pdfetex bdd12.tex This should get you a neat, cross-referenced PDF. The generated PDF also has an index of symbols at the end (and some more crossreferencing data), so you can quickly jump to their definitions.
Ashutosh Mehra
  • 2,462
  • 1
  • 18
  • 15