aboutsummaryrefslogtreecommitdiff
path: root/luxc/src/lux/analyser.clj
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/analyser.clj72
1 files changed, 36 insertions, 36 deletions
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj
index abdd0acd7..af272fa91 100644
--- a/luxc/src/lux/analyser.clj
+++ b/luxc/src/lux/analyser.clj
@@ -22,8 +22,8 @@
group (&&module/tag-group module tag-name)
:let [is-last? (= idx (dec (&/|length group)))]]
(if (= 1 (&/|length group))
- (|do [_cursor &/cursor]
- (analyse exo-type (&/T [_cursor (&/$Tuple values)])))
+ (|do [_location &/location]
+ (analyse exo-type (&/T [_location (&/$Tuple values)])))
(|case exo-type
(&/$Var id)
(|do [? (&type/bound? id)]
@@ -31,9 +31,9 @@
(&&lux/analyse-variant analyse (&/$Right exo-type) idx is-last? values)
(|do [wanted-type (&&module/tag-type module tag-name)
wanted-type* (&type/instantiate-inference wanted-type)
- [[variant-type variant-cursor] variant-analysis] (&&/cap-1 (&&lux/analyse-variant analyse (&/$Left wanted-type*) idx is-last? values))
+ [[variant-type variant-location] variant-analysis] (&&/cap-1 (&&lux/analyse-variant analyse (&/$Left wanted-type*) idx is-last? values))
_ (&type/check exo-type variant-type)]
- (return (&/|list (&&/|meta exo-type variant-cursor variant-analysis))))))
+ (return (&/|list (&&/|meta exo-type variant-location variant-analysis))))))
_
(&&lux/analyse-variant analyse (&/$Right exo-type) idx is-last? values)
@@ -43,23 +43,23 @@
(defn ^:private just-analyse [analyser syntax]
(&type/with-var
(fn [?var]
- (|do [[[?output-type ?output-cursor] ?output-term] (&&/analyse-1 analyser ?var syntax)]
+ (|do [[[?output-type ?output-location] ?output-term] (&&/analyse-1 analyser ?var syntax)]
(|case [?var ?output-type]
[(&/$Var ?e-id) (&/$Var ?a-id)]
(if (= ?e-id ?a-id)
(|do [=output-type (&type/clean ?var ?output-type)]
- (return (&&/|meta =output-type ?output-cursor ?output-term)))
+ (return (&&/|meta =output-type ?output-location ?output-term)))
(|do [=output-type (&type/clean ?var ?var)]
- (return (&&/|meta =output-type ?output-cursor ?output-term))))
+ (return (&&/|meta =output-type ?output-location ?output-term))))
[_ _]
(|do [=output-type (&type/clean ?var ?output-type)]
- (return (&&/|meta =output-type ?output-cursor ?output-term))))
+ (return (&&/|meta =output-type ?output-location ?output-term))))
))))
(defn ^:private analyse-ast [optimize eval! compile-module ^"[Ljava.lang.Object;" compilers exo-type ?token]
(|let [analyse (partial analyse-ast optimize eval! compile-module compilers)
- [cursor token] ?token
+ [location token] ?token
compile-def (aget compilers 0)
compile-program (aget compilers 1)
macro-caller (aget compilers 2)]
@@ -67,42 +67,42 @@
;; Standard special forms
(&/$Bit ?value)
(|do [_ (&type/check exo-type &type/Bit)]
- (return (&/|list (&&/|meta exo-type cursor (&&/$bit ?value)))))
+ (return (&/|list (&&/|meta exo-type location (&&/$bit ?value)))))
(&/$Nat ?value)
(|do [_ (&type/check exo-type &type/Nat)]
- (return (&/|list (&&/|meta exo-type cursor (&&/$nat ?value)))))
+ (return (&/|list (&&/|meta exo-type location (&&/$nat ?value)))))
(&/$Int ?value)
(|do [_ (&type/check exo-type &type/Int)]
- (return (&/|list (&&/|meta exo-type cursor (&&/$int ?value)))))
+ (return (&/|list (&&/|meta exo-type location (&&/$int ?value)))))
(&/$Rev ?value)
(|do [_ (&type/check exo-type &type/Rev)]
- (return (&/|list (&&/|meta exo-type cursor (&&/$rev ?value)))))
+ (return (&/|list (&&/|meta exo-type location (&&/$rev ?value)))))
(&/$Frac ?value)
(|do [_ (&type/check exo-type &type/Frac)]
- (return (&/|list (&&/|meta exo-type cursor (&&/$frac ?value)))))
+ (return (&/|list (&&/|meta exo-type location (&&/$frac ?value)))))
(&/$Text ?value)
(|do [_ (&type/check exo-type &type/Text)]
- (return (&/|list (&&/|meta exo-type cursor (&&/$text ?value)))))
+ (return (&/|list (&&/|meta exo-type location (&&/$text ?value)))))
(&/$Tuple ?elems)
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-tuple analyse (&/$Right exo-type) ?elems))
(&/$Record ?elems)
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-record analyse exo-type ?elems))
(&/$Tag ?ident)
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(analyse-variant+ analyse exo-type ?ident &/$Nil))
(&/$Identifier ?ident)
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-identifier analyse exo-type ?ident))
(&/$Form (&/$Cons [command-meta command] parameters))
@@ -113,7 +113,7 @@
(|let [(&/$Cons ?type
(&/$Cons ?value
(&/$Nil))) parameters]
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-ann analyse eval! exo-type ?type ?value)))
"lux check type"
@@ -124,7 +124,7 @@
(|let [(&/$Cons ?type
(&/$Cons ?value
(&/$Nil))) parameters]
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-coerce analyse eval! exo-type ?type ?value)))
"lux def"
@@ -134,7 +134,7 @@
(&/$Cons [_ (&/$Bit exported?)]
(&/$Nil)))
)) parameters]
- (&/with-cursor cursor
+ (&/with-location location
(&&lux/analyse-def analyse optimize eval! compile-def ?name ?value ?meta exported?)))
"lux def alias"
@@ -142,7 +142,7 @@
(&/$Cons [_ (&/$Identifier ?original)]
(&/$Nil)
)) parameters]
- (&/with-cursor cursor
+ (&/with-location location
(&&lux/analyse-def-alias ?alias ?original)))
"lux def type tagged"
@@ -153,27 +153,27 @@
(&/$Cons [_ (&/$Bit exported?)]
(&/$Nil))))
)) parameters]
- (&/with-cursor cursor
+ (&/with-location location
(&&lux/analyse-def-type-tagged analyse optimize eval! compile-def ?name ?value ?meta ?tags exported?)))
"lux def program"
(|let [(&/$Cons ?program (&/$Nil)) parameters]
- (&/with-cursor cursor
+ (&/with-location location
(&&lux/analyse-program analyse optimize compile-program ?program)))
"lux def module"
(|let [(&/$Cons ?meta (&/$Cons ?imports (&/$Nil))) parameters]
- (&/with-cursor cursor
+ (&/with-location location
(&&lux/analyse-module analyse optimize eval! compile-module ?meta ?imports)))
"lux in-module"
(|let [(&/$Cons [_ (&/$Text ?module)] (&/$Cons ?expr (&/$Nil))) parameters]
- (&/with-cursor cursor
+ (&/with-location location
(&/with-module ?module
(analyse exo-type ?expr))))
;; else
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(cond (.startsWith ^String ?procedure "jvm")
(|do [_ &/jvm-host]
(&&jvm/analyse-host analyse exo-type compilers ?procedure parameters))
@@ -183,30 +183,30 @@
(&/$Nat idx)
(|let [(&/$Cons [_ (&/$Bit ?right)] parameters*) parameters]
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-variant analyse (&/$Right exo-type) (if ?right (inc idx) idx) ?right parameters*)))
(&/$Tag ?ident)
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(analyse-variant+ analyse exo-type ?ident parameters))
;; Pattern-matching syntax.
(&/$Record ?pattern-matching)
(|let [(&/$Cons ?input (&/$Nil)) parameters]
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-case analyse exo-type ?input ?pattern-matching)))
;; Function syntax.
(&/$Tuple (&/$Cons [_ (&/$Identifier "" ?self)]
(&/$Cons [_ (&/$Identifier "" ?arg)] (&/$Nil))))
(|let [(&/$Cons ?body (&/$Nil)) parameters]
- (&/with-analysis-meta cursor exo-type
+ (&/with-analysis-meta location exo-type
(&&lux/analyse-function analyse exo-type ?self ?arg ?body)))
_
- (&/with-cursor cursor
+ (&/with-location location
(|do [=fn (just-analyse analyse (&/T [command-meta command]))]
- (&&lux/analyse-apply analyse cursor exo-type macro-caller =fn parameters))))
+ (&&lux/analyse-apply analyse location exo-type macro-caller =fn parameters))))
_
(&/fail-with-loc (str "[Analyser Error] Unknown syntax: " (&/show-ast (&/T [(&/T ["" -1 -1]) token]))))
@@ -218,9 +218,9 @@
(&/flat-map% (partial analyse-ast optimize eval! compile-module compilers &type/Nothing) asts)))
(defn clean-output [?var analysis]
- (|do [:let [[[?output-type ?output-cursor] ?output-term] analysis]
+ (|do [:let [[[?output-type ?output-location] ?output-term] analysis]
=output-type (&type/clean ?var ?output-type)]
- (return (&&/|meta =output-type ?output-cursor ?output-term))))
+ (return (&&/|meta =output-type ?output-location ?output-term))))
(defn repl-analyse [optimize eval! compile-module compilers]
(|do [asts &parser/parse]