From fb8d8f9f5bb4a1f7736d927a346d4bf834a28ffa Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Fri, 18 Apr 2025 17:25:48 +0000
Subject: [PATCH] add if else statements

---
 src/Parser/Parser.hpp |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/Parser/Parser.hpp b/src/Parser/Parser.hpp
index 0eb1180..d2c826c 100644
--- a/src/Parser/Parser.hpp
+++ b/src/Parser/Parser.hpp
@@ -6,6 +6,7 @@
 #include <vector>
 
 #include "BaseException.hpp"
+#include "Interpreter/StatementNode.hpp"
 #include "Lexer/Token.hpp"
 #include "Lexer/TokenType.hpp"
 #include "Parser/ParsedExpression.hpp"
@@ -169,6 +170,11 @@
     // parseStatement (updated to handle return)
     void parseStatement() {
         const auto & token_type = currentToken().type;
+        // if-else conditional
+        if (token_type == Lexer::Tokens::Type::KEYWORD && currentToken().value == "if") {
+            parseIfStatement();
+            return;
+        }
 
         if (token_type == Lexer::Tokens::Type::KEYWORD_FUNCTION_DECLARATION) {
             parseFunctionDefinition();
@@ -201,6 +207,10 @@
     void parseCallStatement();
     // Parse a return statement (e.g., return; or return expr;)
     void parseReturnStatement();
+    // Parse an if-else conditional statement
+    void parseIfStatement();
+    // Parse a statement node for use inside blocks (not added to operation container)
+    std::unique_ptr<Interpreter::StatementNode> parseStatementNode();
 
     // --- Parsing helper functions ---
 

--
Gitblit v1.9.3