This document summarizes key topics from a class on compiler design, including type checking, the type table, type equivalence, coercions, casts and conversions, and kind checking. It discusses how type information is implemented in a compiler to enable convenient type checks throughout the abstract syntax tree, such as for operator usage, routine calls, and variable assignments. Both named and anonymous types are introduced, with anonymous types given unique names by the compiler.
This document summarizes key topics from a class on compiler design, including type checking, the type table, type equivalence, coercions, casts and conversions, and kind checking. It discusses how type information is implemented in a compiler to enable convenient type checks throughout the abstract syntax tree, such as for operator usage, routine calls, and variable assignments. Both named and anonymous types are introduced, with anonymous types given unique names by the compiler.
This document summarizes key topics from a class on compiler design, including type checking, the type table, type equivalence, coercions, casts and conversions, and kind checking. It discusses how type information is implemented in a compiler to enable convenient type checks throughout the abstract syntax tree, such as for operator usage, routine calls, and variable assignments. Both named and anonymous types are introduced, with anonymous types given unique names by the compiler.
first step in checking the proper use of the identifier is to check this kind information which is mostly trivial
Some Kinds which specify objects that involve
values (constants, variables, routines) may be subject to complicated and intricate rules
these values belong to TYPES
TYPE CHECKING is not at all trivial
CSCI 435 Compiler Design
9.3.3
Type Checking 2
Type checking is involved in large parts of the
annotated syntax tree (AST) Examples:
language rules usually specify types which can be
combined with particular operators rules for formal and actual parameters in a routine call assignment of an expression value to a variable restricts the allowed types for the expression
Implementation of Type information in a
compiler has to be implemented so that checks can be performed conveniently 9.3.4
CSCI 435 Compiler Design
Type Declarations
Types are usually introduced by name in Type
Declarations
TYPE Int_Array = ARRAY[Integer 1..10] OF Integer;
defines the type Int_Array
Types may also be introduced ANONYMOUSLY
VAR a: ARRAY [Integer 1..10] OF Real;
Anonymous types don't have a name in the source program the compiler has to use its imagination to invent a unique name like #type01_in_line_35, declaration of a TYPE #type01_in_line_35=ARRAY[Integer 1..10]OF Integer VAR a: #type01_in_line_35 9.3.5