make function calling better

This commit is contained in:
2025-12-28 13:49:05 +11:00
parent b46a66cea7
commit c266728ff0
2 changed files with 14 additions and 1 deletions

View File

@@ -143,6 +143,8 @@ namespace Solstice {
void SolNode::setValue(SolData in) {
data = in;
}
std::string currentFunctionRetType = "";
const std::vector<SolGroundCodeBlock> SolNode::generateCode() {
std::vector<SolGroundCodeBlock> 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;
}

View File

@@ -3,4 +3,4 @@ def add(int a, int b) int {
return 3
}
puts add(1 2)
puts add(1, 2)