eliscript 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +135 -0
- package/bin/eliscript +16 -0
- package/bin/eliscript-bootstrap +15 -0
- package/bin/eliscript-build +15 -0
- package/bin/eliscript-check +15 -0
- package/bin/eliscript-eval +15 -0
- package/bin/eliscript-format +15 -0
- package/bin/eliscript-org +10 -0
- package/bin/eliscript-portable +17 -0
- package/bin/eliscript-seed +10 -0
- package/bin/eliscript-seed-build +10 -0
- package/bin/eliscript-watch +15 -0
- package/bootstrap/README.md +100 -0
- package/bootstrap/compiler/analyzer.eli +1426 -0
- package/bootstrap/compiler/compiler.eli +472 -0
- package/bootstrap/compiler/emitter.eli +1745 -0
- package/bootstrap/compiler/expander.eli +2522 -0
- package/bootstrap/compiler/formatter.eli +359 -0
- package/bootstrap/compiler/ir.eli +297 -0
- package/bootstrap/compiler/lower.eli +661 -0
- package/bootstrap/compiler/project.eli +1120 -0
- package/bootstrap/compiler/reader.eli +321 -0
- package/bootstrap/compiler/source-map.eli +165 -0
- package/bootstrap/compiler/symbol.eli +92 -0
- package/bootstrap/compiler/syntax.eli +54 -0
- package/bootstrap/compiler/transient-analysis.eli +825 -0
- package/bootstrap/host/build.mjs +28 -0
- package/bootstrap/host/bun.mjs +282 -0
- package/bootstrap/host/check-cli.mjs +163 -0
- package/bootstrap/host/eliscript-cli.mjs +36 -0
- package/bootstrap/host/evaluation-cli.mjs +401 -0
- package/bootstrap/host/evaluation.mjs +560 -0
- package/bootstrap/host/format-cli.mjs +139 -0
- package/bootstrap/host/project-cli.mjs +295 -0
- package/bootstrap/host/project.mjs +1080 -0
- package/bootstrap/host/watch-cli.mjs +129 -0
- package/bootstrap/host/watch.mjs +267 -0
- package/browser/host.mjs +357 -0
- package/browser/worker.mjs +60 -0
- package/compiler/README.md +118 -0
- package/compiler/eliscript-analyzer.el +716 -0
- package/compiler/eliscript-cli.el +108 -0
- package/compiler/eliscript-diagnostic.el +158 -0
- package/compiler/eliscript-emitter.el +1351 -0
- package/compiler/eliscript-evaluation.el +259 -0
- package/compiler/eliscript-expander.el +1630 -0
- package/compiler/eliscript-form.el +79 -0
- package/compiler/eliscript-ir-emitter.el +1460 -0
- package/compiler/eliscript-ir.el +356 -0
- package/compiler/eliscript-lower.el +463 -0
- package/compiler/eliscript-macro-eval.el +811 -0
- package/compiler/eliscript-parameters.el +324 -0
- package/compiler/eliscript-portable.el +492 -0
- package/compiler/eliscript-project-cli.el +156 -0
- package/compiler/eliscript-project.el +1676 -0
- package/compiler/eliscript-reader.el +421 -0
- package/compiler/eliscript-source-map.el +192 -0
- package/compiler/eliscript-symbol.el +101 -0
- package/compiler/eliscript-transient-analysis.el +817 -0
- package/compiler/eliscript.el +239 -0
- package/dist/bootstrap/analyzer.mjs +968 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -0
- package/dist/bootstrap/compiler.mjs +228 -0
- package/dist/bootstrap/compiler.mjs.map +1 -0
- package/dist/bootstrap/emitter.mjs +1173 -0
- package/dist/bootstrap/emitter.mjs.map +1 -0
- package/dist/bootstrap/expander.mjs +1469 -0
- package/dist/bootstrap/expander.mjs.map +1 -0
- package/dist/bootstrap/formatter.mjs +304 -0
- package/dist/bootstrap/formatter.mjs.map +1 -0
- package/dist/bootstrap/ir.mjs +193 -0
- package/dist/bootstrap/ir.mjs.map +1 -0
- package/dist/bootstrap/lower.mjs +344 -0
- package/dist/bootstrap/lower.mjs.map +1 -0
- package/dist/bootstrap/project.mjs +585 -0
- package/dist/bootstrap/project.mjs.map +1 -0
- package/dist/bootstrap/reader.mjs +259 -0
- package/dist/bootstrap/reader.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +154 -0
- package/dist/bootstrap/source-map.mjs.map +1 -0
- package/dist/bootstrap/symbol.mjs +74 -0
- package/dist/bootstrap/symbol.mjs.map +1 -0
- package/dist/bootstrap/syntax.mjs +38 -0
- package/dist/bootstrap/syntax.mjs.map +1 -0
- package/dist/bootstrap/transient-analysis.mjs +660 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -0
- package/dist/browser/compiler.js +6491 -0
- package/editor/README.md +83 -0
- package/editor/eliscript-mode.el +878 -0
- package/editor/eliscript-repl.el +501 -0
- package/package.json +163 -0
- package/platform/README.md +48 -0
- package/platform/browser.mjs +204 -0
- package/platform/worker.mjs +166 -0
- package/runtime/README.md +296 -0
- package/runtime/core/collection-internals.mjs +512 -0
- package/runtime/core/collection.mjs +645 -0
- package/runtime/core/data-text.mjs +532 -0
- package/runtime/core/data.mjs +268 -0
- package/runtime/core/identifier.mjs +314 -0
- package/runtime/core/lazy-sequence.mjs +244 -0
- package/runtime/core/list-internals.mjs +18 -0
- package/runtime/core/list.mjs +273 -0
- package/runtime/core/map-internals.mjs +793 -0
- package/runtime/core/map.mjs +394 -0
- package/runtime/core/metadata-internals.mjs +14 -0
- package/runtime/core/metadata.mjs +44 -0
- package/runtime/core/object-impl.mjs +65 -0
- package/runtime/core/object-impl.mjs.map +1 -0
- package/runtime/core/object.mjs +13 -0
- package/runtime/core/order.mjs +234 -0
- package/runtime/core/persistent-kind.mjs +43 -0
- package/runtime/core/protocol-error.mjs +36 -0
- package/runtime/core/protocol-impl.mjs +326 -0
- package/runtime/core/protocol-impl.mjs.map +1 -0
- package/runtime/core/protocol.mjs +14 -0
- package/runtime/core/queue-internals.mjs +27 -0
- package/runtime/core/queue.mjs +238 -0
- package/runtime/core/record.mjs +346 -0
- package/runtime/core/regex.mjs +184 -0
- package/runtime/core/sequence.mjs +632 -0
- package/runtime/core/set-algebra.mjs +287 -0
- package/runtime/core/set-internals.mjs +33 -0
- package/runtime/core/set.mjs +378 -0
- package/runtime/core/sorted-internals.mjs +215 -0
- package/runtime/core/sorted.mjs +598 -0
- package/runtime/core/text-impl.mjs +95 -0
- package/runtime/core/text-impl.mjs.map +1 -0
- package/runtime/core/text.mjs +15 -0
- package/runtime/core/transducer.mjs +668 -0
- package/runtime/core/transient-internals.mjs +38 -0
- package/runtime/core/transient.mjs +53 -0
- package/runtime/core/truth.mjs +3 -0
- package/runtime/core/type.mjs +262 -0
- package/runtime/core/value-internals.mjs +188 -0
- package/runtime/core/value.mjs +93 -0
- package/runtime/core/vector-internals.mjs +102 -0
- package/runtime/core/vector.mjs +951 -0
- package/runtime/literals.mjs +34 -0
- package/runtime/source-mapping.mjs +220 -0
- package/runtime/testing/list.mjs +52 -0
- package/runtime/testing/map.mjs +145 -0
- package/runtime/testing/queue.mjs +49 -0
- package/runtime/testing/set.mjs +61 -0
- package/runtime/testing/sorted.mjs +105 -0
- package/runtime/testing/value.mjs +17 -0
- package/runtime/testing/vector.mjs +102 -0
- package/runtime/worker-value-codec.mjs +565 -0
- package/runtime/worker-value-stream.mjs +786 -0
- package/runtime/worker.mjs +975 -0
- package/stdlib/README.md +774 -0
- package/stdlib/bit.eli +36 -0
- package/stdlib/core/collection.eli +134 -0
- package/stdlib/core/data-text.eli +16 -0
- package/stdlib/core/data.eli +306 -0
- package/stdlib/core/identifier.eli +32 -0
- package/stdlib/core/lazy-sequence.eli +63 -0
- package/stdlib/core/metadata.eli +20 -0
- package/stdlib/core/object.eli +89 -0
- package/stdlib/core/order.eli +133 -0
- package/stdlib/core/protocol.eli +387 -0
- package/stdlib/core/record.eli +16 -0
- package/stdlib/core/regex.eli +17 -0
- package/stdlib/core/seq.eli +701 -0
- package/stdlib/core/set.eli +312 -0
- package/stdlib/core/sorted.eli +53 -0
- package/stdlib/core/text.eli +103 -0
- package/stdlib/core/transducer.eli +59 -0
- package/stdlib/core/transient.eli +24 -0
- package/stdlib/core/type.eli +19 -0
- package/stdlib/core/walk.eli +195 -0
- package/stdlib/core/zipper.eli +508 -0
- package/stdlib/data-text.eli +1092 -0
- package/stdlib/data.eli +42 -0
- package/stdlib/deferred.eli +70 -0
- package/stdlib/function.eli +120 -0
- package/stdlib/hierarchy.eli +245 -0
- package/stdlib/identifier.eli +147 -0
- package/stdlib/interop/js.eli +616 -0
- package/stdlib/json.eli +870 -0
- package/stdlib/metadata.eli +56 -0
- package/stdlib/multimethod.eli +464 -0
- package/stdlib/numeric.eli +193 -0
- package/stdlib/object.eli +96 -0
- package/stdlib/persistent-list.eli +145 -0
- package/stdlib/persistent-map.eli +724 -0
- package/stdlib/persistent-queue.eli +32 -0
- package/stdlib/persistent-set.eli +236 -0
- package/stdlib/persistent-vector.eli +342 -0
- package/stdlib/result.eli +141 -0
- package/stdlib/sequence.eli +106 -0
- package/stdlib/state/atom.eli +265 -0
- package/stdlib/text.eli +88 -0
- package/stdlib/value.eli +325 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
;;; eliscript.el --- Eliscript seed compiler -*- lexical-binding: t; -*-
|
|
2
|
+
|
|
3
|
+
;;; Commentary:
|
|
4
|
+
|
|
5
|
+
;; Public entry points for compiling Eliscript source with Emacs.
|
|
6
|
+
|
|
7
|
+
;;; Code:
|
|
8
|
+
|
|
9
|
+
(require 'eliscript-reader)
|
|
10
|
+
(require 'eliscript-expander)
|
|
11
|
+
(require 'eliscript-analyzer)
|
|
12
|
+
(require 'eliscript-lower)
|
|
13
|
+
(require 'eliscript-emitter)
|
|
14
|
+
(require 'eliscript-ir-emitter)
|
|
15
|
+
(require 'eliscript-portable)
|
|
16
|
+
|
|
17
|
+
(defun eliscript--analyzed-string (source filename &optional macro-context)
|
|
18
|
+
"Read, expand, and analyze SOURCE from FILENAME."
|
|
19
|
+
(eliscript-analyze-module
|
|
20
|
+
(eliscript-expand-module
|
|
21
|
+
(eliscript-read-located-string source filename)
|
|
22
|
+
filename macro-context)
|
|
23
|
+
filename))
|
|
24
|
+
|
|
25
|
+
(defun eliscript-compile-ir-string (source &optional filename macro-context)
|
|
26
|
+
"Compile Eliscript SOURCE from FILENAME into an IR program."
|
|
27
|
+
(eliscript-lower-module
|
|
28
|
+
(eliscript--analyzed-string source filename macro-context)
|
|
29
|
+
filename))
|
|
30
|
+
|
|
31
|
+
(defun eliscript-compile-portable-ir-string
|
|
32
|
+
(source entries &optional filename macro-context)
|
|
33
|
+
"Compile portable ENTRIES from Eliscript SOURCE into an IR program."
|
|
34
|
+
(let ((forms (eliscript--analyzed-string source filename macro-context)))
|
|
35
|
+
(eliscript-lower-module
|
|
36
|
+
(eliscript-portable-select-module forms entries filename)
|
|
37
|
+
filename)))
|
|
38
|
+
|
|
39
|
+
(defun eliscript-compile-portable-string (source entries &optional filename)
|
|
40
|
+
"Compile portable ENTRIES and their dependencies from SOURCE to ESM."
|
|
41
|
+
(eliscript-emit-ir-module
|
|
42
|
+
(eliscript-compile-portable-ir-string source entries filename)))
|
|
43
|
+
|
|
44
|
+
(defun eliscript-compile-portable-string-with-source-map
|
|
45
|
+
(source entries &optional filename generated-name source-name)
|
|
46
|
+
"Compile portable ENTRIES from SOURCE with a Source Map v3 document."
|
|
47
|
+
(eliscript-emit-ir-module-with-source-map
|
|
48
|
+
(eliscript-compile-portable-ir-string source entries filename)
|
|
49
|
+
source
|
|
50
|
+
generated-name
|
|
51
|
+
(or source-name filename "<string>")))
|
|
52
|
+
|
|
53
|
+
(defun eliscript-compile-string (source &optional filename)
|
|
54
|
+
"Compile Eliscript SOURCE to an ECMAScript module.
|
|
55
|
+
|
|
56
|
+
FILENAME is used for compiler diagnostics."
|
|
57
|
+
(eliscript-emit-ir-module
|
|
58
|
+
(eliscript-compile-ir-string source filename)))
|
|
59
|
+
|
|
60
|
+
(defun eliscript-compile-string-with-source-map
|
|
61
|
+
(source &optional filename generated-name source-name)
|
|
62
|
+
"Compile SOURCE and return JavaScript plus a Source Map v3 document.
|
|
63
|
+
|
|
64
|
+
FILENAME is used for diagnostics. GENERATED-NAME and SOURCE-NAME identify the
|
|
65
|
+
files recorded in the source map. The return value is an `eliscript-emission'."
|
|
66
|
+
(eliscript-emit-ir-module-with-source-map
|
|
67
|
+
(eliscript-compile-ir-string source filename)
|
|
68
|
+
source
|
|
69
|
+
generated-name
|
|
70
|
+
(or source-name filename "<string>")))
|
|
71
|
+
|
|
72
|
+
(defun eliscript-compile-ir-file (input-file)
|
|
73
|
+
"Compile INPUT-FILE into an IR program."
|
|
74
|
+
(eliscript-lower-module
|
|
75
|
+
(eliscript-analyze-module
|
|
76
|
+
(eliscript-expand-module
|
|
77
|
+
(eliscript-read-located-file input-file)
|
|
78
|
+
input-file)
|
|
79
|
+
input-file)
|
|
80
|
+
input-file))
|
|
81
|
+
|
|
82
|
+
(defun eliscript--same-file-path-p (left right)
|
|
83
|
+
"Return non-nil when LEFT and RIGHT name the same physical file."
|
|
84
|
+
(or (string-equal (file-truename left) (file-truename right))
|
|
85
|
+
(and (file-exists-p left)
|
|
86
|
+
(file-exists-p right)
|
|
87
|
+
(condition-case nil
|
|
88
|
+
(file-equal-p left right)
|
|
89
|
+
(file-error nil)))))
|
|
90
|
+
|
|
91
|
+
(defun eliscript--validate-file-output-paths (input paths)
|
|
92
|
+
"Reject PATHS that alias INPUT or one another before writing files."
|
|
93
|
+
(let ((input-path (expand-file-name input))
|
|
94
|
+
validated)
|
|
95
|
+
(dolist (path paths)
|
|
96
|
+
(let ((output-path (expand-file-name path)))
|
|
97
|
+
(when (eliscript--same-file-path-p input-path output-path)
|
|
98
|
+
(error "generated artifact must not overwrite input file: %s"
|
|
99
|
+
output-path))
|
|
100
|
+
(dolist (previous validated)
|
|
101
|
+
(when (eliscript--same-file-path-p previous output-path)
|
|
102
|
+
(error "generated artifact paths must be physically distinct: %s and %s"
|
|
103
|
+
previous output-path)))
|
|
104
|
+
(push output-path validated)))))
|
|
105
|
+
|
|
106
|
+
(defun eliscript-compile-portable-file (input-file entries &optional output-file)
|
|
107
|
+
"Compile portable ENTRIES from INPUT-FILE, optionally to OUTPUT-FILE."
|
|
108
|
+
(let* ((input-path (expand-file-name input-file))
|
|
109
|
+
(_validated
|
|
110
|
+
(when output-file
|
|
111
|
+
(eliscript--validate-file-output-paths
|
|
112
|
+
input-path (list output-file))))
|
|
113
|
+
(source
|
|
114
|
+
(with-temp-buffer
|
|
115
|
+
(insert-file-contents input-path)
|
|
116
|
+
(buffer-string)))
|
|
117
|
+
(output
|
|
118
|
+
(eliscript-compile-portable-string source entries input-path)))
|
|
119
|
+
(when output-file
|
|
120
|
+
(make-directory (file-name-directory (expand-file-name output-file)) t)
|
|
121
|
+
(with-temp-file output-file
|
|
122
|
+
(insert output)))
|
|
123
|
+
output))
|
|
124
|
+
|
|
125
|
+
(defun eliscript-compile-portable-file-with-source-map
|
|
126
|
+
(input-file entries output-file &optional source-map-file)
|
|
127
|
+
"Compile portable ENTRIES from INPUT-FILE with an external source map."
|
|
128
|
+
(unless output-file
|
|
129
|
+
(error "portable source-map compilation requires OUTPUT-FILE"))
|
|
130
|
+
(let* ((input-path (expand-file-name input-file))
|
|
131
|
+
(output-path (expand-file-name output-file))
|
|
132
|
+
(map-path
|
|
133
|
+
(expand-file-name (or source-map-file (concat output-path ".map"))))
|
|
134
|
+
(_validated
|
|
135
|
+
(eliscript--validate-file-output-paths
|
|
136
|
+
input-path (list output-path map-path)))
|
|
137
|
+
(map-directory (file-name-directory map-path))
|
|
138
|
+
(source
|
|
139
|
+
(with-temp-buffer
|
|
140
|
+
(insert-file-contents input-path)
|
|
141
|
+
(buffer-string)))
|
|
142
|
+
(generated-name (file-relative-name output-path map-directory))
|
|
143
|
+
(source-name (file-relative-name input-path map-directory))
|
|
144
|
+
(emission
|
|
145
|
+
(eliscript-compile-portable-string-with-source-map
|
|
146
|
+
source entries input-path generated-name source-name))
|
|
147
|
+
(map-url
|
|
148
|
+
(file-relative-name map-path (file-name-directory output-path)))
|
|
149
|
+
(javascript
|
|
150
|
+
(concat (eliscript-emission-javascript emission)
|
|
151
|
+
"//# sourceMappingURL=" map-url "\n")))
|
|
152
|
+
(setq emission
|
|
153
|
+
(eliscript-emission-create
|
|
154
|
+
:javascript javascript
|
|
155
|
+
:source-map (eliscript-emission-source-map emission)))
|
|
156
|
+
(make-directory map-directory t)
|
|
157
|
+
(with-temp-file map-path
|
|
158
|
+
(insert (eliscript-emission-source-map emission)))
|
|
159
|
+
(make-directory (file-name-directory output-path) t)
|
|
160
|
+
(with-temp-file output-path
|
|
161
|
+
(insert javascript))
|
|
162
|
+
emission))
|
|
163
|
+
|
|
164
|
+
(defun eliscript-compile-file (input-file &optional output-file)
|
|
165
|
+
"Compile INPUT-FILE and optionally write it to OUTPUT-FILE.
|
|
166
|
+
|
|
167
|
+
Return the generated ECMAScript source."
|
|
168
|
+
(let* ((input-path (expand-file-name input-file))
|
|
169
|
+
(_validated
|
|
170
|
+
(when output-file
|
|
171
|
+
(eliscript--validate-file-output-paths
|
|
172
|
+
input-path (list output-file))))
|
|
173
|
+
(output (eliscript-emit-ir-module
|
|
174
|
+
(eliscript-compile-ir-file input-path))))
|
|
175
|
+
(when output-file
|
|
176
|
+
(make-directory (file-name-directory (expand-file-name output-file)) t)
|
|
177
|
+
(with-temp-file output-file
|
|
178
|
+
(insert output)))
|
|
179
|
+
output))
|
|
180
|
+
|
|
181
|
+
(defun eliscript-compile-file-with-source-map
|
|
182
|
+
(input-file &optional output-file source-map-file)
|
|
183
|
+
"Compile INPUT-FILE with a Source Map v3 document.
|
|
184
|
+
|
|
185
|
+
When OUTPUT-FILE is non-nil, write JavaScript there and write the map to
|
|
186
|
+
SOURCE-MAP-FILE or OUTPUT-FILE with `.map' appended. The JavaScript receives
|
|
187
|
+
an external `sourceMappingURL' comment. Return an `eliscript-emission'."
|
|
188
|
+
(when (and source-map-file (null output-file))
|
|
189
|
+
(error "SOURCE-MAP-FILE requires OUTPUT-FILE"))
|
|
190
|
+
(let* ((input-path (expand-file-name input-file))
|
|
191
|
+
(output-path (and output-file (expand-file-name output-file)))
|
|
192
|
+
(map-path
|
|
193
|
+
(and output-path
|
|
194
|
+
(expand-file-name (or source-map-file
|
|
195
|
+
(concat output-path ".map")))))
|
|
196
|
+
(_validated
|
|
197
|
+
(when output-path
|
|
198
|
+
(eliscript--validate-file-output-paths
|
|
199
|
+
input-path (list output-path map-path))))
|
|
200
|
+
(source
|
|
201
|
+
(with-temp-buffer
|
|
202
|
+
(insert-file-contents input-path)
|
|
203
|
+
(buffer-string)))
|
|
204
|
+
(map-directory
|
|
205
|
+
(and map-path (file-name-directory map-path)))
|
|
206
|
+
(generated-name
|
|
207
|
+
(and output-path
|
|
208
|
+
(file-relative-name output-path map-directory)))
|
|
209
|
+
(source-name
|
|
210
|
+
(if map-directory
|
|
211
|
+
(file-relative-name input-path map-directory)
|
|
212
|
+
input-file))
|
|
213
|
+
(emission
|
|
214
|
+
(eliscript-compile-string-with-source-map
|
|
215
|
+
source input-path generated-name source-name)))
|
|
216
|
+
(when output-path
|
|
217
|
+
(let* ((map-url
|
|
218
|
+
(file-relative-name
|
|
219
|
+
map-path (file-name-directory output-path)))
|
|
220
|
+
(javascript
|
|
221
|
+
(concat (eliscript-emission-javascript emission)
|
|
222
|
+
"//# sourceMappingURL=" map-url "\n")))
|
|
223
|
+
(setq emission
|
|
224
|
+
(eliscript-emission-create
|
|
225
|
+
:javascript javascript
|
|
226
|
+
:source-map (eliscript-emission-source-map emission)))
|
|
227
|
+
(make-directory map-directory t)
|
|
228
|
+
(with-temp-file map-path
|
|
229
|
+
(insert (eliscript-emission-source-map emission)))
|
|
230
|
+
(make-directory (file-name-directory output-path) t)
|
|
231
|
+
(with-temp-file output-path
|
|
232
|
+
(insert javascript))))
|
|
233
|
+
emission))
|
|
234
|
+
|
|
235
|
+
(require 'eliscript-evaluation)
|
|
236
|
+
|
|
237
|
+
(provide 'eliscript)
|
|
238
|
+
|
|
239
|
+
;;; eliscript.el ends here
|