Tangle

tangle

If the scanner, parser, and analyser have successfully (with no errors, severe errors, or fatal errors) completed, and the Tangle option (+O) is turned on (it is by default), then the Tangle component of FunnelWeb is invoked to generate the product files specified in the @O macros of the input file.

The operation of Tangle is very simple. Each @O macro is expanded and written to a file of the same name. As there are a finite number of macros, and the analyser guarantees that the macro structure is non-recursive, Tangle is guaranteed to terminate.

Three remaining points are worth discussing.

  1. Tangle expands macros using blank indentation unless the user has specified otherwise in an indentation pragma in the input file (see Section [*]).

  2. Tangle keeps track of the length of the lines that it is writing and issues an error if any line of any product file that it generates is longer than the maximum. The maximum is the minimum of a value defaulted or specified in the input file (Section [*]), and the value (if any) provided by the +w command line argument (Section [*]).

  3. It is worth the user obtaining some understanding of the resources that FunnelWeb requires to perform its task.

When FunnelWeb's scanner executes, it reads each file into memory where it is kept for the duration of the run. Thus, there must be room in memory for the entire input file, including all include files. While this approach may seem expensive in memory, it is almost necessary in order to support forward references. To merely scan the input file, recording the macro names, but leaving the text on disk, would require many random access disk seeks.

In contrast, FunnelWeb never builds an internal representation of the product file. Instead, each piece of output is written immediately to the product file. This means that as long as the input file fits in memory, the product file can be arbitrarily large. It also means that users need not fear to define or call macros that they know will expand to megabytes of text. Nor need they fear placing a call to such a macro as part of an actual parameter. FunnelWeb does not ever expand actual parameters internally. In fact, it does not expand them until it hits the corresponding formal parameter during its expansion of the called macro. At that point, it looks up the ıexpression (not the expansion of the expression) for the corresponding actual parameter, and starts expanding it.