This page lists my attempts (okay, only one so far) at combining literate programming with BCPL.
BCPL is a simple systems programming language developed by Martin Richards. You can find a distribution which includes code for various operating systems including Linux and Windows on his page. Naturally the compiler itself is written in BCPL, and is included in the distribution along with the source to everything else.
And yes, BCPL spawned B, which spawned C, which spawned C++,...
The programs here (again, only one so far) are written in a style called "Literate Programming." The scheme I use is one called noweb, developed by Norman Ramsey. It's language-independent so it works with a variety of programming languages, and it produce documentation in a variety of formats including HTML, troff, and LaTeX. I usually use LaTeX since I want pretty hardcopy.
The idea behind literate programming is that the most important reader of the program is not a compiler but a human being. This may be the author six months after initially writing the program, or another programmer who has to maintain it (or heaven forbid, fix a bug). The documentation and the source are generated from a single source. This source consists of interleaved documentation and code. The fragments are written in the order that best suits describing the program, not the order dictated by any particular programming language. A process called weaving takes the source and produces the typescript. A process called tangling takes the source and produces the code, in the proper order for compilation.
It's important to bear in mind that what one usually thinks of as the source code (the .b file for BCPL) is not the file you should be changing, or even looking at. It's only intended for the compiler. About the only time you should ever have to look at it is when the compiler reports an error and gives a line number. Otherwise you should be looking at the woven output and editing the original noweb source. Treat the .b file as you normally would the .o or .obj file produced by the compiler.
Find patterns in a text file. It's not a full-featured grep but it does understand regular expressions, albeit with its own syntax.
I didn't actually write this program, I translated it from an old C program.
I did this not because there was any pressing need for such a program (even though there isn't such a program included with the standard BCPL distribution), but because I wanted to see how well Literate Programming meshed with BCPL. This program is big enough to be nontrivial but small enough that I could do something with it in a finite amount of time.
|The noweb source||27.3K|
|The woven DVI output||54.1K|
|The tangled BCPL output||7.8K|
This page is under construction.