mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-10 00:48:44 +00:00
partition syntax changed, interface modifier added
This commit is contained in:
parent
3fca384446
commit
b1aff1935d
22 changed files with 299 additions and 266 deletions
|
|
@ -15,32 +15,6 @@ void PrintVisitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void PrintVisitor::Visit(PartitionSources* node) {
|
||||
out_ << "[PartitionSources](\n";
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(Partition* node) {
|
||||
out_ << "[Partition] ";
|
||||
switch (node->name) {
|
||||
case Partition::Test:
|
||||
out_ << "TEST";
|
||||
break;
|
||||
case Partition::Interface:
|
||||
out_ << "INTERFACE";
|
||||
break;
|
||||
case Partition::Code:
|
||||
out_ << "CODE";
|
||||
break;
|
||||
}
|
||||
out_ << " {\n";
|
||||
Visit(&node->scope);
|
||||
out_ << "}\n";
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(NamespaceSources* node) {
|
||||
out_ << "[NamespaceSources](\n";
|
||||
for (auto& statement : node->statements) {
|
||||
|
|
@ -124,6 +98,9 @@ void PrintVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
|
||||
void PrintVisitor::Visit(FunctionDeclaration* node) {
|
||||
out_ << "[FunctionDeclaration ";
|
||||
if (node->is_in_interface) {
|
||||
out_ << "interface ";
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << "] (";
|
||||
for (auto& parameter : node->parameters) {
|
||||
|
|
@ -152,6 +129,9 @@ void PrintVisitor::Visit(TypeDefinitionStatement* node) {
|
|||
out_ << "class";
|
||||
break;
|
||||
}
|
||||
if (node->is_in_interface) {
|
||||
out_ << " interface";
|
||||
}
|
||||
out_ << "] (";
|
||||
Visit(node->definition.get());
|
||||
out_ << ") = (";
|
||||
|
|
@ -188,6 +168,22 @@ void PrintVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
out_ << ")\n";
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(PartitionStatement* node) {
|
||||
out_ << "[Partition ";
|
||||
switch (node->modifier) {
|
||||
case utils::PartitionModifier::Exec:
|
||||
out_ << "exec ";
|
||||
break;
|
||||
case utils::PartitionModifier::Test:
|
||||
out_ << "test ";
|
||||
break;
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << "] = (";
|
||||
Visitor::Visit(node->value);
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
||||
void PrintVisitor::Visit(FunctionDefinition* node) {
|
||||
|
|
@ -556,6 +552,16 @@ void PrintVisitor::Visit(ArrayExpression* node) {
|
|||
|
||||
// Name
|
||||
|
||||
void PrintVisitor::Visit(PartitionName* node) {
|
||||
out_ << "[PartitionName] (";
|
||||
for (auto& path_namespace : node->path) {
|
||||
Visit(&path_namespace);
|
||||
out_ << "::";
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << ')';
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(NameExpression* node) {
|
||||
out_ << "[NameExpression] (";
|
||||
for (size_t i = 0; i < node->names.size(); ++i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue