diff options
-rw-r--r-- | new-luxc/source/luxc/lang/eval.lux | 20 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default.lux | 6 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default/evaluation.lux | 30 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/analysis.lux | 3 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/extension.lux | 7 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/synthesis.lux | 3 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/translation.lux | 3 | ||||
-rw-r--r-- | stdlib/test/tests.lux | 1 |
8 files changed, 49 insertions, 24 deletions
diff --git a/new-luxc/source/luxc/lang/eval.lux b/new-luxc/source/luxc/lang/eval.lux deleted file mode 100644 index eb16cc433..000000000 --- a/new-luxc/source/luxc/lang/eval.lux +++ /dev/null @@ -1,20 +0,0 @@ -(.module: - lux - (lux (control [monad #+ do]) - [macro]) - (luxc ["&" lang] - (lang [".L" extension] - (analysis [".A" expression]) - (synthesis [".S" expression]) - (translation (jvm [".T" expression] - [".T" eval]))))) - -(def: #export (eval type exprC) - &.Eval - (do macro.Monad<Meta> - [exprA (&.with-type type - (expressionA.analyser eval exprC)) - syntheses extensionL.all-syntheses - #let [exprS (expressionS.synthesize syntheses exprA)] - exprI (expressionT.translate exprS)] - (evalT.eval exprI))) 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 |