清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.3 The Symbol Table

COMPILER CONSTRUCTION Principles and practice Kenneth C. louden
COMPILER CONSTRUCTION Principles and Practice Kenneth C. Louden

6. Semantic Analysis PART TWO
6. Semantic Analysis PART TWO

Contents Part One 6. 1 Attributes and Attribute grammars 6.2 Algorithms for Attribute Computation Part two 6.3 The Symbol Table 6.4 Data Types and Type Checking 6.5 A Semantic analyzer for the tiny language
Contents Part One 6.1 Attributes and Attribute Grammars 6.2 Algorithms for Attribute Computation Part Two 6.3 The Symbol Table 6.4 Data Types and Type Checking 6.5 A Semantic Analyzer for the TINY Language

6.3 The Symbol Table
6.3 The Symbol Table

Symbol table: major inherited attribute and major data structure in a compiler Principal operations: Insert: store the information provided by name declarations when processing these declarations Lookup: retrieve the information associated to a name when that name is used in the associated code Delete: remove the information provided by a declaration when that declaration no longer applies · Information stored: Include data type information, information on region of applicability(scope), and information on eventual location in memory
• Symbol table: major inherited attribute and major data structure in a compiler • Principal operations: – Insert: store the information provided by name declarations when processing these declarations – Lookup: retrieve the information associated to a name when that name is used in the associated code. – Delete: remove the information provided by a declaration when that declaration no longer applies. • Information stored: – Include data type information, information on region of applicability (scope), and information on eventual location in memory

6.3.1 The Structure of The Symbol Table
6.3.1 The Structure of The Symbol Table

Typical dictionary data structure Linear list Provide easy and direct implementations of the three basic operations Operation time is linear in the size of the list Good for a compiler implementation in which speed is not a major concern such as a prototype or experimental compiler or an interpreter for a very small program Various search tree structures (binary search trees, AVL trees, B trees) Don,'t provide best case efficiency The delete operation is very complexity Less useful
Typical dictionary data structure • Linear list – Provide easy and direct implementations of the three basic operations; – Operation time is linear in the size of the list; – Good for a compiler implementation in which speed is not a major concern such as a prototype or experimental compiler or an interpreter for a very small program. • Various search tree structures – (binary search trees, AVL trees, B trees) – Don't provide best case efficiency; – The delete operation is very complexity; – Less useful

Hash tables All three operation can be performed in almost constant time Most frequently in practice, best choice Main idea An array of entries(called buckets), indexed by an Integer range a hash function turns the search key into an integer hash value in the index range and the item corresponding to the search key is stored in the bucket at this index The efficiency greatly depends on the design of the hash function Main problem Collision resolution: two keys are mapped to the same index by the hash function
• Hash tables – All three operation can be performed in almost constant time – Most frequently in practice, best choice • Main idea – An array of entries (called buckets), indexed by an integer range – A hash function turns the search key into an integer hash value in the index range – And the item corresponding to the search key is stored in the bucket at this index – The efficiency greatly depends on the design of the hash function • Main problem – Collision resolution: two keys are mapped to the same index by the hash function

The methods to deal with the collision Open addressing Inserting the collided new items in successive buckets Will cause a significant degradation in performance and make delete operation difficult Separate chaining Each bucket is a linear list; collisions are resolved by inserting the new item into the bucket list Perhaps it is the best scheme for compiler construction
The methods to deal with the collision • Open addressing – Inserting the collided new items in successive buckets – Will cause a significant degradation in performance and make delete operation difficult • Separate chaining – Each bucket is a linear list; collisions are resolved by inserting the new item into the bucket list • Perhaps it is the best scheme for compiler construction

6.3.2 Declarations
6.3.2 Declarations
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 6.1 Attributes and AttributeGrammars.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.4 Dynamic Memory.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 7.1 Memory Organization During Program Execution.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 1.1 Why? A Brief History.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing byRecursive-Descent.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 4.1 Top-Down Parsing by Recursive-Descent.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 5.3 SLR(1)Parsing.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 5.1 Overview of Bottom-UpParsing.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8.6 Code Generation in Commercial Compilers:Two Case Studies.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8.1 Intermediate Code and Data.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 8 Code Generation.ppt
- 《NFS报文分析》讲义.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)What makes a good manager.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)Ten attributes of a good employee.doc
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:9 Project Procurement Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:8 Project Risk Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:7 Project Communication Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:6 Project HR Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:5 Project Cost Management.ppt
- 华中科技大学:《IT项目管理》(本科)(英文版)Topic:4 Project Time Management.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 3.1 The Parsing Process.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 2.1 The Scanning Process.ppt
- 清华大学:《编译原理》课程教学资源_(英文译文)Chapter 2.4 From Regular Expression To DFAs.ppt
- 《多媒体技术》课程教学资源(PPT课件讲稿).ppt
- 《JAVA基础实例200题》Java例题(一).pdf
- 《JAVA基础实例200题》Java例题(二).pdf
- 《JAVA基础实例200题》Java例题(三).pdf
- 《JAVA基础实例200题》Java例题(四).pdf
- 《JAVA基础实例200题》Java例题(五).pdf
- 《JAVA基础实例200题》练习题.pdf
- 长江大学:《微型计算机技术及应用课件》第一章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第七章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第三章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第九章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第二章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第五章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第八章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第六章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第十章习题答案(李华贵).doc
- 长江大学:《微型计算机技术及应用课件》第四章习题答案(李华贵).doc