do: Elaborate on pattern syntax, add binary as operator

This commit is contained in:
2025-09-16 04:18:12 -04:00
parent b6949147c4
commit 7b05da1334
6 changed files with 150 additions and 78 deletions

View File

@@ -193,6 +193,8 @@ impl<A: Annotation> Match<A> for Pat {
(Pat::Slice(_), _) => false,
(Pat::Alt(pat), Pat::Alt(expr)) => Match::recurse(sub, pat, expr),
(Pat::Alt(_), _) => false,
(Pat::Typed(pat, _), Pat::Typed(expr, _)) => Match::recurse(sub, pat, expr),
(Pat::Typed(..), _) => false,
}
}
@@ -208,10 +210,24 @@ impl<A: Annotation> Match<A> for Pat {
Pat::Tuple(pats) => pats.apply(sub),
Pat::Slice(pats) => pats.apply(sub),
Pat::Alt(pats) => pats.apply(sub),
Pat::Typed(pat, ty) => {
pat.apply(sub);
ty.apply(sub);
}
}
}
}
impl<A: Annotation> Match<A> for Ty {
fn apply(&mut self, sub: &Subst<A>) {
todo!("Apply subst {sub:?} for {self}.")
}
fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool {
todo!("Construct subst {sub:?} from {pat} and {expr}.")
}
}
impl<A: Annotation> Match<A> for Op {
fn recurse(_: &mut Subst<A>, pat: &Self, expr: &Self) -> bool {
pat == expr