From 44d6e8a27294e5ca7300ab11900011b73d9336d4 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 21 Jul 2026 01:55:56 +0200 Subject: Implement slices --- boot/parser.yy | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'boot/parser.yy') diff --git a/boot/parser.yy b/boot/parser.yy index aad5769..bc2ddb5 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -112,6 +112,7 @@ along with GCC; see the file COPYING3. If not see DEFER "defer" CASE "case" OF "of" + TO "to" PIPE "|" %token OR "or" AND "&" XOR "xor" EQUALS "=" NOT_EQUAL "<>" LESS_THAN "<" GREATER_THAN ">" LESS_EQUAL "<=" GREATER_EQUAL ">=" @@ -372,6 +373,8 @@ type_expressions: designator_expression: simple_expression "[" expression "]" { $$ = new boot::array_access_expression(boot::make_position(@$), $1, $3); } + | simple_expression "[" expression "to" expression "]" + { $$ = new boot::slicing_expression(boot::make_position(@$), $1, $3, $5); } | simple_expression "." identifier { $$ = new boot::field_access_expression(boot::make_position(@$), $1, std::move(*$3)); } | simple_expression "^" @@ -446,6 +449,10 @@ type_expression: { $$ = new boot::array_type_expression(boot::make_position(@$), $4, $2); } + | "[" "]" type_expression + { + $$ = new boot::slice_type_expression(boot::make_position(@$), $3); + } | "const" type_expression { $$ = new boot::constant_type_expression(boot::make_position(@$), $2); -- cgit v1.2.3