SlideShare a Scribd company logo
NADAR SARASWATHI COLLEGE OF ARTS&SCIENCE,THENI
DEPARTMENT OF COMPUTER SCIENCE&INFORMATION TECHNOLOGY
V.S.PRIYADHARSHINI
I-MSC(CS)
COMPILER DESIGN
TOPIC: DATA STRUCTURES FOR SYMBOL TABLES
DATA STRUCTURES FOR SYMBOL
TABLES
Symbol Table in Compiler
 A symbol table is a data structure employed by a
language translator, like a compiler or interpreter,
within which each identifier in a program's source
code is connected with information about its
declaration or presence in the source code, like
its type, scope level, and infrequently its position.
 A symbol table is a significant data structure
used in a compiler that correlates characteristics
with program identifiers. The analysis and
synthesis stages employ symbol table
information to verify that used identifiers have
been specified, to validate that expressions and
assignments are semantically accurate, and to
build intermediate or target code.
There are three data structures used to
implement symbol table:
Linear List
Binary Search Tree
Hash Table
LINEAR LISTS
Linear Lists
 It is the simplest and most
straightforward method of
implementing data structures. To store
names and their accompanying
information, we use a single array.
New names are added to the list in the
order that they appear. To add a new
name, we must first check the list to
ensure that it does not already exist.
Compiler design
TREES
Trees
It is a more efficient method of
organizing symbol tables. Each record
now has two link fields, LEFT and
RIGHT. The procedure below is used
to find NAME in a binary search tree
where x is originally a reference to the
root.
 1. while x ≠ null do
 2. if NAME = NAME(x) then /* NAME
found take action on success*/
 3. else if NAME < NAME(x) then
x:=LEFT(x) /* visit left child*/ 5. else /*
NAME (p)<NAME*/ X:= RIGHT(x)
/*visit right child*/
HASH TABLE
Hash Table
Hashing table technique is suitable for
searching and hence it is implemented
in compiler.
Compiler design
HASH FUNCTION
Hash Function
The hash function is the mapping
between an item and the place in the
hash table where that item resides.
The hash function takes a collection
item and returns an integer in the
range of slot names from 0 to m-1.
Example:
Assume that we have the set of integer items 59,
28, 93, 18, 77 and 31.
Consider m=11 (number of slots of hash table)
Suppose we want to insert the above elements
within the slots by using formula:
h(item) % m
59 % 11 = 4
28 % 11 = 6
93 % 11 = 5
18 % 11 = 7
77 % 11 = 0
31 % 11 = 9
Compiler design

More Related Content

PPTX
Hashing
PPTX
Lecture 11
PPTX
Zlookup function
PPTX
R Datatypes
DOCX
Bc0038– data structure using c
PPTX
Doubly linked list
PPTX
Data structure and its types.
PPTX
Hashing In Data Structure
Hashing
Lecture 11
Zlookup function
R Datatypes
Bc0038– data structure using c
Doubly linked list
Data structure and its types.
Hashing In Data Structure

What's hot (20)

