aboutsummaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-19 13:55:05 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-19 13:55:05 +0300
commita70dcaa949f41c585f9aea5e79f2550053d8e857 (patch)
tree9366f0b1e026c009708ebc243d006a79cbf452c9 /src/parse
parentd4d6e972650370d529363f7db3946e58bdbd7bca (diff)
downloadmyslip-a70dcaa949f41c585f9aea5e79f2550053d8e857.tar.gz
myslip-a70dcaa949f41c585f9aea5e79f2550053d8e857.zip
test: added boilerplate and tests for coproduct parsing, type checking and evaluation
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/parsetree.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/parse/parsetree.rs b/src/parse/parsetree.rs
index c773f3b..081489d 100644
--- a/src/parse/parsetree.rs
+++ b/src/parse/parsetree.rs
@@ -119,6 +119,9 @@ fn tokens_to_ast_inner(
Some(Sym(s)) if s == "false" => Ok(Atom(False)),
Some(Sym(s)) if s == "quote" => Ok(Atom(Quote)),
Some(Sym(s)) if s == "vector" => Ok(Atom(Vector)),
+ Some(Sym(s)) if s == "coprod" => Ok(Atom(Coprod)),
+ Some(Sym(s)) if s == "inl" => Ok(Atom(Inl)),
+ Some(Sym(s)) if s == "inr" => Ok(Atom(Inr)),
Some(Sym(s)) if s == "<>" => Ok(Atom(Concat)),
Some(Sym(s)) if s == "print" => Ok(Atom(Print)),
Some(Sym(s)) if s == "let" => Ok(Atom(Let)),
@@ -248,6 +251,7 @@ mod private_parsing_tests {
Ok(("", List(vec![Integer, Boolean, arr(Boolean, Integer), Integer])))
);
assert_eq!(parse_type("T"), Ok(("", VarType("T".to_string()))));
+ assert_eq!(parse_type("(Sum (Int -> Bool) Int)"), Ok(("", sumtype(arr(Integer, Boolean), Integer))));
}
#[test]