-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSymbolTable.h
44 lines (38 loc) · 1.01 KB
/
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
#ifndef SYMBOL_TABLE_H_INCLUDED
#define SYMBOL_TABLE_H_INCLUDED
#include "Symbol.h"
#include <vector>
#include <string>
/*
Define data structures for symbol table
*/
using namespace std;
class Symbol;
class SymbolTableFrame;
class SymbolTable {
private:
SymbolTableFrame* currFrame;
public:
void Add(Symbol* symbol);
Symbol* Get(std::string name);
SymbolTable();
void EnterScope();
void ExitScope();
void DumpCurrFrameTo(Symbol* structSymbol);
Symbol* RegisterSymbol(std::string name, bool isFunction, bool isType, int dimension);
SymbolTableFrame* GetCurrFrame();
};
class SymbolTableFrame {
friend class SymbolTable;
private:
SymbolTableFrame* innerFrame;
public:
string owner;
std::vector<Symbol*> symbols;
SymbolTableFrame(SymbolTableFrame* innerFrame);
void Add(Symbol* symbol);
Symbol* Get(std::string name);
Symbol* GetInCurrFrame(std::string name);
Symbol* RegisterSymbol(std::string name, bool isFunction, bool isType, int dimension);
};
#endif