block ::=BEGIN blockbody label? END|BEGIN declist blockbody label? END blockbody ::=statement;|blockbody statement; declist ::=dec|declist dec dec ::=accsyndec|cellsyndec|definedec|externaldec| nonplasyddec|proceduredec|puredec|storagedec
In the previous sections the most frequently used executable statements, the assignment statements, have been defined. These will normally be executed sequentially as written. However, PLASYD does contain control and conditional statements which can change the order in which statements are executed. For example, it is possible to skip a group of statements using the conditional statement. To make these instructions as powerful as possible, statements may be grouped together in a block which can then act as though it were a single statement. A block consists of the word BEGIN followed possibly by some declarations, then some executable statements and the word END, possibly preceded by a label (labels will be defined later). For example:
BEGIN INTEGER I,J; X1:=£J; X4:=3; J(X1):=X4; I(X1):=X4; END
The semicolon terminating the statement immediately preceding the END statement may be omitted.
A single PLASYD program will usually consist of a single block. In general, though, a program will consist of a number of blocks. As a block is a special case of a PLASYD statement, it can be part of another block so that blocks can be nested to any depth. For example:
BEGIN INTEGER I,J; ...... BEGIN INTEGER K; ..... BEGIN INTEGER L; X4:=I(X2)+K(X1)+L(X3); END; ..... END; ..... BEGIN INTEGER M,N; ..... END; END
Unlike Algol 60, identifiers must be unique within the complete segment being compiled. The block structure is therefore a means of allocating storage and reusing it. It does not have any effect on the identifiers allowed.
The only variables which can be used at any point in the program are those which have been declared in the current block or a surrounding block. In the example above, statements in the innermost block containing the assignment to X4 can access the variables whose names are I, J, K and L but cannot access the variables M and N.
There is no dynamic storage allocation in PLASYD. Variables are allocated storage space at compile time. An attempt is made to do this as efficiently as possible. Storage allocated to variables declared in low level blocks may be reused at a later point in a program. In the example above, the variables L and M would be allocated the same storage.
A label may be placed before the END symbol of a block as follows:
LB:END
If a jump is made to this statement, the effect is as though a jump was made to a null statement immediately before the END statement. No null instruction will be generated in this case.