Chapter 7. Statements

Table of Contents
7.1. Assignments
7.2. Goto Statements
7.3. Procedure Statements
7.4. Answer Statements
7.5. Code Statements
7.6. Compound Statements
7.7. Blocks
7.8. Dummy Statements
7.9. Conditional Statements
7.10. For Statements

Statement ::= 
     Label :  Statement
     Simplestatement
     Conditionalstatement
     Forstatement 

Simplestatement ::= 
     Assignmentstatement
     Gotostatement
     Procedurecall
     Answerstatement
     Codestatement
     Compoundstatement
     Block
     Dummystatement 

Statements are normally executed in the order in which they were written, except that a goto statement may interrupt this sequence without return, and a conditional statement may cause certain statements to be skipped.

7.1. Assignments

The left-hand side of an assignment statement is always a data reference, and the right-hand side an expression for procuring a numerical value. The result of the assignment is that the left-hand side refers to the new value until this is changed by further assignment, or until the value is lost because the reference goes out of scope (but see Section 4.7). The expression on the right hand side is evaluated to the numeric type of the reference, with automatic scaling and rounding as necessary. The left-hand side may be a word reference as defined in Section 6.1.1.2.1 or it may be a part-word reference, i.e. a part-word table-element or some selected field of a word reference. When assignment is made to a part-word reference, the remaining bits of the word are unaltered. As examples of assignment,


[LOCATION(i) + 1] := 3.8

has the effect of placing the integer 4 in the location succeeding that allocated to i, and


BITS[2,6]x := 3

has the effect of placing the binary digits 11 in bits 7 and 6 of the word allocated to x. This last assignment statement is treated in a similar manner to an assignment which has on its left-hand side an unsigned integer table-element. The statement


BITS[1,23][LOCATION(i) + 1] := 1

would in a 24-bit machine, force the sign bit in the indicated location to one. The syntax of the assignment statement is

Assignmentstatement ::= 
     Variable :=  Expression 

Variable ::= 
     Wordreference
     Partwordreference 

Partwordreference ::= 
     Id [  Index ]
     BITS [  Totalbits ,  Bitposition ]  Wordreference 

There is no form of multiple assignment statement.