diff options
Diffstat (limited to 'boot/parser.yy')
| -rw-r--r-- | boot/parser.yy | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/boot/parser.yy b/boot/parser.yy index f97d545..9c9e728 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -146,8 +146,8 @@ along with GCC; see the file COPYING3. If not see %type <std::unique_ptr<elna::boot::procedure_type_expression>> procedure_heading; %type <elna::boot::procedure_type_expression::return_t> return_declaration; %type <std::vector<elna::boot::procedure_declaration *>> procedure_part; -%type <elna::boot::type_declaration *> type_declaration; -%type <std::vector<elna::boot::type_declaration *>> type_declarations type_part; +%type <std::unique_ptr<elna::boot::type_declaration>> type_declaration; +%type <std::vector<elna::boot::declaration *>> type_declarations type_part; %type <std::unique_ptr<elna::boot::procedure_body>> procedure_body; %type <elna::boot::field_declaration> field_declaration; %type <std::vector<elna::boot::field_declaration>> field_declarations; @@ -171,15 +171,30 @@ program: { driver.finished = true; - boot::unit *tree = new boot::unit(boot::make_position(@$), $1, $2, $3, $4); + std::vector<boot::declaration *> declarations = $2; + std::vector<boot::variable_declaration *> variables = $3; + declarations.insert(declarations.end(), + std::make_move_iterator(variables.begin()), std::make_move_iterator(variables.end())); + std::vector<boot::procedure_declaration *> appendix = $4; + declarations.insert(declarations.end(), + std::make_move_iterator(appendix.begin()), std::make_move_iterator(appendix.end())); + + boot::unit *tree = new boot::unit(boot::make_position(@$), $1, std::move(declarations)); driver.tree.reset(tree); } | import_part type_part variable_part procedure_part "program" "(" optional_identifiers ")" procedure_body "end" "." { driver.finished = true; + std::vector<boot::declaration *> declarations = $2; + std::vector<boot::variable_declaration *> variables = $3; + declarations.insert(declarations.end(), + std::make_move_iterator(variables.begin()), std::make_move_iterator(variables.end())); + std::vector<boot::procedure_declaration *> appendix = $4; + declarations.insert(declarations.end(), + std::make_move_iterator(appendix.begin()), std::make_move_iterator(appendix.end())); - boot::unit *tree = new boot::unit(boot::make_position(@$), $1, $2, $3, $4, + boot::unit *tree = new boot::unit(boot::make_position(@$), $1, std::move(declarations), std::move($7), boot::make_position(@5), std::move(*$9)); driver.tree.reset(tree); } @@ -706,12 +721,12 @@ import_part: | "import" import_declarations { $$ = $2; } type_declaration: identifier_definition generic_parameters "=" type_expression { - $$ = new boot::type_declaration(boot::make_position(@$), std::move(*$1), $4); + $$ = std::make_unique<boot::type_declaration>(boot::make_position(@$), std::move(*$1), $4); $$->parameters = $2; } | identifier_definition generic_parameters "=" "extern" { - $$ = new boot::type_declaration(boot::make_position(@$), std::move(*$1), + $$ = std::make_unique<boot::type_declaration>(boot::make_position(@$), std::move(*$1), new boot::extern_type_expression(boot::make_position(@$))); $$->parameters = $2; } @@ -719,7 +734,7 @@ type_declarations: type_declaration type_declarations { $$ = $2; - $$.insert($$.cbegin(), $1); + $$.insert($$.cbegin(), $1.release()); } | %empty {} type_part: |
