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,108 @@
|
|
|
1
|
+
;;; eliscript-cli.el --- Batch command for Eliscript -*- lexical-binding: t; -*-
|
|
2
|
+
|
|
3
|
+
;;; Commentary:
|
|
4
|
+
|
|
5
|
+
;; Run with:
|
|
6
|
+
;; emacs --batch -Q -L compiler --script compiler/eliscript-cli.el -- FILE
|
|
7
|
+
|
|
8
|
+
;;; Code:
|
|
9
|
+
|
|
10
|
+
(add-to-list 'load-path
|
|
11
|
+
(file-name-directory (or load-file-name buffer-file-name)))
|
|
12
|
+
(require 'eliscript)
|
|
13
|
+
|
|
14
|
+
(defconst eliscript-cli--usage
|
|
15
|
+
(concat
|
|
16
|
+
"Usage: eliscript [--output FILE] [--source-map] [--portable NAME]\n"
|
|
17
|
+
" [--diagnostic-format human|json] INPUT\n\n"
|
|
18
|
+
"Compile INPUT to an ECMAScript module. Write to stdout when --output "
|
|
19
|
+
"is absent.\n--source-map writes FILE.map and requires --output.\n"
|
|
20
|
+
"Repeat --portable to emit only those worker entries and dependencies.\n"
|
|
21
|
+
"Use JSON diagnostics for editor and CI integrations.\n"))
|
|
22
|
+
|
|
23
|
+
(defun eliscript-cli--requested-diagnostic-format (arguments)
|
|
24
|
+
"Return a usable diagnostic format requested by raw ARGUMENTS."
|
|
25
|
+
(let ((remaining arguments)
|
|
26
|
+
(format-name "human"))
|
|
27
|
+
(while remaining
|
|
28
|
+
(when (and (equal (car remaining) "--diagnostic-format")
|
|
29
|
+
(cdr remaining)
|
|
30
|
+
(equal (cadr remaining) "json"))
|
|
31
|
+
(setq format-name "json"))
|
|
32
|
+
(setq remaining (cdr remaining)))
|
|
33
|
+
format-name))
|
|
34
|
+
|
|
35
|
+
(defun eliscript-cli--parse (arguments)
|
|
36
|
+
"Parse ARGUMENTS into input, output, maps, portable, and diagnostic fields."
|
|
37
|
+
(when (equal (car arguments) "--")
|
|
38
|
+
(setq arguments (cdr arguments)))
|
|
39
|
+
(let ((diagnostic-format "human")
|
|
40
|
+
input output source-map portable-entries)
|
|
41
|
+
(while arguments
|
|
42
|
+
(let ((argument (pop arguments)))
|
|
43
|
+
(cond
|
|
44
|
+
((member argument '("-h" "--help"))
|
|
45
|
+
(princ eliscript-cli--usage)
|
|
46
|
+
(kill-emacs 0))
|
|
47
|
+
((member argument '("-o" "--output"))
|
|
48
|
+
(unless arguments
|
|
49
|
+
(error "%s requires a file" argument))
|
|
50
|
+
(setq output (pop arguments)))
|
|
51
|
+
((equal argument "--source-map")
|
|
52
|
+
(setq source-map t))
|
|
53
|
+
((equal argument "--portable")
|
|
54
|
+
(unless arguments
|
|
55
|
+
(error "%s requires a function name" argument))
|
|
56
|
+
(push (pop arguments) portable-entries))
|
|
57
|
+
((equal argument "--diagnostic-format")
|
|
58
|
+
(unless arguments
|
|
59
|
+
(error "%s requires human or json" argument))
|
|
60
|
+
(setq diagnostic-format (pop arguments))
|
|
61
|
+
(unless (member diagnostic-format '("human" "json"))
|
|
62
|
+
(error "unsupported diagnostic format: %s" diagnostic-format)))
|
|
63
|
+
((string-prefix-p "-" argument)
|
|
64
|
+
(error "unknown option: %s" argument))
|
|
65
|
+
(input (error "multiple input files are not supported yet"))
|
|
66
|
+
(t (setq input argument)))))
|
|
67
|
+
(unless input
|
|
68
|
+
(error "missing input file"))
|
|
69
|
+
(when (and source-map (null output))
|
|
70
|
+
(error "--source-map requires --output"))
|
|
71
|
+
(list input output source-map (nreverse portable-entries)
|
|
72
|
+
diagnostic-format)))
|
|
73
|
+
|
|
74
|
+
(defun eliscript-cli-main (arguments)
|
|
75
|
+
"Compile according to command-line ARGUMENTS."
|
|
76
|
+
(let ((requested-format
|
|
77
|
+
(eliscript-cli--requested-diagnostic-format arguments)))
|
|
78
|
+
(condition-case error-data
|
|
79
|
+
(pcase-let ((`(,input ,output ,source-map ,portable-entries
|
|
80
|
+
,diagnostic-format)
|
|
81
|
+
(eliscript-cli--parse arguments)))
|
|
82
|
+
(setq requested-format diagnostic-format)
|
|
83
|
+
(if source-map
|
|
84
|
+
(if portable-entries
|
|
85
|
+
(eliscript-compile-portable-file-with-source-map
|
|
86
|
+
input portable-entries output)
|
|
87
|
+
(eliscript-compile-file-with-source-map input output))
|
|
88
|
+
(let ((generated
|
|
89
|
+
(if portable-entries
|
|
90
|
+
(eliscript-compile-portable-file
|
|
91
|
+
input portable-entries output)
|
|
92
|
+
(eliscript-compile-file input output))))
|
|
93
|
+
(unless output
|
|
94
|
+
(princ generated)))))
|
|
95
|
+
(error
|
|
96
|
+
(if (equal requested-format "json")
|
|
97
|
+
(message
|
|
98
|
+
"%s"
|
|
99
|
+
(eliscript-diagnostic-to-json
|
|
100
|
+
(eliscript-diagnostic-from-error error-data)))
|
|
101
|
+
(message
|
|
102
|
+
"eliscript: %s"
|
|
103
|
+
(eliscript-diagnostic-condition-message error-data)))
|
|
104
|
+
(kill-emacs 1)))))
|
|
105
|
+
|
|
106
|
+
(eliscript-cli-main command-line-args-left)
|
|
107
|
+
|
|
108
|
+
;;; eliscript-cli.el ends here
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
;;; eliscript-diagnostic.el --- Compiler diagnostics -*- lexical-binding: t; -*-
|
|
2
|
+
|
|
3
|
+
;;; Commentary:
|
|
4
|
+
|
|
5
|
+
;; Shared condition types and formatting for compiler phases.
|
|
6
|
+
|
|
7
|
+
;;; Code:
|
|
8
|
+
|
|
9
|
+
(require 'cl-lib)
|
|
10
|
+
(require 'json)
|
|
11
|
+
(require 'eliscript-form)
|
|
12
|
+
|
|
13
|
+
(define-error 'eliscript-compile-error "Eliscript compile error")
|
|
14
|
+
(define-error 'eliscript-expand-error
|
|
15
|
+
"Eliscript macro expansion error"
|
|
16
|
+
'eliscript-compile-error)
|
|
17
|
+
(define-error 'eliscript-analyze-error
|
|
18
|
+
"Eliscript analysis error"
|
|
19
|
+
'eliscript-compile-error)
|
|
20
|
+
|
|
21
|
+
(defconst eliscript-diagnostic-format-name "eliscript-diagnostic"
|
|
22
|
+
"Public format identifier for structured compiler diagnostics.")
|
|
23
|
+
|
|
24
|
+
(defconst eliscript-diagnostic-version 1
|
|
25
|
+
"Current public structured diagnostic schema version.")
|
|
26
|
+
|
|
27
|
+
(cl-defstruct (eliscript-diagnostic
|
|
28
|
+
(:constructor eliscript-diagnostic-create))
|
|
29
|
+
code
|
|
30
|
+
severity
|
|
31
|
+
phase
|
|
32
|
+
message
|
|
33
|
+
file
|
|
34
|
+
span)
|
|
35
|
+
|
|
36
|
+
(defvar eliscript-diagnostic--conditions
|
|
37
|
+
(make-hash-table :test #'eq :weakness 'key)
|
|
38
|
+
"Weak association from condition message strings to diagnostics.")
|
|
39
|
+
|
|
40
|
+
(defun eliscript-diagnostic-format (filename format-string &rest arguments)
|
|
41
|
+
"Format a diagnostic for FILENAME using FORMAT-STRING and ARGUMENTS."
|
|
42
|
+
(format "%s: %s"
|
|
43
|
+
(or filename "<string>")
|
|
44
|
+
(apply #'format format-string arguments)))
|
|
45
|
+
|
|
46
|
+
(defun eliscript-diagnostic-format-at
|
|
47
|
+
(filename span format-string &rest arguments)
|
|
48
|
+
"Format a diagnostic at SPAN in FILENAME using FORMAT-STRING and ARGUMENTS."
|
|
49
|
+
(let ((source-name (or filename
|
|
50
|
+
(and span (eliscript-source-span-filename span))
|
|
51
|
+
"<string>"))
|
|
52
|
+
(message (apply #'format format-string arguments)))
|
|
53
|
+
(if span
|
|
54
|
+
(format "%s:%d:%d: %s"
|
|
55
|
+
source-name
|
|
56
|
+
(eliscript-source-span-line span)
|
|
57
|
+
(eliscript-source-span-column span)
|
|
58
|
+
message)
|
|
59
|
+
(format "%s: %s" source-name message))))
|
|
60
|
+
|
|
61
|
+
(defun eliscript-diagnostic-render (diagnostic)
|
|
62
|
+
"Render DIAGNOSTIC as the stable human-readable compiler message."
|
|
63
|
+
(if (or (eliscript-diagnostic-file diagnostic)
|
|
64
|
+
(eliscript-diagnostic-span diagnostic))
|
|
65
|
+
(eliscript-diagnostic-format-at
|
|
66
|
+
(eliscript-diagnostic-file diagnostic)
|
|
67
|
+
(eliscript-diagnostic-span diagnostic)
|
|
68
|
+
"%s"
|
|
69
|
+
(eliscript-diagnostic-message diagnostic))
|
|
70
|
+
(eliscript-diagnostic-message diagnostic)))
|
|
71
|
+
|
|
72
|
+
(defun eliscript-diagnostic--position (offset line column)
|
|
73
|
+
"Return a JSON-compatible source position from OFFSET, LINE, and COLUMN."
|
|
74
|
+
`((offset . ,offset) (line . ,line) (column . ,column)))
|
|
75
|
+
|
|
76
|
+
(defun eliscript-diagnostic--location (diagnostic)
|
|
77
|
+
"Return DIAGNOSTIC's JSON-compatible location, or nil."
|
|
78
|
+
(let* ((span (eliscript-diagnostic-span diagnostic))
|
|
79
|
+
(file (or (eliscript-diagnostic-file diagnostic)
|
|
80
|
+
(and span (eliscript-source-span-filename span)))))
|
|
81
|
+
(when (or file span)
|
|
82
|
+
(append
|
|
83
|
+
(when file `((file . ,file)))
|
|
84
|
+
(when span
|
|
85
|
+
`((start . ,(eliscript-diagnostic--position
|
|
86
|
+
(eliscript-source-span-start span)
|
|
87
|
+
(eliscript-source-span-line span)
|
|
88
|
+
(eliscript-source-span-column span)))
|
|
89
|
+
(end . ,(eliscript-diagnostic--position
|
|
90
|
+
(eliscript-source-span-end span)
|
|
91
|
+
(eliscript-source-span-end-line span)
|
|
92
|
+
(eliscript-source-span-end-column span)))))))))
|
|
93
|
+
|
|
94
|
+
(defun eliscript-diagnostic-to-alist (diagnostic)
|
|
95
|
+
"Return public JSON-compatible data for DIAGNOSTIC."
|
|
96
|
+
(append
|
|
97
|
+
`((format . ,eliscript-diagnostic-format-name)
|
|
98
|
+
(version . ,eliscript-diagnostic-version)
|
|
99
|
+
(code . ,(eliscript-diagnostic-code diagnostic))
|
|
100
|
+
(severity . ,(eliscript-diagnostic-severity diagnostic))
|
|
101
|
+
(phase . ,(eliscript-diagnostic-phase diagnostic))
|
|
102
|
+
(message . ,(eliscript-diagnostic-message diagnostic)))
|
|
103
|
+
(let ((location (eliscript-diagnostic--location diagnostic)))
|
|
104
|
+
(when location `((location . ,location))))))
|
|
105
|
+
|
|
106
|
+
(defun eliscript-diagnostic-to-json (diagnostic)
|
|
107
|
+
"Serialize DIAGNOSTIC using the public diagnostic schema."
|
|
108
|
+
(json-serialize (eliscript-diagnostic-to-alist diagnostic)))
|
|
109
|
+
|
|
110
|
+
(defun eliscript-diagnostic-from-condition (condition-data)
|
|
111
|
+
"Return the structured diagnostic attached to CONDITION-DATA, or nil."
|
|
112
|
+
(let ((message (cadr condition-data)))
|
|
113
|
+
(or (and (stringp message)
|
|
114
|
+
(gethash message eliscript-diagnostic--conditions))
|
|
115
|
+
(cl-find-if #'eliscript-diagnostic-p (cdr condition-data)))))
|
|
116
|
+
|
|
117
|
+
(defun eliscript-diagnostic-condition-message (condition-data)
|
|
118
|
+
"Return CONDITION-DATA's human message without serializing attached data."
|
|
119
|
+
(let ((diagnostic (eliscript-diagnostic-from-condition condition-data)))
|
|
120
|
+
(if diagnostic
|
|
121
|
+
(eliscript-diagnostic-render diagnostic)
|
|
122
|
+
(error-message-string condition-data))))
|
|
123
|
+
|
|
124
|
+
(defun eliscript-diagnostic-from-error
|
|
125
|
+
(condition-data &optional code phase)
|
|
126
|
+
"Return a diagnostic for CONDITION-DATA, adding a generic fallback.
|
|
127
|
+
|
|
128
|
+
CODE and PHASE identify an error that did not originate in a compiler phase."
|
|
129
|
+
(or (eliscript-diagnostic-from-condition condition-data)
|
|
130
|
+
(eliscript-diagnostic-create
|
|
131
|
+
:code (or code "ELI-C0001")
|
|
132
|
+
:severity "error"
|
|
133
|
+
:phase (or phase "cli")
|
|
134
|
+
:message (error-message-string condition-data))))
|
|
135
|
+
|
|
136
|
+
(defun eliscript-diagnostic-signal
|
|
137
|
+
(condition code phase filename span format-string &rest arguments)
|
|
138
|
+
"Signal CONDITION with a structured compiler diagnostic.
|
|
139
|
+
|
|
140
|
+
CODE and PHASE identify the failure. FILENAME and SPAN locate it.
|
|
141
|
+
FORMAT-STRING and ARGUMENTS produce its unformatted message."
|
|
142
|
+
(let* ((message (apply #'format format-string arguments))
|
|
143
|
+
(diagnostic
|
|
144
|
+
(eliscript-diagnostic-create
|
|
145
|
+
:code code
|
|
146
|
+
:severity "error"
|
|
147
|
+
:phase phase
|
|
148
|
+
:message message
|
|
149
|
+
:file (or filename
|
|
150
|
+
(and span (eliscript-source-span-filename span)))
|
|
151
|
+
:span span)))
|
|
152
|
+
(let ((rendered (eliscript-diagnostic-render diagnostic)))
|
|
153
|
+
(puthash rendered diagnostic eliscript-diagnostic--conditions)
|
|
154
|
+
(signal condition (list rendered)))))
|
|
155
|
+
|
|
156
|
+
(provide 'eliscript-diagnostic)
|
|
157
|
+
|
|
158
|
+
;;; eliscript-diagnostic.el ends here
|