Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active February 23, 2021 03:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogaiu/51cb05c1b6a29bc576f162ec077452ac to your computer and use it in GitHub Desktop.
Save sogaiu/51cb05c1b6a29bc576f162ec077452ac to your computer and use it in GitHub Desktop.
scratch work for a janet source debugger
(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