Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Procedure-statements

A procedure-statement shall specify the activation of the block of the procedure-block associated with the procedure-identifier of the procedure-statement. If the procedure has any formal-parameters, the procedure-statement shall contain an actual-parameter-list, which is the list of actual-parameters that shall be bound to their corresponding formal-parameters defined in the procedure-declaration. The correspondence shall be established by the positions of the parameters in the lists of actual-parameters and formal-parameters respectively. The number of actual-parameters shall be equal to the number of formal-parameters. The types of the actual-parameters shall correspond to the types of the formal-parameters as specified by 6.6.3.

The order of evaluation, accessing, and binding of the actual-parameters shall be implementation-dependent.

The procedure-identifier in a procedure-statement containing a read-parameter-list shall denote the required procedure read; the procedure-identifier in a procedure-statement containing a readln-parameter-list shall denote the required procedure readln; the procedure-identifier in a procedure-statement containing a write-parameter-list shall denote the required procedure write; the procedure-identifier in a procedure-statement containing a writeln-parameter-list shall denote the required procedure writeln.

procedure-statement = procedure-identifier ( [ actual-parameter-list ]

½ read-parameter-list ½ readln-parameter-list

½ write-parameter-list ½ writeln-parameter-list ) .

 

Examples:

printheading

transpose(a, n, m)

bisect(fct, -1.0, +1.0, x)

AddVectors(m[1], m[2], m[k])

 

NOTE --- The fourth example is not for level 0.

 

Goto-statements

A goto-statement shall indicate that further processing is to continue at the program-point denoted by the label in the goto-statement and shall cause the termination of all activations except

a) the activation containing the program-point; and

b) any activation containing the activation-point of an activation required by exceptions a) or b) not to be terminated.

goto-statement = 'goto' label .

 

Structured-statements

 

General

structured-statement = compound-statement ½ conditional-statement

½ repetitive-statement ½ with-statement .

statement-sequence = statement { ';' statement } .

The execution of a statement-sequence shall specify the execution of the statements of the statement-sequence in textual order, except as modified by execution of a goto-statement.

 

Compound-statements

A compound-statement shall specify execution of the statement-sequence of the compound-statement.

compound-statement = 'begin' statement-sequence 'end' .

 

Example:

begin z := x; x := y; y := z end

 

Conditional-statements

conditional-statement = if-statement ½ case-statement .



 

If-statements

if-statement = 'if' Boolean-expression 'then' statement [ else-part ] .

else-part = 'else' statement .

If the Boolean-expression of the if-statement yields the value true, the statement of the if-statement shall be executed. If the Boolean-expression yields the value false, the statement of the if-statement shall not be executed, and the statement of the else-part, if any, shall be executed.

An if-statement without an else-part shall not be immediately followed by the token else.

 

NOTE --- An else-part is thus paired with the nearest preceding otherwise unpaired then.

 

Examples:

if x < 1.5 then z := x + y else z := 1.5

if p1 <> nil then p1 := p1.father

if j = 0 then

if i = 0 then writeln('indefinite')

else writeln('infinite')

else writeln( i / j )

 

Case-statements

The values denoted by the case-constants of the case-constant-lists of the case-list-elements of a case-statement shall be distinct and of the same ordinal-type as the expression of the case-index of the case-statement. On execution of the case-statement the case-index shall be evaluated. That value shall then specify execution of the statement of the case-list-element closest-containing the case-constant denoting that value. One of the case-constants shall be equal to the value of the case-index upon entry to the case-statement; otherwise, it shall be an error.

 

NOTE --- Case-constants are not the same as statement labels.

 

case-statement = 'case' case-index 'of' case-list-element { ';' case-list-element } [ ';' ] 'end' .

case-list-element = case-constant-list ':' statement .

case-index = expression .

 

Example:

case operator of

plus: x := x + y;

minus: x := x - y;

times: x := x * y

end

 


Date: 2015-12-24; view: 714


<== previous page | next page ==>
Arithmetic operators | Repetitive-statements
doclecture.net - lectures - 2014-2022 year. Copyright infringement or personal data (0.002 sec.)