From 9ac53463c56dd57a84036a6944e6b4e5d3829e9c Mon Sep 17 00:00:00 2001 From: kitty Date: Wed, 8 Apr 2026 17:30:24 +1000 Subject: some erroring stuff --- sanctuary.fs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'sanctuary.fs') diff --git a/sanctuary.fs b/sanctuary.fs index b7e5469..1acb5ee 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -174,14 +174,17 @@ false value nonaming 1 constant stdout 2 constant stderr -: sys-write 0 syscall3 ; -: sys-read 1 syscall3 ; +: sys-read 0 syscall3 ; +: sys-write 1 syscall3 ; : sys-open 2 syscall3 ; : sys-close 3 syscall1 ; -: type swap stdout sys-read drop ; +: type swap stdout sys-write drop ; +: etype swap stderr sys-write drop ; : emit sp 1 type drop ; +: cr 10 emit ; + 0 constant r/o 1 constant w/o 2 constant r/w @@ -198,7 +201,29 @@ false value nonaming -1 constant string-source init-source value source-id -: ." ; \ todo doc +\ syntax highlighting cannot handle this. oops,, +: ." postpone s" postpone type ; immediate compile-only \ " + +: e." postpone s" postpone etype ; immediate compile-only \ " +: (abort") ( ? a u -- ) rot 0<> if etype abort else 2drop then ; +: abort" postpone s" postpone (abort") ; immediate compile-only + +\ stk under/overflow ones need to clear the stack first +\ feels wrong but i think its correct +:noname e." word not found" cr abort ; is ?notfound? +:noname sp-reset e." stack overflow" cr abort ; is ?overflow? +:noname sp-reset e." stack underflow" cr abort ; is ?underflow? + +\ if you need more than 16 layers of included files: go away™ +\ todo doc +16 constant #buffers +0 value include-depth +8192 constant /buffer +2048 constant /line-buffer + +\ this bit is so large that i may increase the default brk +create buffers /buffer #buffers * allot +create line-buffers /line-buffer #buffers * allot \ OLD VERSION I GAVE UP ON BECAUSE IT'S TOO COMPLICATED AND SUCKS SHIT {{{ \ 8192 constant /buffer -- cgit v1.2.3