diff options
author | Eduardo Julian | 2015-02-17 16:56:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-02-17 16:56:07 -0400 |
commit | a4c15674a3ac87e635ffa92a907fab24b54d509c (patch) | |
tree | 7484e8f035a013e7c80541d707986269885bc1f7 /src/lux/analyser/base.clj | |
parent | 2a662bb1f9c32c76037b0a478c7d206bf73babfb (diff) |
Corrections to the super-refactoring: part 2
## Reorganized a lot of analyser code and got the analyser to compile.
Diffstat (limited to 'src/lux/analyser/base.clj')
-rw-r--r-- | src/lux/analyser/base.clj | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj new file mode 100644 index 000000000..713b58f18 --- /dev/null +++ b/src/lux/analyser/base.clj @@ -0,0 +1,32 @@ +(ns lux.analyser.base + (:require [clojure.core.match :refer [match]] + (lux [util :as &util :refer [exec return fail + try-all-m map-m mapcat-m reduce-m + assert!]]))) + +;; [Resources] +(defn expr-type [syntax+] + (match syntax+ + [::Expression _ type] + (return type) + + _ + (fail "Can't retrieve the type of a non-expression."))) + +(defn analyse-1 [analyse elem] + (exec [output (analyse elem)] + (match output + ([x] :seq) + (return x) + + :else + (fail "[Analyser Error] Can't expand to other than 1 element.")))) + +(defn analyse-2 [analyse el1 el2] + (exec [output (mapcat-m analyse (list el1 el2))] + (match output + ([x y] :seq) + (return [x y]) + + :else + (fail "[Analyser Error] Can't expand to other than 2 elements.")))) |