Add readint ()
diff --git a/src/lisp/lisp b/src/lisp/lisp
index 2437d14..f104f85 100755
--- a/src/lisp/lisp
+++ b/src/lisp/lisp
Binary files differ
diff --git a/src/lisp/lisp.c b/src/lisp/lisp.c
index d1ae059..efb3efe 100644
--- a/src/lisp/lisp.c
+++ b/src/lisp/lisp.c
@@ -177,6 +177,10 @@
{
printf ("\"%s\"\n", (char *) (v ^ STRING_TAG));
}
+ else if ( integerp (v) )
+ {
+ printf ("%d\n", v >> 2);
+ }
else if ( consp (v) )
{
if ( listp (v) )
@@ -227,6 +231,23 @@
return true;
}
+bool readint (struct istream *is, value_t *val)
+{
+ int number = 0;
+
+ if ( !isdigit (is->peek (is)) )
+ return false;
+
+ while ( isdigit (is->peek (is)) )
+ {
+ number *= 10;
+ number += is->get (is) - '0';
+ }
+
+ *val = intval (number);
+ return true;
+}
+
bool read1 (struct istream *is, value_t *val)
{
if ( readsym (is, val) )
@@ -235,6 +256,9 @@
if ( readstr (is, val) )
return true;
+ if ( readint (is, val) )
+ return true;
+
if ( readlist (is, val) )
return true;
diff --git a/src/lisp/lisp.h b/src/lisp/lisp.h
index 173ae92..3c2cb3b 100644
--- a/src/lisp/lisp.h
+++ b/src/lisp/lisp.h
@@ -28,7 +28,7 @@
#define CONS_TAG 0b001
#define VECTOR_TAG 0b010
-#define STRING_TAG 0b100
+#define STRING_TAG 0b011
#define SYMBOL_TAG 0b101
#define CLOSURE_TAG 0b110
@@ -71,6 +71,7 @@
bool readsym (struct istream *is, value_t *val);
bool readstr (struct istream *is, value_t *val);
bool readlist (struct istream *is, value_t *val);
+bool readint (struct istream *is, value_t *val);
value_t intval (int i);
value_t strval (char *str);
diff --git a/src/lisp/test.lisp b/src/lisp/test.lisp
index 2ddedd8..a4836eb 100644
--- a/src/lisp/test.lisp
+++ b/src/lisp/test.lisp
@@ -2,4 +2,4 @@
(display t "%a\n" (+ a b)))
(defun main ()
- (my-fun pi four))
+ (my-fun pi 4 773832))