From 8ceb48a4e60b8ff89f28372da4f66cd152e2e0fe Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 13 Jul 2026 23:59:36 +0200 Subject: Change record constructor syntax --- boot/parser.yy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index f1bf915..ae2e5a8 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -81,6 +81,7 @@ along with GCC; see the file COPYING3. If not see %token STRING %token BOOLEAN %token LEFT_PAREN "(" RIGHT_PAREN ")" LEFT_SQUARE "[" RIGHT_SQUARE "]" +%token LEFT_BRACE "{" RIGHT_BRACE "}" %token ASSIGNMENT ":=" EXCLAMATION "!" AT "@" HAT "^" @@ -148,6 +149,8 @@ along with GCC; see the file COPYING3. If not see %type > procedure_body; %type field_declaration; %type > optional_fields required_fields; +%type field_initializer; +%type > field_initializers; %type > elsif_then_statements elsif_do_statements; %type *> else_statements; %type cast_expression; @@ -258,6 +261,10 @@ simple_expression: | cast_expression { $$ = $1; } | call_expression { $$ = $1; } | "(" expression ")" { $$ = $2; } + | IDENTIFIER "{" field_initializers "}" + { + $$ = new boot::record_constructor_expression(boot::make_position(@1), std::move($1), std::move($3)); + } operand: unary_expression { $$ = $1; } | simple_expression { $$ = $1; } @@ -421,6 +428,15 @@ required_fields: optional_fields: required_fields { std::swap($$, $1); } | /* no fields */ {} +field_initializer: + IDENTIFIER ":" expression { $$.name = std::move($1); $$.value = $3; } +field_initializers: + field_initializer "," field_initializers + { + std::swap($$, $3); + $$.emplace($$.cbegin(), $1); + } + | field_initializer { $$.push_back($1); } type_expression: "[" INTEGER "]" type_expression { -- cgit v1.2.3