From 12e304fd56f054ba7296ab538eecd4280a67832a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 7 Oct 2026 17:33:40 +0200 Subject: Allow assigning contants to enumeration members --- boot/parser.yy | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index 04c07a8..e8c3590 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -162,6 +162,8 @@ along with GCC; see the file COPYING3. If not see %type > attributes; %type > import_declaration; %type > required_identifiers optional_identifiers generic_parameters; +%type > enumeration_member; +%type > enumeration_members; %type name_reference; %type > import_declarations; %type array_type_expression; @@ -679,9 +681,24 @@ type_expression: } | "proc" procedure_heading { $$ = $2; } - | "(" required_identifiers ")" - { $$ = new boot::enumeration_type_expression(boot::make_position(@$), $2); } + | "(" enumeration_members ")" + { $$ = new boot::enumeration_type_expression(boot::make_position(@$), std::move($2)); } | name_reference { $$ = $1; } +enumeration_members: + enumeration_member "," enumeration_members + { + $$ = std::move($3); + $$.emplace($$.cbegin(), std::move(*$1)); + } + | enumeration_member { $$.emplace_back(std::move(*$1)); } +enumeration_member: + identifier + { $$ = std::make_unique(std::move(*$1), nullptr); } + | identifier "=" expression + { + $$ = std::make_unique(std::move(*$1), + std::unique_ptr($3)); + } generic_parameters: %empty {} | "#[" required_identifiers "]" { $$ = $2; } -- cgit v1.2.3