aboutsummaryrefslogtreecommitdiff
path: root/luxc/src/lux/analyser/meta.clj
blob: 931558374c5f82b2979eb12fdec9aa4e2a8b96b1 (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
42
43
44
45
46
;;  Copyright (c) Eduardo Julian. All rights reserved.
;;  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
;;  If a copy of the MPL was not distributed with this file,
;;  You can obtain one at http://mozilla.org/MPL/2.0/.

(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"
  )