blob: 947dc9d4bb266e7d276dda656abfeeac1041c98c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
(.module:
[lux #*
[control
[monad (#+ do)]]
[data
["." product]]]
[//
["." evaluation]
["." phase
["." analysis
[".A" expression]]
["." synthesis
[".S" expression]]
["." translation (#+ Host)]
["." statement]
["." extension
[".E" analysis]
[".E" synthesis]
[".E" translation]
[".E" statement]]]
[//
["." host]]])
(type: #export Version Text)
(def: #export version Version "0.6.0")
(def: #export (cursor file)
(-> Text Cursor)
[file 1 0])
(def: #export (source file code)
(-> Text Text Source)
[(cursor file) 0 code])
(def: dummy-source
Source
[.dummy-cursor 0 ""])
(def: #export type-context
Type-Context
{#.ex-counter 0
#.var-counter 0
#.var-bindings (list)})
(def: #export info
Info
{#.target (`` (for {(~~ (static host.common-lisp)) host.common-lisp
(~~ (static host.js)) host.js
(~~ (static host.jvm)) host.jvm
(~~ (static host.lua)) host.lua
(~~ (static host.php)) host.php
(~~ (static host.python)) host.python
(~~ (static host.r)) host.r
(~~ (static host.ruby)) host.ruby
(~~ (static host.scheme)) host.scheme}))
#.version ..version
#.mode #.Build})
(def: #export (compiler host)
(-> Any Lux)
{#.info ..info
#.source dummy-source
#.cursor .dummy-cursor
#.current-module #.None
#.modules (list)
#.scopes (list)
#.type-context ..type-context
#.expected #.None
#.seed 0
#.scope-type-vars (list)
#.extensions []
#.host host})
(def: #export (state host translate)
(All [anchor expression statement]
(-> (Host expression statement)
(translation.Phase anchor expression statement)
(statement.State+ anchor expression statement)))
(let [synthesis-state [synthesisE.bundle synthesis.init]
translation-state [translationE.bundle (translation.state host)]
eval (evaluation.evaluator synthesis-state translation-state translate)
analysis-state [(analysisE.bundle eval) (..compiler host)]]
[statementE.bundle
{#statement.analysis {#statement.state analysis-state
#statement.phase expressionA.compile}
#statement.synthesis {#statement.state synthesis-state
#statement.phase expressionS.synthesize}
#statement.translation {#statement.state translation-state
#statement.phase translate}}]))
(def: #export refresh
(All [anchor expression statement]
(statement.Operation anchor expression statement Any))
(do phase.Monad<Operation>
[[bundle state] phase.get-state
#let [eval (evaluation.evaluator (get@ [#statement.synthesis #statement.state] state)
(get@ [#statement.translation #statement.state] state)
(get@ [#statement.translation #statement.phase] state))]]
(phase.set-state [statementE.bundle
(update@ [#statement.analysis #statement.state]
(: (-> analysis.State+ analysis.State+)
(|>> product.right
[(analysisE.bundle eval)]))
state)])))
|