variable namespace, function declaration fixes

This commit is contained in:
ProgramSnail 2023-04-29 12:33:05 +03:00
parent c31b20fa24
commit f973f65b5b
17 changed files with 511 additions and 98 deletions

View file

@ -49,20 +49,15 @@ void PrintVisitor::Visit(Partition* node) {
void PrintVisitor::Visit(Namespace* node) {
out_ << "[Namespace] ";
if (node->name.has_value()) {
if (node->modifier.has_value()) {
switch (node->modifier.value()) {
case Namespace::Const:
out_ << "const ";
break;
case Namespace::Var:
out_ << "var ";
break;
}
} else {
// error
if (node->modifier.has_value()) {
switch (node->modifier.value()) {
case Namespace::Const:
out_ << "const ";
break;
case Namespace::Var:
out_ << "var ";
break;
}
Visit(&node->name.value());
}
Visit(&node->type);
out_ << "{\n";
@ -206,13 +201,6 @@ void PrintVisitor::Visit(FunctionDefinition* node) {
out_ << ' ';
Visit(&node->name);
out_ << "]";
if (!node->parameters.empty()) {
out_ << " (";
for (auto& parameter : node->parameters) {
Visit(parameter.get());
}
out_ << ')';
}
if (!node->arguments.empty()) {
out_ << " : (";
for (auto& argument : node->arguments) {