Commit 9f70d8db authored by Richard Xiong's avatar Richard Xiong
Browse files

Merge commits from master

parents 706dc14d 705d2d75
No preview for this file type
......@@ -412,22 +412,24 @@ 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:}
A while loop statement \lit{while} 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{bool}, and a \lit{do} body statement to be executed if the condition is satisfied.
\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.}
If the condition evaluates to \lit{true}, then the body statement is executed, until the \lit{done} keyword is reached. The \lit{while} 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{true}.
Otherwise, the program exits out of the loop, and continues to execute the next statement. If initially the condition evaluates to \lit{false}, the body statement
\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{true}. In this case, the loop is an infinite loop, and the program will never terminate.
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:}
A scoping statement introduces a new program scope, which is denoted by the \lit{begin} and \lit{end} tokens.
\paragraph{Sequential Composition:}
\hl{... ??? ...}
\hl{This statement composes two statements into one line, to be executed in order. It is denoted by a}
\lit{\hl{;}} \hl{character between the two statements. For example, we can compose the statements s1 and s2 by writing} \lit{\hl{s1 ; s2}} \hl{.}
\hl {Both s1 and s2 must be valid statements for this composed statement to be valid, and s1 will be executed before s2.}
\fillgap{\hl{Define/describe sequential composition} \\ \hl{i.e. }\lit*{\hl{<stat> ; <stat>}} }{2 marks}
\subsection{Expressions}
......@@ -466,14 +468,14 @@ The meaning of each escaped character is shown in Table~\ref{tab:escapedcharacte
Representation & ASCII Value & Description & Symbol \\
\hline
\lit*{\char`\\ 0} & \lit*{0x00} & null terminator & NUL \\
\hl{???} & \lit*{0x08} & \hl{???} & \hl{???} \\
\hl{???} & \lit*{0x09} & \hl{???} & \hl{???}\ \\
\hl{???} & \lit*{0x0a} & \hl{???} & \hl{???} \\
\hl{???} & \lit*{0x0c} & \hl{???} & \hl{???} \\
\lit*{\char`\\ r} & \hl{???} & carriage return & CR \\
\lit*{\char`\\ "} & \hl{???} & double quote & " \\
\lit*{\char`\\ '} & \hl{???} & single quote & ' \\
\lit*{\char`\\ \char`\\} & \hl{???} & backslash & \textbackslash \\
\\lit*{hl{\char`\\ b}} & \lit*{0x08} & \hl{backspace} & \hl{BS} \\
\\lit*{hl{\char`\\ t}} & \lit*{0x09} & \hl{horizontal tab} & \hl{HT}\ \\
\\lit*{hl{\char`\\ n}} & \lit*{0x0a} & \hl{line feed} & \hl{LF} \\
\\lit*{hl{\char`\\ f}} & \lit*{0x0c} & \hl{form feed} & \hl{FF} \\
\lit*{\char`\\ r} & \hl{0x0d} & carriage return & CR \\
\lit*{\char`\\ "} & \hl{0x22} & double quote & " \\
\lit*{\char`\\ '} & \hl{0x27} & single quote & ' \\
\lit*{\char`\\ \char`\\} & \hl{0x5c} & backslash & \textbackslash \\
\hline
\end{tabular}
\caption{The escaped-characters available in the WACC language.}
......
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