kapusta 0.5.0 → 0.8.0
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.
- checksums.yaml +4 -4
- data/README.md +24 -6
- data/bin/fennel-parity +11 -4
- data/examples/classify-wallet.kap +11 -0
- data/examples/import-helpers.kapm +9 -0
- data/examples/macros-import-helpers.kap +3 -0
- data/examples/macros-import-whole.kap +5 -0
- data/examples/macros-import.kap +6 -0
- data/examples/power-of-three.kap +12 -0
- data/examples/shared-macros.kapm +4 -0
- data/exe/kapusta-ls +14 -0
- data/kapusta.gemspec +2 -2
- data/lib/kapusta/compiler/emitter/bindings.rb +38 -4
- data/lib/kapusta/compiler/emitter/collections.rb +51 -59
- data/lib/kapusta/compiler/emitter/control_flow.rb +24 -2
- data/lib/kapusta/compiler/emitter/expressions.rb +0 -2
- data/lib/kapusta/compiler/emitter/interop.rb +2 -1
- data/lib/kapusta/compiler/emitter/patterns.rb +52 -4
- data/lib/kapusta/compiler/emitter/support.rb +1 -1
- data/lib/kapusta/compiler/emitter.rb +1 -1
- data/lib/kapusta/compiler/lua_compat.rb +149 -0
- data/lib/kapusta/compiler/macro_expander.rb +55 -141
- data/lib/kapusta/compiler/macro_gensym.rb +21 -0
- data/lib/kapusta/compiler/macro_importer.rb +81 -0
- data/lib/kapusta/compiler/macro_lowerer.rb +184 -0
- data/lib/kapusta/compiler/normalizer.rb +4 -19
- data/lib/kapusta/compiler.rb +4 -2
- data/lib/kapusta/errors.rb +9 -3
- data/lib/kapusta/formatter.rb +4 -0
- data/lib/kapusta/lsp/definition.rb +67 -0
- data/lib/kapusta/lsp/diagnostics.rb +42 -0
- data/lib/kapusta/lsp/formatting.rb +30 -0
- data/lib/kapusta/lsp/identifier.rb +28 -0
- data/lib/kapusta/lsp/rename.rb +417 -0
- data/lib/kapusta/lsp/scope_walker.rb +643 -0
- data/lib/kapusta/lsp/workspace_index.rb +225 -0
- data/lib/kapusta/lsp.rb +312 -0
- data/lib/kapusta/reader.rb +0 -2
- data/lib/kapusta/version.rb +1 -1
- data/spec/examples_errors_spec.rb +142 -1
- data/spec/examples_spec.rb +12 -0
- data/spec/lsp_spec.rb +603 -0
- metadata +23 -1
|
@@ -27,6 +27,26 @@ RSpec.describe 'examples-errors' do
|
|
|
27
27
|
.to eq("accumulate-missing-iterator.kap:5:3: expected initial value and iterator binding table\n")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
it 'auto-gensym-outside-quasiquote.kap' do
|
|
31
|
+
expect(run_error_example('auto-gensym-outside-quasiquote.kap'))
|
|
32
|
+
.to eq("auto-gensym-outside-quasiquote.kap: auto-gensym x# outside quasiquote\n")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'bad-multisym.kap' do
|
|
36
|
+
expect(run_error_example('bad-multisym.kap'))
|
|
37
|
+
.to eq("bad-multisym.kap:1:8: bad multisym: unbound.foo\n")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'bad-set-target.kap' do
|
|
41
|
+
expect(run_error_example('bad-set-target.kap'))
|
|
42
|
+
.to eq("bad-set-target.kap:2:1: bad set target: 1\n")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'bad-shorthand.kap' do
|
|
46
|
+
expect(run_error_example('bad-shorthand.kap'))
|
|
47
|
+
.to eq("bad-shorthand.kap:2:14: bad shorthand\n")
|
|
48
|
+
end
|
|
49
|
+
|
|
30
50
|
it 'call-empty-form.kap' do
|
|
31
51
|
expect(run_error_example('call-empty-form.kap'))
|
|
32
52
|
.to eq("call-empty-form.kap:7:8: expected a function, macro, or special to call\n")
|
|
@@ -37,16 +57,31 @@ RSpec.describe 'examples-errors' do
|
|
|
37
57
|
.to eq("call-literal-number.kap:6:14: cannot call literal value 1\n")
|
|
38
58
|
end
|
|
39
59
|
|
|
60
|
+
it 'cannot-set-method-binding.kap' do
|
|
61
|
+
expect(run_error_example('cannot-set-method-binding.kap'))
|
|
62
|
+
.to eq("cannot-set-method-binding.kap:2:1: cannot set method binding: foo\n")
|
|
63
|
+
end
|
|
64
|
+
|
|
40
65
|
it 'case-no-patterns.kap' do
|
|
41
66
|
expect(run_error_example('case-no-patterns.kap'))
|
|
42
67
|
.to eq("case-no-patterns.kap:3:5: expected at least one pattern/body pair\n")
|
|
43
68
|
end
|
|
44
69
|
|
|
70
|
+
it 'case-no-subject.kap' do
|
|
71
|
+
expect(run_error_example('case-no-subject.kap'))
|
|
72
|
+
.to eq("case-no-subject.kap:1:1: missing subject\n")
|
|
73
|
+
end
|
|
74
|
+
|
|
45
75
|
it 'case-odd-pattern-body.kap' do
|
|
46
76
|
expect(run_error_example('case-odd-pattern-body.kap'))
|
|
47
77
|
.to eq("case-odd-pattern-body.kap:2:3: expected even number of pattern/body pairs\n")
|
|
48
78
|
end
|
|
49
79
|
|
|
80
|
+
it 'case-unsupported.kap' do
|
|
81
|
+
expect(run_error_example('case-unsupported.kap'))
|
|
82
|
+
.to eq("case-unsupported.kap:1:1: case/match clauses use patterns this compiler cannot translate\n")
|
|
83
|
+
end
|
|
84
|
+
|
|
50
85
|
it 'destructure-literal-number.kap' do
|
|
51
86
|
expect(run_error_example('destructure-literal-number.kap'))
|
|
52
87
|
.to eq("destructure-literal-number.kap:5:3: could not destructure literal\n")
|
|
@@ -119,7 +154,33 @@ RSpec.describe 'examples-errors' do
|
|
|
119
154
|
|
|
120
155
|
it 'import-macros-missing-module.kap' do
|
|
121
156
|
expect(run_error_example('import-macros-missing-module.kap'))
|
|
122
|
-
.to eq("import-macros-missing-module.kap:4:1: import-macros
|
|
157
|
+
.to eq("import-macros-missing-module.kap:4:1: import-macros: module nonexistent-module not found\n")
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'import-macros-macro-not-found.kap' do
|
|
161
|
+
message = 'import-macros: macro missing not exported by module missing-macro-helper'
|
|
162
|
+
expect(run_error_example('import-macros-macro-not-found.kap'))
|
|
163
|
+
.to eq("import-macros-macro-not-found.kap:1:1: #{message}\n")
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'import-macros-no-exports.kap' do
|
|
167
|
+
expect(run_error_example('import-macros-no-exports.kap'))
|
|
168
|
+
.to eq("import-macros-no-exports.kap:1:1: import-macros: module no-exports-helper has no export table\n")
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'import-macros-module-invalid.kap' do
|
|
172
|
+
expect(run_error_example('import-macros-module-invalid.kap'))
|
|
173
|
+
.to eq("import-macros-module-invalid.kap:1:1: import-macros expects a symbol or string module name\n")
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it 'invalid-class-name.kap' do
|
|
177
|
+
expect(run_error_example('invalid-class-name.kap'))
|
|
178
|
+
.to eq("invalid-class-name.kap: invalid class name: lowercase\n")
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'invalid-module-name.kap' do
|
|
182
|
+
expect(run_error_example('invalid-module-name.kap'))
|
|
183
|
+
.to eq("invalid-module-name.kap: invalid module name: lowercase\n")
|
|
123
184
|
end
|
|
124
185
|
|
|
125
186
|
it 'let-odd-bindings.kap' do
|
|
@@ -142,6 +203,16 @@ RSpec.describe 'examples-errors' do
|
|
|
142
203
|
.to eq("local-without-value.kap:6:3: local: expected name and value\n")
|
|
143
204
|
end
|
|
144
205
|
|
|
206
|
+
it 'macro-name-must-be-symbol.kap' do
|
|
207
|
+
expect(run_error_example('macro-name-must-be-symbol.kap'))
|
|
208
|
+
.to eq("macro-name-must-be-symbol.kap: macro name must be a symbol\n")
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
it 'macro-params-must-be-vector.kap' do
|
|
212
|
+
expect(run_error_example('macro-params-must-be-vector.kap'))
|
|
213
|
+
.to eq("macro-params-must-be-vector.kap:1:12: macro params must be a vector\n")
|
|
214
|
+
end
|
|
215
|
+
|
|
145
216
|
it 'macro-unsafe-bind.kap' do
|
|
146
217
|
expect(run_error_example('macro-unsafe-bind.kap'))
|
|
147
218
|
.to eq("macro-unsafe-bind.kap:13:8: macro tried to bind unsafe without gensym\n")
|
|
@@ -152,16 +223,46 @@ RSpec.describe 'examples-errors' do
|
|
|
152
223
|
.to eq("macro-vararg-with-operator.kap:5:3: tried to use vararg with operator\n")
|
|
153
224
|
end
|
|
154
225
|
|
|
226
|
+
it 'macros-entry-must-be-fn.kap' do
|
|
227
|
+
expect(run_error_example('macros-entry-must-be-fn.kap'))
|
|
228
|
+
.to eq("macros-entry-must-be-fn.kap: macros entry value must be a fn form, got 1\n")
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
it 'macros-entry-params-must-be-vector.kap' do
|
|
232
|
+
expect(run_error_example('macros-entry-params-must-be-vector.kap'))
|
|
233
|
+
.to eq("macros-entry-params-must-be-vector.kap:1:19: macros entry params must be a vector\n")
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it 'macros-expects-hash.kap' do
|
|
237
|
+
expect(run_error_example('macros-expects-hash.kap'))
|
|
238
|
+
.to eq("macros-expects-hash.kap: macros expects a hash literal\n")
|
|
239
|
+
end
|
|
240
|
+
|
|
155
241
|
it 'match-no-patterns.kap' do
|
|
156
242
|
expect(run_error_example('match-no-patterns.kap'))
|
|
157
243
|
.to eq("match-no-patterns.kap:3:5: expected at least one pattern/body pair\n")
|
|
158
244
|
end
|
|
159
245
|
|
|
246
|
+
it 'match-no-subject.kap' do
|
|
247
|
+
expect(run_error_example('match-no-subject.kap'))
|
|
248
|
+
.to eq("match-no-subject.kap:1:1: missing subject\n")
|
|
249
|
+
end
|
|
250
|
+
|
|
160
251
|
it 'mismatched-brackets.kap' do
|
|
161
252
|
expect(run_error_example('mismatched-brackets.kap'))
|
|
162
253
|
.to eq("mismatched-brackets.kap:4:19: unexpected closing delimiter ')'\n")
|
|
163
254
|
end
|
|
164
255
|
|
|
256
|
+
it 'nested-quasiquote.kap' do
|
|
257
|
+
expect(run_error_example('nested-quasiquote.kap'))
|
|
258
|
+
.to eq("nested-quasiquote.kap: nested quasiquote is not supported\n")
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
it 'odd-forms-in-hash.kap' do
|
|
262
|
+
expect(run_error_example('odd-forms-in-hash.kap'))
|
|
263
|
+
.to eq("odd-forms-in-hash.kap:1:9: odd number of forms in hash\n")
|
|
264
|
+
end
|
|
265
|
+
|
|
165
266
|
it 'only-rest-param.kap' do
|
|
166
267
|
expect(run_error_example('only-rest-param.kap'))
|
|
167
268
|
.to eq("only-rest-param.kap:4:1: expected rest argument before last parameter\n")
|
|
@@ -177,6 +278,11 @@ RSpec.describe 'examples-errors' do
|
|
|
177
278
|
.to eq("rest-not-last.kap:6:3: expected rest argument before last parameter\n")
|
|
178
279
|
end
|
|
179
280
|
|
|
281
|
+
it 'set-immutable-let.kap' do
|
|
282
|
+
expect(run_error_example('set-immutable-let.kap'))
|
|
283
|
+
.to eq("set-immutable-let.kap:2:3: expected var counter\n")
|
|
284
|
+
end
|
|
285
|
+
|
|
180
286
|
it 'set-immutable-local.kap' do
|
|
181
287
|
expect(run_error_example('set-immutable-local.kap'))
|
|
182
288
|
.to eq("set-immutable-local.kap:8:3: expected var counter\n")
|
|
@@ -212,11 +318,46 @@ RSpec.describe 'examples-errors' do
|
|
|
212
318
|
.to eq("unclosed-table.kap:4:21: unexpected closing delimiter ']'\n")
|
|
213
319
|
end
|
|
214
320
|
|
|
321
|
+
it 'undefined-symbol.kap' do
|
|
322
|
+
expect(run_error_example('undefined-symbol.kap'))
|
|
323
|
+
.to eq("undefined-symbol.kap:1:8: undefined symbol: missing-symbol\n")
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
it 'unexpected-eof.kap' do
|
|
327
|
+
expect(run_error_example('unexpected-eof.kap'))
|
|
328
|
+
.to eq("unexpected-eof.kap:1:2: unexpected eof\n")
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
it 'unexpected-vararg.kap' do
|
|
332
|
+
expect(run_error_example('unexpected-vararg.kap'))
|
|
333
|
+
.to eq("unexpected-vararg.kap:2:10: unexpected vararg\n")
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
it 'unknown-special-form.kap' do
|
|
337
|
+
expect(run_error_example('unknown-special-form.kap'))
|
|
338
|
+
.to eq("unknown-special-form.kap:1:1: unknown special form: catch\n")
|
|
339
|
+
end
|
|
340
|
+
|
|
215
341
|
it 'unquote-outside-quote.kap' do
|
|
216
342
|
expect(run_error_example('unquote-outside-quote.kap'))
|
|
217
343
|
.to eq("unquote-outside-quote.kap:5:10: cannot emit form: ,x\n")
|
|
218
344
|
end
|
|
219
345
|
|
|
346
|
+
it 'unquote-splice-outside-list.kap' do
|
|
347
|
+
expect(run_error_example('unquote-splice-outside-list.kap'))
|
|
348
|
+
.to eq("unquote-splice-outside-list.kap: unquote-splice must appear inside a quoted list/vec\n")
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
it 'unterminated-string.kap' do
|
|
352
|
+
expect(run_error_example('unterminated-string.kap'))
|
|
353
|
+
.to eq("unterminated-string.kap:1:8: unterminated string\n")
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
it 'vararg-not-last.kap' do
|
|
357
|
+
expect(run_error_example('vararg-not-last.kap'))
|
|
358
|
+
.to eq("vararg-not-last.kap:1:1: expected vararg as last parameter\n")
|
|
359
|
+
end
|
|
360
|
+
|
|
220
361
|
it 'var-without-value.kap' do
|
|
221
362
|
expect(run_error_example('var-without-value.kap'))
|
|
222
363
|
.to eq("var-without-value.kap:6:3: var: expected name and value\n")
|
data/spec/examples_spec.rb
CHANGED
|
@@ -551,4 +551,16 @@ RSpec.describe 'examples' do
|
|
|
551
551
|
50
|
|
552
552
|
OUT
|
|
553
553
|
end
|
|
554
|
+
|
|
555
|
+
it 'macros-import.kap' do
|
|
556
|
+
expect(run_example('macros-import.kap')).to eq("8\n")
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
it 'macros-import-helpers.kap' do
|
|
560
|
+
expect(run_example('macros-import-helpers.kap')).to eq("60\n")
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
it 'macros-import-whole.kap' do
|
|
564
|
+
expect(run_example('macros-import-whole.kap')).to eq("7\n")
|
|
565
|
+
end
|
|
554
566
|
end
|