1 / 18

Symbol Tables

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.

largea
Download Presentation

Symbol Tables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Symbol Tables

  2. 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

  3. A Symbol Table Interface

  4. A Symbol Table Interface (cont’d.)

  5. A Symbol Table Interface (cont’d.)

  6. 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).

  7. 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

  8. Basic Implementation Techniques (cont’d.) • String Space Arrays • A fixed-size array

  9. Basic Implementation Techniques (cont’d.) • Segmented String Space Arrays • A dynamic-allocation array

  10. Block-Structured Symbol Tables • Block structured languages

  11. Block-Structured Symbol Tables (cont’d.) • Visibility rules

  12. Block-Structured Symbol Tables (cont’d.) • An Individual Table for Each Scope

  13. Block-Structured Symbol Tables (cont’d.)

  14. Block-Structured Symbol Tables (cont’d.)

  15. Block-Structured Symbol Tables (cont’d.)

More Related