aboutsummaryrefslogtreecommitdiff
path: root/boot/ast.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-09 17:24:42 +0200
committerEugen Wissner <belka@caraus.de>2026-07-09 17:24:42 +0200
commit36440faa345bf842c348711325312c2b02e4cc23 (patch)
treea7ec54ad2f948efc556f3a74b59064321ae581c9 /boot/ast.cc
parent8d8e771af944796eba10cfa9568d284daaab93a1 (diff)
downloadelna-36440faa345bf842c348711325312c2b02e4cc23.tar.gz
Merge program and unit AST types
Diffstat (limited to 'boot/ast.cc')
-rw-r--r--boot/ast.cc45
1 files changed, 17 insertions, 28 deletions
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<field_declaration>&& fields, std::optional<std::string> base)
- : node(position), fields(std::move(fields)), base(base)
+ std::vector<field_declaration>&& fields)
+ : node(position), fields(std::move(fields))
+ {
+ }
+
+ record_type_expression::record_type_expression(const struct position position,
+ std::vector<field_declaration>&& fields, std::string&& base)
+ : node(position), fields(std::move(fields)), base(std::make_optional<std::string>(std::move(base)))
{
}
@@ -493,7 +494,8 @@ namespace elna::boot
return this;
}
- enumeration_type_expression::enumeration_type_expression(const struct position position, std::vector<std::string>&& members)
+ enumeration_type_expression::enumeration_type_expression(const struct position position,
+ std::vector<std::string>&& 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<block>(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<statement *>&& body)
+ : node(position), body(std::make_optional<std::vector<statement *>>(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;