From c266728ff0934762218f7856d8ad227b076a1b7e Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Sun, 28 Dec 2025 13:49:05 +1100 Subject: [PATCH] make function calling better --- src/parser.cpp | 13 +++++++++++++ tests/function.sols | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/parser.cpp b/src/parser.cpp index 68cfac8..5415798 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -143,6 +143,8 @@ namespace Solstice { void SolNode::setValue(SolData in) { data = in; } + + std::string currentFunctionRetType = ""; const std::vector SolNode::generateCode() { std::vector code; @@ -1190,6 +1192,7 @@ namespace Solstice { break; } case SolNodeType::BracketStart: { + // function call if (rootNode.children.back().nodeType == SolNodeType::Identifier) { SolNode fnCallNode(SolNodeType::FunctionCall); fnCallNode.line = tokenObj.line; @@ -1205,6 +1208,16 @@ namespace Solstice { if (tokenopt.value().value == ")") { brackets--; } + // comma, eval statement here + if (tokenopt.value().value == "," && brackets == 1) { + auto node = Parser(tokens).parse(); + if (!node.children.empty()) fnCallNode.children.push_back(node.children[0]); + else { + Error::syntaxError("dingus"); + } + tokens.clear(); + continue; + } if (brackets < 1) { break; } diff --git a/tests/function.sols b/tests/function.sols index 762a27f..53c906f 100644 --- a/tests/function.sols +++ b/tests/function.sols @@ -3,4 +3,4 @@ def add(int a, int b) int { return 3 } -puts add(1 2) +puts add(1, 2)