4.6. Source Tracking

In the beginning, every system is a collection of original source files, one of which is designated as the initial (master) source. Interscript begins processing the initial source, and may switch to another source as a result of executing some command such as 'include_file'. This can be done to break a long work into sections, or to include common 'macros' (python script).

Each source must have a definite name, and each line read is counted. This allows references to the original source to be generated in the code (and documentation) files, so that errors reported by language processors can be corrected. The code files cannot be edited, because they are generated by Interscript and any changes would be overwritten by the next processing run.

A related reason for source tracking is to generate cross reference tables. For example some tanglers generate an identifier cross reference, which can be used, for example, to disentangle duplicated names. The tables can also be used to generate vi editor tags, for example.

Every line of output must have an associated original source. That includes code that is saved temporarily (in memory, or to a disk file), and it includes generated code.

In order to accurately track original source lines, each input driver must have a name, usually the input file name, and must count lines read. When a line is read by the parser, the filename and line number are returned as well. The parser passes this information on to the relevant processor, usually the executor, tangler, or weaver.

In turn, the tangler, for example, will check the sink driver to see if the otput is synchronised with the original source, and then store the source filename and line number in the sink driver.

If since the last write to the sink, not necessarily by this tangler, the original source filename has changed, or the line number is not one more than last time, then a section header is written to the sink file before the data. In C and C++ a #line directive is generated, in languages not supporting such directives (such as HTML and Python), a comment is generated instead. (Coincidentally, many scripting languages use a leading # for a comment and so the C style #line directives is generated)