talorlang 0.1.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/COPYRIGHT ADDED
@@ -0,0 +1,25 @@
1
+ Short version for non-lawyers:
2
+
3
+ Talor is dual-licensed under Apache 2.0 and MIT terms.
4
+
5
+ It is Copyright (c) 2026 Rogerio Lucas and the Talor contributors.
6
+
7
+ Longer version:
8
+
9
+ Copyrights in the Talor project are retained by their contributors. No
10
+ copyright assignment is required to contribute to the project. For authorship
11
+ information, see the version control history.
12
+
13
+ Except as otherwise noted, Talor is licensed under the Apache License, Version
14
+ 2.0 <LICENSE-APACHE> or <http://www.apache.org/licenses/LICENSE-2.0> or the MIT
15
+ license <LICENSE-MIT> or <http://opensource.org/licenses/MIT>, at your option.
16
+
17
+ Individual source files carry no licence header: the terms above cover every
18
+ file in the repository that does not say otherwise in its own text.
19
+
20
+ Third-party materials:
21
+
22
+ vendor/musl is a git submodule referencing musl libc, distributed under the
23
+ MIT license. Its source is not contained in this repository; a clone brings
24
+ it only when the submodule is initialised, and its own COPYRIGHT file governs
25
+ it.
package/LICENSE-APACHE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rogerio Lucas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # talorlang
2
+
3
+ The TextMate grammar and editing configuration for the Talor language, packaged
4
+ so a site, a documentation build or an editor can highlight `.talor` source
5
+ without vendoring a copy of the grammar.
6
+
7
+ Talor is a systems language with static memory safety and no garbage collector.
8
+
9
+ This is the language's package on npm. Today it carries the grammar and nothing
10
+ else: there is no compiler in it, and `npm install talorlang` installs data, not
11
+ a binary.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm install talorlang
17
+ ```
18
+
19
+ ## Use it with Shiki
20
+
21
+ ```js
22
+ import { createHighlighter } from 'shiki';
23
+ import { shikiLanguage } from 'talorlang';
24
+
25
+ const highlighter = await createHighlighter({
26
+ langs: [shikiLanguage],
27
+ themes: ['github-dark'],
28
+ });
29
+
30
+ highlighter.codeToHtml('fn main(): i32 { 0 }', { lang: 'talor', theme: 'github-dark' });
31
+ ```
32
+
33
+ ## Use the grammar directly
34
+
35
+ ```js
36
+ import { grammar, configuration, id, extensions } from 'talorlang';
37
+
38
+ grammar.scopeName; // 'source.talor'
39
+ id; // 'talor'
40
+ extensions; // ['.talor']
41
+ configuration.comments.lineComment; // '//'
42
+ ```
43
+
44
+ CommonJS works too:
45
+
46
+ ```js
47
+ const { grammar } = require('talorlang');
48
+ ```
49
+
50
+ The two JSON files are also reachable on their own, for a tool that wants the
51
+ file rather than the module:
52
+
53
+ ```js
54
+ import grammar from 'talorlang/grammar.json' with { type: 'json' };
55
+ ```
56
+
57
+ ## What the grammar covers
58
+
59
+ The keyword lists are the ones in `src-talor/stage1/token.talor` and
60
+ `src/boot/token.c`, so what the editor calls a keyword is what the compilers lex
61
+ as one, and a test in the repository holds the two together in both directions.
62
+
63
+ - the keywords of the language, including `variant` and `enum` as the two
64
+ declarations of a tagged union and a numbered set, `shared` and `view` as type
65
+ modifiers, and `edits`, `takes` and `views` as the clause after a signature;
66
+ - literals: digit separators, hexadecimal and binary, exponents, `\u{...}`
67
+ escapes, char literals, and template literals with `${...}` interpolation
68
+ highlighted as code;
69
+ - the primitive types and the built-in types `Array`, `Option`, `Result` and
70
+ `Box`, plus the built-in functions `println`, `print`, `eprintln`, `panic`,
71
+ `exit`, `args` and `hash`;
72
+ - the words the language keeps only so a compiler can refuse them (`mut`, `own`,
73
+ `null`) and the ones reserved for a later version (`async`, `await`, `effect`,
74
+ `performs`, `where`, `yield`), both marked invalid;
75
+ - comments, brackets, auto-closing pairs and indentation.
76
+
77
+ It is a grammar only. There is no language server, so an editor using it gets
78
+ colour and bracket behaviour, not completion or diagnostics.
79
+
80
+ ## Versioning
81
+
82
+ The version tracks this package, not the language. The grammar itself is the one
83
+ the Talor repository ships to VS Code, copied at publish time from
84
+ `editors/vscode/`, so the two never disagree.
85
+
86
+ ## License
87
+
88
+ MIT OR Apache-2.0, at your option, the same terms as the Talor repository. The
89
+ two license texts ship in the package as `LICENSE-MIT` and `LICENSE-APACHE`.
@@ -0,0 +1,29 @@
1
+ {
2
+ "comments": {
3
+ "lineComment": "//",
4
+ "blockComment": ["/*", "*/"]
5
+ },
6
+ "brackets": [["{", "}"], ["[", "]"], ["(", ")"]],
7
+ "autoClosingPairs": [
8
+ { "open": "{", "close": "}" },
9
+ { "open": "[", "close": "]" },
10
+ { "open": "(", "close": ")" },
11
+ { "open": "\"", "close": "\"", "notIn": ["string"] },
12
+ { "open": "`", "close": "`", "notIn": ["string"] },
13
+ { "open": "'", "close": "'", "notIn": ["string", "comment"] }
14
+ ],
15
+ "surroundingPairs": [
16
+ ["{", "}"], ["[", "]"], ["(", ")"], ["\"", "\""], ["`", "`"], ["'", "'"]
17
+ ],
18
+ "indentationRules": {
19
+ "increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^)\"']*$|^.*\\[[^\\]\"']*$",
20
+ "decreaseIndentPattern": "^\\s*[}\\])].*$"
21
+ },
22
+ "wordPattern": "[A-Za-z_][A-Za-z0-9_]*",
23
+ "onEnterRules": [
24
+ {
25
+ "beforeText": "^\\s*//.*$",
26
+ "action": { "indent": "none", "appendText": "// " }
27
+ }
28
+ ]
29
+ }
package/grammar.json ADDED
@@ -0,0 +1,355 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
+ "name": "Talor",
4
+ "scopeName": "source.talor",
5
+ "patterns": [
6
+ {
7
+ "include": "#comments"
8
+ },
9
+ {
10
+ "include": "#attributes"
11
+ },
12
+ {
13
+ "include": "#declarations"
14
+ },
15
+ {
16
+ "include": "#strings"
17
+ },
18
+ {
19
+ "include": "#templates"
20
+ },
21
+ {
22
+ "include": "#chars"
23
+ },
24
+ {
25
+ "include": "#numbers"
26
+ },
27
+ {
28
+ "include": "#keywords"
29
+ },
30
+ {
31
+ "include": "#constructors"
32
+ },
33
+ {
34
+ "include": "#types"
35
+ },
36
+ {
37
+ "include": "#calls"
38
+ },
39
+ {
40
+ "include": "#operators"
41
+ },
42
+ {
43
+ "include": "#identifiers"
44
+ }
45
+ ],
46
+ "repository": {
47
+ "comments": {
48
+ "patterns": [
49
+ {
50
+ "name": "comment.line.double-slash.talor",
51
+ "match": "//.*$"
52
+ },
53
+ {
54
+ "name": "comment.block.talor",
55
+ "begin": "/\\*",
56
+ "end": "\\*/"
57
+ }
58
+ ]
59
+ },
60
+ "attributes": {
61
+ "name": "meta.attribute.talor",
62
+ "match": "#\\[\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*(?:\\([^)]*\\))?\\s*\\]",
63
+ "captures": {
64
+ "1": {
65
+ "name": "entity.name.function.decorator.talor"
66
+ }
67
+ }
68
+ },
69
+ "declarations": {
70
+ "patterns": [
71
+ {
72
+ "match": "\\b(fn)\\s+([A-Za-z_][A-Za-z0-9_]*)",
73
+ "captures": {
74
+ "1": {
75
+ "name": "keyword.declaration.function.talor"
76
+ },
77
+ "2": {
78
+ "name": "entity.name.function.talor"
79
+ }
80
+ }
81
+ },
82
+ {
83
+ "match": "\\b(struct|variant|enum|trait|type)\\s+([A-Za-z_][A-Za-z0-9_]*)",
84
+ "captures": {
85
+ "1": {
86
+ "name": "keyword.declaration.type.talor"
87
+ },
88
+ "2": {
89
+ "name": "entity.name.type.talor"
90
+ }
91
+ }
92
+ },
93
+ {
94
+ "comment": "extern type Fd: i32 releases rt_fd_close;",
95
+ "match": "\\b(extern)\\s+(type)\\s+([A-Za-z_][A-Za-z0-9_]*)",
96
+ "captures": {
97
+ "1": {
98
+ "name": "keyword.declaration.talor"
99
+ },
100
+ "2": {
101
+ "name": "keyword.declaration.type.talor"
102
+ },
103
+ "3": {
104
+ "name": "entity.name.type.talor"
105
+ }
106
+ }
107
+ },
108
+ {
109
+ "match": "\\b(const)\\s+([A-Za-z_][A-Za-z0-9_]*)",
110
+ "captures": {
111
+ "1": {
112
+ "name": "keyword.declaration.talor"
113
+ },
114
+ "2": {
115
+ "name": "variable.other.constant.talor"
116
+ }
117
+ }
118
+ },
119
+ {
120
+ "match": "\\b(impl)\\b",
121
+ "captures": {
122
+ "1": {
123
+ "name": "keyword.declaration.impl.talor"
124
+ }
125
+ }
126
+ },
127
+ {
128
+ "match": "\\b(use)\\s+([A-Za-z_][A-Za-z0-9_.]*)",
129
+ "captures": {
130
+ "1": {
131
+ "name": "keyword.control.import.talor"
132
+ },
133
+ "2": {
134
+ "name": "entity.name.namespace.talor"
135
+ }
136
+ }
137
+ }
138
+ ]
139
+ },
140
+ "strings": {
141
+ "name": "string.quoted.double.talor",
142
+ "begin": "\"",
143
+ "end": "\"",
144
+ "patterns": [
145
+ {
146
+ "name": "constant.character.escape.talor",
147
+ "match": "\\\\u\\{[0-9A-Fa-f]{1,6}\\}"
148
+ },
149
+ {
150
+ "name": "constant.character.escape.talor",
151
+ "match": "\\\\[nrt0\\\\\"']"
152
+ },
153
+ {
154
+ "name": "invalid.illegal.escape.talor",
155
+ "match": "\\\\."
156
+ }
157
+ ]
158
+ },
159
+ "templates": {
160
+ "name": "string.template.talor",
161
+ "begin": "`",
162
+ "end": "`",
163
+ "patterns": [
164
+ {
165
+ "name": "meta.embedded.expression.talor",
166
+ "begin": "\\$\\{",
167
+ "end": "\\}",
168
+ "beginCaptures": {
169
+ "0": {
170
+ "name": "punctuation.definition.template-expression.begin.talor"
171
+ }
172
+ },
173
+ "endCaptures": {
174
+ "0": {
175
+ "name": "punctuation.definition.template-expression.end.talor"
176
+ }
177
+ },
178
+ "patterns": [
179
+ {
180
+ "include": "$self"
181
+ }
182
+ ]
183
+ },
184
+ {
185
+ "name": "constant.character.escape.talor",
186
+ "match": "\\\\u\\{[0-9A-Fa-f]{1,6}\\}"
187
+ },
188
+ {
189
+ "name": "constant.character.escape.talor",
190
+ "match": "\\\\[nrt0\\\\`$']"
191
+ }
192
+ ]
193
+ },
194
+ "chars": {
195
+ "name": "string.quoted.single.talor",
196
+ "match": "'(\\\\u\\{[0-9A-Fa-f]{1,6}\\}|\\\\[nrt0\\\\'\"]|[^'\\\\])'"
197
+ },
198
+ "numbers": {
199
+ "patterns": [
200
+ {
201
+ "name": "constant.numeric.hex.talor",
202
+ "match": "\\b0[xX][0-9A-Fa-f_]+\\b"
203
+ },
204
+ {
205
+ "name": "constant.numeric.binary.talor",
206
+ "match": "\\b0[bB][01_]+\\b"
207
+ },
208
+ {
209
+ "name": "constant.numeric.float.talor",
210
+ "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)\\b"
211
+ },
212
+ {
213
+ "name": "constant.numeric.float.talor",
214
+ "match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*\\b"
215
+ },
216
+ {
217
+ "name": "constant.numeric.integer.talor",
218
+ "match": "\\b[0-9][0-9_]*\\b"
219
+ }
220
+ ]
221
+ },
222
+ "keywords": {
223
+ "patterns": [
224
+ {
225
+ "name": "keyword.control.talor",
226
+ "match": "\\b(break|continue|else|for|if|in|loop|match|return|while)\\b"
227
+ },
228
+ {
229
+ "name": "keyword.declaration.talor",
230
+ "match": "\\b(const|dyn|enum|extern|fn|impl|let|pub|releases|struct|trait|type|unsafe|use|var|variant)\\b"
231
+ },
232
+ {
233
+ "comment": "the clause after a signature (section 7.1), and the two type modifiers",
234
+ "name": "storage.modifier.talor",
235
+ "match": "\\b(edits|takes|views|view|shared)\\b"
236
+ },
237
+ {
238
+ "name": "keyword.operator.cast.talor",
239
+ "match": "\\bas\\b"
240
+ },
241
+ {
242
+ "name": "variable.language.self.talor",
243
+ "match": "\\bself\\b"
244
+ },
245
+ {
246
+ "name": "constant.language.boolean.talor",
247
+ "match": "\\b(true|false)\\b"
248
+ },
249
+ {
250
+ "comment": "removed from the language: both lexers keep the word only to refuse it and name what to write instead (4.10 and section 9)",
251
+ "name": "invalid.illegal.removed.talor",
252
+ "match": "\\b(mut|own|null)\\b"
253
+ },
254
+ {
255
+ "comment": "reserved for a later version, so not an identifier either",
256
+ "name": "invalid.illegal.reserved.talor",
257
+ "match": "\\b(async|await|effect|performs|where|yield)\\b"
258
+ }
259
+ ]
260
+ },
261
+ "types": {
262
+ "patterns": [
263
+ {
264
+ "name": "support.type.primitive.talor",
265
+ "match": "\\b(i8|i16|i32|i64|u8|u16|u32|u64|f32|f64|bool|char|string|void|never)\\b"
266
+ },
267
+ {
268
+ "name": "support.type.builtin.talor",
269
+ "match": "\\b(Array|Option|Result|Box)\\b"
270
+ },
271
+ {
272
+ "name": "entity.name.type.talor",
273
+ "match": "\\b[A-Z][A-Za-z0-9_]*\\b"
274
+ }
275
+ ]
276
+ },
277
+ "constructors": {
278
+ "name": "support.function.builtin.talor",
279
+ "match": "\\b(Some|None|Ok|Err)\\b"
280
+ },
281
+ "calls": {
282
+ "patterns": [
283
+ {
284
+ "name": "support.function.builtin.talor",
285
+ "match": "\\b(println|eprintln|print|panic|exit|args|hash)\\b(?=\\s*\\()"
286
+ },
287
+ {
288
+ "comment": "f<i64>(x): a call with explicit type arguments",
289
+ "match": "\\b([a-z_][A-Za-z0-9_]*)\\s*(?=<[^<>()]*>\\s*\\()",
290
+ "captures": {
291
+ "1": {
292
+ "name": "entity.name.function.call.talor"
293
+ }
294
+ }
295
+ },
296
+ {
297
+ "match": "\\b([a-z_][A-Za-z0-9_]*)\\s*(?=\\()",
298
+ "captures": {
299
+ "1": {
300
+ "name": "entity.name.function.call.talor"
301
+ }
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ "operators": {
307
+ "patterns": [
308
+ {
309
+ "name": "keyword.operator.assignment.talor",
310
+ "match": "(\\+=|-=|\\*=|/=|%=|=)"
311
+ },
312
+ {
313
+ "name": "keyword.operator.comparison.talor",
314
+ "match": "(==|!=|<=|>=|<|>)"
315
+ },
316
+ {
317
+ "name": "keyword.operator.logical.talor",
318
+ "match": "(&&|\\|\\||!)"
319
+ },
320
+ {
321
+ "name": "keyword.operator.bitwise.talor",
322
+ "match": "(<<|>>|&|\\||\\^|~)"
323
+ },
324
+ {
325
+ "name": "keyword.operator.arithmetic.talor",
326
+ "match": "(\\+|-|\\*|/|%)"
327
+ },
328
+ {
329
+ "name": "keyword.operator.try.talor",
330
+ "match": "\\?"
331
+ },
332
+ {
333
+ "name": "keyword.operator.range.talor",
334
+ "match": "\\.\\."
335
+ },
336
+ {
337
+ "name": "keyword.operator.arrow.talor",
338
+ "match": "=>"
339
+ }
340
+ ]
341
+ },
342
+ "identifiers": {
343
+ "patterns": [
344
+ {
345
+ "name": "variable.other.constant.talor",
346
+ "match": "\\b[A-Z][A-Z0-9_]*\\b"
347
+ },
348
+ {
349
+ "name": "variable.other.talor",
350
+ "match": "\\b[a-z_][A-Za-z0-9_]*\\b"
351
+ }
352
+ ]
353
+ }
354
+ }
355
+ }
package/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+ // CommonJS twin of index.js; the same five exports.
2
+ const id = 'talor';
3
+ const extensions = ['.talor'];
4
+ const grammar = require('./grammar.json');
5
+ const configuration = require('./configuration.json');
6
+ const shikiLanguage = { ...grammar, name: id, displayName: 'Talor' };
7
+
8
+ module.exports = { id, extensions, grammar, configuration, shikiLanguage, default: shikiLanguage };
package/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /** A TextMate grammar, as VS Code and Shiki read it. */
2
+ export interface TextMateGrammar {
3
+ name: string;
4
+ scopeName: string;
5
+ patterns: unknown[];
6
+ repository: Record<string, unknown>;
7
+ [key: string]: unknown;
8
+ }
9
+
10
+ /** VS Code's language-configuration.json. */
11
+ export interface LanguageConfiguration {
12
+ comments: { lineComment?: string; blockComment?: [string, string] };
13
+ brackets: [string, string][];
14
+ autoClosingPairs: { open: string; close: string; notIn?: string[] }[];
15
+ surroundingPairs: [string, string][];
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ /** The grammar with the language id in `name`, ready for Shiki's `langs`. */
20
+ export interface ShikiLanguage extends TextMateGrammar {
21
+ name: 'talor';
22
+ displayName: 'Talor';
23
+ }
24
+
25
+ export const id: 'talor';
26
+ export const extensions: readonly ['.talor'];
27
+ export const grammar: TextMateGrammar;
28
+ export const configuration: LanguageConfiguration;
29
+ export const shikiLanguage: ShikiLanguage;
30
+ export default shikiLanguage;
package/index.js ADDED
@@ -0,0 +1,26 @@
1
+ // The Talor grammar as a module. The two JSON files are the ones the VS Code
2
+ // extension ships, copied in at pack time; `createRequire` reads them on every
3
+ // Node this package supports without a JSON import assertion.
4
+ import { createRequire } from 'node:module';
5
+
6
+ const require = createRequire(import.meta.url);
7
+
8
+ /** The language id, as editors and Shiki name it. */
9
+ export const id = 'talor';
10
+
11
+ /** The file extensions the compilers read. */
12
+ export const extensions = ['.talor'];
13
+
14
+ /** The TextMate grammar, scope `source.talor`. */
15
+ export const grammar = require('./grammar.json');
16
+
17
+ /** Comments, brackets, auto-closing pairs and indentation rules. */
18
+ export const configuration = require('./configuration.json');
19
+
20
+ /**
21
+ * The grammar in the shape Shiki registers: the TextMate grammar with the
22
+ * language id as `name`. Pass it in `langs` when creating a highlighter.
23
+ */
24
+ export const shikiLanguage = { ...grammar, name: id, displayName: 'Talor' };
25
+
26
+ export default shikiLanguage;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "talorlang",
3
+ "version": "0.1.0",
4
+ "description": "The TextMate grammar and editing configuration of the Talor language, for Shiki and any editor that reads TextMate.",
5
+ "keywords": [
6
+ "talor",
7
+ "textmate",
8
+ "grammar",
9
+ "shiki",
10
+ "syntax-highlighting"
11
+ ],
12
+ "license": "MIT OR Apache-2.0",
13
+ "author": "0x524c",
14
+ "type": "module",
15
+ "main": "./index.cjs",
16
+ "module": "./index.js",
17
+ "types": "./index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./index.d.ts",
21
+ "import": "./index.js",
22
+ "require": "./index.cjs"
23
+ },
24
+ "./grammar.json": "./grammar.json",
25
+ "./configuration.json": "./configuration.json"
26
+ },
27
+ "files": [
28
+ "index.js",
29
+ "index.cjs",
30
+ "index.d.ts",
31
+ "grammar.json",
32
+ "configuration.json",
33
+ "README.md",
34
+ "LICENSE-MIT",
35
+ "LICENSE-APACHE",
36
+ "COPYRIGHT"
37
+ ],
38
+ "scripts": {
39
+ "prepack": "node -e \"const f=require('fs');f.copyFileSync('../vscode/syntaxes/talor.tmLanguage.json','grammar.json');f.copyFileSync('../vscode/language-configuration.json','configuration.json');f.copyFileSync('../../LICENSE-MIT','LICENSE-MIT');f.copyFileSync('../../LICENSE-APACHE','LICENSE-APACHE');f.copyFileSync('../../COPYRIGHT','COPYRIGHT')\"",
40
+ "test": "node -e \"import('./index.js').then(m=>{if(m.grammar.scopeName!=='source.talor')throw new Error('scopeName');if(m.shikiLanguage.name!=='talor'||m.id!=='talor')throw new Error('name');if(m.extensions[0]!=='.talor')throw new Error('extensions');if(!m.configuration.comments)throw new Error('configuration');console.log('ok: grammar, configuration, shikiLanguage')})\""
41
+ },
42
+ "engines": {
43
+ "node": ">=16"
44
+ }
45
+ }