-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsymTable.h
More file actions
50 lines (49 loc) · 1011 Bytes
/
symTable.h
File metadata and controls
50 lines (49 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<ctype.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#ifndef SYM_NODE
#define SYM_NODE
class Symbol_node {
friend class Symbol_table;
public:
Symbol_node(char * id);
~Symbol_node(void);
//void putval(VALUE);
void putval(int);
//VALUE getval(void);
int getval(void);
Symbol_node * getNext();
void setNext(Symbol_node * next);
char * getId();
void setId(char * id);
private:
char * id;
//int token;
//VALUE value;
int val;
Symbol_node * next;
};
#endif
typedef Symbol_node * Symbol_ptr;
#ifndef SYM_TABLE
#define SYM_TABLE
class Symbol_table {
public:
Symbol_table(void);
~Symbol_table(void);
//hash function
unsigned int hash(const char * str);
//insert something into the table
Symbol_ptr insert (char * name);
//void remove(char *);
//find the variable and return a pointer to it
Symbol_ptr lookup(char * name);
void dump_table(void);
//int table_size = 211;
private:
Symbol_ptr *table;
};
#endif