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 /new-luxc/source/luxc/analyser.lux | |
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 '')
-rw-r--r-- | new-luxc/source/luxc/analyser.lux | 51 |
1 files changed, 4 insertions, 47 deletions
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<Meta> wrap (list)) - - (^ (list& patternH bodyH inputT)) - (do meta;Monad<Meta> - [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 [<special> <analyser>] - (^ (#;Form (list [_ (#;Text <special>)] type value))) - (<analyser> analyse eval type value)) - (["lux check" &&type;analyse-check] - ["lux coerce" &&type;analyse-coerce]) - - (^ (#;Form (list [_ (#;Text "lux check type")] valueC))) - (do meta;Monad<Meta> - [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<Meta> - [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 [<tag> <analyser>] (^ (#;Form (list& [_ (<tag> tag)] @@ -180,5 +137,5 @@ (&&function;analyse-apply analyse funcT =func args))) _ - (&;fail (format "Unrecognized syntax: " (%code ast))) + (&;throw Unrecognized-Syntax (%code ast)) ))))))) |