diff options
author | Eduardo Julian | 2017-12-02 01:10:12 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-12-02 01:10:12 -0400 |
commit | 46955edbe6cea9f367562b9fb17cef526109d9e0 (patch) | |
tree | 65a0ccbd9ea7bd02be39963783adac432d8f5e90 /stdlib | |
parent | f92c4dc2f813b40f14d240491daa665942165e7e (diff) |
- Added new "lux in-module" procedure for changing the module while analysing an expression.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux.lux | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index e7326f34b..22fc75e92 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1842,9 +1842,9 @@ #None (#Left ($_ text/compose "Unknown module: " module " @ " (ident/encode ident)))}))) -(def:''' (splice replace? untemplate elems) +(def:''' (splice replace? untemplate subst elems) #Nil - (-> Bool (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) + (-> Bool (-> Code ($' Meta Code)) Text ($' List Code) ($' Meta Code)) ("lux case" replace? {true ("lux case" (list/reverse elems) @@ -1855,7 +1855,9 @@ (do Monad<Meta> [lastO ("lux case" lastI {[_ (#Form (#Cons [[_ (#Symbol ["" "~+"])] (#Cons [spliced #Nil])]))] - (wrap spliced) + (wrap (if (text/= "" subst) + spliced + (form$ (list (text$ "lux in-module") (text$ subst) spliced)))) _ (do Monad<Meta> @@ -1866,7 +1868,9 @@ ("lux case" leftI {[_ (#Form (#Cons [[_ (#Symbol ["" "~+"])] (#Cons [spliced #Nil])]))] (wrap (form$ (list (symbol$ ["lux" "splice-helper"]) - spliced + (if (text/= "" subst) + spliced + (form$ (list (text$ "lux in-module") (text$ subst) spliced))) rightO))) _ @@ -1931,7 +1935,9 @@ (return (wrap-meta (form$ (list (tag$ ["lux" "Symbol"]) (tuple$ (list (text$ module) (text$ name))))))) [true [_ (#Form (#Cons [[_ (#Symbol ["" "~"])] (#Cons [unquoted #Nil])]))]] - (return unquoted) + (return (if (text/= "" subst) + unquoted + (form$ (list (text$ "lux in-module") (text$ subst) unquoted)))) [true [_ (#Form (#Cons [[_ (#Symbol ["" "~@"])] (#Cons [ident #Nil])]))]] (return (wrap-meta (form$ (list (tag$ ["lux" "Symbol"]) ident)))) @@ -1941,13 +1947,13 @@ [_ [meta (#Form elems)]] (do Monad<Meta> - [output (splice replace? (untemplate replace? subst) elems) + [output (splice replace? (untemplate replace? subst) subst elems) #let [[_ output'] (wrap-meta (form$ (list (tag$ ["lux" "Form"]) output)))]] (wrap [meta output'])) [_ [meta (#Tuple elems)]] (do Monad<Meta> - [output (splice replace? (untemplate replace? subst) elems) + [output (splice replace? (untemplate replace? subst) subst elems) #let [[_ output'] (wrap-meta (form$ (list (tag$ ["lux" "Tuple"]) output)))]] (wrap [meta output'])) |