Programs

A program in the subset Elan-1 is an Elan program consisting of one main-packet only.

(315,040) (000,030)program (000,010)(1,0)030060main-packet (1,0)030

We assume the reader to be familiar with the notation of syntax-diagrams. We use those diagrams not only for describing structure but also for introducing useful terminology. For didactic reasons, there will be a large number of relatively simple syntax-diagrams rather than a small number of complicated ones.

The structure of the main-packet is somewhat simpler than it is defined by the standard.

(315,050) (000,040)main-packet (000,020)(1,0)030070bottom-up-part (1,0)030040root (1,0)030070top-down-part (1,0)030 (005,010)(20,20)[rt] (025,010)(20,20)[lb] (025,000)(1,0)080 (105,010)(20,20)[rb] (125,010)(20,20)[lt] (175,010)(20,20)[rt] (195,010)(20,20)[lb] (195,000)(1,0)080 (275,010)(20,20)[rb] (295,010)(20,20)[lt]

The root of the packet is either (as in standard Elan) a paragraph or (as in Elan-0) a refinement. The effect of the execution of an Elan-1 program is the effect of the execution of its bottom-up-part followed by the execution of its root, which may in its turn involve the execution of some refinements in the top-down-part.

(315,060) (000,050)root (000,030)(1,0)030060refinement (1,0)030 (005,020)(20,20)[rt] (025,020)(20,20)[lb] (025,010)(1,0)005060paragraph (1,0)005 (095,020)(20,20)[rb] (115,020)(20,20)[lt]

If the root of the program is a paragraph, it is treated by the Elan Programming Environment as an unnamed refinement, which obtains the name program.

(315,110) (000,100)bottom-up-part (000,080)(1,0)060100procedure-declaration (1,0)030010; (1,0)030 (025,070)(20,20)[lt] (015,070)(0,-1)60 (025,010)(20,20)[lb] (025,000)(1,0)180 (205,010)(20,20)[rb] (215,010)(0,1)60 (205,070)(20,20)[rt] (035,070)(20,20)[rt] (045,070)(0,-1)40 (185,070)(20,20)[lt] (175,070)(0,-1)40 (055,070)(20,20)[lb] (055,060)(1,0)005100operator-declaration (1,0)005 (165,070)(20,20)[rb] (055,050)(20,20)[lb] (055,040)(1,0)005100type-declaration (1,0)005 (165,050)(20,20)[rb] (055,030)(20,20)[lb] (055,020)(1,0)005100synonym-declaration (1,0)005 (165,030)(20,20)[rb]

The bottom-up-part comprises those declarations which precede the root and can be considered as a language fundament on which the rest of the program is to be built.

(315,050) (000,040)top-down-part (000,020)(1,0)030010. (1,0)030060refinement (1,0)030 (025,010)(20,20)[l] (025,000)(1,0)110 (135,010)(20,20)[r]

The top-down-part comprises the refinements that can be invoked from the root. The refinements in the top-down-part can not be invoked from a declaration in the bottom-up-part.

The Elan Programming Environment accepts as input any sequence of declarations, other units and refinements and distributes those elements over the three components of the main-packet in their order of arrival. Therefore the layout and order of input to the Elan Programming Environment can be in a very relaxed syntactic style. In outputting the program the Elan Programming Environment imparts its own strict layout conventions and structure to the program.

(315,040) (000,030)refinement (000,010)(1,0)030040name (1,0)030010: (1,0)030060paragraph (1,0)030

A refinement gives a name to a paragraph. It is invoked by executing its name. It is not a declaration in the proper sense, since it may be invoked (e.g. from the root) before it has been executed. The meaning (effect and value) of a refinement invocation is the same as that of its paragraph.

(315,070) (000,060)paragraph (000,040)(1,0)060040unit (1,0)060 (105,030)(20,20)[r] (105,020)(-1,0)020 (055,020)(1,0)020010; (055,030)(20,20)[l] (005,030)(20,20)[rt] (015,030)(0,-1)20 (025,010)(20,20)[lb] (025,000)(1,0)110 (135,010)(20,20)[rb] (145,010)(0,1)20 (155,030)(20,20)[lt]

The effect of the execution of a paragraph is the effect of the sequential execution of its units in textual order. The value (if any) of a paragraph is the value of its last unit. Notice that a paragraph may be empty. In that case it has neither an effect nor a value.