aboutsummaryrefslogtreecommitdiff
path: root/luxc/src/lux/analyser/meta.clj
blob: 120bab1b016ccd157fc16b3414148942b32447c1 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(ns lux.analyser.meta
  (:require (clojure [template :refer [do-template]])
            clojure.core.match
            clojure.core.match.array
            (lux [base :as & :refer [|let |do return return* |case]])))

;; [Utils]
(defn ^:private ident= [x y]
  (|let [[px nx] x
         [py ny] y]
    (and (= px py)
         (= nx ny))))

(def ^:private tag-prefix "lux")

;; [Values]
(defn meta-get [ident dict]
  "(-> Ident Anns (Maybe Ann-Value))"
  (|case dict
    (&/$Cons [k v] dict*)
    (if (ident= k ident)
      (&/$Some v)
      (meta-get ident dict*))

    (&/$Nil)
    &/$None

    _
    (assert false (println-str (&/adt->text ident)
                               (&/adt->text dict)))))

(do-template [<name> <tag-name>]
  (def <name> (&/T [tag-prefix <tag-name>]))

  type?-tag   "type?"
  alias-tag   "alias"
  macro?-tag  "macro?"
  export?-tag "export?"
  tags-tag    "tags"
  imports-tag "imports"
  )