Commit 87ed4c14 authored by lh5918's avatar lh5918
Browse files

Latest pdf version of specification

parents 148068d7 9f70d8db
No preview for this file type
......@@ -416,7 +416,15 @@ Otherwise, the \lit{else} body statement is executed.
Each of the program branches is executed in its own scope, which are denoted by the \lit{then} and \lit{else} tokens and the \lit{else} and \lit{fi} tokens, respectively.
\paragraph{While Loop Statements:}
\hl{... ??? ...}
\hl{A while loop statement} \lit{\hl{while}} \hl{is used to loop over a body statement, depending on the truth value of the condition given.
The statement is given a condition expression, that must be of type} \lit{\hl{bool}}\hl{, and a} \lit{\hl{do}} \hl{body statement to be executed if the condition is satisfied.}
\hl{If the condition evaluates to }\lit{\hl{true}}\hl{, then the body statement is executed, until the} \lit{\hl{done}} \hl{keyword is reached. The} \lit{\hl{while}} \hl{loop then re-evaluates the condition again, using the
updated program state after executing the body statement, and the body statement is executed repeatedly as long as the condition evaluates to }\lit{\hl{true}}\hl{.
Otherwise, the program exits out of the loop, and continues to execute the next statement. If initially the condition evaluates to }\lit{\hl{false}}\hl{, the body statement
is never executed.
The condition statement may also never evaluate to} \lit{\hl{true}}\hl{. In this case, the loop is an infinite loop, and the program will never terminate.}
\fillgap{\hl{Define/describe while loop statements}}{6 marks}
\paragraph{Scoping Statements:}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment