12.5 Symbol Table
The Symbol Table is the most important data structure initiated by the Scanner and used throughout the compilation operations. There are various ways in which a Symbol Table can be built. In case of miniC compiler, we decided to use a Binary Search Tree (BST) as Symbol Table. In general, we do not need to delete an entry in a Symbol Table and that fact fits well with the characteristics of a BST. Each node in the Symbol Table tree has the structure:
typedef union{
struct node_struct*N;
char *S;
long I;
float F;
void *P;
}util;
typedef struct node_struct{
struct node_struct *link[2]; // left = 0, right = 1
util u,v,w,x,y,z;
}Node;
typedef Node Symbol;
Further, the following definitions provide shortcuts to access various fields ...
Get Compilers: Principles and Practice now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.