diff options
Diffstat (limited to 'boot/parser.yy')
| -rw-r--r-- | boot/parser.yy | 21 |
1 files changed, 19 insertions, 2 deletions
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 <std::vector<elna::boot::attribute>> attributes; %type <std::vector<std::string>> import_declaration; %type <std::vector<elna::boot::identifier>> required_identifiers optional_identifiers generic_parameters; +%type <std::unique_ptr<elna::boot::enumeration_type_expression::member_declaration>> enumeration_member; +%type <std::vector<elna::boot::enumeration_type_expression::member_declaration>> enumeration_members; %type <elna::boot::named_expression *> name_reference; %type <std::vector<elna::boot::import_declaration *>> import_declarations; %type <elna::boot::array_type_expression *> 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<boot::enumeration_type_expression::member_declaration>(std::move(*$1), nullptr); } + | identifier "=" expression + { + $$ = std::make_unique<boot::enumeration_type_expression::member_declaration>(std::move(*$1), + std::unique_ptr<boot::expression>($3)); + } generic_parameters: %empty {} | "#[" required_identifiers "]" { $$ = $2; } |