PPTX
Join operation
PDF
Symbol table in compiler Design
PPTX
Presentation on Data Structure
PPT
Introductiont To Aray,Tree,Stack, Queue
PPTX
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
PDF
Datastructureitstypes
PPTX
Data Structures
PPTX
Data structure & its types
PPTX
Data structure
PPTX
R data types
PPTX
Hashing 1
PPTX
Data structure and its types
PPT
linked list (c#)
PDF
08 Hash Tables
PPTX
Data Structure & Algorithms | Computer Science
PPTX
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
PPT
Lecture 1 data structures and algorithms
PPTX
Introduction to data structure ppt
PDF
Skipl List implementation - Part 1
ZIP
Hashing
Join operation
Symbol table in compiler Design
Presentation on Data Structure
Introductiont To Aray,Tree,Stack, Queue
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Datastructureitstypes
Data Structures
Data structure & its types
Data structure
R data types
Hashing 1
Data structure and its types
linked list (c#)
08 Hash Tables
Data Structure & Algorithms | Computer Science
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Lecture 1 data structures and algorithms
Introduction to data structure ppt
Skipl List implementation - Part 1
Hashing
Ad

Similar to Compiler design (20)

PPTX
Symbol Table.pptx
PPTX
data structure of symbol table.pptx
PPTX
Symbol Table
PPTX
Compiler and symbol table
PDF
Symbol-Table concept in compiler design pdf for reference
PPTX
Data Structures and Agorithm: DS 24 Hash Tables.pptx
PPTX
BCS304 Module 5 slides DSA notes 3rd sem
PPTX
hashing in data strutures advanced in languae java
PPTX
Symbol table
PDF
Advanced data structures vol. 1
PPTX
Lec12-Hash-Tables-27122022-125641pm.pptx
PPTX
Hash function
PPTX
Data structures and algorithms lab11
PPTX
Working with python Nice PPT must try very good
PPTX
compiler design symbol table concept.pptx
PPT
The Stack in Data structure and algorithm
PPT
4.4 hashing02
PPT
Introduction to Hashing in Data Structure using C++
PPT
Hashing ENL A CRIPTOGRAFIAAAAAAAAAAAAAA .ppt
PPT
11_hashtable-1.ppt. Data structure algorithm
Symbol Table.pptx
data structure of symbol table.pptx
Symbol Table
Compiler and symbol table
Symbol-Table concept in compiler design pdf for reference
Data Structures and Agorithm: DS 24 Hash Tables.pptx
BCS304 Module 5 slides DSA notes 3rd sem
hashing in data strutures advanced in languae java
Symbol table
Advanced data structures vol. 1
Lec12-Hash-Tables-27122022-125641pm.pptx
Hash function
Data structures and algorithms lab11
Working with python Nice PPT must try very good
compiler design symbol table concept.pptx
The Stack in Data structure and algorithm
4.4 hashing02
Introduction to Hashing in Data Structure using C++
Hashing ENL A CRIPTOGRAFIAAAAAAAAAAAAAA .ppt
11_hashtable-1.ppt. Data structure algorithm
Ad

More from PriyadharshiniVS (20)

PPTX
R Ramya devi digital image processing
PPTX
R ramya devi cloud computing
PPTX
Ramya devi R women empowerment
PPTX
R Ramya devi artificial intelligence and machine learning
PPTX
Ramya devi R internet of things
PPTX
PPTX
PPTX
PPTX
PPTX
MOBILE APP DEVELOPMENT USING PYTHON
PPTX
Vanmathy python
PPTX
PriyaDharshini distributed operating system
PPTX
Vanmathy distributed operating system
PPTX
vanmathy cryptography network security
PPTX
vanmathy cryptography network security
PPTX
Vanmathy distributed operating system
PPTX
Vanmathy no sql
PPTX
Cryptography and network security
PPTX
PPTX
Graph, graph and network modeling, advantage of graph database
R Ramya devi digital image processing
R ramya devi cloud computing
Ramya devi R women empowerment
R Ramya devi artificial intelligence and machine learning
Ramya devi R internet of things
MOBILE APP DEVELOPMENT USING PYTHON
Vanmathy python
PriyaDharshini distributed operating system
Vanmathy distributed operating system
vanmathy cryptography network security
vanmathy cryptography network security
Vanmathy distributed operating system
Vanmathy no sql
Cryptography and network security
Graph, graph and network modeling, advantage of graph database

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
advance database management system book.pdf
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
IGGE1 Understanding the Self1234567891011
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Lesson notes of climatology university.
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
1_English_Language_Set_2.pdf probationary
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Final Presentation General Medicine 03-08-2024.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Classroom Observation Tools for Teachers
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
advance database management system book.pdf
Indian roads congress 037 - 2012 Flexible pavement
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
IGGE1 Understanding the Self1234567891011
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Lesson notes of climatology university.
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Chinmaya Tiranga quiz Grand Finale.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Types and Its function , kingdom of life
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
A powerpoint presentation on the Revised K-10 Science Shaping Paper
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
1_English_Language_Set_2.pdf probationary
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE

Compiler design

  • 1. NADAR SARASWATHI COLLEGE OF ARTS&SCIENCE,THENI DEPARTMENT OF COMPUTER SCIENCE&INFORMATION TECHNOLOGY V.S.PRIYADHARSHINI I-MSC(CS)
  • 2. COMPILER DESIGN TOPIC: DATA STRUCTURES FOR SYMBOL TABLES
  • 3. DATA STRUCTURES FOR SYMBOL TABLES Symbol Table in Compiler  A symbol table is a data structure employed by a language translator, like a compiler or interpreter, within which each identifier in a program's source code is connected with information about its declaration or presence in the source code, like its type, scope level, and infrequently its position.  A symbol table is a significant data structure used in a compiler that correlates characteristics with program identifiers. The analysis and synthesis stages employ symbol table information to verify that used identifiers have been specified, to validate that expressions and assignments are semantically accurate, and to build intermediate or target code.
  • 4. There are three data structures used to implement symbol table: Linear List Binary Search Tree Hash Table
  • 5. LINEAR LISTS Linear Lists  It is the simplest and most straightforward method of implementing data structures. To store names and their accompanying information, we use a single array. New names are added to the list in the order that they appear. To add a new name, we must first check the list to ensure that it does not already exist.
  • 7. TREES Trees It is a more efficient method of organizing symbol tables. Each record now has two link fields, LEFT and RIGHT. The procedure below is used to find NAME in a binary search tree where x is originally a reference to the root.
  • 8.  1. while x ≠ null do  2. if NAME = NAME(x) then /* NAME found take action on success*/  3. else if NAME < NAME(x) then x:=LEFT(x) /* visit left child*/ 5. else /* NAME (p)<NAME*/ X:= RIGHT(x) /*visit right child*/
  • 9. HASH TABLE Hash Table Hashing table technique is suitable for searching and hence it is implemented in compiler.
  • 11. HASH FUNCTION Hash Function The hash function is the mapping between an item and the place in the hash table where that item resides. The hash function takes a collection item and returns an integer in the range of slot names from 0 to m-1.
  • 12. Example: Assume that we have the set of integer items 59, 28, 93, 18, 77 and 31. Consider m=11 (number of slots of hash table) Suppose we want to insert the above elements within the slots by using formula: h(item) % m 59 % 11 = 4 28 % 11 = 6 93 % 11 = 5 18 % 11 = 7 77 % 11 = 0 31 % 11 = 9