diff options
author | Eduardo Julian | 2017-10-31 01:53:56 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-10-31 01:53:56 -0400 |
commit | e0f63b0cfda4d7dd0d233d13ce88b5da889dea02 (patch) | |
tree | 77a6a0db4fb096715743961d2efe0e5df256a293 /luxc | |
parent | 89f165331e97d6f0814238fbc7686daac3aa4888 (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.clj | 2 | ||||
-rw-r--r-- | luxc/src/lux/analyser/lux.clj | 6 |
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) |