From a5d033df465ca8de8457926cc64aacf38c6ae848 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 13 Sep 2026 16:07:11 +0200 Subject: Visit nested statements in validation visitor --- boot/parser.yy | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index f97d545..9c9e728 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -146,8 +146,8 @@ along with GCC; see the file COPYING3. If not see %type > procedure_heading; %type return_declaration; %type > procedure_part; -%type type_declaration; -%type > type_declarations type_part; +%type > type_declaration; +%type > type_declarations type_part; %type > procedure_body; %type field_declaration; %type > field_declarations; @@ -171,15 +171,30 @@ program: { driver.finished = true; - boot::unit *tree = new boot::unit(boot::make_position(@$), $1, $2, $3, $4); + std::vector declarations = $2; + std::vector variables = $3; + declarations.insert(declarations.end(), + std::make_move_iterator(variables.begin()), std::make_move_iterator(variables.end())); + std::vector appendix = $4; + declarations.insert(declarations.end(), + std::make_move_iterator(appendix.begin()), std::make_move_iterator(appendix.end())); + + boot::unit *tree = new boot::unit(boot::make_position(@$), $1, std::move(declarations)); driver.tree.reset(tree); } | import_part type_part variable_part procedure_part "program" "(" optional_identifiers ")" procedure_body "end" "." { driver.finished = true; + std::vector declarations = $2; + std::vector variables = $3; + declarations.insert(declarations.end(), + std::make_move_iterator(variables.begin()), std::make_move_iterator(variables.end())); + std::vector appendix = $4; + declarations.insert(declarations.end(), + std::make_move_iterator(appendix.begin()), std::make_move_iterator(appendix.end())); - boot::unit *tree = new boot::unit(boot::make_position(@$), $1, $2, $3, $4, + boot::unit *tree = new boot::unit(boot::make_position(@$), $1, std::move(declarations), std::move($7), boot::make_position(@5), std::move(*$9)); driver.tree.reset(tree); } @@ -706,12 +721,12 @@ import_part: | "import" import_declarations { $$ = $2; } type_declaration: identifier_definition generic_parameters "=" type_expression { - $$ = new boot::type_declaration(boot::make_position(@$), std::move(*$1), $4); + $$ = std::make_unique(boot::make_position(@$), std::move(*$1), $4); $$->parameters = $2; } | identifier_definition generic_parameters "=" "extern" { - $$ = new boot::type_declaration(boot::make_position(@$), std::move(*$1), + $$ = std::make_unique(boot::make_position(@$), std::move(*$1), new boot::extern_type_expression(boot::make_position(@$))); $$->parameters = $2; } @@ -719,7 +734,7 @@ type_declarations: type_declaration type_declarations { $$ = $2; - $$.insert($$.cbegin(), $1); + $$.insert($$.cbegin(), $1.release()); } | %empty {} type_part: -- cgit v1.2.3