Var decl with repeat

This commit is contained in:
2026-07-04 09:55:23 +02:00
parent eeac773c06
commit 517a2e5a2b
5 changed files with 62 additions and 11 deletions
+2 -1
View File
@@ -44,8 +44,9 @@ pub struct MatchItem(pub Vec<Pattern>, pub Expression);
#[derive(Debug, Clone, Serialize)]
pub struct VarDecl {
pub name: Pattern,
pub type_: Option<TypeExpr>,
pub name: Pattern,
pub tuple_names: Vec<Pattern>,
}
#[derive(Debug, Clone, Serialize)]
+2 -2
View File
@@ -226,8 +226,8 @@ attributes = {
// DECLARATION HELPERS
// ======================================================
var_decl = {
("let" ~ pattern)
| type_expr ~ (!tuple_pattern ~ pattern)
("let" ~ pattern ~ ("," ~ pattern)*)
| type_expr ~ (!tuple_pattern ~ pattern ~ ("," ~ pattern)*)
}
field = {
+1
View File
@@ -56,6 +56,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for VarDecl {
.map(TypeExpr::try_from)
.transpose()?,
name: Pattern::try_from(inner.next().unwrap())?,
tuple_names: collect_recovered(inner)?,
})
}