Rename mk_type! to ty!

Doesn't seem to conflict with the same macro in the parser tests, so should be
ok
This commit is contained in:
greg 2019-02-17 03:38:15 -08:00
parent 9d4f086a04
commit fbb7b995b8
2 changed files with 23 additions and 23 deletions

View File

@ -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
};
}

View File

@ -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))) };
}
/*