From a0e1740227535adc3151c02eb102c4f96b4f9731 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 17 Jul 2026 10:18:58 +0200 Subject: Implement type constness --- boot/parser.yy | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index c34c905..1dd42a8 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -129,8 +129,6 @@ along with GCC; see the file COPYING3. If not see %type > case_labels; %type switch_case; %type > switch_cases; -%type constant_declaration; -%type > constant_part constant_declarations; %type variable_declaration; %type > variable_declarations variable_part; %type type_expression; @@ -166,14 +164,14 @@ along with GCC; see the file COPYING3. If not see %type > import_declarations import_part; %% program: - import_part constant_part type_part variable_part procedure_part statement_part "end" "." + import_part type_part variable_part procedure_part statement_part "end" "." { - boot::unit *tree = new boot::unit(boot::make_position(@$), $1, $2, $3, $4, $5, $6); + boot::unit *tree = new boot::unit(boot::make_position(@$), $1, $2, $3, $4, $5); driver.tree.reset(tree); } procedure_body: - constant_part variable_part statement_part procedure_return - { $$ = std::make_unique($1, $2, $3, $4); } + variable_part statement_part procedure_return + { $$ = std::make_unique($1, $2, $3); } statement_part: /* no statements */ {} @@ -444,6 +442,10 @@ type_expression: { $$ = new boot::array_type_expression(boot::make_position(@$), $4, $2); } + | "const" type_expression + { + $$ = new boot::constant_type_expression(boot::make_position(@$), $2); + } | "^" type_expression { $$ = new boot::pointer_type_expression(boot::make_position(@$), $2); @@ -501,20 +503,6 @@ variable_declarations: variable_part: /* no variable declarations */ {} | "var" variable_declarations { $$ = $2; } -constant_declaration: identifier_definition ":=" expression - { - $$ = new boot::constant_declaration(boot::make_position(@$), std::move(*$1), $3); - } -constant_declarations: - constant_declaration constant_declarations - { - $$ = $2; - $$.insert(std::cbegin($$), $1); - } - | /* no constant definitions */ {} -constant_part: - /* no constant definitions */ {} - | "const" constant_declarations { $$ = $2; } import_declaration: IDENTIFIER "." import_declaration { -- cgit v1.2.3