eatspaces now eats comments
[scheme.forth.jl.git] / scheme.4th
index 644ee19..72897be 100644 (file)
@@ -301,7 +301,7 @@ global-env setobj
             abort
 ;
 
-: ensure-arg-type ( arg type -- )
+: ensure-arg-type ( arg type -- arg )
     istype? false = if
         arg-type-error
     then
@@ -377,12 +377,27 @@ parse-idx-stack parse-idx-sp !
     nextchar [char] ) = or
 ;
 
+: commentstart? ( -- bool )
+    nextchar [char] ; = ;
+
 : eatspaces
+
+    false \ Indicates whether or not we're eating a comment
+
     begin
-        whitespace?
+        dup whitespace? or commentstart? or
     while
+        dup nextchar '\n' = and if
+            invert \ Stop eating comment
+        else
+            dup false = commentstart? and if   
+                invert \ Begin eating comment
+            then
+        then
+
         inc-parse-idx
     repeat
+    drop
 ;
 
 : digit? ( -- bool )
@@ -393,8 +408,11 @@ parse-idx-stack parse-idx-sp !
 : minus? ( -- bool )
     nextchar [char] - = ;
 
+: plus? ( -- bool )
+    nextchar [char] + = ;
+
 : fixnum? ( -- bool )
-    minus? if
+    minus? plus? or if
         inc-parse-idx
 
         delim? if
@@ -493,8 +511,11 @@ parse-idx-stack parse-idx-sp !
     nextchar [char] " = ;
 
 : readnum ( -- num-atom )
-    minus? dup if
+    plus? minus? or if
+        minus?
         inc-parse-idx
+    else
+        false
     then
 
     0