diff options
Diffstat (limited to 'boot/parser.yy')
| -rw-r--r-- | boot/parser.yy | 16 |
1 files changed, 16 insertions, 0 deletions
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 <std::string> STRING %token <bool> 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 <std::unique_ptr<elna::boot::procedure_body>> procedure_body; %type <elna::boot::field_declaration> field_declaration; %type <std::vector<elna::boot::field_declaration>> optional_fields required_fields; +%type <elna::boot::field_initializer> field_initializer; +%type <std::vector<elna::boot::field_initializer>> field_initializers; %type <std::vector<elna::boot::conditional_statements *>> elsif_then_statements elsif_do_statements; %type <std::vector<elna::boot::statement *> *> else_statements; %type <elna::boot::cast_expression *> 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 { |
