From 36440faa345bf842c348711325312c2b02e4cc23 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 9 Jul 2026 17:24:42 +0200 Subject: Merge program and unit AST types --- boot/ast.cc | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) (limited to 'boot/ast.cc') diff --git a/boot/ast.cc b/boot/ast.cc index 3599308..b6ce4b3 100644 --- a/boot/ast.cc +++ b/boot/ast.cc @@ -39,11 +39,6 @@ namespace elna::boot not_implemented(); } - void empty_visitor::visit(program *) - { - not_implemented(); - } - void empty_visitor::visit(type_declaration *) { not_implemented(); @@ -383,8 +378,14 @@ namespace elna::boot } record_type_expression::record_type_expression(const struct position position, - std::vector&& fields, std::optional base) - : node(position), fields(std::move(fields)), base(base) + std::vector&& fields) + : node(position), fields(std::move(fields)) + { + } + + record_type_expression::record_type_expression(const struct position position, + std::vector&& fields, std::string&& base) + : node(position), fields(std::move(fields)), base(std::make_optional(std::move(base))) { } @@ -493,7 +494,8 @@ namespace elna::boot return this; } - enumeration_type_expression::enumeration_type_expression(const struct position position, std::vector&& members) + enumeration_type_expression::enumeration_type_expression(const struct position position, + std::vector&& members) : node(position), members(members) { } @@ -510,13 +512,13 @@ namespace elna::boot procedure_declaration::procedure_declaration(const struct position position, identifier_definition identifier, procedure_type_expression *heading, block&& body) - : declaration(position, identifier), m_heading(heading), body(std::move(body)) + : declaration(position, identifier), m_heading(heading), body(std::make_optional(std::move(body))) { } procedure_declaration::procedure_declaration(const struct position position, identifier_definition identifier, procedure_type_expression *heading) - : declaration(position, identifier), m_heading(heading), body(std::nullopt) + : declaration(position, identifier), m_heading(heading) { } @@ -618,6 +620,11 @@ namespace elna::boot { } + unit::unit(const struct position position, std::vector&& body) + : node(position), body(std::make_optional>(std::move(body))) + { + } + void unit::accept(parser_visitor *visitor) { visitor->visit(this); @@ -647,24 +654,6 @@ namespace elna::boot } } - program::program(const struct position position) - : unit(position) - { - } - - void program::accept(parser_visitor *visitor) - { - visitor->visit(this); - } - - program::~program() - { - for (statement *body_statement : this->body) - { - delete body_statement; - } - } - literal_expression *literal_expression::is_literal() { return this; -- cgit v1.2.3