aboutsummaryrefslogtreecommitdiff
path: root/boot/parser.yy
diff options
context:
space:
mode:
Diffstat (limited to 'boot/parser.yy')
-rw-r--r--boot/parser.yy31
1 files changed, 16 insertions, 15 deletions
diff --git a/boot/parser.yy b/boot/parser.yy
index bc0cb53..a28b6cb 100644
--- a/boot/parser.yy
+++ b/boot/parser.yy
@@ -135,11 +135,11 @@ along with GCC; see the file COPYING3. If not see
%type <elna::boot::binary_expression *> binary_expression;
%type <std::vector<elna::boot::expression *>> expressions actual_parameter_list;
%type <elna::boot::designator_expression *> designator_expression;
-%type <elna::boot::procedure_call*> call_expression;
+%type <std::unique_ptr<elna::boot::procedure_call>> call_expression;
%type <elna::boot::statement *> statement;
%type <std::vector<elna::boot::statement *>> statements statement_part;
%type <elna::boot::procedure_declaration *> procedure_declaration;
-%type <elna::boot::procedure_type_expression *> procedure_heading;
+%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;
@@ -157,6 +157,7 @@ along with GCC; see the file COPYING3. If not see
%type <std::vector<std::string>> import_declaration;
%type <std::vector<elna::boot::identifier>> identifiers;
%type <std::vector<elna::boot::import_declaration *>> import_declarations import_part;
+%type <std::unique_ptr<elna::boot::array_type_expression>> array_type_expression;
%%
program:
import_part type_part variable_part procedure_part statement_part "end" "."
@@ -188,15 +189,16 @@ return_declaration:
| ":" "!" { $$ = boot::procedure_type_expression::return_t(std::monostate{}); }
| ":" type_expression { $$ = boot::procedure_type_expression::return_t($2); }
procedure_heading: "(" optional_fields ")" return_declaration
- { $$ = new boot::procedure_type_expression(boot::make_position(@$), $2, $4); }
+ { $$ = std::make_unique<boot::procedure_type_expression>(boot::make_position(@$), $2, $4); }
procedure_declaration:
"proc" identifier_definition procedure_heading procedure_body
{
- $$ = new boot::procedure_declaration(boot::make_position(@$), std::move(*$2), $3, std::move(*$4));
+ $$ = new boot::procedure_declaration(boot::make_position(@$),
+ std::move(*$2), $3.release(), std::move(*$4));
}
| "proc" identifier_definition procedure_heading "extern"
{
- $$ = new boot::procedure_declaration(boot::make_position(@$), std::move(*$2), $3);
+ $$ = new boot::procedure_declaration(boot::make_position(@$), std::move(*$2), $3.release());
}
procedure_part:
%empty {}
@@ -207,7 +209,7 @@ procedure_part:
}
call_expression: designator_expression actual_parameter_list
{
- $$ = new boot::procedure_call(boot::make_position(@$), $1, $2);
+ $$ = std::make_unique<boot::procedure_call>(boot::make_position(@$), $1, $2);
}
with_counter:
"with" identifier { $$ = $2; }
@@ -254,15 +256,15 @@ simple_expression:
{
$$ = new boot::cast_expression(boot::make_position(@$), $5, $3);
}
- | call_expression { $$ = $1; }
+ | call_expression { $$ = $1.release(); }
| "(" expression ")" { $$ = $2; }
| identifier "{" field_initializers "}"
{
$$ = new boot::record_constructor_expression(boot::make_position(@$), std::move(*$1), $3);
}
- | "[" INTEGER "]" type_expression "{" expressions "}"
+ | array_type_expression "{" expressions "}"
{
- $$ = new boot::array_constructor_expression(boot::make_position(@$), $2, $4, $6);
+ $$ = new boot::array_constructor_expression(boot::make_position(@$), $1.release(), $3);
}
operand:
unary_expression { $$ = $1; }
@@ -399,7 +401,7 @@ statement:
boot::conditional_statements *then = new boot::conditional_statements($2, $4);
$$ = new boot::if_statement(boot::make_position(@$), then, $5, $6);
}
- | call_expression { $$ = $1; }
+ | call_expression { $$ = $1.release(); }
| "defer" statements "end"
{ $$ = new boot::defer_statement(boot::make_position(@$), $2); }
| "case" expression "of" switch_cases else_statements "end"
@@ -449,11 +451,10 @@ field_initializers:
$$.emplace($$.cbegin(), std::move(*$1));
}
| field_initializer { $$.push_back(std::move(*$1)); }
+array_type_expression: "[" expression "]" type_expression
+ { $$ = std::make_unique<boot::array_type_expression>(boot::make_position(@$), $4, $2); }
type_expression:
- "[" INTEGER "]" type_expression
- {
- $$ = new boot::array_type_expression(boot::make_position(@$), $4, $2);
- }
+ array_type_expression { $$ = $1.release(); }
| "[" "]" type_expression
{
$$ = new boot::slice_type_expression(boot::make_position(@$), $3);
@@ -476,7 +477,7 @@ type_expression:
}
| "proc" procedure_heading
{
- $$ = $2;
+ $$ = $2.release();
}
| "(" identifiers ")"
{