From e0f63b0cfda4d7dd0d233d13ce88b5da889dea02 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Tue, 31 Oct 2017 01:53:56 -0400
Subject: - Now, all special forms are handled as procedures. - "lux case" now
takes its branches as a non-empty record.
---
new-luxc/source/luxc/analyser.lux | 51 +++------------------------------------
1 file changed, 4 insertions(+), 47 deletions(-)
(limited to 'new-luxc/source/luxc/analyser.lux')
diff --git a/new-luxc/source/luxc/analyser.lux b/new-luxc/source/luxc/analyser.lux
index f0712794d..04d8d58b7 100644
--- a/new-luxc/source/luxc/analyser.lux
+++ b/new-luxc/source/luxc/analyser.lux
@@ -8,7 +8,7 @@
[meta]
(meta [type]
(type ["tc" check]))
- [host #+ do-to])
+ [host])
(luxc ["&" base]
[";L" host]
(lang ["la" analysis])
@@ -18,9 +18,7 @@
["&&;" function]
["&&;" primitive]
["&&;" reference]
- ["&&;" type]
["&&;" structure]
- ["&&;" case]
["&&;" procedure]))
(for {"JVM" (as-is (host;import java.lang.reflect.Method
@@ -53,20 +51,7 @@
})
(exception: #export Macro-Expression-Must-Have-Single-Expansion)
-
-(def: (to-branches raw)
- (-> (List Code) (Meta (List [Code Code])))
- (case raw
- (^ (list))
- (:: meta;Monad wrap (list))
-
- (^ (list& patternH bodyH inputT))
- (do meta;Monad
- [outputT (to-branches inputT)]
- (wrap (list& [patternH bodyH] outputT)))
-
- _
- (&;fail "Uneven expressions for pattern-matching.")))
+(exception: #export Unrecognized-Syntax)
(def: #export (analyser eval)
(-> &;Eval &;Analyser)
@@ -105,36 +90,8 @@
(#;Symbol reference)
(&&reference;analyse-reference reference)
- (^ (#;Form (list [_ (#;Text "lux function")]
- [_ (#;Symbol ["" func-name])]
- [_ (#;Symbol ["" arg-name])]
- body)))
- (&&function;analyse-function analyse func-name arg-name body)
-
- (^template [ ]
- (^ (#;Form (list [_ (#;Text )] type value)))
- ( analyse eval type value))
- (["lux check" &&type;analyse-check]
- ["lux coerce" &&type;analyse-coerce])
-
- (^ (#;Form (list [_ (#;Text "lux check type")] valueC)))
- (do meta;Monad
- [valueA (&;with-expected-type Type
- (analyse valueC))
- expected meta;expected-type
- _ (&;with-type-env
- (tc;check expected Type))]
- (wrap valueA))
-
- (^ (#;Form (list& [_ (#;Text "lux case")]
- input
- branches)))
- (do meta;Monad
- [paired (to-branches branches)]
- (&&case;analyse-case analyse input paired))
-
(^ (#;Form (list& [_ (#;Text proc-name)] proc-args)))
- (&&procedure;analyse-procedure analyse proc-name proc-args)
+ (&&procedure;analyse-procedure analyse eval proc-name proc-args)
(^template [ ]
(^ (#;Form (list& [_ ( tag)]
@@ -180,5 +137,5 @@
(&&function;analyse-apply analyse funcT =func args)))
_
- (&;fail (format "Unrecognized syntax: " (%code ast)))
+ (&;throw Unrecognized-Syntax (%code ast))
)))))))
--
cgit v1.2.3