Checklist: Semantic Analysis
A Griffin language compiler should produce a semantic error in each of the following cases:
-
Declaring two global constants, variables, or procedures with the same name.
-
Declaring two local constants, variables, or parameters with the same name.
-
Integer literal greater than 231 – 1.
-
List literal with two of more elements of different types.
-
Empty list literal in a
const
section.
-
Undeclared identifier used in any type of expression or in an assignment statement.
-
Left-hand side type different from right-hand side type in an assignment statement.
-
Non-list constant as the left-hand side of an assignment statement.
-
Non-integer expression type used in a list index expression (
lst[index]
).
-
Calling an undeclared procedure or a declared non-procedure. Using a procedure name without the calling syntax.
-
Calling a procedure with a wrong number of arguments or with the wrong type of arguments.
-
Calling a procedure that returns a value in a call procedure statement.
-
Non-boolean expression used in
if
and elseif
statements.
-
for
statement using undeclared variable.
-
for
statement iterating over a non-list expression type.
-
for
statement with variable type incompatible with list expression type.
-
return
statement with no expression when one should have been provided or with expression when none should have been provided.
-
return
statement with expression of the wrong type.
-
exit
statement used not within a loop
or for
statement.
-
Incorrect type of operands used with any operator.