1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; and now
for something completely different
...
3 ;; UrForth
/C Forth Engine
!
4 ;; Copyright
(C
) 2023 Ketmar Dark
// Invisible Vector
6 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10 $include
-once
<linore
.f
>
12 $include
-once
<debugger
.f
>
16 vocabulary ufo
-repl
-support
17 also
-defs
: ufo
-repl
-support
19 false value editor
-active?
20 0 value restart
-word
-cfa
25 depth ?dup
if ." (" 0 .r
." )" endif
28 flush
-emit tty
:raw
-flush
33 rp0
! restart
-word
-cfa execute
-tail
37 " \r\e[0;1;5m>\e[0m" tty
:raw
-type
41 ..: linore
:on
-before
-draw
( FALSE
-- FALSE
/ TRUE
)
43 dup ifnot draw
-prompt
endif
48 ;; do not allow debugger
to abort on bad forth word
49 ..: forth
:(interpret
-word
-not
-found
-post
) ( addr count
-- addr count
)
50 space xtype
." ? -- wut?!" cr
57 tty
:tty?
" cannot run REPL on non-TTY" ?not
-error
60 true
to ufo
-repl
-support
:editor
-active?
62 tty
:size drop
to linore
:draw
-width
63 flush
-emit linore
:edit
-line
64 false
to ufo
-repl
-support
:editor
-active?
65 linore
:accept
-result linore
:result
-^d
= if break endif
66 linore
:accept
-result
+if
67 ['] ufo-repl-support:interp-done (user-interpret-next-line) !
68 0 linore:line + c! ;; finish TIB with 0 byte
69 linore:line drop tib ! >in 0! ;; setup TIB
72 ufo-repl-support:interp-done
77 ' repl
-loop
to ufo
-repl
-support
:restart
-word
-cfa
83 sp0
! rp0
! ['] ufo-repl-support:repl-loop execute-tail