@fraczak/k 6.3.3 → 6.5.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.
- package/CHANGELOG.md +17 -0
- package/DOCS/CODECS.md +258 -0
- package/DOCS/DICTIONARY.md +1172 -0
- package/DOCS/KIR_SPECIALIZATION_DESIGN.md +51 -46
- package/DOCS/KIR_V1.md +221 -0
- package/DOCS/KVM_EXECUTION_MODEL.md +56 -19
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +2 -1
- package/DOCS/PROFILING_AND_TRACING.md +196 -0
- package/DOCS/REPL.md +61 -4
- package/DOCS/WEB_REPL_REQUIREMENTS.md +135 -0
- package/DOCS/dependency-graph.md +144 -0
- package/Examples/arithmetics.k +108 -82
- package/Examples/bnat.k +1 -1
- package/Examples/buda.k +44 -0
- package/Examples/ieee.k +300 -8671
- package/Examples/poly.k +67 -0
- package/README.md +68 -19
- package/Value.mjs +8 -2
- package/augmentation.mjs +9 -7
- package/backend-api.mjs +11 -2
- package/backends/arm64/README.md +104 -0
- package/backends/arm64/bin/k-arm64-compile.mjs +101 -0
- package/backends/arm64/bin/k-arm64-run.mjs +58 -0
- package/backends/arm64/bin/k-arm64.mjs +88 -0
- package/backends/arm64/scripts/run-tests.mjs +41 -0
- package/backends/arm64/src/arm64.mjs +229 -0
- package/backends/arm64/src/cli.mjs +155 -0
- package/backends/arm64/src/kvm2arm64.mjs +906 -0
- package/backends/arm64/src/runtime.c +728 -0
- package/backends/arm64/tests/integration.sh +112 -0
- package/backends/arm64/tests/test-arm64.mjs +240 -0
- package/backends/llvm/README.md +135 -0
- package/backends/llvm/bin/k-llvm-build.mjs +71 -0
- package/backends/llvm/bin/k-llvm-compile.mjs +68 -0
- package/backends/llvm/bin/k-llvm-jit.mjs +160 -0
- package/backends/llvm/bin/k-llvm-run.mjs +90 -0
- package/backends/llvm/runtime/krt.c +1508 -0
- package/backends/llvm/runtime/krt.h +109 -0
- package/backends/llvm/scripts/conformance.mjs +76 -0
- package/backends/llvm/scripts/run-tests.mjs +28 -0
- package/backends/llvm/src/executable.mjs +562 -0
- package/backends/llvm/src/kvm2llvm.mjs +998 -0
- package/backends/llvm/src/llvm.mjs +1092 -0
- package/backends/llvm/tests/composition-driver.c +22 -0
- package/backends/llvm/tests/identity-driver.c +27 -0
- package/backends/llvm/tests/integration.sh +153 -0
- package/backends/llvm/tests/perf-support.mjs +735 -0
- package/backends/llvm/tests/product-driver.c +23 -0
- package/backends/llvm/tests/projection-driver.c +19 -0
- package/backends/llvm/tests/relation-driver.c +29 -0
- package/backends/llvm/tests/test-llvm.mjs +240 -0
- package/backends/llvm/tests/union-driver.c +31 -0
- package/backends/llvm/tests/variant-driver.c +19 -0
- package/backends/llvm/tests/variant-projection-driver.c +21 -0
- package/backends/wasm/DOCS/USE-WEB-ASSEMBLY.md +233 -0
- package/backends/wasm/README.md +97 -0
- package/backends/wasm/TECHNICAL-DEBT.md +58 -0
- package/backends/wasm/bin/k-wasm-compile.mjs +50 -0
- package/backends/wasm/bin/k-wasm-run.mjs +140 -0
- package/backends/wasm/bin/k-wasm.mjs +49 -0
- package/backends/wasm/demo_ieee.mjs +319 -0
- package/backends/wasm/runtime.wat +475 -0
- package/backends/wasm/scripts/run-tests.mjs +41 -0
- package/backends/wasm/src/cli.mjs +133 -0
- package/backends/wasm/src/kvm2wasm.mjs +697 -0
- package/backends/wasm/src/wasm.mjs +1054 -0
- package/backends/wasm/tests/integration.sh +182 -0
- package/backends/wasm/tests/perf-support.mjs +336 -0
- package/backends/wasm/tests/test-wasm.mjs +625 -0
- package/browser/repl-browser.mjs +1584 -0
- package/browser/shims/assert.mjs +19 -0
- package/browser/shims/buffer.mjs +224 -0
- package/browser/shims/crypto.mjs +103 -0
- package/browser/shims/fs.mjs +159 -0
- package/browser/shims/os.mjs +17 -0
- package/browser/shims/path.mjs +54 -0
- package/browser/shims/process.mjs +44 -0
- package/browser/shims/readline.mjs +11 -0
- package/browser/shims/url.mjs +12 -0
- package/browser/vfs-data.mjs +19 -0
- package/codecs/README.md +3 -0
- package/codecs/runtime/show-value.mjs +12 -3
- package/conformance/helper-reuse/case.json +8 -0
- package/conformance/helper-reuse/expected.kv +1 -0
- package/conformance/helper-reuse/input.kv +1 -0
- package/conformance/helper-reuse/program.k +2 -0
- package/conformance/identity/case.json +8 -0
- package/conformance/identity/expected.kv +1 -0
- package/conformance/identity/input.kv +1 -0
- package/conformance/identity/program.k +1 -0
- package/conformance/product-projection/case.json +8 -0
- package/conformance/product-projection/expected.kv +1 -0
- package/conformance/product-projection/input.kv +1 -0
- package/conformance/product-projection/program.k +1 -0
- package/conformance/run.mjs +149 -0
- package/conformance/variant-construction/case.json +8 -0
- package/conformance/variant-construction/expected.kv +1 -0
- package/conformance/variant-construction/input.kv +1 -0
- package/conformance/variant-construction/program.k +1 -0
- package/harness/adapters/arm64.mjs +105 -0
- package/harness/adapters/kvm.mjs +144 -0
- package/harness/adapters/llvm.mjs +118 -0
- package/harness/adapters/native.mjs +77 -0
- package/harness/adapters/wasm.mjs +169 -0
- package/harness/backend.mjs +95 -0
- package/harness/cli.mjs +130 -0
- package/harness/format.mjs +95 -0
- package/harness/index.mjs +25 -0
- package/harness/persistent.mjs +121 -0
- package/harness/registry.mjs +44 -0
- package/harness/suite.mjs +257 -0
- package/harness/suites/poly.mjs +156 -0
- package/harness/trace.mjs +50 -0
- package/harness/util.mjs +92 -0
- package/intrinsics.mjs +41 -0
- package/kir.mjs +399 -0
- package/kvm.mjs +585 -81
- package/objects/README.md +37 -3
- package/objects/compile.mjs +15 -22
- package/objects/inspect.mjs +96 -0
- package/objects/validate.mjs +415 -0
- package/package.json +51 -19
- package/repl-codecs.mjs +105 -6
- package/repl.mjs +335 -49
- package/run.mjs +2 -7
- package/scripts/benchmark.mjs +406 -22
- package/scripts/build-repl-html.mjs +1784 -0
- package/scripts/perf-ieee.mjs +586 -0
- package/scripts/perf-int.mjs +531 -0
- package/scripts/perf-poly.mjs +945 -0
- package/scripts/render-benchmark.mjs +12 -8
- package/scripts/run-tests.mjs +6 -0
- package/tests/integration.sh +19 -2
- package/tests/test-arithmetics.mjs +54 -0
- package/tests/test-ieee-arithmetic.mjs +4 -0
- package/tests/test-kir.mjs +85 -0
- package/tests/test-kvm-polymorphic.mjs +278 -0
- package/tests/test-kvm.mjs +25 -6
- package/tests/test-poly.mjs +129 -0
- package/tests/test-repl-html.mjs +303 -0
- package/tests/test-repl.mjs +144 -1
- package/tests/test-validate-object.mjs +40 -0
- package/a.klib +0 -1
- package/a.kvm +0 -142676
- package/a.wasm +0 -0
- package/benchmark-results.html +0 -532
- package/benchmark-results.json +0 -480
- package/k-vscode/.vscode/launch.json +0 -14
- package/k-vscode/README.md +0 -75
- package/k-vscode/extension.js +0 -273
- package/k-vscode/language-configuration.json +0 -42
- package/k-vscode/package.json +0 -79
- package/k-vscode/snippets/k.json +0 -92
- package/k-vscode/syntaxes/k.tmLanguage.json +0 -599
- package/k-vscode/test/background-ranges.test.js +0 -50
- package/k-vscode/themes/k-contrast-color-theme.json +0 -104
- package/scripts/git-hooks/pre-commit +0 -10
|
@@ -1,599 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
3
|
-
"name": "k",
|
|
4
|
-
"scopeName": "source.k",
|
|
5
|
-
"patterns": [
|
|
6
|
-
{ "include": "#comment-block" },
|
|
7
|
-
{ "include": "#comment-line" },
|
|
8
|
-
{ "include": "#type-definition" },
|
|
9
|
-
{ "include": "#relation-definition" },
|
|
10
|
-
{ "include": "#main-relation-expression" }
|
|
11
|
-
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"comment-block": {
|
|
14
|
-
"name": "comment.block.k",
|
|
15
|
-
"begin": "/\\*",
|
|
16
|
-
"end": "\\*/",
|
|
17
|
-
"beginCaptures": {
|
|
18
|
-
"0": { "name": "punctuation.definition.comment.begin.k" }
|
|
19
|
-
},
|
|
20
|
-
"endCaptures": {
|
|
21
|
-
"0": { "name": "punctuation.definition.comment.end.k" }
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"comment-line": {
|
|
25
|
-
"name": "comment.line.k",
|
|
26
|
-
"match": "(?://|--|%|#|\\\\\\\\).*$"
|
|
27
|
-
},
|
|
28
|
-
"type-definition": {
|
|
29
|
-
"comment": "$ name = code; defines a named code (type)",
|
|
30
|
-
"name": "meta.definition.type.k",
|
|
31
|
-
"contentName": "meta.expression.type.k",
|
|
32
|
-
"begin": "(\\$)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)\\s*(=)",
|
|
33
|
-
"end": "(;)",
|
|
34
|
-
"beginCaptures": {
|
|
35
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
36
|
-
"2": { "name": "entity.name.type.k" },
|
|
37
|
-
"3": { "name": "keyword.operator.assignment.k" }
|
|
38
|
-
},
|
|
39
|
-
"endCaptures": {
|
|
40
|
-
"1": { "name": "punctuation.terminator.definition.k" }
|
|
41
|
-
},
|
|
42
|
-
"patterns": [
|
|
43
|
-
{ "include": "#type-content" }
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
"relation-definition": {
|
|
47
|
-
"comment": "name = expression; defines a named relation/function",
|
|
48
|
-
"name": "meta.definition.function.k",
|
|
49
|
-
"contentName": "meta.expression.relation.k",
|
|
50
|
-
"begin": "^\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)\\s*(=)",
|
|
51
|
-
"end": "(;)",
|
|
52
|
-
"beginCaptures": {
|
|
53
|
-
"1": { "name": "support.function.identifier.k" },
|
|
54
|
-
"2": { "name": "keyword.operator.assignment.k" }
|
|
55
|
-
},
|
|
56
|
-
"endCaptures": {
|
|
57
|
-
"1": { "name": "punctuation.terminator.definition.k" }
|
|
58
|
-
},
|
|
59
|
-
"patterns": [
|
|
60
|
-
{ "include": "#relation-content" }
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
"main-relation-expression": {
|
|
64
|
-
"comment": "The parser requires one trailing top-level relation expression after definitions",
|
|
65
|
-
"name": "meta.expression.relation.k",
|
|
66
|
-
"begin": "(?=\\S)",
|
|
67
|
-
"end": "(?=$)",
|
|
68
|
-
"patterns": [
|
|
69
|
-
{ "include": "#relation-content" }
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
"type-content": {
|
|
73
|
-
"patterns": [
|
|
74
|
-
{ "include": "#comment-block" },
|
|
75
|
-
{ "include": "#comment-line" },
|
|
76
|
-
{ "include": "#type-product" },
|
|
77
|
-
{ "include": "#type-union" },
|
|
78
|
-
{ "include": "#canonical-type-ref" },
|
|
79
|
-
{ "include": "#type-name" },
|
|
80
|
-
{ "include": "#separator" }
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
"type-product": {
|
|
84
|
-
"name": "meta.expression.type.product.k",
|
|
85
|
-
"begin": "(\\{)",
|
|
86
|
-
"end": "(\\})",
|
|
87
|
-
"beginCaptures": {
|
|
88
|
-
"1": { "name": "punctuation.section.product.begin.k" }
|
|
89
|
-
},
|
|
90
|
-
"endCaptures": {
|
|
91
|
-
"1": { "name": "punctuation.section.product.end.k" }
|
|
92
|
-
},
|
|
93
|
-
"patterns": [
|
|
94
|
-
{ "include": "#comment-block" },
|
|
95
|
-
{ "include": "#comment-line" },
|
|
96
|
-
{ "include": "#type-product-label" },
|
|
97
|
-
{ "include": "#type-product" },
|
|
98
|
-
{ "include": "#type-union" },
|
|
99
|
-
{ "include": "#canonical-type-ref" },
|
|
100
|
-
{ "include": "#type-name" },
|
|
101
|
-
{ "include": "#separator" }
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
|
-
"type-union": {
|
|
105
|
-
"name": "meta.expression.type.union.k",
|
|
106
|
-
"begin": "(<)",
|
|
107
|
-
"end": "(>)",
|
|
108
|
-
"beginCaptures": {
|
|
109
|
-
"1": { "name": "punctuation.section.union.begin.k" }
|
|
110
|
-
},
|
|
111
|
-
"endCaptures": {
|
|
112
|
-
"1": { "name": "punctuation.section.union.end.k" }
|
|
113
|
-
},
|
|
114
|
-
"patterns": [
|
|
115
|
-
{ "include": "#comment-block" },
|
|
116
|
-
{ "include": "#comment-line" },
|
|
117
|
-
{ "include": "#type-union-tag" },
|
|
118
|
-
{ "include": "#type-product" },
|
|
119
|
-
{ "include": "#type-union" },
|
|
120
|
-
{ "include": "#canonical-type-ref" },
|
|
121
|
-
{ "include": "#type-name" },
|
|
122
|
-
{ "include": "#separator" }
|
|
123
|
-
]
|
|
124
|
-
},
|
|
125
|
-
"type-product-label": {
|
|
126
|
-
"patterns": [
|
|
127
|
-
{
|
|
128
|
-
"name": "entity.name.label.k",
|
|
129
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*(?=\\s*[,}])"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"name": "entity.name.label.k",
|
|
133
|
-
"match": "(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')(?=\\s*[,}])"
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
},
|
|
137
|
-
"type-union-tag": {
|
|
138
|
-
"patterns": [
|
|
139
|
-
{
|
|
140
|
-
"name": "entity.name.tag.k",
|
|
141
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*(?=\\s*[,>])"
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"name": "entity.name.tag.k",
|
|
145
|
-
"match": "(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')(?=\\s*[,>])"
|
|
146
|
-
}
|
|
147
|
-
]
|
|
148
|
-
},
|
|
149
|
-
"type-expression": {
|
|
150
|
-
"patterns": [
|
|
151
|
-
{
|
|
152
|
-
"name": "meta.expression.type.k",
|
|
153
|
-
"match": "(\\$)\\s*(@)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
154
|
-
"captures": {
|
|
155
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
156
|
-
"2": { "name": "punctuation.definition.canonical.k" },
|
|
157
|
-
"3": { "name": "support.type.canonical.k" }
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
"name": "meta.expression.type.k",
|
|
162
|
-
"match": "(\\$)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
163
|
-
"captures": {
|
|
164
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
165
|
-
"2": { "name": "support.type.k" }
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
"name": "meta.expression.type.k",
|
|
170
|
-
"begin": "(\\$)\\s*(\\{)",
|
|
171
|
-
"end": "(\\})",
|
|
172
|
-
"beginCaptures": {
|
|
173
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
174
|
-
"2": { "name": "punctuation.section.product.begin.k" }
|
|
175
|
-
},
|
|
176
|
-
"endCaptures": {
|
|
177
|
-
"1": { "name": "punctuation.section.product.end.k" }
|
|
178
|
-
},
|
|
179
|
-
"patterns": [
|
|
180
|
-
{ "include": "#type-product-label" },
|
|
181
|
-
{ "include": "#type-content" }
|
|
182
|
-
]
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
"name": "meta.expression.type.k",
|
|
186
|
-
"begin": "(\\$)\\s*(<)",
|
|
187
|
-
"end": "(>)",
|
|
188
|
-
"beginCaptures": {
|
|
189
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
190
|
-
"2": { "name": "punctuation.section.union.begin.k" }
|
|
191
|
-
},
|
|
192
|
-
"endCaptures": {
|
|
193
|
-
"1": { "name": "punctuation.section.union.end.k" }
|
|
194
|
-
},
|
|
195
|
-
"patterns": [
|
|
196
|
-
{ "include": "#type-union-tag" },
|
|
197
|
-
{ "include": "#type-content" }
|
|
198
|
-
]
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
},
|
|
202
|
-
"type-name": {
|
|
203
|
-
"name": "support.type.k",
|
|
204
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*"
|
|
205
|
-
},
|
|
206
|
-
"canonical-type-ref": {
|
|
207
|
-
"match": "(@)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
208
|
-
"captures": {
|
|
209
|
-
"1": { "name": "punctuation.definition.canonical.k" },
|
|
210
|
-
"2": { "name": "support.type.canonical.k" }
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
"relation-content": {
|
|
214
|
-
"patterns": [
|
|
215
|
-
{ "include": "#comment-block" },
|
|
216
|
-
{ "include": "#comment-line" },
|
|
217
|
-
{ "include": "#filter-expression" },
|
|
218
|
-
{ "include": "#type-expression" },
|
|
219
|
-
{ "include": "#projection-dot" },
|
|
220
|
-
{ "include": "#projection-slash" },
|
|
221
|
-
{ "include": "#variant-intro" },
|
|
222
|
-
{ "include": "#canonical-function-ref" },
|
|
223
|
-
{ "include": "#relation-product" },
|
|
224
|
-
{ "include": "#relation-union" },
|
|
225
|
-
{ "include": "#relation-parens" },
|
|
226
|
-
{ "include": "#string-double" },
|
|
227
|
-
{ "include": "#string-single" },
|
|
228
|
-
{ "include": "#dots" },
|
|
229
|
-
{ "include": "#relation-identifier" },
|
|
230
|
-
{ "include": "#separator" },
|
|
231
|
-
{ "include": "#brackets" }
|
|
232
|
-
]
|
|
233
|
-
},
|
|
234
|
-
"relation-product": {
|
|
235
|
-
"begin": "(\\{)",
|
|
236
|
-
"end": "(\\})",
|
|
237
|
-
"beginCaptures": {
|
|
238
|
-
"1": { "name": "punctuation.section.product.begin.k" }
|
|
239
|
-
},
|
|
240
|
-
"endCaptures": {
|
|
241
|
-
"1": { "name": "punctuation.section.product.end.k" }
|
|
242
|
-
},
|
|
243
|
-
"patterns": [
|
|
244
|
-
{ "include": "#relation-product-label" },
|
|
245
|
-
{ "include": "#relation-content" }
|
|
246
|
-
]
|
|
247
|
-
},
|
|
248
|
-
"relation-union": {
|
|
249
|
-
"begin": "(<)",
|
|
250
|
-
"end": "(>)",
|
|
251
|
-
"beginCaptures": {
|
|
252
|
-
"1": { "name": "punctuation.section.union.begin.k" }
|
|
253
|
-
},
|
|
254
|
-
"endCaptures": {
|
|
255
|
-
"1": { "name": "punctuation.section.union.end.k" }
|
|
256
|
-
},
|
|
257
|
-
"patterns": [
|
|
258
|
-
{ "include": "#relation-content" }
|
|
259
|
-
]
|
|
260
|
-
},
|
|
261
|
-
"relation-parens": {
|
|
262
|
-
"begin": "(\\()",
|
|
263
|
-
"end": "(\\))",
|
|
264
|
-
"beginCaptures": {
|
|
265
|
-
"1": { "name": "punctuation.section.parens.begin.k" }
|
|
266
|
-
},
|
|
267
|
-
"endCaptures": {
|
|
268
|
-
"1": { "name": "punctuation.section.parens.end.k" }
|
|
269
|
-
},
|
|
270
|
-
"patterns": [
|
|
271
|
-
{ "include": "#relation-content" }
|
|
272
|
-
]
|
|
273
|
-
},
|
|
274
|
-
"relation-product-label": {
|
|
275
|
-
"patterns": [
|
|
276
|
-
{
|
|
277
|
-
"name": "entity.name.label.k",
|
|
278
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*(?=\\s*[,}])"
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
"name": "entity.name.label.k",
|
|
282
|
-
"match": "(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')(?=\\s*[,}])"
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
},
|
|
286
|
-
"filter-expression": {
|
|
287
|
-
"patterns": [
|
|
288
|
-
{
|
|
289
|
-
"name": "meta.expression.filter.k",
|
|
290
|
-
"begin": "(\\?)\\s*(<)",
|
|
291
|
-
"end": "(>)(?:\\s*(=)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*))?",
|
|
292
|
-
"beginCaptures": {
|
|
293
|
-
"1": { "name": "keyword.operator.filter.k" },
|
|
294
|
-
"2": { "name": "punctuation.section.filter.union.begin.k" }
|
|
295
|
-
},
|
|
296
|
-
"endCaptures": {
|
|
297
|
-
"1": { "name": "punctuation.section.filter.union.end.k" },
|
|
298
|
-
"2": { "name": "keyword.operator.binding.k" },
|
|
299
|
-
"3": { "name": "variable.other.pattern.k" }
|
|
300
|
-
},
|
|
301
|
-
"patterns": [
|
|
302
|
-
{ "include": "#filter-union-content" }
|
|
303
|
-
]
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
"name": "meta.expression.filter.k",
|
|
307
|
-
"begin": "(\\?)\\s*(\\{)",
|
|
308
|
-
"end": "(\\})(?:\\s*(=)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*))?",
|
|
309
|
-
"beginCaptures": {
|
|
310
|
-
"1": { "name": "keyword.operator.filter.k" },
|
|
311
|
-
"2": { "name": "punctuation.section.filter.product.begin.k" }
|
|
312
|
-
},
|
|
313
|
-
"endCaptures": {
|
|
314
|
-
"1": { "name": "punctuation.section.filter.product.end.k" },
|
|
315
|
-
"2": { "name": "keyword.operator.binding.k" },
|
|
316
|
-
"3": { "name": "variable.other.pattern.k" }
|
|
317
|
-
},
|
|
318
|
-
"patterns": [
|
|
319
|
-
{ "include": "#filter-product-content" }
|
|
320
|
-
]
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
"name": "meta.expression.filter.k",
|
|
324
|
-
"begin": "(\\?)\\s*(\\()",
|
|
325
|
-
"end": "(\\))(?:\\s*(=)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*))?",
|
|
326
|
-
"beginCaptures": {
|
|
327
|
-
"1": { "name": "keyword.operator.filter.k" },
|
|
328
|
-
"2": { "name": "punctuation.section.filter.any.begin.k" }
|
|
329
|
-
},
|
|
330
|
-
"endCaptures": {
|
|
331
|
-
"1": { "name": "punctuation.section.filter.any.end.k" },
|
|
332
|
-
"2": { "name": "keyword.operator.binding.k" },
|
|
333
|
-
"3": { "name": "variable.other.pattern.k" }
|
|
334
|
-
},
|
|
335
|
-
"patterns": [
|
|
336
|
-
{ "include": "#filter-any-content" }
|
|
337
|
-
]
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
"name": "meta.expression.filter.k",
|
|
341
|
-
"match": "(\\?)\\s*(\\$)\\s*(@)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
342
|
-
"captures": {
|
|
343
|
-
"1": { "name": "keyword.operator.filter.k" },
|
|
344
|
-
"2": { "name": "keyword.operator.type.k" },
|
|
345
|
-
"3": { "name": "punctuation.definition.canonical.k" },
|
|
346
|
-
"4": { "name": "support.type.canonical.k" }
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
"name": "meta.expression.filter.k",
|
|
351
|
-
"match": "(\\?)\\s*(\\$)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
352
|
-
"captures": {
|
|
353
|
-
"1": { "name": "keyword.operator.filter.k" },
|
|
354
|
-
"2": { "name": "keyword.operator.type.k" },
|
|
355
|
-
"3": { "name": "support.type.k" }
|
|
356
|
-
}
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
"name": "meta.expression.filter.k",
|
|
360
|
-
"match": "(\\?)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
361
|
-
"captures": {
|
|
362
|
-
"1": { "name": "keyword.operator.filter.k" },
|
|
363
|
-
"2": { "name": "variable.other.pattern.k" }
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
]
|
|
367
|
-
},
|
|
368
|
-
"filter-union": {
|
|
369
|
-
"name": "meta.expression.filter.k",
|
|
370
|
-
"begin": "(<)",
|
|
371
|
-
"end": "(>)(?:\\s*(=)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*))?",
|
|
372
|
-
"beginCaptures": {
|
|
373
|
-
"1": { "name": "punctuation.section.filter.union.begin.k" }
|
|
374
|
-
},
|
|
375
|
-
"endCaptures": {
|
|
376
|
-
"1": { "name": "punctuation.section.filter.union.end.k" },
|
|
377
|
-
"2": { "name": "keyword.operator.binding.k" },
|
|
378
|
-
"3": { "name": "variable.other.pattern.k" }
|
|
379
|
-
},
|
|
380
|
-
"patterns": [
|
|
381
|
-
{ "include": "#filter-union-content" }
|
|
382
|
-
]
|
|
383
|
-
},
|
|
384
|
-
"filter-product": {
|
|
385
|
-
"name": "meta.expression.filter.k",
|
|
386
|
-
"begin": "(\\{)",
|
|
387
|
-
"end": "(\\})(?:\\s*(=)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*))?",
|
|
388
|
-
"beginCaptures": {
|
|
389
|
-
"1": { "name": "punctuation.section.filter.product.begin.k" }
|
|
390
|
-
},
|
|
391
|
-
"endCaptures": {
|
|
392
|
-
"1": { "name": "punctuation.section.filter.product.end.k" },
|
|
393
|
-
"2": { "name": "keyword.operator.binding.k" },
|
|
394
|
-
"3": { "name": "variable.other.pattern.k" }
|
|
395
|
-
},
|
|
396
|
-
"patterns": [
|
|
397
|
-
{ "include": "#filter-product-content" }
|
|
398
|
-
]
|
|
399
|
-
},
|
|
400
|
-
"filter-any": {
|
|
401
|
-
"name": "meta.expression.filter.k",
|
|
402
|
-
"begin": "(\\()",
|
|
403
|
-
"end": "(\\))(?:\\s*(=)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*))?",
|
|
404
|
-
"beginCaptures": {
|
|
405
|
-
"1": { "name": "punctuation.section.filter.any.begin.k" }
|
|
406
|
-
},
|
|
407
|
-
"endCaptures": {
|
|
408
|
-
"1": { "name": "punctuation.section.filter.any.end.k" },
|
|
409
|
-
"2": { "name": "keyword.operator.binding.k" },
|
|
410
|
-
"3": { "name": "variable.other.pattern.k" }
|
|
411
|
-
},
|
|
412
|
-
"patterns": [
|
|
413
|
-
{ "include": "#filter-any-content" }
|
|
414
|
-
]
|
|
415
|
-
},
|
|
416
|
-
"filter-union-content": {
|
|
417
|
-
"patterns": [
|
|
418
|
-
{ "include": "#comment-block" },
|
|
419
|
-
{ "include": "#comment-line" },
|
|
420
|
-
{ "include": "#filter-tag" },
|
|
421
|
-
{ "include": "#filter-product" },
|
|
422
|
-
{ "include": "#filter-union" },
|
|
423
|
-
{ "include": "#filter-any" },
|
|
424
|
-
{ "include": "#filter-type-ref" },
|
|
425
|
-
{ "include": "#dots" },
|
|
426
|
-
{ "include": "#pattern-variable" },
|
|
427
|
-
{ "include": "#separator" }
|
|
428
|
-
]
|
|
429
|
-
},
|
|
430
|
-
"filter-product-content": {
|
|
431
|
-
"patterns": [
|
|
432
|
-
{ "include": "#comment-block" },
|
|
433
|
-
{ "include": "#comment-line" },
|
|
434
|
-
{ "include": "#filter-label" },
|
|
435
|
-
{ "include": "#filter-product" },
|
|
436
|
-
{ "include": "#filter-union" },
|
|
437
|
-
{ "include": "#filter-any" },
|
|
438
|
-
{ "include": "#filter-type-ref" },
|
|
439
|
-
{ "include": "#dots" },
|
|
440
|
-
{ "include": "#pattern-variable" },
|
|
441
|
-
{ "include": "#separator" }
|
|
442
|
-
]
|
|
443
|
-
},
|
|
444
|
-
"filter-any-content": {
|
|
445
|
-
"patterns": [
|
|
446
|
-
{ "include": "#comment-block" },
|
|
447
|
-
{ "include": "#comment-line" },
|
|
448
|
-
{ "include": "#dots" },
|
|
449
|
-
{ "include": "#separator" }
|
|
450
|
-
]
|
|
451
|
-
},
|
|
452
|
-
"filter-label": {
|
|
453
|
-
"patterns": [
|
|
454
|
-
{
|
|
455
|
-
"name": "entity.name.label.k",
|
|
456
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*(?=\\s*[,}])"
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
"name": "entity.name.label.k",
|
|
460
|
-
"match": "(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')(?=\\s*[,}])"
|
|
461
|
-
}
|
|
462
|
-
]
|
|
463
|
-
},
|
|
464
|
-
"filter-tag": {
|
|
465
|
-
"patterns": [
|
|
466
|
-
{
|
|
467
|
-
"name": "entity.name.tag.k",
|
|
468
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*(?=\\s*[,>])"
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
"name": "entity.name.tag.k",
|
|
472
|
-
"match": "(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')(?=\\s*[,>])"
|
|
473
|
-
}
|
|
474
|
-
]
|
|
475
|
-
},
|
|
476
|
-
"filter-type-ref": {
|
|
477
|
-
"patterns": [
|
|
478
|
-
{
|
|
479
|
-
"match": "(\\$)\\s*(@)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
480
|
-
"captures": {
|
|
481
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
482
|
-
"2": { "name": "punctuation.definition.canonical.k" },
|
|
483
|
-
"3": { "name": "support.type.canonical.k" }
|
|
484
|
-
}
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
"match": "(\\$)\\s*([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
488
|
-
"captures": {
|
|
489
|
-
"1": { "name": "keyword.operator.type.k" },
|
|
490
|
-
"2": { "name": "support.type.k" }
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
]
|
|
494
|
-
},
|
|
495
|
-
"pattern-variable": {
|
|
496
|
-
"name": "variable.other.pattern.k",
|
|
497
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*"
|
|
498
|
-
},
|
|
499
|
-
"projection-dot": {
|
|
500
|
-
"comment": ".label projects a product field",
|
|
501
|
-
"patterns": [
|
|
502
|
-
{
|
|
503
|
-
"match": "(\\.)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
504
|
-
"captures": {
|
|
505
|
-
"1": { "name": "keyword.operator.projection.product.k" },
|
|
506
|
-
"2": { "name": "entity.name.label.k" }
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
"match": "(\\.)(\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')",
|
|
511
|
-
"captures": {
|
|
512
|
-
"1": { "name": "keyword.operator.projection.product.k" },
|
|
513
|
-
"2": { "name": "entity.name.label.k" }
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
]
|
|
517
|
-
},
|
|
518
|
-
"projection-slash": {
|
|
519
|
-
"comment": "/tag asserts and unwraps a union variant",
|
|
520
|
-
"patterns": [
|
|
521
|
-
{
|
|
522
|
-
"match": "(/)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
523
|
-
"captures": {
|
|
524
|
-
"1": { "name": "keyword.operator.projection.union.k" },
|
|
525
|
-
"2": { "name": "entity.name.tag.k" }
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
"match": "(/)(\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')",
|
|
530
|
-
"captures": {
|
|
531
|
-
"1": { "name": "keyword.operator.projection.union.k" },
|
|
532
|
-
"2": { "name": "entity.name.tag.k" }
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
]
|
|
536
|
-
},
|
|
537
|
-
"variant-intro": {
|
|
538
|
-
"comment": "|tag or \\tag introduces a union variant",
|
|
539
|
-
"patterns": [
|
|
540
|
-
{
|
|
541
|
-
"match": "([|\\\\])([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
542
|
-
"captures": {
|
|
543
|
-
"1": { "name": "keyword.operator.variant.k" },
|
|
544
|
-
"2": { "name": "entity.name.tag.k" }
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
"match": "([|\\\\])(\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*')",
|
|
549
|
-
"captures": {
|
|
550
|
-
"1": { "name": "keyword.operator.variant.k" },
|
|
551
|
-
"2": { "name": "entity.name.tag.k" }
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
]
|
|
555
|
-
},
|
|
556
|
-
"canonical-function-ref": {
|
|
557
|
-
"match": "(@)([a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*)",
|
|
558
|
-
"captures": {
|
|
559
|
-
"1": { "name": "punctuation.definition.canonical.k" },
|
|
560
|
-
"2": { "name": "support.function.canonical.k" }
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
"relation-identifier": {
|
|
564
|
-
"name": "support.function.identifier.k",
|
|
565
|
-
"match": "[a-zA-Z0-9_+\\-][a-zA-Z0-9_?!+\\-]*"
|
|
566
|
-
},
|
|
567
|
-
"string-double": {
|
|
568
|
-
"name": "string.quoted.double.k",
|
|
569
|
-
"begin": "\"",
|
|
570
|
-
"end": "\"",
|
|
571
|
-
"patterns": [
|
|
572
|
-
{ "name": "constant.character.escape.k", "match": "\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})" },
|
|
573
|
-
{ "name": "invalid.illegal.escape.k", "match": "\\\\." }
|
|
574
|
-
]
|
|
575
|
-
},
|
|
576
|
-
"string-single": {
|
|
577
|
-
"name": "string.quoted.single.k",
|
|
578
|
-
"begin": "'",
|
|
579
|
-
"end": "'",
|
|
580
|
-
"patterns": [
|
|
581
|
-
{ "name": "constant.character.escape.k", "match": "\\\\(?:['\\\\/bfnrt]|u[0-9a-fA-F]{4})" },
|
|
582
|
-
{ "name": "invalid.illegal.escape.k", "match": "\\\\." }
|
|
583
|
-
]
|
|
584
|
-
},
|
|
585
|
-
"dots": {
|
|
586
|
-
"comment": "... is the any/open pattern marker",
|
|
587
|
-
"name": "constant.language.any.k",
|
|
588
|
-
"match": "\\.\\.\\."
|
|
589
|
-
},
|
|
590
|
-
"separator": {
|
|
591
|
-
"name": "punctuation.separator.k",
|
|
592
|
-
"match": "[=;,:~]"
|
|
593
|
-
},
|
|
594
|
-
"brackets": {
|
|
595
|
-
"name": "punctuation.brackets.k",
|
|
596
|
-
"match": "[{}()<>]"
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const assert = require("assert");
|
|
2
|
-
const Module = require("module");
|
|
3
|
-
|
|
4
|
-
const originalLoad = Module._load;
|
|
5
|
-
Module._load = function load(request, parent, isMain) {
|
|
6
|
-
if (request === "vscode") return {};
|
|
7
|
-
return originalLoad.call(this, request, parent, isMain);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const { collectBackgroundRanges } = require("../extension");
|
|
11
|
-
|
|
12
|
-
function slices(text, ranges) {
|
|
13
|
-
return ranges.map(({ start, end }) => text.slice(start, end));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const source = [
|
|
17
|
-
"$ pair = { leaf left, leaf right };",
|
|
18
|
-
"pick = $pair ?{<$leaf some, ...>=X branch, ...} .branch;",
|
|
19
|
-
"-- ?<ignored tag>",
|
|
20
|
-
"/* $ignored */",
|
|
21
|
-
"$pair pick"
|
|
22
|
-
].join("\n");
|
|
23
|
-
|
|
24
|
-
const ranges = collectBackgroundRanges(source);
|
|
25
|
-
const type = slices(source, ranges.type);
|
|
26
|
-
const filter = slices(source, ranges.filter);
|
|
27
|
-
|
|
28
|
-
assert.deepStrictEqual(type, [
|
|
29
|
-
"$ pair = { leaf left, leaf right };",
|
|
30
|
-
"$pair",
|
|
31
|
-
"$leaf",
|
|
32
|
-
"$pair"
|
|
33
|
-
]);
|
|
34
|
-
assert.deepStrictEqual(filter, ["?{<$leaf some, ...>=X branch, ...}"]);
|
|
35
|
-
|
|
36
|
-
const nested = "add = ?{ $nat x, ... } = X <{.x pred x, .y succ y} ? X add, .y> ;";
|
|
37
|
-
const nestedRanges = collectBackgroundRanges(nested);
|
|
38
|
-
|
|
39
|
-
assert.deepStrictEqual(slices(nested, nestedRanges.filter), [
|
|
40
|
-
"?{ $nat x, ... } = X",
|
|
41
|
-
"? X"
|
|
42
|
-
]);
|
|
43
|
-
assert.deepStrictEqual(slices(nested, nestedRanges.type), ["$nat"]);
|
|
44
|
-
assert.deepStrictEqual(nestedRanges.filter, [
|
|
45
|
-
{ start: 6, end: 26 },
|
|
46
|
-
{ start: 51, end: 54 }
|
|
47
|
-
]);
|
|
48
|
-
assert.deepStrictEqual(nestedRanges.type, [{ start: 9, end: 13 }]);
|
|
49
|
-
|
|
50
|
-
console.log("background range scanner tests passed");
|