aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser/base.clj
blob: a4c96c35085f9d43820d509d9056be6a258b0c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns lux.analyser.base
  (:require [clojure.core.match :as M :refer [match matchv]]
            clojure.core.match.array
            (lux [base :as & :refer [|let |do return fail]]
                 [type :as &type])))

;; [Exports]
(defn expr-type [syntax+]
  (matchv ::M/objects [syntax+]
    [[_ type]]
    (return type)))

(defn analyse-1 [analyse exo-type elem]
  (|do [output (analyse exo-type elem)]
    (matchv ::M/objects [output]
      [["lux;Cons" [x ["lux;Nil" _]]]]
      (return x)

      [_]
      (fail "[Analyser Error] Can't expand to other than 1 element."))))

(defn resolved-ident [ident]
  (|let [[?module ?name] ident]
    (|do [module* (if (= "" ?module)
                    &/get-module-name
                    (return ?module))]
      (return (&/ident->text (&/T module* ?name))))))