diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-12 20:00:56 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-12 20:00:56 +0300 |
commit | a8a4c5b567ea6a58809dc8232ea5f1d3c93879b9 (patch) | |
tree | d9ed2fc0970900bb4b8ff790158ae3ff3c0213d9 /src/sexp | |
parent | db736d795b759edd913d96195747f0881c4e950f (diff) | |
download | myslip-a8a4c5b567ea6a58809dc8232ea5f1d3c93879b9.tar.gz myslip-a8a4c5b567ea6a58809dc8232ea5f1d3c93879b9.zip |
feat: type checking for case expressions
Diffstat (limited to 'src/sexp')
-rw-r--r-- | src/sexp/util.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sexp/util.rs b/src/sexp/util.rs index a28aaad..3de45d4 100644 --- a/src/sexp/util.rs +++ b/src/sexp/util.rs @@ -86,4 +86,12 @@ impl SExp { _ => None } } + + pub fn check_case(self) -> Option<(SExp, Vec<SExp>)> { + match &(self.parts())[..] { + [casekw, scrutinee, cases @ ..] if casekw.clone() == Atom(Case) => + Some((scrutinee.clone(), cases.to_vec())), + _ => None, + } + } } |