syntax_test_cpp.cpp (85744B)
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 ///////////////////////////////////////////// 13 // Preprocessor 14 ///////////////////////////////////////////// 15 16 #ifndef IGUARD_ 17 /* <- keyword.control.import */ 18 #define IGUARD_ 19 /* <- keyword.control.import.define */ 20 struct foo* alloc_foo(); 21 /* <- storage.type */ 22 /* <- - entity.name.type */ 23 /* <- entity.name.function */ 24 #endif 25 /* <- keyword.control.import */ 26 27 // The following example ensures that comments at the end of preprocessor 28 // directives don't mess with context transitions 29 int func() { 30 /* ^ entity.name.function */ 31 #if( EXTAL == 40000 ) /* 40 MHz */ 32 /* ^ keyword.control.import */ 33 #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz 34 /* ^ keyword.control.import */ 35 /* ^^ constant.numeric */ 36 /* ^ comment.line */ 37 #endif 38 /* ^ keyword.control.import */ 39 } 40 /* <- meta.function meta.block punctuation.section.block.end */ 41 /* <- - meta.function meta.block */ 42 43 int f(int x, \ 44 /* ^ punctuation.separator.continuation */ 45 int y); 46 47 int g(int x = 5 \ 48 /* ^ punctuation.separator.continuation */ 49 , int y); 50 51 #define MACRO_WITH_CURLY_BRACE { 52 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ 53 /* <- keyword.control.import.define */ 54 /* ^ entity.name.constant */ 55 56 #define MACRO_WITH_CURLY_BRACE_2 } 57 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ 58 /* <- keyword.control.import.define */ 59 /* ^ entity.name.constant */ 60 61 FOOBAR 62 hello() { 63 /* <- meta.function entity.name.function */ 64 return 0; 65 } 66 67 EFIAPI 68 UserStructCompare ( 69 /* <- meta.function entity.name.function */ 70 IN CONST VOID *UserStruct1, 71 IN CONST VOID *UserStruct2 72 ) 73 { 74 const USER_STRUCT *CmpStruct1; 75 /* <- meta.block storage.modifier */ 76 77 CmpStruct1 = UserStruct1; 78 return KeyCompare (&CmpStruct1->Key, UserStruct2); 79 /* <- meta.block keyword.control */ 80 /* ^ meta.block meta.function-call variable.function */ 81 } 82 83 LIB_RESULT 84 foo() 85 /* <- meta.function entity.name.function */ 86 { 87 return LIB_SUCCESS; 88 } 89 90 LIB_RESULT bar() 91 /* ^ meta.function entity.name.function */ 92 { 93 return LIB_SUCCESS; 94 } 95 96 THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE 97 /* <- meta.assumed-macro */ 98 99 int main() { 100 /* <- storage.type */ 101 /* ^ meta.function entity.name.function */ 102 return 0; 103 } 104 105 // This is a method/function with the return type on a separate line and so should not be a 106 // constructor. 107 FOOLIB_RESULT 108 some_namespace::some_function(int a_parameter, double another_parameter) { 109 /* <- meta.function meta.toc-list.full-identifier */ 110 /* ^ entity.name.function - entity.name.function.constructor */ 111 return FOOLIB_SUCCESS; 112 } 113 114 #pragma foo(bar, \ 115 "baz", \ 116 1) 117 /* <- meta.preprocessor */ 118 119 #define MY_MACRO(a, b) 120 /*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ 121 /* ^^^^^^ meta.preprocessor.macro.parameters */ 122 /* ^^^^^^^^ entity.name.function.preprocessor */ 123 /* ^ punctuation.section.group.end */ 124 125 #define max(a, b, \ 126 /*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ 127 /* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ 128 /* <- keyword.control.import.define */ \ 129 /* ^ entity.name.function.preprocessor */ \ 130 /* ^ punctuation.section.group.begin */ \ 131 /* ^ variable.parameter */ \ 132 /* ^ punctuation.separator */ \ 133 /* */ \ 134 /* <- comment.block */ \ 135 c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) 136 /* <- meta.preprocessor.macro meta.group variable.parameter */ 137 /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ 138 /* ^ keyword.operator.ternary */ 139 /* ^ keyword.operator.ternary */ 140 141 #if 0 142 #ifdef moo 143 /* <- - keyword.control */ 144 #endif 145 /* <- - keyword.control */ 146 #endif 147 148 FOO() 149 /* <- meta.assumed-macro variable.function.assumed-macro */ 150 FOO 151 /* <- meta.assumed-macro */ 152 153 struct FOO1 FOO2 FOO3 Test { 154 /* ^ meta.struct meta.assumed-macro */ 155 /* ^ meta.struct meta.assumed-macro */ 156 /* ^ meta.struct meta.assumed-macro */ 157 Test(); 158 Test() noexcept; 159 Test() final; 160 Test() noexcept final; 161 ~Test(); 162 ~Test() noexcept; 163 ~Test() override noexcept; 164 virtual ~Test(); 165 virtual ~Test() noexcept; 166 virtual ~Test() override noexcept; 167 DLL_API Test(); 168 /* <- meta.assumed-macro */ 169 /* ^ meta.method.constructor */ 170 DLL_API Test() noexcept; 171 /* <- meta.assumed-macro */ 172 /* ^ meta.method.constructor */ 173 /* ^ storage.modifier */ 174 DLL_API Test() final; 175 /* <- meta.assumed-macro */ 176 /* ^ meta.method.constructor */ 177 /* ^ storage.modifier */ 178 DLL_API Test() noexcept final; 179 /* <- meta.assumed-macro */ 180 /* ^ meta.method.constructor */ 181 /* ^ storage.modifier */ 182 /* ^ storage.modifier */ 183 DLL_API ~Test(); 184 /* <- meta.assumed-macro */ 185 /* ^ meta.method.destructor */ 186 DLL_API ~Test() noexcept; 187 /* <- meta.assumed-macro */ 188 /* ^ meta.method.destructor */ 189 /* ^ storage.modifier */ 190 DLL_API ~Test() override noexcept; 191 /* <- meta.assumed-macro */ 192 /* ^ meta.method.destructor */ 193 /* ^ storage.modifier */ 194 /* ^ storage.modifier */ 195 DLL_API virtual ~Test(); 196 /* <- meta.assumed-macro */ 197 /* ^ storage.modifier */ 198 /* ^ meta.method.destructor */ 199 DLL_API virtual ~Test() noexcept; 200 /* <- meta.assumed-macro */ 201 /* ^ storage.modifier */ 202 /* ^ meta.method.destructor */ 203 /* ^ storage.modifier */ 204 DLL_API virtual ~Test() override noexcept; 205 /* <- meta.assumed-macro */ 206 /* ^ storage.modifier */ 207 /* ^ meta.method.destructor */ 208 /* ^ storage.modifier */ 209 /* ^ storage.modifier */ 210 } 211 212 struct X { 213 X(); 214 /* <- meta.group */ 215 /*^ meta.group - meta.group meta.group */ 216 }; 217 218 #define DEPRECATED(msg) [[deprecated(msg)]] 219 220 struct Test { 221 DEPRECATED("bla") 222 /* <- meta.assumed-macro variable.function.assumed-macro */ 223 bool foo (bool run=true) {} 224 /* ^ entity.name.function */ 225 }; 226 227 namespace Test { 228 DEPRECATED("bla") 229 /* <- meta.assumed-macro variable.function.assumed-macro */ 230 bool foo (bool run=true) {} 231 /* ^ entity.name.function */ 232 } 233 234 struct Test { 235 DEPRECATED("bla") 236 /* <- meta.assumed-macro variable.function.assumed-macro */ 237 bool foo (bool run=true) {} 238 /* ^ entity.name.function */ 239 }; 240 241 ///////////////////////////////////////////// 242 // Strings 243 ///////////////////////////////////////////// 244 245 char str1[] = "abc"; 246 /* ^ punctuation.definition.string.begin */ 247 /* ^ string.quoted.double */ 248 /* ^ punctuation.definition.string.end */ 249 250 char str2[] = u8"abc"; 251 /* ^ storage.type.string */ 252 /* ^ punctuation.definition.string.begin */ 253 /* ^ string.quoted.double */ 254 255 char16_t str3[] = u"abc"; 256 /* ^ storage.type.string */ 257 /* ^ punctuation.definition.string.begin */ 258 /* ^ string.quoted.double */ 259 260 char32_t str4[] = U"abc"; 261 /* ^ storage.type.string */ 262 /* ^ punctuation.definition.string.begin */ 263 /* ^ string.quoted.double */ 264 265 wchar_t str5[] = L"abc"; 266 /* ^ storage.type.string */ 267 /* ^ punctuation.definition.string.begin */ 268 /* ^ string.quoted.double */ 269 270 char str6[] = "\a|\b|\e|\f|\n|\r|\t|\v|\'|\"|\?"; 271 /* ^^ constant.character.escape */ 272 /* ^^ constant.character.escape */ 273 /* ^^ constant.character.escape */ 274 /* ^^ constant.character.escape */ 275 /* ^^ constant.character.escape */ 276 /* ^^ constant.character.escape */ 277 /* ^^ constant.character.escape */ 278 /* ^^ constant.character.escape */ 279 /* ^^ constant.character.escape */ 280 /* ^^ constant.character.escape */ 281 /* ^^ constant.character.escape */ 282 283 char str7[] = "\0|\012"; 284 /* ^^ constant.character.escape */ 285 /* ^^^^ constant.character.escape */ 286 287 char str8[] = "\x0a|\x41|\xA|\x000065"; 288 /* ^^^^ constant.character.escape */ 289 /* ^^^^ constant.character.escape */ 290 /* ^^^ constant.character.escape */ 291 /* ^^^^^^^^ constant.character.escape */ 292 293 char16_t str9[] = u"\u0063"; 294 /* ^^^^^^ constant.character.escape */ 295 296 char32_t str10[] = U"\U00000063"; 297 /* ^^^^^^^^^^ constant.character.escape */ 298 299 char str11[] = "\q"; 300 /* ^^ invalid.illegal.unknown-escape */ 301 302 scanf("%ms %as %*[, ]", &buf); 303 /* ^^^ constant.other.placeholder */ 304 /* ^^^ constant.other.placeholder */ 305 /* ^^^^^^ constant.other.placeholder */ 306 307 "foo % baz" 308 /* ^ - invalid */ 309 310 char rawStr1[] = R"("This is a raw string")"; 311 /* ^ storage.type.string */ 312 /* ^ punctuation.definition.string.begin */ 313 /* ^ string.quoted.double */ 314 /* ^ punctuation.definition.string.end */ 315 316 char rawStr2[] = R"A*!34( )" )A*!34"; 317 /* ^ storage.type.string */ 318 /* ^ punctuation.definition.string.begin */ 319 /* ^ punctuation.definition.string.begin */ 320 /* ^ string.quoted.double */ 321 /* ^ punctuation.definition.string.end */ 322 /* ^ punctuation.definition.string.end */ 323 324 const char IncludeRegexPattern[] = 325 R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; 326 /* ^ storage.type.string */ 327 /* ^ punctuation.definition.string.begin */ 328 /* ^^ - invalid */ 329 /* ^^ - invalid */ 330 /* ^ punctuation.definition.string.end */ 331 332 foo.f<5> /* foo */ (); 333 334 ///////////////////////////////////////////// 335 // Storage Types 336 ///////////////////////////////////////////// 337 338 void* ptr; 339 /* <- storage.type */ 340 341 bool b; 342 /* <- storage.type */ 343 344 char ch; 345 /* <- storage.type */ 346 347 char16_t ch16; 348 /* <- storage.type */ 349 350 char32_t ch32; 351 /* <- storage.type */ 352 353 wchar_t wch; 354 /* <- storage.type */ 355 356 unsigned int ui; 357 /* <- storage.type */ 358 /* ^ storage.type */ 359 360 signed long l; 361 /* <- storage.type */ 362 /* ^ storage.type */ 363 364 short s; 365 /* <- storage.type */ 366 367 auto a = 2; 368 /* <- storage.type */ 369 370 decltype(s) dt; 371 /* <- storage.type */ 372 /* ^ punctuation.section.group.begin */ 373 /* ^ punctuation.section.group.end */ 374 375 float f; 376 /* <- storage.type */ 377 378 double d; 379 /* <- storage.type */ 380 381 typedef int my_int; 382 /* <- storage.type */ 383 /* ^ entity.name.type */ 384 385 typedef struct Books { 386 /* ^ storage.type */ 387 /* ^ - entity.name.type */ 388 char title[50]; 389 int book_id; 390 } Book; 391 /*^ entity.name.type */ 392 393 using Alias = Foo; 394 /* <- keyword.control */ 395 /* ^^^^^ entity.name.type.using */ 396 397 using Alias 398 = NewLineFoo; 399 /*^ - entity.name */ 400 401 template <typename T> 402 using TemplateAlias = Foo<T>; 403 /* ^^^^^^^^^^^^^ entity.name.type.using */ 404 405 using std::cout; 406 /* <- keyword.control */ 407 /* ^ - entity.name */ 408 409 using std:: 410 cout; 411 /*^ - entity.name */ 412 413 class MyClass : public SuperClass 414 { 415 using This = MyClass; 416 /* ^ keyword.control */ 417 /* ^^^^ entity.name.type.using */ 418 419 using MyInt 420 /* ^ keyword.control */ 421 = int32_t; 422 423 using SuperClass::SuperClass; 424 /* ^ keyword.control */ 425 /* ^ - entity.name */ 426 }; 427 428 class MyClass : public CrtpClass<MyClass> 429 { 430 using typename CrtpClass<MyClass>::PointerType; 431 /* ^ keyword.control */ 432 /* ^ storage.modifier */ 433 using CrtpClass< 434 /* ^ keyword.control */ 435 MyClass>::method; 436 }; 437 438 typedef struct Books Book; 439 /* ^ - entity.name.type.struct */ 440 /* ^ entity.name.type.typedef */ 441 442 template class MyStack<int, 6>; 443 /* <- storage.type.template */ 444 /* ^ punctuation.section.generic */ 445 /* ^ storage.type */ 446 /* ^ constant.numeric */ 447 /* ^ punctuation.section.generic */ 448 449 template<class typeId, int N> class tupleTmpl; 450 /* <- storage.type.template */ 451 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template */ 452 /* ^ punctuation.section.generic.begin */ 453 /* ^ storage.type */ 454 /* ^ storage.type */ 455 /* ^ punctuation.section.generic.end */ 456 457 template<typename First = U<V>, typename... Rest> class tupleVariadic; 458 /* <- storage.type.template */ 459 /* ^ punctuation.section.generic.begin */ 460 /* ^ storage.type */ 461 /* ^ punctuation.section.generic.begin */ 462 /* ^ punctuation.section.generic.end */ 463 /* ^ punctuation.separator */ 464 /* ^^^ keyword.operator.variadic */ 465 /* ^ punctuation.section.generic.end */ 466 467 template<typename T...> void SomeClass<T...>::function(); 468 /* ^^^ keyword.operator.variadic */ 469 /* ^^^^^^^^ entity.name.function */ 470 471 template<typename Foo> inline struct Foo* baz() 472 /* ^^^^^^ storage.modifier */ 473 /* ^ - entity.name */ 474 /* ^^^ meta.function entity.name.function */ 475 {} 476 477 template<typename A, typename B> 478 void classname<A, B>::methodName() { 479 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 480 /* ^ punctuation.section.generic.begin */ 481 /* ^ punctuation.section.generic.end */ 482 /* ^^ punctuation.accessor */ 483 /* ^^^^^^^^^^ entity.name.function */ 484 } 485 486 template<typename C> 487 void funcName<C>() { 488 /* ^^^^^^^^^^^^^^^ meta.function */ 489 /* ^^^^^^^^ entity.name.function */ 490 /* ^ punctuation.section.generic.begin */ 491 /* ^ punctuation.section.generic.end */ 492 } 493 bool A::operator<(const A& a) { return false; } 494 /* ^ storage.type */ 495 /* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 496 /* ^^^^^^^^^ entity.name.function */ 497 /* ^ meta.function.parameters punctuation.section.group.begin */ 498 template <class T> bool A<T>::operator<(const A& a) { return false; } 499 /* ^ storage.type.template */ 500 /* ^ punctuation.section.generic.begin */ 501 /* ^ punctuation.section.generic.end */ 502 /* ^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 503 /* ^^^^^^^^^ entity.name.function */ 504 /* ^ meta.function.parameters meta.group punctuation.section.group.begin */ 505 template <typename Foo> 506 SomeType<OtherType> A<Foo>::foobar(YetAnotherType&& asRValue) {} 507 /* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 508 /* ^^^^^^ entity.name.function */ 509 template <typename Foo> SomeType<OtherType> A<Foo>::foobar(YetAnotherType&& asRValue) {} 510 /* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 511 /* ^^^^^^ entity.name.function */ 512 513 template <typename Foo> A<Foo>::A(YetAnotherType&& asRValue) {} 514 /* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 515 /* ^ entity.name.function */ 516 517 template <typename Foo> A<Foo>::A(YetAnotherType&& asRValue) {} 518 /* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 519 /* ^ entity.name.function.constructor */ 520 521 template <typename Foo> A<Foo>::~A(YetAnotherType&& asRValue) {} 522 /* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 523 /* ^ entity.name.function.destructor */ 524 525 template <class T> 526 bool A<T>::operator > (const A& other) { return false; } 527 /* ^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 528 /* ^^^^^^^^^^^^ entity.name.function */ 529 template <class T> 530 bool A<T>::operator == (const A& other) { return false; } 531 /* ^^^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 532 /* ^^^^^^^^^^^^^^ entity.name.function */ 533 534 typedef std :: vector<std::vector<int> > Table; 535 /* ^^ punctuation.accessor */ 536 /* ^ punctuation.section.generic.begin */ 537 /* ^ punctuation.section.generic.begin */ 538 /* ^ punctuation.section.generic.end */ 539 /* ^ punctuation.section.generic.end */ 540 541 template <typename T = float, int a = 3, bool b = true> 542 /* ^ meta.template keyword.operator */ 543 /* ^ meta.template keyword.operator */ 544 /* ^ meta.template constant.numeric */ 545 /* ^ meta.template keyword.operator */ 546 /* ^ meta.template constant.language */ 547 struct Foo 548 { 549 550 /* <- meta.struct - meta.template */ 551 552 void bar(int a = 3, bool b = true) {} 553 /* ^ - meta.template keyword.operator */ 554 /* ^ - meta.template constant.numeric */ 555 /* ^ - meta.template keyword.operator */ 556 /* ^ - meta.template constant.language */ 557 }; 558 559 /* <- - meta.block - meta.struct - meta.template */ 560 561 template <std::size_t Count = 128> 562 /* ^^ meta.template punctuation.accessor */ 563 /* ^ meta.template keyword.operator */ 564 /* ^ meta.template constant.numeric */ 565 class fixed_array : private std::array<int, Count> {}; 566 567 constexpr std::size_t f() { return 128; } 568 template <std::size_t Count = f()> 569 /* ^^ meta.template punctuation.accessor */ 570 /* ^ meta.template keyword.operator */ 571 /* ^ meta.template variable.function */ 572 /* ^^ meta.template meta.function-call punctuation */ 573 /* ^ meta.template punctuation */ 574 class fixed_array : private std::array<int, Count> {}; 575 576 template<class T> class A { /* ... */ }; 577 template<class T, class U = T> class B { /* ... */ }; 578 /* ^ meta.template keyword.operator */ 579 /* ^ meta.template */ 580 /* ^ meta.template punctuation */ 581 /* ^ - meta.template */ 582 template <class ...Types> class C { /* ... */ }; 583 584 // templates inside templates... it's templates all the way down 585 template<template<class> class P> class X { /* ... */ }; 586 /* ^ meta.template punctuation */ 587 /* ^ meta.template meta.template punctuation */ 588 /* ^^^^^ meta.template meta.template storage.type */ 589 /* ^ meta.template meta.template punctuation */ 590 /* ^^^^^ meta.template storage.type */ 591 /* ^ meta.template punctuation */ 592 593 X<A> xa; // OK 594 X<B> xb; // OK in C++14 after CWG 150 595 // Error earlier: not an exact match 596 X<C> xc; // OK in C++14 after CWG 150 597 598 // template declarations spanning multiple lines 599 template 600 /* <- meta.template storage.type */ 601 < 602 /* <- meta.template punctuation.section.generic.begin */ 603 class T, 604 class U = T 605 > 606 class B 607 { 608 /* ... */ 609 }; 610 611 // template declarations spanning multiple lines 612 template 613 < 614 /* <- meta.template punctuation.section.generic.begin */ 615 std::size_t Count = f() 616 /* ^^ meta.template punctuation.accessor */ 617 /* ^ meta.template keyword.operator */ 618 /* ^ meta.template variable.function */ 619 /* ^^ meta.template meta.function-call punctuation */ 620 > 621 /* <- meta.template punctuation.section.generic.end */ 622 class fixed_array : private std::array<int, Count> {}; 623 624 template <class T> 625 static bool decode(const Node& node, T& sequence) { 626 if (!node.IsSequence()) 627 return false; 628 sequence.clear(); 629 for (const auto& item : node) { 630 sequence.push_back(item.template as<typename T::value_type>()); 631 /* ^ punctuation.accessor */ 632 /* ^ storage.type - variable.other */ 633 /* ^ variable.function */ 634 /* ^ punctuation */ 635 /* ^^ punctuation.accessor */ 636 /* ^ punctuation */ 637 } 638 return true; 639 } 640 641 #include <functional> 642 template <class T> struct A {}; 643 template <class T> struct B {}; 644 struct C {}; 645 A<B<C>> f(std::function<A<B<C>>()> g) { 646 /* ^ punctuation.section.group.begin */ 647 /* ^^ punctuation.accessor */ 648 /* ^ punctuation.section.generic.begin */ 649 /* ^ punctuation.section.generic.begin */ 650 /* ^ punctuation.section.generic.begin */ 651 /* ^^ punctuation.section.generic.end */ 652 /* ^ punctuation.section.group.begin */ 653 /* ^ punctuation.section.group.end */ 654 /* ^ punctuation.section.generic.end */ 655 /* ^ variable.parameter */ 656 /* ^ punctuation.section.group.end */ 657 /* ^ punctuation.section.block.begin */ 658 return g(); 659 } 660 int main() { 661 std::function<C()> foo1; 662 /* ^ - variabe.function */ 663 std::function<B<C>()> foo2; 664 /* ^ - variable.function */ 665 auto f = [](std::function<A<B<C>>()> g) { return g(); }; 666 /* ^ punctuation.section.group.begin */ 667 /* ^^ punctuation.accessor */ 668 /* ^ punctuation.section.generic.begin */ 669 /* ^ punctuation.section.generic.begin */ 670 /* ^ punctuation.section.generic.begin */ 671 /* ^^ punctuation.section.generic.end */ 672 /* ^ punctuation.section.group.begin */ 673 /* ^ punctuation.section.group.end */ 674 /* ^ punctuation.section.generic.end */ 675 /* ^ punctuation.section.group.end */ 676 /* ^ punctuation.section.block.begin */ 677 /* ^ punctuation.section.block.end */ 678 return 0; 679 } 680 /* <- - invalid.illegal */ 681 682 // Example from section 14.2/4 of 683 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf 684 struct X 685 { 686 template <std::size_t> 687 X* alloc(); 688 689 template <std::size_t> 690 static X* adjust(); 691 }; 692 template <class T> 693 void f(T* p) 694 { 695 // Be optimistic: scope it as a template member function call anyway. 696 T* p1 = p->alloc<200>(); // ill-formed: < means less than 697 698 T* p2 = p->template alloc<200>(); // OK: < starts template argument list 699 /* ^ punctuation.accessor */ 700 /* ^ storage.type - variable.other */ 701 /* ^ variable.function */ 702 703 // Be optimistic: scope it as a template member function call anyway. 704 T::adjust<100>(); // ill-formed: < means less than 705 706 T::template adjust<100>(); // OK: < starts template argument list 707 /* <- - variable.function */ 708 /*^ punctuation.accessor */ 709 /* ^ storage.type - variable.other */ 710 /* ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ 711 /* ^ variable.function */ 712 } 713 714 struct X 715 { 716 void template(); // <-- not allowed to be a function! 717 /* ^ - entity.name.function */ 718 }; 719 720 void f() 721 { 722 X x; 723 x.template(); // <-- should not be scoped as variable.function! 724 /* ^ - variable.function */ 725 726 x /**/ . /**/ foo <5> /**/ () /**/ ; 727 /*^^^^ comment.block */ 728 /* ^ punctuation.accessor */ 729 /* ^^^ meta.method-call variable.function */ 730 /* ^ meta.method-call - variable.function */ 731 /* ^ meta.method-call punctuation.section.generic.begin */ 732 /* ^ meta.method-call punctuation.section.generic.end */ 733 /* ^ meta.method-call - punctuation - comment.block */ 734 /* ^^^^ meta.method-call comment.block */ 735 /* ^ meta.method-call - comment.block - punctuation */ 736 /* ^^ meta.method-call punctuation - comment.block */ 737 /* ^ - meta.method-call */ 738 }; 739 740 template<typename T> C<T> f(T t) 741 { 742 return C<T> { g<X<T>>(t) }; 743 /* ^ variable.function */ 744 /* ^ punctuation.section.group.begin */ 745 } 746 747 template<typename T> C<X<T>> f(T t) 748 { 749 return C<X<T>> { g<X<T>>(t) }; 750 /* ^ variable.function */ 751 /* ^ punctuation.section.group.begin */ 752 } 753 754 struct A { int foo; }; 755 int main() { 756 A a, b; 757 a.foo = a.foo < 0 ? 1 : 2; 758 /* ^ - punctuation.section.generic */ 759 a.operator<(b); 760 /*^^^^^^^^^^^^ meta.method-call */ 761 /*^^^^^^^^^ variable.function.member */ 762 /* ^^^ meta.group */ 763 a.operator>(b); 764 /*^^^^^^^^^^^^ meta.method-call */ 765 /*^^^^^^^^^ variable.function.member */ 766 /* ^^^ meta.group */ 767 a.operator<=(b); 768 /*^^^^^^^^^^^^^ meta.method-call */ 769 /*^^^^^^^^^^ variable.function.member */ 770 /* ^^^ meta.group */ 771 a.operator>=(b); 772 /*^^^^^^^^^^^^^ meta.method-call */ 773 /*^^^^^^^^^^ variable.function.member */ 774 /* ^^^ meta.group */ 775 a.operator==(b); 776 /*^^^^^^^^^^^^^ meta.method-call */ 777 /*^^^^^^^^^^ variable.function.member */ 778 /* ^^^ meta.group */ 779 a.operator!=(b); 780 /*^^^^^^^^^^^^^ meta.method-call */ 781 /*^^^^^^^^^^ variable.function.member */ 782 /* ^^^ meta.group */ 783 a.operator->(); 784 /*^^^^^^^^^^^^ meta.method-call */ 785 /*^^^^^^^^^^ variable.function.member */ 786 /* ^^ meta.group */ 787 } 788 /* <- - invalid.illegal */ 789 790 template <typename T> 791 struct A<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_type<T>::value>> { 792 using x = conditional_t<sizeof(T) <= sizeof(long), long, long long>; 793 /* ^^ keyword.operator */ 794 }; 795 /* <- - invalid.illegal */ 796 797 798 ///////////////////////////////////////////// 799 // Storage Modifiers 800 ///////////////////////////////////////////// 801 802 alignas(16) char array[256]; 803 /* <- storage.modifier */ 804 /* ^ punctuation.section.group.begin */ 805 /* ^ punctuation.section.group.end */ 806 807 const int XYZ = 2; 808 /* <- storage.modifier */ 809 810 constexpr int ABC = 3 + 5; 811 /* <- storage.modifier */ 812 813 thread_local int x; 814 /* <- storage.modifier */ 815 816 817 ///////////////////////////////////////////// 818 // Control Keywords 819 ///////////////////////////////////////////// 820 821 static_assert(x >= 0); 822 /* <- keyword.operator */ 823 824 noexcept(f()); 825 /* ^^^ meta.function-call */ 826 /* <- keyword.operator */ 827 828 if (x < 5) 829 /* <- keyword.control */ 830 {} 831 else 832 /* <- keyword.control */ 833 {} 834 835 switch (x) 836 /* <- keyword.control */ 837 { 838 case 1: 839 /* <- keyword.control */ 840 break; 841 /* <- keyword.control.flow.break */ 842 default: 843 /* <- keyword.control */ 844 break; 845 /* <- keyword.control.flow.break */ 846 } 847 848 do 849 /* <- keyword.control */ 850 { 851 if (y == 3) 852 continue; 853 /* <- keyword.control.flow.continue */ 854 } while (y < x); 855 /*^ keyword.control */ 856 857 switch (a) { 858 case 1: break; 859 /* ^ punctuation.separator */ 860 case 100 - 10: break; 861 /* ^ punctuation.separator */ 862 default: break; 863 /* ^ punctuation.separator */ 864 } 865 866 goto label; 867 /* <- keyword.control.flow.goto */ 868 869 try 870 /* <- keyword.control */ 871 { 872 throw std :: string("xyz"); 873 /* <- keyword.control.flow.throw */ 874 /* ^^^^^^ variable.function */ 875 /* ^^ punctuation.accessor */ 876 } 877 catch (...) 878 /* <- keyword.control */ 879 { 880 } 881 882 int* ptr = new int(2); 883 /* ^ keyword.control */ 884 885 delete ptr; 886 /* <- keyword.control */ 887 888 return 123; 889 /* <- keyword.control.flow.return */ 890 891 892 ///////////////////////////////////////////// 893 // Operator Keywords 894 ///////////////////////////////////////////// 895 896 int x = alignof(char); 897 /* ^ keyword.operator.word */ 898 /* ^ punctuation.section.group.begin */ 899 /* ^ punctuation.section.group.end */ 900 901 int x = sizeof(char); 902 /* ^ keyword.operator.word */ 903 /* ^ punctuation.section.group.begin */ 904 /* ^ punctuation.section.group.end */ 905 906 907 ///////////////////////////////////////////// 908 // Cast Keywords 909 ///////////////////////////////////////////// 910 911 const_cast<int>(2.0); 912 /* <- keyword.operator.word.cast */ 913 /* ^ punctuation.section.generic.begin */ 914 /* ^ storage.type */ 915 /* ^ punctuation.section.generic.end */ 916 917 dynamic_cast<int>(2.0); 918 /* <- keyword.operator.word.cast */ 919 920 reinterpret_cast<int>(2.0); 921 /* <- keyword.operator.word.cast */ 922 923 static_cast<int>(2.0); 924 /* <- keyword.operator.word.cast */ 925 926 auto var = *reinterpret_cast<std::vector<std::shared_ptr<AnyClass>>*>(v); 927 /* ^ keyword.operator.word.cast */ 928 /* ^ - variable.function */ 929 930 ///////////////////////////////////////////// 931 // Language Constants 932 ///////////////////////////////////////////// 933 934 bool t = true; 935 /* ^ constant.language */ 936 937 bool f = false; 938 /* ^ constant.language */ 939 940 int* p = nullptr; 941 /* ^ constant.language */ 942 943 char ch[] = __func__; 944 /* ^ constant.language */ 945 946 947 ///////////////////////////////////////////// 948 // Support Constants 949 ///////////////////////////////////////////// 950 951 std::cout << __FILE__ << '\n'; 952 /* ^ support.constant */ 953 /* ^^ punctuation.accessor */ 954 955 std :: cout << __FUNCTION__ << '\n'; 956 /* ^^ punctuation.accessor */ 957 /* ^ support.constant */ 958 959 std::cout << __LINE__ << '\n'; 960 /* ^ support.constant */ 961 962 963 ///////////////////////////////////////////// 964 // Numeric Constants 965 ///////////////////////////////////////////// 966 967 dec1 = 1234567890; 968 /* ^^^^^^^^^^ constant.numeric.integer.decimal */ 969 /* ^ punctuation.terminator - constant */ 970 971 dec2 = 1'924'013; 972 /* ^^^^^^^^^ constant.numeric.integer.decimal */ 973 /* ^ punctuation.terminator - constant */ 974 975 dec3 = 124ul; 976 /* ^^^^^ constant.numeric.integer.decimal */ 977 /* ^^ storage.type.numeric */ 978 /* ^ punctuation.terminator - constant */ 979 980 dec4 = 9'204lu; 981 /* ^^^^^^^ constant.numeric.integer.decimal */ 982 /* ^^ storage.type.numeric */ 983 /* ^ punctuation.terminator - constant */ 984 985 dec5 = 2'354'202'076LL; 986 /* ^^^^^^^^^^^^^^^ constant.numeric.integer.decimal */ 987 /* ^^ storage.type.numeric */ 988 /* ^ punctuation.terminator - constant */ 989 990 oct1 = 0123_567; 991 /* ^^^^^^^^ constant.numeric.integer.octal */ 992 /* ^ punctuation.definition.numeric.base */ 993 /* ^^^^ storage.type.numeric */ 994 /* ^ punctuation.terminator - constant */ 995 996 oct2 = 014'70; 997 /* ^^^^^^ constant.numeric.integer.octal */ 998 /* ^ punctuation.definition.numeric.base */ 999 /* ^ punctuation.terminator - constant */ 1000 1001 hex1 = 0x1234567890ABCDEF; 1002 /* ^^^^^^^^^^^^^^^^^^ constant.numeric.integer.hexadecimal */ 1003 /* ^^ punctuation.definition.numeric.base */ 1004 /* ^ punctuation.terminator - constant */ 1005 1006 hex2 = 0X1234567890ABCDEF; 1007 /* ^^^^^^^^^^^^^^^^^^ constant.numeric.integer.hexadecimal */ 1008 /* ^^ punctuation.definition.numeric.base */ 1009 /* ^ punctuation.terminator - constant */ 1010 1011 hex3 = 0x1234567890abcdef; 1012 /* ^^^^^^^^^^^^^^^^^^ constant.numeric.integer.hexadecimal */ 1013 /* ^^ punctuation.definition.numeric.base */ 1014 /* ^ punctuation.terminator - constant */ 1015 1016 hex4 = 0xA7'45'8C'38; 1017 /* ^^^^^^^^^^^^^ constant.numeric.integer.hexadecimal */ 1018 /* ^^ punctuation.definition.numeric.base */ 1019 /* ^ punctuation.terminator - constant */ 1020 1021 hex5 = 0x0+0xFL+0xaull+0xallu+0xfu+0xf'12_4_uz; 1022 /* ^^^ constant.numeric.integer.hexadecimal */ 1023 /* ^^ punctuation.definition.numeric.base */ 1024 /* ^^^^ constant.numeric.integer.hexadecimal */ 1025 /* ^^ punctuation.definition.numeric.base */ 1026 /* ^ storage.type.numeric */ 1027 /* ^^^^^^ constant.numeric.integer.hexadecimal */ 1028 /* ^^ punctuation.definition.numeric.base */ 1029 /* ^^^ storage.type.numeric */ 1030 /* ^^^^^^ constant.numeric.integer.hexadecimal */ 1031 /* ^^ punctuation.definition.numeric.base */ 1032 /* ^^^ storage.type.numeric */ 1033 /* ^^^^ constant.numeric.integer.hexadecimal */ 1034 /* ^^ punctuation.definition.numeric.base */ 1035 /* ^ storage.type.numeric */ 1036 /* ^^^^^^^^^^ constant.numeric.integer.hexadecimal */ 1037 /* ^^ punctuation.definition.numeric.base */ 1038 /* ^^^^^ storage.type.numeric */ 1039 /* ^ punctuation.terminator - constant */ 1040 1041 hex2 = 0xc1.01AbFp-1; 1042 /* ^^^^^^^^^^^^^ constant.numeric.float.hexadecimal */ 1043 /* ^^ punctuation.definition.numeric.base */ 1044 /* ^ punctuation.separator.decimal */ 1045 /* ^ punctuation.terminator - constant */ 1046 1047 bin1 = 0b010110; 1048 /* ^^^^^^^^ constant.numeric.integer.binary */ 1049 /* ^^ punctuation.definition.numeric.base */ 1050 /* ^ punctuation.terminator - constant */ 1051 1052 bin2 = 0B010010; 1053 /* ^^^^^^^^ constant.numeric.integer.binary */ 1054 /* ^^ punctuation.definition.numeric.base */ 1055 /* ^ punctuation.terminator - constant */ 1056 1057 bin3 = 0b1001'1101'0010'1100; 1058 /* ^^^^^^^^^^^^^^^^^^^^^ constant.numeric.integer.binary */ 1059 /* ^^ punctuation.definition.numeric.base */ 1060 /* ^ punctuation.terminator - constant */ 1061 1062 f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; 1063 /* ^^^ constant.numeric.float.decimal */ 1064 /* ^ punctuation.separator.decimal */ 1065 /* ^ keyword.operator.arithmetic */ 1066 /* ^^^^^ constant.numeric.float.decimal */ 1067 /* ^ punctuation.separator.decimal */ 1068 /* ^ keyword.operator.arithmetic */ 1069 /* ^^^^^^ constant.numeric.float.decimal */ 1070 /* ^ punctuation.separator.decimal */ 1071 /* ^ keyword.operator.arithmetic */ 1072 /* ^^^^ constant.numeric.float.decimal */ 1073 /* ^ punctuation.separator.decimal */ 1074 /* ^ storage.type.numeric */ 1075 /* ^ keyword.operator.arithmetic */ 1076 /* ^^^^^^ constant.numeric.float.decimal */ 1077 /* ^ punctuation.separator.decimal */ 1078 /* ^ storage.type.numeric */ 1079 /* ^ keyword.operator.arithmetic */ 1080 /* ^^^^^^^ constant.numeric.float.decimal */ 1081 /* ^ punctuation.separator.decimal */ 1082 /* ^ storage.type.numeric */ 1083 /* ^ keyword.operator.arithmetic */ 1084 /* ^^^^ constant.numeric.float.decimal */ 1085 /* ^ punctuation.separator.decimal */ 1086 /* ^ storage.type.numeric */ 1087 /* ^ keyword.operator.arithmetic */ 1088 /* ^^^^^^ constant.numeric.float.decimal */ 1089 /* ^ punctuation.separator.decimal */ 1090 /* ^ storage.type.numeric */ 1091 /* ^ keyword.operator.arithmetic */ 1092 /* ^^^^^^^ constant.numeric.float.decimal */ 1093 /* ^ punctuation.separator.decimal */ 1094 /* ^ storage.type.numeric */ 1095 /* ^ punctuation.terminator - constant */ 1096 1097 f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; 1098 /* ^^^^ constant.numeric.float.decimal */ 1099 /* ^ punctuation.separator.decimal */ 1100 /* ^ keyword.operator.arithmetic */ 1101 /* ^^^^^ constant.numeric.float.decimal */ 1102 /* ^ punctuation.separator.decimal */ 1103 /* ^ keyword.operator.arithmetic */ 1104 /* ^^^^^ constant.numeric.float.decimal */ 1105 /* ^ punctuation.separator.decimal */ 1106 /* ^ storage.type.numeric */ 1107 /* ^ keyword.operator.arithmetic */ 1108 /* ^^^^^^ constant.numeric.float.decimal */ 1109 /* ^ punctuation.separator.decimal */ 1110 /* ^ storage.type.numeric */ 1111 /* ^ keyword.operator.arithmetic */ 1112 /* ^^^^^ constant.numeric.float.decimal */ 1113 /* ^ punctuation.separator.decimal */ 1114 /* ^ storage.type.numeric */ 1115 /* ^ keyword.operator.arithmetic */ 1116 /* ^^^^^^ constant.numeric.float.decimal */ 1117 /* ^ punctuation.separator.decimal */ 1118 /* ^ storage.type.numeric */ 1119 /* ^ punctuation.terminator - constant */ 1120 1121 f = 1.+1.f+1.L+1..; 1122 /* ^^ constant.numeric.float.decimal */ 1123 /* ^ punctuation.separator.decimal */ 1124 /* ^ keyword.operator.arithmetic */ 1125 /* ^^^ constant.numeric.float.decimal */ 1126 /* ^ punctuation.separator.decimal */ 1127 /* ^ storage.type.numeric */ 1128 /* ^ keyword.operator.arithmetic */ 1129 /* ^^^ constant.numeric.float.decimal */ 1130 /* ^ punctuation.separator.decimal */ 1131 /* ^ storage.type.numeric */ 1132 /* ^ keyword.operator.arithmetic */ 1133 /* ^ constant.numeric.integer.decimal */ 1134 /* ^^ invalid.illegal.syntax */ 1135 /* ^ punctuation.terminator - constant */ 1136 1137 f = 1e1+1e1f+1e1L; 1138 /* ^^^ constant.numeric.float.decimal */ 1139 /* ^ keyword.operator.arithmetic */ 1140 /* ^^^^ constant.numeric.float.decimal */ 1141 /* ^ storage.type.numeric */ 1142 /* ^ keyword.operator.arithmetic */ 1143 /* ^^^^ constant.numeric.float.decimal */ 1144 /* ^ storage.type.numeric */ 1145 /* ^ punctuation.terminator - constant */ 1146 1147 f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; 1148 /* ^^ constant.numeric.float.decimal */ 1149 /* ^ punctuation.separator.decimal */ 1150 /* ^ keyword.operator.arithmetic */ 1151 /* ^^^^ constant.numeric.float.decimal */ 1152 /* ^ punctuation.separator.decimal */ 1153 /* ^ keyword.operator.arithmetic */ 1154 /* ^^^^^ constant.numeric.float.decimal */ 1155 /* ^ punctuation.separator.decimal */ 1156 /* ^ keyword.operator.arithmetic */ 1157 /* ^^^ constant.numeric.float.decimal */ 1158 /* ^ punctuation.separator.decimal */ 1159 /* ^ storage.type.numeric */ 1160 /* ^ keyword.operator.arithmetic */ 1161 /* ^^^^^ constant.numeric.float.decimal */ 1162 /* ^ punctuation.separator.decimal */ 1163 /* ^ storage.type.numeric */ 1164 /* ^ keyword.operator.arithmetic */ 1165 /* ^^^^^^ constant.numeric.float.decimal */ 1166 /* ^ punctuation.separator.decimal */ 1167 /* ^ storage.type.numeric */ 1168 /* ^^^ constant.numeric.float.decimal */ 1169 /* ^ punctuation.separator.decimal */ 1170 /* ^ storage.type.numeric */ 1171 /* ^ keyword.operator.arithmetic */ 1172 /* ^^^^^ constant.numeric.float.decimal */ 1173 /* ^ punctuation.separator.decimal */ 1174 /* ^ storage.type.numeric */ 1175 /* ^ keyword.operator.arithmetic */ 1176 /* ^^^^^^ constant.numeric.float.decimal */ 1177 /* ^ punctuation.separator.decimal */ 1178 /* ^ storage.type.numeric */ 1179 /* ^ punctuation.terminator - constant */ 1180 1181 f = 1'843'290.245'123; 1182 /* ^^^^^^^^^^^^^^^^^ constant.numeric.float.decimal */ 1183 /* ^ punctuation.separator.decimal */ 1184 /* ^ punctuation.terminator - constant */ 1185 1186 f = 2'837e1'000; 1187 /* ^^^^^^^^^^^ constant.numeric.float.decimal */ 1188 /* ^ punctuation.terminator - constant */ 1189 1190 f = 23e-1'000; 1191 /* ^^^^^^^^^ constant.numeric.float.decimal */ 1192 /* ^ punctuation.terminator - constant */ 1193 1194 units1 = 134h + 123.45h; 1195 /* ^^^^ constant.numeric.integer.decimal */ 1196 /* ^ storage.type.numeric */ 1197 /* ^^^ - constant */ 1198 /* ^^^^^^^ constant.numeric.float.decimal */ 1199 /* ^ punctuation.separator.decimal */ 1200 /* ^ storage.type.numeric */ 1201 /* ^ punctuation.terminator - constant */ 1202 1203 units2 = 147min + 147.min; 1204 /* ^^^^^^ constant.numeric.integer.decimal */ 1205 /* ^^^ storage.type.numeric */ 1206 /* ^^^ - constant */ 1207 /* ^^^^^^^ constant.numeric.float.decimal */ 1208 /* ^ punctuation.separator.decimal */ 1209 /* ^^^ storage.type.numeric */ 1210 /* ^ punctuation.terminator - constant */ 1211 1212 units3 = 357s + 34.7s; 1213 /* ^^^^ constant.numeric.integer.decimal */ 1214 /* ^ storage.type.numeric */ 1215 /* ^^^ - constant */ 1216 /* ^^^^^ constant.numeric.float.decimal */ 1217 /* ^ punctuation.separator.decimal */ 1218 /* ^ storage.type.numeric */ 1219 /* ^ punctuation.terminator - constant */ 1220 1221 units4 = 234_custom + 10e-1_custom; 1222 /* ^^^^^^^^^^ constant.numeric.integer.decimal */ 1223 /* ^^^^^^^ storage.type.numeric */ 1224 /* ^^^ - constant */ 1225 /* ^^^^^^^^^^^^ constant.numeric.float.decimal */ 1226 /* ^^^^^^^ storage.type.numeric */ 1227 /* ^ punctuation.terminator - constant */ 1228 1229 ///////////////////////////////////////////// 1230 // Functions 1231 ///////////////////////////////////////////// 1232 1233 // function prototype 1234 void abcdWXYZ1234(); 1235 /* ^^^^^^^^^^^^^^ meta.function */ 1236 /* ^ entity.name.function */ 1237 /* ^^ meta.function.parameters meta.group */ 1238 /* ^ punctuation.section.group.begin */ 1239 /* ^ punctuation.section.group.end */ 1240 1241 // function definition 1242 void abcdWXYZ1234() 1243 /* ^^^^^^^^^^^^^^ meta.function */ 1244 /* ^ entity.name.function */ 1245 /* ^^ meta.function.parameters meta.group */ 1246 /* ^ punctuation.section.group.begin */ 1247 /* ^ punctuation.section.group.end */ 1248 { 1249 /* <- meta.function meta.block punctuation.section.block.begin */ 1250 } 1251 /* <- meta.function meta.block punctuation.section.block.end */ 1252 1253 struct foo **alloc_foo(); 1254 /* ^^^^^^^^^^^ meta.function */ 1255 /* ^^ meta.function.parameters meta.group */ 1256 /* ^ punctuation.section.group.begin */ 1257 /* ^ punctuation.section.group.end */ 1258 /* ^ storage.type */ 1259 /* ^ - entity.name.struct */ 1260 /* ^^ keyword.operator */ 1261 /* ^ entity.name.function */ 1262 1263 long func 1264 /* ^^^^ meta.function entity.name.function */ 1265 (int x, void *MYMACRO(y) ) { 1266 /*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1267 /*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ 1268 /* <- meta.function.parameters meta.group punctuation.section.group.begin */ 1269 /* ^ variable.parameter */ 1270 /* ^ -entity.name.function */ 1271 /* ^^^^^^^^^^ meta.function-call */ 1272 /* ^^^ meta.group meta.function-call meta.group */ 1273 /* ^ punctuation.section.group.begin */ 1274 /* ^ punctuation.section.group.end */ 1275 /* ^ punctuation.section.group.end */ 1276 // Ensure < and > aren't parsed as a generic 1277 if (foo < bar && baz > bar ) { 1278 /* ^ keyword.operator.comparison */ 1279 /* ^ keyword.operator.comparison */ 1280 1281 label: 1282 /* ^ entity.name.label */ 1283 /* ^ punctuation.separator */ 1284 do { 1285 break; 1286 } while(true); 1287 1288 } 1289 if (version.major == 10 && version.minor < 11) 1290 /* ^ keyword.operator.comparison */ 1291 { 1292 1293 } 1294 } 1295 /* <- meta.function meta.block punctuation.section.block.end */ 1296 1297 MACRO1 1298 RETURN_TYPE 1299 /* <- - entity.name.function */ 1300 func_name() { 1301 /* < entity.name.function */ 1302 } 1303 1304 MACRO1 void * MACRO2 myfuncname () { 1305 /* ^ storage.type */ 1306 /* ^ keyword.operator */ 1307 /* ^ entity.name.function */ 1308 1309 struct Args { 1310 /* ^ storage.type */ 1311 /* ^ entity.name.struct */ 1312 void* hello; 1313 void* foobar; 1314 Args() 1315 /* ^ entity.name.function.constructor */ 1316 : hellp(nullptr), 1317 /* ^ punctuation.separator.initializer-list */ 1318 foobar(nullptr) 1319 { 1320 } 1321 }; 1322 1323 struct Args args2; 1324 /* ^ storage.type */ 1325 /* ^ - entity */ 1326 1327 class LocalFoo MYMACRO 1328 /* ^ storage.type */ 1329 /* ^ entity.name.class */ 1330 /* ^ - entity */ 1331 { 1332 LocalFoo() {} 1333 /* ^ entity.name.function.constructor */ 1334 } 1335 1336 class LocalFoo test; 1337 /* ^ storage.type */ 1338 /* ^ - entity */ 1339 1340 } 1341 1342 static const uint32_t * const MACRO funcname(); 1343 /* ^ storage.modifier */ 1344 /* ^ storage.modifier */ 1345 /* ^ support.type */ 1346 /* ^ keyword.operator */ 1347 /* ^ storage.modifier */ 1348 /* ^ entity.name.function */ 1349 1350 void FooBar :: baz(int a) 1351 /* ^^^^^^^^^^^^^^^^^^^^ meta.function */ 1352 /* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1353 /* ^^^ entity.name.function */ 1354 /* ^^ punctuation.accessor */ 1355 /* ^^^^^^^ meta.function.parameters meta.group */ 1356 /* ^ punctuation.section.group.begin */ 1357 /* ^ variable.parameter */ 1358 /* ^ punctuation.section.group.end */ 1359 { 1360 } 1361 /* A comment. */ void FooBar :: baz(int a) 1362 /* ^^^^^^^^^^^^^^^^^^^^ meta.function */ 1363 /* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1364 /* ^^^ entity.name.function */ 1365 /* ^^ punctuation.accessor */ 1366 /* ^^^^^^^ meta.function.parameters meta.group */ 1367 /* ^ punctuation.section.group.begin */ 1368 /* ^ variable.parameter */ 1369 /* ^ punctuation.section.group.end */ 1370 { 1371 } 1372 // prevent leading comment from function recognition 1373 /**/ HRESULT A::b() 1374 /* ^ meta.function */ 1375 /* ^ entity.name.function */ 1376 { 1377 return S_OK; 1378 } 1379 FooBar::FooBar(int a) 1380 /*^^^^^^^^^^^^^^^^^^^ meta.function */ 1381 /*^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1382 /* ^^^^^^ entity.name.function */ 1383 /* ^^^^^^^ meta.function.parameters meta.group */ 1384 /* ^ punctuation.section.group.begin */ 1385 /* ^^^ storage.type */ 1386 /* ^ punctuation.section.group.end */ 1387 { 1388 } 1389 1390 FooBar :: FooBar(int a) & = 1391 /*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1392 /*^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1393 /* ^^^^^^ entity.name.function */ 1394 /* ^^^^^^^ meta.function.parameters meta.group */ 1395 /* ^ punctuation.section.group.begin */ 1396 /* ^^^ storage.type */ 1397 /* ^ variable.parameter */ 1398 /* ^ punctuation.section.group.end */ 1399 /* ^ keyword.operator */ 1400 /* ^ keyword.operator.assignment */ 1401 default; 1402 /*^^^^^ meta.function storage.modifier */ 1403 1404 FooBar::~FooBar 1405 /*^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ 1406 /* ^^^^^^^ entity.name.function */ 1407 () { } 1408 /* <- meta.function.parameters meta.group punctuation.section.group.begin */ 1409 /* <- meta.function.parameters meta.group punctuation.section.group.end */ 1410 /*^^^^ meta.function */ 1411 1412 ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath:: 1413 ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath() 1414 /* <- meta.function meta.toc-list.full-identifier */ 1415 : var_name(nullptr) { 1416 } 1417 1418 bool FooBar::operator==() {} 1419 /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1420 /* ^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1421 /* ^^^^^^^^^^ entity.name.function */ 1422 /* ^^ meta.function.parameters meta.group */ 1423 /* ^ punctuation.section.group.begin */ 1424 /* ^ punctuation.section.group.end */ 1425 /* ^^ meta.block */ 1426 /* ^ punctuation.section.block.begin */ 1427 /* ^ punctuation.section.block.end */ 1428 1429 1430 myns::FooBar::~FooBar() { } 1431 /*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1432 /*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1433 /* ^^ meta.function.parameters meta.group */ 1434 /* ^ punctuation.section.group.begin */ 1435 /* ^ punctuation.section.group.end */ 1436 /* ^^^ meta.block */ 1437 /* ^ punctuation.section.block.begin */ 1438 /* ^ punctuation.section.block.end */ 1439 /*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ 1440 /* ^^^^^^^ entity.name.function */ 1441 1442 extern "C" void test_in_extern_c_block() 1443 /* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1444 /* ^^ meta.function.parameters meta.group */ 1445 /* ^ punctuation.section.group.begin */ 1446 /* ^ punctuation.section.group.end */ 1447 /* ^ entity.name.function */ 1448 { 1449 /* <- meta.function meta.block punctuation.section.block.begin */ 1450 } 1451 /* <- meta.function meta.block punctuation.section.block.end */ 1452 1453 #ifdef __cplusplus 1454 extern "C" { 1455 #endif 1456 1457 #if 0 1458 void test_in_extern_c_block() 1459 /* ^ comment.block */ 1460 { 1461 } 1462 #else 1463 1464 /* temporary C++ preprocessor block */ 1465 #ifdef __cplusplus 1466 /* <- meta.preprocessor */ 1467 /* <- keyword.control.import */ 1468 # ifndef _Bool 1469 /* <- meta.preprocessor */ 1470 /* <- keyword.control.import */ 1471 typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ 1472 /* ^ storage.type */ 1473 /* ^ entity.name.type.typedef */ 1474 # endif 1475 /* <- meta.preprocessor */ 1476 /* <- keyword.control.import */ 1477 #endif 1478 /* <- meta.preprocessor */ 1479 /* <- keyword.control.import */ 1480 1481 void test_in_extern_c_block() 1482 /* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1483 /* ^^ meta.function.parameters meta.group */ 1484 /* ^ punctuation.section.group.begin */ 1485 /* ^ punctuation.section.group.end */ 1486 /* ^ entity.name.function */ 1487 { 1488 /* <- meta.function meta.block punctuation.section.block.begin */ 1489 } 1490 /* <- meta.function meta.block punctuation.section.block.end */ 1491 #endif 1492 1493 #ifdef __cplusplus 1494 } 1495 #endif 1496 /* ^ - meta.extern-c */ 1497 1498 gener<int> func_returning_generic(int a); 1499 /* ^ entity.name.function */ 1500 1501 std::vector<std::uint8_t> func_returning_path_generic(int a); 1502 /* ^ punctuation.section.generic */ 1503 /* ^ entity.name.function */ 1504 1505 void f() 1506 { 1507 static_assert(false, "oops"); 1508 /* ^ keyword.operator.word */ 1509 } 1510 1511 long double operator "" _km (long double x); 1512 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 1513 /* ^^^^^^^^^^^^^^^ meta.function.parameters */ 1514 /* ^^^^^^^^^^^^^^^ entity.name.function */ 1515 1516 ///////////////////////////////////////////// 1517 // Namespace 1518 ///////////////////////////////////////////// 1519 1520 namespace myNameSpace {} 1521 /* <- keyword.control */ 1522 /* ^ entity.name.namespace */ 1523 1524 namespace new_name = current_name; 1525 /* <- keyword.control */ 1526 1527 using namespace NAME __attribute__((visibility ("hidden"))); 1528 /* <- keyword.control */ 1529 /* ^ keyword.control */ 1530 /* ^ storage.modifier */ 1531 /* ^ string */ 1532 1533 void func() { 1534 using namespace NAME __attribute__((visibility ("hidden"))); 1535 /* ^ keyword.control */ 1536 /* ^ keyword.control */ 1537 /* ^ storage.modifier */ 1538 /* ^ string */ 1539 } 1540 1541 using namespace 1542 /* <- keyword.control */ 1543 /* ^ keyword.control */ 1544 1545 using namespace myNameSpace; 1546 /* <- keyword.control */ 1547 /* ^ keyword.control */ 1548 1549 namespace ns :: abc /* Neither this comment... */ 1550 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace */ 1551 /* ^^^^^^^^^ entity.name.namespace */ 1552 /* ^^ punctuation.accessor */ 1553 /* ^ comment.block */ 1554 // ...nor this comment is highlighted 1555 /* <- comment.line */ 1556 { 1557 /* <- meta.namespace meta.block punctuation.section.block.begin */ 1558 void nsfunc() { 1559 /* ^ entity.name.function */ 1560 } 1561 } 1562 /* <- meta.namespace meta.block punctuation.section.block.end */ 1563 1564 namespace tl { 1565 /*^^^^^^^^^^^^ meta.namespace */ 1566 /* ^ keyword.control */ 1567 namespace { 1568 /* ^ keyword.control */ 1569 /* ^^^^^^^^^^^ meta.namespace meta.namespace */ 1570 /* ^ meta.block meta.block punctuation.section.block.begin */ 1571 void nested_func(){} 1572 /* ^ entity.name.function */ 1573 } 1574 } 1575 1576 MACRONAME namespace ns3 {} 1577 /* ^ keyword.control */ 1578 1579 extern "C++" 1580 // ^ storage.modifier 1581 // ^^^^^ string.quoted.double 1582 { 1583 namespace std _GLIBCXX_VISIBILITY(default) 1584 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace 1585 // ^ keyword.control 1586 // ^ entity.name.namespace 1587 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call 1588 // ^^^^^^^^^ meta.group 1589 // ^ keyword.control 1590 {} 1591 } 1592 1593 #define MY_NAMESPACE_BEGIN namespace greatapp { 1594 #define MY_NAMESPACE_END } 1595 MY_NAMESPACE_BEGIN 1596 class X { 1597 private: 1598 /* <- storage.modifier */ 1599 int a; 1600 protected: 1601 /* <- storage.modifier */ 1602 int b; 1603 public: 1604 /* <- storage.modifier */ 1605 int c; 1606 }; 1607 MY_NAMESPACE_END 1608 1609 MY_NAMESPACE_BEGIN int foo(); MY_NAMESPACE_END 1610 /* ^ storage.type */ 1611 /* ^ meta.function entity.name.function */ 1612 /* ^^^ punctuation */ 1613 1614 // Uncomment this some day 1615 // MY_NAMESPACE_BEGIN class X : public std::true_type {}; MY_NAMESPACE_END 1616 1617 ///////////////////////////////////////////// 1618 // Classes, structs, unions and enums 1619 ///////////////////////////////////////////// 1620 1621 class BaseClass; 1622 /*^^^^^^^^^^^^^ meta.class */ 1623 /* ^ - meta.class meta.class */ 1624 /* ^^^^^^^^^ entity.name.class.forward-decl */ 1625 1626 class BaseClass // comment 1627 /* <- storage.type */ 1628 /* ^ entity.name.class */ 1629 { 1630 public : 1631 /* <- storage.modifier */ 1632 tupleTmpl<int,2> max(tupleGen<int,2> a, tupleGen<int,2> b); 1633 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ 1634 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.parameters meta.group */ 1635 /* ^ punctuation.section.group.begin */ 1636 /* ^ variable.parameter */ 1637 /* ^ punctuation.separator */ 1638 /* ^ variable.parameter */ 1639 /* ^ punctuation.section.group.end */ 1640 /* ^ punctuation.section.generic.begin */ 1641 /* ^ storage.type */ 1642 /* ^ punctuation.section.generic.end */ 1643 /* ^ punctuation.section.generic.begin */ 1644 /* ^ storage.type */ 1645 /* ^ punctuation.section.generic.end */ 1646 protected: 1647 /* <- storage.modifier */ 1648 private: 1649 /* <- storage.modifier */ 1650 1651 static int a = 1 << 4; 1652 /* <- storage.modifier */ 1653 /* ^^ keyword.operator.arithmetic */ 1654 1655 static int x; 1656 /* <- storage.modifier */ 1657 1658 virtual void doSomething() const = 0; 1659 /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ 1660 /* ^ - meta.method meta.method */ 1661 /* ^^ meta.method.parameters meta.group */ 1662 /* ^ punctuation.section.group.begin */ 1663 /* ^ punctuation.section.group.end */ 1664 /* <- storage.modifier */ 1665 /* ^ entity.name.function */ 1666 /* ^ storage.modifier */ 1667 /* ^ constant.numeric */ 1668 1669 template<typename A> 1670 void func(){} 1671 /* ^^^^^^^^ meta.method */ 1672 /* ^^ meta.method.parameters meta.group */ 1673 /* ^ punctuation.section.group.begin */ 1674 /* ^ punctuation.section.group.end */ 1675 /* ^^ meta.block */ 1676 /* ^ punctuation.section.block.begin */ 1677 /* ^ punctuation.section.block.end */ 1678 /* ^^^^ entity.name.function */ 1679 1680 template<typename A> 1681 void func<A>(){} 1682 /* ^^^^^^^^^^^ meta.method */ 1683 /* ^^^^ entity.name.function */ 1684 /* ^ punctuation.section.generic.begin */ 1685 /* ^ punctuation.section.generic.end */ 1686 /* ^^ meta.method.parameters meta.group */ 1687 /* ^ punctuation.section.group.begin */ 1688 /* ^ punctuation.section.group.end */ 1689 /* ^^ meta.block */ 1690 /* ^ punctuation.section.block.begin */ 1691 /* ^ punctuation.section.block.end */ 1692 1693 template<typename A> 1694 BaseClass(){} 1695 /* ^^^^^^^^^^^^^ meta.method */ 1696 /* ^^^^^^^^^ meta.method.constructor */ 1697 /* ^^^^^^^^^ entity.name.function */ 1698 1699 ~BaseClass() {} 1700 /* ^^^^^^^^^^^^^^^ meta.method */ 1701 /* ^^^^^^^^^^ meta.method.destructor */ 1702 /* ^^^^^^^^^^ entity.name.function */ 1703 1704 BaseClass operator [] () 1705 /* ^^^^^^^^^^^^^^ meta.method */ 1706 /* ^^ meta.method.parameters */ 1707 /* ^^^^^^^^^^^ entity.name.function */ 1708 {} 1709 1710 BaseClass operator= 1711 /* ^^^^^^^^^ meta.method */ 1712 /* ^^^^^^^^^ entity.name.function */ 1713 () {} 1714 /* ^^^^^ meta.method */ 1715 /* ^^ meta.method.parameters */ 1716 /* ^^ meta.block */ 1717 }; 1718 1719 class DerivedClass : public ::BaseClass // Comment 1720 /* ^ entity.other.inherited-class */ 1721 /* ^ comment.line */ 1722 { 1723 ~DerivedClass() override; 1724 /* <- meta.method.destructor */ 1725 /*^^^^^^^^^^^^^^^^^^^^^^ meta.method */ 1726 /*^^^^^^^^^^^ meta.method.destructor */ 1727 /* ^ storage.modifier */ 1728 virtual void doSomething() const override final; 1729 /* ^ storage.modifier */ 1730 /* ^ storage.modifier */ 1731 /* ^ storage.modifier */ 1732 protected: 1733 /*^^^^^^^^ storage.modifier */ 1734 DerivedClass() override 1735 /*^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ 1736 /*^^^^^^^^^^^^ meta.method.constructor */ 1737 /* ^ storage.modifier */ 1738 : a(a), 1739 /* ^^^^^^^ meta.method.constructor.initializer-list */ 1740 base_id_(BaseClass::None().ToInt()), 1741 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ 1742 /* ^ variable.other.readwrite.member */ 1743 /* ^ punctuation.accessor */ 1744 /* ^^^^^^^^^^^^^^^^^ meta.function-call */ 1745 /* ^^^^ variable.function */ 1746 /* ^ punctuation - meta.method-call */ 1747 /* ^^^^^^^ meta.method-call */ 1748 /* ^^^^^ variable.function */ 1749 /* ^ punctuation.separator */ 1750 bounds_(NULL), 1751 /* ^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ 1752 bit_field_(0) { 1753 /* ^^^^^^^^^^^^^^^ meta.method */ 1754 /* ^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ 1755 char * a = "sprintf"; 1756 char * b = sprintf("Testing %s", a); 1757 /* ^^^^^^^^^ meta.function-call */ 1758 /* ^^^^^^^ support.function.C99 */ 1759 1760 base_id_->foobar(1, "foo"); 1761 /* ^^ punctuation.accessor - meta.method-call */ 1762 /* ^^^^^^^^^^^^^^^^ meta.method-call */ 1763 /* ^^^^^^ variable.function */ 1764 1765 base_id_->~BaseClass(); 1766 /* ^^ punctuation.accessor - meta.method-call */ 1767 /* ^^^^^^^^^^^^ meta.method-call */ 1768 /* ^^^^^^^^^^ variable.function */ 1769 } 1770 /* ^ meta.method meta.block punctuation.section.block.end */ 1771 1772 /* <- - meta.class.constructor.initializer-list */ 1773 1774 typedef std::vector<int> qux; 1775 /* ^^^ entity.name.type.typedef */ 1776 }; 1777 1778 1779 template<typename A> 1780 class class1<A> : class2<A> 1781 /* ^^^^^^ entity.name.class */ 1782 /* ^ punctuation.section.generic */ 1783 /* ^ punctuation.section.generic */ 1784 /* ^^^^^^ entity.other.inherited-class */ 1785 /* ^ punctuation.section.generic */ 1786 /* ^ punctuation.section.generic */ 1787 {} 1788 1789 class FooBar { 1790 /* ^ meta.class meta.block punctuation.section.block.begin */ 1791 explicit FooBar(int a); 1792 /* ^^^^^^^^^^^^^ meta.method */ 1793 /* ^^^^^^^^ storage.modifier */ 1794 /* ^^^^^^ entity.name.function */ 1795 FooBar() =default; 1796 /* ^^^^^^ entity.name.function */ 1797 /* ^ keyword.operator.assignment */ 1798 /* ^^^^^^^ storage.modifier */ 1799 FooBar(void) =default; 1800 /* ^^^^^^ entity.name.function */ 1801 /* ^^^^ storage.type */ 1802 /* ^ keyword.operator.assignment */ 1803 /* ^^^^^^^ storage.modifier */ 1804 1805 // If a constructor name is on a line without the opening (, it is not 1806 // highlighted as a method/constructor. This prevents a bunch of false 1807 // positives, including data types as they are being typed into a struct. 1808 FooBar 1809 /* ^ - entity.name.function */ 1810 (); 1811 1812 virtual ~FooBar(); 1813 /* ^^^^^^^ entity.name.function */ 1814 1815 #ifndef DEBUG 1816 ~FooBar(); 1817 /* ^^^^^^^ entity.name.function */ 1818 #endif 1819 1820 void insert () {} 1821 /* ^^^^^^ entity.name.function */ 1822 1823 explicit operator bool 1824 /* ^^^^ entity.name.function */ 1825 () {} 1826 1827 FooBar::~FooBar(); 1828 /* ^^^^^^^^^^^^^^^ entity.name.function */ 1829 1830 void FooBar:: 1831 Baz() { 1832 /* <- entity.name.function */ 1833 } 1834 1835 auto f(int a) -> decltype(a.begin()) override final; 1836 /* ^^ punctuation.separator */ 1837 /* ^ punctuation.accessor */ 1838 /* ^^^^^ variable.function */ 1839 /* ^ storage.modifier */ 1840 /* ^ storage.modifier */ 1841 1842 auto g() -> std::vector<int> override final { 1843 /* ^^ punctuation.separator */ 1844 /* ^^ punctuation.accessor */ 1845 /* ^ storage.type */ 1846 /* ^ storage.modifier */ 1847 /* ^ storage.modifier */ 1848 this->g(1); 1849 /* ^ variable.language */ 1850 } 1851 1852 private: 1853 /*^^^^^ storage.modifier */ 1854 1855 VISIBILITY_MACRO 1856 /* ^ - entity.name.function */ 1857 myns::subns::MyDataType 1858 /* ^ - entity.name.function */ 1859 and_now_method_name(); 1860 /* ^ entity.name.function */ 1861 1862 VISIBILITY_MACRO 1863 /* ^ - entity.name.function */ 1864 std::shared_future<std::vector<myns::mysubns::MyDataType>> 1865 /* ^ - entity.name.function */ 1866 /* ^^ punctuation.accessor */ 1867 /* ^ punctuation.section.generic.begin */ 1868 /* ^^ punctuation.accessor */ 1869 /* ^ punctuation.section.generic.begin */ 1870 /* ^^ punctuation.accessor */ 1871 and_now_method_name2(); 1872 /* ^ entity.name.function */ 1873 1874 enum 1875 /* ^^^^ meta.enum storage.type */ 1876 { 1877 /* ^ meta.enum punctuation.section.block.begin */ 1878 A = 1, 1879 B = 20 / 5 1880 } 1881 /* ^ meta.enum punctuation.section.block.end */ 1882 /* ^ - meta.enum */ 1883 1884 friend int func(int a, int b); 1885 /* ^ storage.modifier */ 1886 /* ^ storage.type */ 1887 /* ^ - entity.name.function */ 1888 /* ^ - meta.function-call */ 1889 1890 friend int func(int a, int b) { 1891 /* ^ storage.modifier */ 1892 /* ^ storage.type */ 1893 /* ^ entity.name.function */ 1894 /* ^ - meta.function-call */ 1895 /* ^ meta.class meta.block meta.method meta.block punctuation.section.block.begin */ 1896 int a = 1; 1897 } 1898 /* ^ meta.class meta.block meta.block punctuation.section.block.end */ 1899 /* ^ - meta.class meta.block meta.block */ 1900 1901 friend class ::FooBar; 1902 /* ^ storage.modifier */ 1903 /* ^ storage.type 1904 /* ^^ punctuation.accessor */ 1905 /* ^ - entity */ 1906 1907 friend bool operator != (const X& lhs, const X& rhs) { 1908 /* ^^^^^^^^^^^ entity.name.function */ 1909 int a = 1; 1910 } 1911 /* ^ meta.class meta.block meta.block punctuation.section.block.end */ 1912 /* ^ - meta.class meta.block meta.block */ 1913 1914 #if 0 1915 /* ^ constant.numeric */ 1916 int disabled_func() { 1917 /* ^ comment.block */ 1918 } 1919 #endif 1920 1921 #if 1 1922 /* ^ constant.numeric */ 1923 int enabled_func() {} 1924 /* ^ entity.name.function */ 1925 #else 1926 int disabled_func() { 1927 /* ^ comment.block */ 1928 } 1929 #endif 1930 1931 MACRO_NOT_CONSTRUCTOR(FooBar); 1932 /* ^ meta.function-call variable.function - entity.name.function */ 1933 1934 MACRO_NOT_CONSTRUCTOR2(FooBar, 1935 /* ^ meta.function-call variable.function - entity.name.function */ 1936 FriendClass); 1937 } 1938 /* <- meta.class meta.block punctuation.section.block.end */ 1939 /* <- - meta.class meta.block */ 1940 1941 struct X { 1942 Y f() override noexcept final; 1943 /*^ entity.name.function */ 1944 /* ^ storage.modifier */ 1945 /* ^ storage.modifier */ 1946 /* ^ storage.modifier */ 1947 ::Y g() override noexcept final; 1948 /* <- punctuation.accessor */ 1949 /* ^ entity.name.function */ 1950 /* ^ storage.modifier */ 1951 /* ^ storage.modifier */ 1952 /* ^ storage.modifier */ 1953 }; 1954 1955 class X { 1956 public: 1957 ::Y g() override noexcept final; 1958 /* <- punctuation.accessor */ 1959 /* ^ entity.name.function */ 1960 /* ^ storage.modifier */ 1961 /* ^ storage.modifier */ 1962 /* ^ storage.modifier */ 1963 }; 1964 1965 union Y { 1966 ::Y g() override noexcept final; 1967 /* <- punctuation.accessor */ 1968 /* ^ entity.name.function */ 1969 /* ^ storage.modifier */ 1970 /* ^ storage.modifier */ 1971 /* ^ storage.modifier */ 1972 }; 1973 1974 class Child : public Parent { 1975 ::anotherClass Func() override; 1976 /* <- punctuation.accessor */ 1977 /* ^ entity.name.function */ 1978 /* ^ storage.modifier */ 1979 } 1980 1981 class Adapter2 : public Abstraction, private Scenario { 1982 /* ^ punctuation.separator */ 1983 } 1984 1985 class Adapter : public Abstraction 1986 #if defined ASPECTO_MACRO 1987 /* ^^^ keyword.control.import */ 1988 , public Scenario 1989 /* ^ punctuation.separator */ 1990 /* ^ storage.modifier */ 1991 /* ^ entity.other.inherited-class */ 1992 #endif 1993 /* ^^^^^^ keyword.control.import */ 1994 { 1995 1996 } 1997 1998 struct Base {}; 1999 class Derived final : Base {}; 2000 /* ^ storage.modifier */ 2001 struct Derived final : Base {}; 2002 /* ^ storage.modifier */ 2003 2004 /* C++11 "uniform initialization" in initializer lists */ 2005 class Foo { 2006 public: 2007 Foo() : var1(1), var(2), var3{3}, var4(4) {} 2008 /* ^ meta.method.constructor.initializer-list */ 2009 /* ^ - meta.function-call - variable.function */ 2010 private: 2011 int var1, var2, var3, var4; 2012 }; 2013 2014 class X { 2015 int a, b, i, j; 2016 public: 2017 const int& r; 2018 X(int i) 2019 : r(a) // initializes X::r to refer to X::a 2020 /* ^ meta.method.constructor.initializer-list punctuation */ 2021 /* ^ meta.method.constructor.initializer-list punctuation */ 2022 , b{i} // initializes X::b to the value of the parameter i 2023 /* ^ meta.method.constructor.initializer-list punctuation */ 2024 /* ^ meta.method.constructor.initializer-list punctuation */ 2025 , i(i) // initializes X::i to the value of the parameter i 2026 /* ^ meta.method.constructor.initializer-list punctuation */ 2027 /* ^ meta.method.constructor.initializer-list punctuation */ 2028 , j(this->i) // initializes X::j to the value of X::i 2029 /* ^ meta.method.constructor.initializer-list punctuation */ 2030 /* ^ meta.method.constructor.initializer-list punctuation */ 2031 , j 2032 /*^ variable */ 2033 (this->i) 2034 /* <- meta.method.constructor.initializer-list punctuation */ 2035 { } 2036 /* ^ punctuation - meta.method.constructor.initializer-list */ 2037 /* ^ punctuation - meta.method.constructor.initializer-list */ 2038 }; 2039 2040 struct A { 2041 static_assert(0 < 1, ""); 2042 /* ^ keyword.operator.word */ 2043 /* ^ meta.function-call */ 2044 /* ^ keyword.operator.comparison */ 2045 2046 A(); 2047 /*^ meta.method.constructor entity.name.function.constructor */ 2048 2049 void f(); 2050 /* ^ storage.type */ 2051 /* ^ meta.method entity.name.function */ 2052 /* ^ punctuation.terminator */ 2053 }; 2054 /* <- punctuation.section.block.end - invalid.illegal */ 2055 2056 struct bar { 2057 /*^^^^^^^^^^ meta.struct */ 2058 /*^^^^ storage.type */ 2059 /* ^^^ entity.name.struct */ 2060 /* ^ meta.block punctuation.section.block.begin */ 2061 bar() 2062 /* ^^^^^ meta.method */ 2063 /* ^^^ entity.name.function */ 2064 {} 2065 } 2066 /* <- meta.struct meta.block punctuation.section.block.end */ 2067 /* <- - meta.struct meta.block */ 2068 2069 enum baz { 2070 /*^^^^^^^^ meta.enum */ 2071 /* <- meta.enum storage.type */ 2072 /* ^^^ entity.name.enum */ 2073 /* ^ meta.block punctuation.section.block.begin */ 2074 FOO = 1, 2075 /* ^ keyword.operator.assignment */ 2076 /* ^ constant.numeric */ 2077 BAR = 2, 2078 BAZ = 3, 2079 #if 0 2080 /* ^ constant.numeric */ 2081 QUX = 4, 2082 /* ^ comment.block */ 2083 #endif 2084 } 2085 /* <- meta.enum meta.block punctuation.section.block.end */ 2086 /* <- - meta.enum meta.block */ 2087 2088 int main(void) 2089 { 2090 struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; 2091 /* ^ - entity.name */ 2092 /* ^ - entity.name */ 2093 } 2094 2095 struct foo MACRO { 2096 /* ^ entity.name.struct */ 2097 /* ^ - entity.name */ 2098 } 2099 2100 // Partially-typed 2101 struct foo 2102 /* ^ entity.name */ 2103 2104 struct UI_MenuBoxData 2105 /* <- storage.type */ 2106 /* ^ entity.name.struct */ 2107 { 2108 struct UI_BoundingBox position; 2109 /* ^ - entity.name */ 2110 /* ^ - entity.name */ 2111 enum UI_BoxCharType borderType; 2112 /* ^ - entity.name */ 2113 /* ^ - entity.name */ 2114 unsigned int paddingX; 2115 unsigned int paddingY; 2116 struct UI_ScrollBoxText boxContents[]; 2117 /* ^ - entity.name */ 2118 /* ^ - entity.name */ 2119 }; 2120 2121 enum class qux : std::uint8_t 2122 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ 2123 /*^^^^^^^^ storage.type */ 2124 /* ^^^ entity.name.enum */ 2125 /* ^ punctuation.separator */ 2126 /* ^^^^^^^^^^^^ entity.other.inherited-class */ 2127 { 2128 /* <- meta.block punctuation.section.block.begin */ 2129 FOO = 1, 2130 BAR = 2, 2131 /* ^ keyword.operator.assignment */ 2132 /* ^ constant.numeric */ 2133 BAZ = 3 2134 } 2135 /* <- meta.enum meta.block punctuation.section.block.end */ 2136 /* <- - meta.enum meta.block */ 2137 2138 enum LineEnding : uint32_t; 2139 /*^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ 2140 /* ^^^^^^^^^^ entity.name.enum.forward-decl */ 2141 /* ^ punctuation.separator */ 2142 /* ^^^^^^^^ entity.other.inherited-class */ 2143 /* ^ - meta.enum */ 2144 2145 union foobaz { 2146 /* <- meta.union storage.type */ 2147 /* ^^^^^^ entity.name.union */ 2148 /* ^ meta.block punctuation.section.block.begin */ 2149 } 2150 /* <- meta.union meta.block punctuation.section.block.end */ 2151 /* <- - meta.union meta.block */ 2152 2153 // Class name that looks like a possible macro 2154 class SP {} 2155 /* ^^ entity.name.class */ 2156 2157 class MyClass MACRO MACRO2 2158 /* ^ storage.type */ 2159 /* ^ entity.name.class */ 2160 /* ^ - entity */ 2161 /* ^ - entity */ 2162 {} 2163 2164 // Class using macro to handle __declspec() on Windows 2165 class SK_API SkBitmap {} 2166 /* ^ entity.name.class */ 2167 class __declspec(property(get=foo)) SkBitmap {} 2168 /* ^ storage.modifier */ 2169 /* ^ variable.parameter */ 2170 /* ^ entity.name.class */ 2171 class __declspec(align(8)) SkBitmap {} 2172 /* ^ storage.modifier */ 2173 /* ^ constant.numeric */ 2174 /* ^ entity.name.class */ 2175 class __declspec(dllimport) SkBitmap {} 2176 /* ^ constant.other */ 2177 /* ^ entity.name.class */ 2178 2179 // Make sure not to match macros that have "too few characters". 2180 template <class T> class Sample { 2181 public: 2182 // The T here should not be consumed as a macro. 2183 T operator() (const foo x) { 2184 /* <- entity.name.function */ 2185 /*^^^^^^^^ entity.name.function */ 2186 return T; 2187 } 2188 int operator == (const int x) { 2189 /*^^^^^^^^^^^ entity.name.function */ 2190 return 0; 2191 } 2192 // The T here should not be consumed as a macro. 2193 T operator()(int a) { 2194 /* <- entity.name.function */ 2195 /*^^^^^^^^ entity.name.function */ 2196 return T; 2197 } 2198 // The T here should not be consumed as a macro. 2199 T operator[](int a) { 2200 /* <- entity.name.function */ 2201 /*^^^^^^^^ entity.name.function */ 2202 return T; 2203 } 2204 }; 2205 2206 class Namespace::MyClass MACRO1 MACRO2 : public SuperClass 2207 /* ^^^^^^^ entity.name.class */ 2208 /* ^^ punctuation.accessor */ 2209 /* ^ - entity.name */ 2210 { 2211 }; 2212 2213 struct Namespace::MyStruct 2214 /* ^^^^^^^^ entity.name.struct */ 2215 /* ^^ punctuation.accessor */ 2216 { 2217 }; 2218 2219 union Namespace::MyUnion 2220 /* ^^^^^^^ entity.name.union */ 2221 /* ^^ punctuation.accessor */ 2222 { 2223 }; 2224 2225 enum class Namespace::MyEnum 2226 /* ^^^^^^ entity.name.enum */ 2227 /* ^^ punctuation.accessor */ 2228 { 2229 }; 2230 2231 class Namespace:: 2232 MyClass MACRO1 2233 /* <- entity.name.class */ 2234 /* ^ - entity.name */ 2235 { 2236 }; 2237 2238 struct Namespace:: 2239 MyStruct MACRO1 2240 /* <- entity.name.struct */ 2241 /* ^ - entity.name */ 2242 { 2243 }; 2244 2245 union Namespace:: 2246 MyUnion MACRO1 2247 /* <- entity.name.union */ 2248 /* ^ - entity.name */ 2249 { 2250 }; 2251 2252 enum class Namespace:: 2253 MyEnum MACRO1 2254 /* <- entity.name.enum */ 2255 /* ^ - entity.name */ 2256 { 2257 }; 2258 2259 2260 ///////////////////////////////////////////// 2261 // Test preprocessor branching and C blocks 2262 ///////////////////////////////////////////// 2263 2264 int foo(int val, float val2[], bool val3 = false) 2265 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ 2266 /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ 2267 /* ^ punctuation.section.group.begin */ 2268 /* ^ punctuation.section.group.end */ 2269 /* ^^^ variable.parameter */ 2270 /* ^ punctuation.separator */ 2271 /* ^^^^ variable.parameter */ 2272 /* ^^ meta.brackets */ 2273 /* ^ punctuation.section.brackets.begin */ 2274 /* ^ punctuation.section.brackets.end */ 2275 /* ^ punctuation.separator */ 2276 /* ^^^^ storage.type */ 2277 /* ^^^^ variable.parameter */ 2278 /* ^ keyword.operator.assignment */ 2279 /* ^^^^^ constant.language */ 2280 { 2281 myClass *result; 2282 result->kk = func(val); 2283 /* ^^ punctuation.accessor */ 2284 if (result == 0) { 2285 return 0; 2286 #if CROSS_SCOPE_MACRO 2287 /* <- keyword.control.import */ 2288 } else if (result > 0) { 2289 return 1; 2290 #endif 2291 /* <- keyword.control.import */ 2292 } 2293 /* ^ meta.block meta.block punctuation.section.block.end */ 2294 /* ^ - meta.block meta.block */ 2295 2296 #ifndef DEBUG 2297 if (check_debug()) { 2298 val /= 2; 2299 #endif 2300 val += 1; 2301 #ifndef DEBUG 2302 } 2303 /* ^ meta.function meta.block meta.block punctuation.section.block.end */ 2304 /* ^ - meta.block meta.block */ 2305 #endif 2306 2307 #ifdef FOO 2308 /* <- keyword.control.import */ 2309 int foobar 2310 /* ^^^^^^ - entity.name.function */ 2311 ; 2312 2313 if (val == -1) { 2314 /* ^ meta.block meta.block punctuation.section.block.begin */ 2315 #else 2316 /* <- keyword.control.import */ 2317 if (val == -2) { 2318 /* ^ meta.block meta.block punctuation.section.block.begin */ 2319 #endif 2320 /* <- keyword.control.import */ 2321 val += 1; 2322 } 2323 /* ^ meta.block punctuation.section.block.end */ 2324 /* ^ - meta.block meta.block */ 2325 2326 return -1; 2327 } 2328 /* <- meta.function punctuation.section.block.end */ 2329 /* <- - meta.function */ 2330 2331 #if 0 2332 /* ^ constant.numeric */ 2333 int disabled_func() { 2334 /* ^ comment.block */ 2335 } 2336 #endif 2337 2338 #if 1 2339 /* ^ constant.numeric */ 2340 int enabled_func() {} 2341 /* ^ entity.name.function */ 2342 #else 2343 int disabled_func() { 2344 /* ^ comment.block */ 2345 } 2346 #endif 2347 2348 #if 1 2349 int a = 1; 2350 #if 0 2351 /* ^ constant.numeric */ 2352 int b = 2; 2353 /* ^ comment.block */ 2354 #else 2355 int c = 3; 2356 #endif 2357 #else 2358 int d = 4; 2359 /* ^ comment.block */ 2360 #endif 2361 2362 BOOL 2363 GetTextMetrics( 2364 HDC hdc, 2365 LPTEXTMETRIC lptm 2366 ) 2367 { 2368 #ifdef UNICODE 2369 /* <- keyword.control.import */ 2370 return GetTextMetricsW( 2371 /* ^ variable.function */ 2372 #else 2373 /* <- keyword.control.import */ 2374 return GetTextMetricsA( 2375 /* ^ variable.function */ 2376 #endif 2377 /* <- keyword.control.import */ 2378 hdc, 2379 lptm 2380 ); 2381 /* ^ meta.function-call */ 2382 /* ^ - meta.function-call */ 2383 } 2384 /* <- - meta.function */ 2385 /* <- - meta.block */ 2386 2387 ///////////////////////////////////////////// 2388 // Matching various function definitions 2389 ///////////////////////////////////////////// 2390 2391 const int foo = 1; 2392 /* ^ - entity.name.function */ 2393 int a; 2394 /* ^ - entity.name.function */ 2395 2396 int /* comment */ * myfunc 2397 /* <- storage.type */ 2398 /* ^ comment.block */ 2399 /* ^ keyword.operator */ 2400 /* ^^^^^^ entity.name.function */ 2401 (int * a) 2402 /* <- punctuation.section.group.begin */ 2403 /* ^ keyword.operator */ 2404 /* ^ punctuation.section.group.end */ 2405 { 2406 2407 } 2408 2409 void MyClass3:: 2410 foo() { 2411 /* <- entity.name.function */ 2412 } 2413 2414 MyClass3:: 2415 ~MyClass3() { 2416 /* <- entity.name.function */ 2417 } 2418 2419 struct A 2420 { 2421 #ifdef X 2422 static_assert(false, "asdf"); 2423 /* ^ keyword.operator.word */ 2424 #endif 2425 2426 void f() 2427 { 2428 #ifdef X 2429 static_assert(false, "asdf"); 2430 /* ^ keyword.operator.word */ 2431 #endif 2432 } 2433 2434 void f() 2435 { 2436 static_assert(false, "asdf"); 2437 /* ^ keyword.operator.word */ 2438 } 2439 }; 2440 2441 void f() 2442 { 2443 static_assert(false, "asdf"); 2444 /* ^ meta.function meta.block */ 2445 /* ^ keyword.operator.word */ 2446 } 2447 2448 void f() 2449 { 2450 #ifdef X 2451 static_assert(false, "asdf"); 2452 /* ^ meta.function meta.block */ 2453 /* ^ keyword.operator.word */ 2454 #endif 2455 } 2456 2457 Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/); 2458 /* ^^^^^^^^^ comment */ 2459 2460 MACRO1 void * MACRO2 myfuncname () { 2461 /* ^ storage.type */ 2462 /* ^ keyword.operator */ 2463 /* ^ entity.name.function */ 2464 2465 label: 2466 /* ^ entity.name.label */ 2467 /* ^ punctuation.separator */ 2468 do { 2469 break; 2470 } while(true); 2471 2472 switch (a) { 2473 case 1: break; 2474 /* ^ punctuation.separator */ 2475 case 100 - 10: break; 2476 /* ^ punctuation.separator */ 2477 default: break; 2478 /* ^ punctuation.separator */ 2479 } 2480 2481 } 2482 2483 static const uint32_t * const MACRO funcname(); 2484 /* ^ storage.modifier */ 2485 /* ^ storage.modifier */ 2486 /* ^ support.type */ 2487 /* ^ keyword.operator */ 2488 /* ^ storage.modifier */ 2489 /* ^ entity.name.function */ 2490 2491 MACRO int 2492 /* ^ storage.type */ 2493 funcname2 2494 /* ^ entity.name.function */ 2495 () 2496 { 2497 2498 } 2499 2500 MACRO_CALL(int) macro_prefixed_func(){} 2501 /*^^^^^^^^^^^^^ meta.function-call */ 2502 /* ^^^^^ meta.group */ 2503 /* ^ punctuation.section.group.begin */ 2504 /* ^ punctuation.section.group.end */ 2505 /* ^ entity.name.function */ 2506 2507 int* return_type_pointer_no_space(){} 2508 /* ^ entity.name.function */ 2509 2510 int& return_type_ref_no_space(){} 2511 /* ^ entity.name.function */ 2512 2513 // Make sure there isn't an incorrect match here since this is not a valid 2514 // function definition 2515 int32 2516 /* <- - entity.name.function */ 2517 () {} 2518 2519 _declspec(deprecated("bla")) void func2(int) {} 2520 /* <- meta.function-call variable.function */ 2521 /* ^ entity.name.function */ 2522 __declspec(deprecated("bla")) void func2(int) {} 2523 /* <- storage.modifier - variable.function */ 2524 /* ^ storage.modifier - variable.function */ 2525 /* ^ string.quoted.double punctuation */ 2526 /* ^ string.quoted.double - punctuation */ 2527 /* ^ string.quoted.double - punctuation */ 2528 /* ^ string.quoted.double punctuation */ 2529 /* ^^ punctuation - invalid */ 2530 /* ^ entity.name.function */ 2531 __notdeclspec(deprecated("bla")) void func2(int) {} 2532 /* <- meta.function-call variable.function */ 2533 /* ^ entity.name.function */ 2534 2535 ///////////////////////////////////////////// 2536 // Paths/identifiers 2537 ///////////////////////////////////////////// 2538 2539 void sayHi() 2540 { 2541 std::cout << "Hi!\n"; 2542 /* ^ punctuation.accessor */ 2543 Print<int>(3); 2544 /* ^ variable.function */ 2545 func_call(foo 2546 /* ^ meta.function-call */ 2547 ); 2548 2549 if (::std::foo()) {} 2550 /* ^^^ variable.function */ 2551 /* ^^ punctuation.accessor */ 2552 /* ^^ punctuation.accessor */ 2553 2554 foobaz<int>(); 2555 /* ^^^^^^^^^^^^^ meta.function-call */ 2556 /* ^^^^^^ variable.function */ 2557 /* ^ punctuation.section.generic.begin */ 2558 /* ^ punctuation.section.generic.end */ 2559 /* ^^ meta.group */ 2560 2561 foobaz<>(); 2562 /* ^^^^^^^^^^ meta.function-call */ 2563 /* ^^^^^^ variable.function */ 2564 /* ^ punctuation.section.generic.begin */ 2565 /* ^ punctuation.section.generic.end */ 2566 /* ^^ meta.group */ 2567 2568 foobaz<0>(); 2569 /* ^^^^^^^^^^^ meta.function-call */ 2570 /* ^^^^^^ variable.function */ 2571 /* ^ punctuation.section.generic.begin */ 2572 /* ^ constant.numeric */ 2573 /* ^ punctuation.section.generic.end */ 2574 /* ^^ meta.group */ 2575 2576 ::myns::foo<int>(); 2577 /* ^^ punctuation.accessor.double-colon */ 2578 /* ^^ punctuation.accessor.double-colon */ 2579 /* ^^^^^^^^^^^^^^^^^^ meta.function-call */ 2580 /* ^^^ variable.function */ 2581 /* ^^^ storage.type */ 2582 2583 myns::FooClass{42}; 2584 /* ^^ punctuation.accessor.double-colon */ 2585 /* ^^^^^^^^^^^^^^^^^^ meta.function-call */ 2586 /* ^^^^^^^^ variable.function */ 2587 2588 ::myns::BarClass<int>{}; 2589 /* ^^ punctuation.accessor.double-colon */ 2590 /* ^^ punctuation.accessor.double-colon */ 2591 /* ^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ 2592 /* ^^^^^^^^ variable.function */ 2593 /* ^^^ storage.type */ 2594 2595 int a[5]; 2596 /* ^^^ meta.brackets */ 2597 /* ^ punctuation.section.brackets.begin */ 2598 /* ^ punctuation.section.brackets.end */ 2599 2600 std::cout << ">> Hi!\n"; 2601 /* ^^ keyword.operator.arithmetic.c */ 2602 } 2603 2604 ///////////////////////////////////////////// 2605 // Includes 2606 ///////////////////////////////////////////// 2607 2608 #include "foobar.h" 2609 /* <- keyword.control.import.include */ 2610 /* ^ punctuation.definition.string.begin */ 2611 /* ^^^^^^^^ string.quoted.double.include */ 2612 /* ^ punctuation.definition.string.end */ 2613 2614 #include <cstdlib> 2615 /* <- keyword.control.import.include */ 2616 /* ^ punctuation.definition.string.begin */ 2617 /* ^^^^^^^ string.quoted.other.lt-gt.include */ 2618 /* ^ punctuation.definition.string.end */ 2619 2620 #ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS 2621 #include_next <math.h> 2622 /* <- keyword.control.import.include */ 2623 /* ^ punctuation.definition.string.begin */ 2624 /* ^^^^^^ string.quoted.other.lt-gt.include */ 2625 /* ^ punctuation.definition.string.end */ 2626 #endif 2627 2628 #include<iostream> 2629 /* <- keyword.control.import.include */ 2630 /* ^ punctuation.definition.string.begin */ 2631 /* ^^^^^^^^ string.quoted.other.lt-gt.include */ 2632 /* ^ punctuation.definition.string.end */ 2633 2634 /** 2635 * 2636 /* ^ comment.block.c punctuation.definition.comment.c */