aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Julian2015-07-21 01:03:37 -0400
committerEduardo Julian2015-07-21 01:03:37 -0400
commit874af34a80ab799d0470810b7ade337b96ce50bc (patch)
treee34e3768410b01e3fb8530d1b142e3cd8bcec8e3 /src
parent3a760fa6c0f47f7621970b9747779f3edcc96286 (diff)
- Added a way to pass the cursor from un-expanded macro-forms to their expansions in order to aid error-reporting.
- Added recursive type definitions through the #rec tag in deftype.
Diffstat (limited to '')
-rw-r--r--src/lux/analyser.clj2
-rw-r--r--src/lux/analyser/lux.clj12
2 files changed, 10 insertions, 4 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj
index 995e77fe6..f85b3d619 100644
--- a/src/lux/analyser.clj
+++ b/src/lux/analyser.clj
@@ -535,7 +535,7 @@
]
[["lux;Right" [state* =fn]]]
(do ;; (prn 'GOT_FUN (&/show-ast ?fn) (&/show-ast token) (aget =fn 0 0) (aget =fn 1 0))
- ((&&lux/analyse-apply (partial analyse-ast eval! compile-module) exo-type =fn ?args) state*))
+ ((&&lux/analyse-apply (partial analyse-ast eval! compile-module) exo-type meta =fn ?args) state*))
[_]
((analyse-basic-ast (partial analyse-ast eval! compile-module) eval! compile-module exo-type token) state)))
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index fc96fecff..8be2a8924 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -30,6 +30,11 @@
(return (&/T ?item =type)))
)))))
+(defn ^:private with-cursor [cursor form]
+ (matchv ::M/objects [form]
+ [["lux;Meta" [_ syntax]]]
+ (&/V "lux;Meta" (&/T cursor syntax))))
+
;; [Exports]
(defn analyse-tuple [analyse exo-type ?elems]
(|do [exo-type* (&type/actual-type exo-type)]
@@ -245,7 +250,7 @@
(fail (str "[Analyser Error] Can't apply a non-function: " (&type/show-type ?fun-type*)))))
))
-(defn analyse-apply [analyse exo-type =fn ?args]
+(defn analyse-apply [analyse exo-type form-cursor =fn ?args]
(|do [loader &/loader]
(matchv ::M/objects [=fn]
[[=fn-form =fn-type]]
@@ -255,14 +260,15 @@
(matchv ::M/objects [$def]
[["lux;MacroD" macro]]
(|do [macro-expansion #(-> macro (.apply ?args) (.apply %))
+ :let [macro-expansion* (&/|map (partial with-cursor form-cursor) macro-expansion)]
:let [_ (when (and ;; (= "lux/control/monad" ?module)
(= "case" ?name))
- (->> (&/|map &/show-ast macro-expansion)
+ (->> (&/|map &/show-ast macro-expansion*)
(&/|interpose "\n")
(&/fold str "")
(prn ?module "case")))]
]
- (&/flat-map% (partial analyse exo-type) macro-expansion))
+ (&/flat-map% (partial analyse exo-type) macro-expansion*))
[_]
(|do [[=output-t =args] (analyse-apply* analyse exo-type =fn-type ?args)]