3 (chicken process-context)
8 (define (load-progs filenames)
9 (map (lambda (filename)
10 (string->prog (with-input-from-file filename read-string)))
15 "q:\tPrint current process queues\n"
16 "c:\tClear and reinitialize core\n"
17 "d:\tDump list of instructions around each process instruction pointer\n"
18 "s, n:\tStep to next iteration\n"
21 (define (mars-debugger core-size filenames)
22 (let* ((core (make-core core-size))
23 (progs (load-progs filenames))
24 (queues (install-progs core progs)))
25 (print "JaRS Redcode Debugger. Enter 'h' for help.")
29 (match (string-tokenize (read-line))
37 (print "Reinitializing...")
38 (set! core (make-core core-size))
39 (set! queues (install-progs core progs))
42 (dump-queues queues core)
45 (set! queues (run-mars core queues 1 1))
46 (dump-queues queues core)
51 (print "Error: unrecognised command '" other "'")
57 (print "Usage: run-mars [-h|--help]\n"
58 " run-mars [-c|--core size]\n"
59 " warrior1.red [warrior2.red [...]]"))
62 (let loop ((args (cdr (argv)))
65 ((or () ((or "-h" "--help")))
67 (((or "-c" "--core-size") cstr rest ...)
68 (loop rest (string->number cstr)))
70 (mars-debugger core-size filenames)))))