blob: 57f217ece7eb80df5a5e6b2f3a7761fb57da4361 (
plain)
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
|
#include "semantic/semantic_analyzer.hpp"
SemanticAnalyzer::SemanticAnalyzer() : symobl_table(new SemanticTable), errors(std::vector<Error>), warnings(std::vector<Error>), current_function(nullptr), current_function_return_type(""), has_main_function(false) {}
bool SemanticAnalyzer::analyze(ASTNode* ast) {
this->symbol_table.enterScope("global")
this->visit(ast);
this->validateMainFunction();
if (has_main_function == false) {
//error
return false;
}
this->symbol_table.exitScope();
return true;
}
std::vector<Error> SemanticAnalyzer::getErrors() {
return this->errors;
}
std::vector<Error> SemanticAnalyzer::getWarnings() {
return this->warnings;
}
bool SemanticAnalyzer::hasErrors() {
return !this->errors.empty();
}
std::string SemanticAnalyzer::visit(ASTNode* ast) {
}
|