next up previous contents
Next: 2.3.3.1 The Macro Program Up: COSY Previous: Basic COSY

Macro COSY

The Macro COSY notation contains features for the concise representation and precise generation of similar regularities of structure in Basic COSY programs. The Macro COSY notation has been evolved into a flexible and powerful tool for system specification. It has three main features: the collectivisor, then replicator and the distributor. The collectivisor declares arrays of indexed operations to be used in paths or processes. The replicator is the most general feature for representing and generating a variety of similar regularities of structure in Basic COSY programs. Replicators may generate regularities which either follow each other or are nested within each other. Finally, the distributor may represent and generate some regularities in Basic COSY programs. Distributors cannot generate all the regularities which replicators can, but their advantage is that they represent regularities more concisely than replicators.

Now, we will use tex2html_wrap_inline5066 (Section 2.3.2) as an example to see how the macro COSY notation represents this linereader/lineprinter with interrupt handler specification. Firstly, we consider what we need to express the 5-frame ring buffer specified by tex2html_wrap_inline5212 :

displaymath5232

For each of the buffer frames we need a deposit and a remove operation, and there are 5 frames altogether. So we need a collective operation name for each operation type from which to obtain specific operation names by indexing. In the macro notation such collective names and their index ranges are defined as follows:

displaymath5233

The above definition is called a collectivisor, it assumes that index bounds begin at 1 and it generates two totally ordered sets of indexed events without gaps:

displaymath5234

displaymath5235

Once the indexed events have been defined by a collectivisor, they may be used by the rest of the macro notation constructions. In particular, the total order defined for each individual array will be used to expand so called distributors.

Now that we have a way of defining collections of names distinguished by indices we will want to use these collective names to obtain more succinct notation for collections of paths and processes of identical structure but possibly with some operations differing in indices. Body replicators were introduced into the macro notation for this purpose. The general form of a body replicator is:

displaymath5236

For example, the 5 paths representing the individual buffer frames from tex2html_wrap_inline5066 can now be written as:

displaymath5237

Similarly, paths tex2html_wrap_inline5228 through tex2html_wrap_inline5278 from tex2html_wrap_inline5066 can now be expressed succinctly as:

displaymath5238

which shows the utility of having more than one path in a body replicator.

Before we can give the concise form of all of tex2html_wrap_inline5066 we need to introduce replicators which may occur inside of path and process expressions.

Consider the two paths:

displaymath5239

which specify the ring discipline deposits and removals from the frames of tex2html_wrap_inline5212 must obey. To give a more concise formulation, we will need to use a so called concatenator, which concatenates consecutive copies of text patterns and has the form:

displaymath5240

where p(index) denotes a text pattern (possibly involving occurrences of index), and sep is one of the separators ``;'' or ``,''. The @ strips the separator in front of it in the final copy produced from the pattern p(index).

A concise formulation of the two paths from above then becomes:

displaymath5241

and the concise formulation of tex2html_wrap_inline5066 is depicted in Figure 2.3:

  figure1215
Figure 2.3: Linereader/lineprinter with 5-frame ring buffer and interrupt handler 

There is a simple form of concatenator which appears so frequently, e.g. in tex2html_wrap_inline5302 , that we use a very convenient shorthand for it, called a distributor, which turns out to have very natural modelling properties as well.

Consider the path:

displaymath5242

The distributor equivalent to the above concatenator is simply:

displaymath5243

assuming that the collective name deposit has been previously defined by the collectivisor:

displaymath5244

Using this notation we can now rewrite tex2html_wrap_inline5302 to obtain tex2html_wrap_inline5308 which is depicted in Figure 2.4.

  figure1364
Figure 2.4: Linereader/lineprinter with 5-frame ring buffer and interrupt handler 

Programs tex2html_wrap_inline5302 and tex2html_wrap_inline5308 are called Macro COSY Programs. When we expand these two programs, the result will look like the basic COSY program tex2html_wrap_inline5066 (Figure 2.2). The following sections (from section 2.3.3.1 to section 2.3.3.6) will discuss the macro COSY program and macro COSY notation in detail and section 2 will discuss the expansion of macro COSY programs.




next up previous contents
Next: 2.3.3.1 The Macro Program Up: COSY Previous: Basic COSY

Peter Lauer
Mon Jul 22 17:29:46 EDT 1996