From 2cfc45ff22cd9b6166de3cf963aceede21b358aa Mon Sep 17 00:00:00 2001 From: Cori Barker Date: Tue, 10 Feb 2026 21:58:23 +0000 Subject: Started the implementation of semantic_analyzer methods --- src/semantic/semantic_analyzer.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/semantic') 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), warnings(std::vector), 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 SemanticAnalyzer::getErrors() { + return this->errors; +} + +std::vector SemanticAnalyzer::getWarnings() { + return this->warnings; +} + +bool SemanticAnalyzer::hasErrors() { + return !this->errors.empty(); +} + +std::string SemanticAnalyzer::visit(ASTNode* ast) { + +} -- cgit v1.2.3