aboutsummaryrefslogtreecommitdiff
path: root/boot/parser.yy
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-10 17:06:21 +0200
committerEugen Wissner <belka@caraus.de>2026-07-10 17:06:21 +0200
commitb7dd49c1d5832ac7d82edba27316884ab53e614c (patch)
tree24afc27b83974c9322088e5469d2d1894c0eb314 /boot/parser.yy
parent36440faa345bf842c348711325312c2b02e4cc23 (diff)
downloadelna-b7dd49c1d5832ac7d82edba27316884ab53e614c.tar.gz
Report if the base type of a record is not a record
Diffstat (limited to 'boot/parser.yy')
-rw-r--r--boot/parser.yy25
1 files changed, 13 insertions, 12 deletions
diff --git a/boot/parser.yy b/boot/parser.yy
index 42840ff..6ada702 100644
--- a/boot/parser.yy
+++ b/boot/parser.yy
@@ -148,7 +148,7 @@ along with GCC; see the file COPYING3. If not see
%type <std::vector<elna::boot::procedure_declaration *>> procedure_part;
%type <elna::boot::type_declaration *> type_declaration;
%type <std::vector<elna::boot::type_declaration *>> type_declarations type_part;
-%type <std::unique_ptr<elna::boot::block>> block;
+%type <std::unique_ptr<elna::boot::procedure_body>> procedure_body;
%type <elna::boot::field_declaration> field_declaration;
%type <std::vector<elna::boot::field_declaration>> optional_fields required_fields;
%type <std::vector<elna::boot::conditional_statements *>> elsif_then_statements elsif_do_statements;
@@ -162,32 +162,33 @@ along with GCC; see the file COPYING3. If not see
program:
import_part constant_part type_part variable_part procedure_part statement_part "end" "."
{
+ boot::unit *tree;
if ($6)
{
- boot::unit *tree = new boot::unit(boot::make_position(@1));
- tree->body = std::make_optional<std::vector<boot::statement *>>(std::move(*$6.release()));
-
- driver.tree.reset(tree);
+ tree = new boot::unit(boot::make_position(@1),
+ std::move(*$6.release()));
}
else
{
- driver.tree.reset(new boot::unit(boot::make_position(@1)));
+ tree = new boot::unit(boot::make_position(@1));
}
+ driver.tree.reset(tree);
+
std::swap(driver.tree->imports, $1);
std::swap(driver.tree->constants, $2);
std::swap(driver.tree->types , $3);
std::swap(driver.tree->variables, $4);
std::swap(driver.tree->procedures, $5);
}
-block: constant_part variable_part statement_part "end"
+procedure_body: constant_part variable_part statement_part "end"
{
if ($3)
{
- $$ = std::make_unique<boot::block>(std::move($1), std::move($2), std::move(*$3.release()));
+ $$ = std::make_unique<boot::procedure_body>(std::move($1), std::move($2), std::move(*$3.release()));
}
else
{
- $$ = std::make_unique<boot::block>(std::move($1), std::move($2));
+ $$ = std::make_unique<boot::procedure_body>(std::move($1), std::move($2));
}
}
statement_part:
@@ -221,7 +222,7 @@ procedure_heading: "(" optional_fields ")" return_declaration
$$ = new boot::procedure_type_expression(boot::make_position(@1), std::move($2), std::move($4));
}
procedure_declaration:
- "proc" identifier_definition procedure_heading block
+ "proc" identifier_definition procedure_heading procedure_body
{
$$ = new boot::procedure_declaration(boot::make_position(@1), std::move($2), $3,
std::move(*$4));
@@ -251,7 +252,7 @@ elsif_do_statements:
std::swap($5, $$);
$$.emplace($$.begin(), branch);
}
- | {}
+ | /* no branches */ {}
else_statements:
"else" statements { $$ = new std::vector<boot::statement *>(std::move($2)); }
| { $$ = nullptr; }
@@ -262,7 +263,7 @@ elsif_then_statements:
std::swap($5, $$);
$$.emplace($$.begin(), branch);
}
- | {}
+ | /* no branches */ {}
return_statement: "return" expression
{ $$ = new boot::return_statement(boot::make_position(@1), $2); }
literal: