From 83e98573aa975134790d579b01679d07279328ef Mon Sep 17 00:00:00 2001 From: Selimaj Dev Date: Thu, 28 May 2026 11:30:47 +0200 Subject: [PATCH] Updated pattern grammar --- crates/parser/src/grammar.pest | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/parser/src/grammar.pest b/crates/parser/src/grammar.pest index 6651ae5..9755861 100644 --- a/crates/parser/src/grammar.pest +++ b/crates/parser/src/grammar.pest @@ -134,16 +134,24 @@ literal = { // PATTERNS // ====================================================== +multi_pat_template = _{ + "[" ~ (identifier ~ ("," ~ identifier)*)? ~ "]" +} + tuple_pattern = { - "[" ~ (identifier ~ ("," ~ identifier)*) ~ "]" + "[" ~ multi_pat_template ~ "]" } named_tuple_pattern = { - static_path ~ "[" ~ (identifier ~ ("," ~ identifier)*)? ~ "]" + static_path ~ "[" ~ multi_pat_template ~ "]" } struct_pattern = { - static_path ~ "{" ~ (identifier ~ ("," ~ identifier)*)? ~ "}" + static_path ~ "{" ~ multi_pat_template ~ "}" +} + +path_pattern = { + mutable? ~ static_path } pattern = _{ @@ -151,7 +159,7 @@ pattern = _{ | tuple_pattern | struct_pattern | literal - | static_path + | path_pattern } // ====================================================== @@ -182,7 +190,7 @@ attributes = { // DECLARATION HELPERS // ====================================================== var_decl = { - (var | type_expr) ~ mutable? ~ pattern + (var | type_expr) ~ pattern } field = { @@ -415,7 +423,7 @@ c_for_stmt = { } for_stmt = { - "for" ~ "(" ~ mutable? ~ pattern ~ ":" ~ expr ~ ")" ~ statement_body + "for" ~ "(" ~ pattern ~ ":" ~ expr ~ ")" ~ statement_body } loop_stmt = {