-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbol_table.h
89 lines (74 loc) · 1.47 KB
/
symbol_table.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Compilers Project Group 2
// Aditya Raisinghani 2011A7PS042P
// Utkarsh Verma 2011A7PS137P
// BITS Pilani, Pilani Campus
// Second semester 2014
*/
#ifndef SYMBOL
#define SYMBOL
typedef struct _STList *STList;
typedef struct _STable *STable;
typedef struct _identifier *identifier;
typedef enum {VAR,PARA,RETURN} idType;
typedef struct _matrixSizes *matrixSizes;
typedef struct _stringSizes *stringSizes;
struct _STList
{
STList parentList;
STList sisterList;
STList childList;
STable table;
matrixSizes matrixTable;
stringSizes stringTable;
char* functionName;
int scopeIdentifier;
int startLineNumber;
int startCharNumber;
int endLineNumber;
int endCharNumber;
};
struct _STable
{
identifier data;
STable nextEntry;
int scope;
int offset;
int lineNumber;
int charNumber;
idType type;
int scopeIdentifier; // Not sure if neeeded
};
/**
* Separate structure to store string names and their sizes.
*/
struct _stringSizes
{
char* stringName;
int length;
stringSizes nextEntry;
};
/**
* Separate structure to store matrix names and their rows and columns.
*/
struct _matrixSizes
{
char* matrixName;
int rows;
int columns;
matrixSizes nextEntry;
};
/**
* Stores the name of each identifier in symbol table.
*/
struct _identifier
{
token symbol;
char* value;
token type;
};
void checkNextStatementAndRead();
void createSymbolTables();
token convertType(token type);
void printSymbolTable(STList list);
STList generateSymbolTables(astTree astRoot);
#endif