X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=scheme.4th;h=72897bedbec770f312f62e273db0b0d9a45b600c;hb=85e14c9d3e9509418125d2a7a6b7fa366a8f31ad;hp=644ee1914c221ab38227825a97f09599391140a6;hpb=22e181f918b5518f64ee693c492469d11f2898ac;p=scheme.forth.jl.git diff --git a/scheme.4th b/scheme.4th index 644ee19..72897be 100644 --- a/scheme.4th +++ b/scheme.4th @@ -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