diff options
| author | kitty <nepeta@canaglie.net> | 2026-04-14 00:31:35 +1000 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-04-14 00:31:35 +1000 |
| commit | 6ff9e379accc25d7c9fda0d51cf83b48139620a5 (patch) | |
| tree | db59559432bd7430427aa4e39b076bafdfb505f8 /sanctuary.fs | |
| parent | 64984f5987264fb06587fb669801f8c6f4fdcc31 (diff) | |
whee!!!
Diffstat (limited to 'sanctuary.fs')
| -rw-r--r-- | sanctuary.fs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sanctuary.fs b/sanctuary.fs index e555055..de37b52 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -84,8 +84,10 @@ decimal r> dup >resolve 4 + ( u a ) postpone literal ( a ) drop ; immediate compile-only : zstrlen dup begin dup c@ 0<> while 1+ repeat swap - ; -\ todo s>z becomes s>z, s>z writes to pad (will then need to be moved below pno) -: s>z here -rot cmove, 0 c, ; + +: s>z, here -rot cmove, 0 c, ; +\ todo doc +: /string ( a1 u1 n -- a2 u2 ) tuck - >r + r> ; \ DEFER {{{ \ todo ['] abort → ['] ?defer or something (where ?defer yields an appropriate error) @@ -154,7 +156,7 @@ decimal \ NUMERIC OUTPUT {{{ \ this buffer is also used as a temporary string buffer. 255 constant #pad -create pad 255 cells allot +create pad 256 cells allot \ 256 because pad is also used by `s>z` which can be at most 255 w/o the null byte : pad$ pad #pad + ; variable hld @@ -215,7 +217,7 @@ init-source value source-id : ." postpone s" postpone type ; immediate compile-only \ " : e." postpone s" postpone warn ; immediate compile-only \ " -: (abort") ( a u -- ) warn abort ; +: (abort") ( a u -- ) warn ecr abort ; : abort" postpone s" postpone (abort") ; immediate compile-only \ ERROR MESSAGES {{{ @@ -325,6 +327,10 @@ privatise (evaluate) r> >in ! r> #tib ! r> tib ! ; +: s>z dup #pad >= if abort" string too large for pad" then + >r pad r@ ( a pad u ) cmove + r> ( u ) pad + 0 swap c! pad ; + : ?include-depth include-depth #buffers >= if 0 to include-depth abort" too many input buffers" then ; : include-file ( fd -- ) source-id >r ( fd ) dup to source-id @@ -332,6 +338,15 @@ privatise 0 cbuffer-used ! 0 cbuffer->in ! ( fd ) cbuffer-fd ! begin refill while interpret repeat 1 -to include-depth r> to source-id ; +: included ( a u -- ) s>z r/o open-file 0= if + dup >r + include-file + r> + close-file + else + drop abort" file open for include failed" + then ; +: include ( "path" -- ) parse-name included ; \ }}} \ \ VOCABULARY {{{ @@ -353,3 +368,4 @@ privatise : welcome ." sanctuary: a 64 bit forth for linux, version " version u. cr ; welcome quit bye +bye |
