diff options
author | Eduardo Julian | 2017-10-05 00:17:51 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-10-05 00:17:51 -0400 |
commit | 54815ade282ff4feb81d7d557188bde8111db376 (patch) | |
tree | 1cdb03715bca9d88557781113cadd7296d0327af /new-luxc/source/luxc/analyser.lux | |
parent | ece2c0ba374fdc05976e3f164517a11fb75b427f (diff) |
- Added tests for type-checking and type-coercion.
- Implemented "eval".
- Fixed bugs when analysing variants and tuples.
Diffstat (limited to 'new-luxc/source/luxc/analyser.lux')
-rw-r--r-- | new-luxc/source/luxc/analyser.lux | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/new-luxc/source/luxc/analyser.lux b/new-luxc/source/luxc/analyser.lux index 3272057f2..f17ec8496 100644 --- a/new-luxc/source/luxc/analyser.lux +++ b/new-luxc/source/luxc/analyser.lux @@ -76,16 +76,12 @@ body))) (&&function;analyse-function analyse func-name arg-name body) - (^ (#;Form (list [_ (#;Symbol ["" "_lux_check"])] - type - value))) - (&&type;analyse-check analyse eval type value) - - (^ (#;Form (list [_ (#;Symbol ["" "_lux_coerce"])] - type - value))) - (&&type;analyse-coerce analyse eval type value) - + (^template [<proc> <analyser>] + (^ (#;Form (list [_ (#;Symbol ["" <proc>])] type value))) + (<analyser> analyse eval type value)) + (["_lux_check" &&type;analyse-check] + ["_lux_coerce" &&type;analyse-coerce]) + (^ (#;Form (list& [_ (#;Text proc-name)] proc-args))) (&&procedure;analyse-procedure analyse proc-name proc-args) @@ -96,13 +92,17 @@ [paired (to-branches branches)] (&&case;analyse-case analyse input paired)) - (^ (#;Form (list [_ (#;Nat tag)] - value))) - (&&structure;analyse-sum analyse tag value) + (^template [<tag> <analyser>] + (^ (#;Form (list& [_ (<tag> tag)] + values))) + (case values + (#;Cons value #;Nil) + (<analyser> analyse tag value) - (^ (#;Form (list [_ (#;Tag tag)] - value))) - (&&structure;analyse-tagged-sum analyse tag value) + _ + (<analyser> analyse tag (` [(~@ values)])))) + ([#;Nat &&structure;analyse-sum] + [#;Tag &&structure;analyse-tagged-sum]) (^ (#;Form (list& func args))) (do Monad<Lux> |