diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-05 12:08:23 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-05 12:08:23 +0300 |
commit | bf458367d77cb4ca3f4ac0a4a8c9ffe13f71b09b (patch) | |
tree | 4019d2a46cf2c74dadd773aaa510a3867889a194 /src/type/check.rs | |
parent | c629fac4297b8f13bdab00100f3b05549174154e (diff) | |
download | myslip-bf458367d77cb4ca3f4ac0a4a8c9ffe13f71b09b.tar.gz myslip-bf458367d77cb4ca3f4ac0a4a8c9ffe13f71b09b.zip |
Implemented booleans (no if-else yet)
Diffstat (limited to 'src/type/check.rs')
-rw-r--r-- | src/type/check.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/type/check.rs b/src/type/check.rs index e9917c7..d678411 100644 --- a/src/type/check.rs +++ b/src/type/check.rs @@ -136,8 +136,7 @@ impl SExp { match self { Atom(Int(_)) => Ok(Integer), - Atom(True) => todo!(), - Atom(False) => todo!(), + Atom(True | False) => Ok(Boolean), Atom(Var(name)) => ctx.get(name) .ok_or(UndefinedVariable(name.to_string())) .cloned(), @@ -145,16 +144,10 @@ impl SExp { Atom(Mul) => Ok(arr(List(vec![Integer, Integer]), Integer)), // TODO varlen Atom(Sub) => Ok(arr(List(vec![Integer, Integer]), Integer)), Atom(Div) => Ok(arr(List(vec![Integer, Integer]), Integer)), - Atom(Eq) => todo!(), - Atom(Neq) => todo!(), - Atom(Lt) => todo!(), - Atom(Gt) => todo!(), - Atom(Le) => todo!(), - Atom(Ge) => todo!(), - Atom(Or) => todo!(), - Atom(And) => todo!(), - Atom(Xor) => todo!(), - Atom(Not) => todo!(), + Atom(Eq | Neq | Lt | Gt | Le | Ge) => + Ok(arr(List(vec![Integer, Integer]), Boolean)), + Atom(Or | And | Xor) => Ok(arr(List(vec![Boolean, Boolean]), Boolean)), + Atom(Not) => Ok(arr(Boolean, Boolean)), Atom(Nil) => Ok(List(vec![])), Atom(Quote) => Ok(arr( VarType("T".to_string()), |