Chapter 5:Semantic Analysis

Type system

. A type is a set of values

. Certain operations are legal for values of each type

. A language's type system specifies which operations are valid for a type

. The aim of type checking is to ensure that operations are used on the variable/expressions of the correct types

Type checking is an important aspect of semantic analysis. A type is a set of values. Certain operations are valid for values of each type. For example, consider the type integer in Pascal. The operation mod can only be applied to values of type integer, and to no other types. A language's type specifies which operations are valid for values of each type. A type checker verifies that the type of a construct matches which is expected by its context, and ensures that correct operations are applied to the values of each type.