forked from solstice/solstice
make function calling better
This commit is contained in:
@@ -144,6 +144,8 @@ namespace Solstice {
|
||||
data = in;
|
||||
}
|
||||
|
||||
std::string currentFunctionRetType = "";
|
||||
|
||||
const std::vector<SolGroundCodeBlock> SolNode::generateCode() {
|
||||
std::vector<SolGroundCodeBlock> code;
|
||||
if (nodeType != SolNodeType::If && nodeType != SolNodeType::While) for (auto& child : children) {
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ def add(int a, int b) int {
|
||||
return 3
|
||||
}
|
||||
|
||||
puts add(1 2)
|
||||
puts add(1, 2)
|
||||
|
||||
Reference in New Issue
Block a user