microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/enable-backcompat-top-parameter

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

grammars/typespec.json

1433lines · modecode

1{
2 "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3 "name": "TypeSpec",
4 "scopeName": "source.tsp",
5 "fileTypes": [
6 "tsp"
7 ],
8 "patterns": [
9 {
10 "include": "#statement"
11 }
12 ],
13 "repository": {
14 "alias-id": {
15 "name": "meta.alias-id.typespec",
16 "begin": "(=)\\s*",
17 "beginCaptures": {
18 "1": {
19 "name": "keyword.operator.assignment.tsp"
20 }
21 },
22 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
23 "patterns": [
24 {
25 "include": "#expression"
26 }
27 ]
28 },
29 "alias-statement": {
30 "name": "meta.alias-statement.typespec",
31 "begin": "\\b(alias)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)\\s*",
32 "beginCaptures": {
33 "1": {
34 "name": "keyword.other.tsp"
35 },
36 "2": {
37 "name": "entity.name.type.tsp"
38 }
39 },
40 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
41 "patterns": [
42 {
43 "include": "#alias-id"
44 },
45 {
46 "include": "#type-parameters"
47 }
48 ]
49 },
50 "augment-decorator-statement": {
51 "name": "meta.augment-decorator-statement.typespec",
52 "begin": "((@@)\\b[_$[:alpha:]](?:[_$[:alnum:]]|\\.[_$[:alpha:]])*\\b)",
53 "beginCaptures": {
54 "1": {
55 "name": "entity.name.tag.tsp"
56 },
57 "2": {
58 "name": "entity.name.tag.tsp"
59 }
60 },
61 "end": "(?=([_$[:alpha:]]|`))|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
62 "patterns": [
63 {
64 "include": "#token"
65 },
66 {
67 "include": "#parenthesized-expression"
68 }
69 ]
70 },
71 "block-comment": {
72 "name": "comment.block.tsp",
73 "begin": "/\\*",
74 "end": "\\*/"
75 },
76 "boolean-literal": {
77 "name": "constant.language.tsp",
78 "match": "\\b(true|false)\\b"
79 },
80 "callExpression": {
81 "name": "meta.callExpression.typespec",
82 "begin": "(\\b[_$[:alpha:]](?:[_$[:alnum:]]|\\.[_$[:alpha:]])*\\b)\\s*(\\()",
83 "beginCaptures": {
84 "1": {
85 "name": "entity.name.function.tsp"
86 },
87 "2": {
88 "name": "punctuation.parenthesis.open.tsp"
89 }
90 },
91 "end": "\\)",
92 "endCaptures": {
93 "0": {
94 "name": "punctuation.parenthesis.close.tsp"
95 }
96 },
97 "patterns": [
98 {
99 "include": "#token"
100 },
101 {
102 "include": "#expression"
103 },
104 {
105 "include": "#punctuation-comma"
106 }
107 ]
108 },
109 "const-statement": {
110 "name": "meta.const-statement.typespec",
111 "begin": "\\b(const)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
112 "beginCaptures": {
113 "1": {
114 "name": "keyword.other.tsp"
115 },
116 "2": {
117 "name": "variable.name.tsp"
118 }
119 },
120 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
121 "patterns": [
122 {
123 "include": "#type-annotation"
124 },
125 {
126 "include": "#operator-assignment"
127 },
128 {
129 "include": "#expression"
130 }
131 ]
132 },
133 "decorator": {
134 "name": "meta.decorator.typespec",
135 "begin": "((@)\\b[_$[:alpha:]](?:[_$[:alnum:]]|\\.[_$[:alpha:]])*\\b)",
136 "beginCaptures": {
137 "1": {
138 "name": "entity.name.tag.tsp"
139 },
140 "2": {
141 "name": "entity.name.tag.tsp"
142 }
143 },
144 "end": "(?=([_$[:alpha:]]|`))|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
145 "patterns": [
146 {
147 "include": "#token"
148 },
149 {
150 "include": "#parenthesized-expression"
151 }
152 ]
153 },
154 "decorator-declaration-statement": {
155 "name": "meta.decorator-declaration-statement.typespec",
156 "begin": "(?:(extern)\\s+)?\\b(dec)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
157 "beginCaptures": {
158 "1": {
159 "name": "keyword.other.tsp"
160 },
161 "2": {
162 "name": "keyword.other.tsp"
163 },
164 "3": {
165 "name": "entity.name.function.tsp"
166 }
167 },
168 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
169 "patterns": [
170 {
171 "include": "#token"
172 },
173 {
174 "include": "#operation-parameters"
175 }
176 ]
177 },
178 "directive": {
179 "name": "meta.directive.typespec",
180 "begin": "\\s*(#)(\\b[_$[:alpha:]][_$[:alnum:]]*\\b)",
181 "beginCaptures": {
182 "1": {
183 "name": "keyword.directive.name.tsp"
184 },
185 "2": {
186 "name": "keyword.directive.name.tsp"
187 }
188 },
189 "end": "$|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
190 "patterns": [
191 {
192 "include": "#string-literal"
193 },
194 {
195 "include": "#identifier-expression"
196 }
197 ]
198 },
199 "doc-comment": {
200 "name": "comment.block.tsp",
201 "begin": "/\\*\\*",
202 "beginCaptures": {
203 "0": {
204 "name": "comment.block.tsp"
205 }
206 },
207 "end": "\\*/",
208 "endCaptures": {
209 "0": {
210 "name": "comment.block.tsp"
211 }
212 },
213 "patterns": [
214 {
215 "include": "#doc-comment-block"
216 }
217 ]
218 },
219 "doc-comment-block": {
220 "patterns": [
221 {
222 "include": "#doc-comment-param"
223 },
224 {
225 "include": "#doc-comment-return-tag"
226 },
227 {
228 "include": "#doc-comment-unknown-tag"
229 }
230 ]
231 },
232 "doc-comment-param": {
233 "name": "comment.block.tsp",
234 "match": "(?x)((@)(?:param|template|prop))\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)\\b",
235 "captures": {
236 "1": {
237 "name": "keyword.tag.tspdoc"
238 },
239 "2": {
240 "name": "keyword.tag.tspdoc"
241 },
242 "3": {
243 "name": "variable.name.tsp"
244 }
245 }
246 },
247 "doc-comment-return-tag": {
248 "name": "comment.block.tsp",
249 "match": "(?x)((@)(?:returns))\\b",
250 "captures": {
251 "1": {
252 "name": "keyword.tag.tspdoc"
253 },
254 "2": {
255 "name": "keyword.tag.tspdoc"
256 }
257 }
258 },
259 "doc-comment-unknown-tag": {
260 "name": "comment.block.tsp",
261 "match": "(?x)((@)(?:\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`))\\b",
262 "captures": {
263 "1": {
264 "name": "entity.name.tag.tsp"
265 },
266 "2": {
267 "name": "entity.name.tag.tsp"
268 }
269 }
270 },
271 "enum-body": {
272 "name": "meta.enum-body.typespec",
273 "begin": "\\{",
274 "beginCaptures": {
275 "0": {
276 "name": "punctuation.curlybrace.open.tsp"
277 }
278 },
279 "end": "\\}",
280 "endCaptures": {
281 "0": {
282 "name": "punctuation.curlybrace.close.tsp"
283 }
284 },
285 "patterns": [
286 {
287 "include": "#enum-member"
288 },
289 {
290 "include": "#token"
291 },
292 {
293 "include": "#directive"
294 },
295 {
296 "include": "#decorator"
297 },
298 {
299 "include": "#punctuation-comma"
300 }
301 ]
302 },
303 "enum-member": {
304 "name": "meta.enum-member.typespec",
305 "begin": "(?:(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)\\s*(:?))",
306 "beginCaptures": {
307 "1": {
308 "name": "variable.name.tsp"
309 },
310 "2": {
311 "name": "keyword.operator.type.annotation.tsp"
312 }
313 },
314 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
315 "patterns": [
316 {
317 "include": "#token"
318 },
319 {
320 "include": "#type-annotation"
321 }
322 ]
323 },
324 "enum-statement": {
325 "name": "meta.enum-statement.typespec",
326 "begin": "\\b(enum)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
327 "beginCaptures": {
328 "1": {
329 "name": "keyword.other.tsp"
330 },
331 "2": {
332 "name": "entity.name.type.tsp"
333 }
334 },
335 "end": "(?<=\\})|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
336 "patterns": [
337 {
338 "include": "#token"
339 },
340 {
341 "include": "#enum-body"
342 }
343 ]
344 },
345 "escape-character": {
346 "name": "constant.character.escape.tsp",
347 "match": "\\\\."
348 },
349 "expression": {
350 "patterns": [
351 {
352 "include": "#token"
353 },
354 {
355 "include": "#directive"
356 },
357 {
358 "include": "#parenthesized-expression"
359 },
360 {
361 "include": "#valueof"
362 },
363 {
364 "include": "#typeof"
365 },
366 {
367 "include": "#type-arguments"
368 },
369 {
370 "include": "#object-literal"
371 },
372 {
373 "include": "#tuple-literal"
374 },
375 {
376 "include": "#tuple-expression"
377 },
378 {
379 "include": "#model-expression"
380 },
381 {
382 "include": "#callExpression"
383 },
384 {
385 "include": "#identifier-expression"
386 }
387 ]
388 },
389 "function-declaration-statement": {
390 "name": "meta.function-declaration-statement.typespec",
391 "begin": "(?:(extern)\\s+)?\\b(fn)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
392 "beginCaptures": {
393 "1": {
394 "name": "keyword.other.tsp"
395 },
396 "2": {
397 "name": "keyword.other.tsp"
398 },
399 "3": {
400 "name": "entity.name.function.tsp"
401 }
402 },
403 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
404 "patterns": [
405 {
406 "include": "#token"
407 },
408 {
409 "include": "#operation-parameters"
410 },
411 {
412 "include": "#type-annotation"
413 }
414 ]
415 },
416 "identifier-expression": {
417 "name": "entity.name.type.tsp",
418 "match": "\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`"
419 },
420 "import-statement": {
421 "name": "meta.import-statement.typespec",
422 "begin": "\\b(import)\\b",
423 "beginCaptures": {
424 "1": {
425 "name": "keyword.other.tsp"
426 }
427 },
428 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
429 "patterns": [
430 {
431 "include": "#token"
432 }
433 ]
434 },
435 "interface-body": {
436 "name": "meta.interface-body.typespec",
437 "begin": "\\{",
438 "beginCaptures": {
439 "0": {
440 "name": "punctuation.curlybrace.open.tsp"
441 }
442 },
443 "end": "\\}",
444 "endCaptures": {
445 "0": {
446 "name": "punctuation.curlybrace.close.tsp"
447 }
448 },
449 "patterns": [
450 {
451 "include": "#token"
452 },
453 {
454 "include": "#directive"
455 },
456 {
457 "include": "#decorator"
458 },
459 {
460 "include": "#interface-member"
461 },
462 {
463 "include": "#punctuation-semicolon"
464 }
465 ]
466 },
467 "interface-heritage": {
468 "name": "meta.interface-heritage.typespec",
469 "begin": "\\b(extends)\\b",
470 "beginCaptures": {
471 "1": {
472 "name": "keyword.other.tsp"
473 }
474 },
475 "end": "((?=\\{)|(?=;|@|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b))",
476 "patterns": [
477 {
478 "include": "#expression"
479 },
480 {
481 "include": "#punctuation-comma"
482 }
483 ]
484 },
485 "interface-member": {
486 "name": "meta.interface-member.typespec",
487 "begin": "(?:\\b(op)\\b\\s+)?(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
488 "beginCaptures": {
489 "1": {
490 "name": "keyword.other.tsp"
491 },
492 "2": {
493 "name": "entity.name.function.tsp"
494 }
495 },
496 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
497 "patterns": [
498 {
499 "include": "#token"
500 },
501 {
502 "include": "#operation-signature"
503 }
504 ]
505 },
506 "interface-statement": {
507 "name": "meta.interface-statement.typespec",
508 "begin": "\\b(interface)\\b",
509 "beginCaptures": {
510 "1": {
511 "name": "keyword.other.tsp"
512 }
513 },
514 "end": "(?<=\\})|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
515 "patterns": [
516 {
517 "include": "#token"
518 },
519 {
520 "include": "#type-parameters"
521 },
522 {
523 "include": "#interface-heritage"
524 },
525 {
526 "include": "#interface-body"
527 },
528 {
529 "include": "#expression"
530 }
531 ]
532 },
533 "line-comment": {
534 "name": "comment.line.double-slash.tsp",
535 "match": "//.*$"
536 },
537 "model-expression": {
538 "name": "meta.model-expression.typespec",
539 "begin": "\\{",
540 "beginCaptures": {
541 "0": {
542 "name": "punctuation.curlybrace.open.tsp"
543 }
544 },
545 "end": "\\}",
546 "endCaptures": {
547 "0": {
548 "name": "punctuation.curlybrace.close.tsp"
549 }
550 },
551 "patterns": [
552 {
553 "include": "#model-property"
554 },
555 {
556 "include": "#token"
557 },
558 {
559 "include": "#directive"
560 },
561 {
562 "include": "#decorator"
563 },
564 {
565 "include": "#spread-operator"
566 },
567 {
568 "include": "#punctuation-semicolon"
569 }
570 ]
571 },
572 "model-heritage": {
573 "name": "meta.model-heritage.typespec",
574 "begin": "\\b(extends|is)\\b",
575 "beginCaptures": {
576 "1": {
577 "name": "keyword.other.tsp"
578 }
579 },
580 "end": "((?=\\{)|(?=;|@|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b))",
581 "patterns": [
582 {
583 "include": "#expression"
584 },
585 {
586 "include": "#punctuation-comma"
587 }
588 ]
589 },
590 "model-property": {
591 "name": "meta.model-property.typespec",
592 "begin": "(?:(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)|(\\\"(?:[^\\\"\\\\]|\\\\.)*\\\"))",
593 "beginCaptures": {
594 "1": {
595 "name": "variable.name.tsp"
596 },
597 "2": {
598 "name": "string.quoted.double.tsp"
599 }
600 },
601 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
602 "patterns": [
603 {
604 "include": "#token"
605 },
606 {
607 "include": "#type-annotation"
608 },
609 {
610 "include": "#operator-assignment"
611 },
612 {
613 "include": "#expression"
614 }
615 ]
616 },
617 "model-statement": {
618 "name": "meta.model-statement.typespec",
619 "begin": "\\b(model)\\b",
620 "beginCaptures": {
621 "1": {
622 "name": "keyword.other.tsp"
623 }
624 },
625 "end": "(?<=\\})|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
626 "patterns": [
627 {
628 "include": "#token"
629 },
630 {
631 "include": "#type-parameters"
632 },
633 {
634 "include": "#model-heritage"
635 },
636 {
637 "include": "#expression"
638 }
639 ]
640 },
641 "namespace-body": {
642 "name": "meta.namespace-body.typespec",
643 "begin": "\\{",
644 "beginCaptures": {
645 "0": {
646 "name": "punctuation.curlybrace.open.tsp"
647 }
648 },
649 "end": "\\}",
650 "endCaptures": {
651 "0": {
652 "name": "punctuation.curlybrace.close.tsp"
653 }
654 },
655 "patterns": [
656 {
657 "include": "#statement"
658 }
659 ]
660 },
661 "namespace-name": {
662 "name": "meta.namespace-name.typespec",
663 "begin": "(?=([_$[:alpha:]]|`))",
664 "end": "((?=\\{)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b))",
665 "patterns": [
666 {
667 "include": "#identifier-expression"
668 },
669 {
670 "include": "#punctuation-accessor"
671 }
672 ]
673 },
674 "namespace-statement": {
675 "name": "meta.namespace-statement.typespec",
676 "begin": "\\b(namespace)\\b",
677 "beginCaptures": {
678 "1": {
679 "name": "keyword.other.tsp"
680 }
681 },
682 "end": "((?<=\\})|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b))",
683 "patterns": [
684 {
685 "include": "#token"
686 },
687 {
688 "include": "#namespace-name"
689 },
690 {
691 "include": "#namespace-body"
692 }
693 ]
694 },
695 "numeric-literal": {
696 "name": "constant.numeric.tsp",
697 "match": "(?:\\b(?<!\\$)0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\\b(?!\\$)|\\b(?<!\\$)0(?:b|B)[01][01_]*(n)?\\b(?!\\$)|(?<!\\$)(?:(?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\\b)|(?:\\b[0-9][0-9_]*(\\.)[eE][+-]?[0-9][0-9_]*(n)?\\b)|(?:\\B(\\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\\b)|(?:\\b[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\\b)|(?:\\b[0-9][0-9_]*(\\.)[0-9][0-9_]*(n)?\\b)|(?:\\b[0-9][0-9_]*(\\.)(n)?\\B)|(?:\\B(\\.)[0-9][0-9_]*(n)?\\b)|(?:\\b[0-9][0-9_]*(n)?\\b(?!\\.)))(?!\\$))"
698 },
699 "object-literal": {
700 "name": "meta.object-literal.typespec",
701 "begin": "#\\{",
702 "beginCaptures": {
703 "0": {
704 "name": "punctuation.hashcurlybrace.open.tsp"
705 }
706 },
707 "end": "\\}",
708 "endCaptures": {
709 "0": {
710 "name": "punctuation.curlybrace.close.tsp"
711 }
712 },
713 "patterns": [
714 {
715 "include": "#token"
716 },
717 {
718 "include": "#object-literal-property"
719 },
720 {
721 "include": "#directive"
722 },
723 {
724 "include": "#spread-operator"
725 },
726 {
727 "include": "#punctuation-comma"
728 }
729 ]
730 },
731 "object-literal-property": {
732 "name": "meta.object-literal-property.typespec",
733 "begin": "(?:(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)\\s*(:))",
734 "beginCaptures": {
735 "1": {
736 "name": "variable.name.tsp"
737 },
738 "2": {
739 "name": "keyword.operator.type.annotation.tsp"
740 }
741 },
742 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
743 "patterns": [
744 {
745 "include": "#token"
746 },
747 {
748 "include": "#expression"
749 }
750 ]
751 },
752 "operation-heritage": {
753 "name": "meta.operation-heritage.typespec",
754 "begin": "\\b(is)\\b",
755 "beginCaptures": {
756 "1": {
757 "name": "keyword.other.tsp"
758 }
759 },
760 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
761 "patterns": [
762 {
763 "include": "#expression"
764 }
765 ]
766 },
767 "operation-parameters": {
768 "name": "meta.operation-parameters.typespec",
769 "begin": "\\(",
770 "beginCaptures": {
771 "0": {
772 "name": "punctuation.parenthesis.open.tsp"
773 }
774 },
775 "end": "\\)",
776 "endCaptures": {
777 "0": {
778 "name": "punctuation.parenthesis.close.tsp"
779 }
780 },
781 "patterns": [
782 {
783 "include": "#token"
784 },
785 {
786 "include": "#decorator"
787 },
788 {
789 "include": "#model-property"
790 },
791 {
792 "include": "#spread-operator"
793 },
794 {
795 "include": "#punctuation-comma"
796 }
797 ]
798 },
799 "operation-signature": {
800 "patterns": [
801 {
802 "include": "#type-parameters"
803 },
804 {
805 "include": "#operation-heritage"
806 },
807 {
808 "include": "#operation-parameters"
809 },
810 {
811 "include": "#type-annotation"
812 }
813 ]
814 },
815 "operation-statement": {
816 "name": "meta.operation-statement.typespec",
817 "begin": "\\b(op)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
818 "beginCaptures": {
819 "1": {
820 "name": "keyword.other.tsp"
821 },
822 "2": {
823 "name": "entity.name.function.tsp"
824 }
825 },
826 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
827 "patterns": [
828 {
829 "include": "#token"
830 },
831 {
832 "include": "#operation-signature"
833 }
834 ]
835 },
836 "operator-assignment": {
837 "name": "keyword.operator.assignment.tsp",
838 "match": "="
839 },
840 "parenthesized-expression": {
841 "name": "meta.parenthesized-expression.typespec",
842 "begin": "\\(",
843 "beginCaptures": {
844 "0": {
845 "name": "punctuation.parenthesis.open.tsp"
846 }
847 },
848 "end": "\\)",
849 "endCaptures": {
850 "0": {
851 "name": "punctuation.parenthesis.close.tsp"
852 }
853 },
854 "patterns": [
855 {
856 "include": "#expression"
857 },
858 {
859 "include": "#punctuation-comma"
860 }
861 ]
862 },
863 "punctuation-accessor": {
864 "name": "punctuation.accessor.tsp",
865 "match": "\\."
866 },
867 "punctuation-comma": {
868 "name": "punctuation.comma.tsp",
869 "match": ","
870 },
871 "punctuation-semicolon": {
872 "name": "punctuation.terminator.statement.tsp",
873 "match": ";"
874 },
875 "scalar-body": {
876 "name": "meta.scalar-body.typespec",
877 "begin": "\\{",
878 "beginCaptures": {
879 "0": {
880 "name": "punctuation.curlybrace.open.tsp"
881 }
882 },
883 "end": "\\}",
884 "endCaptures": {
885 "0": {
886 "name": "punctuation.curlybrace.close.tsp"
887 }
888 },
889 "patterns": [
890 {
891 "include": "#token"
892 },
893 {
894 "include": "#directive"
895 },
896 {
897 "include": "#scalar-constructor"
898 },
899 {
900 "include": "#punctuation-semicolon"
901 }
902 ]
903 },
904 "scalar-constructor": {
905 "name": "meta.scalar-constructor.typespec",
906 "begin": "\\b(init)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
907 "beginCaptures": {
908 "1": {
909 "name": "keyword.other.tsp"
910 },
911 "2": {
912 "name": "entity.name.function.tsp"
913 }
914 },
915 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
916 "patterns": [
917 {
918 "include": "#token"
919 },
920 {
921 "include": "#operation-parameters"
922 }
923 ]
924 },
925 "scalar-extends": {
926 "name": "meta.scalar-extends.typespec",
927 "begin": "\\b(extends)\\b",
928 "beginCaptures": {
929 "1": {
930 "name": "keyword.other.tsp"
931 }
932 },
933 "end": "(?=;|@|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
934 "patterns": [
935 {
936 "include": "#expression"
937 },
938 {
939 "include": "#punctuation-comma"
940 }
941 ]
942 },
943 "scalar-statement": {
944 "name": "meta.scalar-statement.typespec",
945 "begin": "\\b(scalar)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
946 "beginCaptures": {
947 "1": {
948 "name": "keyword.other.tsp"
949 },
950 "2": {
951 "name": "entity.name.type.tsp"
952 }
953 },
954 "end": "(?<=\\})|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
955 "patterns": [
956 {
957 "include": "#token"
958 },
959 {
960 "include": "#type-parameters"
961 },
962 {
963 "include": "#scalar-extends"
964 },
965 {
966 "include": "#scalar-body"
967 }
968 ]
969 },
970 "spread-operator": {
971 "name": "meta.spread-operator.typespec",
972 "begin": "\\.\\.\\.",
973 "beginCaptures": {
974 "0": {
975 "name": "keyword.operator.spread.tsp"
976 }
977 },
978 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
979 "patterns": [
980 {
981 "include": "#expression"
982 }
983 ]
984 },
985 "statement": {
986 "patterns": [
987 {
988 "include": "#token"
989 },
990 {
991 "include": "#directive"
992 },
993 {
994 "include": "#augment-decorator-statement"
995 },
996 {
997 "include": "#decorator"
998 },
999 {
1000 "include": "#model-statement"
1001 },
1002 {
1003 "include": "#scalar-statement"
1004 },
1005 {
1006 "include": "#union-statement"
1007 },
1008 {
1009 "include": "#interface-statement"
1010 },
1011 {
1012 "include": "#enum-statement"
1013 },
1014 {
1015 "include": "#alias-statement"
1016 },
1017 {
1018 "include": "#const-statement"
1019 },
1020 {
1021 "include": "#namespace-statement"
1022 },
1023 {
1024 "include": "#operation-statement"
1025 },
1026 {
1027 "include": "#import-statement"
1028 },
1029 {
1030 "include": "#using-statement"
1031 },
1032 {
1033 "include": "#decorator-declaration-statement"
1034 },
1035 {
1036 "include": "#function-declaration-statement"
1037 },
1038 {
1039 "include": "#punctuation-semicolon"
1040 }
1041 ]
1042 },
1043 "string-literal": {
1044 "name": "string.quoted.double.tsp",
1045 "begin": "\"",
1046 "end": "\"|$",
1047 "patterns": [
1048 {
1049 "include": "#template-expression"
1050 },
1051 {
1052 "include": "#escape-character"
1053 }
1054 ]
1055 },
1056 "template-expression": {
1057 "name": "meta.template-expression.typespec",
1058 "begin": "\\$\\{",
1059 "beginCaptures": {
1060 "0": {
1061 "name": "punctuation.definition.template-expression.begin.tsp"
1062 }
1063 },
1064 "end": "\\}",
1065 "endCaptures": {
1066 "0": {
1067 "name": "punctuation.definition.template-expression.end.tsp"
1068 }
1069 },
1070 "patterns": [
1071 {
1072 "include": "#expression"
1073 }
1074 ]
1075 },
1076 "token": {
1077 "patterns": [
1078 {
1079 "include": "#doc-comment"
1080 },
1081 {
1082 "include": "#line-comment"
1083 },
1084 {
1085 "include": "#block-comment"
1086 },
1087 {
1088 "include": "#triple-quoted-string-literal"
1089 },
1090 {
1091 "include": "#string-literal"
1092 },
1093 {
1094 "include": "#boolean-literal"
1095 },
1096 {
1097 "include": "#numeric-literal"
1098 }
1099 ]
1100 },
1101 "triple-quoted-string-literal": {
1102 "name": "string.quoted.triple.tsp",
1103 "begin": "\"\"\"",
1104 "end": "\"\"\"",
1105 "patterns": [
1106 {
1107 "include": "#template-expression"
1108 },
1109 {
1110 "include": "#escape-character"
1111 }
1112 ]
1113 },
1114 "tuple-expression": {
1115 "name": "meta.tuple-expression.typespec",
1116 "begin": "\\[",
1117 "beginCaptures": {
1118 "0": {
1119 "name": "punctuation.squarebracket.open.tsp"
1120 }
1121 },
1122 "end": "\\]",
1123 "endCaptures": {
1124 "0": {
1125 "name": "punctuation.squarebracket.close.tsp"
1126 }
1127 },
1128 "patterns": [
1129 {
1130 "include": "#expression"
1131 }
1132 ]
1133 },
1134 "tuple-literal": {
1135 "name": "meta.tuple-literal.typespec",
1136 "begin": "#\\[",
1137 "beginCaptures": {
1138 "0": {
1139 "name": "punctuation.hashsquarebracket.open.tsp"
1140 }
1141 },
1142 "end": "\\]",
1143 "endCaptures": {
1144 "0": {
1145 "name": "punctuation.squarebracket.close.tsp"
1146 }
1147 },
1148 "patterns": [
1149 {
1150 "include": "#expression"
1151 },
1152 {
1153 "include": "#punctuation-comma"
1154 }
1155 ]
1156 },
1157 "type-annotation": {
1158 "name": "meta.type-annotation.typespec",
1159 "begin": "\\s*(\\??)\\s*(:)",
1160 "beginCaptures": {
1161 "1": {
1162 "name": "keyword.operator.optional.tsp"
1163 },
1164 "2": {
1165 "name": "keyword.operator.type.annotation.tsp"
1166 }
1167 },
1168 "end": "(?=,|;|@|\\)|\\}|=|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1169 "patterns": [
1170 {
1171 "include": "#expression"
1172 }
1173 ]
1174 },
1175 "type-argument": {
1176 "name": "meta.type-argument.typespec",
1177 "begin": "(?:(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)\\s*(=))",
1178 "beginCaptures": {
1179 "1": {
1180 "name": "entity.name.type.tsp"
1181 },
1182 "2": {
1183 "name": "keyword.operator.assignment.tsp"
1184 }
1185 },
1186 "end": "(?=>)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1187 "endCaptures": {
1188 "0": {
1189 "name": "keyword.operator.assignment.tsp"
1190 }
1191 },
1192 "patterns": [
1193 {
1194 "include": "#token"
1195 },
1196 {
1197 "include": "#expression"
1198 },
1199 {
1200 "include": "#punctuation-comma"
1201 }
1202 ]
1203 },
1204 "type-arguments": {
1205 "name": "meta.type-arguments.typespec",
1206 "begin": "<",
1207 "beginCaptures": {
1208 "0": {
1209 "name": "punctuation.definition.typeparameters.begin.tsp"
1210 }
1211 },
1212 "end": ">",
1213 "endCaptures": {
1214 "0": {
1215 "name": "punctuation.definition.typeparameters.end.tsp"
1216 }
1217 },
1218 "patterns": [
1219 {
1220 "include": "#type-argument"
1221 },
1222 {
1223 "include": "#expression"
1224 },
1225 {
1226 "include": "#punctuation-comma"
1227 }
1228 ]
1229 },
1230 "type-parameter": {
1231 "name": "meta.type-parameter.typespec",
1232 "begin": "(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
1233 "beginCaptures": {
1234 "1": {
1235 "name": "entity.name.type.tsp"
1236 }
1237 },
1238 "end": "(?=>)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1239 "patterns": [
1240 {
1241 "include": "#token"
1242 },
1243 {
1244 "include": "#type-parameter-constraint"
1245 },
1246 {
1247 "include": "#type-parameter-default"
1248 }
1249 ]
1250 },
1251 "type-parameter-constraint": {
1252 "name": "meta.type-parameter-constraint.typespec",
1253 "begin": "extends",
1254 "beginCaptures": {
1255 "0": {
1256 "name": "keyword.other.tsp"
1257 }
1258 },
1259 "end": "(?=>)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1260 "patterns": [
1261 {
1262 "include": "#expression"
1263 }
1264 ]
1265 },
1266 "type-parameter-default": {
1267 "name": "meta.type-parameter-default.typespec",
1268 "begin": "=",
1269 "beginCaptures": {
1270 "0": {
1271 "name": "keyword.operator.assignment.tsp"
1272 }
1273 },
1274 "end": "(?=>)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1275 "patterns": [
1276 {
1277 "include": "#expression"
1278 }
1279 ]
1280 },
1281 "type-parameters": {
1282 "name": "meta.type-parameters.typespec",
1283 "begin": "<",
1284 "beginCaptures": {
1285 "0": {
1286 "name": "punctuation.definition.typeparameters.begin.tsp"
1287 }
1288 },
1289 "end": ">",
1290 "endCaptures": {
1291 "0": {
1292 "name": "punctuation.definition.typeparameters.end.tsp"
1293 }
1294 },
1295 "patterns": [
1296 {
1297 "include": "#type-parameter"
1298 },
1299 {
1300 "include": "#punctuation-comma"
1301 }
1302 ]
1303 },
1304 "typeof": {
1305 "name": "meta.typeof.typespec",
1306 "begin": "\\b(typeof)",
1307 "beginCaptures": {
1308 "1": {
1309 "name": "keyword.other.tsp"
1310 }
1311 },
1312 "end": "(?=>)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1313 "patterns": [
1314 {
1315 "include": "#expression"
1316 }
1317 ]
1318 },
1319 "union-body": {
1320 "name": "meta.union-body.typespec",
1321 "begin": "\\{",
1322 "beginCaptures": {
1323 "0": {
1324 "name": "punctuation.curlybrace.open.tsp"
1325 }
1326 },
1327 "end": "\\}",
1328 "endCaptures": {
1329 "0": {
1330 "name": "punctuation.curlybrace.close.tsp"
1331 }
1332 },
1333 "patterns": [
1334 {
1335 "include": "#union-variant"
1336 },
1337 {
1338 "include": "#token"
1339 },
1340 {
1341 "include": "#directive"
1342 },
1343 {
1344 "include": "#decorator"
1345 },
1346 {
1347 "include": "#expression"
1348 },
1349 {
1350 "include": "#punctuation-comma"
1351 }
1352 ]
1353 },
1354 "union-statement": {
1355 "name": "meta.union-statement.typespec",
1356 "begin": "\\b(union)\\b\\s+(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)",
1357 "beginCaptures": {
1358 "1": {
1359 "name": "keyword.other.tsp"
1360 },
1361 "2": {
1362 "name": "entity.name.type.tsp"
1363 }
1364 },
1365 "end": "(?<=\\})|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1366 "patterns": [
1367 {
1368 "include": "#token"
1369 },
1370 {
1371 "include": "#union-body"
1372 }
1373 ]
1374 },
1375 "union-variant": {
1376 "name": "meta.union-variant.typespec",
1377 "begin": "(?:(\\b[_$[:alpha:]][_$[:alnum:]]*\\b|`(?:[^`\\\\]|\\\\.)*`)\\s*(:))",
1378 "beginCaptures": {
1379 "1": {
1380 "name": "variable.name.tsp"
1381 },
1382 "2": {
1383 "name": "keyword.operator.type.annotation.tsp"
1384 }
1385 },
1386 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1387 "patterns": [
1388 {
1389 "include": "#token"
1390 },
1391 {
1392 "include": "#expression"
1393 }
1394 ]
1395 },
1396 "using-statement": {
1397 "name": "meta.using-statement.typespec",
1398 "begin": "\\b(using)\\b",
1399 "beginCaptures": {
1400 "1": {
1401 "name": "keyword.other.tsp"
1402 }
1403 },
1404 "end": "(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1405 "patterns": [
1406 {
1407 "include": "#token"
1408 },
1409 {
1410 "include": "#identifier-expression"
1411 },
1412 {
1413 "include": "#punctuation-accessor"
1414 }
1415 ]
1416 },
1417 "valueof": {
1418 "name": "meta.valueof.typespec",
1419 "begin": "\\b(valueof)",
1420 "beginCaptures": {
1421 "1": {
1422 "name": "keyword.other.tsp"
1423 }
1424 },
1425 "end": "(?=>)|(?=,|;|@|#[a-z]|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
1426 "patterns": [
1427 {
1428 "include": "#expression"
1429 }
1430 ]
1431 }
1432 }
1433}