aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/scheme.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/scheme.lux')
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/scheme.lux62
1 files changed, 62 insertions, 0 deletions
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/scheme.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/scheme.lux
new file mode 100644
index 000000000..cdedd1a3d
--- /dev/null
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/scheme.lux
@@ -0,0 +1,62 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]]
+ [meta
+ [macro
+ ["^" pattern]]
+ [target
+ ["_" scheme]]]]]
+ ["[0]" /
+ [runtime (.only Phase)]
+ ["[1][0]" primitive]
+ ["[1][0]" structure]
+ ["[1][0]" reference]
+ ["[1][0]" case]
+ ["[1][0]" loop]
+ ["[1][0]" function]
+ ["/[1]" //
+ ["[1][0]" reference]
+ ["/[1]" //
+ ["[1][0]" extension]
+ ["/[1]" //
+ [analysis (.only)]
+ ["[1][0]" synthesis]
+ ["//[1]" ///
+ ["[1][0]" phase (.use "[1]#[0]" monad)]
+ [reference (.only)
+ [variable (.only)]]]]]]])
+
+(def .public (generate archive synthesis)
+ Phase
+ (case synthesis
+ (^.with_template [<tag> <generator>]
+ [(<tag> value)
+ (//////phase#in (<generator> value))])
+ ([////synthesis.bit /primitive.bit]
+ [////synthesis.i64 /primitive.i64]
+ [////synthesis.f64 /primitive.f64]
+ [////synthesis.text /primitive.text])
+
+ {////synthesis.#Reference value}
+ (//reference.reference /reference.system archive value)
+
+ (^.with_template [<tag> <generator>]
+ [(<tag> value)
+ (<generator> generate archive value)])
+ ([////synthesis.variant /structure.variant]
+ [////synthesis.tuple /structure.tuple]
+ [////synthesis.branch/let /case.let]
+ [////synthesis.branch/if /case.if]
+ [////synthesis.branch/get /case.get]
+ [////synthesis.function/apply /function.apply]
+
+ [////synthesis.branch/case /case.case]
+ [////synthesis.loop/scope /loop.scope]
+ [////synthesis.loop/again /loop.again]
+ [////synthesis.function/abstraction /function.function])
+
+ {////synthesis.#Extension extension}
+ (///extension.apply archive generate extension)
+ ))