boxed console printing works, but not janet prints

This commit is contained in:
Scott Richmond 2024-06-05 23:03:08 -04:00
parent 8ac289cc9d
commit 176feb5ae2
3 changed files with 15 additions and 19 deletions

View File

@ -9,25 +9,23 @@
(defn parse-error [e]
(def msg (e :msg))
(def line-num (get-in e [:token :line]))
(def source (get-in e [:token :source]))
(def {:line line-num :input input :soure source} (e :token))
(def source-line (get-line source line-num))
(print "Parsing error: " msg)
(print "On line " line-num ":")
(print "On line " line-num " in " input)
(print source-line)
e)
(defn validation-error [e]
(def msg (e :msg))
(def line-num (get-in e [:node :token :line]))
(def source (get-in e [:node :token :source]))
(def {:line line-num :input input :source source} (get-in e [:node :token]))
(def source-line (get-line source line-num))
(case msg
"unbound name"
(do
(print "Validation error: " msg " " (get-in e [:node :data]))
(print "on line " line-num)
(print "on line " line-num " in " input)
(print source-line))
(do
(print "Validation error: " msg)
@ -37,10 +35,9 @@
(defn- fn-no-match [e]
(print "Ludus panicked! no match")
(def line-num (get-in e [:node :token :line]))
(def source (get-in e [:node :token :source]))
(def {:line line-num :source source :input input} (get-in e [:node :token]))
(def source-line (get-line source line-num))
(print "on line " line-num)
(print "on line " line-num " in " input)
(def called (e :called))
(print "calling " (b/show called))
(def value (e :value))
@ -52,10 +49,9 @@
(defn- let-no-match [e]
(print "Ludus panicked! no match")
(def line-num (get-in e [:node :token :line]))
(def source (get-in e [:node :token :source]))
(def {:line line-num :source source :input input} (get-in e [:node :token]))
(def source-line (get-line source line-num))
(print "on line " line-num)
(print "on line " line-num " in " input)
(print "binding " (b/show (e :value)))
(def pattern (get-in e [:node :data 0]))
(print "to " (b/show-patt pattern))
@ -63,19 +59,18 @@
(defn- generic-panic [e]
(def msg (e :msg))
(def line-num (get-in e [:node :token :line]))
(def source (get-in e [:node :token :source]))
(def {:line line-num :source source :input input} (get-in e [:node :token]))
(def source-line (get-line source line-num))
(print "Ludus panicked! " msg)
(print "on line " line-num)
(print "on line " line-num " in " input)
(print source-line)
)
(defn- unbound-name [e]
(def {:line line-num :source source :lexeme name} (get-in e [:node :token]))
(def {:line line-num :source source :lexeme name :input input} (get-in e [:node :token]))
(def source-line (get-line source line-num))
(print "Ludus panicked! unbound name " name)
(print "on line " line-num)
(print "on line " line-num " in " input)
(print source-line)
)

View File

@ -9,7 +9,7 @@
(def pkg (do
(def prelude-ctx @{:^parent {"base" b/base}})
(def prelude-src (slurp "prelude.ld"))
(def prelude-scanned (s/scan prelude-src))
(def prelude-scanned (s/scan prelude-src :prelude))
(def prelude-parsed (p/parse prelude-scanned))
(def parse-errors (prelude-parsed :errors))
(when (any? parse-errors) (each err parse-errors (e/parse-error err)) (break :error))

View File

@ -51,9 +51,10 @@ This new scene will have to return a JSON POJSO:
(do
(def source `
print! ("hello")
`)
(-> source run)
)