From cc16e4ba982a9a2b228c7b40d927f539c9e1a5c8 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 4 Apr 2019 18:30:46 -0400 Subject: Changed the order of the inputs to the common extensions. --- luxc/src/lux/analyser/proc/common.clj | 75 +++++++++++++++-------------------- 1 file changed, 33 insertions(+), 42 deletions(-) (limited to 'luxc/src') diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index fbdf05546..8f51521d8 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -9,13 +9,13 @@ (defn- analyse-lux-is [analyse exo-type ?values] (&type/with-var (fn [$var] - (|do [:let [(&/$Cons left (&/$Cons right (&/$Nil))) ?values] - =left (&&/analyse-1 analyse $var left) - =right (&&/analyse-1 analyse $var right) + (|do [:let [(&/$Cons reference (&/$Cons sample (&/$Nil))) ?values] + =reference (&&/analyse-1 analyse $var reference) + =sample (&&/analyse-1 analyse $var sample) _ (&type/check exo-type &type/Bit) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["lux" "is"]) (&/|list =left =right) (&/|list))))))))) + (&&/$proc (&/T ["lux" "is"]) (&/|list =sample =reference) (&/|list))))))))) (defn- analyse-lux-try [analyse exo-type ?values] (&type/with-var @@ -31,40 +31,44 @@ (do-template [ ] (defn- [analyse exo-type ?values] - (|do [:let [(&/$Cons x (&/$Cons y (&/$Nil))) ?values] - =x (&&/analyse-1 analyse x) - =y (&&/analyse-1 analyse y) + (|do [:let [(&/$Cons reference (&/$Cons sample (&/$Nil))) ?values] + =reference (&&/analyse-1 analyse reference) + =sample (&&/analyse-1 analyse sample) _ (&type/check exo-type ) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ) (&/|list =x =y) (&/|list))))))) + (&&/$proc (&/T ) (&/|list =sample =reference) (&/|list))))))) analyse-text-eq ["text" "="] &type/Text &type/Bit analyse-text-lt ["text" "<"] &type/Text &type/Bit - analyse-text-concat ["text" "concat"] &type/Text &type/Text ) -(do-template [ ] - (defn- [analyse exo-type ?values] - (|do [:let [(&/$Cons text (&/$Cons part (&/$Cons start (&/$Nil)))) ?values] - =text (&&/analyse-1 analyse &type/Text text) - =part (&&/analyse-1 analyse &type/Text part) - =start (&&/analyse-1 analyse &type/Nat start) - _ (&type/check exo-type ) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["text" ]) - (&/|list =text =part =start) - (&/|list))))))) +(defn- analyse-text-concat [analyse exo-type ?values] + (|do [:let [(&/$Cons parameter (&/$Cons subject (&/$Nil))) ?values] + =parameter (&&/analyse-1 analyse &type/Text parameter) + =subject (&&/analyse-1 analyse &type/Text subject) + _ (&type/check exo-type &type/Text) + _cursor &/cursor] + (return (&/|list (&&/|meta exo-type _cursor + (&&/$proc (&/T ["text" "concat"]) (&/|list =parameter =subject) (&/|list))))))) - analyse-text-index "index" (&/$Apply &type/Nat &type/Maybe) - ) +(defn- analyse-text-index [analyse exo-type ?values] + (|do [:let [(&/$Cons start (&/$Cons part (&/$Cons text (&/$Nil)))) ?values] + =start (&&/analyse-1 analyse &type/Nat start) + =part (&&/analyse-1 analyse &type/Text part) + =text (&&/analyse-1 analyse &type/Text text) + _ (&type/check exo-type (&/$Apply &type/Nat &type/Maybe)) + _cursor &/cursor] + (return (&/|list (&&/|meta exo-type _cursor + (&&/$proc (&/T ["text" "index"]) + (&/|list =text =part =start) + (&/|list))))))) (defn- analyse-text-clip [analyse exo-type ?values] - (|do [:let [(&/$Cons text (&/$Cons from (&/$Cons to (&/$Nil)))) ?values] - =text (&&/analyse-1 analyse &type/Text text) + (|do [:let [(&/$Cons from (&/$Cons to (&/$Cons text (&/$Nil)))) ?values] =from (&&/analyse-1 analyse &type/Nat from) =to (&&/analyse-1 analyse &type/Nat to) + =text (&&/analyse-1 analyse &type/Text text) _ (&type/check exo-type &type/Text) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor @@ -135,31 +139,18 @@ (let [inputT outputT ] (defn- [analyse exo-type ?values] - (|do [:let [(&/$Cons subjectC (&/$Cons paramC (&/$Nil))) ?values] + (|do [:let [(&/$Cons parameterC (&/$Cons subjectC (&/$Nil))) ?values] + parameterA (&&/analyse-1 analyse parameterC) subjectA (&&/analyse-1 analyse subjectC) - paramA (&&/analyse-1 analyse paramC) _ (&type/check exo-type ) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ) (&/|list subjectA paramA) (&/|list)))))))) + (&&/$proc (&/T ) (&/|list subjectA parameterA) (&/|list)))))))) analyse-i64-eq ["i64" "="] (&/$Apply &type/Any &type/I64) &type/Bit analyse-i64-add ["i64" "+"] (&/$Apply &type/Any &type/I64) &type/I64 analyse-i64-sub ["i64" "-"] (&/$Apply &type/Any &type/I64) &type/I64 - ) - -(do-template [ ] - (let [inputT - outputT ] - (defn- [analyse exo-type ?values] - (|do [:let [(&/$Cons x (&/$Cons y (&/$Nil))) ?values] - =x (&&/analyse-1 analyse x) - =y (&&/analyse-1 analyse y) - _ (&type/check exo-type ) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ) (&/|list =x =y) (&/|list)))))))) - + analyse-int-mul ["int" "*"] &type/Int &type/Int analyse-int-div ["int" "/"] &type/Int &type/Int analyse-int-rem ["int" "%"] &type/Int &type/Int -- cgit v1.2.3