From fbb7b995b82b8242f6927a48757c69e21c8686d2 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 17 Feb 2019 03:38:15 -0800 Subject: [PATCH] Rename mk_type! to ty! Doesn't seem to conflict with the same macro in the parser tests, so should be ok --- schala-lang/language/src/builtin.rs | 40 ++++++++++++------------ schala-lang/language/src/typechecking.rs | 6 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/schala-lang/language/src/builtin.rs b/schala-lang/language/src/builtin.rs index 867cdb9..9d8683b 100644 --- a/schala-lang/language/src/builtin.rs +++ b/schala-lang/language/src/builtin.rs @@ -90,9 +90,9 @@ impl PrefixOp { lazy_static! { static ref PREFIX_OPS: HashMap<&'static str, (Type, ())> = hashmap! { - "+" => (mk_type!(Nat -> Int), ()), - "-" => (mk_type!(Nat -> Int), ()), - "!" => (mk_type!(Bool -> Bool), ()), + "+" => (ty!(Nat -> Int), ()), + "-" => (ty!(Nat -> Int), ()), + "!" => (ty!(Bool -> Bool), ()), }; } @@ -102,22 +102,22 @@ lazy_static! { lazy_static! { static ref BINOPS: HashMap<&'static str, (Type, (), i32)> = hashmap! { - "+" => (mk_type!(Nat -> Nat -> Nat), (), 10), - "-" => (mk_type!(Nat -> Nat -> Nat), (), 10), - "*" => (mk_type!(Nat -> Nat -> Nat), (), 20), - "/" => (mk_type!(Nat -> Nat -> Float), (), 20), - "quot" => (mk_type!(Nat -> Nat -> Nat), (), 20), - "%" => (mk_type!(Nat -> Nat -> Nat), (), 20), - "++" => (mk_type!(StringT -> StringT -> StringT), (), 30), - "^" => (mk_type!(Nat -> Nat -> Nat), (), 20), - "&" => (mk_type!(Nat -> Nat -> Nat), (), 20), - "|" => (mk_type!(Nat -> Nat -> Nat), (), 20), - ">" => (mk_type!(Nat -> Nat -> Bool), (), 20), - ">=" => (mk_type!(Nat -> Nat -> Bool), (), 20), - "<" => (mk_type!(Nat -> Nat -> Bool), (), 20), - "<=" => (mk_type!(Nat -> Nat -> Bool), (), 20), - "==" => (mk_type!(Nat -> Nat -> Bool), (), 20), - "=" => (mk_type!(Unit), (), 20), //TODO not sure what the type of this should be b/c special fmr - "<=>" => (mk_type!(Nat -> Nat -> Ordering), (), 20), //TODO figure out how to treat Order + "+" => (ty!(Nat -> Nat -> Nat), (), 10), + "-" => (ty!(Nat -> Nat -> Nat), (), 10), + "*" => (ty!(Nat -> Nat -> Nat), (), 20), + "/" => (ty!(Nat -> Nat -> Float), (), 20), + "quot" => (ty!(Nat -> Nat -> Nat), (), 20), + "%" => (ty!(Nat -> Nat -> Nat), (), 20), + "++" => (ty!(StringT -> StringT -> StringT), (), 30), + "^" => (ty!(Nat -> Nat -> Nat), (), 20), + "&" => (ty!(Nat -> Nat -> Nat), (), 20), + "|" => (ty!(Nat -> Nat -> Nat), (), 20), + ">" => (ty!(Nat -> Nat -> Bool), (), 20), + ">=" => (ty!(Nat -> Nat -> Bool), (), 20), + "<" => (ty!(Nat -> Nat -> Bool), (), 20), + "<=" => (ty!(Nat -> Nat -> Bool), (), 20), + "==" => (ty!(Nat -> Nat -> Bool), (), 20), + "=" => (ty!(Unit), (), 20), //TODO not sure what the type of this should be b/c special fmr + "<=>" => (ty!(Nat -> Nat -> Ordering), (), 20), //TODO figure out how to treat Order }; } diff --git a/schala-lang/language/src/typechecking.rs b/schala-lang/language/src/typechecking.rs index 385ff9e..2dcca99 100644 --- a/schala-lang/language/src/typechecking.rs +++ b/schala-lang/language/src/typechecking.rs @@ -78,10 +78,10 @@ impl Type { } } -macro_rules! mk_type { +macro_rules! ty { ($type_name:ident) => { Type::Const(TypeConst::$type_name) }; - ($t1:ident -> $t2:ident) => { Type::Arrow(Box::new(mk_type!($t1)), Box::new(mk_type!($t2))) }; - ($t1:ident -> $t2:ident -> $t3:ident) => { Type::Arrow(Box::new(mk_type!($t1)), Box::new(mk_type!($t2 -> $t3))) }; + ($t1:ident -> $t2:ident) => { Type::Arrow(Box::new(ty!($t1)), Box::new(ty!($t2))) }; + ($t1:ident -> $t2:ident -> $t3:ident) => { Type::Arrow(Box::new(ty!($t1)), Box::new(ty!($t2 -> $t3))) }; } /*