-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymTableHelp.cpp
More file actions
48 lines (38 loc) · 1.05 KB
/
SymTableHelp.cpp
File metadata and controls
48 lines (38 loc) · 1.05 KB
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
#include "SymTableHelp.h"
SymTable* SymTableHelp::currentScope = NULL;
ofstream SymTableHelp::fisier;
string SymTableHelp::currentType = "";
void SymTableHelp:: Init() {
fisier.open("tables.txt");
EnterScope("GLOBAL");
}
void SymTableHelp::EnterScope(string name) {
currentScope = new SymTable(name, currentScope);
}
void SymTableHelp::ExitScope() {
if (currentScope) {
currentScope->print(fisier);
SymTable* c = currentScope;
currentScope = currentScope->getPred();
delete c;
}
}
void SymTableHelp::Clean() {
ExitScope();
fisier.close();
}
void SymTableHelp::SetType(string type) {
currentType = type;
}
void SymTableHelp::AddVar(string name, string kind) {
if (currentScope) {
currentScope->addVar(currentType, name, kind);
}
}
bool SymTableHelp::CheckId(string name) {
if (currentScope && currentScope->findId(name)) {
return true;
}
cout << "Eroare: variabila '" << name << "' nu e declarata" << endl;
return false;
}