Pattern AST and grammar

This commit is contained in:
2026-05-07 22:10:26 +02:00
parent c51ff01ce8
commit a6fb70eebf
4 changed files with 35 additions and 5 deletions
+4 -3
View File
@@ -13,9 +13,10 @@ inner_str = @{ (!"\"" ~ ("\\\"" | ANY))* }
static_path = { identifier ~ ("::" ~ identifier)* }
// pattern
tuple_pattern = { static_path ~ "(" ~ (identifier ~ ("," ~ identifier)*)? ~ ")" }
struct_pattern = { static_path ~ "{" ~ (identifier ~ ("," ~ identifier)*)? ~ "}" }
pattern = _{ tuple_pattern | struct_pattern | identifier }
tuple_pattern = { "(" ~ (identifier ~ ("," ~ identifier)*)? ~ ")" }
named_tuple_pattern = { static_path ~ "(" ~ (identifier ~ ("," ~ identifier)*)? ~ ")" }
struct_pattern = { static_path ~ "{" ~ (identifier ~ ("," ~ identifier)*)? ~ "}" }
pattern = _{ named_tuple_pattern | tuple_pattern | struct_pattern | identifier }
export = { "public" }
mutable = { "mut" }