Add readint ()
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;