Support while … else

This commit is contained in:
2025-04-13 18:40:49 +02:00
parent 8ec407515a
commit 1cd44508c3
6 changed files with 145 additions and 135 deletions

View File

@ -77,10 +77,12 @@ namespace elna::boot
{
for (type_definition *const type : program->types)
{
if (!this->unresolved.insert({ type->identifier, std::make_shared<alias_type>(type->identifier) }).second
|| this->symbols->contains(type->identifier))
const std::string& type_identifier = type->identifier.identifier;
if (!this->unresolved.insert({ type_identifier, std::make_shared<alias_type>(type_identifier) }).second
|| this->symbols->contains(type_identifier))
{
add_error<already_declared_error>(type->identifier, this->input_file, type->position());
add_error<already_declared_error>(type->identifier.identifier, this->input_file, type->position());
}
}
for (type_definition *const type : program->types)
@ -109,7 +111,7 @@ namespace elna::boot
void declaration_visitor::visit(type_definition *definition)
{
definition->body().accept(this);
auto unresolved_declaration = this->unresolved.at(definition->identifier);
auto unresolved_declaration = this->unresolved.at(definition->identifier.identifier);
unresolved_declaration->reference = this->current_type;
}
@ -193,7 +195,8 @@ namespace elna::boot
{
definition->body().accept(this);
this->symbols->enter(definition->identifier, std::make_shared<constant_info>(this->current_literal));
this->symbols->enter(definition->identifier.identifier,
std::make_shared<constant_info>(this->current_literal));
}
void declaration_visitor::visit(procedure_definition *definition)
@ -201,7 +204,7 @@ namespace elna::boot
std::shared_ptr<procedure_info> info = std::make_shared<procedure_info>(
build_procedure(definition->heading()), definition->parameter_names);
this->symbols->enter(definition->identifier, info);
this->symbols->enter(definition->identifier.identifier, info);
if (definition->body != nullptr)
{
definition->body->accept(this);