Ch 5: Basic Semantics ----------------------- Semantics: describes the meaning of programs -- operational Vs denotational -- formal Vs informal Semantics is typically defined in a bottom-up fashion: -- values -- names -- variables -- constants -- expressions -- statements -- compound statements -- procedures -- program 5.1 Attributes, Binding, and Semantic Functions Meanings of names is captured via attributes associated with the names: -- type -- value -- location Binding: establishing an association between name and an attribute -- binding time -- static -- language definition time -- lang impl time -- compile-time -- link time -- load time -- dynamic Eg: type is statically bound in most langs value is dynamically bound location may be dynamically or statically bound Bindings are held in -- symbol table: name --> static attributes -- environment: name --> locations -- memory: locations --> value Declarations Blocks and Scopes ------------------------------- Scope: region of program over which a declaration is in effect ie bindings established by decl must be maintained global package or module file class procedure block Block-structured, lexically-scoped language Visibility: redefinitions in inner scopes supercede outer definitions qualifiers may be needed to make otherwise invisible names to be visible in a scope Eg: local var superceding global var names in other packages private members in classes