diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-11 21:39:01 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-11 21:39:01 +0300 |
commit | 2e17ad5361a86d004ca48419a0f69f9c298ec1e1 (patch) | |
tree | 562b4735c164024e348fbf622e7b59319f0f0e35 /src/parse/parsetree.rs | |
parent | c2a293e46e6bf7563138ea852191ae70a7b7652e (diff) | |
download | myslip-2e17ad5361a86d004ca48419a0f69f9c298ec1e1.tar.gz myslip-2e17ad5361a86d004ca48419a0f69f9c298ec1e1.zip |
refactor: Added helper matches_pat for pattern matching
Diffstat (limited to 'src/parse/parsetree.rs')
-rw-r--r-- | src/parse/parsetree.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/parse/parsetree.rs b/src/parse/parsetree.rs index 46e636c..7f9d9dc 100644 --- a/src/parse/parsetree.rs +++ b/src/parse/parsetree.rs @@ -117,9 +117,12 @@ fn tokens_to_ast_inner( Some(Sym(s)) if s == "print" => Ok(Atom(Print)), Some(Sym(s)) if s == "let" => Ok(Atom(Let)), Some(Sym(s)) if s == "fn" => Ok(Atom(Fun)), + Some(Sym(s)) if s == "case" => Ok(Atom(Case)), Some(Sym(s)) if s == "->" => Ok(Atom(Arr)), Some(Sym(s)) if s == "int" => Ok(Atom(Ty(Integer))), Some(Sym(s)) if s == "bool" => Ok(Atom(Ty(Boolean))), + Some(Sym(s)) if s.starts_with("..") => + Ok(Atom(RestPat(s.strip_prefix("..").unwrap().to_string()))), Some(Sym(s)) => Ok(Atom(Var(s))), Some(ParClose) => break, Some(ParOpen) => { |