From d392f0c54a7748b816ab327758ae835f73cd1c0a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 8 Oct 2026 01:46:45 +0200 Subject: Allow initialized declarations without an explicit type --- boot/parser.yy | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index f416d57..cfa63d5 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -711,18 +711,23 @@ optional_identifiers: variable_declaration: identifier_definitions ":" type_expression { - std::shared_ptr shared_type{ $3 }; - $$ = new boot::variable_declaration( boot::make_position(@$), $1, shared_type); + $$ = new boot::variable_declaration(boot::make_position(@$), $1, $3); } | identifier_definitions ":" type_expression ":=" "extern" { - std::shared_ptr shared_type{ $3 }; - $$ = new boot::variable_declaration( boot::make_position(@$), $1, shared_type, std::monostate{}); + $$ = new boot::variable_declaration(boot::make_position(@$), $1, $3, std::monostate{}); } | identifier_definitions ":" type_expression ":=" expression { - std::shared_ptr shared_type{ $3 }; - $$ = new boot::variable_declaration( boot::make_position(@$), $1, shared_type, $5); + $$ = new boot::variable_declaration(boot::make_position(@$), $1, $3, $5); + } + | identifier_definitions ":=" expression + { + $$ = new boot::variable_declaration(boot::make_position(@$), $1, nullptr, $3); + } + | identifier_definitions ":" "const" ":=" expression + { + $$ = new boot::variable_declaration(boot::make_position(@$), $1, nullptr, $5, true); } variable_declarations: %empty {} -- cgit v1.2.3