mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-06 23:18:44 +00:00
build_visitor first iteration
This commit is contained in:
parent
622b86f6c6
commit
582ad5668e
5 changed files with 338 additions and 116 deletions
|
|
@ -516,12 +516,14 @@ void PrintVisitor::Visit(TypeConstructor* node) {
|
|||
|
||||
void PrintVisitor::Visit(TupleType* node) {
|
||||
out_ << "<TupleType> ";
|
||||
Visit(&node->type); // optional
|
||||
if (node->type.has_value()) {
|
||||
Visit(&node->type.value()); // optional
|
||||
}
|
||||
out_ << ' ';
|
||||
for (auto& entity : node->entities) {
|
||||
out_ << "& ";
|
||||
if (entity.first != "") {
|
||||
Visit(&entity.first);
|
||||
if (entity.first.has_value()) {
|
||||
Visit(&entity.first.value());
|
||||
out_ << " : ";
|
||||
}
|
||||
Visitor::Visit(entity.second);
|
||||
|
|
@ -531,12 +533,19 @@ void PrintVisitor::Visit(TupleType* node) {
|
|||
|
||||
void PrintVisitor::Visit(VariantType* node) {
|
||||
out_ << "<VariantType> ";
|
||||
Visit(&node->type); // optional
|
||||
if (node->type.has_value()) {
|
||||
Visit(&node->type.value());
|
||||
}
|
||||
out_ << ' ';
|
||||
for (auto& constructor : node->constructors) {
|
||||
out_ << "| ";
|
||||
Visit(&constructor.first);
|
||||
Visit(constructor.second.get());
|
||||
if (std::holds_alternative<TypeIdentifierDefinition>(constructor)) {
|
||||
Visit(&std::get<TypeIdentifierDefinition>(constructor));
|
||||
} else if (std::holds_alternative<std::unique_ptr<TupleType>>(constructor)) {
|
||||
Visit(std::get<std::unique_ptr<TupleType>>(constructor).get());
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
}
|
||||
out_ << "</VariantType>";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue