09-02: Scope
- Matching identifier declaration with uses;
- The scope of an identifier is the potion of a program in which that identifier is accessible;
- Static scope depends only on the program text;
- Dynamic scope depends on execution of the program.
09-03: Symbol Tables
- Much of semantic analysis can be expressed as a recursive descent of an AST;
- When performing semantic analysis on a portion of the AST, we need to know which identifiers are defined;
- A symbol table is a data structure that tracks the current bindings of identifiers;
- Semantic analysis requires multiple passes.
09-04: Types
- The goal of type checking is to ensure that operations are used only with the correct types;
- Three kinds of languages:
- Statically typed: All or almost all checking of types is done as part of compilation;
- Dynamically typed: Almost all checking of types is done as part of program execution;
- Untyped: No type checking.
09-05: Type Checking
- The appropriate formalism for type checking is logical rules of inference.
09-06: Type Environments
- A type environment gives types for free variables:
- A type environment is a function from ObjectIdentifiers to Types;
- A variable is free in an expression if it not defines within the expression.