Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
A <do-statement> executes a sequence of statements as long as a specified pre/post-condition is True.
-
do-statement = "Do" [condition-clause] EOS statement-block
"Loop" [condition-clause]
-
condition-clause = while-clause / until-clause while-clause = "While" boolean-expression until-clause = "Until" boolean-expression
Static Semantics.
§ Only one <condition-clause> can be specified after the keyword Do or the keyword Loop, not both. If an <until-clause> is specified, the effect is as if it were a <while-clause> with the value of the <boolean-expression> set to "Not (<boolean-expression>)".
§ If no <condition-clause> is specified (either after Do or Loop), the effect is as if a <condition-clause> containing a <while-clause> with the expression "True" were specified after Do.
Runtime Semantics.
§ A <do-statement> repeatedly evaluates its <condition-clause> and executes the <statement-block> if it evaluates to the data value True. The ordering of the of the evaluation of the <condition-clause> and the execution of the <statement-block> is defined by the following table:
|
Location of <condition-clause> |
Result |
|---|---|
|
None specified |
Execution of the loop continues until an <exit-do-statement> is executed. |
|
Immediately following "Do" |
<condition-clause> is evaluated prior to executing <statement-block>. If it evaluates to the data value False then execution of the <statement-block> and the current statement immediately completes. |
|
Immediately following "Loop" |
The <statement-block> is executed before evaluation of the <condition-clause>. If it evaluates to the data value True, then the <statement-block> is again executed and the process is repeated. If it evaluates to the data value False then execution of the <statement-block> and the current statement immediately completes. |