mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-07 07:28:44 +00:00
functions arguments and parameters are separated now
This commit is contained in:
parent
f7e985a448
commit
a11ddbd25f
8 changed files with 49 additions and 98 deletions
|
|
@ -905,26 +905,6 @@ void BuildVisitor::Visit(AccessExpression* node) {
|
|||
|
||||
// Other expressions
|
||||
|
||||
void BuildVisitor::Visit(FunctionArgument& node) {
|
||||
auto parse_node = current_node_;
|
||||
|
||||
current_node_ = parse_node.NthNamedChild(0);
|
||||
|
||||
std::string current_node_type = current_node_.GetType();
|
||||
|
||||
if (current_node_type == parser::tokens::SubExpressionToken) {
|
||||
node = SubExpressionToken();
|
||||
Visit(std::get<SubExpressionToken>(node));
|
||||
} else if (current_node_type == parser::tokens::TypeExpression) {
|
||||
node = std::make_unique<TypeExpression>();
|
||||
Visit(std::get<std::unique_ptr<TypeExpression>>(node).get());
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(FunctionCallExpression* node) {
|
||||
auto parse_node = current_node_;
|
||||
|
||||
|
|
@ -953,11 +933,24 @@ void BuildVisitor::Visit(FunctionCallExpression* node) {
|
|||
size_t child_count = parse_node.NamedChildCount();
|
||||
|
||||
if (child_count > excluded_child_count) { // always true (repeat1)
|
||||
bool parameters_ended = false;
|
||||
|
||||
node->arguments.resize(child_count - excluded_child_count);
|
||||
|
||||
for (size_t i = 0; i + excluded_child_count < child_count; ++i) {
|
||||
current_node_ = parse_node.NthNamedChild(i + excluded_child_count);
|
||||
Visit(node->arguments[i]);
|
||||
|
||||
if (current_node_.GetType() != parser::tokens::TypeExpression) {
|
||||
parameters_ended = true;
|
||||
}
|
||||
|
||||
if (!parameters_ended) {
|
||||
node->parameters.push_back(std::make_unique<TypeExpression>());
|
||||
Visit(node->parameters.back().get());
|
||||
} else {
|
||||
node->arguments.emplace_back();
|
||||
Visit(node->arguments.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue