




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Semantic Analysis Typechecking in COOL
Outline
Why a Separate Semantic Analysis?
Scope
Scope (Cont.)
Static Scoping Example
let x: Int <- 0 in
{ x; let x: Int <- 1 in x; x; }
Static Scoping Example (Cont.)
let x: Int <- 0 in
{ x; let x: Int <- 1 in x; x; }
Uses of x refer to closest enclosing definition
Scope in Cool
Implementing the Most-Closely Nested Rule
Symbol Tables
the current bindings of identifiers
Scope in Cool (Cont.)
More Scope in Cool
Attribute names are global within the class in which they are defined
Class Foo {
f(): Int { a }; a: Int 0;
}
More Scope (Cont.)