aboutsummaryrefslogtreecommitdiff
path: root/source/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2015-05-01 19:01:20 -0400
committerEduardo Julian2015-05-01 19:01:20 -0400
commita31500f27a29c34877e94188fad1abac3fefb576 (patch)
treec3f1a983b2764747de4ca1d1db36ac8b486de369 /source/lux.lux
parentf3cc638b9dd31d06b9cf3e51dff8fb6352f22c7c (diff)
- 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).
Diffstat (limited to 'source/lux.lux')
-rw-r--r--source/lux.lux41
1 files changed, 35 insertions, 6 deletions
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)))))