diff options
| author | kitty <nepeta@canaglie.net> | 2026-03-05 02:14:43 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-03-05 02:14:43 +1100 |
| commit | 91c0eeda4d0a20ccfc5201c1d7ec161b91caea2e (patch) | |
| tree | dd8aac1658d7b2508667765ad50257ee5b438082 | |
| parent | 12025926739a8b2b4c7a33d8eccd805cbce4d06a (diff) | |
eujh,,,,
look it's ugly as shit but it Works
| -rw-r--r-- | jefs.fs | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -4,6 +4,7 @@ \ DO LOOP \ s\" \ add error handling to compiling words +\ better syscall error handling \ <builds does> \ argc/argv \ file io @@ -321,16 +322,18 @@ stdin buffers-fd ! : buffer-empty? cbuffer->in @ cbuffer-used @ >= ; : 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 + +\ this is profoundly horrible and ugly 0 value (accept-n) 0 value (accept-a) -\ todo this will not return a flag if the input buffer runs out -: accept ( a n -- n ? ) to (accept-n) to (accept-a) +0 value (accept-real-n) +: truncate-(accept-n) ( n -- ) (accept-n) to (accept-real-n) to (accept-n) ; +: accept ( a n -- n ? ) dup to (accept-n) to (accept-real-n) to (accept-a) 0 begin dup (accept-n) < while buffer-key dup - 0>= if ( n c -- ) dup 10 = if drop dup to (accept-n) true swap + 0>= if ( n c -- ) dup 10 = if drop dup truncate-(accept-n) true swap else over (accept-a) + c! 1+ then - else drop to (accept-n) false swap then repeat swap ; + else drop truncate-(accept-n) false swap then repeat + (accept-real-n) (accept-n) = if true else swap then ; \ i think i'll just take the wonkiness of \ 'if you use LOAD or something like that you lose the rest of that line' @@ -344,5 +347,6 @@ make line-buffer line-buffer-length allot : evaluate ( c-addr u -- ) tib @ >r #tib @ >r >in @ >r (evaluate) r> >in ! r> #tib ! r> tib ! ; .free -line-buffer line-buffer-length accept .s +\ make testb 10 allot +\ testb 10 accept .s bye |
