aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser/meta.clj
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lux/analyser/meta.clj41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lux/analyser/meta.clj b/src/lux/analyser/meta.clj
new file mode 100644
index 000000000..6b9d91695
--- /dev/null
+++ b/src/lux/analyser/meta.clj
@@ -0,0 +1,41 @@
+;; 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 [deftags |let |do return return* fail fail* |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 DefMeta (Maybe DefMetaValue))"
+ (|case dict
+ (&/$Cons [k v] dict*)
+ (if (ident= k ident)
+ (&/Some$ v)
+ (meta-get ident dict*))
+
+ (&/$Nil)
+ &/None$))
+
+(do-template [<name> <tag-name>]
+ (def <name> (&/V tag-prefix <tag-name>))
+
+ type?-tag "type?"
+ alias-tag "alias"
+ macro?-tag "macro?"
+ export?-tag "export?"
+ tags-tag "tags"
+ )