syntax_test_c.c (30644B)
1 /* SYNTAX TEST "Packages/C++/C.sublime-syntax" */ 2 3 int main(){ 4 int a=5,b=0; 5 while(a-->0)++b; 6 /* ^^ keyword.operator.arithmetic */ 7 /* ^ keyword.operator.comparison */ 8 /* ^ constant.numeric */ 9 /* ^^ keyword.operator.arithmetic */ 10 } 11 12 enum Foo { kFoo, kBar }; 13 #define FOO Foo 14 enum FOO do_the_foo(void); 15 /* ^ entity.name.function */ 16 /* ^ storage.type */ 17 18 #define APIC_CAPABILITY TheEnum 19 enum TheEnum { kFoo, kBar }; 20 static enum APIC_CAPABILITY apic_capabilities(void) { return kFoo; }; 21 /* ^ entity.name.function */ 22 /* ^ storage.type */ 23 24 struct __declspec(dllimport) X {}; 25 /* ^ storage.modifier */ 26 /* ^ entity.name.struct */ 27 28 struct __declspec(dllimport) baz X {}; 29 /* ^ storage.modifier */ 30 /* ^ entity.name.struct */ 31 32 struct foo { 33 /* ^ entity.name.struct */ 34 union { 35 /* ^ storage.type */ 36 struct { 37 /* ^ storage.type */ 38 int a; 39 /* ^ storage.type */ 40 int b; 41 /* ^ storage.type */ 42 } 43 } 44 } 45 46 #define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS /* comment block */ * sizeof(struct ptp_extts_event)) // comment line 47 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ 48 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */ 49 /* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group meta.group */ 50 /* <- keyword.control.import.define */ 51 /* ^ entity.name.constant.preprocessor */ 52 /* ^ comment.block */ 53 /* ^ keyword.operator.word */ 54 /* ^ storage.type */ 55 /* ^ comment.line */ 56 57 #pragma foo(bar, \ 58 "baz") 59 /*^^^^ meta.preprocessor */ 60 61 #define MY_MACRO(a, b) 62 /*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ 63 /* ^^^^^^ meta.preprocessor.macro.parameters */ 64 /* ^^^^^^^^ entity.name.function.preprocessor */ 65 /* ^ punctuation.section.group.end */ 66 67 #define max(a, b, \ 68 /*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ 69 /* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ 70 /* <- keyword.control.import.define */ \ 71 /* ^ entity.name.function.preprocessor */ \ 72 /* ^ punctuation.section.group.begin */ \ 73 /* ^ variable.parameter */ \ 74 /* ^ punctuation.separator */ \ 75 /* */ \ 76 /* <- comment.block */ \ 77 c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) 78 /* <- meta.preprocessor.macro meta.group variable.parameter */ 79 /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ 80 /* ^ keyword.operator.ternary */ 81 /* ^ keyword.operator.ternary */ 82 83 #define PACKED __attribute__((aligned(1),packed)) 84 /* ^ entity.name.constant */ 85 /* ^ storage.modifier */ 86 87 int i; 88 /* <- storage.type */ 89 90 // The following example ensures that comments at the end of preprocessor 91 // directives don't mess with context transitions 92 int func() { 93 /* ^^^^^^^^ meta.function */ 94 /* ^^ meta.function.parameters */ 95 /* ^ meta.block punctuation.section.block.begin */ 96 /* ^ entity.name.function */ 97 #if( EXTAL == 40000 ) /* 40 MHz */ 98 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.block */ 99 /* ^ keyword.control.import */ 100 #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz 101 /* ^ keyword.control.import */ 102 /* ^^ constant.numeric */ 103 /* ^ comment.line */ 104 #endif 105 /* ^ keyword.control.import */ 106 } 107 /* <- meta.function meta.block punctuation.section.block.end */ 108 /* <- - meta.function meta.block */ 109 110 int f(int x, \ 111 /* ^ punctuation.separator.continuation */ 112 int y); 113 114 #define CONST0 16 // Comment 115 #define CONST1 8 116 /* <- keyword.control.import.define */ 117 /* ^ entity.name.constant */ 118 119 #if defined(VARIABLE) | // comment_line \ 120 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor */ \ 121 defined(VAR2) 122 /*^^^^^^^^^^^^^^^ meta.preprocessor */ 123 /* ^ keyword.control */ 124 # error This is a long error message that need to \ 125 /* <- keyword.control.import */ \ 126 /* ^ string.unquoted */ \ 127 be splitted into two lines to prevent large lines. // comment 128 #error "Eplicitly quoted string wrapped, \ 129 ensuring that the string quoting stops at some point \ 130 " 131 #warning This is a short warning 132 /* <- keyword.control.import */ 133 #endif 134 /* <- keyword.control.import */ 135 136 #define MACRO_WITH_CURLY_BRACE { 137 /* <- keyword.control.import.define */ 138 /* ^ entity.name.constant */ 139 140 #define MACRO_WITH_CURLY_BRACE_2 } 141 /* <- keyword.control.import.define */ 142 /* ^ entity.name.constant */ 143 144 bool still_C_code_here = true; 145 /* <- storage.type */ 146 /* ^ constant.language */ 147 148 FOOBAR 149 hello() { 150 /* <- meta.function entity.name.function */ 151 return 0; 152 } 153 154 EFIAPI 155 UserStructCompare ( 156 /* <- meta.function entity.name.function */ 157 IN CONST VOID *UserStruct1, 158 IN CONST VOID *UserStruct2 159 ) 160 { 161 const USER_STRUCT *CmpStruct1; 162 /* <- meta.block storage.modifier */ 163 164 CmpStruct1 = UserStruct1; 165 return KeyCompare (&CmpStruct1->Key, UserStruct2); 166 /* <- meta.block keyword.control */ 167 /* ^ meta.block meta.function-call variable.function */ 168 } 169 170 LIB_RESULT 171 foo() 172 /* <- meta.function entity.name.function */ 173 { 174 return LIB_SUCCESS; 175 } 176 177 LIB_RESULT bar() 178 /* ^ meta.function entity.name.function */ 179 { 180 return LIB_SUCCESS; 181 } 182 183 THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE 184 /* <- meta.assumed-macro */ 185 186 int main() { 187 /* <- storage.type */ 188 /* ^ meta.function entity.name.function */ 189 return 0; 190 } 191 192 #if 0 193 #ifdef moo 194 /* <- - keyword.control */ 195 #endif 196 /* <- - keyword.control */ 197 #endif 198 199 #if 0 200 /* ^ constant.numeric */ 201 int disabled_func() { 202 /* ^ comment.block */ 203 } 204 #endif 205 206 #if 1 207 /* ^ constant.numeric */ 208 int enabled_func() {} 209 /* ^ entity.name.function */ 210 #else 211 int disabled_func() { 212 /* ^ comment.block */ 213 } 214 #endif 215 216 #if 1 217 int a = 1; 218 #if 0 219 /* ^ constant.numeric */ 220 int b = 2; 221 /* ^ comment.block */ 222 #else 223 int c = 3; 224 #endif 225 #else 226 int d = 4; 227 /* ^ comment.block */ 228 #endif 229 230 FOO 231 /* <- meta.assumed-macro */ 232 FOO; 233 /* <- - meta.assumed-macro */ 234 foo 235 /* <- - meta.assumed-macro */ 236 ; // fix highlighting 237 /* <- punctuation.terminator */ 238 FOO() 239 /* <- meta.assumed-macro variable.function.assumed-macro */ 240 FOO(); 241 /* <- - meta.assumed-macro */ 242 foo() 243 /* <- - meta.assumed-macro */ 244 ; // fix highlighting 245 /* <- punctuation.terminator */ 246 247 struct X 248 { 249 ENABLED("reason") 250 /* <- meta.assumed-macro variable.function.assumed-macro */ 251 int foo; 252 /* <- storage.type */ 253 254 DISABLED("reason") 255 /* <- meta.assumed-macro variable.function.assumed-macro */ 256 float bar; 257 /* <- storage.type */ 258 }; 259 260 /** 261 * 262 /* ^ comment.block.c punctuation.definition.comment.c */ 263 264 ///////////////////////////////////////////// 265 // Preprocessor branches starting blocks 266 ///////////////////////////////////////////// 267 268 #ifdef FOO 269 if (1) { 270 #elif BAR 271 if (2) { 272 # elif BAZ 273 if (3) { 274 # else 275 if (4) { 276 #endif 277 int bar = 1; 278 } 279 /* <- meta.block punctuation.section.block.end */ 280 /* <- - meta.block */ 281 282 ///////////////////////////////////////////// 283 // Typedefs 284 ///////////////////////////////////////////// 285 286 typedef int myint; 287 /* <- storage.type */ 288 /* ^ entity.name.type */ 289 290 typedef struct mystruct { 291 /* <- storage.type */ 292 /* ^ - entity */ 293 } mystruct; 294 /* ^ entity.name.type */ 295 296 ///////////////////////////////////////////// 297 // Data structures and return values 298 ///////////////////////////////////////////// 299 300 struct point 301 /* ^ storage.type */ 302 /* ^ entity.name.struct */ 303 { 304 int x; 305 int y; 306 } 307 308 struct point2 { 309 /* ^ storage.type */ 310 /* ^ entity.name.struct */ 311 int x; 312 int y; 313 } 314 315 int main(void) { 316 /* ^^^^ entity.name.function */ 317 /* ^^^^ storage.type */ 318 } 319 320 struct point get_point() {} 321 /* ^^^^^^^^^^^^^^ meta.function */ 322 /* ^^ meta.function.parameters */ 323 /* ^^ meta.block */ 324 /* ^ punctuation.section.block.begin 325 /* ^ punctuation.section.block.end 326 /* ^ storage.type */ 327 /* ^ - entity.name.struct */ 328 /* ^ entity.name.function */ 329 330 struct point **alloc_points(); 331 /* ^ storage.type */ 332 /* ^ - entity.name.struct */ 333 /* ^^ keyword.operator */ 334 /* ^ entity.name.function */ 335 336 struct point* alloc_point(); 337 /* ^ entity.name.function - variable.function */ 338 339 struct point FOO_API *alloc_point3(); 340 /* ^ entity.name.function - variable.function */ 341 342 int main(void) 343 { 344 struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; 345 /* ^ - entity.name */ 346 /* ^ - entity.name */ 347 } 348 349 struct foo MACRO { 350 /* ^ entity.name.struct */ 351 /* ^ - entity.name */ 352 } 353 354 // Partially-typed 355 struct foo 356 /* ^ entity.name */ 357 358 struct UI_MenuBoxData 359 /* <- storage.type */ 360 /* ^ entity.name.struct */ 361 { 362 struct UI_BoundingBox position; 363 /* ^ - entity.name */ 364 /* ^ - entity.name */ 365 enum UI_BoxCharType borderType; 366 /* ^ - entity.name */ 367 /* ^ - entity.name */ 368 unsigned int paddingX; 369 unsigned int paddingY; 370 struct UI_ScrollBoxText boxContents[]; 371 /* ^ - entity.name */ 372 /* ^ - entity.name */ 373 }; 374 375 ///////////////////////////////////////////// 376 // Test preprocessor branching and C blocks 377 ///////////////////////////////////////////// 378 379 int foo(int val, float val2[]) 380 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 381 /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ 382 /* ^ punctuation.section.group.begin */ 383 /* ^ punctuation.section.group.end */ 384 /* ^^^ variable.parameter */ 385 /* ^ punctuation.separator */ 386 /* ^^^^ variable.parameter */ 387 /* ^^ meta.brackets */ 388 /* ^ punctuation.section.brackets.begin */ 389 /* ^ punctuation.section.brackets.end */ 390 { 391 /* <- meta.function meta.block */ 392 myClass *result; 393 result->kk = func(val); 394 /* ^^ punctuation.accessor */ 395 if (result != 0) { 396 /* ^^ keyword.operator.comparison.c */ 397 return 0; 398 #if CROSS_SCOPE_MACRO 399 /* <- keyword.control.import */ 400 } else if (result > 0) { 401 return 1; 402 #endif 403 /* <- keyword.control.import */ 404 } 405 /* ^ meta.block meta.block punctuation.section.block.end */ 406 /* ^ - meta.block meta.block */ 407 408 #ifdef FOO 409 /* <- keyword.control.import */ 410 int foobar 411 /* ^^^^^^ - entity.name.function */ 412 ; 413 414 if (val == -1) { 415 /* ^^ keyword.control */ 416 /* ^ meta.block meta.block punctuation.section.block.begin */ 417 #else 418 /* <- keyword.control.import */ 419 if (val == -2) { 420 /* ^ meta.block meta.block punctuation.section.block.begin */ 421 #endif 422 /* <- keyword.control.import */ 423 val += 1; 424 } 425 /* ^ meta.block meta.block punctuation.section.block.end */ 426 /* ^ - meta.block meta.block */ 427 428 return -1; 429 } 430 /* <- meta.function punctuation.section.block.end */ 431 /* <- - meta.function */ 432 433 BOOL 434 GetTextMetrics( 435 HDC hdc, 436 LPTEXTMETRIC lptm 437 ) 438 { 439 #ifdef UNICODE 440 /* <- keyword.control.import */ 441 return GetTextMetricsW( 442 /* ^ variable.function */ 443 #else 444 /* <- keyword.control.import */ 445 return GetTextMetricsA( 446 /* ^ variable.function */ 447 #endif 448 /* <- keyword.control.import */ 449 hdc, 450 lptm 451 ); 452 /* ^ meta.function-call */ 453 /* ^ - meta.function-call */ 454 } 455 /* <- - meta.function */ 456 /* <- - meta.block */ 457 458 ///////////////////////////////////////////// 459 // Matching various function definitions 460 ///////////////////////////////////////////// 461 462 const int foo = 1; 463 /* ^ - entity.name.function */ 464 int a; 465 /* ^ - entity.name.function */ 466 467 int /* comment */ * myfunc 468 /* <- storage.type */ 469 /* ^ comment.block */ 470 /* ^ keyword.operator */ 471 /* ^^^^^^ meta.function entity.name.function */ 472 (int * a) 473 /*^^^^^^^ meta.function.parameters meta.group */ 474 /* <- punctuation.section.group.begin */ 475 /* ^ keyword.operator */ 476 /* ^ variable.parameter */ 477 /* ^ punctuation.section.group.end */ 478 { 479 /* <- meta.function meta.block punctuation.section.block.begin */ 480 } 481 482 MACRO1 483 RETURN_TYPE 484 /* <- - entity.name.function */ 485 func_name() { 486 /* < entity.name.function */ 487 } 488 489 MACRO1 void * MACRO2 myfuncname () { 490 /* ^^^^^^^^^^^^^^^ meta.function */ 491 /* ^^ meta.function.parameters */ 492 /* ^ meta.block punctuation.section.block.begin 493 /* ^ storage.type */ 494 /* ^ keyword.operator */ 495 /* ^ entity.name.function */ 496 497 label: 498 /* ^ entity.name.label */ 499 /* ^ punctuation.separator */ 500 do { 501 break; 502 } while(true); 503 504 switch (a) { 505 case 1: break; 506 /* ^ punctuation.separator */ 507 case 100 - 10: break; 508 /* ^ punctuation.separator */ 509 default: break; 510 /* ^ punctuation.separator */ 511 } 512 513 struct Args { 514 /* ^ storage.type */ 515 /* ^ entity.name.struct */ 516 void* hello; 517 void* foobar; 518 }; 519 520 struct Args args; 521 /* ^ storage.type */ 522 /* ^ - entity */ 523 524 } 525 526 static const uint32_t * const MACRO funcname(); 527 /* ^^^^^^^^^^ meta.function */ 528 /* ^^ meta.function.parameters */ 529 /* ^ storage.modifier */ 530 /* ^ storage.modifier */ 531 /* ^ support.type */ 532 /* ^ keyword.operator */ 533 /* ^ storage.modifier */ 534 /* ^ entity.name.function */ 535 536 MACRO int 537 /* ^ storage.type */ 538 funcname2 539 /* ^ entity.name.function */ 540 () 541 { 542 int a[5]; 543 /* ^^^ meta.brackets */ 544 /* ^ punctuation.section.brackets.begin */ 545 /* ^ punctuation.section.brackets.end */ 546 } 547 548 MACRO_CALL(int) macro_prefixed_func(){} 549 /*^^^^^^^^^^^^^ meta.function-call */ 550 /* ^^^^^ meta.group */ 551 /* ^ punctuation.section.group.begin */ 552 /* ^ punctuation.section.group.end */ 553 /* ^ entity.name.function */ 554 555 int* return_type_pointer_no_space(){} 556 /* ^ entity.name.function */ 557 558 // Make sure there isn't an incorrect match here since this is not a valid 559 // function definition 560 int32 561 /* <- - entity.name.function */ 562 () {} 563 564 _declspec(deprecated("bla")) void func2(int) {} 565 /* <- meta.function-call variable.function */ 566 /* ^ entity.name.function */ 567 __declspec(deprecated("bla")) void func2(int) {} 568 /* <- storage.modifier - variable.function */ 569 /* ^ storage.modifier - variable.function */ 570 /* ^ string.quoted.double punctuation */ 571 /* ^ string.quoted.double - punctuation */ 572 /* ^ string.quoted.double - punctuation */ 573 /* ^ string.quoted.double punctuation */ 574 /* ^^ punctuation - invalid */ 575 /* ^ entity.name.function */ 576 __notdeclspec(deprecated("bla")) void func2(int) {} 577 /* <- meta.function-call variable.function */ 578 /* ^ entity.name.function */ 579 580 ///////////////////////////////////////////// 581 // Test function call in function parameters 582 ///////////////////////////////////////////// 583 584 static string foo(bar() + ';'); 585 /* ^^^^^^^^^^^^^^^^ meta.function */ 586 /* ^^^^^^^^^^^^^ meta.function.parameters */ 587 /* ^^^ entity.name.function */ 588 /* ^^^^^ meta.function-call */ 589 /* ^^^ variable.function */ 590 /* ^^^ string */ 591 /* ^ -string */ 592 593 func_call(foo 594 /*^^^^^^^^^^^ meta.function-call */ 595 /* ^^^^ meta.group */ 596 /* ^ punctuation.section.group.begin */ 597 ); 598 /* <- meta.function-call meta.group punctuation.section.group.end */ 599 600 ///////////////////////////////////////////// 601 // Invalid 602 ///////////////////////////////////////////// 603 ) 604 /* <- invalid.illegal.stray-bracket-end */ 605 } 606 /* <- invalid.illegal.stray-bracket-end */ 607 608 ///////////////////////////////////////////// 609 // Includes 610 ///////////////////////////////////////////// 611 612 #include "foobar.h" 613 /* <- keyword.control.import.include */ 614 /* ^ punctuation.definition.string.begin */ 615 /* ^^^^^^^^ string.quoted.double.include */ 616 /* ^ punctuation.definition.string.end */ 617 618 #include <cstdlib> 619 /* <- keyword.control.import.include */ 620 /* ^ punctuation.definition.string.begin */ 621 /* ^^^^^^^ string.quoted.other.lt-gt.include */ 622 /* ^ punctuation.definition.string.end */ 623 624 #ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS 625 #include_next <math.h> 626 /* <- keyword.control.import.include */ 627 /* ^ punctuation.definition.string.begin */ 628 /* ^^^^^^ string.quoted.other.lt-gt.include */ 629 /* ^ punctuation.definition.string.end */ 630 #endif 631 632 #include<iostream> 633 /* <- keyword.control.import.include */ 634 /* ^ punctuation.definition.string.begin */ 635 /* ^^^^^^^^ string.quoted.other.lt-gt.include */ 636 /* ^ punctuation.definition.string.end */ 637 638 ///////////////////////////////////////////// 639 // Numeric Constants 640 ///////////////////////////////////////////// 641 642 dec0 = 0; 643 /* ^ constant.numeric.integer.decimal */ 644 /* ^ punctuation.terminator - constant */ 645 dec1 = 1234567890; 646 /* ^^^^^^^^^^ constant.numeric.integer.decimal */ 647 /* ^ punctuation.terminator - constant */ 648 649 dec2 = 1234567890f; 650 /* ^^^^^^^^^^^ constant.numeric.float.decimal */ 651 /* ^ storage.type.numeric */ 652 /* ^ punctuation.terminator - constant */ 653 654 dec3 = 1234567890L; 655 /* ^^^^^^^^^^^ constant.numeric.integer.decimal */ 656 /* ^ storage.type.numeric */ 657 /* ^ punctuation.terminator - constant */ 658 659 dec4 = 1234567890ul; 660 /* ^^^^^^^^^^^^ constant.numeric.integer.decimal */ 661 /* ^^ storage.type.numeric */ 662 /* ^ punctuation.terminator - constant */ 663 664 dec5 = 1234567890Lu; 665 /* ^^^^^^^^^^^^ constant.numeric.integer.decimal */ 666 /* ^^ storage.type.numeric */ 667 /* ^ punctuation.terminator - constant */ 668 669 dec6 = 1234567890LLU; 670 /* ^^^^^^^^^^^^^ constant.numeric.integer.decimal */ 671 /* ^^^ storage.type.numeric */ 672 /* ^ punctuation.terminator - constant */ 673 674 dec7 = 1234567890uLL; 675 /* ^^^^^^^^^^^^^ constant.numeric.integer.decimal */ 676 /* ^^^ storage.type.numeric */ 677 /* ^ punctuation.terminator - constant */ 678 679 dec8 = 1'234_567'890s0f; 680 /* ^ constant.numeric.integer.decimal */ 681 /* ^^^^^^^^^ string.quoted.single */ 682 /* ^^^^^^ constant.numeric.integer.decimal */ 683 /* ^^^ invalid.illegal.numeric.suffix */ 684 /* ^ punctuation.terminator - constant */ 685 686 oct1 = 01234567; 687 /* ^^^^^^^^ constant.numeric.integer.octal */ 688 /* ^ punctuation.definition.numeric.base */ 689 /* ^ punctuation.terminator - constant */ 690 691 oct2 = 01234567L; 692 /* ^^^^^^^^ constant.numeric.integer.octal */ 693 /* ^ punctuation.definition.numeric.base */ 694 /* ^ storage.type.numeric */ 695 /* ^ punctuation.terminator - constant */ 696 697 oct3 = 01234567LL; 698 /* ^^^^^^^^^^ constant.numeric.integer.octal */ 699 /* ^ punctuation.definition.numeric.base */ 700 /* ^^ storage.type.numeric */ 701 /* ^ punctuation.terminator - constant */ 702 703 oct4 = 01234567ulL; 704 /* ^^^^^^^^^^^ constant.numeric.integer.octal */ 705 /* ^ punctuation.definition.numeric.base */ 706 /* ^^^ storage.type.numeric */ 707 /* ^ punctuation.terminator - constant */ 708 709 oct2 = 01284967Z0L; 710 /* ^^^^^^^^^^^ constant.numeric.integer.octal */ 711 /* ^ punctuation.definition.numeric.base */ 712 /* ^ invalid.illegal.numeric.digit */ 713 /* ^ invalid.illegal.numeric.digit */ 714 /* ^^^ invalid.illegal.numeric.suffix */ 715 /* ^ punctuation.terminator - constant */ 716 717 hex1 = 0x0+0xFL+0xaull+0xallu+0xfu+0x'f'12_4uz; 718 /* ^^^ constant.numeric.integer.hexadecimal */ 719 /* ^^ punctuation.definition.numeric.base */ 720 /* ^^^^ constant.numeric.integer.hexadecimal */ 721 /* ^^ punctuation.definition.numeric.base */ 722 /* ^ storage.type.numeric */ 723 /* ^^^^^^ constant.numeric.integer.hexadecimal */ 724 /* ^^ punctuation.definition.numeric.base */ 725 /* ^^^ storage.type.numeric */ 726 /* ^^^^^^ constant.numeric.integer.hexadecimal */ 727 /* ^^ punctuation.definition.numeric.base */ 728 /* ^^^ storage.type.numeric */ 729 /* ^^^^ constant.numeric.integer.hexadecimal */ 730 /* ^^ punctuation.definition.numeric.base */ 731 /* ^ storage.type.numeric */ 732 /* ^^ constant.numeric.integer.hexadecimal */ 733 /* ^^ punctuation.definition.numeric.base */ 734 /* ^^^ string.quoted.single */ 735 /* ^^^^^^ constant.numeric.integer.decimal */ 736 /* ^^^^ invalid.illegal.numeric.suffix */ 737 /* ^ punctuation.terminator - constant */ 738 739 hex2 = 0xc1.01AbFp-1; 740 /* ^^^^^^^^^^^^^ constant.numeric.float.hexadecimal */ 741 /* ^^ punctuation.definition.numeric.base */ 742 /* ^ punctuation.separator.decimal */ 743 /* ^ punctuation.terminator - constant */ 744 745 f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; 746 /* ^^^ constant.numeric.float.decimal */ 747 /* ^ punctuation.separator.decimal */ 748 /* ^ keyword.operator.arithmetic */ 749 /* ^^^^^ constant.numeric.float.decimal */ 750 /* ^ punctuation.separator.decimal */ 751 /* ^ keyword.operator.arithmetic */ 752 /* ^^^^^^ constant.numeric.float.decimal */ 753 /* ^ punctuation.separator.decimal */ 754 /* ^ keyword.operator.arithmetic */ 755 /* ^^^^ constant.numeric.float.decimal */ 756 /* ^ punctuation.separator.decimal */ 757 /* ^ storage.type.numeric */ 758 /* ^ keyword.operator.arithmetic */ 759 /* ^^^^^^ constant.numeric.float.decimal */ 760 /* ^ punctuation.separator.decimal */ 761 /* ^ storage.type.numeric */ 762 /* ^ keyword.operator.arithmetic */ 763 /* ^^^^^^^ constant.numeric.float.decimal */ 764 /* ^ punctuation.separator.decimal */ 765 /* ^ storage.type.numeric */ 766 /* ^ keyword.operator.arithmetic */ 767 /* ^^^^ constant.numeric.float.decimal */ 768 /* ^ punctuation.separator.decimal */ 769 /* ^ storage.type.numeric */ 770 /* ^ keyword.operator.arithmetic */ 771 /* ^^^^^^ constant.numeric.float.decimal */ 772 /* ^ punctuation.separator.decimal */ 773 /* ^ storage.type.numeric */ 774 /* ^ keyword.operator.arithmetic */ 775 /* ^^^^^^^ constant.numeric.float.decimal */ 776 /* ^ punctuation.separator.decimal */ 777 /* ^ storage.type.numeric */ 778 /* ^ punctuation.terminator - constant */ 779 780 f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; 781 /* ^^^^ constant.numeric.float.decimal */ 782 /* ^ punctuation.separator.decimal */ 783 /* ^ keyword.operator.arithmetic */ 784 /* ^^^^^ constant.numeric.float.decimal */ 785 /* ^ punctuation.separator.decimal */ 786 /* ^ keyword.operator.arithmetic */ 787 /* ^^^^^ constant.numeric.float.decimal */ 788 /* ^ punctuation.separator.decimal */ 789 /* ^ storage.type.numeric */ 790 /* ^ keyword.operator.arithmetic */ 791 /* ^^^^^^ constant.numeric.float.decimal */ 792 /* ^ punctuation.separator.decimal */ 793 /* ^ storage.type.numeric */ 794 /* ^ keyword.operator.arithmetic */ 795 /* ^^^^^ constant.numeric.float.decimal */ 796 /* ^ punctuation.separator.decimal */ 797 /* ^ storage.type.numeric */ 798 /* ^ keyword.operator.arithmetic */ 799 /* ^^^^^^ constant.numeric.float.decimal */ 800 /* ^ punctuation.separator.decimal */ 801 /* ^ storage.type.numeric */ 802 /* ^ punctuation.terminator - constant */ 803 804 f = 1.+1.f+1.L+1..; 805 /* ^^ constant.numeric.float.decimal */ 806 /* ^ punctuation.separator.decimal */ 807 /* ^ keyword.operator.arithmetic */ 808 /* ^^^ constant.numeric.float.decimal */ 809 /* ^ punctuation.separator.decimal */ 810 /* ^ storage.type.numeric */ 811 /* ^ keyword.operator.arithmetic */ 812 /* ^^^ constant.numeric.float.decimal */ 813 /* ^ punctuation.separator.decimal */ 814 /* ^ storage.type.numeric */ 815 /* ^ keyword.operator.arithmetic */ 816 /* ^ constant.numeric.integer.decimal */ 817 /* ^^ invalid.illegal.syntax */ 818 /* ^ punctuation.terminator - constant */ 819 820 f = 1e1+1e1f+1e1L; 821 /* ^^^ constant.numeric.float.decimal */ 822 /* ^ keyword.operator.arithmetic */ 823 /* ^^^^ constant.numeric.float.decimal */ 824 /* ^ storage.type.numeric */ 825 /* ^ keyword.operator.arithmetic */ 826 /* ^^^^ constant.numeric.float.decimal */ 827 /* ^ storage.type.numeric */ 828 /* ^ punctuation.terminator - constant */ 829 830 f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; 831 /* ^^ constant.numeric.float.decimal */ 832 /* ^ punctuation.separator.decimal */ 833 /* ^ keyword.operator.arithmetic */ 834 /* ^^^^ constant.numeric.float.decimal */ 835 /* ^ punctuation.separator.decimal */ 836 /* ^ keyword.operator.arithmetic */ 837 /* ^^^^^ constant.numeric.float.decimal */ 838 /* ^ punctuation.separator.decimal */ 839 /* ^ keyword.operator.arithmetic */ 840 /* ^^^ constant.numeric.float.decimal */ 841 /* ^ punctuation.separator.decimal */ 842 /* ^ storage.type.numeric */ 843 /* ^ keyword.operator.arithmetic */ 844 /* ^^^^^ constant.numeric.float.decimal */ 845 /* ^ punctuation.separator.decimal */ 846 /* ^ storage.type.numeric */ 847 /* ^ keyword.operator.arithmetic */ 848 /* ^^^^^^ constant.numeric.float.decimal */ 849 /* ^ punctuation.separator.decimal */ 850 /* ^ storage.type.numeric */ 851 /* ^^^ constant.numeric.float.decimal */ 852 /* ^ punctuation.separator.decimal */ 853 /* ^ storage.type.numeric */ 854 /* ^ keyword.operator.arithmetic */ 855 /* ^^^^^ constant.numeric.float.decimal */ 856 /* ^ punctuation.separator.decimal */ 857 /* ^ storage.type.numeric */ 858 /* ^ keyword.operator.arithmetic */ 859 /* ^^^^^^ constant.numeric.float.decimal */ 860 /* ^ punctuation.separator.decimal */ 861 /* ^ storage.type.numeric */ 862 /* ^ punctuation.terminator - constant */ 863 864 f = 1.0suff+1.suff*.0suff/{1suff} 865 /* ^^^ constant.numeric.float.decimal - invalid */ 866 /* ^^^^ constant.numeric.float.decimal invalid.illegal.numeric.suffix */ 867 /* ^ keyword.operator.arithmetic */ 868 /* ^^ constant.numeric.float.decimal - invalid */ 869 /* ^^^^ constant.numeric.float.decimal invalid.illegal.numeric.suffix */ 870 /* ^ keyword.operator */ 871 /* ^^ constant.numeric.float.decimal - invalid */ 872 /* ^^^^ constant.numeric.float.decimal invalid.illegal.numeric.suffix */ 873 /* ^ keyword.operator.arithmetic */ 874 /* ^ punctuation.section.block.begin */ 875 /* ^ constant.numeric.integer.decimal - invalid */ 876 /* ^^^^ constant.numeric.integer.decimal invalid.illegal.numeric.suffix */ 877 /* ^ punctuation.section.block.end */ 878 879 scanf("%ms %as %*[, ]", &buf); 880 /* ^^^ constant.other.placeholder */ 881 /* ^^^ constant.other.placeholder */ 882 /* ^^^^^^ constant.other.placeholder */ 883 884 "foo % baz" 885 /* ^ - invalid */ 886 887 888 ///////////////////////////////////////////// 889 // Control Keywords 890 ///////////////////////////////////////////// 891 892 int control_keywords() 893 { 894 if (x < 5) 895 /* <- keyword.control */ 896 {} 897 else 898 /* <- keyword.control */ 899 {} 900 901 switch (x) 902 /* <- keyword.control */ 903 { 904 case 1: 905 /* <- keyword.control */ 906 break; 907 /* <- keyword.control.flow.break */ 908 default: 909 /* <- keyword.control */ 910 break; 911 /* <- keyword.control.flow.break */ 912 } 913 914 do 915 /* <- keyword.control */ 916 { 917 if (y == 3) 918 continue; 919 /* <- keyword.control.flow.continue */ 920 } while (y < x); 921 /*^ keyword.control */ 922 923 switch (a) { 924 case 1: break; 925 /* ^ punctuation.separator */ 926 case 100 - 10: break; 927 /* ^ punctuation.separator */ 928 default: break; 929 /* ^ punctuation.separator */ 930 } 931 932 goto label; 933 /* <- keyword.control.flow.goto */ 934 935 label: 936 937 return 123; 938 /* <- keyword.control.flow.return */ 939 }