============================ Symbol Tables in Haskell ============================ ==> Look at HW8, which asks for a symbol table design. ==> See last Friday's recitation about the use of Data.Map. -------------------------- Look at the symbol table dot files that reference compiler outputs. What symbols/identifiers are in the outermost scope? What information is being stored for them? What symbols are in each class scope? What information is being stored for them? What symbols are in each method scope? What information is being stored for them? -------------------------- While looking at an AST generated by the reference compiler. During an AST traversal ... At which AST nodes will we be changing scope? At which AST nodes is information queried from the symbol table? At which AST nodes is information put into the symbol table? -------------------------- How can we organize this in a Haskell data structure? Recursive dictionary structure A Scope is a dictionary that maps a symbol (String) to a symbol table entry, STE for short. A symbol table entry contains all the information needed for a symbol. What do parameters, member variables, and local variables need? What does a method need? Type signature Scope What does a class need? type Scope = Data.Map String STE data STE = VarSTE ... | MethodSTE Scope ... | ClassSTE ... -- The Scope is the outermost scope that contains classes. -- The list of strings is tracking the current scope in terms of -- classname and method name. -- [] would be outermost scope -- ["Foo"] would be the Foo class scope. -- ["Foo","baz"] would be the baz method inside the Foo class. data SymbolTable = SymTab Scope [String] ------------------------ mstrout@cs.arizona.edu, 11/1/16