aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCori Barker <coribarker2@gmail.com>2026-02-10 21:58:23 +0000
committerCori Barker <coribarker2@gmail.com>2026-02-10 21:58:23 +0000
commit2cfc45ff22cd9b6166de3cf963aceede21b358aa (patch)
tree492510b80bc47af3c757d447989b975b911f8b67 /src
parent7a9df4dd91d0bb8a00325adc2c48fe7c7c5c6ce4 (diff)
Started the implementation of semantic_analyzer methods
Diffstat (limited to 'src')
-rw-r--r--src/semantic/semantic_analyzer.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/semantic/semantic_analyzer.cpp b/src/semantic/semantic_analyzer.cpp
index e69de29..57f217e 100644
--- a/src/semantic/semantic_analyzer.cpp
+++ b/src/semantic/semantic_analyzer.cpp
@@ -0,0 +1,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) {
+
+}