mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-06 06:58:45 +00:00
variable namespace, function declaration fixes
This commit is contained in:
parent
c31b20fa24
commit
f973f65b5b
17 changed files with 511 additions and 98 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue