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