First draft bugfix
This commit is contained in:
parent
feb02dc1b6
commit
60c44d8923
|
@ -6,6 +6,8 @@
|
|||
the_line (nth lines (dec line))]
|
||||
the_line))
|
||||
|
||||
(string/split-lines "abcd")
|
||||
|
||||
(defn get-underline [source {:keys [line start lexeme]} prefix]
|
||||
(let [lines (string/split-lines source)
|
||||
lines-before (subvec lines 0 (dec line))
|
||||
|
@ -37,3 +39,4 @@
|
|||
(str "Ludus panicked on line " line ":\n" (get-line source {:line line}) "\n" message)
|
||||
(str "Ludus panicked!\n" message)
|
||||
))
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@
|
|||
(throw (ex-info (str "Struct error: no member at " kw) {:ast kw}))))
|
||||
(get map kw))))))
|
||||
|
||||
(defn- call-fn [lfn args ctx]
|
||||
(defn- call-fn [lfn args ctx from]
|
||||
;(println "Calling function " (:name lfn))
|
||||
(cond
|
||||
(= ::data/partial (first args))
|
||||
|
@ -452,7 +452,8 @@
|
|||
(call-fn
|
||||
lfn
|
||||
(into [::data/tuple] (replace {::data/placeholder arg} (rest args)))
|
||||
ctx))}
|
||||
ctx
|
||||
from))}
|
||||
|
||||
(= (::data/type lfn) ::data/clj) (apply (:body lfn) (next args))
|
||||
|
||||
|
@ -492,7 +493,7 @@
|
|||
(interpret-ast body fn-ctx)))
|
||||
(recur (first clauses) (rest clauses))))
|
||||
|
||||
(throw (ex-info (str "Match Error: No match found for " (show/show args) " in function " (:name lfn)) {:ast (:ast lfn)})))))
|
||||
(throw (ex-info (str "Match Error: No match found for " (show/show args) " in function " (:name lfn)) {:ast from})))))
|
||||
|
||||
(keyword? lfn)
|
||||
(if (= 2 (count args))
|
||||
|
@ -531,7 +532,7 @@
|
|||
(throw (ex-info (str "Namespace error: no member " (:value curr) " in ns " (::data/name prev-value)) {:ast curr}))
|
||||
(throw (ex-info (str "Struct error: no member " (:value curr)) {:ast curr}))))
|
||||
(get prev-value (first data)))
|
||||
(call-fn prev-value (interpret-args data ctx) ctx))))
|
||||
(call-fn prev-value (interpret-args data ctx) ctx curr))))
|
||||
|
||||
(defn- interpret-synthetic [ast ctx]
|
||||
;;(println "interpreting synthetic " ast)
|
||||
|
@ -606,7 +607,7 @@
|
|||
(let [data (:data ast)
|
||||
root (interpret-ast (first data) ctx)
|
||||
fns (rest data)]
|
||||
(reduce #(call-fn (interpret-ast %2 ctx) [::data/tuple %1] ctx) root fns)))
|
||||
(reduce #(call-fn (interpret-ast %2 ctx) [::data/tuple %1] ctx ast) root fns)))
|
||||
|
||||
(defn- map-values [f]
|
||||
(map (fn [kv]
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
(defn run [source]
|
||||
(let [user_scanned (s/scan source)
|
||||
user_tokens (:tokens user_scanned)
|
||||
_ (println "Tokens: " user_tokens)
|
||||
user_parsed (p/apply-parser g/script user_tokens)
|
||||
_ (println "Ast: " (i/prettify-ast user_parsed))
|
||||
user_result (i/interpret-safe source user_parsed {})
|
||||
result_str (show/show user_result)
|
||||
post_scanned (s/scan pre/postlude)
|
||||
|
@ -57,3 +59,4 @@
|
|||
(clean-out clj_result)
|
||||
)
|
||||
))
|
||||
|
||||
|
|
1
target/repl-port
Normal file
1
target/repl-port
Normal file
|
@ -0,0 +1 @@
|
|||
51500
|
Loading…
Reference in New Issue
Block a user