From b2dee14873402ee3d13d59ae5579593796ea862f Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 5 Aug 2026 01:03:55 +0200 Subject: Check that constants are initialized --- boot/parser.yy | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index bc0cb53..a28b6cb 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -135,11 +135,11 @@ along with GCC; see the file COPYING3. If not see %type binary_expression; %type > expressions actual_parameter_list; %type designator_expression; -%type call_expression; +%type > call_expression; %type statement; %type > statements statement_part; %type procedure_declaration; -%type procedure_heading; +%type > procedure_heading; %type return_declaration; %type > procedure_part; %type type_declaration; @@ -157,6 +157,7 @@ along with GCC; see the file COPYING3. If not see %type > import_declaration; %type > identifiers; %type > import_declarations import_part; +%type > array_type_expression; %% program: import_part type_part variable_part procedure_part statement_part "end" "." @@ -188,15 +189,16 @@ return_declaration: | ":" "!" { $$ = boot::procedure_type_expression::return_t(std::monostate{}); } | ":" type_expression { $$ = boot::procedure_type_expression::return_t($2); } procedure_heading: "(" optional_fields ")" return_declaration - { $$ = new boot::procedure_type_expression(boot::make_position(@$), $2, $4); } + { $$ = std::make_unique(boot::make_position(@$), $2, $4); } procedure_declaration: "proc" identifier_definition procedure_heading procedure_body { - $$ = new boot::procedure_declaration(boot::make_position(@$), std::move(*$2), $3, std::move(*$4)); + $$ = new boot::procedure_declaration(boot::make_position(@$), + std::move(*$2), $3.release(), std::move(*$4)); } | "proc" identifier_definition procedure_heading "extern" { - $$ = new boot::procedure_declaration(boot::make_position(@$), std::move(*$2), $3); + $$ = new boot::procedure_declaration(boot::make_position(@$), std::move(*$2), $3.release()); } procedure_part: %empty {} @@ -207,7 +209,7 @@ procedure_part: } call_expression: designator_expression actual_parameter_list { - $$ = new boot::procedure_call(boot::make_position(@$), $1, $2); + $$ = std::make_unique(boot::make_position(@$), $1, $2); } with_counter: "with" identifier { $$ = $2; } @@ -254,15 +256,15 @@ simple_expression: { $$ = new boot::cast_expression(boot::make_position(@$), $5, $3); } - | call_expression { $$ = $1; } + | call_expression { $$ = $1.release(); } | "(" expression ")" { $$ = $2; } | identifier "{" field_initializers "}" { $$ = new boot::record_constructor_expression(boot::make_position(@$), std::move(*$1), $3); } - | "[" INTEGER "]" type_expression "{" expressions "}" + | array_type_expression "{" expressions "}" { - $$ = new boot::array_constructor_expression(boot::make_position(@$), $2, $4, $6); + $$ = new boot::array_constructor_expression(boot::make_position(@$), $1.release(), $3); } operand: unary_expression { $$ = $1; } @@ -399,7 +401,7 @@ statement: boot::conditional_statements *then = new boot::conditional_statements($2, $4); $$ = new boot::if_statement(boot::make_position(@$), then, $5, $6); } - | call_expression { $$ = $1; } + | call_expression { $$ = $1.release(); } | "defer" statements "end" { $$ = new boot::defer_statement(boot::make_position(@$), $2); } | "case" expression "of" switch_cases else_statements "end" @@ -449,11 +451,10 @@ field_initializers: $$.emplace($$.cbegin(), std::move(*$1)); } | field_initializer { $$.push_back(std::move(*$1)); } +array_type_expression: "[" expression "]" type_expression + { $$ = std::make_unique(boot::make_position(@$), $4, $2); } type_expression: - "[" INTEGER "]" type_expression - { - $$ = new boot::array_type_expression(boot::make_position(@$), $4, $2); - } + array_type_expression { $$ = $1.release(); } | "[" "]" type_expression { $$ = new boot::slice_type_expression(boot::make_position(@$), $3); @@ -476,7 +477,7 @@ type_expression: } | "proc" procedure_heading { - $$ = $2; + $$ = $2.release(); } | "(" identifiers ")" { -- cgit v1.2.3