CS450 Compiler Design
28
Type Rules
Type rules regulate the expected types of arguments and types of
returned values for the operations of a language.
Examples
Terminology:
Static typing
vs.
dynamic typing
Type rule of
<
:
E1
<
E2
is type
-
correct and has type
Boolean
if
E1
and
E2
are both type
-
correct and have type
Integer
Type rule of
while
:
while
E
do
C
is type
-
correct if
E
is type
-
correct and has type
Boolean
and
C
is type
-
correct