\documentstyle{article}
\font\mc=cmcsc10
\def\TANGLE{{\tt TANGLE}}
\def\TIE{{\tt TIE}}
\def\WEAVE{{\tt WEAVE}}
\def\WEB{{\tt WEB}}
\def\CWEB{{\mc cweb}}
\def\PASCAL{{\mc Pascal}}
\title{The TIE Processor}
\author{Klaus Guntermann\\
TH Darmstadt\\
Fachbereich Informatik\\
Institut f\"ur Theoretische Informatik}

\date{December 1986}
\begin{document}
\maketitle
\section{Introduction}

To install a program on a computer usually
system dependent changes are needed.
The \WEB\ system allows to describe these changes in a
so called change file.
To incorporate the changes into the program \TANGLE\ processes
the original source file and inserts the changes into the proper places.

Sometimes it is good practice to develop a set of change files to be able to
distinguish between different changes like
program enhancements, bug fixes, system dependent changes 
and output device dependent modifications.
Additionally this allows combinations of changes that can be used with a set of 
programs that share some common features.

The processors \TANGLE\ and \WEAVE\ can handle only one change file.
The combination of change files is done best in another preprocessing step.
\TIE\ is able to create either a new master file or a single change file that 
comprises the effect of all change files.

Since \TIE\ does not know anything about \WEB\ programs but only about the 
structure of change files, it is possible to use this program for other 
programming languages as well.
You just pretend that you want to create a new master file and \TIE\ will go 
and insert all the changes from your change files.



\section{Application}

The current version of \TIE\ accepts a master file and up to 9 change files.
Because in general it is important to use the changes in their proper sequence 
the order of the files must be chosen carefully.

The standard version of \TIE\ prompts the user for the names of the change 
files interactively.
The implementor may choose to replace this by a command line interface if the 
operating system and the compiler support such features.
Within this document we will refer to the interactive version of \TIE.

First the name of the master file must be entered.
The extension of this name (beginning with a period) 
is stripped to get the base name of the file.
The base name and the extensions {\tt CF1}, \dots, {\tt CF9} 
are checked.
If such files exist they are opened and are allocated as current change files.
As soon as one of these files is not found the user is asked to supply 
additional change file names.
Thus change files with other names may be used deliberately.
If there are no more changes the user enters an empty name just hitting 
``Return''.
Then the processing mode still must be supplied.
The user may request the creation of a new master file by selection of mode 
``m'' or he may want to create a single change file by selection of mode ``c''.

The name of the output file created is not specified interactively.
It depends on the runtime system of the \PASCAL\ compiler and the
operating system whether it must be given before the program is started
or at some point when the file is to be opened.

The multiple change files are used as if the single change files were merged 
into the master files step by step.
Thus more than 9 change files might be incorporated by repeated application of 
\TIE.

Please note that even when multiple change files are processed each of the 
files is read only once.
For each of the change files and for the master file there is only one line in 
memory at a time (neglecting operating system buffering).
Thus the storage requirement of \TIE\ does not depend on the size of the change 
files or the size of a single changed section.

\vfill\eject
\def\eof{$\langle$EOF$\rangle$}
\section{Example}

To illustrate the actions \TIE\ performs you may inspect the following example 
that exercises some of the border line cases.

$$\vbox{
\halign{#\hfill\qquad\quad&#\hfill\qquad\quad&#\hfill\qquad\quad&#\hfill\cr
``master''      &{\tt CF1}      &{\tt CF2}      &{\tt CF3}\cr
line 1		&@x		&@x		&@x\cr
line 2		&line 2		&line 1		&changed line 4\cr
line 3		&line 3		&changed line 2	&@y\cr
line 4		&@y		&changed line 3	&final line 4\cr
line 5		&changed line 2	&inserted line	&@z\cr
line 6		&changed line 3	&line 4		&\eof\cr
line 7		&inserted line	&@y\cr
line 8		&@z		&final line 2\cr
line 9		&		&final line 3\cr
line 10		&@x		&changed line 4\cr
\eof		&line 7		&@z\cr
		&@y\cr
		&changed line 7	&@x\cr
		&@z		&changed line 7\cr
		&\eof		&line 8\cr
		&		&@y\cr
		&		&final line 7\cr
		&		&final line 8\cr
		&		&@z\cr
		&		&\eof\cr}
}$$
\vfill\eject
Using these input files and running \TIE\ twice to create a new master file
and a new change file will result in the following output files:

$$\vbox{
\halign{#\hfill\qquad\quad&&#\hfill\qquad\quad\cr
``master''	&``change''\cr
final line 2	&@x\cr
final line 3	&line 1\cr
final line 4	&line 2\cr
line 5		&line 3\cr
line 6		&line 4\cr
final line 7	&@y\cr
final line 8	&final line 2\cr
line 9		&final line 3\cr
line 10		&final line 4\cr
\eof		&@z\cr
		&\cr
		&@x\cr
		&line 7\cr
		&line 8\cr
		&@y\cr
		&final line 7\cr
		&final line 8\cr
		&@z\cr
		&\eof\cr}
}$$
\end{document}
