;; OBSOLETE ;; TERMINAL ;; endpoint console + command server (module terminal mzscheme (require "composite.ss" "cat.ss") (compositions (badnop) badnop: ;; all this is from the perspective of the target system. there are 2 ;; modes. COMPILE mode accepts forth code as if it was source. it ;; will compile immediately to assembler using incremental ;; compilation. INTERPRET mode is for executing code on the target, ;; uploading compiled code, inspecting assembly, ... ;; common repl interface: ( string state -- state+ ) ;; the input string can for now be assumed to be valid. if not, throw ;; exception. ;; TODO: ;; * re-enable hooks ;; * move prompt somewhere so snot can display it ;; interpreter input ;; this is where the input is plugged: ( prompt -- inputstring )x (prompt display (read-line) (p-error "") try dup eof-object?) (badnop compile-badnop run) ;; interpret badnop cmd ( state cmd -- ) (next-mode '(next-console interpret!) badnop) (current-mode '(current-console interpret!) badnop) (try-hook (swap '(hook run!) badnop) (p-error) try) (prompt/next (prompt) dip (drop next-mode) swap ifte) (try-badnop compile-badnop (p-error) try) ;; run with error handler (cdc cr d cr) ;; NATIVE INTERPRET MODE (live-mode "> " (forth->list swap ;; lex '(interpret-target) try-badnop live-mode) prompt/next) ;; VM INTERPRET MODE (vm-live-mode "_> " (forth->list swap ;; lex '(vm-interpret-target) try-badnop vm-live-mode) prompt/next) ;; NATIVE COMPILE MODE (compile-mode ">> " (swap '(string>asm) try-badnop ;; compile line + again compile-mode) prompt/next) ;; VM COMPILE MODE (vm-compile-mode "_>> " (swap '(vm-string>asm) try-badnop vm-compile-mode) prompt/next) ;; CAT MODE (cat-mode "~ " (lex-line try-badnop cat-mode) prompt/next) ;; entry point (badnop-init read-file-1 '(init-host) badnop) (badnop-console badnop-init current-mode) ) ;; DEBUG ;; debug compiler macros, plain cat, to escape compilation. (compositions (macro) badnop: (pa pa-cpa) (clear stack drop ()) (post post) (sd (sd) dip) ) (compositions (badnop) badnop: ;; debug bin print in *cpa* mode (pb-cpa assemble assemble ;; perform 2 assembler passes ;; print print-dict print-bin) ;; debug asm print in *cpa* mode (pa-cpa (ps) dip ;; print stack for macro debug "---------------------------" d cr dup reverse print-asm) ) )