aboutsummaryrefslogtreecommitdiff
path: root/lux-bootstrapper
diff options
context:
space:
mode:
authorEduardo Julian2021-09-10 01:21:23 -0400
committerEduardo Julian2021-09-10 01:21:23 -0400
commitcd71a864ad5be13ed6ec6d046e0a2cb1087bdf94 (patch)
treeaf6366578f98f1a8e551f4da9f3ad230fd63a4dd /lux-bootstrapper
parentef77466323f85a3d1b65b46a3deb93652ef22085 (diff)
Migrated variants to the new syntax.
Diffstat (limited to '')
-rw-r--r--lux-bootstrapper/src/lux/analyser.clj33
-rw-r--r--lux-bootstrapper/src/lux/analyser/case.clj4
2 files changed, 21 insertions, 16 deletions
diff --git a/lux-bootstrapper/src/lux/analyser.clj b/lux-bootstrapper/src/lux/analyser.clj
index f837d8cee..ce571cae8 100644
--- a/lux-bootstrapper/src/lux/analyser.clj
+++ b/lux-bootstrapper/src/lux/analyser.clj
@@ -86,14 +86,28 @@
(|do [_ (&type/check exo-type &type/Text)]
(return (&/|list (&&/|meta exo-type location (&&/$text ?value)))))
- (&/$Tuple ?elems)
- (&/with-analysis-meta location exo-type
- (&&lux/analyse-record analyse exo-type ?elems))
-
(&/$Tag ?ident)
(&/with-analysis-meta location exo-type
(analyse-variant+ analyse exo-type ?ident &/$End))
+ (&/$Variant (&/$Item [command-meta command] parameters))
+ (|case command
+ (&/$Nat idx)
+ (|let [(&/$Item [_ (&/$Bit ?right)] parameters*) parameters]
+ (&/with-analysis-meta location exo-type
+ (&&lux/analyse-variant analyse (&/$Right exo-type) (if ?right (inc idx) idx) ?right parameters*)))
+
+ (&/$Tag ?ident)
+ (&/with-analysis-meta location exo-type
+ (analyse-variant+ analyse exo-type ?ident parameters))
+
+ _
+ (&/fail-with-loc (str "[Analyser Error] Unknown syntax: " (&/show-ast (&/T [(&/T ["" -1 -1]) token])))))
+
+ (&/$Tuple ?elems)
+ (&/with-analysis-meta location exo-type
+ (&&lux/analyse-record analyse exo-type ?elems))
+
(&/$Identifier ?ident)
(&/with-analysis-meta location exo-type
(&&lux/analyse-identifier analyse exo-type ?ident))
@@ -146,7 +160,7 @@
)) parameters]
(&/with-location location
(|case ?labels
- [_ (&/$Form ?tags)]
+ [_ (&/$Variant ?tags)]
(&&lux/analyse-def-type-tagged analyse optimize eval! compile-def ?name ?value false ?tags exported?)
[_ (&/$Tuple ?slots)]
@@ -176,15 +190,6 @@
:else
(&&common/analyse-proc analyse exo-type ?procedure parameters))))
-
- (&/$Nat idx)
- (|let [(&/$Item [_ (&/$Bit ?right)] parameters*) parameters]
- (&/with-analysis-meta location exo-type
- (&&lux/analyse-variant analyse (&/$Right exo-type) (if ?right (inc idx) idx) ?right parameters*)))
-
- (&/$Tag ?ident)
- (&/with-analysis-meta location exo-type
- (analyse-variant+ analyse exo-type ?ident parameters))
;; Pattern-matching syntax.
(&/$Variant ?pattern-matching)
diff --git a/lux-bootstrapper/src/lux/analyser/case.clj b/lux-bootstrapper/src/lux/analyser/case.clj
index 49d781c3b..5d2bb020a 100644
--- a/lux-bootstrapper/src/lux/analyser/case.clj
+++ b/lux-bootstrapper/src/lux/analyser/case.clj
@@ -358,7 +358,7 @@
[=test =kont] (analyse-pattern &/$None case-type unit-tuple kont)]
(return (&/T [($VariantTestAC (&/T [idx (&/|length group) =test])) =kont])))
- (&/$Form (&/$Item [_ (&/$Nat idx)] (&/$Item [_ (&/$Bit right?)] ?values)))
+ (&/$Variant (&/$Item [_ (&/$Nat idx)] (&/$Item [_ (&/$Bit right?)] ?values)))
(let [idx (if right? (inc idx) idx)]
(|do [value-type* (adjust-type value-type)
case-type (&type/sum-at idx value-type*)
@@ -369,7 +369,7 @@
(analyse-pattern &/$None case-type (&/T [(&/T ["" -1 -1]) (&/$Tuple ?values)]) kont))]
(return (&/T [($VariantTestAC (&/T [idx (&/|length (&type/flatten-sum value-type*)) =test])) =kont]))))
- (&/$Form (&/$Item [_ (&/$Tag ?ident)] ?values))
+ (&/$Variant (&/$Item [_ (&/$Tag ?ident)] ?values))
(|do [[=module =name] (&&/resolved-ident ?ident)
must-infer? (&type/unknown? value-type)
[_exported? variant-type** group idx] (&module/find-tag =module (str "#" =name))