1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-27 22:58:00 +03:00
mal/impls/janet/types.janet

76 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-11-08 16:24:51 +03:00
(defn make-nil
[]
{:tag :nil
:content "nil"})
(defn make-boolean
[bool]
{:tag :boolean
:content (string bool)})
2020-11-13 17:37:05 +03:00
(defn make-keyword
[a-str]
{:tag :keyword
:content a-str})
2020-11-06 15:58:07 +03:00
(defn make-number
[a-str]
{:tag :number
:content a-str})
2020-11-08 16:24:51 +03:00
(defn make-string
[a-str]
{:tag :string
:content a-str})
2020-11-06 15:58:07 +03:00
(defn make-symbol
[a-str]
{:tag :symbol
:content a-str})
(defn make-hash-map
2020-11-14 08:41:00 +03:00
[items &opt meta]
(default meta (make-nil))
2020-11-13 17:37:05 +03:00
(let [a-struct (if (dictionary? items)
items
(struct ;items))]
{:tag :hash-map
2020-11-14 08:41:00 +03:00
:content a-struct
:meta meta}))
2020-11-06 15:58:07 +03:00
(defn make-list
2020-11-14 08:41:00 +03:00
[items &opt meta]
(default meta (make-nil))
2020-11-06 15:58:07 +03:00
{:tag :list
2020-11-14 08:41:00 +03:00
:content items
:meta meta})
2020-11-06 15:58:07 +03:00
(defn make-vector
2020-11-14 08:41:00 +03:00
[items &opt meta]
(default meta (make-nil))
2020-11-06 15:58:07 +03:00
{:tag :vector
2020-11-14 08:41:00 +03:00
:content items
:meta meta})
2020-11-08 16:24:51 +03:00
(defn make-function
2020-11-14 08:41:00 +03:00
[a-fn &opt meta is-macro ast params env]
(default meta (make-nil))
(default is-macro false)
{:tag :function
:content a-fn
:meta meta
:is-macro is-macro
:ast ast
:params params
:env env})
2020-11-10 13:25:38 +03:00
(defn make-atom
[ast]
@{:tag :atom
:content ast})
2020-11-13 17:37:05 +03:00
(defn make-exception
[ast]
{:tag :exception
:content ast})