From 3fde297e078ad3a61f0ec0e2032d2910e3179ed4 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Sun, 20 Mar 2022 16:41:02 -0400 Subject: [PATCH] Import prelude --- src/ludus/interpreter.clj | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/ludus/interpreter.clj b/src/ludus/interpreter.clj index b715564..71bfa5b 100644 --- a/src/ludus/interpreter.clj +++ b/src/ludus/interpreter.clj @@ -4,6 +4,7 @@ [ludus.scanner :as scanner] [ludus.ast :as ast] [ludus.collections :as colls] + [ludus.prelude :as prelude] [clojure.pprint :as pp])) ;; right now this is not very efficient: @@ -132,26 +133,6 @@ ) ) -(def eq { - :name "eq" - ::ast/type ::ast/clj - :body = - }) - -(def add { - :name "add" - ::ast/type ::ast/clj - :body + - }) - -(def panic { - :name "panic" - ::ast/type ::ast/clj - :body (fn [& args] (throw (ex-info "Ludus panicked!" {:args args}))) - }) - -(def prelude {"eq" eq "add" add "panic" panic}) - (defn- call-fn [fn tuple ctx] (let [passed (interpret tuple ctx)] (case (::ast/type fn) @@ -219,7 +200,7 @@ (let [exprs (:exprs ast) inner (pop exprs) last (peek exprs) - ctx (atom prelude) + ctx (atom prelude/prelude) ] (run! #(interpret % ctx) inner) (interpret last ctx) @@ -255,7 +236,7 @@ (do (def source " - if true then :yay else panic (\"whoops\") + if false then :yay else print(:foo) ")