Last active
February 23, 2021 03:34
-
-
Save sogaiu/51cb05c1b6a29bc576f162ec077452ac to your computer and use it in GitHub Desktop.
scratch work for a janet source debugger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(var steps 0) | |
(defn my-repl | |
[the-syms] | |
(def chunks | |
(fn [buf p] | |
(getline (string/format "\nrecent: %p\nsteps: %d\n> " | |
(keys the-syms) steps) | |
buf the-syms))) | |
# | |
(++ steps) | |
(repl chunks nil the-syms)) | |
(var syms @{}) | |
(table/setproto syms (curenv)) | |
(do | |
(my-repl syms) | |
# | |
(def a 1) | |
(def syms (table/setproto @{'a @{:value a}} | |
syms)) | |
(my-repl syms) | |
# | |
(def b 2) | |
(def syms (table/setproto @{'b @{:value b}} | |
syms)) | |
(my-repl syms) | |
# | |
(let [c 3 | |
d 4] | |
(def syms (table/setproto @{'c @{:value c} | |
'd @{:value d}} | |
syms)) | |
(my-repl syms) | |
# | |
(print "c + d: " (+ c d)) | |
(my-repl syms)) | |
(my-repl syms) | |
# | |
(if true | |
(do | |
(my-repl syms) | |
# | |
(print "true branch") | |
(my-repl syms)) | |
(do | |
(my-repl syms) | |
# | |
(print "not true branch") | |
(my-repl syms))) | |
(my-repl syms)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment