The Pweb Literate Programming system
What Literate Programming
Literate Programming was invented by D.E. Knuth to implement TeX. The idea is that a program should read like an article.
A literate programming environment also called web-system consist of two programs called tangle and weave.
The tangle program extracts the source code of the web-file and generates an input file for the compiler (interpreter) of our programming language. It must resort the code from the human readable form into the machine readable form.
The weave program generates the input for a text processor. It must apply syntax highlighting to our code and generate an index, etc.
In principle you can use any text processing tool and any computer language as basis for a literate programming environment. In practice the weave and tangle program need some information about the destination language, so a specific literate programming environment support only few languages.
Pweb Design goals
When I started this project, I found that non of the existing literate programming systems satisfies exactly my needs. So I began with the development of a new literate programming tool. I called pweb, since its main part is a bunch of Perl scripts.
I designed pweb with the following goals in mind:
- It should be easy to add support for additional programming language. To guarantee this pweb should only use regular expressions and not a complete parser. I was willing to scarify advanced formating functions, like auto-detection of variables, for this goal.
- Not every language have such a good preprocessor like LISP. Therefore pweb should provide its own preprocessor. I decided to use the macro processor M4 for that purpose.
- It should be possible to have (in documentation) variable names like α, x', etc.
Pweb status
I use pweb for most of my programs and I have already done medium size project in pweb (see for example the population count program, joint work with Y. Edel). So it works, but I consider it still α-status.
Known Limitations
- The scripts assume that they are installed under /usr/local. At the moment the path is a fixed constant in the scripts. I plan to add an install script that allow you to choose the installation path.
- Pweb uses temporary files without checking if the file name exists. So never run it as root and use only trusted sources.
- One of my next goals is to add a good Perl mode to pweb and reimplemented pweb in pweb.
Downloads
You can download the latest release of pweb here. A manual is here.
