summaryrefslogtreecommitdiff
path: root/jefs.fs
diff options
context:
space:
mode:
Diffstat (limited to 'jefs.fs')
-rw-r--r--jefs.fs22
1 files changed, 12 insertions, 10 deletions
diff --git a/jefs.fs b/jefs.fs
index 84bb85a..45804c7 100644
--- a/jefs.fs
+++ b/jefs.fs
@@ -1,6 +1,7 @@
\ i think something is going on with the stack. i dunno
\ things TODO:
-\ read-line (will be slow)
+\ standardise stack comment abbrs (i like leo brodie's forth_style.txt)
+\ go back to brked user mem area (with mprotect) (someone in the uiua discord suggested it
\ DO LOOP
\ s\"
\ add error handling to compiling words
@@ -298,9 +299,16 @@ stdin buffers-fd !
: buffer-refill ( u|0 ) cbuffer /buffer cbuffer-fd @ read-file 0<> if 0 then
0 cbuffer->in ! dup cbuffer-used ! ; \ returns zero on error or nothing read.
: buffer-empty? cbuffer->in @ cbuffer-used @ >= ;
-: buffer-key buffer-empty? if buffer-refill 0= if -1 [ ret, ] then then
- cbuffer cbuffer->in @ + c@
- cbuffer->in @ 1+ cbuffer->in ! ;
+: buffer-key ( key|-1 ) buffer-empty? if buffer-refill 0= if -1 [ ret, ] then then
+ cbuffer cbuffer->in @ + c@ cbuffer->in @ 1+ cbuffer->in ! ;
+\ i could do some stack wrangling and not need these variables. maybe later.
+\ i just want something that Works right now
+0 value (accept-n)
+0 value (accept-a)
+: accept ( a n -- n ) to (accept-n) to (accept-a)
+ 0 begin dup (accept-n) < while buffer-key dup
+ 0>= if ( n c -- ) over (accept-a) + c! 1+
+ else drop to (accept-n) then repeat ;
\ i think i'll just take the wonkiness of
\ 'if you use LOAD or something like that you lose the rest of that line'
@@ -313,11 +321,5 @@ make line-buffer line-buffer-length allot
source-id @ >r string-source source-id ! interpret r> source-id ! ;
: evaluate ( c-addr u -- ) tib @ >r #tib @ >r >in @ >r (evaluate) r> >in ! r> #tib ! r> tib ! ;
-\ INTERACTIVITY {{{
-\ i hate dealing with user input!!!
-\ but my idea is: when reading forth from a file,
-\ words are read into a buffer, and read from there.
-\ }}}
-
.free
bye