180 likes | 200 Views
Symbol Tables. Contents. Introduction A Simple Compiler Scanning – Theory and Practice Grammars and Parsing LL(1) Parsing Lex and yacc LR Parsing Semantic Processing Symbol Tables Run-time Storage Organization Code Generation and Local Code Optimization Global Optimization.
E N D
Contents • Introduction • A Simple Compiler • Scanning – Theory and Practice • Grammars and Parsing • LL(1) Parsing • Lex and yacc • LR Parsing • Semantic Processing • Symbol Tables • Run-time Storage Organization • Code Generation and Local Code Optimization • Global Optimization
Basic Implementation Techniques • Unordered List • Ordered List • Binary Search Trees • The expected search time is O(log(n)) • For a balanced tree, the worst-case performance is O(n).
Basic Implementation Techniques (cont’d.) • Hash Tables • Hash function • Resolving collisions • Linear • If position h(n) is occupied, try (h(n)+1) mod m • Add-the-hash rehash • If position h(n) is occupied, try (2*h(n)) mod m • Quadratic rehash • If position h(n) is occupied, try (h(n)+1**2) mod m • Collision resolution by chaining
Basic Implementation Techniques (cont’d.) • String Space Arrays • A fixed-size array
Basic Implementation Techniques (cont’d.) • Segmented String Space Arrays • A dynamic-allocation array
Block-Structured Symbol Tables • Block structured languages
Block-Structured Symbol Tables (cont’d.) • Visibility rules
Block-Structured Symbol Tables (cont’d.) • An Individual Table for Each Scope