aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/tool/compiler/default/init.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/default/platform.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/statement.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/phase/statement.lux90
-rw-r--r--stdlib/source/lux/tool/compiler/phase/statement/total.lux62
-rw-r--r--stdlib/source/lux/tool/compiler/program.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/statement.lux46
7 files changed, 108 insertions, 108 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/init.lux b/stdlib/source/lux/tool/compiler/default/init.lux
index 0958c3b01..5de9970f6 100644
--- a/stdlib/source/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/lux/tool/compiler/default/init.lux
@@ -19,6 +19,7 @@
["/." // (#+ Instancer)
["." analysis]
["." synthesis]
+ ["." statement]
["." host]
["." phase
[macro (#+ Expander)]
@@ -26,8 +27,7 @@
["." module]]
[".P" synthesis]
["." translation]
- ["." statement
- [".S" total]]
+ [".P" statement]
["." extension
[".E" analysis]
[".E" synthesis]
@@ -131,7 +131,7 @@
(def: (iteration expander reader)
(-> Expander Reader <Operation>)
- (let [execute (totalS.phase expander)]
+ (let [execute (statementP.phase expander)]
(do phase.monad
[code (statement.lift-analysis
(..read reader))
diff --git a/stdlib/source/lux/tool/compiler/default/platform.lux b/stdlib/source/lux/tool/compiler/default/platform.lux
index 959478f28..f9b4d4bd3 100644
--- a/stdlib/source/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/lux/tool/compiler/default/platform.lux
@@ -11,10 +11,10 @@
["." init]
["." syntax]
["/." //
+ ["." statement]
["." phase
[macro (#+ Expander)]
- ["." translation]
- ["." statement]]
+ ["." translation]]
["." cli (#+ Configuration)]
[meta
["." archive]
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
index 37ff93b9c..749924650 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
@@ -19,10 +19,10 @@
["." module]
["." type]]
["." translation]
- ["." statement (#+ Operation Handler Bundle)]
[//
["." analysis]
- ["." synthesis (#+ Synthesis)]]]])
+ ["." synthesis (#+ Synthesis)]
+ ["." statement (#+ Operation Handler Bundle)]]]])
## TODO: Inline "evaluate!'" into "evaluate!" ASAP
(def: (evaluate!' translate code//type codeS)
diff --git a/stdlib/source/lux/tool/compiler/phase/statement.lux b/stdlib/source/lux/tool/compiler/phase/statement.lux
index ba84d146f..87736643c 100644
--- a/stdlib/source/lux/tool/compiler/phase/statement.lux
+++ b/stdlib/source/lux/tool/compiler/phase/statement.lux
@@ -1,46 +1,62 @@
(.module:
- [lux #*]
+ [lux #*
+ [control
+ ["." monad (#+ do)]
+ ["." exception (#+ exception:)]]
+ [data
+ [text
+ format]]
+ ["." macro]]
["." //
- ["." translation]
- ["." extension]
+ ["//." macro (#+ Expander)]
+ ["//." extension]
+ [".P" analysis
+ ["." type]]
[//
- ["." analysis]
- ["." synthesis]]])
+ ["/" statement (#+ Phase)]
+ ["." analysis]]])
-(type: #export (Component state phase)
- {#state state
- #phase phase})
+(exception: #export (not-a-statement {code Code})
+ (exception.report
+ ["Statement" (%code code)]))
-(type: #export (State anchor expression statement)
- {#analysis (Component analysis.State+
- analysis.Phase)
- #synthesis (Component synthesis.State+
- synthesis.Phase)
- #translation (Component (translation.State+ anchor expression statement)
- (translation.Phase anchor expression statement))})
+(exception: #export (not-a-macro-call {code Code})
+ (exception.report
+ ["Code" (%code code)]))
-(do-template [<special> <general>]
- [(type: #export (<special> anchor expression statement)
- (<general> (..State anchor expression statement) Code Any))]
+(exception: #export (macro-was-not-found {name Name})
+ (exception.report
+ ["Name" (%name name)]))
- [State+ extension.State]
- [Operation extension.Operation]
- [Phase extension.Phase]
- [Handler extension.Handler]
- [Bundle extension.Bundle]
- )
+(def: #export (phase expander)
+ (-> Expander Phase)
+ (let [analyze (analysisP.phase expander)]
+ (function (compile code)
+ (case code
+ (^ [_ (#.Form (list& [_ (#.Text name)] inputs))])
+ (//extension.apply compile [name inputs])
-(do-template [<name> <component> <operation>]
- [(def: #export (<name> operation)
- (All [anchor expression statement output]
- (-> (<operation> output)
- (Operation anchor expression statement output)))
- (extension.lift
- (//.sub [(get@ [<component> #..state])
- (set@ [<component> #..state])]
- operation)))]
+ (^ [_ (#.Form (list& macro inputs))])
+ (do //.monad
+ [expansion (/.lift-analysis
+ (do @
+ [macroA (type.with-type Macro
+ (analyze macro))]
+ (case macroA
+ (^ (analysis.constant macro-name))
+ (do @
+ [?macro (//extension.lift (macro.find-macro macro-name))
+ macro (case ?macro
+ (#.Some macro)
+ (wrap macro)
+
+ #.None
+ (//.throw macro-was-not-found macro-name))]
+ (//extension.lift (//macro.expand expander macro-name macro inputs)))
+
+ _
+ (//.throw not-a-macro-call code))))]
+ (monad.map @ compile expansion))
- [lift-analysis #..analysis analysis.Operation]
- [lift-synthesis #..synthesis synthesis.Operation]
- [lift-translation #..translation (translation.Operation anchor expression statement)]
- )
+ _
+ (//.throw not-a-statement code)))))
diff --git a/stdlib/source/lux/tool/compiler/phase/statement/total.lux b/stdlib/source/lux/tool/compiler/phase/statement/total.lux
deleted file mode 100644
index 166425ffa..000000000
--- a/stdlib/source/lux/tool/compiler/phase/statement/total.lux
+++ /dev/null
@@ -1,62 +0,0 @@
-(.module:
- [lux #*
- [control
- ["." monad (#+ do)]
- ["." exception (#+ exception:)]]
- [data
- [text
- format]]
- ["." macro]]
- ["." // (#+ Phase)
- ["/." //
- ["///." macro (#+ Expander)]
- [".P" analysis
- ["." type]]
- ["." extension]
- [//
- ["." analysis]]]])
-
-(exception: #export (not-a-statement {code Code})
- (exception.report
- ["Statement" (%code code)]))
-
-(exception: #export (not-a-macro-call {code Code})
- (exception.report
- ["Code" (%code code)]))
-
-(exception: #export (macro-was-not-found {name Name})
- (exception.report
- ["Name" (%name name)]))
-
-(def: #export (phase expander)
- (-> Expander Phase)
- (let [analyze (analysisP.phase expander)]
- (function (compile code)
- (case code
- (^ [_ (#.Form (list& [_ (#.Text name)] inputs))])
- (extension.apply compile [name inputs])
-
- (^ [_ (#.Form (list& macro inputs))])
- (do ///.monad
- [expansion (//.lift-analysis
- (do @
- [macroA (type.with-type Macro
- (analyze macro))]
- (case macroA
- (^ (analysis.constant macro-name))
- (do @
- [?macro (extension.lift (macro.find-macro macro-name))
- macro (case ?macro
- (#.Some macro)
- (wrap macro)
-
- #.None
- (///.throw macro-was-not-found macro-name))]
- (extension.lift (///macro.expand expander macro-name macro inputs)))
-
- _
- (///.throw not-a-macro-call code))))]
- (monad.map @ compile expansion))
-
- _
- (///.throw not-a-statement code)))))
diff --git a/stdlib/source/lux/tool/compiler/program.lux b/stdlib/source/lux/tool/compiler/program.lux
index 167f64221..265277ac7 100644
--- a/stdlib/source/lux/tool/compiler/program.lux
+++ b/stdlib/source/lux/tool/compiler/program.lux
@@ -15,10 +15,10 @@
["." console]]
[tool
[compiler
+ ["." statement]
[phase
[macro (#+ Expander)]
- ["." translation]
- ["." statement]]
+ ["." translation]]
[default
["." platform (#+ Platform)]
["." syntax]]]
diff --git a/stdlib/source/lux/tool/compiler/statement.lux b/stdlib/source/lux/tool/compiler/statement.lux
new file mode 100644
index 000000000..c4a8b56b1
--- /dev/null
+++ b/stdlib/source/lux/tool/compiler/statement.lux
@@ -0,0 +1,46 @@
+(.module:
+ [lux #*]
+ [//
+ ["." analysis]
+ ["." synthesis]
+ ["." phase
+ ["." translation]
+ ["." extension]]])
+
+(type: #export (Component state phase)
+ {#state state
+ #phase phase})
+
+(type: #export (State anchor expression statement)
+ {#analysis (Component analysis.State+
+ analysis.Phase)
+ #synthesis (Component synthesis.State+
+ synthesis.Phase)
+ #translation (Component (translation.State+ anchor expression statement)
+ (translation.Phase anchor expression statement))})
+
+(do-template [<special> <general>]
+ [(type: #export (<special> anchor expression statement)
+ (<general> (..State anchor expression statement) Code Any))]
+
+ [State+ extension.State]
+ [Operation extension.Operation]
+ [Phase extension.Phase]
+ [Handler extension.Handler]
+ [Bundle extension.Bundle]
+ )
+
+(do-template [<name> <component> <operation>]
+ [(def: #export (<name> operation)
+ (All [anchor expression statement output]
+ (-> (<operation> output)
+ (Operation anchor expression statement output)))
+ (extension.lift
+ (phase.sub [(get@ [<component> #..state])
+ (set@ [<component> #..state])]
+ operation)))]
+
+ [lift-analysis #..analysis analysis.Operation]
+ [lift-synthesis #..synthesis synthesis.Operation]
+ [lift-translation #..translation (translation.Operation anchor expression statement)]
+ )