diff options
| author | kitty <nepeta@canaglie.net> | 2026-03-08 17:49:32 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-03-08 17:49:32 +1100 |
| commit | 875478f5e71d6d63ba3eb83e923dc8b211af212f (patch) | |
| tree | dca0a691c53b9552eb8e4840d18d6a59d87a11de | |
| parent | 9014dde6d62d7d37e3ccb050608db15ed9930b49 (diff) | |
s>z, untested include-file
| -rw-r--r-- | jefs.fs | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -71,6 +71,9 @@ hex : ret, c3 c, ; decimal : ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting, here have another " : z" 1 >in +! [ char " ] literal cparse branch >mark >r 2dup cmove, 0 c, nip r> dup >resolve 4 + [compile] lit drop ( 1+ [compile] lit ) ; immediate +\ todo s>z z>s +: s>z ( a u -- zstr ) here @ -rot cmove, 0 c, ; + \ creates a word called _ (so don't create an actual word called that!!!) \ maybe it could be an empty string but that might require some rewriting \ (maybe a bad solution, but ; expects a header and reads from LATEST... @@ -277,7 +280,6 @@ make error-msgs #error-msgs cells allot 1 constant w/o 2 constant r/w -\ todo do these return the right values? (true instead of false?) : open-file ( mode zstr -- ?fd flag ) 0 -rot sysopen errno ; : close-file ( fd -- flag ) sysclose errno-flag ; : read-file ( c-addr u fd -- ?u flag ) >r swap r> sysread errno ; @@ -326,9 +328,6 @@ stdin buffers-fd ! hide (accept-n) hide (accept-a) hide (accept-real-n) hide truncate-(accept-n) -\ i think i'll just take the wonkiness of -\ 'if you use LOAD or something like that you lose the rest of that line' -\ i dont think that's that big a deal 2048 constant line-buffer-length make line-buffer line-buffer-length allot @@ -346,12 +345,14 @@ make line-buffer line-buffer-length allot source-id >r string-source to source-id interpret r> to source-id ; : evaluate ( c-addr u -- ) tib @ >r #tib @ >r >in @ >r (evaluate) r> >in ! r> #tib ! r> tib ! ; +\ for now, if you include a file the rest of the line is discarded : ?inc-depth include-depth max-include-depth > if 0 to include-depth 5 fuck then ; -: include-file tib @ >r #tib @ >r >in @ >r source-id >r 1 +to include-depth - ?inc-depth - 1 -to include-depth >r >in ! >r #tib ! >r tib ! r> to source-id ; -: included ; -: include ; +: include-file ( fd -- ) source-id >r to source-id 1 +to include-depth + ?inc-depth 0 cbuffer-used ! 0 cbuffer->in ! source-id cbuffer-fd ! + begin refill while interpret repeat + 1 -to include-depth r> to source-id ; +: included ( a u -- ) ; +: include ( "path" -- ) ; \ }}} \ TERMINAL CONTROL {{{ |
