Commit 7c87d969 authored by Luke  Thorpe's avatar Luke Thorpe
Browse files

Improved clarity in answer to 'Gap 1'

parent 9f70d8db
No preview for this file type
......@@ -291,9 +291,15 @@ For example, in an \lit*{if} statement where we want to have an empty \lit*{else
A variable declaration statement creates a new program variable in the current scope setting its static type and initial value.
The statement must be given a valid WACC type \synt{type}, a variable name \synt{ident} and an initial assignment value \synt{assign-rhs}.
Variable names must not clash with \hl{any of the base type, unary opener, pair type, pair element, assigment and statement keywords declared in section 2.1.}
They can consist of \hl{a `_', `a'-`z' or `A'-`Z' character, followed by a sequence of alphanumeric characters or `_'.}
\hl{Variable names must consist of one or more characters, whereby each character is either alphanumeric or an underscore (with the exception of the first character, which cannot be a digit). However, it is crucial that variable names do not clash with any keywords in the language. For example:} \lit{return} \hl{is an acceptable identifier by the definition provided above, yet using it as such would cause a syntax error, since it already has some designated functionality within the language. More generally, a keyword can be any literal used as part of the program constructs defined in section 2.1. Notably, they include (but are not limited to):}
\begin{itemize}
\item Statement delimiters, such as \lit{begin}, \lit{is}, \lit{skip}, \lit{while} or \lit{do}.
\item \lit{newpair} and \lit{call}.
\item \lit{pair}, \lit{fst} and \lit{snd}.
\item Any base type.
\item Any unary operator.
\item \lit{true} and \lit{false}.
\end{itemize}
The initial assignment to a variable follows all of the assignment restrictions discussed in detail in the assignment statement section below.
......
# keyword used as variable name
# Output:
# #syntax_error#
# Exit:
# 100
# Program:
begin
int result = 42
end
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