commit 4aa5249b5f082ff4d72865dc6d0bc9541a27d43d
parent 30e659bb8314118e1a659ff73b7c6edfe3c68226
Author: Ed van Bruggen <edvb@uw.edu>
Date: Thu, 7 Mar 2019 17:08:39 -0800
Add rational type
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tisp.c b/tisp.c
@@ -98,6 +98,8 @@ type_str(Type t)
case FUNCTION: return "function";
case PAIR: return "pair";
default:
+ if (t == RATIONAL)
+ return "rational";
if (t & NUMBER)
return "number";
return "invalid";
diff --git a/tisp.h b/tisp.h
@@ -35,7 +35,7 @@
NARGS, NARGS > 1 ? "s" : "", list_len(ARGS)); \
} while(0)
#define tsp_arg_type(ARG, NAME, TYPE) do { \
- if (!(ARG->t & TYPE)) \
+ if (!(ARG->t & (TYPE))) \
tsp_warnf(NAME ": expected %s, received %s", type_str(TYPE), type_str(ARG->t)); \
} while(0)
@@ -104,7 +104,8 @@ typedef enum {
FUNCTION = 1 << 8,
PAIR = 1 << 9,
} Type;
-static Type const NUMBER = INTEGER | DECIMAL | RATIO;
+static Type const RATIONAL = INTEGER | RATIO;
+static Type const NUMBER = INTEGER | RATIO | DECIMAL;
struct Val {
Type t; /* NONE, NIL */