Prerequisite: Symbol Table
A Symbol table is a data structure used by the compiler, where each identifier in program’s source code is stored along with information associated with it relating to its declaration. It stores identifier as well as it’s associated attributes like scope, type, line-number of occurrence, etc.
Symbol table can be implemented using various data structures like:
- Hash Table
A common data structure used to implement a symbol table is HashTable.
Operations of Symbol table – The basic operations defined on a symbol table include:
Consider the following C++ function:
// Define a global function
int add(int a, int b)
int sum = 0;
sum = a + b;
Symbol Table for above code:
|a||int||function parameter||b||int||function parameter||sum||int||local|
Below is the C++ implementation of Symbol Table using the concept of Hashing with separate chaining:
**** SYMBOL_TABLE **** if inserted -successfully number inserted -successfully Identifier's Name:if Type:keyword Scope: local Line Number: 4 Identifier Is present if Identifier is deleted number Identifier updated Identifier's Name:number Type:variable Scope: global Line Number: 3 Identifier Is present
- Symbol Table in Compiler
- Program to implement ASCII lookup table
- Program for Binomial Coefficients table
- Program to print multiplication table of a number
- 8085 program to print the table of input integer
- 8086 program to print the table of input integer
- Program to implement t-test
- Program to implement Collatz Conjecture
- Program to implement Simpson's 3/8 rule
- Program to implement standard error of mean
- What is the use of the @ symbol in PHP?
- Program to Implement NFA with epsilon move to DFA Conversion
- Python | Program to implement Jumbled word game
- Python | Program to implement simple FLAMES game
- Program to implement standard deviation of grouped data
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.