1 Symbol Tables. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

1 11. Hash Tables Heejin Park College of Information and Communications Hanyang University.
Slide 1 Insert your own content. Slide 2 Insert your own content.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 7 System Design Techniques.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
List and Search Grants Chapter 2. List and Search Grants 2-2 Objectives Understand the option My Grants List Grant Screen Viewing a Grant Understand the.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
BALANCING 2 AIM: To solve equations with variables on both sides.
Compilers Course 379K, TTH 9:30-11:00 Instructor: Dr. Doron A. Peled Office Hours: Mon 11:00-12:00.
Introduction to Compiler Construction
Photo Composition Study Guide Label each photo with the category that applies to that image.
Chapter 2-2 A Simple One-Pass Compiler
Lesson 6 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
David Luebke 1 6/7/2014 ITCS 6114 Skip Lists Hashing.
1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
Chap 8 Symbol Table name attributes : :
Hash Tables.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Hash Tables,
COP 3402 System Software Fall 2013
Symbol Table.
O X Click on Number next to person for a question.
© S Haughton more than 3?
5.9 + = 10 a)3.6 b)4.1 c)5.3 Question 1: Good Answer!! Well Done!! = 10 Question 1:
1 Directed Depth First Search Adjacency Lists A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: F A B C G D E H I.
Linking Verb? Action Verb or. Question 1 Define the term: action verb.
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Hashing / Hash tables Chapter 20 CSCI 3333 Data Structures.
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
11 = This is the fact family. You say: 8+3=11 and 3+8=11
Week 1.
1 Week 9 Questions / Concerns Hand back Test#2 What’s due: Final Project due next Thursday June 5. Final Project check-off on Friday June 6 in class. Next.
1 Ke – Kitchen Elements Newport Ave. – Lot 13 Bethesda, MD.
O X Click on Number next to person for a question.
Lecture 6 Hashing. Motivating Example Want to store a list whose elements are integers between 1 and 5 Will define an array of size 5, and if the list.
Data Structures Using C++ 2E
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
1 Contents Introduction A Simple Compiler Scanning – Theory and Practice Grammars and Parsing LL(1) Parsing LR Parsing Lex and yacc Semantic Processing.
© 2006 Pearson Addison-Wesley. All rights reserved13 A-1 Chapter 13 Hash Tables.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
Data Structures Using C++ 2E Chapter 9 Searching and Hashing Algorithms.
Lecture 6 Hashing. Motivating Example Want to store a list whose elements are integers between 1 and 5 Will define an array of size 5, and if the list.
國立台灣大學 資訊工程學系 薛智文 98 Spring Symbol Table (textbook ch#2.7 and 6.5 )
Symbol Tables Symbol tables are used by compilers to keep track of information about variables functions class names type names temporary variables etc.
Hashing Chapter 20. Hash Table A hash table is a data structure that allows fast find, insert, and delete operations (most of the time). The simplest.
1 Symbol Tables The symbol table contains information about –variables –functions –class names –type names –temporary variables –etc.
Chapter 3: Symbol Table 1 Compiler Designs and Constructions Chapter 3: Symbol Table Objectives: (7.6) Introduction to Symbol Table Implementation of Symbol.
Hashing1 Hashing. hashing2 Observation: We can store a set very easily if we can use its keys as array indices: A: e.g. SEARCH(A,k) return A[k]
1 CSCD 326 Data Structures I Hashing. 2 Hashing Background Goal: provide a constant time complexity method of searching for stored data The best traditional.
1 Chapter 9 Searching And Table. 2 OBJECTIVE Introduces: Basic searching concept Type of searching Hash function Collision problems.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Hash Tables ADT Data Dictionary, with two operations – Insert an item, – Search for (and retrieve) an item How should we implement a data dictionary? –
Semantic Analysis. Find 6 problems with this code. These issues go beyond syntax.
Hashing CSE 2011 Winter July 2018.
Hashing Exercises.
Subject: Language Processor
Symbol Table 薛智文 (textbook ch#2.7 and 6.5) 薛智文 96 Spring.
SYMBOL TABLE Chuen-Liang Chen Department of Computer Science
Linear Hashing Example
Presentation transcript:

1 Symbol Tables

2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice Grammars and Parsing Grammars and Parsing LL(1) Parsing LL(1) Parsing Lex and yacc Lex and yacc LR Parsing LR Parsing Semantic Processing Semantic Processing Symbol Tables Symbol Tables Run-time Storage Organization Run-time Storage Organization Code Generation and Local Code Optimization Code Generation and Local Code Optimization Global Optimization Global Optimization

3 A Symbol Table Interface

4

5 A Symbol Table Interface (contd.)

6

7 Basic Implementation Techniques Unordered List Unordered List Ordered List Ordered List Binary Search Trees Binary Search Trees The expected search time is O(log(n)) The expected search time is O(log(n)) For a balanced tree, the worst-case performance is O(n). For a balanced tree, the worst-case performance is O(n).

8 Basic Implementation Techniques (contd.) Hash Tables Hash Tables Hash function Hash function Resolving collisions Resolving collisions Linear Linear If position h(n) is occupied, try (h(n)+1) mod m If position h(n) is occupied, try (h(n)+1) mod m Add-the-hash rehash Add-the-hash rehash If position h(n) is occupied, try (2*h(n)) mod m If position h(n) is occupied, try (2*h(n)) mod m Quadratic rehash Quadratic rehash If position h(n) is occupied, try (h(n)+1**2) mod m If position h(n) is occupied, try (h(n)+1**2) mod m Collision resolution by chaining Collision resolution by chaining

9 Basic Implementation Techniques (contd.) String Space Arrays String Space Arrays A fixed-size array A fixed-size array

10 Basic Implementation Techniques (contd.) Segmented String Space Arrays Segmented String Space Arrays A dynamic-allocation array A dynamic-allocation array

11 Block-Structured Symbol Tables Block structured languages Block structured languages

12 Block-Structured Symbol Tables (contd.) Visibility rules Visibility rules

13 Block-Structured Symbol Tables (contd.) An Individual Table for Each Scope An Individual Table for Each Scope

14 Block-Structured Symbol Tables (contd.)

15 Block-Structured Symbol Tables (contd.)

16 Block-Structured Symbol Tables (contd.)

17

18