aboutsummaryrefslogtreecommitdiff
path: root/boot/parser.yy
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-10-08 01:46:45 +0200
committerEugen Wissner <belka@caraus.de>2026-10-08 01:46:45 +0200
commitd392f0c54a7748b816ab327758ae835f73cd1c0a (patch)
treea7c029dffab842acbd4f5f0cab5685a93e9b9747 /boot/parser.yy
parentd4b7f5e52a33f2d15aafca7f1b040f3f2821fd0c (diff)
downloadelna-d392f0c54a7748b816ab327758ae835f73cd1c0a.tar.gz
Allow initialized declarations without an explicit type
Diffstat (limited to 'boot/parser.yy')
-rw-r--r--boot/parser.yy17
1 files changed, 11 insertions, 6 deletions
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<boot::type_expression> 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<boot::type_expression> 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<boot::type_expression> 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 {}