-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymboltable.h
51 lines (38 loc) · 904 Bytes
/
symboltable.h
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
51
#ifndef SYMBOLTABLE_H
#define SYMBOLTABLE_H
#define VAR_NAME_MAX 20
#define MAX_SYMBOLS 10
struct symType{
int type;
int initialized;
int references;
int scope;
int array;
int arrSize;
int parameters;
int localVarStackOffset;
int regContainingArrIndex;
};
struct symbolEntry{
char id[VAR_NAME_MAX];
int type; /*variable or function*/
struct symType attr;
};
struct symTable{
struct symbolEntry symTab[MAX_SYMBOLS];
struct symTable *outerScope;
int numOfSym;
int numOfLocalVar;
};
struct symType parsedsymType;
struct symTable globalSymTab;
struct symTable *CurrentScope;
struct symbolEntry *findSym(char *id);
void insertSym(char *id, struct symType attr, int type);
void insertGlobalSym(char *id, struct symType attr, int type);
void startScope();
void endScope();
void printSym(struct symbolEntry sym);
void resetparsedsymType();
int inFunctionBody();
#endif