From a31500f27a29c34877e94188fad1abac3fefb576 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 1 May 2015 19:01:20 -0400 Subject: - Added the lux;seed slot to the compiler state. - Macro declarations are now handled at the compiler-phase instead of the analyser phase to avoid the posibility of trying to declare a yet-uncompiled macro (due to the macro-expansion of defmacro). - Added a makeshift implementation of existential types on top of BoundT (must migrate to a more permanent implementation). --- source/lux.lux | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'source/lux.lux') diff --git a/source/lux.lux b/source/lux.lux index 8e004913b..a385bb700 100644 --- a/source/lux.lux +++ b/source/lux.lux @@ -238,7 +238,8 @@ (#Cons [["lux;envs" (#AppT [List (#AppT [(#AppT [Env Text]) Void])])] (#Cons [["lux;types" (#AppT [(#AppT [Bindings Int]) Type])] (#Cons [["lux;host" HostState] - #Nil])])])])])]))]) + (#Cons [["lux;seed" Int] + #Nil])])])])])])]))]) Void])) (export' CompilerState) @@ -1284,7 +1285,8 @@ ## (let [[module name] ident] ## (case' state ## {#source source #modules modules #module-aliases module-aliases -## #envs envs #types types #host host} +## #envs envs #types types #host host +## #seed seed} ## (case' (:' ($' Maybe Macro) ## (do Maybe:Monad ## [bindings (get module modules) @@ -1306,7 +1308,8 @@ (let [[module name] ident] (case' state {#source source #modules modules #module-aliases module-aliases - #envs envs #types types #host host} + #envs envs #types types #host host + #seed seed} (case' (:' ($' Maybe Macro) (case' (get module modules) (#Some bindings) @@ -1335,6 +1338,32 @@ (-> ($' List ($' List a)) ($' List a))) (fold list:++ #Nil xs)) +## (def #export (macro-expand syntax state) +## (-> Syntax ($' Lux ($' List Syntax))) +## (case' syntax +## (#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol macro-name)]) args]))]) +## (do Lux:Monad +## [macro' (find-macro macro-name)] +## (case' macro' +## (#Some macro) +## (do Lux:Monad +## [expansion (macro args) +## expansion' (map% Lux:Monad macro-expand expansion)] +## (return (:' SyntaxList (join-list expansion')))) + +## #None +## (do Lux:Monad +## [parts' (map% Lux:Monad macro-expand (list& ($symbol macro-name) args))] +## (return (:' Syntax (list ($form (join-list parts')))))))) + +## (#Meta [_ (#Tuple members)]) +## (do Lux:Monad +## [members' (map% Lux:Monad macro-expand members)] +## (return (:' Syntax (list ($tuple (join-list members')))))) + +## _ +## (return (:' SyntaxList (list syntax))))) + (def #export (macro-expand syntax state) (-> Syntax ($' Lux ($' List Syntax))) (case' syntax @@ -1346,17 +1375,17 @@ (do Lux:Monad [expansion (macro args) expansion' (map% Lux:Monad macro-expand expansion)] - (return (:' SyntaxList (join-list expansion')))) + (;return (:' SyntaxList (join-list expansion')))) #None (do Lux:Monad [parts' (map% Lux:Monad macro-expand (list& ($symbol macro-name) args))] - (return (:' Syntax (list ($form (join-list parts')))))))) + (;return (:' Syntax (list ($form (join-list parts')))))))) (#Meta [_ (#Tuple members)]) (do Lux:Monad [members' (map% Lux:Monad macro-expand members)] - (return (:' Syntax (list ($tuple (join-list members')))))) + (;return (:' Syntax (list ($tuple (join-list members')))))) _ (return (:' SyntaxList (list syntax))))) -- cgit v1.2.3