bl-compiler

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 2cfc45ff22cd9b6166de3cf963aceede21b358aa
parent 7a9df4dd91d0bb8a00325adc2c48fe7c7c5c6ce4
Author: Cori Barker <coribarker2@gmail.com>
Date:   Tue, 10 Feb 2026 21:58:23 +0000

Started the implementation of semantic_analyzer methods

Diffstat:
Msrc/semantic/semantic_analyzer.cpp | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git 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) { + +}