diff options
-rw-r--r-- | src/parse/parsetree.rs | 16 | ||||
-rw-r--r-- | src/type/check.rs | 6 | ||||
-rw-r--r-- | src/type/display.rs | 2 |
3 files changed, 16 insertions, 8 deletions
diff --git a/src/parse/parsetree.rs b/src/parse/parsetree.rs index 0a5782d..86da0f0 100644 --- a/src/parse/parsetree.rs +++ b/src/parse/parsetree.rs @@ -198,9 +198,13 @@ fn parse_type(s: &str) -> IResult<&str, Type> { .map(|s: &str| VarType(s.to_string())); alt(( - tag("Int").map(|_| Integer), - tag("Bool").map(|_| Boolean), - tag("Nil").map(|_| NilType), + tag("Int") .map(|_| Integer), + tag("Bool") .map(|_| Boolean), + tag("Quote") .map(|_| QuoteTy), + tag("Vector").map(|_| VecType), + tag("Let") .map(|_| LetType), + tag("Type") .map(|_| TypeLit), + tag("Nil") .map(|_| NilType), arrp, vecp, listp, @@ -217,7 +221,11 @@ mod private_parsing_tests { fn test_parse_type() { assert_eq!(parse_type("Int"), Ok(("", Integer))); assert_eq!(parse_type("Bool"), Ok(("", Boolean))); - assert_eq!(parse_type("Nil"), Ok(("", NilType))); + assert_eq!(parse_type("Quote"), Ok(("", QuoteTy))); + assert_eq!(parse_type("Vector"), Ok(("", VecType))); + assert_eq!(parse_type("Let"), Ok(("", LetType))); + assert_eq!(parse_type("Type"), Ok(("", TypeLit))); + assert_eq!(parse_type("Nil"), Ok(("", NilType))); assert_eq!(parse_type("(Int -> Bool)"), Ok(("", arr(Integer, Boolean)))); assert_eq!( parse_type("((Int -> Int) -> (Bool -> Bool))"), diff --git a/src/type/check.rs b/src/type/check.rs index ad6be13..2c04d2e 100644 --- a/src/type/check.rs +++ b/src/type/check.rs @@ -111,8 +111,8 @@ impl SExp { /// }; /// /// let varlist = scons(var("a"), Nil); - /// let typelist = scons(Ty(Integer), Nil); - /// let ret = scons(Ty(Integer), Nil); + /// let typelist = Atom(Ty(Integer)); + /// let ret = Atom(Ty(Integer)); /// let body = scons(Add, scons(var("a"), scons(1, Nil))); /// assert_eq!( /// scons(Fun, scons(varlist, scons(typelist, scons(ret, scons(body, Nil))))).type_check(), @@ -127,7 +127,7 @@ impl SExp { /// }; /// /// let varlist = scons(var("a"), scons(var("b"), Nil)); - /// let typelist = scons(Ty(List(vec![Integer])), Nil); + /// let typelist = Atom(Ty(List(vec![Integer, Integer]))); /// let ret = Atom(Ty(Boolean)); /// let body = scons(Eq, varlist.clone()); /// assert_eq!( diff --git a/src/type/display.rs b/src/type/display.rs index 27f1427..b562d7b 100644 --- a/src/type/display.rs +++ b/src/type/display.rs @@ -32,7 +32,7 @@ impl fmt::Display for Type { VecType => write!(f, "{}", "Vector"), LetType => write!(f, "{}", "Let"), NilType => write!(f, "Nil"), - TypeLit => write!(f, "[type literal]"), + TypeLit => write!(f, "Type"), VecOf(ty) => write!(f, "({} ...)", *ty), Arrow(a, b) => write!(f, "({} -> {})", a, b), List(types) => write!( |