From b7dd49c1d5832ac7d82edba27316884ab53e614c Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 10 Jul 2026 17:06:21 +0200 Subject: Report if the base type of a record is not a record --- boot/parser.yy | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'boot/parser.yy') 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 > procedure_part; %type type_declaration; %type > type_declarations type_part; -%type > block; +%type > procedure_body; %type field_declaration; %type > optional_fields required_fields; %type > 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::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(std::move($1), std::move($2), std::move(*$3.release())); + $$ = std::make_unique(std::move($1), std::move($2), std::move(*$3.release())); } else { - $$ = std::make_unique(std::move($1), std::move($2)); + $$ = std::make_unique(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(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: -- cgit v1.2.3