aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/compiler/default.lux6
-rw-r--r--stdlib/source/lux/compiler/default/evaluation.lux30
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis.lux3
-rw-r--r--stdlib/source/lux/compiler/default/phase/extension.lux7
-rw-r--r--stdlib/source/lux/compiler/default/phase/synthesis.lux3
-rw-r--r--stdlib/source/lux/compiler/default/phase/translation.lux3
-rw-r--r--stdlib/test/tests.lux1
7 files changed, 49 insertions, 4 deletions
diff --git a/stdlib/source/lux/compiler/default.lux b/stdlib/source/lux/compiler/default.lux
index bc6e2c9ec..bc58c5d7b 100644
--- a/stdlib/source/lux/compiler/default.lux
+++ b/stdlib/source/lux/compiler/default.lux
@@ -1,8 +1,10 @@
(.module:
- lux)
+ [lux #*
+ [data
+ ["." error (#+ Error)]]])
(type: #export Eval
- (-> Type Code (Meta Any)))
+ (-> Type Code (Error Any)))
(type: #export Version Text)
diff --git a/stdlib/source/lux/compiler/default/evaluation.lux b/stdlib/source/lux/compiler/default/evaluation.lux
new file mode 100644
index 000000000..26c4b0355
--- /dev/null
+++ b/stdlib/source/lux/compiler/default/evaluation.lux
@@ -0,0 +1,30 @@
+(.module:
+ [lux #*
+ [control
+ [monad (#+ do)]
+ pipe]
+ [data
+ ["." error]]]
+ ["." // (#+ Eval)
+ ["." phase
+ ["." analysis
+ [".A" expression]]
+ ["." synthesis
+ [".S" expression]]
+ ["." translation]]])
+
+(def: #export (evaluator analysis-state synthesis-state translation-state translate)
+ (All [anchor expression statement]
+ (-> analysis.State+
+ synthesis.State+
+ (translation.State+ anchor expression statement)
+ (translation.Phase anchor expression statement)
+ Eval))
+ (function (eval type exprC)
+ (do error.Monad<Error>
+ [exprA (|> exprC (expressionA.analyser eval)(phase.run analysis-state))
+ exprS (|> exprA expressionS.synthesize (phase.run synthesis-state))]
+ (phase.run translation-state
+ (do phase.Monad<Operation>
+ [exprO (translate exprS)]
+ (translation.evaluate! exprO))))))
diff --git a/stdlib/source/lux/compiler/default/phase/analysis.lux b/stdlib/source/lux/compiler/default/phase/analysis.lux
index cbd447d46..72d2a3485 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis.lux
@@ -51,6 +51,9 @@
(#Apply Analysis Analysis)
(#Extension (Extension Analysis)))
+(type: #export State+
+ (extension.State .Lux Code Analysis))
+
(type: #export Operation
(extension.Operation .Lux Code Analysis))
diff --git a/stdlib/source/lux/compiler/default/phase/extension.lux b/stdlib/source/lux/compiler/default/phase/extension.lux
index a24d72b0c..15960083b 100644
--- a/stdlib/source/lux/compiler/default/phase/extension.lux
+++ b/stdlib/source/lux/compiler/default/phase/extension.lux
@@ -23,11 +23,14 @@
(type: #export (Bundle s i o)
<Bundle>))
+(type: #export (State s i o)
+ [(Bundle s i o) s])
+
(type: #export (Operation s i o v)
- (//.Operation [(Bundle s i o) s] v))
+ (//.Operation (State s i o) v))
(type: #export (Phase s i o)
- (//.Phase [(Bundle s i o) s] i o))
+ (//.Phase (State s i o) i o))
(do-template [<name>]
[(exception: #export (<name> {name Text})
diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux
index 1dbbffd84..99111d2a7 100644
--- a/stdlib/source/lux/compiler/default/phase/synthesis.lux
+++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux
@@ -98,6 +98,9 @@
(#Control (Control Synthesis))
(#Extension (Extension Synthesis)))
+(type: #export State+
+ (extension.State ..State Analysis Synthesis))
+
(type: #export Operation
(extension.Operation ..State Analysis Synthesis))
diff --git a/stdlib/source/lux/compiler/default/phase/translation.lux b/stdlib/source/lux/compiler/default/phase/translation.lux
index d2b0b0678..321573767 100644
--- a/stdlib/source/lux/compiler/default/phase/translation.lux
+++ b/stdlib/source/lux/compiler/default/phase/translation.lux
@@ -71,6 +71,9 @@
#counter Nat
#name-cache (Dictionary Name Text)})
+(type: #export (State+ anchor expression statement)
+ (extension.State (State anchor expression statement) Synthesis expression))
+
(type: #export (Operation anchor expression statement)
(extension.Operation (State anchor expression statement) Synthesis expression))
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index 2380365bf..0e09def80 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -43,6 +43,7 @@
[host
[".H" scheme]]
[default
+ ["._" evaluation]
[phase
["._" translation
[scheme