aboutsummaryrefslogtreecommitdiff
path: root/luxc
diff options
context:
space:
mode:
authorEduardo Julian2017-10-31 01:53:56 -0400
committerEduardo Julian2017-10-31 01:53:56 -0400
commite0f63b0cfda4d7dd0d233d13ce88b5da889dea02 (patch)
tree77a6a0db4fb096715743961d2efe0e5df256a293 /luxc
parent89f165331e97d6f0814238fbc7686daac3aa4888 (diff)
- Now, all special forms are handled as procedures.
- "lux case" now takes its branches as a non-empty record.
Diffstat (limited to 'luxc')
-rw-r--r--luxc/src/lux/analyser.clj2
-rw-r--r--luxc/src/lux/analyser/lux.clj6
2 files changed, 3 insertions, 5 deletions
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj
index 116102f37..2d029155e 100644
--- a/luxc/src/lux/analyser.clj
+++ b/luxc/src/lux/analyser.clj
@@ -145,7 +145,7 @@
(&&lux/analyse-program analyse optimize compile-program ?args ?body)))
"lux case"
- (|let [(&/$Cons ?value ?branches) parameters]
+ (|let [(&/$Cons ?value (&/$Cons [_ (&/$Record ?branches)] (&/$Nil))) parameters]
(&/with-analysis-meta cursor exo-type
(&&lux/analyse-case analyse exo-type ?value ?branches)))
diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj
index 8dc13680d..d6e82481d 100644
--- a/luxc/src/lux/analyser/lux.clj
+++ b/luxc/src/lux/analyser/lux.clj
@@ -393,9 +393,7 @@
)
(defn analyse-case [analyse exo-type ?value ?branches]
- (|do [:let [num-branches (&/|length ?branches)]
- _ (&/assert! (> num-branches 0) "[Analyser Error] Cannot have empty branches in \"case\" expression.")
- _ (&/assert! (even? num-branches) "[Analyser Error] Unbalanced branches in \"case\" expression.")
+ (|do [_ (&/assert! (> (&/|length ?branches) 0) "[Analyser Error] Cannot have empty branches in \"case\" expression.")
=value (&&/analyse-1+ analyse ?value)
:let [var?? (|case =value
[_ (&&/$var =var-kind)]
@@ -403,7 +401,7 @@
_
&/$None)]
- =match (&&case/analyse-branches analyse exo-type var?? (&&/expr-type* =value) (&/|as-pairs ?branches))
+ =match (&&case/analyse-branches analyse exo-type var?? (&&/expr-type* =value) ?branches)
_cursor &/cursor]
(return (&/|list (&&/|meta exo-type _cursor
(&&/$case =value =match)