diff options
author | Eduardo Julian | 2015-03-10 01:39:35 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-03-10 01:39:35 -0400 |
commit | e2fcc7ebbb1f423a3137aa5525b9409f870fe191 (patch) | |
tree | a9765d5d44be59bae48b1a411444f1112b1a00a4 /src/lux/analyser/host.clj | |
parent | a386d0c4688b8749db3e4d612658774a24bc61a2 (diff) |
- Modified the compiler so parser syntax tokens are stored in the same format as lux data-structures, to ease communication between the compiler & macros.
Diffstat (limited to 'src/lux/analyser/host.clj')
-rw-r--r-- | src/lux/analyser/host.clj | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index 5b96a2a74..f6f20d695 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -1,6 +1,7 @@ (ns lux.analyser.host (:require (clojure [template :refer [do-template]]) - [clojure.core.match :refer [match]] + [clojure.core.match :as M :refer [match matchv]] + clojure.core.match.array (lux [base :as & :refer [exec return fail try-all-m map-m mapcat-m reduce-m assert!]] @@ -10,12 +11,20 @@ (lux.analyser [base :as &&]))) ;; [Utils] +(defn ^:private ->seq [xs] + (matchv ::M/objects [xs] + [["Nil" _]] + (list) + + [["Cons" [x xs*]]] + (cons x (->seq xs*)))) + (defn ^:private extract-ident [ident] - (match ident - [::&parser/Ident ?ident] + (matchv ::M/objects [ident] + [["Ident" ?ident]] (return ?ident) - _ + [_] (fail "[Analyser Error] Can't extract Ident."))) ;; [Resources] @@ -156,16 +165,22 @@ (defn analyse-jvm-interface [analyse ?name ?members] ;; (prn 'analyse-jvm-interface ?name ?members) (exec [?members (map-m (fn [member] - (match member - [::&parser/Form ([[::&parser/Ident ":"] [::&parser/Ident ?member-name] - [::&parser/Form ([[::&parser/Ident "->"] [::&parser/Tuple ?inputs] [::&parser/Ident ?output]] :seq)]] - :seq)] - (exec [?inputs (map-m extract-ident ?inputs)] - (return [?member-name [?inputs ?output]])) + ;; (prn 'analyse-jvm-interface (&/show-ast member)) + (matchv ::M/objects [member] + [["Form" ["Cons" [["Ident" ":"] + ["Cons" [["Ident" ?member-name] + ["Cons" [["Form" ["Cons" [["Ident" "->"] + ["Cons" [["Tuple" ?inputs] + ["Cons" [["Ident" ?output] + ["Nil" _]]]]]]]] + ["Nil" _]]]]]]]]] + (do ;; (prn 'analyse-jvm-interface ?member-name ?inputs ?output) + (exec [?inputs (map-m extract-ident (&/->seq ?inputs))] + (return [?member-name [?inputs ?output]]))) - _ + [_] (fail "[Analyser Error] Invalid method signature!"))) - ?members) + (&/->seq ?members)) :let [=methods (into {} (for [[method [inputs output]] ?members] [method {:access :public :type [inputs output]}]))] |