diff --git a/C++/C++.sublime-settings b/C++/C++.sublime-settings deleted file mode 100644 index 15f4f890ce..0000000000 --- a/C++/C++.sublime-settings +++ /dev/null @@ -1,4 +0,0 @@ -{ - // This overrides "file_extensions" in C.sublime-syntax - "extensions": ["h"] -} diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 81ed81d942..97c50bb3ea 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -3,6 +3,8 @@ # http://www.sublimetext.com/docs/3/syntax.html name: C++ scope: source.c++ +version: 2 +extends: Packages/C++/C.sublime-syntax file_extensions: - cpp @@ -26,2340 +28,629 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \b(c\+\+|cpp\b) .*? -\*- # editorconfig ) -variables: - # number digits - bin_digit: '[01'']' - oct_digit: '[0-7'']' - dec_digit: '[\d'']' - hex_digit: '[\h'']' - - dec_digits: '(?:\d(?:{{dec_digit}}*\d)?)' - - # number exponents - dec_exponent: '(?:[eE][-+]?{{dec_digit}}*)' - hex_exponent: '(?:[pP][-+]?{{dec_digit}}*)' - - # number suffixes - # note: nearly everything can be defined as suffix - # a) see user literals - # https://en.cppreference.com/w/cpp/language/user_literal - # b) see complex `operator` keyword - # https://en.cppreference.com/w/cpp/numeric/complex/operator%22%22i - bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' - oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' - dec_suffix: '[a-zA-Z_][[:alnum:]_]*' - hex_suffix: '[g-zG-Z_][[:alnum:]_]*' - float_suffix: '[fF]' - - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - path_lookahead: '(?:::\s*)?(?:{{identifier}}\s*::\s*)*(?:template\s+)?{{identifier}}' - operator_method_name: '\boperator\s*(?:[-+*/%^&|~!=<>]|[-+*/%^&|=!<>]=|<=>|<<=?|>>=?|&&|\|\||\+\+|--|,|->\*?|\(\)|\[\]|""\s*{{identifier}})' - casts: 'const_cast|dynamic_cast|reinterpret_cast|static_cast' - operator_keywords: 'and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq|noexcept' - coroutine_keywords: co_(?:await|return|yield) - control_keywords: 'break|case|catch|continue|default|do|else|for|goto|if|_Pragma|switch|throw|try|while|{{coroutine_keywords}}' - memory_operators: 'new|delete' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum\s+class|enum\s+struct|enum|class|concept' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|export|extern|friend|explicit|virtual|register|thread_local' - type_qualifier: 'const|mutable|typename|volatile' - constant_expression_specifiers: 'consteval|constexpr|constinit' - compiler_directive: 'inline|restrict|__restrict__|__restrict' - visibility_modifiers: 'private|protected|public' - other_keywords: 'typedef|nullptr|{{visibility_modifiers}}|static_assert|sizeof|using|typeid|alignof|alignas|namespace|template' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}|{{constant_expression_specifiers}}' - non_angle_brackets: '(?=<<|<=)' - module_identifier: '{{identifier}}(?:\.{{identifier}})*' - - regular: '[^(){}&;*^%=<>-]*' - regular_plus: '[^(){}&;*^%=<>-]+' - paren_open: (?:\( - paren_close: '\))?' - generic_open: (?:{{regular_plus}}(?:< - generic_close: '>)?)?' - balance_parentheses: '{{regular}}{{paren_open}}{{regular}}{{paren_close}}{{regular}}' - generic_lookahead: <{{generic_open}}{{generic_open}}{{regular}}{{generic_close}}\s*{{generic_close}}{{balance_parentheses}}> - - data_structures_forward_decl_lookahead: '(\s+{{macro_identifier}})*\s*(:\s*({{path_lookahead}}|{{visibility_modifiers}}|,|\s|<[^;]*>)+)?;' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__|typeid|alignof|alignas|static_assert' - contexts: - main: - - include: preprocessor-global - - include: global - - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the - # Objective-C++ syntax. They are specifically constructed to not push into - # sub-contexts, which ensures that Objective-C++ code isn't accidentally - # lexed as plain C++. - # - # The "unique-*" contexts are additions that C++ makes over C, and thus can - # be directly reused in Objective-C++ along with contexts from Objective-C - # and C. - ############################################################################# - - unique-late-expressions: - # This is highlighted after all of the other control keywords - # to allow operator overloading to be lexed properly - - match: \boperator\b - scope: keyword.control.c++ - - unique-modifiers: - - match: \b({{modifiers}})\b - scope: storage.modifier.c++ - - unique-variables: - - match: \bthis\b - scope: variable.language.c++ - # common C++ instance var naming idiom -- fMemberName - - match: '\b(f|m)[[:upper:]]\w*\b' - scope: variable.other.readwrite.member.c++ - # common C++ instance var naming idiom -- m_member_name - - match: '\bm_[[:alnum:]_]+\b' - scope: variable.other.readwrite.member.c++ - - unique-constants: - - match: \bnullptr\b - scope: constant.language.c++ - - unique-keywords: - - match: \busing\b - scope: keyword.control.c++ - - match: \bbreak\b - scope: keyword.control.flow.break.c++ - - match: \bcontinue\b - scope: keyword.control.flow.continue.c++ - - match: \bgoto\b - scope: keyword.control.flow.goto.c++ - - match: \breturn\b - scope: keyword.control.flow.return.c++ - - match: \bthrow\b - scope: keyword.control.flow.throw.c++ - - match: \b({{control_keywords}})\b - scope: keyword.control.c++ - - match: '\bdelete\b(\s*\[\])?|\bnew\b(?!])' - scope: keyword.control.c++ - - match: \b({{operator_keywords}})\b - scope: keyword.operator.word.c++ - - unique-types: - - match: \bclass\b - scope: keyword.declaration.class.c++ - - unique-strings: - - match: '((?:L|u8|u|U)?R)("([^\(\)\\ ]{0,16})\()' + function: + - match: \b(operator)\s*([<>=+\-*/%&|^!]=?|[+\-&|<>]{2}|<<=|>>=|<=>|~|->\*?|\(\)|\[\]|\"\"\s*{{identifier}})\s*(\() captures: - 1: storage.type.string.c++ - 2: punctuation.definition.string.begin.c++ + 1: keyword.operator.c++ + 2: entity.name.function.c++ + 3: meta.group.c++ punctuation.section.group.begin.c++ push: - - meta_scope: string.quoted.double.c++ - - match: '\)\3"' - scope: punctuation.definition.string.end.c++ - pop: true - - numbers: - # https://en.cppreference.com/w/cpp/language/floating_literal - - # decimal floats - - match: |- - (?x: - \b({{dec_digits}}) - (?: - ( (\.) - (?: - # 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L - {{dec_digit}}+ {{dec_exponent}}? - # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L - | {{dec_exponent}} - # 1., 1.f, 1.L # but not `..` - | (?!\.) - ) - # 1e1 1e1f 1e1L - | {{dec_exponent}} - ) ({{dec_suffix}})? - # 1f - | ({{float_suffix}}) - ) - # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L - | ( (\.) {{dec_digit}}+ {{dec_exponent}}? ) ({{dec_suffix}})? - ) - scope: meta.number.float.decimal.c++ - captures: - 1: constant.numeric.value.c++ - 2: constant.numeric.value.c++ - 3: punctuation.separator.decimal.c++ - 4: constant.numeric.suffix.c++ - 5: constant.numeric.suffix.c++ - 6: constant.numeric.value.c++ - 7: punctuation.separator.decimal.c++ - 8: constant.numeric.suffix.c++ - - # hexadecimal float - - match: \b(0[xX])({{hex_digit}}*(\.){{hex_digit}}*{{hex_exponent}})({{dec_suffix}})? - scope: meta.number.float.hexadecimal.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: punctuation.separator.decimal.c++ - 4: constant.numeric.suffix.c++ - - # https://en.cppreference.com/w/cpp/language/integer_literal - - # hexadecimal integer - - match: \b(0[xX])({{hex_digit}}*)({{hex_suffix}})? - scope: meta.number.integer.hexadecimal.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: constant.numeric.suffix.c++ - - # binary integer (C++14) - - match: \b(0[bB])({{bin_digit}}*)({{bin_suffix}})? - scope: meta.number.integer.binary.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: constant.numeric.suffix.c++ + - function-tail + - function-params - # octal integer - - match: \b(0)({{oct_digit}}+)({{oct_suffix}})? - scope: meta.number.integer.octal.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: constant.numeric.suffix.c++ - - # decimal integer - - match: \b({{dec_digits}})({{dec_suffix}})? - scope: meta.number.integer.decimal.c++ - captures: - 1: constant.numeric.value.c++ - 2: constant.numeric.suffix.c++ - - identifiers: - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - match: '(?:(::)\s*)?{{identifier}}' - captures: - 1: punctuation.accessor.double-colon.c++ - - identifier-path-generic: - - include: angle-brackets - - match: '(?:(::)\s*)?{{identifier}}\s*(?=(<.*>)?\s*(::))\s*' + - include: expression-identifiers + - include: operator.pointer + - match: (~?{{identifier}})\s*(\() captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - function-specifiers: - - match: \b(const|final|noexcept|override)\b - scope: storage.modifier.c++ - - ############################################################################# - # The following are C++-specific contexts that should not be reused. This is - # because they push into subcontexts and use variables that are C++-specific. - ############################################################################# - - ## Common context layout - - global: - - match: '(?=\btemplate\b)' + 1: entity.name.function.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ push: + - function-tail + - function-params + - match: (?={{identifier}}\s*<) + branch_point: function-template + branch: [function-template, consume-ident] + - match: '{{identifier}}' + function-template: + - match: '{{identifier}}(?=\s*<)' + scope: entity.name.function.c++ + set: function-template-body + function-template-body: - include: template + - match: \( + scope: meta.group.c++ punctuation.section.group.begin.c++ + push: + - pop-twice + - function-tail + - function-params - match: (?=\S) - set: global-modifier - - include: using-namespace - - include: namespace - - include: module - - include: keywords-angle-brackets - - match: '(?={{path_lookahead}}\s*<)' - push: global-modifier - - include: global-block-comments - - include: early-expressions - - match: ^\s*\b(extern)(?=\s+"C(\+\+)?") - scope: storage.modifier.c++ - push: - - include: comments - - include: strings - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_scope: meta.extern-c.c++ - - match: '^\s*(#\s*ifdef)\s*__cplusplus\s*' - scope: meta.preprocessor.c++ - captures: - 1: keyword.control.import.c++ - set: - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: preprocessor-global - - include: global - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: preprocessor-global - - include: global - - match: (?=\S) - set: global-modifier - - match: ^\s*(?=\w) - push: global-modifier - - include: late-expressions - - global-block-comments: - # NOTE: This context overrides `comments` context, which re-uses scopes - # from `source.c#comments`. So keep the trailing `c` for consistency reasons! - - match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n? - scope: comment.block.banner.c - captures: - 1: punctuation.definition.comment.begin.c - 2: meta.toc-list.banner.block.c - 3: punctuation.definition.comment.end.c - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.c punctuation.definition.comment.c - push: global-block-comment-after - # documentation block comments - - match: (?:/\*!|/\*{2,}) - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-documentation-body - # normal block comments - - match: /\* - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-body - - global-block-comment-after: - - match: \s*(?=\w) - set: global-modifier - - match: '' - pop: true - - statements: - - include: preprocessor-statements - - include: scope:source.c#label - - include: expressions - - statements-enum: - - include: comments - - include: preprocessor-statements - - include: scope:source.c#label - - match: '{{identifier}}' - scope: entity.name.constant.c++ - push: constant-value - - match: ',' - scope: punctuation.separator.c++ - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: early-expressions-before-generic-type - - include: generic-type - - include: early-expressions-after-generic-type - - early-expressions-before-generic-type: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: using-namespace - - include: typedef - - include: using-alias - - include: keywords-angle-brackets - - include: keywords-parens - - include: keywords - - include: numbers - # Prevent a '<' from getting scoped as the start of another template - # parameter list, if in reality a less-than-or-equals sign or - # three-way comparison operator is meant. - - match: '<=>?' - scope: keyword.operator.comparison.c + fail: function-template - early-expressions-after-generic-type: - - include: members-arrow - - include: operators - - include: members-dot - - include: strings - - include: parens - - include: brackets - - include: block - - include: variables - - include: constants - - match: ',' - scope: punctuation.separator.c++ - - match: '\)|\}' + function-params: # Add default parameters + - meta_content_scope: meta.function.parameters.c meta.group.c++ + - match: \) + scope: punctuation.section.group.end.c++ + pop: 1 + - match: \}|\] # Fallback scope: invalid.illegal.stray-bracket-end.c++ + pop: 2 + - match: ; # Fallback + scope: invalid.illegal.unexpected-terminator.c++ + pop: 2 - expressions-minus-generic-type: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions - - expressions-minus-generic-type-function-call: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions-before-function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - late-expressions: - - include: late-expressions-before-function-call - - include: function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - late-expressions-before-function-call: - - include: unique-late-expressions - - include: modifiers-parens - - include: modifiers - - include: types - - expressions-minus-function-call: - - include: early-expressions - - include: late-expressions-before-function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - comments: - - include: scope:source.c#comments - - operators: - - include: scope:source.c#operators - - modifiers: - - include: unique-modifiers - - include: scope:source.c#modifiers - - variables: - - include: unique-variables - - include: scope:source.c#variables - - constants: - - include: unique-constants - - include: scope:source.c#constants - - keywords: - - include: unique-keywords - - include: scope:source.c#keywords - - types: - - include: unique-types - - include: types-parens - - include: scope:source.c#types - - strings: - - include: unique-strings - - include: scope:source.c#strings - - ## C++-specific contexts - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.c++ - push: - - match: (?=[);,]) - pop: true - - match: ':' - scope: punctuation.separator.c++ - pop: true - - include: expressions + - match: (?={{identifier}}\s*(?!\s*[\[,\)=]|$)) + push: + - match: \b + set: function-params-name + - include: expression + - include: expression + function-params-name: + - match: (?=[\]\}\);]) # Fallback + pop: 1 + - include: expression-identifiers + - match: ({{identifier}})\s*(\[) + captures: + 1: variable.parameter.c++ + 2: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ + set: enclosure.brackets + - match: ({{identifier}})\s*(?=[,\)=]|$) + captures: + 1: variable.parameter.c++ + pop: 1 + - include: expression + + function-tail: + - meta_prepend: true + - match: \b(?:override|final|noexcept)\b + scope: storage.modifier.c++ + - match: ':' + scope: punctuation.separator.initializer-list.begin.c++ + push: initializer-list + - match: \brequires\b + scope: storage.modifier.c++ + push: function-tail-requires + - match: \-\> + scope: keyword.operator.arrow.c++ + push: function-tail-return + - include: operator + function-tail-return: + - meta_scope: meta.function.return-type.c++ + - match: (?=\brequires\b) + pop: 1 + - include: expression-identifiers + - match: (?=(?:{{identifier}})?\s*{) + pop: 1 + - include: expression + function-tail-requires: + - meta_scope: meta.function.requires.c++ + - match: (?={) + pop: 1 + - include: expression + + initializer-list: + - meta_scope: meta.method.initializer-list.c++ + - match: '{{identifier}}' + scope: variable.other.readwrite.member.c++ + push: initializer-list-body + - include: punctuation.comma + - include: else-pop + initializer-list-body: + - include: template + - match: \( + scope: meta.group.c++ punctuation.section.group.begin.c++ + set: enclosure.parenthesis + - match: \{ + scope: meta.block.c++ punctuation.section.block.begin.c++ + set: enclosure.inner-block + - include: else-pop - modifiers-parens: - - match: '\b(alignas)\b\s*(\()' - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push : - - meta_scope: meta.attribute.c++ - - meta_content_scope: meta.group.c++ - - include: parens - - include: strings - - match: \)\) - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - match: \b(__declspec)(\() + call: + - meta_prepend: true + - match: \b(?={{identifier}}\s*<) + branch_point: template-call + branch: [template-call, qualified-ident] + - match: (~{{identifier}})\s*(\() captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.c++ - - match: ',' - scope: punctuation.separator.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.c++ - - types-parens: - - match: '\b(decltype)\b\s*(\()' + 1: variable.function.c++ + 2: punctuation.section.group.begin.c++ + push: enclosure.parenthesis + template-call: + - match: '{{identifier}}' + scope: entity.name.function.c++ + set: template-call-body + template-call-body: + - include: template + - match: \( + scope: meta.group.c++ punctuation.section.group.begin.c++ + set: enclosure.parenthesis + - match: (?=\S) + fail: template-call + call-try-not-paren: + - meta_prepend: true + - include: template + call-multi-line: + - meta_prepend: true + - include: template + + expression-identifiers: + - meta_append: true + - include: punctuation.qualifier + - include: template + - include: module + expression: + - meta_prepend: true + - include: template + - include: module + - include: type + - match: \+\s*(\[) captures: - 1: keyword.declaration.type.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - keywords-angle-brackets: - - match: \b({{casts}})\b\s* - scope: keyword.operator.word.cast.c++ - push: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - match: '<' - scope: punctuation.definition.generic.begin.c++ - push: - - match: '(?=>)' - pop: true - - include: expressions-minus-generic-type-function-call + 1: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ + push: lambda - keywords-parens: - - match: '\b(alignof|typeid|static_assert|sizeof)\b\s*(\()' - captures: - 1: keyword.operator.word.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions + module: + - match: \bmodule\b + scope: keyword.declaration.module.c++ + push: module-name + - match: \b(import)\s*(?=<) + captures: + 1: keyword.other.import.c++ + push: string.angled + - match: \bimport\b + scope: keyword.other.import.c++ + push: module-name + module-name: + - meta_content_scope: entity.name.module.c++ + - match: '{{identifier}}' + - match: \.(?=\W) + scope: invalid.illegal.unexpected-character.c++ + - match: \. + scope: punctuation.accessor.dot.c++ + - match: ':' + scope: punctuation.separator.partition.c++ + - include: else-pop - using-namespace: - - match: '\b(using)\s+(namespace)\b' + type: + - meta_prepend: true + - match: \bnamespace\b + scope: keyword.declaration.namesace.c++ + branch_point: namespace + branch: [type.namespace, pop-immediately] + - match: \b(using)\s+(namespace|enum)\b captures: - 1: keyword.control.c++ - 2: keyword.control.c++ + 1: keyword.declaration.c++ + 2: keyword.declaration.c++ + push: type.using-namespace + - match: \busing\b + scope: keyword.declaration.c++ + push: type.using + - match: \b(?:struct|class)\b + scope: keyword.declaration.c++ + push: class + - match: \btemplate\b + scope: keyword.declaration.c++ + push: type.template + - match: \bconcept\b + scope: keyword.declaration.c++ + push: type.concept + type.namespace: + - meta_scope: meta.namespace.c++ + - match: (?={{qualified}}) + push: + - meta_scope: entity.name.namespace.c++ + - include: qualified-ident + - include: else-pop + - match: \{ + scope: meta.block.c++ punctuation.section.block.begin.c++ push: - - include: identifiers - - match: '' - pop: true - - namespace: - - match: '\b(namespace)\s+(?=({{path_lookahead}})?(?!\s*[;,]))' - scope: meta.namespace.c++ - captures: - 1: keyword.control.c++ + - pop-twice + - enclosure.outer-block + - match: = + scope: keyword.operator.assignment.c++ + pop: 1 + - match: (?=\S) + fail: namespace + type.using: + - meta_scope: meta.using.c++ + - meta_content_scope: entity.name.using.c++ + - match: (?={{qualified}}) + push: qualified-ident + - include: else-pop + type.using-namespace: + - meta_scope: meta.using.c++ + - meta_content_scope: entity.name.namespace.c++ + - match: (?={{qualified}}) + push: + - pop-twice + - qualified-ident + - include: eol-pop + + type.template: + - meta_scope: meta.template.c++ + - match: \< + scope: punctuation.definition.generic.begin.c++ push: - - meta_content_scope: meta.namespace.c++ entity.name.namespace.c++ - - include: identifiers - - match: '' - set: - - meta_scope: meta.namespace.c++ - - include: comments - - match: '=' - scope: keyword.operator.alias.c++ - - match: '(?=;)' - pop: true - - match: '\}' - scope: meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - - include: expressions - - module-identifier: - # Special handling for trailing periods to prevent color changing while typing. - # Exit to catch invalid trailing period. - - match: '(?=\.\s*[\:;])' - pop: true - # Prevent color changing. - - match: \. - scope: entity.name.module.c++ - # Upcoming partition. - - match: (?=\s*\:) - pop: true - # Forgotten semmi-colon, fully abort out to handle upcoming syntax. - - match: (?=\s*\S) + - type.template-requires + - type.template-body + - include: else-pop + type.template-body: + - match: \> + scope: punctuation.section.generic.end.c++ + pop: 1 + - match: \}|\]|\) # Fallback + scope: invalid.illegal.stray-bracket-end.c++ pop: 2 - - match: '' #safety pop - pop: true - - module-error-handling: - # Stray periods in the name are invalid. - # Only mark the first period as invalid, even though trailing periods are also invalid. - - match: '\B\.' - scope: invalid.illegal.unexpected-character.c++ - # Stray period at end of module name. - - match: '(\.)(?=\s*\:)' - captures: - 1: invalid.illegal.unexpected-character.c++ - # Module partition - check for invalid partition names. - - match: (\:)\s*({{module_identifier}})(?:\s*(\:))? + - match: ; # Fallback + scope: invalid.illegal.unexpected-terminator.c++ + pop: 2 + - match: (?={{identifier}}\s*(?!\s*[,\>=]|$)) + push: + - match: \b + set: type.template-name + - include: expression + - match: \b(?:typename|class)\b + scope: keyword.declaration.type.c++ + - include: expression + type.template-requires: + - match: \brequires\b + scope: storage.modifier.c++ + pop: 1 + - include: else-pop + type.template-name: + - match: (?=[\]\}\);]) # Fallback + pop: 1 + - match: \b(?:typename|class)\b + scope: keyword.declaration.type.c++ + - include: expression-identifiers + - match: ({{identifier}})\s*(\[) captures: - 1: punctuation.accessor.c++ - 2: entity.name.partition.other - 3: invalid.illegal.unexpected-character.c++ - # End of line, but also check for stray period. - - match: '(\.\s*)?(;)' + 1: variable.parameter.type.c++ + 2: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ + set: enclosure.brackets + - match: ({{identifier}})\s*(?=[,\>=]|$) captures: - 1: invalid.illegal.unexpected-character.c++ - 2: punctuation.terminator.c++ - pop: true - - match: (?=\S|$) # safety pop - pop: true + 1: variable.parameter.type.c++ + pop: 1 + - include: expression - module: - # The export keyword can go before most anything. - - match: '\b(export)\s+' - captures: - 1: keyword.control.c++ - push: - # export {...} block. - - match: '\}' - scope: meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - # If this is exporting a module declaration, pop so we can handle it. - - match: '(?=(module|import))' - pop: true - # Otherwise, set into a normal declaration. We are exporting a function or something. - - match: '' - set: global-type + type.concept: + - meta_scope: meta.concept.c++ + - match: '{{identifier}}' + scope: entity.name.concept.c++ + push: type.concept-body + - include: else-pop + type.concept-body: + - match: (?=;|\)|\]|\}) + pop: 1 + - include: expression + + enum-def: + - match: \b(enum)(?:\s*(class))?\b + captures: + 1: keyword.declaration.enum.c++ + 2: keyword.declaration.class.c++ + branch_point: enum + branch: [type.enum, pop-immediately] + + enclosure: + - meta_prepend: true + - include: lambda-enclosure + enclosure.brackets: + - meta_prepend: true + - match: (\])\s*(<) + captures: + 1: punctuation.section.brackets.end.c++ + 2: keyword.control.comparison.c++ + set: lambda-try-not-template + - match: (\])\s*(\() + captures: + 1: punctuation.section.brackets.end.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + set: [lambda-try-not, enclosure.parenthesis] - - match: '\b(import)\s+' + - match: \]\s*(?:\{|\-\>|mutable\b) + fail: lambda + enclosure.outer-block: + - meta_content_scope: meta.block.c++ + - match: \} + scope: meta.block.c++ punctuation.section.block.end.c++ + pop: 1 + - match: '({{likely_macro}})\s*(\()' captures: - 1: keyword.control.c++ + 1: variable.function.assumed-macro.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: call-body + - match: '{{likely_macro}}' + scope: meta.assumed-macro.c++ + - include: main + + lambda-enclosure: # for ObjC++ + - match: \[(?!\[) + branch_point: lambda + scope: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ + branch: [enclosure.brackets, lambda] + + lambda-try-not: + - include: expression-identifiers + - match: \-\> + fail: lambda + - match: \{ + fail: lambda + - include: else-pop + lambda-try-not-template: + - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) + pop: 1 + - match: (?=\&\&\s*[^>,]) + pop: 1 + - match: '>' + fail: lambda + - include: expression + lambda: + - meta_scope: meta.lambda.c++ + - match: '[&=](?=\s*[,\]])' + scope: storage.modifier.capture.c++ + - match: (?=\S) push: - - meta_scope: meta.module.c++ - # Module name. - - match: '{{module_identifier}}' - scope: entity.name.module.c++ - push: module-identifier - # import "header"; - - match: '"' - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: meta.module.import.c++ string.quoted.double.import.c++ - - match: '"' - scope: punctuation.definition.string.end.c++ - pop: true - # import
; - - match: \< - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: meta.module.import.c++ string.quoted.other.lt-gt.import.c++ - - match: '>' - scope: punctuation.definition.string.end.c++ - pop: true - - include: module-error-handling + - pop-twice + - function-tail + - function-params + - lambda-template + - lambda-captures + lambda-captures: + - match: '{{identifier}}' + scope: entity.other.lambda-capture.c++ variable.parameter.c++ + - match: \] + scope: punctuation.section.brackets.end.c++ + pop: 1 + - match: (?=\=) + push: + - match: (?=[,\]]) + pop: 1 + - include: expression + - include: expression + lambda-template: + - match: (?=\<) + push: type.template + - match: \( + scope: meta.group.c++ punctuation.section.group.begin.c++ + pop: 1 + - match: (?=->) + pop: 2 # skip params + - include: expression-identifiers + - match: (?=\{) + pop: 2 # skip params - - match: '\b(module)(\s+)?' + generic: # override, replace with {} constructor + - match: ({{identifier}})\s*(\{) captures: - 1: keyword.control.c++ - push: - - meta_scope: meta.module.c++ - # Module name. - - match: '{{module_identifier}}' - scope: entity.name.module.c++ - push: module-identifier - # Module partition - check for invalid partition names. - - match: (\:)\s*(private)(?:\s*(\:))? - captures: - 1: punctuation.accessor.c++ - 2: entity.name.partition.private - 3: invalid.illegal.unexpected-character.c++ - - include: module-error-handling - - template-common: - # Exit the template scope if we hit some basic invalid characters. This - # helps when a user is in the middle of typing their template types and - # prevents re-highlighting the whole file until the next > is found. - - match: (?=[{};]) - pop: true - - include: expressions - - template: - - match: \btemplate\b - scope: keyword.declaration.template.c++ - push: - - meta_scope: meta.template.c++ - # Explicitly include comments here at the top, in order to NOT match the - # \S lookahead in the case of comments. - - include: comments - - match: < - scope: punctuation.definition.generic.begin.c++ - set: - - meta_content_scope: meta.template.c++ - - match: '>' - scope: meta.template.c++ punctuation.definition.generic.end.c++ - set: - - include: constraint-requires - - match: (?=\S) - pop: true - - match: \.{3} - scope: keyword.operator.variadic.c++ - - match: \b(typename|{{before_tag}})\b - scope: keyword.declaration.c++ - - include: template # include template here for nested templates - - include: template-common + 1: variable.function.c++ + 2: meta.block.c punctuation.section.block.begin.c++ + push: enclosure.inner-block + + class: + - match: ({{identifier}})(?=\s*;) + scope: entity.name.class.forward-declare.c++ + pop: 1 + - match: (?={{identifier}}|:|\{) + set: + - class-body-start + - class-inherit + - class-final + - likely-macro + - class-name + - likely-macro + class-name: + - include: punctuation.qualifier + - match: (?={{identifier}}) + branch_point: class-name + branch: [class-name-body, consume-ident] + - include: else-pop + class-name-body: + - match: ({{identifier}}) + scope: entity.name.class.c++ + set: + - include: template + - match: '::' + fail: class-name - match: (?=\S) - set: - - meta_content_scope: meta.template.c++ - - match: \b({{before_tag}})\b - scope: keyword.declaration.c++ - - include: template-common - - requires: - - match: \brequires\b - scope: keyword.operator.word.c++ - push: function-definition-params - - constraint: - - match: (?=;) - pop: true - - include: requires - - include: expressions-minus-generic-type-function-call - - constraint-requires: - - match: '\brequires\b' + pop: 2 + - match: (::) + fail: class-name + - include: else-pop + class-final: + - match: \bfinal(?!\s*;)\b scope: storage.modifier.c++ - push: - - meta_scope: meta.constraint.c++ - - match: (?=\{|{{identifier}}\s*{{identifier}}\(|{{before_tag}}|:) - pop: true - - include: constraint - - generic-type: - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}}\s*(\(|\{))' - push: - - meta_scope: meta.function-call.c++ - - match: \btemplate\b - scope: keyword.declaration.template.c++ - - match: (?:(::)\s*)?({{identifier}})\s*(<) - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.definition.generic.begin.c++ - push: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - match: (?:(::)\s*)?({{identifier}})\s*(\() - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: (?:(::)\s*)?({{identifier}})\s*(\{) - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\}' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - include: identifiers - - include: angle-brackets - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\}' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}})' - push: - - include: identifiers - - match: '<' - scope: punctuation.definition.generic.begin.c++ - set: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call + - include: else-pop + class-inherit: + - match: ':' + scope: punctuation.separator.inheritance.c++ + push: class-inherit.body + - include: else-pop + class-inherit.body: + - include: keyword.storage + - include: punctuation.comma + - match: (?={{qualified}}) + push: + - meta_scope: entity.other.inherited-class.c++ + - include: qualified-ident + - include: else-pop + class-body-start: + - meta_scope: meta.class.c++ + - match: \{ + scope: meta.block.c++ punctuation.section.block.begin.c++ + set: class-body + - include: else-pop + class-body: + - meta_scope: meta.block.c++ meta.class.c++ + - include: enclosure.outer-block + + qualified-ident: + - match: \btypename\b + scope: storage.modifier.c++ + - match: '::' + scope: punctuation.accessor.double-colon.c++ + - match: '{{identifier}}' + push: qualified-ident-body + - include: else-pop + qualified-ident-body: + - match: '::' + scope: punctuation.accessor.double-colon.c++ + pop: 1 + - include: template + - match: (?=\S) + pop: 2 - angle-brackets: - - match: '<(?!<)' + template: + - match: (?=<([^<=]|$)) + branch_point: template + branch: [try-template, template.fail] + try-template: + - meta_scope: meta.template.c++ + - match: < scope: punctuation.definition.generic.begin.c++ - push: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - block: - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - function-call: - - match: (?={{path_lookahead}}\s*(\(|\{)) - push: - - meta_scope: meta.function-call.c++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.c++ - 2: variable.function.c++ - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\)' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\}' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - members-inside-function-call: - - meta_content_scope: meta.method-call.c++ meta.group.c++ - - match: \) - scope: meta.method-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - members-after-accessor-junction: - # After we've seen an accessor (dot or arrow), this context decides what - # kind of entity we're accessing. - - include: comments - - match: \btemplate\b - scope: meta.method-call.c++ keyword.declaration.template.c++ - # Guaranteed to be a template member function call after we match this - set: - - meta_content_scope: meta.method-call.c++ - - include: comments - - match: '{{identifier}}' - scope: variable.function.member.c++ - set: - - meta_content_scope: meta.method-call.c++ - - match: \( - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - - include: comments - - include: angle-brackets - - match: (?=\S) # safety pop - pop: true - - match: (?=\S) # safety pop - pop: true - # Operator overloading - - match: '({{operator_method_name}})\s*(\()' + set: try-template-body + try-template-body: + - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) + fail: template + - match: (?=\&\&\s*[^>,]) + fail: template + - match: '>' + scope: punctuation.definition.generic.end.c++ + pop: true + - include: expression + template.fail: + - match: < + scope: keyword.operator.comparison.c++ + - include: pop-immediately + + label: + - match: '({{identifier}})\s*(:)(?!:)' + captures: + 1: entity.name.label.c++ + 2: punctuation.separator.c++ + + access-not-fn: + - meta_prepend: true + - match: \< + fail: access + + keyword: + - meta_append: true + - match: \b(?:export|friend|operator)\b + scope: keyword.other.c++ + keyword.type: + - meta_prepend: true + - match: \b(?:w?char(?:8|16|32)_t)|wchar_t\b + scope: storage.type.c++ + - match: \b(decltype)\s*(\() captures: - 0: meta.method-call.c++ - 1: variable.function.member.c++ + 1: keyword.declaration.type.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - # Non-templated member function call - - match: (~?{{identifier}})\s*(\() + push: enclosure.parenthesis + - match: \bdecltype\b + scope: keyword.declaration.type.c++ + keyword.storage: + - meta_prepend: true + - match: '\b(?:private|protected|public)\s*:' + scope: storage.modifier.c++ + - match: \b(?:const(?:expr|eval|init)|explicit|mutable|private|protected|public|virtual|typename|alignas)\b + scope: storage.modifier.c++ + keyword.control: + - meta_prepend: true + - match: '\b(catch)\s*(\()' captures: - 0: meta.method-call.c++ - 1: variable.function.member.c++ + 1: keyword.control.exception.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - # Templated member function call - - match: (~?{{identifier}})\s*(?={{generic_lookahead}}) - captures: - 1: variable.function.member.c++ - set: - - meta_scope: meta.method-call.c++ - - match: < - scope: punctuation.definition.generic.begin.c++ - set: - - meta_content_scope: meta.method-call.c++ - - match: '>' - scope: punctuation.definition.generic.end.c++ - set: - - meta_content_scope: meta.method-call.c++ - - include: comments - - match: \( - scope: punctuation.section.group.begin.c++ - set: members-inside-function-call - - match: (?=\S) # safety pop - pop: true - - include: expressions - # Explicit base-class access - - match: ({{identifier}})\s*(::) + push: function-params + - match: \b(?:try|catch|finally|throw)\b + scope: keyword.control.exception.c++ + - match: \bco_(?:await|yield|return)\b + scope: keyword.control.c++ + - match: \b(requires)\s*(\() captures: - 1: variable.other.base-class.c++ - 2: punctuation.accessor.double-colon.c++ - set: members-after-accessor-junction # reset - # Just a regular member variable - - match: '{{identifier}}' - scope: variable.other.readwrite.member.c++ - pop: true - - members-dot: - - include: scope:source.c#access-illegal - # No lookahead required because members-dot goes after operators in the - # early-expressions-after-generic-type context. This means triple dots - # (i.e. "..." or "variadic") is attempted first. - - match: \. - scope: punctuation.accessor.dot.c++ - push: members-after-accessor-junction + 1: keyword.operator.word.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: [function-tail, function-params] + - match: \brequires\b + scope: keyword.operator.word.c++ - members-arrow: - # This needs to be before operators in the - # early-expressions-after-generic-type context because otherwise the "->" - # from the C language will match. - - match: -> - scope: punctuation.accessor.arrow.c++ - push: members-after-accessor-junction + constant: + - meta_prepend: true + - match: \bthis\b + scope: variable.language.c++ + - match: \bm_[[:alpha:]_$][[:alnum:]_$]*\b + scope: variable.other.readwrite.member.c++ - using-alias: - # consume keyword if followed by typename - - match: '\b(using)\b(?=\s+typename\b)' - captures: - 1: keyword.control.c++ - - match: '\b(using)\b\s+({{identifier}})(?!\s*(<|::))' + punctuation: + - meta_prepend: true + - include: punctuation.qualifier + punctuation.qualifier: + - match: (::) + scope: punctuation.accessor.double-colon.c++ + + keyword.operator: # needs precedence over the < comparison + - meta_prepend: true + - include: template + operator.bitwise: + - match: \&|\||\^|~(?!{{identifier}}\s*\()|<<|>> + scope: keyword.operator.bitwise.c++ + operator.word: + - meta_prepend: true + - match: \b(?:(?:const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b + scope: keyword.operator.word.c++ + - match: \b(?:and|xor|or|not)(?:_eq)?\b + scope: keyword.operator.logical.c++ + - match: \b(?:bit(?:and|or)|compl)\b + scope: keyword.operator.bitwise.c++ + operator.comparison: + - meta_prepend: true + - match: <=> + scope: keyword.operator.comparison.c++ + + string: + - meta_prepend: true + - match: (R)(\")([^\s]*)(\() captures: - 1: keyword.control.c++ - 2: entity.name.type.using.c++ - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.c++ - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.c++ - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions-minus-generic-type - - parens: - - match: \( - scope: punctuation.section.group.begin.c++ - push: - - meta_scope: meta.group.c++ - - match: \) - scope: punctuation.section.group.end.c++ - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.c++ - push: - - meta_scope: meta.brackets.c++ - - match: \] - scope: punctuation.section.brackets.end.c++ - pop: true - - include: expressions - - function-trailing-return-type: - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - - include: identifiers - - match: \*|& - scope: keyword.operator.c++ - - include: function-trailing-return-type-parens - - match: '(?=\S)' - pop: true - - function-trailing-return-type-parens: - - match: \( - scope: punctuation.section.group.begin.c++ - push: - - meta_scope: meta.group.c++ - - match: \) - scope: punctuation.section.group.end.c++ - pop: true - - include: function-trailing-return-type - - ## Detection of function and data structure definitions at the global level - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - # Constructors and destructors don't have a type - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*{{identifier}}\s*\()' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.constructor.c++ - - match: '(?=[^\w\s])' - set: function-definition-params - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*~{{identifier}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?(~{{identifier}})' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.destructor.c++ - - match: '(?=[^\w\s])' - set: function-definition-params - # If we see a path ending in :: before a newline, we don't know if it is - # a constructor or destructor, or a long return type, so we are just going - # to treat it like a regular function. Most likely it is a constructor, - # since it doesn't seem most developers would create such a long typename. - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*$)' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(::)\s*$' - captures: - 1: punctuation.accessor.double-colon.c++ - - match: '(?:(::)\s*)?(~?{{identifier}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - match: '(?=[^\w\s])' - set: function-definition-params - - include: unique-strings - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.c++ - set: - - include: identifiers - - match: '' - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '(?={{path_lookahead}}\s*\()' - set: - - include: function-call - - match: '' - pop: true - - include: variables - - include: constants - - include: identifiers - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.c++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Operator overloading - - match: '(?=({{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*)?{{operator_method_name}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?({{operator_method_name}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - match: '(?=\s*(\(|$))' - set: function-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\(|$)))' - push: - - include: identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*(\(|$))' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\(|$))' - set: [function-definition-params, global-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [function-definition-params, global-function-identifier] - - match: '(?=\S)' - pop: true - - global-function-identifier-generic: - - meta_content_scope: meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})(?=\s*(<.*>)?\s*\()' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - match: '(?=\()' - pop: true - - global-function-identifier: - - meta_content_scope: meta.toc-list.full-identifier.c++ - - match: '(?:(::)\s*)?({{identifier}})(?!\s*(::))' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.c++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function.parameters.c++ meta.group.c++ - - match : \) - scope: punctuation.section.group.end.c++ - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.c++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.c++ - set: function-definition-trailing-return - - include: function-specifiers - - include: constraint-requires - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '&' - scope: keyword.operator.c++ - - match: \b0\b - scope: meta.number.integer.decimal.c++ constant.numeric.value.c++ - - match: \b(default|delete)\b - scope: storage.modifier.c++ - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: function-definition-body - - include: function-specifiers - - include: constraint-requires - - include: function-trailing-return-type - - function-definition-body: - - meta_content_scope: meta.function.c++ meta.block.c++ - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.function.c++ meta.block.c++ - - match: '\}' - scope: meta.function.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Data structures including classes, structs, unions and enums - - data-structures: - - match: '\bclass\b' - scope: keyword.declaration.class.c++ - set: data-structures-class-definition - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{path_lookahead}}\s+{{path_lookahead}}\s*[=;\[])' - scope: keyword.declaration.c++ - - match: '\bstruct\b' - scope: keyword.declaration.struct.type.c++ - set: data-structures-struct-definition - - match: '\benum(\s+(class|struct))?\b' - scope: keyword.declaration.enum.type.c++ - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.type.c++ - set: data-structures-union-definition - - match: '\bconcept\b' - scope: meta.concept.c++ keyword.declaration.concept.c++ - set: data-structures-concept-definition - - match: '(?=\S)' - pop: true - - preprocessor-workaround-eat-macro-before-identifier: - # Handle macros so they aren't matched as the class name - - match: ({{macro_identifier}})(?=\s+~?{{identifier}}) - captures: - 1: meta.assumed-macro.c - - match: '({{macro_identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - data-structures-class-definition: - - meta_scope: meta.class.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.class.forward-decl.c++ - set: data-structures-class-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.class.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.class.c++ - set: data-structures-class-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-class-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-class-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-class-definition-after-identifier: - - meta_content_scope: meta.class.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.class.c++ meta.block.c++ - - match: '\}' - scope: meta.class.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - data-structures-struct-definition: - - meta_scope: meta.struct.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.struct.forward-decl.c++ - set: data-structures-struct-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.struct.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.struct.c++ - set: data-structures-struct-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-struct-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-struct-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-identifier: - - meta_content_scope: meta.struct.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.struct.c++ meta.block.c++ - - match: '\}' - scope: meta.struct.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.enum.forward-decl.c++ - set: data-structures-enum-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.enum.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.enum.c++ - set: data-structures-enum-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-enum-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-enum-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-identifier: - - meta_content_scope: meta.enum.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.enum.c++ meta.block.c++ - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: statements-enum - - data-structures-union-definition: - - meta_scope: meta.union.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.union.forward-decl.c++ - set: data-structures-union-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.union.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.union.c++ - set: data-structures-union-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-union-definition-after-identifier - - match: '(?=[{])' - set: data-structures-union-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-identifier: - - meta_content_scope: meta.union.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - # Unions don't support base classes - - include: angle-brackets - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.union.c++ meta.block.c++ - - match: '\}' - scope: meta.union.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - match: '(?=;)' - pop: true - - data-structures-concept-definition: - - meta_content_scope: meta.concept.c++ - - include: data-structures-definition-common-begin - - match: '({{identifier}})\s+(=)' - captures: - 1: entity.name.concept.c++ - 2: keyword.operator.assignment.c++ - set: - - meta_content_scope: meta.concept.c++ meta.constraint.c++ - - include: constraint - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - include: preprocessor-workaround-eat-macro-before-identifier - - data-structures-definition-common-end: - - include: angle-brackets - - match: \bfinal\b - scope: storage.modifier.c++ - - match: ':' - scope: punctuation.separator.c++ - push: - - include: comments - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - match: '\b(virtual|{{visibility_modifiers}})\b' - scope: storage.modifier.c++ - - match: (?={{path_lookahead}}) - push: - - meta_scope: entity.other.inherited-class.c++ - - include: identifiers - - match: '' - pop: true - - include: angle-brackets - - match: ',' - scope: punctuation.separator.c++ - - match: (?=\{|;) - pop: true - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: data-structures-modifier - - include: using-namespace - - include: typedef - - include: using-alias - - match: \b({{visibility_modifiers}})\s*(:)(?!:) - captures: - 1: storage.modifier.c++ - 2: punctuation.section.class.c++ - - match: '^\s*(?=(?:~?\w+|::))' - push: data-structures-modifier - - include: expressions-minus-generic-type - - data-structures-modifier-friend: - - match: (?=;) - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_scope: meta.block.c++ - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - include: expressions-minus-function-call - - data-structures-modifier: - - match: '\bfriend\b' - scope: storage.modifier.c++ - push: - - include: comments - - match: '\b({{before_tag}})\b' - scope: keyword.declaration.c++ - set: data-structures-modifier-friend - - match: '(?=\S)(?=[^;]+;)' - set: data-structures-modifier-friend - - match: '(?=\S)' - pop: true - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '\bstatic_assert(?=\s*\()' - scope: meta.static-assert.c++ keyword.operator.word.c++ - push: - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\)' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - # Destructor - - match: '(?:{{identifier}}\s*(::)\s*)?~{{identifier}}(?=\s*(\(|$))' - scope: meta.method.destructor.c++ entity.name.function.destructor.c++ - captures: - 1: punctuation.accessor.c++ - set: method-definition-params - # It's a macro, not a constructor if there is no type in the first param - - match: '({{identifier}})\s*(\()(?=\s*(?!void){{identifier}}\s*[),])' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - # Constructor - - include: preprocessor-workaround-eat-macro-before-identifier - - match: '((?!{{before_tag}}|template){{identifier}})(?=\s*\()' - scope: meta.method.constructor.c++ entity.name.function.constructor.c++ - set: method-definition-params - # Long form constructor - - match: '({{identifier}}\s*(::)\s*{{identifier}})(?=\s*\()' - captures: - 1: meta.method.constructor.c++ entity.name.function.constructor.c++ - 2: punctuation.accessor.c++ - push: method-definition-params - - match: '(?=\S)' - set: data-structures-type - - data-structures-type: - - include: comments - - match: \*|& - scope: keyword.operator.c++ - # Cast methods - - match: '(operator)\s+({{identifier}})(?=\s*(\(|$))' - captures: - 1: keyword.control.c++ - 2: meta.method.c++ entity.name.function.c++ - set: method-definition-params - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: data-structures-maybe-method - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.c++ - set: - - include: identifiers - - match: '' - set: data-structures-maybe-method - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: variables - - include: constants - - include: identifiers - - match: (?=[&*]) - set: data-structures-maybe-method - - match: (?=\W) - pop: true - - data-structures-maybe-method: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.c++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # Operator overloading - - match: '{{operator_method_name}}(?=\s*(\(|$))' - scope: meta.method.c++ entity.name.function.c++ - set: method-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\()))' - push: - - include: identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}})\s*(\())' - set: [method-definition-params, data-structures-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\())' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?=\S)' - pop: true - - data-structures-function-identifier-generic: - - include: angle-brackets - - match: '(?={{identifier}})' - push: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=<)' - pop: true - - match: '(?=\()' - pop: true - - data-structures-function-identifier: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - method-definition-params: - - meta_content_scope: meta.method.c++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.method.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.method.parameters.c++ meta.group.c++ - - match : \) - scope: punctuation.section.group.end.c++ - set: method-definition-continue - - match: '\bvoid\b' - scope: storage.type.c++ - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: expressions-minus-generic-type - - match: '(?=\S)' - pop: true - - method-definition-continue: - - meta_content_scope: meta.method.c++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.c++ - set: method-definition-trailing-return - - include: function-specifiers - - include: constraint-requires - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '&' - scope: keyword.operator.c++ - - match: \b0\b - scope: meta.number.integer.decimal.c++ constant.numeric.value.c++ - - match: \b(default|delete)\b - scope: storage.modifier.c++ - - match: '(?=:)' - set: - - match: ':' - scope: punctuation.separator.initializer-list.c++ - set: - - meta_scope: meta.method.constructor.initializer-list.c++ - - match: '{{identifier}}' - scope: variable.other.readwrite.member.c++ - push: - - match: \( - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.group.c++ - - match: \) - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: \{ - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.group.c++ - - match: \} - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - include: comments - - match: (?=\{|;) - set: method-definition-continue - - include: expressions - - match: '(?=\{)' - set: method-definition-body - - match: '(?=\S)' - pop: true - - method-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: method-definition-body - - include: function-specifiers - - include: function-trailing-return-type - - method-definition-body: - - meta_content_scope: meta.method.c++ meta.block.c++ - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.method.c++ meta.block.c++ - - match: '\}' - scope: meta.method.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - include: preprocessor-practical-workarounds - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.c++ - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.c++ - pop: true - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*(endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.c++ - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{path_lookahead}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.c++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - 2: punctuation.accessor.c++ - - match: '(?:(::)\s*)?{{identifier}}' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: preprocessor-if-branch-function-call-arguments - - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match : \) - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: \) - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.c++ - pop: true - - match: \} - scope: meta.block.c++ punctuation.section.block.end.c++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.c++ - push: - - match: '\{' - scope: punctuation.section.block.begin.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.c++ keyword.control.import.define.c++ - push: - - meta_content_scope: meta.preprocessor.macro.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.c++ - set: - - match: '\(' - scope: punctuation.section.group.begin.c++ - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.c++ - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.c++ meta.group.c++ - - match: '{{identifier}}' - scope: variable.parameter.c++ - - match: \) - scope: punctuation.section.group.end.c++ - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.c++ - push: - - match: '{{identifier}}' - scope: variable.parameter.c++ - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c++ - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.c++ - captures: - 1: punctuation.definition.comment.c++ - 2: punctuation.definition.comment.c++ - - match: '\S+' - scope: invalid.illegal.unexpected-character.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c++ - - match: (/\*).*(\*/) - scope: comment.block.c++ - captures: - 1: punctuation.definition.comment.c++ - 2: punctuation.definition.comment.c++ - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.c++ - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.c++ - - match: '\}' - scope: punctuation.section.block.end.c++ - # Captures the namespace macro idiom - - match: '\b(namespace)\s+(?={{path_lookahead}}\s*\{)' - scope: meta.namespace.c++ - captures: - 1: keyword.control.c++ - push: - - meta_content_scope: meta.namespace.c++ entity.name.namespace.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - include: expressions - - preprocessor-practical-workarounds: - - include: preprocessor-convention-ignore-uppercase-ident-lines - - include: scope:source.c#preprocessor-convention-ignore-uppercase-calls-without-semicolon - - preprocessor-convention-ignore-uppercase-ident-lines: - - match: ^(\s*{{macro_identifier}})+\s*$ - scope: meta.assumed-macro.c++ - push: - # It's possible that we are dealing with a function return type on its own line, and the - # name of the function is on the subsequent line. - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*\()' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*\()' - set: [function-definition-params, global-function-identifier] - - match: ^ - pop: true - - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.c++ - push: - - meta_scope: meta.preprocessor.diagnostic.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.c++ - - match: ^\s*(#\s*(?:include|include_next|embed|import))\b - captures: - 1: keyword.control.import.include.c++ - push: - - meta_scope: meta.preprocessor.include.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.double.include.c++ - - match: '"' - scope: punctuation.definition.string.end.c++ - pop: true - - match: < - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.other.lt-gt.include.c++ - - match: '>' - scope: punctuation.definition.string.end.c++ - pop: true - - include: preprocessor-practical-workarounds + 1: storage.type.string.c++ + 2: punctuation.definition.string.begin.c++ + 3: constant.other.placeholder.c++ + 4: constant.other.placeholder.c++ + push: string.raw + string.double: + - meta_prepend: true + - match: (\")({{literal_operator}})? + captures: + 1: punctuation.definition.string.end.c++ + 2: variable.function.c++ + pop: 1 + string.single: + - meta_prepend: true + - match: (\')({{literal_operator}})? + captures: + 1: punctuation.definition.string.end.c++ + 2: variable.function.c++ + pop: 1 + string.raw: + - meta_scope: string.quoted.double.raw.c++ + - match: (\)\3)(\")({{literal_operator}})? + captures: + 1: constant.other.placeholder.c++ + 2: punctuation.definition.string.end.c++ + 3: variable.function.c++ + pop: true + string-format: + - meta_prepend: true + - match: '{}' + scope: constant.other.placeholder.c++ + + consume-ident: + - match: \b{{identifier}}\b + - include: pop-immediately +variables: + literal_operator: '[[:alpha:]_$]+' + double_suffix: '(?![xb]|\w+\d){{literal_operator}}' + integer_suffix: '(?![xb]|\w+\d){{literal_operator}}' + identifier: (?:\b|(?=\$))[[:alpha:]_$][[:alnum:]_$]*(?:\b|\$) + qualified: (?:::\s*)?(?:{{identifier}}(?:\s*:{0,2}\s*)?)+ + attribute_item: '(?:(?:gnu|clang)::{{gnu_attribute_item}}|deprecated|noreturn|likely|unlikely|no_unique_address|fallthrough|nodiscard|maybe_unused|noreturn|unsequenced|reproducible)' + attribute_func: '(?:(?:gnu|clang)::{{gnu_attribute_func}}|deprecated|nodiscard|assume)' diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 779b35d7b7..eb2bcaa4ff 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -3,6 +3,7 @@ # http://www.sublimetext.com/docs/3/syntax.html name: C scope: source.c +version: 2 file_extensions: - c @@ -13,1427 +14,901 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \bc\b(?![#+]) .*? -\*- # editorconfig ) -variables: - # number digits - bin_digit: '[01'']' - oct_digit: '[0-7'']' - dec_digit: '[\d'']' - hex_digit: '[\h'']' - - # number exponents - dec_exponent: '(?:[eE][-+]?{{dec_digit}}*)' - hex_exponent: '(?:[pP][-+]?{{dec_digit}}*)' - - # number suffixes - bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' - oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' - dec_suffix: '[a-zA-Z_][[:alnum:]_]*' - hex_suffix: '[g-zG-Z_][[:alnum:]_]*' - double_suffix: 'df|DF|dd|DD|dl|DL|[fFlL]' - integer_suffix: 'u?wb|[lL]{1,2}[uU]?|[uU][lL]{0,2}' - - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - control_keywords: 'break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|_Decimal(32|64|128)|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum' - microsoft_types: '__int8|__int16|__int32|__int64' - windows_types: 'APIENTRY|ATOM|BOOL|BOOLEAN|BYTE|CALLBACK|CCHAR|CHAR|COLORREF|CONST|DWORD|DWORDLONG|DWORD_PTR|DWORD32|DWORD64|FLOAT|HACCEL|HALF_PTR|HANDLE|HBITMAP|HBRUSH|HCOLORSPACE|HCONV|HCONVLIST|HCURSOR|HDC|HDDEDATA|HDESK|HDROP|HDWP|HENHMETAFILE|HFILE|HFONT|HGDIOBJ|HGLOBAL|HHOOK|HICON|HINSTANCE|HKEY|HKL|HLOCAL|HMENU|HMETAFILE|HMODULE|HMONITOR|HPALETTE|HPEN|HRESULT|HRGN|HRSRC|HSZ|HWINSTA|HWND|INT|INT_PTR|INT8|INT16|INT32|INT64|LANGID|LCID|LCTYPE|LGRPID|LONG|LONGLONG|LONG_PTR|LONG32|LONG64|LPARAM|LPBOOL|LPBYTE|LPCOLORREF|LPCSTR|LPCTSTR|LPCVOID|LPCWSTR|LPDWORD|LPHANDLE|LPINT|LPLONG|LPSTR|LPTSTR|LPVOID|LPWORD|LPWSTR|LRESULT|PBOOL|PBOOLEAN|PBYTE|PCHAR|PCSTR|PCTSTR|PCWSTR|PDWORD|PDWORDLONG|PDWORD_PTR|PDWORD32|PDWORD64|PFLOAT|PHALF_PTR|PHANDLE|PHKEY|PINT|PINT_PTR|PINT8|PINT16|PINT32|PINT64|PLCID|PLONG|PLONGLONG|PLONG_PTR|PLONG32|PLONG64|POINTER_32|POINTER_64|POINTER_SIGNED|POINTER_UNSIGNED|PSHORT|PSIZE_T|PSSIZE_T|PSTR|PTBYTE|PTCHAR|PTSTR|PUCHAR|PUHALF_PTR|PUINT|PUINT_PTR|PUINT8|PUINT16|PUINT32|PUINT64|PULONG|PULONGLONG|PULONG_PTR|PULONG32|PULONG64|PUSHORT|PVOID|PWCHAR|PWORD|PWSTR|QWORD|SC_HANDLE|SC_LOCK|SERVICE_STATUS_HANDLE|SHORT|SIZE_T|SSIZE_T|TBYTE|TCHAR|UCHAR|UHALF_PTR|UINT|UINT_PTR|UINT8|UINT16|UINT32|UINT64|ULONG|ULONGLONG|ULONG_PTR|ULONG32|ULONG64|UNICODE_STRING|USHORT|USN|VOID|WCHAR|WINAPI|WORD|WPARAM' - complex: 'complex|imaginary' - fenv: 'fenv_t|fexcept_t' - setjmp: 'jmp_buf' - signal: 'sig_atomic_t' - stdarg: 'va_list' - stdatomic: 'atomic_(bool|char|schar|uchar|short|ushort|int|uint|long|ulong|llong|ullong|char8_t|char16_t|char32_t|wchar_t|int_least8_t|uint_least8_t|int_least16_t|uint_least16_t|int_least32_t|uint_least32_t|int_least64_t|uint_least64_t|int_fast8_t|uint_fast8_t|int_fast16_t|uint_fast16_t|int_fast32_t|uint_fast32_t|int_fast64_t|uint_fast64_t|intptr_t|uintptr_t|size_t|ptrdiff_t|intmax_t|uintmax_t|flag)|memory_order' - stdint: 'int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t' - stdio: 'FILE|fpos_t' - stdlib: 'div_t|ldiv_t|lldiv_t|imaxdiv_t' - stddef: 'size_t|ptrdiff_t|max_align_t|nullptr_t' - time: 'time_t|clock_t' - threads: 'thrd_t|thrd_start_t|mtx_t|cnd_t|tss_t|tss_dtor_t|once_flag' - wchar: 'wchar_t|wint_t|wctrans_t|wctype_t' - uchar: 'mbstate_t|char8_t|char16_t|char32_t' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|extern|register|thread_local|_Thread_local|constexpr|{{declspec}}' - type_qualifier: 'const|volatile|_Atomic' - compiler_directive: 'inline|restrict|__restrict__|__restrict|_Noreturn|noreturn' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}' - non_func_keywords: 'if|for|switch|while|decltype|typeof|typeof_unqual|_Atomic|_BitInt|sizeof|alignof|_Alignof|alignas|_Alignas|static_assert|_Static_assert|__declspec|__attribute__' - contexts: main: - - include: preprocessor-global - - include: global + - include: function + - match: (?=\S) + push: statement - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the C++ - # syntax. They are specifically constructed to not push into sub-contexts, - # which ensures that C++ code isn't accidentally lexed as plain C. They also - # should not use the {{identifier}} variable since that is different for C++. - ############################################################################# + prototype: + - include: comment + - include: preprocessor + - match: ^\s*({{likely_macro}})\s*$ + captures: + 1: meta.assumed-macro.c - comments: - - include: block-comments - - include: line-comments +###[ PREPROCESSOR ]############################################################ - block-comments: - - match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n? - scope: comment.block.banner.c - captures: - 1: punctuation.definition.comment.begin.c - 2: meta.toc-list.banner.block.c - 3: punctuation.definition.comment.end.c - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.c punctuation.definition.comment.c - # documentation block comments - - match: (?:/\*!|/\*{2,}) - scope: punctuation.definition.comment.begin.c - push: block-comment-documentation-body - # normal block comments + comment: + - match: // + scope: punctuation.definition.comment.c + push: comment.line - match: /\* - scope: punctuation.definition.comment.begin.c - push: block-comment-body - # stray block comment end - - match: \*+/(?!\*) + scope: punctuation.definition.comment.c + push: comment.block + - match: \*/ scope: invalid.illegal.stray-comment-end.c + comment.line: + - meta_scope: comment.line.double-slash.c + - include: preprocessor.line-escape + - include: eol-pop + comment.block: + - meta_scope: comment.block.c + - include: preprocessor.line-escape + - match: \*/ + scope: punctuation.definition.comment.c + pop: 1 - block-comment-documentation-body: - - meta_include_prototype: false - - meta_scope: comment.block.documentation.c - - match: \*+/ - scope: punctuation.definition.comment.end.c - pop: true - - match: ^\s*(\*)(?!\**/) + preprocessor: + - include: preprocessor.line-escape + - include: comment + + - match: '{{dir_start}}((?:el)?if(?:n?def)?|undef|pragma)\b' + scope: keyword.control.import.c + push: + - meta_scope: meta.preprocessor.c + - include: preprocessor.line-escape + - include: comment + - include: eol-pop + + - match: '{{dir_start}}(?:else|endif)\b' + scope: keyword.control.import.c + + - match: '{{dir_start}}(?:include|include_next)\b' + scope: keyword.control.import.c + push: preprocessor.include + + - match: '{{dir_start}}embed\b' + scope: keyword.control.import.c + push: preprocessor.embed + + - match: '{{dir_start}}define\b' + scope: keyword.control.import.c + push: preprocessor.define + + - match: '{{dir_start}}error\b' + scope: keyword.control.import.error.c + push: preprocessor.diagnostic + + - match: '{{dir_start}}warning\b' + scope: keyword.control.import.warning.c + push: preprocessor.diagnostic + + - match: '{{dir_start}}(?!\s*{{identifier}})' + scope: keyword.control.c + preprocessor.line-escape: + - match: \\$\n + scope: punctuation.separator.continuation.c + push: + - match: ^ + pop: 1 + preprocessor.include: + - meta_scope: meta.preprocessor.include.c + - match: \" + scope: punctuation.definition.string.begin.c + push: string.double + - match: \< + scope: punctuation.definition.string.begin.c + push: string.angled + - include: comment + - include: eol-pop + preprocessor.diagnostic: + - meta_scope: meta.preprocessor.diagnostic.c + - meta_content_scope: string.unquoted.c + - include: preprocessor.line-escape + - include: eol-pop + preprocessor.define: + - meta_scope: meta.preprocessor.macro.c + - include: eol-pop + - match: \s*({{identifier}})(\() + captures: + 1: entity.name.macro.c support.macro.c + 2: meta.group.c punctuation.section.group.begin.c meta.preprocessor.macro.parameters.c + set: preprocessor.define-params + - match: '{{identifier}}' + scope: entity.name.macro.c support.macro.c + embed: preprocessor.define-body + escape: (? + scope: punctuation.definition.string.end.c + pop: 1 + string-escape: + - match: \\(?:[abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x\h+|u\h{4}|U\h{8}) scope: constant.character.escape.c - match: \\. scope: invalid.illegal.unknown-escape.c - - string_placeholder: + string-format: - match: |- (?x)% - (\d+\$)? # field (argument #) - [#0\- +']* # flags - [,;:_]? # separator character (AltiVec) - ((-?\d+)|\*(-?\d+\$)?)? # minimum field width - (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision - (hh|h|ll|l|j|t|z|q|L|H|D|DD|vh|vl|v|hv|hl|wf?[0-9]+)? # length modifier - (\[[^\]]+\]|[am]s|[diouxXbDOUeEfFgGaACcSspn%]) # conversion type + (?:\d+\$)? # field (argument #) + [#0\- +']* # flags + [,;:_]? # separator character (AltiVec) + (?:(?:-?\d+)|\*(?:-?\d+\$)?)? # minimum field width + (?:\.(?:(?:-?\d+)|\*(?:-?\d+\$)?)?)? # precision + (?:hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier + (?:\[[^\]]+\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type scope: constant.other.placeholder.c - keywords: - - match: \bbreak\b - scope: keyword.control.flow.break.c - - match: \bcontinue\b - scope: keyword.control.flow.continue.c - - match: \bgoto\b - scope: keyword.control.flow.goto.c - - match: \breturn\b - scope: keyword.control.flow.return.c - - match: \b({{control_keywords}})\b - scope: keyword.control.c - - match: \b(sizeof|alignof|_Alignof|static_assert|_Static_assert)\b + operator: + - include: operator.variadic + - include: operator.increment-decrement + - include: operator.accessor + - include: operator.assignment + - include: operator.arithmetic + - include: operator.logical + - include: operator.bitwise + - include: operator.comparison + - include: operator.word + - include: operator.ternary + operator.assignment: + - match: = + scope: keyword.operator.assignment.c + - match: \+=|-=|\*=|/=|%=|&=|\|=|\^=|<<=|>>=|>>= + scope: keyword.operator.assignment.augmented.c + operator.arithmetic: + - match: \+|-|\*|/|%|! + scope: keyword.operator.arithmetic.c + operator.logical: + - match: \&\&|\|\| + scope: keyword.operator.logical.c + operator.bitwise: + - match: \&|\||\^|~|<<|>> + scope: keyword.operator.bitwise.c + operator.comparison: + - match: ==|!=|<=|>=|<|> + scope: keyword.operator.comparison.c + operator.word: + - match: \b(?:sizeof|_Alignof|alignof|offsetof|_Static_assert|static_assert|_Pragma)\b scope: keyword.operator.word.c - - modifiers: - - match: \b({{modifiers}})\b - scope: storage.modifier.c - - variables: - - match: '\bg[A-Z]\w*\b' - scope: variable.other.readwrite.global.mac-classic.c - - match: '\bs[A-Z]\w*\b' - scope: variable.other.readwrite.static.mac-classic.c - - constants: - - match: \b(false|FALSE)\b - scope: constant.language.boolean.false.c - - match: \b(true|TRUE)\b - scope: constant.language.boolean.true.c - - match: \b(nullptr|NULL)\b - scope: constant.language.null.c - - match: \b__func__\b - scope: constant.language.c - - match: \b(__FILE__|__FUNCTION__|__LINE__)\b - scope: support.constant.c - # common C constant naming idiom -- kConstantVariable - - match: '\bk[A-Z]\w*\b' - scope: constant.other.variable.mac-classic.c - - match: \b(noErr|kNilOptions|kInvalidID|kVariableLengthArray)\b - scope: support.constant.mac-classic.c - - c99: - - match: \b(hypot(f|l)?|s(scanf|ystem|nprintf|ca(nf|lb(n(f|l)?|ln(f|l)?))|i(n(h(f|l)?|f|l)?|gn(al|bit))|tr(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(jmp|vbuf|locale|buf)|qrt(f|l)?|w(scanf|printf)|rand)|n(e(arbyint(f|l)?|xt(toward(f|l)?|after(f|l)?))|an(f|l)?)|c(s(in(h(f|l)?|f|l)?|qrt(f|l)?)|cos(h(f)?|f|l)?|imag(f|l)?|t(ime|an(h(f|l)?|f|l)?)|o(s(h(f|l)?|f|l)?|nj(f|l)?|pysign(f|l)?)|p(ow(f|l)?|roj(f|l)?)|e(il(f|l)?|xp(f|l)?)|l(o(ck|g(f|l)?)|earerr)|a(sin(h(f|l)?|f|l)?|cos(h(f|l)?|f|l)?|tan(h(f|l)?|f|l)?|lloc|rg(f|l)?|bs(f|l)?)|real(f|l)?|brt(f|l)?)|t(ime|o(upper|lower)|an(h(f|l)?|f|l)?|runc(f|l)?|gamma(f|l)?|mp(nam|file))|i(s(space|n(ormal|an)|cntrl|inf|digit|u(nordered|pper)|p(unct|rint)|finite|w(space|c(ntrl|type)|digit|upper|p(unct|rint)|lower|al(num|pha)|graph|xdigit|blank)|l(ower|ess(equal|greater)?)|al(num|pha)|gr(eater(equal)?|aph)|xdigit|blank)|logb(f|l)?|max(div|abs))|di(v|fftime)|_Exit|unget(c|wc)|p(ow(f|l)?|ut(s|c(har)?|wc(har)?)|error|rintf)|e(rf(c(f|l)?|f|l)?|x(it|p(2(f|l)?|f|l|m1(f|l)?)?))|v(s(scanf|nprintf|canf|printf|w(scanf|printf))|printf|f(scanf|printf|w(scanf|printf))|w(scanf|printf)|a_(start|copy|end|arg))|qsort|f(s(canf|e(tpos|ek))|close|tell|open|dim(f|l)?|p(classify|ut(s|c|w(s|c))|rintf)|e(holdexcept|set(e(nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(aiseexcept|ror)|get(e(nv|xceptflag)|round))|flush|w(scanf|ide|printf|rite)|loor(f|l)?|abs(f|l)?|get(s|c|pos|w(s|c))|re(open|e|ad|xp(f|l)?)|m(in(f|l)?|od(f|l)?|a(f|l|x(f|l)?)?))|l(d(iv|exp(f|l)?)|o(ngjmp|cal(time|econv)|g(1(p(f|l)?|0(f|l)?)|2(f|l)?|f|l|b(f|l)?)?)|abs|l(div|abs|r(int(f|l)?|ound(f|l)?))|r(int(f|l)?|ound(f|l)?)|gamma(f|l)?)|w(scanf|c(s(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?|mbs)|pbrk|ftime|len|r(chr|tombs)|xfrm)|to(b|mb)|rtomb)|printf|mem(set|c(hr|py|mp)|move))|a(s(sert|ctime|in(h(f|l)?|f|l)?)|cos(h(f|l)?|f|l)?|t(o(i|f|l(l)?)|exit|an(h(f|l)?|2(f|l)?|f|l)?)|b(s|ort))|g(et(s|c(har)?|env|wc(har)?)|mtime)|r(int(f|l)?|ound(f|l)?|e(name|alloc|wind|m(ove|quo(f|l)?|ainder(f|l)?))|a(nd|ise))|b(search|towc)|m(odf(f|l)?|em(set|c(hr|py|mp)|move)|ktime|alloc|b(s(init|towcs|rtowcs)|towc|len|r(towc|len))))\b - scope: support.function.C99.c - - types: - - match: \b({{before_tag}})\b - scope: keyword.declaration.c - - match: \b({{basic_types}})\b - scope: storage.type.c - - match: \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|ssize_t|useconds_t|suseconds_t)\b - scope: support.type.sys-types.c - - match: \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b - scope: support.type.pthread.c - - match: \b({{complex}})\b - scope: support.type.complex.c - - match: \b({{fenv}})\b - scope: support.type.fenv.c - - match: \b({{setjmp}})\b - scope: support.type.setjmp.c - - match: \b({{signal}})\b - scope: support.type.signal.c - - match: \b({{stdarg}})\b - scope: support.type.stdarg.c - - match: \b({{stdatomic}})\b - scope: support.type.stdatomic.c - - match: \b({{stdint}})\b - scope: support.type.stdint.c - - match: \b({{stdio}})\b - scope: support.type.stdio.c - - match: \b({{stdlib}})\b - scope: support.type.stdlib.c - - match: \b({{stddef}})\b - scope: support.type.stddef.c - - match: \b({{wchar}})\b - scope: support.type.wchar.c - - match: \b({{uchar}})\b - scope: support.type.uchar.c - - match: \b({{time}})\b - scope: support.type.time.c - - match: \b({{threads}})\b - scope: support.type.threads.c - - match: '\b({{microsoft_types}})\b' - scope: support.type.microsoft.c - - match: '\b({{windows_types}})\b' - scope: support.type.windows.c - - match: \b(AbsoluteTime|Boolean|Byte|ByteCount|ByteOffset|BytePtr|CompTimeValue|ConstLogicalAddress|ConstStrFileNameParam|ConstStringPtr|Duration|Fixed|FixedPtr|Float32|Float32Point|Float64|Float80|Float96|FourCharCode|Fract|FractPtr|Handle|ItemCount|LogicalAddress|OptionBits|OSErr|OSStatus|OSType|OSTypePtr|PhysicalAddress|ProcessSerialNumber|ProcessSerialNumberPtr|ProcHandle|Ptr|ResType|ResTypePtr|ShortFixed|ShortFixedPtr|SignedByte|SInt16|SInt32|SInt64|SInt8|Size|StrFileName|StringHandle|StringPtr|TimeBase|TimeRecord|TimeScale|TimeValue|TimeValue64|UInt16|UInt32|UInt64|UInt8|UniChar|UniCharCount|UniCharCountPtr|UniCharPtr|UnicodeScalarValue|UniversalProcHandle|UniversalProcPtr|UnsignedFixed|UnsignedFixedPtr|UnsignedWide|UTF16Char|UTF32Char|UTF8Char)\b - scope: support.type.mac-classic.c - - include: types-parens - - types-parens: - - match: '\b(typeof|__typeof|__typeof__|typeof_unqual|alignas|_Alignas|_Atomic|_BitInt)\b\s*(\()' + operator.ternary: + - match: '\?|\:' + scope: keyword.operator.ternary.c + operator.variadic: + - match: \.\.\. + scope: keyword.operator.variadic.c + operator.increment-decrement: + - match: \+\+|-- + scope: keyword.operator.arithmetic.c + operator.accessor: + - match: \.\. + scope: invalid.illegal.syntax.c + - match: (?:(\.)|(\-\>))(?=\s*{{identifier}}) captures: - 1: keyword.declaration.type.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions + 1: punctuation.accessor.dot.c + 2: punctuation.accessor.arrow.c + branch_point: access + branch: [access, pop-immediately] + - match: \.|\-\> + scope: punctuation.accessor.c + operator.pointer: + - match: \&|\* + scope: keyword.operator.c - numbers: - # https://en.cppreference.com/w/c/language/floating_constant + punctuation: + - include: punctuation.comma + - include: punctuation.semicolon + punctuation.comma: + - match: ',' + scope: punctuation.separator.c + punctuation.semicolon: + - match: ; + scope: punctuation.terminator.c + number: # decimal floats - match: |- - (?x) - ( - \b{{dec_digit}}+ + (?x: + \b(\d[\d']*) (?: - # 1., 1.f, 1.L, 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L - (\.) (?: {{dec_digit}}+ | (?!\.) ) {{dec_exponent}}? - # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L - | {{dec_exponent}} - ) - # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L - | (\.) {{dec_digit}}+ {{dec_exponent}}? + ( (\.) + (?: + # 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L + \d[\d']* {{dec_exponent}}? + # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L + | {{dec_exponent}} + # 1., 1.f, 1.L # but not `..` + | (?!\.) + ) + # 1e1 1e1f 1e1L + | {{dec_exponent}} + ) ({{double_suffix}})? + # 1f + | ({{float_suffix}}) + ) ({{dec_suffix}})? + # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L + | ( (\.) \d[\d']* {{dec_exponent}}? ) (?: ({{double_suffix}}) | ({{dec_suffix}}) )? ) - (?: ({{double_suffix}}) | ({{dec_suffix}}) )? scope: meta.number.float.decimal.c captures: 1: constant.numeric.value.c - 2: punctuation.separator.decimal.c + 2: constant.numeric.value.c 3: punctuation.separator.decimal.c 4: constant.numeric.suffix.c - 5: invalid.illegal.numeric.suffix.c - - # hexadecimal float (C99) - - match: |- - (?x) - \b(0[xX]) - ( - (?: - # 0xfp1, 0xf.p1, 0xfp1f, 0xf.p1f - {{hex_digit}}+ (\.)? - # 0x.fp1, 0xf.fp1, 0x.fp1f, 0xf.fp1f - | {{hex_digit}}* (\.) {{hex_digit}}+ - ) - {{hex_exponent}} - ) - (?: ({{double_suffix}}) | ({{dec_suffix}}) )? + 5: constant.numeric.suffix.c + 6: invalid.illegal.numeric.suffix.c + 7: constant.numeric.value.c + 8: punctuation.separator.decimal.c + 9: constant.numeric.suffix.c + 10: invalid.illegal.numeric.suffix.c + # hexadecimal float + - match: \b(0[xX])(\h*(\.)\h*{{hex_exponent}})(?:([fFlL]\b)|({{dec_suffix}}))? scope: meta.number.float.hexadecimal.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: punctuation.separator.decimal.c - 4: punctuation.separator.decimal.c - 5: constant.numeric.suffix.c - 6: invalid.illegal.numeric.suffix.c - - # https://en.cppreference.com/w/c/language/integer_constant - + 4: constant.numeric.suffix.c + 5: invalid.illegal.numeric.suffix.c # binary integer (C23) - - match: \b(0[bB])({{bin_digit}}*)(?:({{integer_suffix}})|({{bin_suffix}}))? + - match: \b(0[bB])(['01]*)?(?:({{integer_suffix}})|({{bin_suffix}}))? scope: meta.number.integer.binary.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c - # hexadecimal integer - - match: \b(0[xX])({{hex_digit}}*)(?:({{integer_suffix}})|({{hex_suffix}}))? + - match: \b(0[xX])(['\h]*)?(?:({{integer_suffix}})|({{hex_suffix}}))? scope: meta.number.integer.hexadecimal.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c - # octal integer - - match: \b(0)({{oct_digit}}+)(?:({{integer_suffix}})|({{oct_suffix}}))? + - match: \b(0)([0-7][0-7']*)(?:({{integer_suffix}})|({{oct_suffix}}))? scope: meta.number.integer.octal.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c - # decimal integer - - match: \b({{dec_digit}}+)(?:({{integer_suffix}})|({{dec_suffix}}))? + - match: \b(\d[\d']*)(?:({{integer_suffix}})|({{dec_suffix}}))? scope: meta.number.integer.decimal.c captures: 1: constant.numeric.value.c 2: constant.numeric.suffix.c 3: invalid.illegal.numeric.suffix.c - operators: - - match: (?:\+\+|--) - scope: keyword.operator.arithmetic.c - - match: '->' - scope: punctuation.accessor.c - - match: \+\=|-\=|\*\=|/\=|%\=|&\=|\|\=|\^\=|>>\=|<<\= - scope: keyword.operator.assignment.augmented.c - - match: <<|>>|&&|\|\| - scope: keyword.operator.arithmetic.c - - match: <\=|>\=|\=\=|<|>|\!\= - scope: keyword.operator.comparison.c - - match: \+|\-|/|%|\||\^|~|! - scope: keyword.operator.arithmetic.c - # These two operator can be both arithmetic and pointer/address related - - match: \*|& - scope: keyword.operator.c - - match: \= - scope: keyword.operator.assignment.c - # Negative lookahead prevents match :: when included in C++ - - match: '\?|:(?!:)' - scope: keyword.operator.ternary.c - - match: '\.\.\.' - scope: keyword.operator.variadic.c - - access-illegal: - - match: \.\.(?!\.) - scope: invalid.illegal.syntax.c - - access: - - match: '(\.)({{identifier}})(?!\s*\()' - captures: - 1: punctuation.accessor.c - 2: variable.other.member.c - - include: access-illegal - - match: \.(?!\.) - scope: punctuation.accessor.c - - label: - - match: '^\s*((?!default){{identifier}})(:)(?!:)' - captures: - 1: entity.name.label.c - 2: punctuation.separator.c - - preprocessor-disabled: - - match: ^\s*(#\s*if(n?def)?)\b - captures: - 1: meta.preprocessor.c - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c - pop: true - - include: preprocessor-disabled - - include: pragma-mark - - include: pragma-mark - - preprocessor-line-continuation: - - match: '(\\)$\n' - captures: - 1: punctuation.separator.continuation.c - - match: \\(\s+?)$ - captures: - 1: invalid.illegal.space-after-continuation.c - - preprocessor-line-ending: - - match: $\n - pop: true - - # Comment handling in preprocessor directives are complicated by the fact - # that a single-line comment will normally consume the newline to prevent - # completions from being presented to the user. Additionally, a multi-line - # comment without a line continuation ends at the newline. - preprocessor-comments: - - match: /\* - scope: punctuation.definition.comment.c - push: - - meta_scope: comment.block.c - - match: '\\$\n' - scope: punctuation.separator.continuation.c - - match: \*/ - scope: punctuation.definition.comment.c - pop: true - - match: // - scope: punctuation.definition.comment.c - push: - - meta_scope: comment.line.double-slash.c - - match: '(\\)$\n' - captures: - 1: punctuation.separator.continuation.c - pop: true - - match: (?=\n) - pop: true - - pragma-mark: - - match: ^\s*((#\s*pragma\s+mark)\s+(.*)) - scope: meta.section.c - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.pragma.c - 3: meta.toc-list.pragma-mark.c - - # Used by "inc" snippets to prevent double ##include - incomplete-inc: - - match: '^\s*(#i(nc?)?)\b\s*' - scope: meta.preprocessor.incomplete.c - - ############################################################################# - # The following are C-specific scopes that should not be reused. This is - # because they push into subcontexts and use variables that are C-specific. - ############################################################################# - - global: - - include: early-expressions - - match: '^\s*(?=\w+)' - push: global-modifier - - include: late-expressions - - statements: - - include: preprocessor-statements - - include: label - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: typedef - - include: keywords-parens - - include: keywords - - include: numbers - - include: operators - - include: strings - - include: parens - - include: brackets - - include: block - - include: variables - - include: constants - - include: access - - match: ',' - scope: punctuation.separator.c - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.c - - late-expressions: - - include: modifiers-parens - - include: modifiers - - include: types - - include: function-call - - match: ';' - scope: punctuation.terminator.c - - ## C-specific contexts - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - include: types-parens - - match: \* - scope: keyword.operator.c - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - {{identifier}} - (\s+{{identifier}}(?!\s*[{=;])|\s*\*+) - ) - ) - captures: - 1: keyword.declaration.c - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/union - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{control_keywords}})\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_scope: meta.function-call.c - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - match: (?={{identifier}}\s*\() - set: - - include: function-call - - match: '' - pop: true - - include: types - - match: '{{identifier}}' - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \* - scope: keyword.operator.c - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Identifier that is not the function name - likely a macro - - match: '{{identifier}}(?!\s*(\(|$))' - # Real function definition - - match: '{{identifier}}(?=\s*(\(|$))' - scope: meta.function.c entity.name.function.c - set: function-definition-params - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.c - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.c meta.group.c punctuation.section.group.begin.c - set: - - meta_content_scope: meta.function.parameters.c meta.group.c - - match : \) - scope: punctuation.section.group.end.c - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)))' - scope: variable.parameter.c - - include: expressions - - include: preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.c - - include: comments - - match: '(?=;)' - pop: true - - match: \b(const|final|noexcept|override)\b + constant: + - match: \b(?:true|TRUE)\b + scope: constant.language.boolean.true.c + - match: \b(?:false|FALSE)\b + scope: constant.language.boolean.false.c + - match: \b(?:NULL|nullptr)\b + scope: constant.language.null.c + - match: \b__func__\b + scope: constant.language.c + - match: \b__(?:cplusplus|[a-zA-Z_]*[a-zA-Z]__)\b + scope: support.constant.c + - match: '\bk[A-Z]\w*\b' + scope: constant.other.variable.mac-classic.c + - include: constant.malformed + constant.malformed: + - match: \b(?i:true|false|null|nullptr|__cplusplus)\b + scope: invalid.illegal.malformed-constant-language.c + + keyword: + - include: keyword.control-flow + - include: keyword.control + - include: keyword.storage + - include: keyword.declaration + - include: keyword.asm + - include: keyword.type + keyword.storage: + - match: \bauto\b + scope: storage.type.c + - match: \b(?:const|volatile|restrict|_Atomic|register|static|inline|extern|register|thread_local|_Thread_local|_Noreturn|noreturn|_Alignas)\b scope: storage.modifier.c - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-body: - - meta_content_scope: meta.function.c - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.function.c meta.block.c - - match: '\}' - scope: meta.function.c meta.block.c punctuation.section.block.end.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - data-structures: - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{identifier}}\s+{{identifier}}\s*[=;\[])' - scope: keyword.declaration.c - - match: '\bstruct\b' - scope: keyword.declaration.struct.c - set: data-structures-struct-definition - - match: '\benum\b' - scope: keyword.declaration.enum.c - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.c - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - data-structures-struct-definition: - - meta_scope: meta.struct.c - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.struct.forward-decl.c - - match: '{{identifier}}' - scope: entity.name.struct.c - set: data-structures-struct-definition-after-name - - include: data-structures-struct-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-name: - - meta_scope: meta.struct.c - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-struct-definition-block-start - - data-structures-struct-definition-block-start: - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.struct.c meta.block.c - - match: '\}' - scope: meta.struct.c meta.block.c punctuation.section.block.end.c - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.c - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.enum.forward-decl.c - - match: '{{identifier}}' - scope: entity.name.enum.c - set: data-structures-enum-definition-after-name - - include: data-structures-enum-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-name: - - meta_scope: meta.enum.c - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-enum-definition-block-start - - data-structures-enum-definition-block-start: - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.enum.c meta.block.c - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.c meta.block.c punctuation.section.block.end.c - pop: true - - include: data-structures-body-enum - - data-structures-union-definition: - - meta_scope: meta.union.c - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.union.forward-decl.c - - match: '{{identifier}}' - scope: entity.name.union.c - set: data-structures-union-definition-after-name - - include: data-structures-union-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-name: - - meta_scope: meta.union.c - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-union-definition-block-start - - data-structures-union-definition-block-start: - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.union.c meta.block.c - - match: '\}' - scope: meta.union.c meta.block.c punctuation.section.block.end.c - pop: true - - include: data-structures-body - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: modifiers-parens - - include: modifiers - - data-structures-definition-common-macro: - # Handle macros so they aren't matched as the class name - - match: '\b[[:upper:][:digit:]_]+\b(?!\s*($|\{))' - - data-structures-definition-common-end: - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - include: expressions - - data-structures-body-enum: - - include: comments - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - match: '{{identifier}}' - scope: entity.name.constant.c - push: constant-value - - match: ',' - scope: punctuation.separator.c - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - block: - - match: '\{' - scope: punctuation.section.block.begin.c - push: - - meta_scope: meta.block.c - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.c - pop: true - - include: statements - - parens: - - match: \( - scope: punctuation.section.group.begin.c - push: - - meta_scope: meta.group.c - - match: \) - scope: punctuation.section.group.end.c - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.c - push: - - meta_scope: meta.brackets.c - - match: \] - scope: punctuation.section.brackets.end.c - pop: true - - include: expressions - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.c - push: - - match: ':' - scope: punctuation.separator.c - pop: true - - include: expressions - - modifiers-parens: - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.c - 2: meta.group.c punctuation.section.group.begin.c - push : - - meta_scope: meta.attribute.c - - meta_content_scope: meta.group.c - - include: parens - - include: strings - - match: \)\) - scope: meta.group.c punctuation.section.group.end.c - pop: true - match: \b(__declspec)(\() captures: 1: storage.modifier.c 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.c - - match: ',' - scope: punctuation.separator.c - - match: '=' - scope: keyword.operator.assignment.c - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.c + push: declspec + - match: \b__declspec\b + scope: storage.modifier.c - keywords-parens: - - match: '\b(sizeof|alignof|_Alignof|static_assert|_Static_assert)\b\s*(\()' + - match: \b(__attribute__)\s*(\(\() captures: - 1: keyword.operator.word.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - typedef: + 1: storage.modifier.c + 2: punctuation.section.group.begin.c + push: gnu-attribute + keyword.declaration: + - match: \b(?:struct|enum|union)\b + scope: keyword.declaration.c - match: \btypedef\b scope: keyword.declaration.type.c - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.c - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions - - function-call: - - match: (?={{identifier}}\s*\() - push: - - meta_content_scope: meta.function-call.c - - include: c99 - - match: '{{identifier}}' - scope: variable.function.c - - match: '\(' - scope: meta.group.c punctuation.section.group.begin.c - set: - - meta_content_scope: meta.function-call.c meta.group.c - - match : \) - scope: meta.function-call.c meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-disabled - - preprocessor-if-true: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - include: preprocessor-if-true - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: incomplete-inc - - include: preprocessor-macro-define - - include: pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - include: preprocessor-if-true - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.c - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.c - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.c - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.c - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: preprocessor-global - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - include: preprocessor-if-true - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b + keyword.control-flow: + - match: \bcontinue\b + scope: keyword.control.flow.continue.c + - match: \bbreak\b + scope: keyword.control.flow.break.c + - match: \breturn\b + scope: keyword.control.flow.return.c + - match: \bgoto\b + scope: keyword.control.flow.goto.c + keyword.control: + - include: case + - match: \b(default)\s*(:) captures: - 1: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b + 1: keyword.control.case.c + 2: punctuation.separator.c + - match: \b(?:if|else|for|while|do|switch|default)\b + scope: keyword.control.c + keyword.asm: + - match: \b(?:asm|__asm|__asm__)\b + scope: keyword.control.import.c + keyword.type: + - match: \b(?:bool|void|char|short|int|long|float|double|signed|unsigned|_Complex|_Imaginary|_Bool)\b + scope: storage.type.c + - match: \b(?:u?intptr|u?intmax|ptrdiff|nullptr|max_align|size|u?int(?:_fast|_least)?(?:8|16|32|64))_t\b + scope: support.type.stdint.c + - match: \b(typeof_unqual|__typeof__|__typeof|typeof)\s*(\() captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.c - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.c - - include: c99 - - match: '{{identifier}}' - scope: variable.function.c - - match: '\(' - scope: meta.group.c punctuation.section.group.begin.c - set: preprocessor-if-branch-function-call-arguments + 1: keyword.declaration.type.c + 2: meta.group.c punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b(?:typeof_unqual|__typeof__|__typeof|typeof)\b + scope: keyword.declaration.type.c - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.c meta.group.c - - match : \) - scope: meta.function-call.c meta.group.c punctuation.section.group.end.c - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b + declspec: + - meta_content_scope: meta.group.c + - match: \b{{declspec_item}}\b + scope: constant.other.c + - match: \b({{declspec_func}})\s*(\() captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b + 1: storage.modifier.c + 2: meta.group.c punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b(property)\s*(\() captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.c meta.group.c + 1: storage.modifier.c + 2: punctuation.section.group.begin.c + push: declspec-proprty + - include: expression - match: \) - scope: meta.function-call.c meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.c - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.c - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.c - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.c - push: - - match: '\{' - scope: punctuation.section.block.begin.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements + scope: meta.group.c punctuation.section.group.end.c + pop: 1 + declspec-proprty: + - meta_content_scope: meta.group.c + - match: \b(?:get|put)\b + scope: variable.parameter.c + - include: enclosure.parenthesis - preprocessor-macro-define: - - match: ^\s*(#\s*define)\b + gnu-attribute: + - meta_scope: meta.group.c meta.attribute.c + - include: punctuation.comma + - match: \b({{gnu_attribute_func}})\s*(\() captures: - 1: meta.preprocessor.macro.c keyword.control.import.define.c - push: - - meta_content_scope: meta.preprocessor.macro.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.c - set: - - match: '\(' - scope: punctuation.section.group.begin.c - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.c - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.c meta.group.c - - match: '{{identifier}}' - scope: variable.parameter.c - - match: \) + 1: storage.modifier.c + 2: meta.group.c punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b{{gnu_attribute_item}}\b + scope: constant.other.c + - match: \)\) scope: punctuation.section.group.end.c - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.c - push: - - match: '{{identifier}}' - scope: variable.parameter.c - pop: true - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.c - captures: - 1: punctuation.definition.comment.c - 2: punctuation.definition.comment.c - - match: '\S+' - scope: invalid.illegal.unexpected-character.c - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c - - match: (/\*).*(\*/) - scope: comment.block.c - captures: - 1: punctuation.definition.comment.c - 2: punctuation.definition.comment.c - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.c - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.c - - match: '\}' - scope: punctuation.section.block.end.c - - include: expressions - - preprocessor-practical-workarounds: - - include: preprocessor-convention-ignore-uppercase-ident-lines - - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon + pop: 1 - preprocessor-convention-ignore-uppercase-ident-lines: - - match: ^(\s*{{macro_identifier}})+\s*$ - scope: meta.assumed-macro.c - push: - # It's possible that we are dealing with a function return type on its own line, and the - # name of the function is on the subsequent line. - - match: \s*({{identifier}})(?=\s*\() - captures: - 1: meta.function.c entity.name.function.c - set: function-definition-params - - match: ^ - pop: true +###[ HELPERS ]############################################################ + pop-immediately: + - match: "" + pop: 1 + else-pop: + - match: (?=\S) + pop: 1 + eol-pop: + - match: $\n? + pop: 1 + pop-twice: + - match: "" + pop: 2 - preprocessor-convention-ignore-uppercase-calls-without-semicolon: - - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$) - captures: - 1: variable.function.assumed-macro.c - 2: punctuation.section.group.begin.c - push: - - meta_scope: meta.assumed-macro.c - - match: \) - scope: punctuation.section.group.end.c - pop: true - - include: expressions +variables: + identifier: \b[[:alpha:]_][[:alnum:]_]*\b + likely_macro: \b[[:upper:]][[:upper:][:digit:]_]+\b + fn_pointer: \(\s*(\*)({{identifier}})\s*\)\s*(\() - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.c - push: - - meta_scope: meta.preprocessor.diagnostic.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.c - - match: ^\s*(#\s*(?:include|include_next|embed|import))\b - captures: - 1: keyword.control.import.include.c - push: - - meta_scope: meta.preprocessor.include.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.c - push: - - meta_scope: string.quoted.double.include.c - - match: '"' - scope: punctuation.definition.string.end.c - pop: true - - match: < - scope: punctuation.definition.string.begin.c - push: - - meta_scope: string.quoted.other.lt-gt.include.c - - match: ">" - scope: punctuation.definition.string.end.c - pop: true - - include: preprocessor-practical-workarounds + bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' + oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' + dec_suffix: '[a-zA-Z_][[:alnum:]_]*' + hex_suffix: '[g-zG-Z_][[:alnum:]_]*' + double_suffix: '[fFlL]' + float_suffix: '[fF]' + integer_suffix: '(?:(?:ll|LL)(?!\s*[lL])|(?i)(?:u(?!\w*u)|l(?!\w*l)|i(?!\w*[ij])|j(?!\w*[ij])))+\b' + dec_exponent: (?:[eE][-+]?[\d']*) + hex_exponent: (?:[pP][-+]?[\d']*) + + declspec_item: '(?:allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' + declspec_func: '(?:align|allocate|code_seg|spectre|uuid|deprecated)' + gnu_attribute_item: '(?:noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' + gnu_attribute_func: '(?:aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' + attribute_item: '(?:(?:gnu|clang)::{{gnu_attribute_item}}|deprecated|fallthrough|nodiscard|maybe_unused|noreturn|unsequenced|reproducible)' + attribute_func: '(?:(?:gnu|clang)::{{gnu_attribute_func}}|deprecated|nodiscard)' + + std_funcs: '(?:assert|(?:exp(?:2|m1)|log(?:10|2|1p)|cbrt|hypot|erfc?|[lt]gamma|ceil|floor|trunc|l{0,2}round|f(?:absmod|max|min|dim)|c(?:abs|real|imag|arg|onj|proj|)|c?(?:exp|log|pow|sqrt|a?(?:sin|cos|tan)h?))[fl]?|abs|l{0,2}div|is(?:finite|inf|nan|normal|greater(?:equal)?|less(?:equal|greater)?|unordered|alnum|alpha|lower|upper|x?digit|cntrl|graph|space|blank|print|punct)(?:set|long)jmp|jmp_buf|signal|raise|va_(?:list|start|arg|copy|end)|std(?:in|out|err)|setv?buf|re(?:wind|move|name)|tmp(?:nam|file)(?:_s)?|f(?:(?:re)?open(?:_s)?|close|flush|wide|read|write|tell|getpos|seek|setpos|error)|gets_s|f?(?:get|put)?(?:c|s|char)|v?f?s?w?scanf(?:s|sn)?w?printf(?:_s)?|abort|(?:(?:at_)?quick_|at)?exit|_Exit|unreachable|system|getenv(?:_s)?|to(?:lower|upper)|ato(?:f|i|l|ll)|str(?:to(?:u?ll?|f|l?d)|from[dfl]|(?:n?cpy|cat|nlen|tok|error(?:len)?)(?:_s)?|xfrm|n?dup|n?cmp|coll|r?chr|c?spn|pbrk|str|len)|mem(?:chr|cmp|set(?:_explicit|_s)?|(?:move|cpy)(?:_s)?|ccpy)|thrd_(?:create|equal|current|sleep|yield|exit|detach|join|success|timedout|busy|nomem|error)|(?:diff|mk|strf)?time|clock|timespec_get(?:res)?|(?:as)?ctime(?:_s)?|(?:gm|local)time(?:_[rs])?)' + + dir_start: ^\s*#\s* \ No newline at end of file diff --git a/C++/Default.sublime-keymap b/C++/Default.sublime-keymap index 7bf907a606..643310c47f 100644 --- a/C++/Default.sublime-keymap +++ b/C++/Default.sublime-keymap @@ -7,14 +7,14 @@ { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true }, { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, { "keys": ["<"], "command": "insert_snippet", "args": {"contents": "<${0:$SELECTION}>"}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, { "keys": [">"], "command": "move", "args": {"by": "characters", "forward": true}, "context": @@ -24,7 +24,7 @@ { "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true }, { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": @@ -35,7 +35,7 @@ { "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true }, { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, ] diff --git a/C++/syntax_test_accessor.c b/C++/syntax_test_accessor.c deleted file mode 100644 index df99affa0b..0000000000 --- a/C++/syntax_test_accessor.c +++ /dev/null @@ -1,35 +0,0 @@ -// SYNTAX TEST "Packages/C++/C.sublime-syntax" - -typedef struct _X -{ - int a; - int b; -} X; - -int main() -{ - X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - X x; - x.. -// ^^ invalid.illegal - punctuation.accessor -} - -int main() -{ - X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - X* x = malloc(sizeof(X)); - x-> -// ^^ punctuation.accessor -} diff --git a/C++/syntax_test_accessor.cpp b/C++/syntax_test_accessor.cpp deleted file mode 100644 index e20a7bb04d..0000000000 --- a/C++/syntax_test_accessor.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// SYNTAX TEST "Packages/C++/C++.sublime-syntax" - -namespace N { - -class X -{ - public: - int a; - int b; -}; - -class Y : public X -{ - public: - int c; -} - -} // namespace N - -int main() -{ - N:: -// ^^ punctuation.accessor -} - -int main() -{ - N::X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - N::X x; - x.. -// ^^ - punctuation.accessor -} - -int main() -{ - N::X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - N::X* x = new X(); - x-> -// ^^ punctuation.accessor -} - -int main() -{ - N::Y y; - y.X:: -// ^ punctuation.accessor -// ^^ punctuation.accessor -} - -int main() -{ - N::Y* y = new Y(); - y->X:: -// ^^ punctuation.accessor -// ^^ punctuation.accessor -} diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index ec3bd38270..a19e3fb070 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,1555 +1,1250 @@ -/* SYNTAX TEST "Packages/C++/C.sublime-syntax" */ +// SYNTAX TEST "Packages/C++/C.sublime-syntax" +// <- source.c -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number constant.numeric.value */ - /* ^^ keyword.operator.arithmetic */ -} - -enum Foo { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.enum */ -/* ^ entity.name.constant.c */ -/* ^ entity.name.constant.c */ -#define FOO Foo -enum FOO do_the_foo(void); -/* ^ entity.name.function */ -/* ^ storage.type */ - -#define APIC_CAPABILITY TheEnum -enum TheEnum { kFoo, kBar }; -static enum APIC_CAPABILITY apic_capabilities(void) { return kFoo; }; -/* ^ entity.name.function */ -/* ^ storage.type */ - -enum { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.constant.c */ -/* ^ entity.name.constant.c */ - -enum { kFoo = FOO, kBar = BAR }; -/* <- keyword.declaration */ -/* ^^^^ entity.name.constant.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ -/* ^ punctuation.separator.c */ -/* ^^^^ entity.name.constant.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ - -enum { - FOO, -/* ^^^ entity.name.constant.c */ -/* ^ punctuation.separator.c */ - BAR -/* ^^^ entity.name.constant.c */ -}; - -typedef enum state { DEAD, ALIVE } State; -/* <- keyword.declaration -/* ^ entity.name.enum */ -/* ^ entity.name.constant.c */ -/* ^ entity.name.constant.c */ - -struct __declspec(dllimport) X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct __declspec(dllimport) baz X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct foo { -/* ^ entity.name.struct */ - union { -/* ^ keyword.declaration */ - struct { -/* ^ keyword.declaration */ - int a; -/* ^ storage.type */ - int b; -/* ^ storage.type */ - } - } -} - -#define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS /* comment block */ * sizeof(struct ptp_extts_event)) // comment line -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group meta.group */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant.preprocessor */ -/* ^ comment.block */ -/* ^ keyword.operator.word */ -/* ^ keyword.declaration */ -/* ^ comment.line */ - -#pragma foo(bar, \ -"baz") -/*^^^^ meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#define PACKED __attribute__((aligned(1),packed)) -/* ^ entity.name.constant */ -/* ^ storage.modifier */ - -int i; -/* <- storage.type */ - -signed _BitInt(4) bi1 = 1wb; -/* ^ keyword.declaration.type */ -/* ^ constant.numeric.suffix */ - -unsigned _BitInt(4) bi2 = 1uwb; -/* ^ keyword.declaration.type */ -/* ^ constant.numeric.suffix */ - -_Atomic int ai1; -/* <- storage.modifier */ - -_Atomic(int) ai2; -/* <- storage.modifier */ - -_Alignas(int) int aa1; -/* <- keyword.declaration.type */ - -alignas(int) int aa2; -/* <- keyword.declaration.type */ - -thread_local int tl1; -/* <- storage.modifier */ - -_Thread_local int tl2; -/* <- storage.modifier */ - -typeof(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -__typeof(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -__typeof__(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -typeof_unqual(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -static_assert(alignof(int) == 4); -/* ^ keyword.operator.word */ - -_Static_assert(_Alignof(int) == 4); -/* ^ keyword.operator.word */ - -static_assert(sizeof(int) == 4); -/* <- keyword.operator.word */ - -_Static_assert(sizeof(int) == 4); -/* <- keyword.operator.word */ - -void build_default_prototype(Function *ret) { - static typeof(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - static __typeof(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - static __typeof__(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - static typeof_unqual(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ -} - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin */ -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.block */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number constant.numeric.value */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -#define CONST0 16 // Comment -#define CONST1 8 -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#if defined(VARIABLE) | // comment_line \ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor */ \ - defined(VAR2) -/*^^^^^^^^^^^^^^^ meta.preprocessor */ -/* ^ keyword.control */ -# error This is a long error message that need to \ -/* <- keyword.control.import */ \ -/* ^ string.unquoted */ \ - be splitted into two lines to prevent large lines. // comment -#error "Explicitly quoted string wrapped, \ - ensuring that the string quoting stops at some point \ - " -#warning This is a short warning -/* <- keyword.control.import */ -#endif - /* <- keyword.control.import */ - -#define MACRO_WITH_CURLY_BRACE { -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -bool still_C_code_here = true; -/* <- storage.type */ -/* ^ constant.language */ - -_Decimal32 d32; -/* <- storage.type */ - -_Decimal64 d64; -/* <- storage.type */ - -_Decimal128 d128; -/* <- storage.type */ - -complex complex_t_var; -/* <- support.type.complex */ - -imaginary imaginary_t_var; -/* <- support.type.complex */ - -fenv_t fenv_t_var; -/* <- support.type.fenv */ - -fexcept_t fexcept_t_var; -/* <- support.type.fenv */ - -jmp_buf jmp_buf_var; -/* <- support.type.setjmp */ - -sig_atomic_t sig_atomic_t_var; -/* <- support.type.signal */ - -va_list va_list_var; -/* <- support.type.stdarg */ - -atomic_bool atomic_bool_var; -/* <- support.type.stdatomic */ - -atomic_char atomic_char_var; -/* <- support.type.stdatomic */ - -atomic_schar atomic_schar_var; -/* <- support.type.stdatomic */ - -atomic_uchar atomic_uchar_var; -/* <- support.type.stdatomic */ - -atomic_short atomic_short_var; -/* <- support.type.stdatomic */ - -atomic_ushort atomic_ushort_var; -/* <- support.type.stdatomic */ - -atomic_int atomic_int_var; -/* <- support.type.stdatomic */ - -atomic_uint atomic_uint_var; -/* <- support.type.stdatomic */ - -atomic_long atomic_long_var; -/* <- support.type.stdatomic */ - -atomic_ulong atomic_ulong_var; -/* <- support.type.stdatomic */ - -atomic_llong atomic_llong_var; -/* <- support.type.stdatomic */ - -atomic_ullong atomic_ullong_var; -/* <- support.type.stdatomic */ - -atomic_char8_t atomic_char8_t_var; -/* <- support.type.stdatomic */ - -atomic_char16_t atomic_char16_t_var; -/* <- support.type.stdatomic */ - -atomic_char32_t atomic_char32_t_var; -/* <- support.type.stdatomic */ - -atomic_wchar_t atomic_wchar_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least8_t atomic_int_least8_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least8_t atomic_uint_least8_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least16_t atomic_int_least16_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least16_t atomic_uint_least16_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least32_t atomic_int_least32_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least32_t atomic_uint_least32_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least64_t atomic_int_least64_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least64_t atomic_uint_least64_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast8_t atomic_int_fast8_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast8_t atomic_uint_fast8_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast16_t atomic_int_fast16_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast16_t atomic_uint_fast16_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast32_t atomic_int_fast32_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast32_t atomic_uint_fast32_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast64_t atomic_int_fast64_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast64_t atomic_uint_fast64_t_var; -/* <- support.type.stdatomic */ - -atomic_intptr_t atomic_intptr_t_var; -/* <- support.type.stdatomic */ - -atomic_uintptr_t atomic_uintptr_t_var; -/* <- support.type.stdatomic */ - -atomic_size_t atomic_size_t_var; -/* <- support.type.stdatomic */ - -atomic_ptrdiff_t atomic_ptrdiff_t_var; -/* <- support.type.stdatomic */ - -atomic_intmax_t atomic_intmax_t_var; -/* <- support.type.stdatomic */ - -atomic_uintmax_t atomic_uintmax_t_var; -/* <- support.type.stdatomic */ - -atomic_flag atomic_flag_var; -/* <- support.type.stdatomic */ - -memory_order memory_order_var; -/* <- support.type.stdatomic */ - -FILE *FILE_var; -/* <- support.type.stdio */ - -fpos_t fpos_t_var; -/* <- support.type.stdio */ - -div_t div_t_var; -/* <- support.type.stdlib */ - -ldiv_t ldiv_t_var; -/* <- support.type.stdlib */ - -lldiv_t lldiv_t_var; -/* <- support.type.stdlib */ - -imaxdiv_t imaxdiv_t_var; -/* <- support.type.stdlib */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -time_t time_t_var; -/* <- support.type.time */ - -clock_t clock_t_var; -/* <- support.type.time */ - -thrd_t thrd_t_var; -/* <- support.type.threads */ - -thrd_start_t thrd_start_t_var; -/* <- support.type.threads */ - -mtx_t mtx_t_var; -/* <- support.type.threads */ - -cnd_t cnd_t_var; -/* <- support.type.threads */ - -tss_t tss_t_var; -/* <- support.type.threads */ - -tss_dtor_t tss_dtor_t_var; -/* <- support.type.threads */ - -once_flag once_flag_var; -/* <- support.type.threads */ - -void *null_pointer1 = NULL; - /* ^ constant.language.null */ - -void *null_pointer2 = nullptr; - /* ^ constant.language.null */ - -_Noreturn -/* <- storage.modifier */ -void foo(void) { abort(); } - -noreturn -/* <- storage.modifier */ -void bar(void) { abort(); } - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ - - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} - -#if 0 -#ifdef moo -/* <- - keyword.control - ^ meta.number constant.numeric.value -*/ -#endif -/* <- - keyword.control */ -#endif - -#if 0 -/* ^ meta.number constant.numeric.value */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 0000000 -/* ^^^^^^^ meta.number constant.numeric.value -*/ -#endif - -#if 1 -/* ^ meta.number constant.numeric.value */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 0090 -/* ^^^^ meta.number constant.numeric.value -*/ -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number constant.numeric.value */ - int b = 2; -/* ^ comment.block */ - #else - int c = 3; - #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - -FOO -/* <- meta.assumed-macro */ -FOO; -/* <- - meta.assumed-macro */ -foo -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO(); -/* <- - meta.assumed-macro */ -foo() -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ - -struct X -{ - ENABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - int foo; - /* <- storage.type */ - - DISABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - float bar; - /* <- storage.type */ -}; - -/** - * -/* ^ comment.block.documentation.c punctuation.definition.comment.c */ - -/* - * -/* ^ comment.block.c punctuation.definition.comment.c */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Preprocessor branches starting blocks +// Numbers ///////////////////////////////////////////// -#ifdef FOO -if (1) { -#elif BAR -if (2) { -# elif BAZ -if (3) { -# else -if (4) { -#endif - int bar = 1; -} -/* <- meta.block punctuation.section.block.end */ - /* <- - meta.block */ + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.1'4L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-1'5 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c + 0x314.1p5af 0b10e20 314e+30llu +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^^^^ meta.number.float.decimal.c +// ^^^^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Typedefs +// Operators ///////////////////////////////////////////// -typedef int myint; -/* <- keyword.declaration */ -/* ^ entity.name.type */ - -typedef struct mystruct { -/* <- keyword.declaration */ -/* ^ keyword.declaration.struct.c */ -/* ^ entity.name.struct.c */ -} mystruct; -/* ^ entity.name.type.typedef.c */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^^^^^^^^^^^ entity.name.struct.c */ -/* ^ punctuation.section.block.begin.c */ -/* ^ punctuation.section.block.end.c */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.c */ + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 ? -2 : ~3 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Data structures and return values +// Strings ///////////////////////////////////////////// -struct point -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ -{ - int x; - int y; -} - -struct point2 { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - int x; - int y; -} - -int main(void) { -/* ^^^^ entity.name.function */ -/* ^^^^ storage.type */ -} - -struct point get_point() {} -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin -/* ^ punctuation.section.block.end -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^ entity.name.function */ - -struct point **alloc_points(); -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -struct point* alloc_point(); -/* ^ entity.name.function - variable.function */ - -struct point FOO_API *alloc_point3(); -/* ^ entity.name.function - variable.function */ - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Constants ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[]) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -{ -/* <- meta.function meta.block */ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result != 0) { -/* ^^ keyword.operator.comparison.c */ - return 0; -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^^ keyword.control */ -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifdef BAR - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifndef BAZ - /* <- keyword.control.import */ - if (val == -3) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -4) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Matching various function definitions +// Enclosings ///////////////////////////////////////////// -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.function entity.name.function */ -(int * a) -/*^^^^^^^ meta.function.parameters meta.group */ -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} - -MACRO1 void * MACRO2 myfuncname () { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ - } - - struct Args { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - }; - - struct Args args; -/* ^ keyword.declaration */ -/* ^ - entity */ - -} - -static const uint32_t * const MACRO funcname(); -/* ^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ + [a, b, c] +// ^^^^^^^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end.c + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end -static constexpr int bar = 1; -/* ^ storage.modifier */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() -{ - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -} - -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} +///////////////////////////////////////////// +// Default Types +///////////////////////////////////////////// -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Test function call in function parameters +// Storage Keywords ///////////////////////////////////////////// -static string foo(bar() + ';'); -/* ^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^ entity.name.function */ -/* ^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ string */ -/* ^ -string */ + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end -func_call(foo -/*^^^^^^^^^^^ meta.function-call */ -/* ^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -); -/* <- meta.function-call meta.group punctuation.section.group.end */ ///////////////////////////////////////////// -// Invalid +// Functions ///////////////////////////////////////////// -) -/* <- invalid.illegal.stray-bracket-end */ -} -/* <- invalid.illegal.stray-bracket-end */ + + test(5, 10, 15, 20); +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^^^^^^^^^^^^^^ meta.function.return-type.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.c + test( +//^^^^^^ meta.function.identifier.c +// ^^ meta.function.parameters.c meta.group.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^ variable.parameter.c + ); +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Includes +// Control Flow ///////////////////////////////////////////// -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -static const unsigned char image_png[] = { -#embed -/* <- keyword.control.import.include */ -}; - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a --> b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c +// ^ punctuation.separator.c + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Numeric Constants +// Data Structures ///////////////////////////////////////////// -dec0 = 0; -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1234567890f; -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec3 = 1234567890L; -/* ^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec4 = 1234567890ul; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec5 = 1234567890Lu; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec6 = 1234567890LLU; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec7 = 1234567890uLL; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec8 = 1'234_567'890s0f; -/* ^^^^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec9 = 2'354'202'076LL; -/* ^^^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct1 = 01234567; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -oct2 = 01234567L; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct3 = 01234567LL; -/* ^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct4 = 01234567ulL; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct5 = 01284967Z0L; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^^^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct6 = 014'70; -/* ^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x0+0xFL+0xaull+0xallu+0xfu+0x'f'12_4uz; -/* ^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic - constant.c */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex3 = 0xA7'45'8C'38; -/* ^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -bin1 = 0b010110; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin2 = 0B010010; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin3 = 0b1001'1101'0010'1100; -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c */ -/* ^ constant.numeric.value.c */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ - + struct A; enum B; union C; +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.forward-declare.c +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.forward-declare.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.union.forward-declare.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c + { +// ^ meta.struct.c meta.block.c punctuation.section.block.begin.c + int a1; +//^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ keyword.declaration.enum.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + struct C* ptr; +//^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.struct.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ meta.block.c punctuation.section.block.begin.c + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Control Keywords +// Attributes and Declspec ///////////////////////////////////////////// -int control_keywords() -{ - if (x < 5) - /* <- keyword.control */ - {} - else - /* <- keyword.control */ - {} - - switch (x) - /* <- keyword.control */ - { - case 1: - /* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ - default: - /* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ - } - - do - /* <- keyword.control */ - { - if (y == 3) - continue; - /* <- keyword.control.flow.continue */ - } while (y < x); - /*^ keyword.control */ - - switch (a) { - case 1: break; - /* ^ punctuation.separator */ - case 100 - 10: break; - /* ^ punctuation.separator */ - default: break; - /* ^ punctuation.separator */ - } - - goto label; - /* <- keyword.control.flow.goto */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.struct.c - meta.struct meta.struct +// ^^^^^^^^^^ - meta.group +// ^^^^^^ meta.group.c - meta.group meta.group +// ^^^ meta.group.c meta.group.c +// ^ meta.group.c - meta.group meta.group +// ^^^^^^^^^^^^^ - meta.group - meta.block +// ^^ meta.block.c - meta.block meta.block +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^^^^ entity.name.struct.c +// ^ meta.block.c punctuation.section.block.begin.c + int a; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^^ meta.function.return-type.c +// ^^^^ meta.function.identifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^ meta.function.c - meta.block - meta.group +// ^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin -label: + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c - return 123; - /* <- keyword.control.flow.return */ -} +///////////////////////////////////////////// +// Preprocessor +///////////////////////////////////////////// + ASSUME_MACRO +// ^^^^^^^^^^^^ meta.assumed-macro.c + + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^ - keyword - string +// ^^^^^^^^^^^^^ meta.string.c string.unquoted.c +// ^ - string + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c - meta.macro meta.macro +// ^^^^^^^^ meta.macro.c +// ^^^ meta.macro.identifier.c - meta.group +// ^^^^^^^^^^^ meta.macro.body.c - meta.group +// ^^^^^^^^^^^ meta.macro.body.c meta.group.c +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c - meta.macro meta.macro +// ^^^^^^^^ meta.macro.c +// ^^^ meta.macro.identifier.c - meta.group +// ^^^^^^^^^^^ meta.macro.parameters.c meta.group.c +// ^^^^^^^^^^^^^^^^^^ meta.macro.body.c - meta.group - meta.block +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.macro.body.c meta.block.c - meta.group +// ^^^ meta.macro.body.c meta.block.c meta.group.c - meta.group meta.group +// ^^^^^^^^^^^^^^ meta.macro.body.c meta.block.c - meta.group +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.separator.c +// ^ punctuation.section.group.end +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^ - keyword.control.import.c +// ^^^ keyword.control.import.c +// ^ - keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c + #else +//^^^^^^^ meta.preprocessor.c +//^^ - keyword.control.import.c +// ^^^^^ keyword.control.import.c +// ^ - keyword.control.import.c + #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + # +// ^ keyword.control.c + #embed "file.txt" if_empty(0) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^ - keyword +// ^^^^^^ keyword.control.import.c +// ^ - keyword - string +// ^^^^^^^^^^ meta.string.c string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ keyword.other.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 8a6ee23d42..43c3e79684 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -1,3223 +1,1898 @@ -/* SYNTAX TEST "Packages/C++/C++.sublime-syntax" */ - -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ +// SYNTAX TEST "Packages/C++/C++.sublime-syntax" - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -Task natural_numbers() -{ - int n = 0; - while (true) { - co_yield n; - /* ^ keyword.control */ - n++; - } -} -Task foo() -{ - co_return 42; - /* ^ keyword.control */ - /* ^ meta.number */ -} -Task bar() -{ - co_await natural_numbers(); - /* ^ keyword.control */ - /* ^ variable.function */ -} - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number */ - /* ^^ keyword.operator.arithmetic */ -} - -///////////////////////////////////////////// -// Preprocessor -///////////////////////////////////////////// + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c -#ifndef IGUARD_ - /* <- keyword.control.import */ -#define IGUARD_ - /* <- keyword.control.import.define */ -struct foo* alloc_foo(); -/* <- keyword.declaration */ - /* <- - entity.name.type */ - /* <- entity.name.function */ -#endif - /* <- keyword.control.import */ - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -int g(int x = 5 \ - /* ^ punctuation.separator.continuation */ - , int y); - -#define MACRO_WITH_CURLY_BRACE { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ - - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} - -// This is a method/function with the return type on a separate line and so should not be a -// constructor. -FOOLIB_RESULT -some_namespace::some_function(int a_parameter, double another_parameter) { - /* <- meta.function meta.toc-list.full-identifier */ - /* ^ entity.name.function - entity.name.function.constructor */ - return FOOLIB_SUCCESS; -} - -#pragma foo(bar, \ -"baz", \ -1) -/* <- meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#if 0 -#ifdef moo -/* <- - keyword.control */ -#endif -/* <- - keyword.control */ -#endif - -#if 0000000 -/* ^^^^^^^ meta.number constant.numeric.value -*/ -#endif - -#if 0090 -/* ^^^^ meta.number constant.numeric.value -*/ -#endif - -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO -/* <- meta.assumed-macro */ - -struct FOO1 FOO2 FOO3 Test { - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - Test(); - Test() noexcept; - Test() final; - Test() noexcept final; - ~Test(); - ~Test() noexcept; - ~Test() override noexcept; - virtual ~Test(); - virtual ~Test() noexcept; - virtual ~Test() override noexcept; - DLL_API Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - DLL_API Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() noexcept final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API ~Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - DLL_API ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API virtual ~Test(); - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - DLL_API virtual ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API virtual ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -} - -struct X { - X(); - /* <- meta.group */ - /*^ meta.group - meta.group meta.group */ -}; - -#define DEPRECATED(msg) [[deprecated(msg)]] - -struct Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -}; - -namespace Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -} - -struct Test { -DEPRECATED("bla") -/* <- meta.assumed-macro variable.function.assumed-macro */ -bool foo (bool run=true) {} -/* ^ entity.name.function */ -}; + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c -///////////////////////////////////////////// -// Strings -///////////////////////////////////////////// + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c -char str1[] = "abc"; -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char8_t str2[] = u8"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char16_t str3[] = u"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char32_t str4[] = U"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -wchar_t str5[] = L"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char str6[] = "\a|\b|\e|\f|\n|\r|\t|\v|\'|\"|\?"; -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ - -char str7[] = "\0|\012"; -/* ^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ - -char str8[] = "\x0a|\x41|\xA|\x000065"; -/* ^^^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ -/* ^^^ constant.character.escape */ -/* ^^^^^^^^ constant.character.escape */ - -char8_t str9[] = u8"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char16_t str10[] = u"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char32_t str11[] = U"\U00000063"; -/* ^^^^^^^^^^ constant.character.escape */ - -char str12[] = "\q"; -/* ^^ invalid.illegal.unknown-escape */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ - -char rawStr1[] = R"("This is a raw string")"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char rawStr2[] = R"A*!34( )" )A*!34"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.definition.string.end */ - -const char IncludeRegexPattern[] = - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^^ - invalid */ -/* ^^ - invalid */ -/* ^ punctuation.definition.string.end */ - -foo.f<5> /* foo */ (); + */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Storage Types +// Numbers ///////////////////////////////////////////// -void* ptr; -/* <- storage.type */ - -bool b; -/* <- storage.type */ - -char ch; -/* <- storage.type */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -unsigned int ui; -/* <- storage.type */ -/* ^ storage.type */ - -signed long l; -/* <- storage.type */ -/* ^ storage.type */ - -short s; -/* <- storage.type */ - -auto a = 2; -/* <- storage.type */ - -decltype(s) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -float f; -/* <- storage.type */ - -double d; -/* <- storage.type */ - -typedef int my_int; -/* <- keyword.declaration.type */ -/* ^ entity.name.type */ - -typedef struct Books { -/* ^^^^^^ keyword.declaration.struct */ -/* ^ - entity.name.type */ - char title[50]; - int book_id; -} Book; -/*^ entity.name.type */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.c++ */ -/* ^^^^^^ keyword.declaration.struct.type.c++ */ -/* ^^^^^^^^^^^ entity.name.struct.c++ */ -/* ^ punctuation.section.block.begin.c++ */ -/* ^ punctuation.section.block.end.c++ */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.c++ */ - -using Alias = Foo; -/* <- keyword.control */ -/* ^^^^^ entity.name.type.using */ - -using Alias - = NewLineFoo; -/*^ - entity.name */ - -template -using TemplateAlias = Foo; -/* ^^^^^^^^^^^^^ entity.name.type.using */ - -using std::cout; -/* <- keyword.control */ -/* ^ - entity.name */ - -using std:: - cout; -/*^ - entity.name */ - -class MyClass : public SuperClass -{ - using This = MyClass; -/* ^ keyword.control */ -/* ^^^^ entity.name.type.using */ - - using MyInt -/* ^ keyword.control */ - = int32_t; - - using SuperClass::SuperClass; -/* ^ keyword.control */ -/* ^ - entity.name */ -}; - -class MyClass : public CrtpClass -{ - using typename CrtpClass::PointerType; -/* ^ keyword.control */ -/* ^ storage.modifier */ - using CrtpClass< -/* ^ keyword.control */ - MyClass>::method; -}; - -typedef struct Books Book; -/* ^ - entity.name.type.struct */ -/* ^ entity.name.type.typedef */ - -template class MyStack; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic */ -/* ^ storage.type */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic */ - -template class tupleTmpl; -/* <- keyword.declaration.template */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^^^^^ keyword.declaration.c++ */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -template, typename... Rest> class tupleVariadic; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^^^^^^^^ keyword.declaration */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ punctuation.definition.generic.end */ - -template void SomeClass::function(); -/* ^^^ keyword.operator.variadic */ -/* ^^^^^^^^ entity.name.function */ - -template inline struct Foo* baz() -/* ^^^^^^ storage.modifier */ -/* ^ - entity.name */ -/* ^^^ meta.function entity.name.function */ -{} - -template -void classname::methodName() { -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^^^^ entity.name.function */ -} - -template -void funcName() { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -} -bool A::operator<(const A& a) { return false; } -/* ^ storage.type */ -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters punctuation.section.group.begin */ -template bool A::operator<(const A& a) { return false; } -/* ^ keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters meta.group punctuation.section.group.begin */ -template -SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -template SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.constructor */ - -template A::~A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.destructor */ - -template -bool A::operator > (const A& other) { return false; } -/* ^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^^^^ entity.name.function */ -template -bool A::operator == (const A& other) { return false; } -/* ^^^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^^^^^^ entity.name.function */ -template -bool A::operator <=> (const A& other) { return false; } -/* ^^^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^^^^^^ entity.name.function */ - -typedef std :: vector > Table; -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.end */ - -template - /* ^ meta.template keyword.operator */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template meta.number */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template constant.language */ -struct Foo -{ - -/* <- meta.struct - meta.template */ - - void bar(int a = 3, bool b = true) {} - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template meta.number */ - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template constant.language */ -}; - -/* <- - meta.block - meta.struct - meta.template */ - -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template meta.number */ -class fixed_array : private std::array {}; - -constexpr std::size_t f() { return 128; } -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -/* ^ meta.template punctuation */ -class fixed_array : private std::array {}; - -template class A { /* ... */ }; -template class B { /* ... */ }; -/* ^ meta.template keyword.operator */ -/* ^ meta.template */ -/* ^ meta.template punctuation */ -/* ^ - meta.template */ -template class C { /* ... */ }; - -// templates inside templates... it's templates all the way down -template class P> class X { /* ... */ }; -/* ^ meta.template punctuation */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template meta.template keyword.declaration */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template keyword.declaration */ -/* ^ meta.template punctuation */ - -X xa; // OK -X xb; // OK in C++14 after CWG 150 - // Error earlier: not an exact match -X xc; // OK in C++14 after CWG 150 - -// template declarations spanning multiple lines -template -/* <- meta.template keyword.declaration.template */ -< -/* <- meta.template punctuation.definition.generic.begin */ - class T, - class U = T -> -class B -{ - /* ... */ -}; - -// template declarations spanning multiple lines -template -< -/* <- meta.template punctuation.definition.generic.begin */ - std::size_t Count = f() -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -> -/* <- meta.template punctuation.definition.generic.end */ -class fixed_array : private std::array {}; - -template -static bool decode(const Node& node, T& sequence) { - if (!node.IsSequence()) - return false; - sequence.clear(); - for (const auto& item : node) { - sequence.push_back(item.template as()); - /* ^ punctuation.accessor */ - /* ^ keyword.declaration.template - variable.other */ - /* ^ variable.function */ - /* ^ punctuation */ - /* ^^ punctuation.accessor */ - /* ^ punctuation */ - } - return true; -} - -#include -template struct A {}; -template struct B {}; -struct C {}; -A> f(std::function>()> g) { - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ variable.parameter */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - return g(); -} -int main() { - std::function foo1; - /* ^ - variable.function */ - std::function()> foo2; - /* ^ - variable.function */ - auto f = [](std::function>()> g) { return g(); }; - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - /* ^ punctuation.section.block.end */ - return 0; -} -/* <- - invalid.illegal */ - -// Example from section 14.2/4 of -// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf -struct X -{ - template - X* alloc(); - - template - static X* adjust(); -}; -template -void f(T* p) -{ - // Be optimistic: scope it as a template member function call anyway. - T* p1 = p->alloc<200>(); // ill-formed: < means less than - - T* p2 = p->template alloc<200>(); // OK: < starts template argument list - /* ^ punctuation.accessor */ - /* ^ keyword.declaration.template - variable.other */ - /* ^ variable.function */ - - // Be optimistic: scope it as a template member function call anyway. - T::adjust<100>(); // ill-formed: < means less than - - T::template adjust<100>(); // OK: < starts template argument list - /* <- - variable.function */ - /*^ punctuation.accessor */ - /* ^ keyword.declaration.template - variable.other */ - /* ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ - /* ^ variable.function */ -} - -struct X -{ - void template(); // <-- not allowed to be a function! - /* ^ - entity.name.function */ -}; - -void f() -{ - X x; - x.template(); // <-- should not be scoped as variable.function! - /* ^ - variable.function */ - - x /**/ . /**/ foo <5> /**/ () /**/ ; - /*^^^^ comment.block */ - /* ^ punctuation.accessor */ - /* ^^^ meta.method-call variable.function */ - /* ^ meta.method-call - variable.function */ - /* ^ meta.method-call punctuation.definition.generic.begin */ - /* ^ meta.method-call punctuation.definition.generic.end */ - /* ^ meta.method-call - punctuation - comment.block */ - /* ^^^^ meta.method-call comment.block */ - /* ^ meta.method-call - comment.block - punctuation */ - /* ^^ meta.method-call punctuation - comment.block */ - /* ^ - meta.method-call */ -}; - -template C f(T t) -{ - return C { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -template C> f(T t) -{ - return C> { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -struct A { int foo; }; -int main() { - A a, b; - a.foo = a.foo < 0 ? 1 : 2; - /* ^ - punctuation.definition.generic */ - a.operator<(b); - /*^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator>(b); - /*^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator<=(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator>=(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator==(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator!=(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator<=>(b); - /*^^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator->(); - /*^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^ meta.group */ -} -/* <- - invalid.illegal */ - -template -struct A::value && !is_std_char_type::value>> { - using x = conditional_t; - /* ^^ keyword.operator.comparison */ - - template - struct Y { - constexpr int operator<=>(const Y&) { return 0; } - }; - Y{} <=> Y<0>{}> y; - /* ^^^ keyword.operator.comparison */ -}; -/* <- - invalid.illegal */ - + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.14L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-15 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c + 0x314.1p5af 0b10e20 +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Storage Modifiers +// Operators ///////////////////////////////////////////// -alignas(16) char array[256]; -/* <- storage.modifier */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -const int XYZ = 2; -/* <- storage.modifier */ - -constexpr int ABC = 3 + 5; -/* <- storage.modifier */ - -consteval int f() { return 42; } -/* <- storage.modifier */ - -constinit const int i = f(); -/* <- storage.modifier */ - -thread_local int x; -/* <- storage.modifier */ - + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 && 2 || 3 ? -4 : ~5 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ keyword.operator.word.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Control Keywords +// Strings ///////////////////////////////////////////// -static_assert(x >= 0); -/* <- keyword.operator */ - -noexcept(f()); -/* ^^^ meta.function-call */ -/* <- keyword.operator */ - -if (x < 5) -/* <- keyword.control */ -{} -else -/* <- keyword.control */ -{} - -switch (x) -/* <- keyword.control */ -{ -case 1: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -default: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -} - -do -/* <- keyword.control */ -{ - if (y == 3) - continue; - /* <- keyword.control.flow.continue */ -} while (y < x); -/*^ keyword.control */ - -switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ -} - -goto label; -/* <- keyword.control.flow.goto */ - -try -/* <- keyword.control */ -{ - throw std :: string("xyz"); - /* <- keyword.control.flow.throw */ - /* ^^^^^^ variable.function */ - /* ^^ punctuation.accessor */ -} -catch (...) -/* <- keyword.control */ -{ -} - -int* ptr = new int(2); -/* ^ keyword.control */ - -delete ptr; -/* <- keyword.control */ - -return 123; -/* <- keyword.control.flow.return */ - + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c++ + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c++ + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c++ + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c++ ///////////////////////////////////////////// -// Operator Keywords +// Constants ///////////////////////////////////////////// -int x = alignof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -int x = sizeof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Cast Keywords +// Enclosings ///////////////////////////////////////////// -const_cast(2.0); -/* <- keyword.operator.word.cast */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -dynamic_cast(2.0); -/* <- keyword.operator.word.cast */ - -reinterpret_cast(2.0); -/* <- keyword.operator.word.cast */ - -static_cast(2.0); -/* <- keyword.operator.word.cast */ - -auto var = *reinterpret_cast>*>(v); -/* ^ keyword.operator.word.cast */ -/* ^ - variable.function */ + [a, b, c] +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^^^^^^ meta.brackets.square.c +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end.c + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Language Constants +// Default Types ///////////////////////////////////////////// -bool t = true; -/* ^ constant.language */ - -bool f = false; -/* ^ constant.language */ - -int* p = nullptr; -/* ^ constant.language */ - -char ch[] = __func__; -/* ^ constant.language */ - + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Support Constants +// Storage Keywords ///////////////////////////////////////////// -std::cout << __FILE__ << '\n'; -/* ^ support.constant */ -/* ^^ punctuation.accessor */ - -std :: cout << __FUNCTION__ << '\n'; -/* ^^ punctuation.accessor */ -/* ^ support.constant */ - -std::cout << __LINE__ << '\n'; -/* ^ support.constant */ + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Numeric Constants +// Functions ///////////////////////////////////////////// -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1'924'013; -/* ^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec3 = 124ul; -/* ^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec4 = 9'204lu; -/* ^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec5 = 2'354'202'076LL; -/* ^^^^^^^^^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct1 = 0123_567; -/* ^^^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct2 = 014'70; -/* ^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0X1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex3 = 0x1234567890abcdef; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex4 = 0xA7'45'8C'38; -/* ^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex5 = 0x0+0xFL+0xaull+0xallu+0xfu+0xf'12_4_uz; -/* ^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic - constant.c++ */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -bin1 = 0b010110; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin2 = 0B010010; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin3 = 0b1001'1101'0010'1100; -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1'843'290.245'123; -/* ^^^^^^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 2'837e1'000; -/* ^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 23e-1'000; -/* ^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ constant.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ + test(5, 10, 15, 20); +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.c + test( +// ^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.c++ + ); +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Functions +// Control Flow ///////////////////////////////////////////// -// function prototype -void abcdWXYZ1234(); -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -// function definition -void abcdWXYZ1234() -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -struct foo **alloc_foo(); -/* ^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -long func -/* ^^^^ meta.function entity.name.function */ -(int x, void *MYMACRO(y) ) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ -entity.name.function */ -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^ meta.group meta.function-call meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end */ - // Ensure < and > aren't parsed as a generic - if (foo < bar && baz > bar ) { -/* ^ keyword.operator.comparison */ -/* ^ keyword.operator.comparison */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - } - if (version.major == 10 && version.minor < 11) -/* ^ keyword.operator.comparison */ - { - - } -} -/* <- meta.function meta.block punctuation.section.block.end */ - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} - -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - struct Args { -/* ^^^^^^ keyword.declaration.struct.type */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - Args() -/* ^ entity.name.function.constructor */ - : hellp(nullptr), -/* ^ punctuation.separator.initializer-list */ - foobar(nullptr) - { + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c++ +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c++ +// ^ punctuation.section.group.end.c +// ^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^ punctuation.section.block.end.c + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a > b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } - }; - - struct Args args2; -/* ^^^^^^ keyword.declaration */ -/* ^ - entity */ - - class LocalFoo MYMACRO -/* ^^^^^ keyword.declaration.class */ -/* ^ entity.name.class */ -/* ^ - entity */ - { - LocalFoo() {} -/* ^ entity.name.function.constructor */ +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c++ +// ^ punctuation.separator.c++ + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c } - - class LocalFoo test; -/* ^^^^^ keyword.declaration.class */ -/* ^ - entity */ - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -/* A comment. */ void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -// prevent leading comment from function recognition -/**/ HRESULT A::b() -/* ^ meta.function */ -/* ^ entity.name.function */ -{ - return S_OK; -} -FooBar::FooBar(int a) -/*^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ punctuation.section.group.end */ -{ -} - -FooBar :: FooBar(int a) & = -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.operator */ -/* ^ keyword.operator.assignment */ -default; -/*^^^^^ meta.function storage.modifier */ - -FooBar::~FooBar -/*^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ -() { } -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ - /* <- meta.function.parameters meta.group punctuation.section.group.end */ -/*^^^^ meta.function */ - -ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath:: - ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath() -/* <- meta.function meta.toc-list.full-identifier */ - : var_name(nullptr) { -} - -bool FooBar::operator==() {} -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^^^^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - -myns::FooBar::~FooBar() { } -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ - - extern "C" void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if 0 -void test_in_extern_c_block() -/* ^ comment.block */ -{ -} -#else - -/* temporary C++ preprocessor block */ -#ifdef __cplusplus -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -# ifndef _Bool -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ -/* ^ keyword.declaration */ -/* ^ entity.name.type.typedef */ -# endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -#endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - -void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ -#endif - -#ifdef __cplusplus -} -#endif -/* ^ - meta.extern-c */ - -gener func_returning_generic(int a); -/* ^ entity.name.function */ - -std::vector func_returning_path_generic(int a); -/* ^ punctuation.definition.generic */ -/* ^ entity.name.function */ - -void f() -{ - static_assert(false, "oops"); - /* ^ keyword.operator.word */ -} - -long double operator "" _km (long double x); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^^^^^^^^^^^^^ entity.name.function */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Namespace +// Data Structures ///////////////////////////////////////////// -namespace myNameSpace {} -/* <- keyword.control */ -/* ^ entity.name.namespace */ - -namespace new_name = current_name; -/* <- keyword.control */ - -using namespace NAME __attribute__((visibility ("hidden"))); -/* <- keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ - -void func() { - using namespace NAME __attribute__((visibility ("hidden"))); -/* ^ keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ -} - -using namespace -/* <- keyword.control */ -/* ^ keyword.control */ - -using namespace myNameSpace; -/* <- keyword.control */ -/* ^ keyword.control */ - -namespace ns :: abc /* Neither this comment... */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace */ -/* ^^^^^^^^^ entity.name.namespace */ -/* ^^ punctuation.accessor */ -/* ^ comment.block */ -// ...nor this comment is highlighted -/* <- comment.line */ -{ -/* <- meta.namespace meta.block punctuation.section.block.begin */ - void nsfunc() { - /* ^ entity.name.function */ - } -} -/* <- meta.namespace meta.block punctuation.section.block.end */ - -namespace tl { -/*^^^^^^^^^^^^ meta.namespace */ -/* ^ keyword.control */ - namespace { -/* ^ keyword.control */ -/* ^^^^^^^^^^^ meta.namespace meta.namespace */ -/* ^ meta.block meta.block punctuation.section.block.begin */ - void nested_func(){} -/* ^ entity.name.function */ + struct A; enum B; union C; +// ^^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.forward-declare.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.union.forward-declare.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ entity.name.class.c++ + { +//^^^ meta.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a1; +//^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^ meta.brackets.square.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.c +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ keyword.declaration.enum.c++ +// ^ punctuation.terminator.c +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + void* ptr; +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c } -} - -MACRONAME namespace ns3 {} -/* ^ keyword.control */ - -extern "C++" -// ^ storage.modifier -// ^^^^^ string.quoted.double -{ -namespace std _GLIBCXX_VISIBILITY(default) -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace -// ^ keyword.control -// ^ entity.name.namespace -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call -// ^^^^^^^^^ meta.group -// ^ keyword.control -{} -} - -#define MY_NAMESPACE_BEGIN namespace greatapp { -#define MY_NAMESPACE_END } -MY_NAMESPACE_BEGIN -class X { -private: -/* <- storage.modifier */ - int a; -protected: -/* <- storage.modifier */ - int b; -public: -/* <- storage.modifier */ - int c; -}; -MY_NAMESPACE_END - -MY_NAMESPACE_BEGIN int foo(); MY_NAMESPACE_END -/* ^ storage.type */ -/* ^ meta.function entity.name.function */ -/* ^^^ punctuation */ - -// Uncomment this some day -// MY_NAMESPACE_BEGIN class X : public std::true_type {}; MY_NAMESPACE_END +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^ keyword.operator.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Classes, structs, unions and enums +// Attributes and Declspec ///////////////////////////////////////////// -class BaseClass; -/*^^^^^^^^^^^^^ meta.class */ -/* ^ - meta.class meta.class */ -/* ^^^^^^^^^ entity.name.class.forward-decl */ - -class BaseClass // comment -/* <- keyword.declaration */ -/* ^ entity.name.class */ -{ -public : -/* <- storage.modifier */ - tupleTmpl max(tupleGen a, tupleGen b); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -protected: -/* <- storage.modifier */ -private: -/* <- storage.modifier */ - - static int a = 1 << 4; - /* <- storage.modifier */ - /* ^^ keyword.operator.arithmetic */ - - static int x; - /* <- storage.modifier */ - - virtual void doSomething() const = 0; - /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /* ^ - meta.method meta.method */ - /* ^^ meta.method.parameters meta.group */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* <- storage.modifier */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ meta.number */ - - template - void func(){} -/* ^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/* ^^^^ entity.name.function */ - - template - void func(){} -/* ^^^^^^^^^^^ meta.method */ -/* ^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - template - BaseClass(){} -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ meta.method.constructor */ -/* ^^^^^^^^^ entity.name.function */ - - ~BaseClass() {} -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^ meta.method.destructor */ -/* ^^^^^^^^^^ entity.name.function */ - - BaseClass operator [] () -/* ^^^^^^^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^^^^^^^^^^ entity.name.function */ - {} - - BaseClass operator= -/* ^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ entity.name.function */ - () {} -/* ^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^ meta.block */ -}; - -class DerivedClass : public ::BaseClass // Comment -/* ^ entity.other.inherited-class */ -/* ^ comment.line */ -{ - ~DerivedClass() override; - /* <- meta.method.destructor */ - /*^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /*^^^^^^^^^^^ meta.method.destructor */ - /* ^ storage.modifier */ - virtual void doSomething() const override final; - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - protected: -/*^^^^^^^^ storage.modifier */ - DerivedClass() override -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/*^^^^^^^^^^^^ meta.method.constructor */ -/* ^ storage.modifier */ - : a(a), -/* ^^^^^^^ meta.method.constructor.initializer-list */ - base_id_(BaseClass::None().ToInt()), -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ -/* ^ variable.other.readwrite.member */ -/* ^ punctuation.accessor */ -/* ^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^ variable.function */ -/* ^ punctuation - meta.method-call */ -/* ^^^^^^^ meta.method-call */ -/* ^^^^^ variable.function */ -/* ^ punctuation.separator */ - bounds_(NULL), -/* ^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - bit_field_(0) { -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - char * a = "sprintf"; - char * b = sprintf("Testing %s", a); -/* ^^^^^^^^^ meta.function-call */ -/* ^^^^^^^ support.function.C99 */ - - base_id_->foobar(1, "foo"); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^ variable.function */ - - base_id_->~BaseClass(); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^^^^^ variable.function */ - } -/* ^ meta.method meta.block punctuation.section.block.end */ - -/* <- - meta.class.constructor.initializer-list */ - - typedef std::vector qux; -/* ^^^ entity.name.type.typedef */ -}; - - -template -class class1 : class2 -/* ^^^^^^ entity.name.class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -/* ^^^^^^ entity.other.inherited-class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -{} - -class FooBar { -/* ^ meta.class meta.block punctuation.section.block.begin */ - explicit FooBar(int a); -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^ storage.modifier */ -/* ^^^^^^ entity.name.function */ - FooBar() =default; -/* ^^^^^^ entity.name.function */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - FooBar(void) =default; -/* ^^^^^^ entity.name.function */ -/* ^^^^ storage.type */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - - // If a constructor name is on a line without the opening (, it is not - // highlighted as a method/constructor. This prevents a bunch of false - // positives, including data types as they are being typed into a struct. - FooBar -/* ^ - entity.name.function */ - (); - - virtual ~FooBar(); -/* ^^^^^^^ entity.name.function */ - -#ifndef DEBUG - ~FooBar(); -/* ^^^^^^^ entity.name.function */ -#endif - - void insert () {} -/* ^^^^^^ entity.name.function */ - - explicit operator bool -/* ^^^^ entity.name.function */ - () {} - - FooBar::~FooBar(); -/* ^^^^^^^^^^^^^^^ entity.name.function */ - - void FooBar:: - Baz() { - /* <- entity.name.function */ - } - - auto f(int a) -> decltype(a.begin()) override final; -/* ^^ punctuation.separator */ -/* ^ punctuation.accessor */ -/* ^^^^^ variable.function */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - - auto g() -> std::vector override final { -/* ^^ punctuation.separator */ -/* ^^ punctuation.accessor */ -/* ^ storage.type */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - this->g(1); -/* ^ variable.language */ - } - -private: -/*^^^^^ storage.modifier */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - myns::subns::MyDataType -/* ^ - entity.name.function */ - and_now_method_name(); -/* ^ entity.name.function */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - std::shared_future> -/* ^ - entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ - and_now_method_name2(); -/* ^ entity.name.function */ - - enum { - FOO, - /* ^^^ entity.name.constant.c++ */ - /* ^ punctuation.separator.c++ */ - BAR - /* ^^^ entity.name.constant.c++ */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c }; - - enum -/* ^^^^ meta.enum keyword.declaration */ - { -/* ^ meta.enum punctuation.section.block.begin */ - A = 1, -/* ^ entity.name.constant.c++ */ -/* ^ punctuation.separator.c++ */ - B = 20 / 5, -/* ^ entity.name.constant.c++ */ -/* ^ punctuation.separator.c++ */ - C = FOO -/* ^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^ - entity.name */ - } -/* ^ meta.enum punctuation.section.block.end */ -/* ^ - meta.enum */ - - friend int func(int a, int b); -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ - entity.name.function */ -/* ^ - meta.function-call */ - - friend int func(int a, int b) { -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ entity.name.function */ -/* ^ - meta.function-call */ -/* ^ meta.class meta.block meta.method meta.block punctuation.section.block.begin */ - int a = 1; - } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ - - friend class ::FooBar; -/* ^ storage.modifier */ -/* ^ keyword.declaration -/* ^^ punctuation.accessor */ -/* ^ - entity */ - - friend bool operator != (const X& lhs, const X& rhs) { - /* ^^^^^^^^^^^ entity.name.function */ - int a = 1; - } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ - - #if 0 - /* ^ meta.number */ - int disabled_func() { - /* ^ comment.block */ +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } - #endif +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin - #if 1 - /* ^ meta.number */ - int enabled_func() {} - /* ^ entity.name.function */ - #else - int disabled_func() { - /* ^ comment.block */ } - #endif - - MACRO_NOT_CONSTRUCTOR(FooBar); -/* ^ meta.function-call variable.function - entity.name.function */ - - MACRO_NOT_CONSTRUCTOR2(FooBar, -/* ^ meta.function-call variable.function - entity.name.function */ - FriendClass); -} -/* <- meta.class meta.block punctuation.section.block.end */ - /* <- - meta.class meta.block */ - -struct X { - Y f() override noexcept final; - /*^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class X { - public: - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -union Y { - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class Child : public Parent { - ::anotherClass Func() override; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ -} - -class Adapter2 : public Abstraction, private Scenario { -/* ^ punctuation.separator */ -} - -class Adapter : public Abstraction - #if defined ASPECTO_MACRO -/* ^^^ keyword.control.import */ - , public Scenario -/* ^ punctuation.separator */ -/* ^ storage.modifier */ -/* ^ entity.other.inherited-class */ - #endif -/* ^^^^^^ keyword.control.import */ -{ - -} - -struct Base {}; -class Derived final : Base {}; -/* ^ storage.modifier */ -struct Derived final : Base {}; -/* ^ storage.modifier */ - -/* C++11 "uniform initialization" in initializer lists */ -class Foo { -public: - Foo() : var1(1), var(2), var3{3}, var4(4) {} - /* ^ meta.method.constructor.initializer-list */ - /* ^ - meta.function-call - variable.function */ -private: - int var1, var2, var3, var4; -}; - -class X { - int a, b, i, j; -public: - const int& r; - X(int i) - : r(a) // initializes X::r to refer to X::a - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , b{i} // initializes X::b to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , i(i) // initializes X::i to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j(this->i) // initializes X::j to the value of X::i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j - /*^ variable */ - (this->i) - /* <- meta.method.constructor.initializer-list punctuation */ - { } -/* ^ punctuation - meta.method.constructor.initializer-list */ -/* ^ punctuation - meta.method.constructor.initializer-list */ -}; - -struct A { - static_assert(0 < 1, ""); - /* ^ keyword.operator.word */ - /* ^ meta.function-call */ - /* ^ keyword.operator.comparison */ - - A(); -/*^ meta.method.constructor entity.name.function.constructor */ - - void f(); - /* ^ storage.type */ - /* ^ meta.method entity.name.function */ - /* ^ punctuation.terminator */ -}; -/* <- punctuation.section.block.end - invalid.illegal */ - -struct bar { -/*^^^^^^^^^^ meta.struct */ -/*^^^^ keyword.declaration */ -/* ^^^ entity.name.struct */ -/* ^ meta.block punctuation.section.block.begin */ - bar() -/* ^^^^^ meta.method */ -/* ^^^ entity.name.function */ - {} -} -/* <- meta.struct meta.block punctuation.section.block.end */ - /* <- - meta.struct meta.block */ - -enum baz { -/*^^^^^^^^ meta.enum */ -/* <- meta.enum keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ meta.block punctuation.section.block.begin */ - FOO = 1, -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAR = 2, - BAZ = 3, -#if 0 -/* ^ meta.number */ - QUX = 4, -/* ^ comment.block */ -#endif -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; - -enum class qux : std::uint8_t -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/*^^^^^^^^ keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ punctuation.separator */ -/* ^^^^^^^^^^^^ entity.other.inherited-class */ -{ -/* <- meta.block punctuation.section.block.begin */ - FOO = 1, - BAR = 2, -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAZ = 3 -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -typedef enum class funky -/*^^^^^ keyword.declaration */ -/* ^^^^^ entity.name.enum */ -{ - BAZ = 3 -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Funky; - -typedef enum -/*^^^^^ keyword.declaration */ -{ - FOO = 1, - BAR = 2, - BAZ = 3 -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Fun; - -enum LineEnding : uint32_t; -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/* ^^^^^^^^^^ entity.name.enum.forward-decl */ -/* ^ punctuation.separator */ -/* ^^^^^^^^ entity.other.inherited-class */ -/* ^ - meta.enum */ - -union foobaz { -/* <- meta.union keyword.declaration */ -/* ^^^^^^ entity.name.union */ -/* ^ meta.block punctuation.section.block.begin */ -} -/* <- meta.union meta.block punctuation.section.block.end */ - /* <- - meta.union meta.block */ - -// Class name that looks like a possible macro -class SP {} -/* ^^ entity.name.class */ - -class MyClass MACRO MACRO2 -/* ^ keyword.declaration */ -/* ^ entity.name.class */ -/* ^ - entity */ -/* ^ - entity */ -{} - -// Class using macro to handle __declspec() on Windows -class SK_API SkBitmap {} -/* ^ entity.name.class */ -class __declspec(property(get=foo)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ variable.parameter */ -/* ^ entity.name.class */ -class __declspec(align(8)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ meta.number */ -/* ^ entity.name.class */ -class __declspec(dllimport) SkBitmap {} -/* ^ constant.other */ -/* ^ entity.name.class */ - -// Make sure not to match macros that have "too few characters". -template class Sample { - public: - // The T here should not be consumed as a macro. - T operator() (const foo x) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - int operator == (const int x) { - /*^^^^^^^^^^^ entity.name.function */ - return 0; - } - // The T here should not be consumed as a macro. - T operator()(int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - // The T here should not be consumed as a macro. - T operator[](int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } -}; - -class Namespace::MyClass MACRO1 MACRO2 : public SuperClass -/* ^^^^^^^ entity.name.class */ -/* ^^ punctuation.accessor */ -/* ^ - entity.name */ -{ -}; - -struct Namespace::MyStruct -/* ^^^^^^^^ entity.name.struct */ -/* ^^ punctuation.accessor */ -{ -}; - -union Namespace::MyUnion -/* ^^^^^^^ entity.name.union */ -/* ^^ punctuation.accessor */ -{ -}; - -enum class Namespace::MyEnum -/* ^^^^^^ entity.name.enum */ -/* ^^ punctuation.accessor */ -{ - BAR = 1, -/* ^^^ entity.name.constant.c++ */ -}; - -class Namespace:: -MyClass MACRO1 -/* <- entity.name.class */ -/* ^ - entity.name */ -{ -}; - -struct Namespace:: -MyStruct MACRO1 -/* <- entity.name.struct */ -/* ^ - entity.name */ -{ -}; - -union Namespace:: -MyUnion MACRO1 -/* <- entity.name.union */ -/* ^ - entity.name */ -{ -}; - -enum class Namespace:: -MyEnum MACRO1 -/* <- entity.name.enum */ -/* ^ - entity.name */ -{ -}; - +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Preprocessor ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[], bool val3 = false) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -/* ^ punctuation.separator */ -/* ^^^^ storage.type */ -/* ^^^^ variable.parameter */ -/* ^ keyword.operator.assignment */ -/* ^^^^^ constant.language */ -{ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result == 0) { - return 0; -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifndef DEBUG - if (check_debug()) { - val /= 2; -#endif - val += 1; -#ifndef DEBUG - } -/* ^ meta.function meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ -#endif - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -#if 0 -/* ^ meta.number */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 -/* ^ meta.number */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number */ - int b = 2; -/* ^ comment.block */ + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c++ +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.separator.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c #else - int c = 3; - #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ - -///////////////////////////////////////////// -// Matching various function definitions -///////////////////////////////////////////// - -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ entity.name.function */ -(int * a) -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ punctuation.section.group.end */ -{ - -} - -void MyClass3:: -foo() { -/* <- entity.name.function */ -} - -MyClass3:: -~MyClass3() { -/* <- entity.name.function */ -} - -struct A -{ - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ +//^^^^^^^ keyword.control.import.c #endif - - void f() - { - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ - #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + # +// ^ keyword.control.c + #embed "file.txt" if_empty(0) +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ keyword.other.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c + + + "Hello {}!"_literal +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + 'h'_literal +// ^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + R"RAW( +// ^^^^^^ string.quoted.double.raw.c++ +// ^ storage.type.string.c++ +// ^ punctuation.definition.string.begin.c++ +// ^^^^ constant.other.placeholder.c++ +// ^ storage.type.string.c++ +// ^ punctuation.definition.string.begin.c++ +// ^^^^ constant.other.placeholder.c++ + raw string )STR" +//^^^^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ + )RAW"_literal +//^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ +// ^^^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + + using std::cout; +// ^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^ entity.name.using.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.terminator.c + using namespace std; +// ^^^^^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.namespace.c++ +// ^ punctuation.terminator.c + + and and_eq or or_eq not not_eq xor xor_eq bitand bitor compl +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^ keyword.operator.logical.c++ +// ^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ + delete new typeid noexcept <=> +// ^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.word.c++ +// ^^^^^^ keyword.operator.word.c++ +// ^^^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.comparison.c++ + + constexpr consteval constinit +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ + wchar_t wchar8_t wchar16_t wchar32_t +// ^^^^^^^ storage.type.c++ +// ^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ + + enum class Test { +// ^^^^^^^^^^^^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^^^^^ keyword.declaration.class.c++ +// ^^^^ entity.name.enum.c +// ^ punctuation.section.block.begin.c + A = 314, +//^^^^^^^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + B, +//^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ punctuation.separator.c + }; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + namespace std::mynamespace { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ +// ^^^^^^^^^ keyword.declaration.namesace.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.namespace.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.block.c++ punctuation.section.block.begin.c++ + std::vector const& func(std::string const& a, std::function b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + template auto func(char param1, int param2 = f(20) - g(20)) const -> decltype(T::func(param)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ variable.function.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + try { +//^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + throw ns::func(param2); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^ keyword.control.exception.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^^^^ meta.function.c +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } catch (std::exception const& e) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^ keyword.control.exception.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_await func +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ + (e); +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + } finally { +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_yield func(param1); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ +// ^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end.c + + co_return 7; +//^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^^^^^^^ keyword.control.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c } - - void f() - { - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ +//^^^ meta.namespace.c++ meta.block.c++ +// ^ punctuation.section.block.end.c++ + + class Type; +// ^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + + template class V, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.separator.c + typename ...Args> requires std::same_as, std::string> +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^^^ keyword.operator.variadic.c +// ^^^^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ + struct MACRO Type> MACRO final : D> { +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^^^^^ entity.other.inherited-class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + private: +//^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ + alignas(20) std::string m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + protected: +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^ storage.modifier.c++ + int m_value2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + friend class V; +//^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + friend void someFunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + public: +//^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ + Type() && : m_value1("a"), m_value2(10); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.initializer-list.c++ +// ^ punctuation.separator.initializer-list.begin.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^ meta.group.c +// ^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.separator.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.group.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + ~Type() = default; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^^ keyword.control.c +// ^ punctuation.terminator.c + explicit Type(int) = delete; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ storage.type.c +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^ keyword.operator.word.c++ +// ^ punctuation.terminator.c + + template <> +//^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^ punctuation.section.generic.end.c++ + std::string const& doThing() const requires requires(std::tuple a) { a.get<0>().runThing(); } { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +//^^^^^^ meta.template.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.requires.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ keyword.operator.variadic.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.definition.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return this->m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^ variable.language.c++ +// ^^ punctuation.accessor.arrow.c +// ^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + }; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + export { +// ^^^^^^ keyword.other.c++ +// ^ meta.block.c punctuation.section.block.begin.c + class A : protected A, private B, public C { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.c++ +// ^^ entity.other.inherited-class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + virtual void vfunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ storage.type.c +// ^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + bool operator ==(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + int operator<=>(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + unsigned long long operator ""_label(unsigned long long a) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c } -}; - -void f() -{ - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ -} - -void f() -{ - #ifdef X - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ - #endif -} - -Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/); -/* ^^^^^^^^^ comment */ - -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + void A::vfunc() { +// ^^^^ storage.type.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + auto lambda = [=] mutable -> std::string { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return "test"; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + ([&, this, lambda](int a, char b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.separator.c +// ^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^^^^^^ meta.template.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + })(5, 10); +//^^^^^^^^^^^^^^^^ meta.block.c +//^^^^^^^^^^^^^^^ meta.group.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + auto somestruct = { +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.block.c punctuation.section.block.begin.c + .thing = 5, "200", .other = lambda +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.separator.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c } - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() -{ - -} - -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -int& return_type_ref_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ - -///////////////////////////////////////////// -// Paths/identifiers -///////////////////////////////////////////// - -void sayHi() -{ - std::cout << "Hi!\n"; -/* ^ punctuation.accessor */ - Print(3); -/* ^ variable.function */ - func_call(foo -/* ^ meta.function-call */ - ); - - if (::std::foo()) {} -/* ^^^ variable.function */ -/* ^^ punctuation.accessor */ -/* ^^ punctuation.accessor */ - - foobaz(); -/* ^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<>(); -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<0>(); -/* ^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - ::myns::foo(); -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ storage.type */ - - myns::FooClass{42}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ - - ::myns::BarClass{}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ -/* ^^^ storage.type */ - - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ - - std::cout << ">> Hi!\n"; -/* ^^ keyword.operator.arithmetic.c */ -} - -///////////////////////////////////////////// -// Includes -///////////////////////////////////////////// - -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -/** - * -/* ^ comment.block.documentation.c punctuation.definition.comment.c */ - -///////////////////////////////////////////// -// Modules -///////////////////////////////////////////// - -export module AA; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export module A.B; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ - -export module A.BB.C.D; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^^^^^^ entity.name.module.c++ */ - -export module ABC:DE; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^ entity.name.partition.other */ - -module ABC; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -module :private; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^^^ entity.name.partition.private */ - -import A; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ entity.name.module.c++ */ - -import :B; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^ entity.name.partition.other */ - -import "ABC"; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^ meta.module.import.c++ string.quoted.double.import.c++ */ -/* ^ punctuation.definition.string.begin.c++ */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.terminator.c++ */ - -import ; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^ meta.module.import.c++ string.quoted.other.lt-gt.import.c++ */ -/* ^ punctuation.definition.string.begin */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.terminator.c++ */ - -import "ABC/BCD.h"; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^^^^^^ meta.module.import.c++ string.quoted.double.import.c++ */ -/* ^ punctuation.definition.string.begin.c++ */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.terminator.c++ */ - -// Doesn't break grammar when missing semi-colon. -export module ABC:d -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^ entity.name.partition.other */ - -// Doesn't break grammar when missing semi-colon. -export import ABC:d -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^ entity.name.partition.other */ - -module .test.module; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^^^^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -import .test.module; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^^^^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -module test : part1:part2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -module abc.def.:part1:part2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^^^^ entity.name.module.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -module test. -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^^ entity.name.module.c++ */ -/* ^ - invalid.illegal.unexpected-character.c++ */ - -module test. ; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^ entity.name.module.c++ */ -/* ^^ invalid.illegal.unexpected-character.c++ */ -/* ^ punctuation.terminator.c++ */ - -import :part1:part2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -module :private:test2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^^^ entity.name.partition.private */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -import .test.module; import ABD; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^^^^^^ source.c++ */ -/* ^ punctuation.terminator.c++ */ -/* ^^^^^^ meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export module ABC:test1:test2; import DEF; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ -/* ^^^^^^ meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export module ABC:test1:test2 import DEF; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^ - entity.name.partition.other */ -/* ^^^^^^ meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export { -/* <- keyword.control.c++ */ -/* ^ meta.block.c++ punctuation.section.block.begin.c++ */ - void test(); -/* ^^^^ meta.block.c++ storage.type.c */ -/* ^^^^ meta.block.c++ meta.function.c++ entity.name.function.c++ */ - void test2(); -/* ^^^^ meta.block.c++ storage.type.c */ -/* ^^^^^ meta.block.c++ meta.function.c++ entity.name.function.c++ */ -} -/* <- meta.block.c++ punctuation.section.block.end.c++ */ - -export void test3(); -/* <- keyword.control.c++ */ -/* ^^^^ storage.type.c */ -/* ^^^^^ meta.function.c++ entity.name.function.c++ */ - -export -/* <- keyword.control.c++ */ -template -/* <- meta.template.c++ keyword.declaration.template.c++ */ -void test4() -{ - return; -} - -///////////////////////////////////////////// -// Concepts -///////////////////////////////////////////// - -template -/* <- meta.template.c++ keyword.declaration.template.c++ */ -concept has_foo = requires(T t) { -/* <- meta.concept.c++ keyword.declaration.concept.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ */ -/* ^^^^^^^ meta.concept.c++ entity.name.concept.c++ */ -/* ^^^^^^^^^^^^^^^ meta.concept.c++ meta.constraint.c++ */ -/* ^^^^^ meta.function.parameters.c++ */ -/* ^ meta.function.c++ meta.block.c++ */ - t.foo(); -/* ^^^^^^^^ meta.concept.c++ meta.constraint.c++ meta.function.c++ meta.block.c++ */ -} && std::move_constructible; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ meta.constraint.c++ */ - -template -/* <- meta.template.c++ keyword.declaration.template.c++ */ -void foo() requires std::same_as -/* <- storage.type.c */ -/* ^^^ meta.function.c++ entity.name.function.c++ */ -/* ^^^^^^^^ meta.function.c++ meta.constraint.c++ storage.modifier.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.function.c++ meta.constraint.c++ */ -{ - return; -} - -template requires std::same_as -/* <- meta.template.c++ keyword.declaration.template.c++ */ -/* ^^^^^^^^ meta.constraint.c++ storage.modifier.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.constraint.c++ */ -void bar() -/* <- storage.type.c */ -/* ^^^ meta.function.c++ entity.name.function.c++ */ -{ - return; -} - -#define GTY0 -/* ^^^^ meta.preprocessor.macro.c++ */ -#define GTY1(A) -/* ^^^^ entity.name.function.preprocessor */ -/* ^^^ meta.preprocessor.macro.parameters */ -#define GTY2(A, B) -/* ^^^^ entity.name.function.preprocessor */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ - -struct GTY0 foo { -/*<- keyword.declaration.struct.type.c++ */ -/* ^^^^ meta.assumed-macro */ -/* ^^^ entity.name.struct.c++ */ -}; - -struct GTY1(42) bar { -/*<- keyword.declaration.struct.type.c++ */ -/* ^^^^ meta.function-call.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^^^ entity.name.struct.c++ */ -}; - -enum GTY1("struct") baz { -/*<- keyword.declaration.enum.type.c++ */ -/* ^^^^ meta.function-call.c++ */ -/* ^^^^^^^^ string */ -/* ^^^ entity.name.enum.c++ */ -}; - -union GTY2("union struct", 42) bazz { -/*<- keyword.declaration.union.type.c++ */ -/* ^^^^ meta.function-call.c++ */ -/* ^^^^^^^^^^^^^^ string */ -/* ^^ constant.numeric.value.c++ */ -/* ^^^^ entity.name.union.c++ */ -}; - -class GTY2("struct class", 42) bazzz { -/*<- keyword.declaration.class.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ entity.name.class.c++ */ -}; +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + A::~A() { +// ^^ punctuation.accessor.double-colon.c++ +// ^^ variable.function.c++ +// ^ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + delete this; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.operator.word.c++ +// ^^^^ variable.language.c++ +// ^ punctuation.terminator.c + } +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + template +// ^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ + concept MyConcept = std::same_as || requires(T a) { something(a) == 0; }; +//^^ meta.template.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ entity.name.concept.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^ keyword.operator.assignment.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + export module test.module:part; +// ^^^^^^ keyword.other.c++ +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + module test.module:part; +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + import test.module:part; +// ^^^^^^ keyword.other.import.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index a072f4eebc..923f107d40 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -3,6 +3,10 @@ # http://www.sublimetext.com/docs/3/syntax.html name: Objective-C++ scope: source.objc++ +version: 2 +extends: + - Packages/Objective-C/Objective-C.sublime-syntax + - Packages/C++/C++.sublime-syntax file_extensions: - mm @@ -14,2186 +18,19 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \bobj(ective-)?(c\+\+|cpp\b) .*? -\*- # editorconfig ) -variables: - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - path_lookahead: '(?:::\s*)?(?:{{identifier}}\s*::\s*)*(?:template\s+)?{{identifier}}' - operator_method_name: '\boperator\s*(?:[-+*/%ˆ&|~!=<>]|[-+*/%^&|=!<>]=|<=>|<<=?|>>=?|&&|\|\||\+\+|--|,|->\*?|\(\)|\[\]|""\s*{{identifier}})' - casts: 'const_cast|dynamic_cast|reinterpret_cast|static_cast' - operator_keywords: 'and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq|noexcept' - coroutine_keywords: co_(?:await|return|yield) - control_keywords: 'break|case|catch|continue|default|do|else|for|goto|if|_Pragma|return|switch|throw|try|while|{{coroutine_keywords}}' - memory_operators: 'new|delete' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum\s+class|enum\s+struct|enum|class' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|export|extern|friend|explicit|virtual|register|thread_local' - type_qualifier: 'const|mutable|typename|volatile' - constant_expression_specifiers: 'consteval|constexpr|constinit' - compiler_directive: 'inline|restrict|__restrict__|__restrict' - visibility_modifiers: 'private|protected|public' - other_keywords: 'typedef|nullptr|{{visibility_modifiers}}|static_assert|sizeof|using|typeid|alignof|alignas|namespace|template' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}|{{constant_expression_specifiers}}' - non_angle_brackets: '(?=<<|<=)' - - regular: '[^(){}&;*^%=<>-]*' - regular_plus: '[^(){}&;*^%=<>-]+' - paren_open: (?:\( - paren_close: '\))?' - generic_open: (?:{{regular_plus}}(?:< - generic_close: '>)?)?' - balance_parentheses: '{{regular}}{{paren_open}}{{regular}}{{paren_close}}{{regular}}' - generic_lookahead: <{{generic_open}}{{generic_open}}{{regular}}{{generic_close}}\s*{{generic_close}}{{balance_parentheses}}> - - data_structures_forward_decl_lookahead: '(\s+{{macro_identifier}})*\s*(:\s*({{path_lookahead}}|{{visibility_modifiers}}|,|\s|<[^;]*>)+)?;' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__|typeid|alignof|alignas|static_assert' - contexts: - main: - - include: preprocessor-global - - include: global - - ## Common context layout - - global: - - include: preprocessor-expressions - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: global-modifier - - include: using-namespace - - include: namespace - - include: keywords-angle-brackets - - match: '(?={{path_lookahead}}\s*<)' - push: global-modifier - - include: objc-structures - - include: global-block-comments - - include: early-expressions - - match: ^\s*\b(extern)(?=\s+"C(\+\+)?") - scope: storage.modifier.objc++ - push: - - include: comments - - include: strings - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_scope: meta.extern-c.objc++ - - match: '^\s*(#\s*ifdef)\s*__cplusplus\s*' - scope: meta.preprocessor.objc++ - captures: - 1: keyword.control.import.objc++ - set: - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: preprocessor-global - - include: global - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: preprocessor-global - - include: global - - match: (?=\S) - set: global-modifier - - match: ^\s*(?=\w) - push: global-modifier - - include: late-expressions - - global-block-comments: - # NOTE: This context overrides `comments` context, which re-uses scopes - # from `source.c#comments`. So keep the trailing `c` for consistency reasons! - - match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n? - scope: comment.block.banner.c - captures: - 1: punctuation.definition.comment.begin.c - 2: meta.toc-list.banner.block.c - 3: punctuation.definition.comment.end.c - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.c punctuation.definition.comment.c - push: global-block-comment-after - # documentation block comments - - match: (?:/\*!|/\*{2,}) - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-documentation-body - # normal block comments - - match: /\* - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-body - - global-block-comment-after: - - match: \s*(?=\w) - set: global-modifier - - match: '' - pop: true - - statements: - - include: preprocessor-statements - - include: preprocessor-expressions - - include: scope:source.c#label - - include: expressions - - statements-enum: - - include: comments - - include: preprocessor-statements - - include: scope:source.c#label - - match: '{{identifier}}' - scope: entity.name.constant.objc++ - push: constant-value - - match: ',' - scope: punctuation.separator.objc++ - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: early-expressions-before-generic-type - - include: generic-type - - include: early-expressions-after-generic-type - - early-expressions-before-generic-type: - - include: comments - - include: case-default - - include: using-namespace - - include: typedef - - include: using-alias - - include: keywords-angle-brackets - - include: keywords-parens - - include: keywords - - include: numbers - # Prevent a '<' from getting scoped as the start of another template - # parameter list, if in reality a less-than-or-equals sign or - # three-way comparison operator is meant. - - match: '<=>?' - scope: keyword.operator.comparison.c - - early-expressions-after-generic-type: - - include: members-arrow - - include: operators - - include: members-dot - - include: strings - - include: parens - - include: block - - include: variables - - include: constants - - match: ',' - scope: punctuation.separator.objc++ - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.objc++ - - include: bracketed-content - - include: brackets - - expressions-minus-generic-type: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions - - expressions-minus-generic-type-function-call: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions-before-function-call - - include: scope:source.c++#identifiers - - match: ';' - scope: punctuation.terminator.objc++ - - late-expressions: - - include: late-expressions-before-function-call - - include: function-call - - include: scope:source.c++#identifiers - - match: ';' - scope: punctuation.terminator.objc++ - - late-expressions-before-function-call: - - include: scope:source.c++#unique-late-expressions - - include: modifiers-parens - - include: modifiers - - include: types - - expressions-minus-function-call: - - include: early-expressions - - include: late-expressions-before-function-call - - include: scope:source.c++#identifiers - - match: ';' - scope: punctuation.terminator.objc++ - - comments: - - include: scope:source.c#comments - - operators: - - include: scope:source.c#operators - - modifiers: - - include: scope:source.objc#unique-modifiers - - include: scope:source.c++#unique-modifiers - - include: scope:source.c#modifiers - - variables: - - include: scope:source.objc#unique-variables - - include: scope:source.c++#unique-variables - - include: scope:source.c#variables - - constants: - - include: scope:source.objc#unique-constants - - match: '(?=\bNS\w+\b)' - push: scope:source.objc#ns-identifiers - - include: scope:source.c++#unique-constants - - include: scope:source.c#constants - - keywords: - - include: scope:source.objc#unique-keywords - - include: scope:source.c++#unique-keywords - - include: scope:source.c#keywords - - types: - - include: scope:source.objc#unique-types - - match: '(?=\bNS\w+\b)' - push: scope:source.objc#ns-identifiers - - include: scope:source.c++#unique-types - - include: types-parens - - include: scope:source.c#types - - strings: - - include: scope:source.objc#unique-strings - - include: scope:source.c++#unique-strings - - include: scope:source.c#strings - - numbers: - - include: scope:source.c++#numbers - - ########################################## - # Directly from Objective-C.sublime-syntax - ########################################## - - bracketed-content: - - match: '(\[)\s*(?={{identifier}}\s+[^\s,])' - captures: - 1: punctuation.section.scope.begin.objc++ - push: - - meta_scope: meta.bracketed.objc++ - - match: '\]' - scope: punctuation.section.scope.end.objc++ - pop: true - - match: \s*(NSPredicate)\s+(predicateWithFormat(:)) - captures: - 1: support.class.cocoa.objc++ - 2: support.function.any-method.objc++ - 3: punctuation.separator.arguments.objc++ - push: - - meta_scope: meta.function-call.predicate.objc++ - - include: scope:source.objc#ns-predicate - - include: expressions - - match: '\s+(\w+)(?=\s*\])' - captures: - 1: support.function.any-method.objc++ - - match: '\s+(\w+(:))' - captures: - 1: support.function.any-method.objc++ - 2: punctuation.separator.arguments.objc++ - push: - - meta_scope: meta.function-call.objc++ - - match: '(?=\])' - pop: true - - match: \b\w+(:) - scope: support.function.any-method.name-of-parameter.objc++ - captures: - 1: punctuation.separator.arguments.objc++ - - include: expressions - - include: expressions - - objc-structures: - - match: '((@)(interface|protocol))(?!.+;)\s+([[:alpha:]_][[:alnum:]_]*)\s*((:)(?:\s*)([[:alpha:]][[:alnum:]]*))?(\s|\n)?' - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - 4: entity.name.type.objc++ - 6: punctuation.definition.entity.other.inherited-class.objc++ - 7: entity.other.inherited-class.objc++ - 8: meta.divider.objc++ - 9: meta.inherited-class.objc++ - push: - - meta_scope: meta.interface-or-protocol.objc++ - - meta_content_scope: meta.scope.interface.objc++ - - match: ((@)end)\b - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - match: '((@)(implementation))\s+([[:alpha:]_][[:alnum:]_]*)\s*(?::\s*([[:alpha:]][[:alnum:]]*))?' - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - 4: entity.name.type.objc++ - 5: entity.other.inherited-class.objc++ - push: - - meta_scope: meta.implementation.objc++ - - meta_content_scope: meta.scope.implementation.objc++ - - match: ((@)end)\b - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - objc-structure-body: - - include: scope:source.objc#properties - - include: scope:source.objc#protocol_list - - include: method - - include: expressions - - method: - - match: ^(-|\+)\s* - push: - - meta_scope: meta.function.objc++ - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_scope: meta.block.objc++ - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: (?=@end\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - match: '(?=#|@end|;)' - pop: true - - match: '\(' - scope: meta.return-type.objc++ punctuation.definition.type.objc++ - push: - - meta_scope: meta.return-type.objc++ - - match: (\))\s*(\w+\b) - captures: - 1: punctuation.definition.type.objc++ - 2: entity.name.function.objc++ - pop: true - - include: scope:source.objc#protocol_list - - include: scope:source.objc#protocol_type_qualifier - - include: expressions - - match: \b\w+(?=:) - scope: entity.name.function.name-of-parameter.objc++ - - match: ((:))\s*(\() - captures: - 1: entity.name.function.name-of-parameter.objc++ - 2: punctuation.separator.arguments.objc++ - 3: punctuation.definition.type.objc++ - push: - - meta_scope: meta.argument-type.objc++ - - match: (\))\s*(\w+\b)? - captures: - 1: punctuation.definition.type.objc++ - 2: variable.parameter.function.objc++ - pop: true - - include: scope:source.objc#protocol_list - - include: scope:source.objc#protocol_type_qualifier - - include: expressions - - include: comments - - include: attribute - - match: '(,)\s+(\.\.\.)\s*' - captures: - 1: punctuation.separator.objc++ - 2: keyword.operator.variadic.objc++ - push: - - include: scope:source.c#function-call - - match: '(?=\S)' - pop: true - - ## Preprocessor for objc-structures - - preprocessor-objc-structures: - - include: preprocessor-rule-enabled-objc-structures - - include: preprocessor-rule-disabled-objc-structures - - preprocessor-rule-disabled-objc-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: objc-structure-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-objc-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: objc-structure-body - - ################################## - # Directly from C++.sublime-syntax - ################################## - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.objc++ - push: - - match: (?=[);,]) - pop: true - - match: ':' - scope: punctuation.separator.objc++ - pop: true - - include: expressions - - modifiers-parens: - - match: '\b(alignas)\b\s*(\()' - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - include: attribute - - match: \b(__declspec)(\() - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.objc++ - - match: ',' - scope: punctuation.separator.objc++ - - match: '=' - scope: keyword.operator.assignment.objc++ - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.objc++ - - attribute: - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push : - - meta_scope: meta.attribute.objc++ - - meta_content_scope: meta.group.objc++ - - include: parens - - include: strings - - match: \)\) - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - types-parens: - - match: '\b(decltype)\b\s*(\()' - captures: - 1: keyword.declaration.type.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - keywords-angle-brackets: - - match: \b({{casts}})\b\s* - scope: keyword.operator.word.cast.objc++ - push: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - match: '<' - scope: punctuation.definition.generic.begin.objc++ - push: - - match: '(?=>)' - pop: true - - include: expressions-minus-generic-type-function-call - - keywords-parens: - - match: '\b(alignof|typeid|static_assert|sizeof)\b\s*(\()' - captures: - 1: keyword.operator.word.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - using-namespace: - - match: '\b(using)\s+(namespace)\b' - captures: - 1: keyword.control.objc++ - 2: keyword.control.objc++ - push: - - include: scope:source.c++#identifiers - - match: '' - pop: true - - namespace: - - match: '\b(namespace)\s+(?=({{path_lookahead}})?(?!\s*[;,]))' - scope: meta.namespace.objc++ - captures: - 1: keyword.control.objc++ - push: - - meta_content_scope: meta.namespace.objc++ entity.name.namespace.objc++ - - include: scope:source.c++#identifiers - - match: '' - set: - - meta_scope: meta.namespace.objc++ - - include: comments - - match: '=' - scope: keyword.operator.alias.objc++ - - match: '(?=;)' - pop: true - - match: '\}' - scope: meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.objc++ - push: - - meta_scope: meta.block.objc++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - - include: expressions - - template-common: - # Exit the template scope if we hit some basic invalid characters. This - # helps when a user is in the middle of typing their template types and - # prevents re-highlighting the whole file until the next > is found. - - match: (?=[{};]) - pop: true - - include: expressions - - template: - - match: \btemplate\b - scope: keyword.declaration.template.objc++ - push: - - meta_scope: meta.template.objc++ - # Explicitly include comments here at the top, in order to NOT match the - # \S lookahead in the case of comments. - - include: comments - - match: < - scope: punctuation.definition.generic.begin.objc++ - set: - - meta_content_scope: meta.template.objc++ - - match: '>' - scope: meta.template.objc++ punctuation.definition.generic.end.objc++ - pop: true - - match: \.{3} - scope: keyword.operator.variadic.objc++ - - match: \b(typename|{{before_tag}})\b - scope: keyword.declaration.objc++ - - include: template # include template here for nested templates - - include: template-common - - match: (?=\S) - set: - - meta_content_scope: meta.template.objc++ - - match: \b({{before_tag}})\b - scope: keyword.declaration.objc++ - - include: template-common - - generic-type: - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}}\s*(\(|\{))' - push: - - meta_scope: meta.function-call.objc++ - - match: \btemplate\b - scope: keyword.declaration.template.objc++ - - match: (?:(::)\s*)?({{identifier}})\s*(<) - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - 3: punctuation.definition.generic.begin.objc++ - push: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - include: expressions-minus-generic-type-function-call - - match: (?:(::)\s*)?({{identifier}})\s*(\() - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - 3: punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: (?:(::)\s*)?({{identifier}})\s*(\{) - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - 3: punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\}' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - include: scope:source.c++#identifiers - - include: angle-brackets - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\}' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}})' - push: - - include: scope:source.c++#identifiers - - match: '<' - scope: punctuation.definition.generic.begin.objc++ - set: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - include: expressions-minus-generic-type-function-call - - angle-brackets: - - match: '<(?!<)' - scope: punctuation.definition.generic.begin.objc++ - push: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - include: expressions-minus-generic-type-function-call - - block: - - match: '\{' - scope: punctuation.section.block.begin.objc++ - push: - - meta_scope: meta.block.objc++ - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - function-call: - - match: (?={{path_lookahead}}\s*(\(|\{)) - push: - - meta_scope: meta.function-call.objc++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: punctuation.accessor.double-colon.objc++ - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match: '\}' - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - members-inside-function-call: - - meta_content_scope: meta.method-call.objc++ meta.group.objc++ - - match: \) - scope: meta.method-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - members-after-accessor-junction: - # After we've seen an accessor (dot or arrow), this context decides what - # kind of entity we're accessing. - - include: comments - - match: \btemplate\b - scope: meta.method-call.objc++ keyword.declaration.template.objc++ - # Guaranteed to be a template member function call after we match this - set: - - meta_content_scope: meta.method-call.objc++ - - include: comments - - match: '{{identifier}}' - scope: variable.function.member.objc++ - set: - - meta_content_scope: meta.method-call.objc++ - - match: \( - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: members-inside-function-call - - include: comments - - include: angle-brackets - - match: (?=\S) # safety pop - pop: true - - match: (?=\S) # safety pop - pop: true - # Non-templated member function call - - match: (~?{{identifier}})\s*(\() - captures: - 0: meta.method-call.objc++ - 1: variable.function.member.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - set: members-inside-function-call - # Templated member function call - - match: (~?{{identifier}})\s*(?={{generic_lookahead}}) - captures: - 1: variable.function.member.objc++ - set: - - meta_scope: meta.method-call.objc++ - - match: < - scope: punctuation.definition.generic.begin.objc++ - set: - - meta_content_scope: meta.method-call.objc++ - - match: '>' - scope: punctuation.definition.generic.end.objc++ - set: - - meta_content_scope: meta.method-call.objc++ - - include: comments - - match: \( - scope: punctuation.section.group.begin.objc++ - set: members-inside-function-call - - match: (?=\S) # safety pop - pop: true - - include: expressions - # Explicit base-class access - - match: ({{identifier}})\s*(::) - captures: - 1: variable.other.base-class.objc++ - 2: punctuation.accessor.double-colon.objc++ - set: members-after-accessor-junction # reset - # Just a regular member variable - - match: '{{identifier}}' - scope: variable.other.readwrite.member.objc++ - pop: true - - members-dot: - - include: scope:source.c#access-illegal - # No lookahead required because members-dot goes after operators in the - # early-expressions-after-generic-type context. This means triple dots - # (i.e. "..." or "variadic") is attempted first. - - match: \. - scope: punctuation.accessor.dot.objc++ - push: members-after-accessor-junction - - members-arrow: - # This needs to be before operators in the - # early-expressions-after-generic-type context because otherwise the "->" - # from the C language will match. - - match: -> - scope: punctuation.accessor.arrow.objc++ - push: members-after-accessor-junction - - using-alias: - # consume keyword if followed by typename - - match: '\b(using)\b(?=\s+typename\b)' - captures: - 1: keyword.control.objc++ - - match: '\b(using)\b\s+({{identifier}})(?!\s*(<|::))' - captures: - 1: keyword.control.objc++ - 2: entity.name.type.using.objc++ - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.objc++ - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.objc++ - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions-minus-generic-type - - parens: - - match: \( - scope: punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.group.objc++ - - match: \) - scope: punctuation.section.group.end.objc++ - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.objc++ - push: - - meta_scope: meta.brackets.objc++ - - match: \] - scope: punctuation.section.brackets.end.objc++ - pop: true - - include: expressions - - function-trailing-return-type: - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - - include: scope:source.c++#identifiers - - match: \*|& - scope: keyword.operator.objc++ - - include: function-trailing-return-type-parens - - match: '(?=\S)' - pop: true - - function-trailing-return-type-parens: - - match: \( - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.group.objc++ - - match: \) - scope: punctuation.section.group.end.objc++ - pop: true - - include: function-trailing-return-type - - ## Detection of function and data structure definitions at the global level - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - # Constructors and destructors don't have a type - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*{{identifier}}\s*\()' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.constructor.objc++ - - match: '(?=[^\w\s])' - set: function-definition-params - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*~{{identifier}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?(~{{identifier}})' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.destructor.objc++ - - match: '(?=[^\w\s])' - set: function-definition-params - # If we see a path ending in :: before a newline, we don't know if it is - # a constructor or destructor, or a long return type, so we are just going - # to treat it like a regular function. Most likely it is a constructor, - # since it doesn't seem most developers would create such a long typename. - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*$)' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(::)\s*$' - captures: - 1: punctuation.accessor.double-colon.objc++ - - match: '(?:(::)\s*)?(~?{{identifier}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.objc++ - - match: '(?=[^\w\s])' - set: function-definition-params - - include: scope:source.c++#unique-strings - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \*|& - scope: keyword.operator.objc++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.objc++ - set: - - include: scope:source.c++#identifiers - - match: '' - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '(?={{path_lookahead}}\s*\()' - set: - - include: function-call - - match: '' - pop: true - - include: variables - - include: constants - - include: scope:source.c++#identifiers - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.objc++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.objc++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Operator overloading - - match: '(?=({{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*)?{{operator_method_name}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?({{operator_method_name}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.objc++ - - match: '(?=\s*(\(|$))' - set: function-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\(|$)))' - push: - - include: scope:source.c++#identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*(\(|$))' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\(|$))' - set: [function-definition-params, global-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [function-definition-params, global-function-identifier] - - match: '(?=\S)' - pop: true - - global-function-identifier-generic: - - meta_content_scope: meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})(?=\s*(<.*>)?\s*\()' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.objc++ - - match: '(?=\()' - pop: true - - global-function-identifier: - - meta_content_scope: meta.toc-list.full-identifier.objc++ - - match: '(?:(::)\s*)?({{identifier}})(?!\s*(::))' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - include: scope:source.c++#identifiers - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.objc++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.objc++ meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.function.parameters.objc++ meta.group.objc++ - - match : \) - scope: punctuation.section.group.end.objc++ - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.objc++ - - match: '=' - scope: keyword.operator.assignment.objc++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.objc++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.objc++ - set: function-definition-trailing-return - - include: scope:source.c++#function-specifiers - - match: '=' - scope: keyword.operator.assignment.objc++ - - match: '&' - scope: keyword.operator.objc++ - - match: \b0\b - scope: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - - match: \b(default|delete)\b - scope: storage.modifier.objc++ - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: function-definition-body - - include: scope:source.c++#function-specifiers - - include: function-trailing-return-type - - function-definition-body: - - meta_content_scope: meta.function.objc++ meta.block.objc++ - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.function.objc++ meta.block.objc++ - - match: '\}' - scope: meta.function.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Data structures including classes, structs, unions and enums - - data-structures: - - match: '\bclass\b' - scope: keyword.declaration.class.objc++ - set: data-structures-class-definition - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{path_lookahead}}\s+{{path_lookahead}}\s*[=;\[])' - scope: keyword.declaration.objc++ - - match: '\bstruct\b' - scope: keyword.declaration.struct.objc++ - set: data-structures-struct-definition - - match: '\benum(\s+(class|struct))?\b' - scope: keyword.declaration.enum.objc++ - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.objc++ - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - - preprocessor-workaround-eat-macro-before-identifier: - # Handle macros so they aren't matched as the class name - - match: ({{macro_identifier}})(?=\s+~?{{identifier}}) - captures: - 1: meta.assumed-macro.c - - data-structures-class-definition: - - meta_scope: meta.class.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.class.forward-decl.objc++ - set: data-structures-class-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.class.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.class.objc++ - set: data-structures-class-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-class-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-class-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-class-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-class-definition-after-identifier: - - meta_content_scope: meta.class.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.class.objc++ meta.block.objc++ - - match: '\}' - scope: meta.class.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: data-structures-body - - data-structures-struct-definition: - - meta_scope: meta.struct.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.struct.forward-decl.objc++ - set: data-structures-struct-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.struct.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.struct.objc++ - set: data-structures-struct-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-struct-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-struct-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-struct-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-identifier: - - meta_content_scope: meta.struct.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.struct.objc++ meta.block.objc++ - - match: '\}' - scope: meta.struct.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.enum.forward-decl.objc++ - set: data-structures-enum-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.enum.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.enum.objc++ - set: data-structures-enum-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-enum-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-enum-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-enum-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-identifier: - - meta_content_scope: meta.enum.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.enum.objc++ meta.block.objc++ - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: statements-enum - - data-structures-union-definition: - - meta_scope: meta.union.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.union.forward-decl.objc++ - set: data-structures-union-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.union.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.union.objc++ - set: data-structures-union-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-union-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-union-definition-after-identifier - - match: '(?=[{])' - set: data-structures-union-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-identifier: - - meta_content_scope: meta.union.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - # Unions don't support base classes - - include: angle-brackets - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.union.objc++ meta.block.objc++ - - match: '\}' - scope: meta.union.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: data-structures-body - - match: '(?=;)' - pop: true - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - include: scope:source.c++#preprocessor-workaround-eat-macro-before-identifier - - data-structures-definition-common-end: - - include: angle-brackets - - match: \bfinal\b - scope: storage.modifier.c++ - - match: ':' - scope: punctuation.separator.objc++ - push: - - include: comments - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - match: '\b(virtual|{{visibility_modifiers}})\b' - scope: storage.modifier.objc++ - - match: (?={{path_lookahead}}) - push: - - meta_scope: entity.other.inherited-class.objc++ - - include: scope:source.c++#identifiers - - match: '' - pop: true - - include: angle-brackets - - match: ',' - scope: punctuation.separator.objc++ - - match: (?=\{|;) - pop: true - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: data-structures-modifier - - include: typedef - - match: \b({{visibility_modifiers}})\s*(:)(?!:) - captures: - 1: storage.modifier.objc++ - 2: punctuation.section.class.objc++ - - match: '^\s*(?=(?:~?\w+|::))' - push: data-structures-modifier - - include: preprocessor-expressions - - include: expressions-minus-generic-type - - data-structures-modifier-friend: - - match: (?=;) - pop: true - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_scope: meta.block.objc++ - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - include: expressions-minus-function-call - - data-structures-modifier: - - match: '\bfriend\b' - scope: storage.modifier.objc++ - push: - - include: comments - - match: '\b({{before_tag}})\b' - scope: keyword.declaration.objc++ - set: data-structures-modifier-friend - - match: '(?=\S)(?=[^;]+;)' - set: data-structures-modifier-friend - - match: '(?=\S)' - pop: true - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '\bstatic_assert(?=\s*\()' - scope: meta.static-assert.objc++ keyword.operator.word.objc++ - push: - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match: '\)' - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - # Destructor - - match: '(?:{{identifier}}\s*(::)\s*)?~{{identifier}}(?=\s*(\(|$))' - scope: meta.method.destructor.objc++ entity.name.function.destructor.objc++ - captures: - 1: punctuation.accessor.objc++ - set: method-definition-params - # It's a macro, not a constructor if there is no type in the first param - - match: '({{identifier}})\s*(\()(?=\s*(?!void){{identifier}}\s*[),])' - captures: - 1: variable.function.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - # Constructor - - include: scope:source.c++#preprocessor-workaround-eat-macro-before-identifier - - match: '((?!{{before_tag}}|template){{identifier}})(?=\s*\()' - scope: meta.method.constructor.objc++ entity.name.function.constructor.objc++ - set: method-definition-params - # Long form constructor - - match: '({{identifier}}\s*(::)\s*{{identifier}})(?=\s*\()' - captures: - 1: meta.method.constructor.objc++ entity.name.function.constructor.objc++ - 2: punctuation.accessor.objc++ - push: method-definition-params - - match: '(?=\S)' - set: data-structures-type - - data-structures-type: - - include: comments - - match: \*|& - scope: keyword.operator.objc++ - # Cast methods - - match: '(operator)\s+({{identifier}})(?=\s*(\(|$))' - captures: - 1: keyword.control.objc++ - 2: meta.method.objc++ entity.name.function.objc++ - set: method-definition-params - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: data-structures-maybe-method - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.objc++ - set: - - include: scope:source.c++#identifiers - - match: '' - set: data-structures-maybe-method - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: variables - - include: constants - - include: scope:source.c++#identifiers - - match: (?=[&*]) - set: data-structures-maybe-method - - match: (?=\W) - pop: true - - data-structures-maybe-method: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.objc++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.objc++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # Operator overloading - - match: '{{operator_method_name}}(?=\s*(\(|$))' - scope: meta.method.objc++ entity.name.function.objc++ - set: method-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\()))' - push: - - include: scope:source.c++#identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}})\s*(\())' - set: [method-definition-params, data-structures-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\())' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?=\S)' - pop: true - - data-structures-function-identifier-generic: - - include: angle-brackets - - match: '(?={{identifier}})' - push: - - meta_content_scope: entity.name.function.objc++ - - include: scope:source.c++#identifiers - - match: '(?=<)' - pop: true - - match: '(?=\()' - pop: true - - data-structures-function-identifier: - - meta_content_scope: entity.name.function.objc++ - - include: scope:source.c++#identifiers - - match: '(?=\S)' - pop: true - - method-definition-params: - - meta_content_scope: meta.method.objc++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.method.parameters.objc++ meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.method.parameters.objc++ meta.group.objc++ - - match : \) - scope: punctuation.section.group.end.objc++ - set: method-definition-continue - - match: '\bvoid\b' - scope: storage.type.objc++ - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.objc++ - - match: '=' - scope: keyword.operator.assignment.objc++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: expressions-minus-generic-type - - match: '(?=\S)' - pop: true - - method-definition-continue: - - meta_content_scope: meta.method.objc++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.objc++ - set: method-definition-trailing-return - - include: scope:source.c++#function-specifiers - - match: '=' - scope: keyword.operator.assignment.objc++ - - match: '&' - scope: keyword.operator.objc++ - - match: \b0\b - scope: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - - match: \b(default|delete)\b - scope: storage.modifier.objc++ - - match: '(?=:)' - set: - - match: ':' - scope: punctuation.separator.initializer-list.objc++ - set: - - meta_scope: meta.method.constructor.initializer-list.objc++ - - match: '{{identifier}}' - scope: variable.other.readwrite.member.objc++ - push: - - match: \( - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.group.objc++ - - match: \) - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: \{ - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.group.objc++ - - match: \} - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - include: comments - - match: (?=\{|;) - set: method-definition-continue - - include: expressions - - match: '(?=\{)' - set: method-definition-body - - match: '(?=\S)' - pop: true - - method-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: method-definition-body - - include: scope:source.c++#function-specifiers - - include: function-trailing-return-type - - method-definition-body: - - meta_content_scope: meta.method.objc++ meta.block.objc++ - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.method.objc++ meta.block.objc++ - - match: '\}' - scope: meta.method.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - include: scope:source.c++#preprocessor-practical-workarounds - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc++ - push: - - meta_scope: meta.preprocessor.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.objc++ - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.objc++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.objc++ - pop: true - - match: \} - scope: punctuation.section.block.end.objc++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*(endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc++ - push: - - meta_scope: meta.preprocessor.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.objc++ - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{path_lookahead}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.objc++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - scope: variable.function.objc++ - captures: - 1: punctuation.accessor.objc++ - 2: punctuation.accessor.objc++ - - match: '(?:(::)\s*)?{{identifier}}' - scope: variable.function.objc++ - captures: - 1: punctuation.accessor.objc++ - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: preprocessor-if-branch-function-call-arguments - - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match : \) - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match: \) - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.objc++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.objc++ - pop: true - - match: \} - scope: meta.block.objc++ punctuation.section.block.end.objc++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.objc++ - push: - - match: '\{' - scope: punctuation.section.block.begin.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.objc++ keyword.control.import.define.objc++ - push: - - meta_content_scope: meta.preprocessor.macro.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.objc++ - set: - - match: '\(' - scope: punctuation.section.group.begin.objc++ - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.objc++ - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.objc++ meta.group.objc++ - - match: '{{identifier}}' - scope: variable.parameter.objc++ - - match: \) - scope: punctuation.section.group.end.objc++ - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.objc++ - push: - - match: '{{identifier}}' - scope: variable.parameter.objc++ - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc++ - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.objc++ - captures: - 1: punctuation.definition.comment.objc++ - 2: punctuation.definition.comment.objc++ - - match: '\S+' - scope: invalid.illegal.unexpected-character.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc++ - - match: (/\*).*(\*/) - scope: comment.block.objc++ - captures: - 1: punctuation.definition.comment.objc++ - 2: punctuation.definition.comment.objc++ - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.objc++ - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.objc++ - - match: '\}' - scope: punctuation.section.block.end.objc++ - # Captures the namespace macro idiom - - match: '\b(namespace)\s+(?={{path_lookahead}}\s*\{)' - scope: meta.namespace.objc++ - captures: - 1: keyword.control.objc++ - push: - - meta_content_scope: meta.namespace.objc++ entity.name.namespace.objc++ - - include: scope:source.c++#identifiers - - match: '(?=\S)' - pop: true - - include: expressions - - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.objc++ - push: - - meta_scope: meta.preprocessor.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.objc++ - push: - - meta_scope: meta.preprocessor.diagnostic.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.objc++ - - match: ^\s*(#\s*(?:include|include_next|embed))\b - captures: - 1: keyword.control.import.include.objc++ - push: - - meta_scope: meta.preprocessor.include.objc++ - - include: preprocessor-other-include-common - - match: ^\s*(#\s*import)\b - captures: - 1: keyword.control.import.import.objc++ - push: - - meta_scope: meta.preprocessor.import.objc++ - - include: preprocessor-other-include-common - - include: scope:source.c++#preprocessor-practical-workarounds - - preprocessor-other-include-common: - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.objc++ - push: - - meta_scope: string.quoted.double.include.objc++ - - match: '"' - scope: punctuation.definition.string.end.objc++ - pop: true - - match: < - scope: punctuation.definition.string.begin.objc++ - push: - - meta_scope: string.quoted.other.lt-gt.include.objc++ - - match: ">" - scope: punctuation.definition.string.end.objc++ - pop: true + protocol-list: + - include: template + message-enclosure: [] + enclosure: + - meta_prepend: true + - match: (?=\[(?!\s*{{identifier}}\s*[:\]])) + branch_point: message + branch: [pre-message, pre-lambda] + + pre-lambda: + - match: \[\[ + scope: meta.brackts.square.objc++ punctuation.section.brackets.begin.objc++ + set: enclosure.attribute + - include: lambda-enclosure + - include: pop-immediately \ No newline at end of file diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 812e5d05af..e23d08ea1e 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -3,6 +3,8 @@ # http://www.sublimetext.com/docs/3/syntax.html name: Objective-C scope: source.objc +version: 2 +extends: Packages/C++/C.sublime-syntax file_extensions: - m @@ -13,1422 +15,400 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \bobj(ective-)?c\b(?![#+]) .*? -\*- # editorconfig ) -variables: - identifier: '\b[[:alpha:]_][[:alnum:]_]*\b' - control_keywords: 'break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while' - before_tag: 'struct|union|enum' - common_protocols: '\bNS(GlyphStorage|M(utableCopying|enuItem)|C(hangeSpelling|o(ding|pying|lorPicking(Custom|Default)))|T(oolbarItemValidations|ext(Input|AttachmentCell))|I(nputServ(iceProvider|erMouseTracker)|gnoreMisspelledWords)|Obj(CTypeSerializationCallBack|ect)|D(ecimalNumberBehaviors|raggingInfo)|U(serInterfaceValidations|RL(HandleClient|DownloadDelegate|ProtocolClient|AuthenticationChallengeSender))|Validated(ToolbarItem|UserInterfaceItem)|Locking)\b' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__' - contexts: main: - - include: preprocessor-global - - include: global - - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the - # Objective-C++ syntax. They are specifically constructed to not push into - # sub-contexts, which ensures that Objective-C++ code isn't accidentally - # lexed as plain Objective-C. - # - # The "unique-*" contexts are additions that Objective-C makes over C, and - # thus can be directly reused in Objective-C++ along with contexts from C++ - # and C. - ############################################################################# + - meta_prepend: true + - include: interface + - include: implementation - properties: - - match: ((@)property)\s*(\() - captures: - 1: keyword.other.property.objc - 2: punctuation.definition.keyword.objc - 3: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.property-with-attributes.objc - - match: '\)' - scope: punctuation.section.scope.end.objc - pop: true - - match: \b(getter|setter|readonly|readwrite|assign|retain|copy|nonatomic|strong|weak|class|nonnull|nullable|null_unspecified|null_resettable)\b - scope: keyword.other.property.attribute.objc - - match: ',' - scope: punctuation.separator.objc - - match: ((@)property)\b - scope: meta.property.objc + implementation: + - match: ^\s*(@implementation)\b captures: - 1: keyword.other.property.objc - 2: punctuation.definition.keyword.objc - - protocol_list: - - match: '<' - scope: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.protocol-list.objc - - match: '>' - scope: punctuation.section.scope.end.objc - pop: true - - match: '{{common_protocols}}' - scope: support.other.protocol.objc - - protocol_type_qualifier: - - match: \b(in|out|inout|oneway|bycopy|byref)\b - scope: storage.modifier.protocol.objc - - ns-predicate: - - match: '(?=\])' - pop: true - - match: \bargument(?:Array|s)(:) - scope: support.function.any-method.name-of-parameter.objc - captures: - 1: punctuation.separator.arguments.objc - - match: \b\w+(:) - scope: invalid.illegal.unknown-method.objc - captures: - 1: punctuation.separator.arguments.objc - - match: '@"' - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.double.objc - - match: '"' - scope: punctuation.definition.string.end.objc - pop: true - - match: \b(?i:AND|OR|NOT|IN)\b - scope: keyword.operator.logical.predicate.cocoa.objc - - match: \b(?i:ALL|ANY|SOME|NONE)\b - scope: constant.language.predicate.cocoa.objc - - match: \b(?i:NULL|NIL|SELF|TRUE|YES|FALSE|NO|FIRST|LAST|SIZE)\b - scope: constant.language.predicate.cocoa.objc - - match: \b(?i:MATCHES|CONTAINS|BEGINSWITH|ENDSWITH|BETWEEN|LIKE)\b - scope: keyword.operator.comparison.predicate.cocoa.objc - - match: \b(?i:C(ASEINSENSITIVE|I))\b - scope: keyword.other.modifier.predicate.cocoa.objc - - match: \b(?i:ANYKEY|SUBQUERY|CAST|TRUEPREDICATE|FALSEPREDICATE)\b - scope: keyword.other.predicate.cocoa.objc - - match: '\\(\\|[abefnrtv''"?]|[0-3]\d{,2}|[4-7]\d?|x[a-zA-Z0-9]+)' - scope: constant.character.escape.objc - - match: \\. - scope: invalid.illegal.unknown-escape.objc - - unique-strings: - - match: '@"' - scope: punctuation.definition.string.begin.objc + 1: keyword.declaration.class.objc + push: implementation-start + implementation-start: + - meta_scope: meta.implementation.objc + - match: '{{identifier}}' + scope: entity.name.type.objc push: - - meta_scope: string.quoted.double.objc - - match: '"' - scope: punctuation.definition.string.end.objc - pop: true - - include: scope:source.c#string_escaped_char - - match: '%@' - scope: constant.other.placeholder.objc - - include: scope:source.c#string_placeholder - - unique-keywords: - - match: (@)(dynamic|synthesize)\b - scope: keyword.other.property.directive.objc - captures: - 1: punctuation.definition.keyword.objc - - match: \b(NS_DURING|NS_HANDLER|NS_ENDHANDLER)\b - scope: keyword.control.macro.objc - - match: (@)(try|catch|finally|throw)\b - scope: keyword.control.exception.objc - captures: - 1: punctuation.definition.keyword.objc - - match: (@)(synchronized)\b - scope: keyword.control.synchronize.objc - captures: - 1: punctuation.definition.keyword.objc - - match: (@)(defs|encode)\b - scope: keyword.other.objc - captures: - 1: punctuation.definition.keyword.objc + - pop-twice + - interface-body + - include: else-pop - unique-variables: - - match: \b_cmd\b - scope: variable.other.selector.objc - - match: \b(self|super)\b - scope: variable.language.objc - - match: \bNSApp\b - scope: support.variable.foundation - - unique-constants: - - match: \b(YES|NO|Nil|nil)\b - scope: constant.language.objc - - unique-modifiers: - - match: (@)(synchronized|public|private|protected)\b - scope: storage.modifier.objc + interface: + - match: ^\s*(@interface)\b captures: - 1: punctuation.definition.storage.modifier.objc - - unique-types: - - match: ((@)selector)\s*(\() - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - 3: punctuation.definition.storage.type.objc + 1: keyword.declaration.class.objc push: - - meta_scope: meta.selector.objc - - meta_content_scope: meta.selector.method-name.objc - - match: '\)' - scope: punctuation.definition.storage.type.objc - pop: true - - match: '\b(?:[[:alpha:]_:][[:alnum:]_]*)+' - scope: support.function.any-method.name-of-parameter.objc - captures: - 1: punctuation.separator.arguments.objc - - match: \b(id)\s*(?=<) + - meta_scope: meta.interface.objc + - include: interface-start + - match: ^\s*(@protocol)\b captures: - 1: storage.type.objc + 1: keyword.declaration.class.objc push: - - meta_scope: meta.id-with-protocol.objc - - match: '>' - scope: punctuation.section.scope.end.objc - pop: true - - match: '<' - scope: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.protocol-list.objc - - match: '(?=>)' - pop: true - - match: '{{common_protocols}}' - scope: support.other.protocol.objc - - match: \bid\b(\s|\n)? - scope: storage.type.id.objc - - match: \b(IBOutlet|IBAction|BOOL|SEL|id|unichar|IMP|Class)\b - scope: storage.type.objc - - match: (@)(class|protocol)\b - scope: storage.type.objc - captures: - 1: punctuation.definition.storage.type.objc - - match: \bC(I(Sampler|Co(ntext|lor)|Image(Accumulator)?|PlugIn(Registration)?|Vector|Kernel|Filter(Generator|Shape)?)|A(Renderer|MediaTiming(Function)?|BasicAnimation|ScrollLayer|Constraint(LayoutManager)?|T(iledLayer|extLayer|rans(ition|action))|OpenGLLayer|PropertyAnimation|KeyframeAnimation|Layer|A(nimation(Group)?|ction)))\b - scope: support.class.quartz.objc - - match: \bC(G(Float|Point|Size|Rect)|IFormat|AConstraintAttribute)\b - scope: support.type.quartz.objc + - meta_scope: meta.protocol.objc + - include: interface-start - # This context is separate since the regexes are huge and they affect - # compilation speed and caching performance - ns-identifiers: - - match: (\s*)\b(NS(Rect(ToCGRect|FromCGRect)|MakeCollectable|S(tringFromProtocol|ize(ToCGSize|FromCGSize))|Draw(NinePartImage|ThreePartImage)|P(oint(ToCGPoint|FromCGPoint)|rotocolFromString)|EventMaskFromType|Value))\b - captures: - 1: punctuation.whitespace.support.function.cocoa.leopard.objc - 2: support.function.cocoa.leopard.objc - - match: (\s*)\b(NS(R(ound(DownToMultipleOfPageSize|UpToMultipleOfPageSize)|un(CriticalAlertPanel(RelativeToWindow)?|InformationalAlertPanel(RelativeToWindow)?|AlertPanel(RelativeToWindow)?)|e(set(MapTable|HashTable)|c(ycleZone|t(Clip(List)?|F(ill(UsingOperation|List(UsingOperation|With(Grays|Colors(UsingOperation)?))?)?|romString))|ordAllocationEvent)|turnAddress|leaseAlertPanel|a(dPixel|l(MemoryAvailable|locateCollectable))|gisterServicesProvider)|angeFromString)|Get(SizeAndAlignment|CriticalAlertPanel|InformationalAlertPanel|UncaughtExceptionHandler|FileType(s)?|WindowServerMemory|AlertPanel)|M(i(n(X|Y)|d(X|Y))|ouseInRect|a(p(Remove|Get|Member|Insert(IfAbsent|KnownAbsent)?)|ke(R(ect|ange)|Size|Point)|x(Range|X|Y)))|B(itsPer(SampleFromDepth|PixelFromDepth)|e(stDepth|ep|gin(CriticalAlertSheet|InformationalAlertSheet|AlertSheet)))|S(ho(uldRetainWithZone|w(sServicesMenuItem|AnimationEffect))|tringFrom(R(ect|ange)|MapTable|S(ize|elector)|HashTable|Class|Point)|izeFromString|e(t(ShowsServicesMenuItem|ZoneName|UncaughtExceptionHandler|FocusRingStyle)|lectorFromString|archPathForDirectoriesInDomains)|wap(Big(ShortToHost|IntToHost|DoubleToHost|FloatToHost|Long(ToHost|LongToHost))|Short|Host(ShortTo(Big|Little)|IntTo(Big|Little)|DoubleTo(Big|Little)|FloatTo(Big|Little)|Long(To(Big|Little)|LongTo(Big|Little)))|Int|Double|Float|L(ittle(ShortToHost|IntToHost|DoubleToHost|FloatToHost|Long(ToHost|LongToHost))|ong(Long)?)))|H(ighlightRect|o(stByteOrder|meDirectory(ForUser)?)|eight|ash(Remove|Get|Insert(IfAbsent|KnownAbsent)?)|FSType(CodeFromFileType|OfFile))|N(umberOfColorComponents|ext(MapEnumeratorPair|HashEnumeratorItem))|C(o(n(tainsRect|vert(GlyphsToPackedGlyphs|Swapped(DoubleToHost|FloatToHost)|Host(DoubleToSwapped|FloatToSwapped)))|unt(MapTable|HashTable|Frames|Windows(ForContext)?)|py(M(emoryPages|apTableWithZone)|Bits|HashTableWithZone|Object)|lorSpaceFromDepth|mpare(MapTables|HashTables))|lassFromString|reate(MapTable(WithZone)?|HashTable(WithZone)?|Zone|File(namePboardType|ContentsPboardType)))|TemporaryDirectory|I(s(ControllerMarker|EmptyRect|FreedObject)|n(setRect|crementExtraRefCount|te(r(sect(sRect|ionR(ect|ange))|faceStyleForKey)|gralRect)))|Zone(Realloc|Malloc|Name|Calloc|Fr(omPointer|ee))|O(penStepRootDirectory|ffsetRect)|D(i(sableScreenUpdates|videRect)|ottedFrameRect|e(c(imal(Round|Multiply|S(tring|ubtract)|Normalize|Co(py|mpa(ct|re))|IsNotANumber|Divide|Power|Add)|rementExtraRefCountWasZero)|faultMallocZone|allocate(MemoryPages|Object))|raw(Gr(oove|ayBezel)|B(itmap|utton)|ColorTiledRects|TiledRects|DarkBezel|W(hiteBezel|indowBackground)|LightBezel))|U(serName|n(ionR(ect|ange)|registerServicesProvider)|pdateDynamicServices)|Java(Bundle(Setup|Cleanup)|Setup(VirtualMachine)?|Needs(ToLoadClasses|VirtualMachine)|ClassesF(orBundle|romPath)|ObjectNamedInPath|ProvidesClasses)|P(oint(InRect|FromString)|erformService|lanarFromDepth|ageSize)|E(n(d(MapTableEnumeration|HashTableEnumeration)|umerate(MapTable|HashTable)|ableScreenUpdates)|qual(R(ects|anges)|Sizes|Points)|raseRect|xtraRefCount)|F(ileTypeForHFSTypeCode|ullUserName|r(ee(MapTable|HashTable)|ame(Rect(WithWidth(UsingOperation)?)?|Address)))|Wi(ndowList(ForContext)?|dth)|Lo(cationInRange|g(v|PageSize)?)|A(ccessibility(R(oleDescription(ForUIElement)?|aiseBadArgumentException)|Unignored(Children(ForOnlyChild)?|Descendant|Ancestor)|PostNotification|ActionDescription)|pplication(Main|Load)|vailableWindowDepths|ll(MapTable(Values|Keys)|HashTableObjects|ocate(MemoryPages|Collectable|Object)))))\b - captures: - 1: punctuation.whitespace.support.function.leading.cocoa.objc - 2: support.function.cocoa.objc - - match: \bNS(NotFound|Ordered(Ascending|Descending|Same))\b - scope: support.constant.cocoa.objc - - match: \bNS(MenuDidBeginTracking|ViewDidUpdateTrackingAreas)?Notification\b - scope: support.constant.notification.cocoa.leopard.objc - - match: \bNS(Menu(Did(RemoveItem|SendAction|ChangeItem|EndTracking|AddItem)|WillSendAction)|S(ystemColorsDidChange|plitView(DidResizeSubviews|WillResizeSubviews))|C(o(nt(extHelpModeDid(Deactivate|Activate)|rolT(intDidChange|extDid(BeginEditing|Change|EndEditing)))|lor(PanelColorDidChange|ListDidChange)|mboBox(Selection(IsChanging|DidChange)|Will(Dismiss|PopUp)))|lassDescriptionNeededForClass)|T(oolbar(DidRemoveItem|WillAddItem)|ext(Storage(DidProcessEditing|WillProcessEditing)|Did(BeginEditing|Change|EndEditing)|View(DidChange(Selection|TypingAttributes)|WillChangeNotifyingTextView))|ableView(Selection(IsChanging|DidChange)|ColumnDid(Resize|Move)))|ImageRepRegistryDidChange|OutlineView(Selection(IsChanging|DidChange)|ColumnDid(Resize|Move)|Item(Did(Collapse|Expand)|Will(Collapse|Expand)))|Drawer(Did(Close|Open)|Will(Close|Open))|PopUpButton(CellWillPopUp|WillPopUp)|View(GlobalFrameDidChange|BoundsDidChange|F(ocusDidChange|rameDidChange))|FontSetChanged|W(indow(Did(Resi(ze|gn(Main|Key))|M(iniaturize|ove)|Become(Main|Key)|ChangeScreen(|Profile)|Deminiaturize|Update|E(ndSheet|xpose))|Will(M(iniaturize|ove)|BeginSheet|Close))|orkspace(SessionDid(ResignActive|BecomeActive)|Did(Mount|TerminateApplication|Unmount|PerformFileOperation|Wake|LaunchApplication)|Will(Sleep|Unmount|PowerOff|LaunchApplication)))|A(ntialiasThresholdChanged|ppl(ication(Did(ResignActive|BecomeActive|Hide|ChangeScreenParameters|U(nhide|pdate)|FinishLaunching)|Will(ResignActive|BecomeActive|Hide|Terminate|U(nhide|pdate)|FinishLaunching))|eEventManagerWillProcessFirstEvent)))Notification\b - scope: support.constant.notification.cocoa.objc - - match: \bNS(RuleEditor(RowType(Simple|Compound)|NestingMode(Si(ngle|mple)|Compound|List))|GradientDraws(BeforeStartingLocation|AfterEndingLocation)|M(inusSetExpressionType|a(chPortDeallocate(ReceiveRight|SendRight|None)|pTable(StrongMemory|CopyIn|ZeroingWeakMemory|ObjectPointerPersonality)))|B(oxCustom|undleExecutableArchitecture(X86|I386|PPC(64)?)|etweenPredicateOperatorType|ackgroundStyle(Raised|Dark|L(ight|owered)))|S(tring(DrawingTruncatesLastVisibleLine|EncodingConversion(ExternalRepresentation|AllowLossy))|ubqueryExpressionType|p(e(ech(SentenceBoundary|ImmediateBoundary|WordBoundary)|llingState(GrammarFlag|SpellingFlag))|litViewDividerStyleThi(n|ck))|e(rvice(RequestTimedOutError|M(iscellaneousError|alformedServiceDictionaryError)|InvalidPasteboardDataError|ErrorM(inimum|aximum)|Application(NotFoundError|LaunchFailedError))|gmentStyle(Round(Rect|ed)|SmallSquare|Capsule|Textured(Rounded|Square)|Automatic)))|H(UDWindowMask|ashTable(StrongMemory|CopyIn|ZeroingWeakMemory|ObjectPointerPersonality))|N(oModeColorPanel|etServiceNoAutoRename)|C(hangeRedone|o(ntainsPredicateOperatorType|l(orRenderingIntent(RelativeColorimetric|Saturation|Default|Perceptual|AbsoluteColorimetric)|lectorDisabledOption))|ellHit(None|ContentArea|TrackableArea|EditableTextArea))|T(imeZoneNameStyle(S(hort(Standard|DaylightSaving)|tandard)|DaylightSaving)|extFieldDatePickerStyle|ableViewSelectionHighlightStyle(Regular|SourceList)|racking(Mouse(Moved|EnteredAndExited)|CursorUpdate|InVisibleRect|EnabledDuringMouseDrag|A(ssumeInside|ctive(In(KeyWindow|ActiveApp)|WhenFirstResponder|Always))))|I(n(tersectSetExpressionType|dexedColorSpaceModel)|mageScale(None|Proportionally(Down|UpOrDown)|AxesIndependently))|Ope(nGLPFAAllowOfflineRenderers|rationQueue(DefaultMaxConcurrentOperationCount|Priority(High|Normal|Very(High|Low)|Low)))|D(iacriticInsensitiveSearch|ownloadsDirectory)|U(nionSetExpressionType|TF(16(BigEndianStringEncoding|StringEncoding|LittleEndianStringEncoding)|32(BigEndianStringEncoding|StringEncoding|LittleEndianStringEncoding)))|P(ointerFunctions(Ma(chVirtualMemory|llocMemory)|Str(ongMemory|uctPersonality)|C(StringPersonality|opyIn)|IntegerPersonality|ZeroingWeakMemory|O(paque(Memory|Personality)|bjectP(ointerPersonality|ersonality)))|at(hStyle(Standard|NavigationBar|PopUp)|ternColorSpaceModel)|rintPanelShows(Scaling|Copies|Orientation|P(a(perSize|ge(Range|SetupAccessory))|review)))|Executable(RuntimeMismatchError|NotLoadableError|ErrorM(inimum|aximum)|L(inkError|oadError)|ArchitectureMismatchError)|KeyValueObservingOption(Initial|Prior)|F(i(ndPanelSubstringMatchType(StartsWith|Contains|EndsWith|FullWord)|leRead(TooLargeError|UnknownStringEncodingError))|orcedOrderingSearch)|Wi(ndow(BackingLocation(MainMemory|Default|VideoMemory)|Sharing(Read(Only|Write)|None)|CollectionBehavior(MoveToActiveSpace|CanJoinAllSpaces|Default))|dthInsensitiveSearch)|AggregateExpressionType)\b - scope: support.constant.cocoa.leopard.objc - - match: \bNS(R(GB(ModeColorPanel|ColorSpaceModel)|ight(Mouse(D(own(Mask)?|ragged(Mask)?)|Up(Mask)?)|T(ext(Movement|Alignment)|ab(sBezelBorder|StopType))|ArrowFunctionKey)|ound(RectBezelStyle|Bankers|ed(BezelStyle|TokenStyle|DisclosureBezelStyle)|Down|Up|Plain|Line(CapStyle|JoinStyle))|un(StoppedResponse|ContinuesResponse|AbortedResponse)|e(s(izableWindowMask|et(CursorRectsRunLoopOrdering|FunctionKey))|ce(ssedBezelStyle|iver(sCantHandleCommandScriptError|EvaluationScriptError))|turnTextMovement|doFunctionKey|quiredArgumentsMissingScriptError|l(evancyLevelIndicatorStyle|ative(Before|After))|gular(SquareBezelStyle|ControlSize)|moveTraitFontAction)|a(n(domSubelement|geDateMode)|tingLevelIndicatorStyle|dio(ModeMatrix|Button)))|G(IFFileType|lyph(Below|Inscribe(B(elow|ase)|Over(strike|Below)|Above)|Layout(WithPrevious|A(tAPoint|gainstAPoint))|A(ttribute(BidiLevel|Soft|Inscribe|Elastic)|bove))|r(ooveBorder|eaterThan(Comparison|OrEqualTo(Comparison|PredicateOperatorType)|PredicateOperatorType)|a(y(ModeColorPanel|ColorSpaceModel)|dient(None|Con(cave(Strong|Weak)|vex(Strong|Weak)))|phiteControlTint)))|XML(N(o(tationDeclarationKind|de(CompactEmptyElement|IsCDATA|OptionsNone|Use(SingleQuotes|DoubleQuotes)|Pre(serve(NamespaceOrder|C(haracterReferences|DATA)|DTD|Prefixes|E(ntities|mptyElements)|Quotes|Whitespace|A(ttributeOrder|ll))|ttyPrint)|ExpandEmptyElement))|amespaceKind)|CommentKind|TextKind|InvalidKind|D(ocument(X(MLKind|HTMLKind|Include)|HTMLKind|T(idy(XML|HTML)|extKind)|IncludeContentTypeDeclaration|Validate|Kind)|TDKind)|P(arser(GTRequiredError|XMLDeclNot(StartedError|FinishedError)|Mi(splaced(XMLDeclarationError|CDATAEndStringError)|xedContentDeclNot(StartedError|FinishedError))|S(t(andaloneValueError|ringNot(StartedError|ClosedError))|paceRequiredError|eparatorRequiredError)|N(MTOKENRequiredError|o(t(ationNot(StartedError|FinishedError)|WellBalancedError)|DTDError)|amespaceDeclarationError|AMERequiredError)|C(haracterRef(In(DTDError|PrologError|EpilogError)|AtEOFError)|o(nditionalSectionNot(StartedError|FinishedError)|mment(NotFinishedError|ContainsDoubleHyphenError))|DATANotFinishedError)|TagNameMismatchError|In(ternalError|valid(HexCharacterRefError|C(haracter(RefError|InEntityError|Error)|onditionalSectionError)|DecimalCharacterRefError|URIError|Encoding(NameError|Error)))|OutOfMemoryError|D(ocumentStartError|elegateAbortedParseError|OCTYPEDeclNotFinishedError)|U(RI(RequiredError|FragmentError)|n(declaredEntityError|parsedEntityError|knownEncodingError|finishedTagError))|P(CDATARequiredError|ublicIdentifierRequiredError|arsedEntityRef(MissingSemiError|NoNameError|In(Internal(SubsetError|Error)|PrologError|EpilogError)|AtEOFError)|r(ocessingInstructionNot(StartedError|FinishedError)|ematureDocumentEndError))|E(n(codingNotSupportedError|tity(Ref(In(DTDError|PrologError|EpilogError)|erence(MissingSemiError|WithoutNameError)|LoopError|AtEOFError)|BoundaryError|Not(StartedError|FinishedError)|Is(ParameterError|ExternalError)|ValueRequiredError))|qualExpectedError|lementContentDeclNot(StartedError|FinishedError)|xt(ernalS(tandaloneEntityError|ubsetNotFinishedError)|raContentError)|mptyDocumentError)|L(iteralNot(StartedError|FinishedError)|T(RequiredError|SlashRequiredError)|essThanSymbolInAttributeError)|Attribute(RedefinedError|HasNoValueError|Not(StartedError|FinishedError)|ListNot(StartedError|FinishedError)))|rocessingInstructionKind)|E(ntity(GeneralKind|DeclarationKind|UnparsedKind|P(ar(sedKind|ameterKind)|redefined))|lement(Declaration(MixedKind|UndefinedKind|E(lementKind|mptyKind)|Kind|AnyKind)|Kind))|Attribute(N(MToken(sKind|Kind)|otationKind)|CDATAKind|ID(Ref(sKind|Kind)|Kind)|DeclarationKind|En(tit(yKind|iesKind)|umerationKind)|Kind))|M(i(n(XEdge|iaturizableWindowMask|YEdge|uteCalendarUnit)|terLineJoinStyle|ddleSubelement|xedState)|o(nthCalendarUnit|deSwitchFunctionKey|use(Moved(Mask)?|E(ntered(Mask)?|ventSubtype|xited(Mask)?))|veToBezierPathElement|mentary(ChangeButton|Push(Button|InButton)|Light(Button)?))|enuFunctionKey|a(c(intoshInterfaceStyle|OSRomanStringEncoding)|tchesPredicateOperatorType|ppedRead|x(XEdge|YEdge))|ACHOperatingSystem)|B(MPFileType|o(ttomTabsBezelBorder|ldFontMask|rderlessWindowMask|x(Se(condary|parator)|OldStyle|Primary))|uttLineCapStyle|e(zelBorder|velLineJoinStyle|low(Bottom|Top)|gin(sWith(Comparison|PredicateOperatorType)|FunctionKey))|lueControlTint|ack(spaceCharacter|tabTextMovement|ingStore(Retained|Buffered|Nonretained)|TabCharacter|wardsSearch|groundTab)|r(owser(NoColumnResizing|UserColumnResizing|AutoColumnResizing)|eakFunctionKey))|S(h(ift(JISStringEncoding|KeyMask)|ow(ControlGlyphs|InvisibleGlyphs)|adowlessSquareBezelStyle)|y(s(ReqFunctionKey|tem(D(omainMask|efined(Mask)?)|FunctionKey))|mbolStringEncoding)|c(a(nnedOption|le(None|ToFit|Proportionally))|r(oll(er(NoPart|Increment(Page|Line|Arrow)|Decrement(Page|Line|Arrow)|Knob(Slot)?|Arrows(M(inEnd|axEnd)|None|DefaultSetting))|Wheel(Mask)?|LockFunctionKey)|eenChangedEventType))|t(opFunctionKey|r(ingDrawing(OneShot|DisableScreenFontSubstitution|Uses(DeviceMetrics|FontLeading|LineFragmentOrigin))|eam(Status(Reading|NotOpen|Closed|Open(ing)?|Error|Writing|AtEnd)|Event(Has(BytesAvailable|SpaceAvailable)|None|OpenCompleted|E(ndEncountered|rrorOccurred)))))|i(ngle(DateMode|UnderlineStyle)|ze(DownFontAction|UpFontAction))|olarisOperatingSystem|unOSOperatingSystem|pecialPageOrder|e(condCalendarUnit|lect(By(Character|Paragraph|Word)|i(ng(Next|Previous)|onAffinity(Downstream|Upstream))|edTab|FunctionKey)|gmentSwitchTracking(Momentary|Select(One|Any)))|quareLineCapStyle|witchButton|ave(ToOperation|Op(tions(Yes|No|Ask)|eration)|AsOperation)|mall(SquareBezelStyle|C(ontrolSize|apsFontMask)|IconButtonBezelStyle))|H(ighlightModeMatrix|SBModeColorPanel|o(ur(Minute(SecondDatePickerElementFlag|DatePickerElementFlag)|CalendarUnit)|rizontalRuler|meFunctionKey)|TTPCookieAcceptPolicy(Never|OnlyFromMainDocumentDomain|Always)|e(lp(ButtonBezelStyle|KeyMask|FunctionKey)|avierFontAction)|PUXOperatingSystem)|Year(MonthDa(yDatePickerElementFlag|tePickerElementFlag)|CalendarUnit)|N(o(n(StandardCharacterSetFontMask|ZeroWindingRule|activatingPanelMask|LossyASCIIStringEncoding)|Border|t(ification(SuspensionBehavior(Hold|Coalesce|D(eliverImmediately|rop))|NoCoalescing|CoalescingOn(Sender|Name)|DeliverImmediately|PostToAllSessions)|PredicateType|EqualToPredicateOperatorType)|S(cr(iptError|ollerParts)|ubelement|pecifierError)|CellMask|T(itle|opLevelContainersSpecifierError|abs(BezelBorder|NoBorder|LineBorder))|I(nterfaceStyle|mage)|UnderlineStyle|FontChangeAction)|u(ll(Glyph|CellType)|m(eric(Search|PadKeyMask)|berFormatter(Round(Half(Down|Up|Even)|Ceiling|Down|Up|Floor)|Behavior(10|Default)|S(cientificStyle|pellOutStyle)|NoStyle|CurrencyStyle|DecimalStyle|P(ercentStyle|ad(Before(Suffix|Prefix)|After(Suffix|Prefix))))))|e(t(Services(BadArgumentError|NotFoundError|C(ollisionError|ancelledError)|TimeoutError|InvalidError|UnknownError|ActivityInProgress)|workDomainMask)|wlineCharacter|xt(StepInterfaceStyle|FunctionKey))|EXTSTEPStringEncoding|a(t(iveShortGlyphPacking|uralTextAlignment)|rrowFontMask))|C(hange(ReadOtherContents|GrayCell(Mask)?|BackgroundCell(Mask)?|Cleared|Done|Undone|Autosaved)|MYK(ModeColorPanel|ColorSpaceModel)|ircular(BezelStyle|Slider)|o(n(stantValueExpressionType|t(inuousCapacityLevelIndicatorStyle|entsCellMask|ain(sComparison|erSpecifierError)|rol(Glyph|KeyMask))|densedFontMask)|lor(Panel(RGBModeMask|GrayModeMask|HSBModeMask|C(MYKModeMask|olorListModeMask|ustomPaletteModeMask|rayonModeMask)|WheelModeMask|AllModesMask)|ListModeColorPanel)|reServiceDirectory|m(p(osite(XOR|Source(In|O(ut|ver)|Atop)|Highlight|C(opy|lear)|Destination(In|O(ut|ver)|Atop)|Plus(Darker|Lighter))|ressedFontMask)|mandKeyMask))|u(stom(SelectorPredicateOperatorType|PaletteModeColorPanel)|r(sor(Update(Mask)?|PointingDevice)|veToBezierPathElement))|e(nterT(extAlignment|abStopType)|ll(State|H(ighlighted|as(Image(Horizontal|OnLeftOrBottom)|OverlappingImage))|ChangesContents|Is(Bordered|InsetButton)|Disabled|Editable|LightsBy(Gray|Background|Contents)|AllowsMixedState))|l(ipPagination|o(s(ePathBezierPathElement|ableWindowMask)|ckAndCalendarDatePickerStyle)|ear(ControlTint|DisplayFunctionKey|LineFunctionKey))|a(seInsensitive(Search|PredicateOption)|n(notCreateScriptCommandError|cel(Button|TextMovement))|chesDirectory|lculation(NoError|Overflow|DivideByZero|Underflow|LossOfPrecision)|rriageReturnCharacter)|r(itical(Request|AlertStyle)|ayonModeColorPanel))|T(hick(SquareBezelStyle|erSquareBezelStyle)|ypesetter(Behavior|HorizontalTabAction|ContainerBreakAction|ZeroAdvancementAction|OriginalBehavior|ParagraphBreakAction|WhitespaceAction|L(ineBreakAction|atestBehavior))|i(ckMark(Right|Below|Left|Above)|tledWindowMask|meZoneDatePickerElementFlag)|o(olbarItemVisibilityPriority(Standard|High|User|Low)|pTabsBezelBorder|ggleButton)|IFF(Compression(N(one|EXT)|CCITTFAX(3|4)|OldJPEG|JPEG|PackBits|LZW)|FileType)|e(rminate(Now|Cancel|Later)|xt(Read(InapplicableDocumentTypeError|WriteErrorM(inimum|aximum))|Block(M(i(nimum(Height|Width)|ddleAlignment)|a(rgin|ximum(Height|Width)))|B(o(ttomAlignment|rder)|aselineAlignment)|Height|TopAlignment|P(ercentageValueType|adding)|Width|AbsoluteValueType)|StorageEdited(Characters|Attributes)|CellType|ured(RoundedBezelStyle|BackgroundWindowMask|SquareBezelStyle)|Table(FixedLayoutAlgorithm|AutomaticLayoutAlgorithm)|Field(RoundedBezel|SquareBezel|AndStepperDatePickerStyle)|WriteInapplicableDocumentTypeError|ListPrependEnclosingMarker))|woByteGlyphPacking|ab(Character|TextMovement|le(tP(oint(Mask|EventSubtype)?|roximity(Mask|EventSubtype)?)|Column(NoResizing|UserResizingMask|AutoresizingMask)|View(ReverseSequentialColumnAutoresizingStyle|GridNone|S(olid(HorizontalGridLineMask|VerticalGridLineMask)|equentialColumnAutoresizingStyle)|NoColumnAutoresizing|UniformColumnAutoresizingStyle|FirstColumnOnlyAutoresizingStyle|LastColumnOnlyAutoresizingStyle)))|rackModeMatrix)|I(n(sert(CharFunctionKey|FunctionKey|LineFunctionKey)|t(Type|ernalS(criptError|pecifierError))|dexSubelement|validIndexSpecifierError|formational(Request|AlertStyle)|PredicateOperatorType)|talicFontMask|SO(2022JPStringEncoding|Latin(1StringEncoding|2StringEncoding))|dentityMappingCharacterCollection|llegalTextMovement|mage(R(ight|ep(MatchesDevice|LoadStatus(ReadingHeader|Completed|InvalidData|Un(expectedEOF|knownType)|WillNeedAllData)))|Below|C(ellType|ache(BySize|Never|Default|Always))|Interpolation(High|None|Default|Low)|O(nly|verlaps)|Frame(Gr(oove|ayBezel)|Button|None|Photo)|L(oadStatus(ReadError|C(ompleted|ancelled)|InvalidData|UnexpectedEOF)|eft)|A(lign(Right|Bottom(Right|Left)?|Center|Top(Right|Left)?|Left)|bove)))|O(n(State|eByteGlyphPacking|OffButton|lyScrollerArrows)|ther(Mouse(D(own(Mask)?|ragged(Mask)?)|Up(Mask)?)|TextMovement)|SF1OperatingSystem|pe(n(GL(GO(Re(setLibrary|tainRenderers)|ClearFormatCache|FormatCacheSize)|PFA(R(obust|endererID)|M(inimumPolicy|ulti(sample|Screen)|PSafe|aximumPolicy)|BackingStore|S(creenMask|te(ncilSize|reo)|ingleRenderer|upersample|ample(s|Buffers|Alpha))|NoRecovery|C(o(lor(Size|Float)|mpliant)|losestPolicy)|OffScreen|D(oubleBuffer|epthSize)|PixelBuffer|VirtualScreenCount|FullScreen|Window|A(cc(umSize|elerated)|ux(Buffers|DepthStencil)|l(phaSize|lRenderers))))|StepUnicodeReservedBase)|rationNotSupportedForKeyS(criptError|pecifierError))|ffState|KButton|rPredicateType|bjC(B(itfield|oolType)|S(hortType|tr(ingType|uctType)|electorType)|NoType|CharType|ObjectType|DoubleType|UnionType|PointerType|VoidType|FloatType|Long(Type|longType)|ArrayType))|D(i(s(c(losureBezelStyle|reteCapacityLevelIndicatorStyle)|playWindowRunLoopOrdering)|acriticInsensitivePredicateOption|rect(Selection|PredicateModifier))|o(c(ModalWindowMask|ument(Directory|ationDirectory))|ubleType|wn(TextMovement|ArrowFunctionKey))|e(s(cendingPageOrder|ktopDirectory)|cimalTabStopType|v(ice(NColorSpaceModel|IndependentModifierFlagsMask)|eloper(Directory|ApplicationDirectory))|fault(ControlTint|TokenStyle)|lete(Char(acter|FunctionKey)|FunctionKey|LineFunctionKey)|moApplicationDirectory)|a(yCalendarUnit|teFormatter(MediumStyle|Behavior(10|Default)|ShortStyle|NoStyle|FullStyle|LongStyle))|ra(wer(Clos(ingState|edState)|Open(ingState|State))|gOperation(Generic|Move|None|Copy|Delete|Private|Every|Link|All)))|U(ser(CancelledError|D(irectory|omainMask)|FunctionKey)|RL(Handle(NotLoaded|Load(Succeeded|InProgress|Failed))|CredentialPersistence(None|Permanent|ForSession))|n(scaledWindowMask|cachedRead|i(codeStringEncoding|talicFontMask|fiedTitleAndToolbarWindowMask)|d(o(CloseGroupingRunLoopOrdering|FunctionKey)|e(finedDateComponent|rline(Style(Single|None|Thick|Double)|Pattern(Solid|D(ot|ash(Dot(Dot)?)?)))))|known(ColorSpaceModel|P(ointingDevice|ageOrder)|KeyS(criptError|pecifierError))|boldFontMask)|tilityWindowMask|TF8StringEncoding|p(dateWindowsRunLoopOrdering|TextMovement|ArrowFunctionKey))|J(ustifiedTextAlignment|PEG(2000FileType|FileType)|apaneseEUC(GlyphPacking|StringEncoding))|P(o(s(t(Now|erFontMask|WhenIdle|ASAP)|iti(on(Replace|Be(fore|ginning)|End|After)|ve(IntType|DoubleType|FloatType)))|pUp(NoArrow|ArrowAt(Bottom|Center))|werOffEventType|rtraitOrientation)|NGFileType|ush(InCell(Mask)?|OnPushOffButton)|e(n(TipMask|UpperSideMask|PointingDevice|LowerSideMask)|riodic(Mask)?)|P(S(caleField|tatus(Title|Field)|aveButton)|N(ote(Title|Field)|ame(Title|Field))|CopiesField|TitleField|ImageButton|OptionsButton|P(a(perFeedButton|ge(Range(To|From)|ChoiceMatrix))|reviewButton)|LayoutButton)|lainTextTokenStyle|a(useFunctionKey|ragraphSeparatorCharacter|ge(DownFunctionKey|UpFunctionKey))|r(int(ing(ReplyLater|Success|Cancelled|Failure)|ScreenFunctionKey|erTable(NotFound|OK|Error)|FunctionKey)|o(p(ertyList(XMLFormat|MutableContainers(AndLeaves)?|BinaryFormat|Immutable|OpenStepFormat)|rietaryStringEncoding)|gressIndicator(BarStyle|SpinningStyle|Preferred(SmallThickness|Thickness|LargeThickness|AquaThickness)))|e(ssedTab|vFunctionKey))|L(HeightForm|CancelButton|TitleField|ImageButton|O(KButton|rientationMatrix)|UnitsButton|PaperNameButton|WidthForm))|E(n(terCharacter|d(sWith(Comparison|PredicateOperatorType)|FunctionKey))|v(e(nOddWindingRule|rySubelement)|aluatedObjectExpressionType)|qualTo(Comparison|PredicateOperatorType)|ra(serPointingDevice|CalendarUnit|DatePickerElementFlag)|x(clude(10|QuickDrawElementsIconCreationOption)|pandedFontMask|ecuteFunctionKey))|V(i(ew(M(in(XMargin|YMargin)|ax(XMargin|YMargin))|HeightSizable|NotSizable|WidthSizable)|aPanelFontAction)|erticalRuler|a(lidationErrorM(inimum|aximum)|riableExpressionType))|Key(SpecifierEvaluationScriptError|Down(Mask)?|Up(Mask)?|PathExpressionType|Value(MinusSetMutation|SetSetMutation|Change(Re(placement|moval)|Setting|Insertion)|IntersectSetMutation|ObservingOption(New|Old)|UnionSetMutation|ValidationError))|QTMovie(NormalPlayback|Looping(BackAndForthPlayback|Playback))|F(1(1FunctionKey|7FunctionKey|2FunctionKey|8FunctionKey|3FunctionKey|9FunctionKey|4FunctionKey|5FunctionKey|FunctionKey|0FunctionKey|6FunctionKey)|7FunctionKey|i(nd(PanelAction(Replace(A(ndFind|ll(InSelection)?))?|S(howFindPanel|e(tFindString|lectAll(InSelection)?))|Next|Previous)|FunctionKey)|tPagination|le(Read(No(SuchFileError|PermissionError)|CorruptFileError|In(validFileNameError|applicableStringEncodingError)|Un(supportedSchemeError|knownError))|HandlingPanel(CancelButton|OKButton)|NoSuchFileError|ErrorM(inimum|aximum)|Write(NoPermissionError|In(validFileNameError|applicableStringEncodingError)|OutOfSpaceError|Un(supportedSchemeError|knownError))|LockingError)|xedPitchFontMask)|2(1FunctionKey|7FunctionKey|2FunctionKey|8FunctionKey|3FunctionKey|9FunctionKey|4FunctionKey|5FunctionKey|FunctionKey|0FunctionKey|6FunctionKey)|o(nt(Mo(noSpaceTrait|dernSerifsClass)|BoldTrait|S(ymbolicClass|criptsClass|labSerifsClass|ansSerifClass)|C(o(ndensedTrait|llectionApplicationOnlyMask)|larendonSerifsClass)|TransitionalSerifsClass|I(ntegerAdvancementsRenderingMode|talicTrait)|O(ldStyleSerifsClass|rnamentalsClass)|DefaultRenderingMode|U(nknownClass|IOptimizedTrait)|Panel(S(hadowEffectModeMask|t(andardModesMask|rikethroughEffectModeMask)|izeModeMask)|CollectionModeMask|TextColorEffectModeMask|DocumentColorEffectModeMask|UnderlineEffectModeMask|FaceModeMask|All(ModesMask|EffectsModeMask))|ExpandedTrait|VerticalTrait|F(amilyClassMask|reeformSerifsClass)|Antialiased(RenderingMode|IntegerAdvancementsRenderingMode))|cusRing(Below|Type(None|Default|Exterior)|Only|Above)|urByteGlyphPacking|rm(attingError(M(inimum|aximum))?|FeedCharacter))|8FunctionKey|unction(ExpressionType|KeyMask)|3(1FunctionKey|2FunctionKey|3FunctionKey|4FunctionKey|5FunctionKey|FunctionKey|0FunctionKey)|9FunctionKey|4FunctionKey|P(RevertButton|S(ize(Title|Field)|etButton)|CurrentField|Preview(Button|Field))|l(oat(ingPointSamplesBitmapFormat|Type)|agsChanged(Mask)?)|axButton|5FunctionKey|6FunctionKey)|W(heelModeColorPanel|indow(s(NTOperatingSystem|CP125(1StringEncoding|2StringEncoding|3StringEncoding|4StringEncoding|0StringEncoding)|95(InterfaceStyle|OperatingSystem))|M(iniaturizeButton|ovedEventType)|Below|CloseButton|ToolbarButton|ZoomButton|Out|DocumentIconButton|ExposedEventType|Above)|orkspaceLaunch(NewInstance|InhibitingBackgroundOnly|Default|PreferringClassic|WithoutA(ctivation|ddingToRecents)|A(sync|nd(Hide(Others)?|Print)|llowingClassicStartup))|eek(day(CalendarUnit|OrdinalCalendarUnit)|CalendarUnit)|a(ntsBidiLevels|rningAlertStyle)|r(itingDirection(RightToLeft|Natural|LeftToRight)|apCalendarComponents))|L(i(stModeMatrix|ne(Moves(Right|Down|Up|Left)|B(order|reakBy(C(harWrapping|lipping)|Truncating(Middle|Head|Tail)|WordWrapping))|S(eparatorCharacter|weep(Right|Down|Up|Left))|ToBezierPathElement|DoesntMove|arSlider)|teralSearch|kePredicateOperatorType|ghterFontAction|braryDirectory)|ocalDomainMask|e(ssThan(Comparison|OrEqualTo(Comparison|PredicateOperatorType)|PredicateOperatorType)|ft(Mouse(D(own(Mask)?|ragged(Mask)?)|Up(Mask)?)|T(ext(Movement|Alignment)|ab(sBezelBorder|StopType))|ArrowFunctionKey))|a(yout(RightToLeft|NotDone|CantFit|OutOfGlyphs|Done|LeftToRight)|ndscapeOrientation)|ABColorSpaceModel)|A(sc(iiWithDoubleByteEUCGlyphPacking|endingPageOrder)|n(y(Type|PredicateModifier|EventMask)|choredSearch|imation(Blocking|Nonblocking(Threaded)?|E(ffect(DisappearingItemDefault|Poof)|ase(In(Out)?|Out))|Linear)|dPredicateType)|t(Bottom|tachmentCharacter|omicWrite|Top)|SCIIStringEncoding|d(obe(GB1CharacterCollection|CNS1CharacterCollection|Japan(1CharacterCollection|2CharacterCollection)|Korea1CharacterCollection)|dTraitFontAction|minApplicationDirectory)|uto(saveOperation|Pagination)|pp(lication(SupportDirectory|D(irectory|e(fined(Mask)?|legateReply(Success|Cancel|Failure)|activatedEventType))|ActivatedEventType)|KitDefined(Mask)?)|l(ternateKeyMask|pha(ShiftKeyMask|NonpremultipliedBitmapFormat|FirstBitmapFormat)|ert(SecondButtonReturn|ThirdButtonReturn|OtherReturn|DefaultReturn|ErrorReturn|FirstButtonReturn|AlternateReturn)|l(ScrollerParts|DomainsMask|PredicateModifier|LibrariesDirectory|ApplicationsDirectory))|rgument(sWrongScriptError|EvaluationScriptError)|bove(Bottom|Top)|WTEventType))\b - scope: support.constant.cocoa.objc - - match: \bNS(RuleEditor|G(arbageCollector|radient)|MapTable|HashTable|Co(ndition|llectionView(Item)?)|T(oolbarItemGroup|extInputClient|r(eeNode|ackingArea))|InvocationOperation|Operation(Queue)?|D(ictionaryController|ockTile)|P(ointer(Functions|Array)|athC(o(ntrol(Delegate)?|mponentCell)|ell(Delegate)?)|r(intPanelAccessorizing|edicateEditor(RowTemplate)?))|ViewController|FastEnumeration|Animat(ionContext|ablePropertyContainer))\b - scope: support.class.cocoa.leopard.objc - - match: \bNS(R(u(nLoop|ler(Marker|View))|e(sponder|cursiveLock|lativeSpecifier)|an(domSpecifier|geSpecifier))|G(etCommand|lyph(Generator|Storage|Info)|raphicsContext)|XML(Node|D(ocument|TD(Node)?)|Parser|Element)|M(iddleSpecifier|ov(ie(View)?|eCommand)|utable(S(tring|et)|C(haracterSet|opying)|IndexSet|D(ictionary|ata)|URLRequest|ParagraphStyle|A(ttributedString|rray))|e(ssagePort(NameServer)?|nu(Item(Cell)?|View)?|t(hodSignature|adata(Item|Query(ResultGroup|AttributeValueTuple)?)))|a(ch(BootstrapServer|Port)|trix))|B(itmapImageRep|ox|u(ndle|tton(Cell)?)|ezierPath|rowser(Cell)?)|S(hadow|c(anner|r(ipt(SuiteRegistry|C(o(ercionHandler|mmand(Description)?)|lassDescription)|ObjectSpecifier|ExecutionContext|WhoseTest)|oll(er|View)|een))|t(epper(Cell)?|atus(Bar|Item)|r(ing|eam))|imple(HorizontalTypesetter|CString)|o(cketPort(NameServer)?|und|rtDescriptor)|p(e(cifierTest|ech(Recognizer|Synthesizer)|ll(Server|Checker))|litView)|e(cureTextField(Cell)?|t(Command)?|archField(Cell)?|rializer|gmentedC(ontrol|ell))|lider(Cell)?|avePanel)|H(ost|TTP(Cookie(Storage)?|URLResponse)|elpManager)|N(ib(Con(nector|trolConnector)|OutletConnector)?|otification(Center|Queue)?|u(ll|mber(Formatter)?)|etService(Browser)?|ameSpecifier)|C(ha(ngeSpelling|racterSet)|o(n(stantString|nection|trol(ler)?|ditionLock)|d(ing|er)|unt(Command|edSet)|pying|lor(Space|P(ick(ing(Custom|Default)|er)|anel)|Well|List)?|m(p(oundPredicate|arisonPredicate)|boBox(Cell)?))|u(stomImageRep|rsor)|IImageRep|ell|l(ipView|o(seCommand|neCommand)|assDescription)|a(ched(ImageRep|URLResponse)|lendar(Date)?)|reateCommand)|T(hread|ypesetter|ime(Zone|r)|o(olbar(Item(Validations)?)?|kenField(Cell)?)|ext(Block|Storage|Container|Tab(le(Block)?)?|Input|View|Field(Cell)?|List|Attachment(Cell)?)?|a(sk|b(le(Header(Cell|View)|Column|View)|View(Item)?))|reeController)|I(n(dex(S(pecifier|et)|Path)|put(Manager|S(tream|erv(iceProvider|er(MouseTracker)?)))|vocation)|gnoreMisspelledWords|mage(Rep|Cell|View)?)|O(ut(putStream|lineView)|pen(GL(Context|Pixel(Buffer|Format)|View)|Panel)|bj(CTypeSerializationCallBack|ect(Controller)?))|D(i(st(antObject(Request)?|ributed(NotificationCenter|Lock))|ctionary|rectoryEnumerator)|ocument(Controller)?|e(serializer|cimalNumber(Behaviors|Handler)?|leteCommand)|at(e(Components|Picker(Cell)?|Formatter)?|a)|ra(wer|ggingInfo))|U(ser(InterfaceValidations|Defaults(Controller)?)|RL(Re(sponse|quest)|Handle(Client)?|C(onnection|ache|redential(Storage)?)|Download(Delegate)?|Prot(ocol(Client)?|ectionSpace)|AuthenticationChallenge(Sender)?)?|n(iqueIDSpecifier|doManager|archiver))|P(ipe|o(sitionalSpecifier|pUpButton(Cell)?|rt(Message|NameServer|Coder)?)|ICTImageRep|ersistentDocument|DFImageRep|a(steboard|nel|ragraphStyle|geLayout)|r(int(Info|er|Operation|Panel)|o(cessInfo|tocolChecker|perty(Specifier|ListSerialization)|gressIndicator|xy)|edicate))|E(numerator|vent|PSImageRep|rror|x(ception|istsCommand|pression))|V(iew(Animation)?|al(idated(ToolbarItem|UserInterfaceItem)|ue(Transformer)?))|Keyed(Unarchiver|Archiver)|Qui(ckDrawView|tCommand)|F(ile(Manager|Handle|Wrapper)|o(nt(Manager|Descriptor|Panel)?|rm(Cell|atter)))|W(hoseSpecifier|indow(Controller)?|orkspace)|L(o(c(k(ing)?|ale)|gicalTest)|evelIndicator(Cell)?|ayoutManager)|A(ssertionHandler|nimation|ctionCell|ttributedString|utoreleasePool|TSTypesetter|ppl(ication|e(Script|Event(Manager|Descriptor)))|ffineTransform|lert|r(chiver|ray(Controller)?)))\b - scope: support.class.cocoa.objc - - match: \bNS(R(oundingMode|ule(Editor(RowType|NestingMode)|rOrientation)|e(questUserAttentionType|lativePosition))|G(lyphInscription|radientDrawingOptions)|XML(NodeKind|D(ocumentContentKind|TDNodeKind)|ParserError)|M(ultibyteGlyphPacking|apTableOptions)|B(itmapFormat|oxType|ezierPathElement|ackgroundStyle|rowserDropOperation)|S(tr(ing(CompareOptions|DrawingOptions|EncodingConversionOptions)|eam(Status|Event))|p(eechBoundary|litViewDividerStyle)|e(archPathD(irectory|omainMask)|gmentS(tyle|witchTracking))|liderType|aveOptions)|H(TTPCookieAcceptPolicy|ashTableOptions)|N(otification(SuspensionBehavior|Coalescing)|umberFormatter(RoundingMode|Behavior|Style|PadPosition)|etService(sError|Options))|C(haracterCollection|o(lor(RenderingIntent|SpaceModel|PanelMode)|mp(oundPredicateType|arisonPredicateModifier))|ellStateValue|al(culationError|endarUnit))|T(ypesetterControlCharacterAction|imeZoneNameStyle|e(stComparisonOperation|xt(Block(Dimension|V(erticalAlignment|alueType)|Layer)|TableLayoutAlgorithm|FieldBezelStyle))|ableView(SelectionHighlightStyle|ColumnAutoresizingStyle)|rackingAreaOptions)|I(n(sertionPosition|te(rfaceStyle|ger))|mage(RepLoadStatus|Scaling|CacheMode|FrameStyle|LoadStatus|Alignment))|Ope(nGLPixelFormatAttribute|rationQueuePriority)|Date(Picker(Mode|Style)|Formatter(Behavior|Style))|U(RL(RequestCachePolicy|HandleStatus|C(acheStoragePolicy|redentialPersistence))|Integer)|P(o(stingStyle|int(ingDeviceType|erFunctionsOptions)|pUpArrowPosition)|athStyle|r(int(ing(Orientation|PaginationMode)|erTableStatus|PanelOptions)|opertyList(MutabilityOptions|Format)|edicateOperatorType))|ExpressionType|KeyValue(SetMutationKind|Change)|QTMovieLoopMode|F(indPanel(SubstringMatchType|Action)|o(nt(RenderingMode|FamilyClass)|cusRingPlacement))|W(hoseSubelementIdentifier|ind(ingRule|ow(B(utton|ackingLocation)|SharingType|CollectionBehavior)))|L(ine(MovementDirection|SweepDirection|CapStyle|JoinStyle)|evelIndicatorStyle)|Animation(BlockingMode|Curve))\b - scope: support.type.cocoa.leopard.objc - - match: \bNS(R(ect(Edge)?|ange)|G(lyph(Relation|LayoutMode)?|radientType)|M(odalSession|a(trixMode|p(Table|Enumerator)))|B(itmapImageFileType|orderType|uttonType|ezelStyle|ackingStoreType|rowserColumnResizingType)|S(cr(oll(er(Part|Arrow)|ArrowPosition)|eenAuxiliaryOpaque)|tringEncoding|ize|ocketNativeHandle|election(Granularity|Direction|Affinity)|wapped(Double|Float)|aveOperationType)|Ha(sh(Table|Enumerator)|ndler(2)?)|C(o(ntrol(Size|Tint)|mp(ositingOperation|arisonResult))|ell(State|Type|ImagePosition|Attribute))|T(hreadPrivate|ypesetterGlyphInfo|i(ckMarkPosition|tlePosition|meInterval)|o(ol(TipTag|bar(SizeMode|DisplayMode))|kenStyle)|IFFCompression|ext(TabType|Alignment)|ab(State|leViewDropOperation|ViewType)|rackingRectTag)|ImageInterpolation|Zone|OpenGL(ContextAuxiliary|PixelFormatAuxiliary)|D(ocumentChangeType|atePickerElementFlags|ra(werState|gOperation))|UsableScrollerParts|P(oint|r(intingPageOrder|ogressIndicator(Style|Th(ickness|readInfo))))|EventType|KeyValueObservingOptions|Fo(nt(SymbolicTraits|TraitMask|Action)|cusRingType)|W(indow(OrderingMode|Depth)|orkspace(IconCreationOptions|LaunchOptions)|ritingDirection)|L(ineBreakMode|ayout(Status|Direction))|A(nimation(Progress|Effect)|ppl(ication(TerminateReply|DelegateReply|PrintReply)|eEventManagerSuspensionID)|ffineTransformStruct|lertStyle))\b - scope: support.type.cocoa.objc - # Catch-all - - match: \bNS\w+\b - - match: '' - pop: true - - - ############################################################################# - # The following are Objective-C-specific contexts that should not be reused. - # This is because they push into subcontexts and use variables that are - # Objective-C-specific. - ############################################################################# - - ## Common context layout - - global: - - include: objc-structures - - include: early-expressions - - match: '^\s*(?=\w+)' - push: global-modifier - - include: late-expressions - - statements: - - include: preprocessor-statements - - include: scope:source.c#label - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: typedef - - include: keywords-parens - - include: keywords - - include: numbers - - include: operators - - include: strings - - include: parens - - include: block - - include: variables - - include: constants - - include: access - - match: ',' + interface-start: + - match: '{{identifier}}' + scope: entity.name.type.objc + push: + - pop-twice + - interface-body + - interface-struct + - interface-subclass + - interface-category + - include: else-pop + interface-category: + - match: \( + scope: meta.group.objc punctuation.section.group.begin.objc + set: + - meta_content_scope: meta.group.objc entity.name.type.category.objc + - include: enclosure.parenthesis + - include: else-pop + interface-subclass: + - include: protocol-list + - match: ':' scope: punctuation.separator.objc - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.objc - - include: bracketed-content - - include: brackets - - late-expressions: - - include: modifiers-parens - - include: modifiers - - include: types - - include: function-call - - match: ';' - scope: punctuation.terminator.objc - - comments: - - include: scope:source.c#comments - - access: - - include: scope:source.c#access - - keywords: - - include: unique-keywords - - include: scope:source.c#keywords - - numbers: - - include: scope:source.c#numbers - - operators: - - include: scope:source.c#operators - - strings: - - include: unique-strings - - include: scope:source.c#strings - - variables: - - include: unique-variables - - include: scope:source.c#variables - - constants: - - include: unique-constants - - match: '(?=\bNS\w+\b)' - push: ns-identifiers - - include: scope:source.c#constants - - modifiers: - - include: unique-modifiers - - include: scope:source.c#modifiers - - types: - - include: unique-types - - match: '(?=\bNS\w+\b)' - push: ns-identifiers - - include: scope:source.c#types - - ## Objective-C-specific contexts - - bracketed-content: - - match: '(\[)\s*(?={{identifier}}\s+[^\s,])' - captures: - 1: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.bracketed.objc - - match: '\]' - scope: punctuation.section.scope.end.objc - pop: true - - match: \s*(NSPredicate)\s+(predicateWithFormat(:)) - captures: - 1: support.class.cocoa - 2: support.function.any-method.objc - 3: punctuation.separator.arguments.objc - push: - - meta_scope: meta.function-call.predicate.objc - - include: ns-predicate - - include: expressions - - match: '\s+(\w+)(?=\s*\])' - captures: - 1: support.function.any-method.objc - - match: '\s+(\w+(:))' - captures: - 1: support.function.any-method.objc - 2: punctuation.separator.arguments.objc - push: - - meta_scope: meta.function-call.objc - - match: '(?=\])' - pop: true - - match: \b\w+(:) - scope: support.function.any-method.name-of-parameter.objc - captures: - 1: punctuation.separator.arguments.objc - - include: expressions - - include: expressions - - objc-structures: - - match: '((@)(interface|protocol))(?!.+;)\s+([[:alpha:]_][[:alnum:]_]*)\s*((:)(?:\s*)([[:alpha:]][[:alnum:]]*))?(\s|\n)?' - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - 4: entity.name.type.objc - 6: punctuation.definition.entity.other.inherited-class.objc - 7: entity.other.inherited-class.objc - 8: meta.divider.objc - 9: meta.inherited-class.objc - push: - - meta_scope: meta.interface-or-protocol.objc - - meta_content_scope: meta.scope.interface.objc - - match: ((@)end)\b - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - match: '((@)(implementation))\s+([[:alpha:]_][[:alnum:]_]*)\s*(?::\s*([[:alpha:]][[:alnum:]]*))?' - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - 4: entity.name.type.objc - 5: entity.other.inherited-class.objc + - include: expression-identifiers + - include: else-pop + interface-struct: + - match: \{ + scope: meta.block.objc punctuation.section.block.begin.objc + set: enclosure.block + - include: else-pop + interface-body: + - match: \@end\b + scope: keyword.declaration.interface.end.objc + pop: 1 + - match: \@property\b + scope: keyword.other.objc push: - - meta_scope: meta.implementation.objc - - meta_content_scope: meta.scope.implementation.objc - - match: ((@)end)\b - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - objc-structure-body: - - include: properties - - include: protocol_list - - include: method - - include: expressions + - statement + - property + - match: \@(?:synthesize|dynamic)\b + scope: keyword.other.objc + push: statement - method: - - match: ^(-|\+)\s* + - match: (?:\+|\-)\s*(?=\() push: - - meta_scope: meta.function.objc - - match: '\{' - scope: punctuation.section.block.begin.objc - set: - - meta_scope: meta.block.objc - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: (?=@end\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc - pop: true - - include: statements - - match: '(?=#|@end|;)' - pop: true - - match: '\(' - scope: meta.return-type.objc punctuation.definition.type.objc - push: - - meta_scope: meta.return-type.objc - - match: (\))\s*(\w+\b) - captures: - 1: punctuation.definition.type.objc - 2: entity.name.function.objc - pop: true - - include: protocol_list - - include: protocol_type_qualifier - - include: expressions - - match: \b\w+(?=:) - scope: entity.name.function.name-of-parameter.objc - - match: ((:))\s*(\() - captures: - 1: entity.name.function.name-of-parameter.objc - 2: punctuation.separator.arguments.objc - 3: punctuation.definition.type.objc - push: - - meta_scope: meta.argument-type.objc - - match: (\))\s*(\w+\b)? - captures: - 1: punctuation.definition.type.objc - 2: variable.parameter.function.objc - pop: true - - include: protocol_list - - include: protocol_type_qualifier - - include: expressions - - include: comments - - include: attribute - - match: '(,)\s+(\.\.\.)\s*' - captures: - 1: punctuation.separator.objc - 2: keyword.operator.variadic.objc - push: - - include: scope:source.c#function-call - - match: '(?=\S)' - pop: true + - selector + - selector-return + - include: expression - ## Preprocessor for objc-structures - - preprocessor-objc-structures: - - include: preprocessor-rule-enabled-objc-structures - - include: preprocessor-rule-disabled-objc-structures - - preprocessor-rule-disabled-objc-structures: - - match: ^\s*((#if)\s+(0))\b + property: + - match: \( + scope: punctuation.section.group.begin.objc + set: property-attrs + - include: else-pop + property-attrs: + - meta_scope: meta.group.objc + - match: \) + scope: punctuation.section.group.end.objc + pop: 1 + - match: \b([sg]etter)\s*(=)\s*({{identifier}})\b captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: objc-structure-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled + 1: storage.modifier.objc + 2: keyword.operator.assignment.objc + 3: entity.name.function.method.objc + - match: \b(?:[sg]etter|readonly|readwrite|assign|retain|copy|atomic|nonatomic|strong|weak|class|nonnull|nullable|null_unspecified|null_resettable)\b + scope: storage.modifier.objc + - include: punctuation.comma + - include: operator - preprocessor-rule-enabled-objc-structures: - - match: ^\s*((#if)\s+(0*1))\b + selector: + - meta_scope: meta.function.selector.objc + - match: '\b({{identifier}})\s*(\:)\s*(\()' captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc + 1: entity.name.function.method.objc + 2: punctuation.separator.arguments.objc + 3: meta.group.objc punctuation.section.group.begin.objc push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: objc-structure-body - - ################################ - # Directly from C.sublime-syntax - ################################ - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \* - scope: keyword.operator.objc - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - {{identifier}} - (\s+{{identifier}}(?!\s*[{=;])|\s*\*+) - ) - ) + - selector-param + - enclosure.parenthesis + - match: \b({{identifier}})\s*(\:) captures: - 1: keyword.declaration.objc - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/union - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{control_keywords}})\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_scope: meta.function-call.objc - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - match: (?={{identifier}}\s*\() - set: - - include: function-call - - match: '' - pop: true - - include: types - - match: '{{identifier}}' - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \* - scope: keyword.operator.objc - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Identifier that is not the function name - likely a macro - - match: '{{identifier}}(?!\s*(\(|$))' - # Real function definition - - match: '{{identifier}}(?=\s*(\(|$))' - scope: meta.function.objc entity.name.function.objc - set: function-definition-params - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.objc - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.objc meta.group.objc punctuation.section.group.begin.objc - set: - - meta_content_scope: meta.function.parameters.objc meta.group.objc - - match : \) - scope: punctuation.section.group.end.objc - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)))' - scope: variable.parameter.objc - - include: expressions - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true + 1: entity.name.function.method.objc + 2: punctuation.separator.arguments.objc - function-definition-continue: - - meta_content_scope: meta.function.objc - - include: comments - - match: '(?=;)' - pop: true - - match: \b(const|final|noexcept|override)\b - scope: storage.modifier.objc - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-body: - - meta_content_scope: meta.function.objc - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.function.objc meta.block.objc - - match: '\}' - scope: meta.function.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - data-structures: - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{identifier}}\s+{{identifier}}\s*[=;\[])' - scope: keyword.declaration.objc - - match: '\bstruct\b' - scope: keyword.declaration.struct.objc - set: data-structures-struct-definition - - match: '\benum\b' - scope: keyword.declaration.enum.objc - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.objc - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - - data-structures-struct-definition: - - meta_scope: meta.struct.objc - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.struct.forward-decl.objc - - match: '{{identifier}}' - scope: entity.name.struct.objc - set: data-structures-struct-definition-after-name - - include: data-structures-struct-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-name: - - meta_scope: meta.struct.objc - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-struct-definition-block-start - - data-structures-struct-definition-block-start: - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.struct.objc meta.block.objc - - match: '\}' - scope: meta.struct.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - include: data-structures-body + - include: expression-identifiers - data-structures-enum-definition: - - meta_scope: meta.enum.objc - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.enum.forward-decl.objc - - match: '{{identifier}}' - scope: entity.name.enum.objc - set: data-structures-enum-definition-after-name - - include: data-structures-enum-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-name: - - meta_scope: meta.enum.objc - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-enum-definition-block-start - - data-structures-enum-definition-block-start: - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.enum.objc meta.block.objc - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - include: data-structures-body-enum - - data-structures-union-definition: - - meta_scope: meta.union.objc - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.union.forward-decl.objc - - match: '{{identifier}}' - scope: entity.name.union.objc - set: data-structures-union-definition-after-name - - include: data-structures-union-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-name: - - meta_scope: meta.union.objc - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-union-definition-block-start - - data-structures-union-definition-block-start: - - match: '\{' + - match: \b{{identifier}}\b + scope: entity.name.function.method.objc + - match: ; + scope: punctuation.terminator.objc + pop: 1 + - match: \{ scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.union.objc meta.block.objc - - match: '\}' - scope: meta.union.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - include: data-structures-body - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: modifiers-parens - - include: modifiers - - data-structures-definition-common-macro: - # Handle macros so they aren't matched as the class name - - match: '\b[[:upper:][:digit:]_]+\b(?!\s*($|\{))' - - data-structures-definition-common-end: - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - include: expressions - - data-structures-body-enum: - - include: comments - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - match: '{{identifier}}' - scope: entity.name.constant.objc - push: constant-value - - match: ',' - scope: punctuation.separator.objc + set: enclosure.block + - include: operator.variadic + - include: expression + selector-return: + - match: \( + scope: meta.group.objc punctuation.section.group.begin.objc + set: enclosure.parenthesis + selector-param: + - match: \b{{identifier}}\b + scope: variable.parameter.objc + pop: 1 - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions + protocol-list: + - match: \<(?=({{identifier}}|,|\s|\*)*\>) + scope: punctuation.section.scope.begin.objc + push: protocol-list-body + protocol-list-body: + - meta_scope: meta.protocol-list.objc + - include: expression-identifiers + - include: punctuation.comma + - include: operator.pointer + - match: \> + scope: punctuation.section.scope.end.objc + pop: 1 + + expression: + - meta_prepend: true + - match: (\^)\s*(?=\() + captures: + 1: keyword.operator.bitwise.objc + branch_point: block + branch: [block, pop-immediately] + - include: protocol-list + + call-try-not: + - meta_prepend: true + - match: '(?={{identifier}}\s*:)' + pop: 1 block: - - match: '\{' - scope: punctuation.section.block.begin.objc - push: - - meta_scope: meta.block.objc - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc - pop: true - - include: statements - - parens: + - meta_scope: meta.function.block.objc + - match: '' + set: + - block-body + - block-params + block-params: - match: \( scope: punctuation.section.group.begin.objc - push: - - meta_scope: meta.group.objc - - match: \) - scope: punctuation.section.group.end.objc - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.objc - push: - - meta_scope: meta.brackets.objc - - match: \] - scope: punctuation.section.brackets.end.objc - pop: true - - include: expressions - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.objc - push: - - match: ':' - scope: punctuation.separator.objc - pop: true - - include: expressions + set: function-params + - include: else-pop + block-body: + - match: \{ + scope: meta.block.objc punctuation.section.block.begin.objc + set: enclosure.block + - match: (?=\S) + fail: block - modifiers-parens: - - include: attribute - - match: \b(__declspec)(\() - captures: - 1: storage.modifier.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.objc - - match: ',' - scope: punctuation.separator.objc - - match: '=' - scope: keyword.operator.assignment.objc - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.objc + preprocessor: + - meta_prepend: true + - match: '{{dir_start}}import\b' + scope: keyword.control.import.objc + push: preprocessor.include - attribute: - - match: \b(__attribute__)\s*(\(\() + string: + - meta_prepend: true + - match: \@\" + scope: punctuation.definition.string.begin.objc + push: string.double-ns + - match: \@\' + scope: punctuation.definition.string.begin.objc + push: string.single + string.double-ns: + - meta_scope: string.quoted.double.objc + - include: string.double + - match: '%@' + scope: constant.other.placeholder.objc + + keyword: + - meta_prepend: true + - match: \b(?:self|super)\b + scope: variable.language.objc + - match: \@(?:property|synthesize|dynamic)\b + scope: keyword.other.objc + - match: '(@available)\s*(\()' captures: - 1: storage.modifier.objc + 1: keyword.operator.word.objc 2: meta.group.objc punctuation.section.group.begin.objc - push : - - meta_scope: meta.attribute.objc - - meta_content_scope: meta.group.objc - - include: parens - - include: strings - - match: \)\) - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - keywords-parens: - - match: '\b(sizeof)\b\s*(\()' + push: keyword.available + - match: '(@selector)\s*(\()' captures: 1: keyword.operator.word.objc 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.objc - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.objc - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions - - function-call: - - match: (?={{identifier}}\s*\() - push: - - meta_content_scope: meta.function-call.objc - - include: scope:source.c#c99 - - match: '{{identifier}}' - scope: variable.function.objc - - match: '\(' - scope: meta.group.objc punctuation.section.group.begin.objc - set: - - meta_content_scope: meta.function-call.objc meta.group.objc - - match : \) - scope: meta.function-call.objc meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc - push: - - meta_scope: meta.preprocessor.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.objc - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b + push: keyword.selector + - match: '@(?:selector|encode|defs|available)\b' + scope: keyword.operator.word.objc + keyword.control: + - meta_prepend: true + - match: \@(?:autoreleasepool|import|synchronized)\b + scope: keyword.control.objc + - match: '(@catch)\s*(\()' captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.objc - pop: true - - include: statements + 1: keyword.control.exception.objc + 2: meta.group.objc punctuation.section.group.begin.objc + push: function-params + - match: \@(?:try|catch|finally|throw)\b + scope: keyword.control.exception.objc + keyword.storage: + - meta_prepend: true + - match: \b(?:nonnull|nullable|_Nullable|_Nonnull|IBOutlet|IBInspectable|__(?:unused|nonnull|block|weak|strong|autoreleasing|bridge|covariant|contravariant))\b + scope: storage.modifier.objc + - match: \@(?:private|public|protected|package|optional|required)\b + scope: storage.modifier.objc + keyword.type: + - meta_append: true + - match: \b(?:BOOL|Class|SEL|IMP|id|instancetype|IBAction)\b + scope: storage.type.objc + - match: \@(?:interface|class|implementation|protocol|end)\b + scope: keyword.declaration.objc + - match: '(?=\bNS)' + push: ns-identifiers + keyword.available: + - meta_scope: meta.available.objc + - meta_content_scope: meta.group.objc + - match: \) + scope: meta.group.objc punctuation.section.group.end.objc + pop: 1 + - match: \b(?:iOS|macOS|watchOS|tvOS|visionOS)\b + scope: support.constant.platform.objc + - match: \b(\d[\d\.]+)\b + captures: + 1: constant.numeric.version.objc + - include: expression + keyword.selector: + - meta_scope: meta.selector.objc + - meta_content_scope: meta.group.objc meta.selector.method-name.objc + - match: \) + scope: meta.group.objc punctuation.section.group.end.objc + pop: 1 + - match: '[^)]+' + scope: support.function.objc - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b + gnu-attribute: + - meta_append: true + - match: \bobjc_(?:direct|designated_initializer|root_class|requires_super|subclassing_restricted|precise_lifetime)\b + scope: constant.other.objc + - match: \b(swift_name|objc_runtime_name)\s*(\() captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true + 1: storage.modifier.objc + 2: meta.group.objc punctuation.section.group.begin.objc + push: enclosure.parenthesis + + constant: + - meta_prepend: true + - match: \b(nil|Nil)\b + scope: constant.language.null.objc + - match: ((@|\b)YES|@true)\b + scope: constant.language.boolean.true.objc + - match: ((@|\b)NO|@false)\b + scope: constant.language.boolean.false.objc + + type: + - meta_prepend: true + - match: \@(?=\d) + scope: constant.numeric.objc + - match: (\@class)\s*({{identifier}}) + captures: + 1: keyword.declaration.class.objc + 2: entity.name.type.class.objc + + enclosure: + - meta_prepend: true + - include: message-enclosure + - match: '@\{' + scope: punctuation.section.mapping.begin.objc + push: enclosure.mapping + enclosure.mapping: + - meta_scope: meta.mapping.objc - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-global - - include: statements + scope: punctuation.section.mapping.end.objc + pop: 1 + - include: expression - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global + message-enclosure: # for ObjC++ + - match: (?=\[(?!\s*{{identifier}}\s*[:\]])) + branch_point: message + branch: [pre-message, not-message] - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc - push: - - meta_scope: meta.preprocessor.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.objc - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.objc - - include: scope:source.c#c99 - - match: '{{identifier}}' - scope: variable.function.objc - - match: '\(' - scope: meta.group.objc punctuation.section.group.begin.objc - set: preprocessor-if-branch-function-call-arguments + pre-message: + - match: \[ + scope: meta.brackets.square.objc punctuation.section.brackets.begin.objc + set: message + message: + - meta_scope: meta.bracketed.objc - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.objc meta.group.objc - - match : \) - scope: meta.function-call.objc meta.group.objc punctuation.section.group.end.objc - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions + - include: type + - include: keyword + - include: constant + - include: operator.accessor + - include: operator.pointer + - include: call + - include: enclosure - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.objc meta.group.objc - - match: \) - scope: meta.function-call.objc meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions + - match: (?={{identifier}}\s*:) + set: message-func - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-statements - - include: statements + - match: \] + fail: message - preprocessor-block-finish-statements: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b + - match: ({{identifier}})\s*(\]) captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.objc - pop: true - - include: statements + 1: entity.name.function.method.objc + 2: punctuation.section.brackets.end.objc + pop: 1 - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b + - match: '\b({{identifier}})\b' + - match: (?=\S) + fail: message + message-func: + - meta_scope: meta.bracketed.objc + - match: '\b({{identifier}})\s*(:)' captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-statements - - include: statements + 1: entity.name.function.method.objc + 2: punctuation.separator.arguments.objc - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements + - include: expression - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.objc - push: - - match: '\{' - scope: punctuation.section.block.begin.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.objc keyword.control.import.define.objc - push: - - meta_content_scope: meta.preprocessor.macro.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.objc - set: - - match: '\(' - scope: punctuation.section.group.begin.objc - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.objc - set: preprocessor-macro-definition + - match: \] + scope: punctuation.section.brackets.end.objc + pop: 1 - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.objc meta.group.objc - - match: '{{identifier}}' - scope: variable.parameter.objc - - match: \) - scope: punctuation.section.group.end.objc - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.objc - push: - - match: '{{identifier}}' - scope: variable.parameter.objc - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.objc - captures: - 1: punctuation.definition.comment.objc - 2: punctuation.definition.comment.objc - - match: '\S+' - scope: invalid.illegal.unexpected-character.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc - - match: (/\*).*(\*/) - scope: comment.block.objc - captures: - 1: punctuation.definition.comment.objc - 2: punctuation.definition.comment.objc - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.objc - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.objc - - match: '\}' - scope: punctuation.section.block.end.objc - - include: expressions + not-message: + - match: \[\[ + scope: meta.brackets.square.objc punctuation.section.brackts.begin.objc + set: enclosure.attribute + - match: \[ + scope: meta.brackets.square.objc punctuation.section.brackets.begin.objc + set: enclosure.brackets - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.objc - push: - - meta_scope: meta.preprocessor.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc - - match: ^\s*(#\s*(endif)\b) - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.objc - push: - - meta_scope: meta.preprocessor.diagnostic.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.objc - - match: ^\s*(#\s*(?:include|include_next|embed))\b + ns-identifiers: + - match: (\s*)\b(NS(Rect(ToCGRect|FromCGRect)|MakeCollectable|S(tringFromProtocol|ize(ToCGSize|FromCGSize))|Draw(NinePartImage|ThreePartImage)|P(oint(ToCGPoint|FromCGPoint)|rotocolFromString)|EventMaskFromType|Value))\b captures: - 1: keyword.control.import.include.objc - push: - - meta_scope: meta.preprocessor.include.objc - - include: preprocessor-other-include-common - - match: ^\s*(#\s*import)\b + 1: punctuation.whitespace.support.function.cocoa.leopard.objc + 2: support.function.cocoa.leopard.objc + - match: (\s*)\b(NS(R(ound(DownToMultipleOfPageSize|UpToMultipleOfPageSize)|un(CriticalAlertPanel(RelativeToWindow)?|InformationalAlertPanel(RelativeToWindow)?|AlertPanel(RelativeToWindow)?)|e(set(MapTable|HashTable)|c(ycleZone|t(Clip(List)?|F(ill(UsingOperation|List(UsingOperation|With(Grays|Colors(UsingOperation)?))?)?|romString))|ordAllocationEvent)|turnAddress|leaseAlertPanel|a(dPixel|l(MemoryAvailable|locateCollectable))|gisterServicesProvider)|angeFromString)|Get(SizeAndAlignment|CriticalAlertPanel|InformationalAlertPanel|UncaughtExceptionHandler|FileType(s)?|WindowServerMemory|AlertPanel)|M(i(n(X|Y)|d(X|Y))|ouseInRect|a(p(Remove|Get|Member|Insert(IfAbsent|KnownAbsent)?)|ke(R(ect|ange)|Size|Point)|x(Range|X|Y)))|B(itsPer(SampleFromDepth|PixelFromDepth)|e(stDepth|ep|gin(CriticalAlertSheet|InformationalAlertSheet|AlertSheet)))|S(ho(uldRetainWithZone|w(sServicesMenuItem|AnimationEffect))|tringFrom(R(ect|ange)|MapTable|S(ize|elector)|HashTable|Class|Point)|izeFromString|e(t(ShowsServicesMenuItem|ZoneName|UncaughtExceptionHandler|FocusRingStyle)|lectorFromString|archPathForDirectoriesInDomains)|wap(Big(ShortToHost|IntToHost|DoubleToHost|FloatToHost|Long(ToHost|LongToHost))|Short|Host(ShortTo(Big|Little)|IntTo(Big|Little)|DoubleTo(Big|Little)|FloatTo(Big|Little)|Long(To(Big|Little)|LongTo(Big|Little)))|Int|Double|Float|L(ittle(ShortToHost|IntToHost|DoubleToHost|FloatToHost|Long(ToHost|LongToHost))|ong(Long)?)))|H(ighlightRect|o(stByteOrder|meDirectory(ForUser)?)|eight|ash(Remove|Get|Insert(IfAbsent|KnownAbsent)?)|FSType(CodeFromFileType|OfFile))|N(umberOfColorComponents|ext(MapEnumeratorPair|HashEnumeratorItem))|C(o(n(tainsRect|vert(GlyphsToPackedGlyphs|Swapped(DoubleToHost|FloatToHost)|Host(DoubleToSwapped|FloatToSwapped)))|unt(MapTable|HashTable|Frames|Windows(ForContext)?)|py(M(emoryPages|apTableWithZone)|Bits|HashTableWithZone|Object)|lorSpaceFromDepth|mpare(MapTables|HashTables))|lassFromString|reate(MapTable(WithZone)?|HashTable(WithZone)?|Zone|File(namePboardType|ContentsPboardType)))|TemporaryDirectory|I(s(ControllerMarker|EmptyRect|FreedObject)|n(setRect|crementExtraRefCount|te(r(sect(sRect|ionR(ect|ange))|faceStyleForKey)|gralRect)))|Zone(Realloc|Malloc|Name|Calloc|Fr(omPointer|ee))|O(penStepRootDirectory|ffsetRect)|D(i(sableScreenUpdates|videRect)|ottedFrameRect|e(c(imal(Round|Multiply|S(tring|ubtract)|Normalize|Co(py|mpa(ct|re))|IsNotANumber|Divide|Power|Add)|rementExtraRefCountWasZero)|faultMallocZone|allocate(MemoryPages|Object))|raw(Gr(oove|ayBezel)|B(itmap|utton)|ColorTiledRects|TiledRects|DarkBezel|W(hiteBezel|indowBackground)|LightBezel))|U(serName|n(ionR(ect|ange)|registerServicesProvider)|pdateDynamicServices)|Java(Bundle(Setup|Cleanup)|Setup(VirtualMachine)?|Needs(ToLoadClasses|VirtualMachine)|ClassesF(orBundle|romPath)|ObjectNamedInPath|ProvidesClasses)|P(oint(InRect|FromString)|erformService|lanarFromDepth|ageSize)|E(n(d(MapTableEnumeration|HashTableEnumeration)|umerate(MapTable|HashTable)|ableScreenUpdates)|qual(R(ects|anges)|Sizes|Points)|raseRect|xtraRefCount)|F(ileTypeForHFSTypeCode|ullUserName|r(ee(MapTable|HashTable)|ame(Rect(WithWidth(UsingOperation)?)?|Address)))|Wi(ndowList(ForContext)?|dth)|Lo(cationInRange|g(v|PageSize)?)|A(ccessibility(R(oleDescription(ForUIElement)?|aiseBadArgumentException)|Unignored(Children(ForOnlyChild)?|Descendant|Ancestor)|PostNotification|ActionDescription)|pplication(Main|Load)|vailableWindowDepths|ll(MapTable(Values|Keys)|HashTableObjects|ocate(MemoryPages|Collectable|Object)))))\b captures: - 1: keyword.control.import.import.objc - push: - - meta_scope: meta.preprocessor.import.objc - - include: preprocessor-other-include-common - - include: scope:source.c#preprocessor-practical-workarounds + 1: punctuation.whitespace.support.function.leading.cocoa.objc + 2: support.function.cocoa.objc + - match: \bNS(NotFound|Ordered(Ascending|Descending|Same))\b + scope: support.constant.cocoa.objc + - match: \bNS(MenuDidBeginTracking|ViewDidUpdateTrackingAreas)?Notification\b + scope: support.constant.notification.cocoa.leopard.objc + - match: \bNS(Menu(Did(RemoveItem|SendAction|ChangeItem|EndTracking|AddItem)|WillSendAction)|S(ystemColorsDidChange|plitView(DidResizeSubviews|WillResizeSubviews))|C(o(nt(extHelpModeDid(Deactivate|Activate)|rolT(intDidChange|extDid(BeginEditing|Change|EndEditing)))|lor(PanelColorDidChange|ListDidChange)|mboBox(Selection(IsChanging|DidChange)|Will(Dismiss|PopUp)))|lassDescriptionNeededForClass)|T(oolbar(DidRemoveItem|WillAddItem)|ext(Storage(DidProcessEditing|WillProcessEditing)|Did(BeginEditing|Change|EndEditing)|View(DidChange(Selection|TypingAttributes)|WillChangeNotifyingTextView))|ableView(Selection(IsChanging|DidChange)|ColumnDid(Resize|Move)))|ImageRepRegistryDidChange|OutlineView(Selection(IsChanging|DidChange)|ColumnDid(Resize|Move)|Item(Did(Collapse|Expand)|Will(Collapse|Expand)))|Drawer(Did(Close|Open)|Will(Close|Open))|PopUpButton(CellWillPopUp|WillPopUp)|View(GlobalFrameDidChange|BoundsDidChange|F(ocusDidChange|rameDidChange))|FontSetChanged|W(indow(Did(Resi(ze|gn(Main|Key))|M(iniaturize|ove)|Become(Main|Key)|ChangeScreen(|Profile)|Deminiaturize|Update|E(ndSheet|xpose))|Will(M(iniaturize|ove)|BeginSheet|Close))|orkspace(SessionDid(ResignActive|BecomeActive)|Did(Mount|TerminateApplication|Unmount|PerformFileOperation|Wake|LaunchApplication)|Will(Sleep|Unmount|PowerOff|LaunchApplication)))|A(ntialiasThresholdChanged|ppl(ication(Did(ResignActive|BecomeActive|Hide|ChangeScreenParameters|U(nhide|pdate)|FinishLaunching)|Will(ResignActive|BecomeActive|Hide|Terminate|U(nhide|pdate)|FinishLaunching))|eEventManagerWillProcessFirstEvent)))Notification\b + scope: support.constant.notification.cocoa.objc + - match: \bNS(RuleEditor(RowType(Simple|Compound)|NestingMode(Si(ngle|mple)|Compound|List))|GradientDraws(BeforeStartingLocation|AfterEndingLocation)|M(inusSetExpressionType|a(chPortDeallocate(ReceiveRight|SendRight|None)|pTable(StrongMemory|CopyIn|ZeroingWeakMemory|ObjectPointerPersonality)))|B(oxCustom|undleExecutableArchitecture(X86|I386|PPC(64)?)|etweenPredicateOperatorType|ackgroundStyle(Raised|Dark|L(ight|owered)))|S(tring(DrawingTruncatesLastVisibleLine|EncodingConversion(ExternalRepresentation|AllowLossy))|ubqueryExpressionType|p(e(ech(SentenceBoundary|ImmediateBoundary|WordBoundary)|llingState(GrammarFlag|SpellingFlag))|litViewDividerStyleThi(n|ck))|e(rvice(RequestTimedOutError|M(iscellaneousError|alformedServiceDictionaryError)|InvalidPasteboardDataError|ErrorM(inimum|aximum)|Application(NotFoundError|LaunchFailedError))|gmentStyle(Round(Rect|ed)|SmallSquare|Capsule|Textured(Rounded|Square)|Automatic)))|H(UDWindowMask|ashTable(StrongMemory|CopyIn|ZeroingWeakMemory|ObjectPointerPersonality))|N(oModeColorPanel|etServiceNoAutoRename)|C(hangeRedone|o(ntainsPredicateOperatorType|l(orRenderingIntent(RelativeColorimetric|Saturation|Default|Perceptual|AbsoluteColorimetric)|lectorDisabledOption))|ellHit(None|ContentArea|TrackableArea|EditableTextArea))|T(imeZoneNameStyle(S(hort(Standard|DaylightSaving)|tandard)|DaylightSaving)|extFieldDatePickerStyle|ableViewSelectionHighlightStyle(Regular|SourceList)|racking(Mouse(Moved|EnteredAndExited)|CursorUpdate|InVisibleRect|EnabledDuringMouseDrag|A(ssumeInside|ctive(In(KeyWindow|ActiveApp)|WhenFirstResponder|Always))))|I(n(tersectSetExpressionType|dexedColorSpaceModel)|mageScale(None|Proportionally(Down|UpOrDown)|AxesIndependently))|Ope(nGLPFAAllowOfflineRenderers|rationQueue(DefaultMaxConcurrentOperationCount|Priority(High|Normal|Very(High|Low)|Low)))|D(iacriticInsensitiveSearch|ownloadsDirectory)|U(nionSetExpressionType|TF(16(BigEndianStringEncoding|StringEncoding|LittleEndianStringEncoding)|32(BigEndianStringEncoding|StringEncoding|LittleEndianStringEncoding)))|P(ointerFunctions(Ma(chVirtualMemory|llocMemory)|Str(ongMemory|uctPersonality)|C(StringPersonality|opyIn)|IntegerPersonality|ZeroingWeakMemory|O(paque(Memory|Personality)|bjectP(ointerPersonality|ersonality)))|at(hStyle(Standard|NavigationBar|PopUp)|ternColorSpaceModel)|rintPanelShows(Scaling|Copies|Orientation|P(a(perSize|ge(Range|SetupAccessory))|review)))|Executable(RuntimeMismatchError|NotLoadableError|ErrorM(inimum|aximum)|L(inkError|oadError)|ArchitectureMismatchError)|KeyValueObservingOption(Initial|Prior)|F(i(ndPanelSubstringMatchType(StartsWith|Contains|EndsWith|FullWord)|leRead(TooLargeError|UnknownStringEncodingError))|orcedOrderingSearch)|Wi(ndow(BackingLocation(MainMemory|Default|VideoMemory)|Sharing(Read(Only|Write)|None)|CollectionBehavior(MoveToActiveSpace|CanJoinAllSpaces|Default))|dthInsensitiveSearch)|AggregateExpressionType)\b + scope: support.constant.cocoa.leopard.objc + - match: \bNS(R(GB(ModeColorPanel|ColorSpaceModel)|ight(Mouse(D(own(Mask)?|ragged(Mask)?)|Up(Mask)?)|T(ext(Movement|Alignment)|ab(sBezelBorder|StopType))|ArrowFunctionKey)|ound(RectBezelStyle|Bankers|ed(BezelStyle|TokenStyle|DisclosureBezelStyle)|Down|Up|Plain|Line(CapStyle|JoinStyle))|un(StoppedResponse|ContinuesResponse|AbortedResponse)|e(s(izableWindowMask|et(CursorRectsRunLoopOrdering|FunctionKey))|ce(ssedBezelStyle|iver(sCantHandleCommandScriptError|EvaluationScriptError))|turnTextMovement|doFunctionKey|quiredArgumentsMissingScriptError|l(evancyLevelIndicatorStyle|ative(Before|After))|gular(SquareBezelStyle|ControlSize)|moveTraitFontAction)|a(n(domSubelement|geDateMode)|tingLevelIndicatorStyle|dio(ModeMatrix|Button)))|G(IFFileType|lyph(Below|Inscribe(B(elow|ase)|Over(strike|Below)|Above)|Layout(WithPrevious|A(tAPoint|gainstAPoint))|A(ttribute(BidiLevel|Soft|Inscribe|Elastic)|bove))|r(ooveBorder|eaterThan(Comparison|OrEqualTo(Comparison|PredicateOperatorType)|PredicateOperatorType)|a(y(ModeColorPanel|ColorSpaceModel)|dient(None|Con(cave(Strong|Weak)|vex(Strong|Weak)))|phiteControlTint)))|XML(N(o(tationDeclarationKind|de(CompactEmptyElement|IsCDATA|OptionsNone|Use(SingleQuotes|DoubleQuotes)|Pre(serve(NamespaceOrder|C(haracterReferences|DATA)|DTD|Prefixes|E(ntities|mptyElements)|Quotes|Whitespace|A(ttributeOrder|ll))|ttyPrint)|ExpandEmptyElement))|amespaceKind)|CommentKind|TextKind|InvalidKind|D(ocument(X(MLKind|HTMLKind|Include)|HTMLKind|T(idy(XML|HTML)|extKind)|IncludeContentTypeDeclaration|Validate|Kind)|TDKind)|P(arser(GTRequiredError|XMLDeclNot(StartedError|FinishedError)|Mi(splaced(XMLDeclarationError|CDATAEndStringError)|xedContentDeclNot(StartedError|FinishedError))|S(t(andaloneValueError|ringNot(StartedError|ClosedError))|paceRequiredError|eparatorRequiredError)|N(MTOKENRequiredError|o(t(ationNot(StartedError|FinishedError)|WellBalancedError)|DTDError)|amespaceDeclarationError|AMERequiredError)|C(haracterRef(In(DTDError|PrologError|EpilogError)|AtEOFError)|o(nditionalSectionNot(StartedError|FinishedError)|mment(NotFinishedError|ContainsDoubleHyphenError))|DATANotFinishedError)|TagNameMismatchError|In(ternalError|valid(HexCharacterRefError|C(haracter(RefError|InEntityError|Error)|onditionalSectionError)|DecimalCharacterRefError|URIError|Encoding(NameError|Error)))|OutOfMemoryError|D(ocumentStartError|elegateAbortedParseError|OCTYPEDeclNotFinishedError)|U(RI(RequiredError|FragmentError)|n(declaredEntityError|parsedEntityError|knownEncodingError|finishedTagError))|P(CDATARequiredError|ublicIdentifierRequiredError|arsedEntityRef(MissingSemiError|NoNameError|In(Internal(SubsetError|Error)|PrologError|EpilogError)|AtEOFError)|r(ocessingInstructionNot(StartedError|FinishedError)|ematureDocumentEndError))|E(n(codingNotSupportedError|tity(Ref(In(DTDError|PrologError|EpilogError)|erence(MissingSemiError|WithoutNameError)|LoopError|AtEOFError)|BoundaryError|Not(StartedError|FinishedError)|Is(ParameterError|ExternalError)|ValueRequiredError))|qualExpectedError|lementContentDeclNot(StartedError|FinishedError)|xt(ernalS(tandaloneEntityError|ubsetNotFinishedError)|raContentError)|mptyDocumentError)|L(iteralNot(StartedError|FinishedError)|T(RequiredError|SlashRequiredError)|essThanSymbolInAttributeError)|Attribute(RedefinedError|HasNoValueError|Not(StartedError|FinishedError)|ListNot(StartedError|FinishedError)))|rocessingInstructionKind)|E(ntity(GeneralKind|DeclarationKind|UnparsedKind|P(ar(sedKind|ameterKind)|redefined))|lement(Declaration(MixedKind|UndefinedKind|E(lementKind|mptyKind)|Kind|AnyKind)|Kind))|Attribute(N(MToken(sKind|Kind)|otationKind)|CDATAKind|ID(Ref(sKind|Kind)|Kind)|DeclarationKind|En(tit(yKind|iesKind)|umerationKind)|Kind))|M(i(n(XEdge|iaturizableWindowMask|YEdge|uteCalendarUnit)|terLineJoinStyle|ddleSubelement|xedState)|o(nthCalendarUnit|deSwitchFunctionKey|use(Moved(Mask)?|E(ntered(Mask)?|ventSubtype|xited(Mask)?))|veToBezierPathElement|mentary(ChangeButton|Push(Button|InButton)|Light(Button)?))|enuFunctionKey|a(c(intoshInterfaceStyle|OSRomanStringEncoding)|tchesPredicateOperatorType|ppedRead|x(XEdge|YEdge))|ACHOperatingSystem)|B(MPFileType|o(ttomTabsBezelBorder|ldFontMask|rderlessWindowMask|x(Se(condary|parator)|OldStyle|Primary))|uttLineCapStyle|e(zelBorder|velLineJoinStyle|low(Bottom|Top)|gin(sWith(Comparison|PredicateOperatorType)|FunctionKey))|lueControlTint|ack(spaceCharacter|tabTextMovement|ingStore(Retained|Buffered|Nonretained)|TabCharacter|wardsSearch|groundTab)|r(owser(NoColumnResizing|UserColumnResizing|AutoColumnResizing)|eakFunctionKey))|S(h(ift(JISStringEncoding|KeyMask)|ow(ControlGlyphs|InvisibleGlyphs)|adowlessSquareBezelStyle)|y(s(ReqFunctionKey|tem(D(omainMask|efined(Mask)?)|FunctionKey))|mbolStringEncoding)|c(a(nnedOption|le(None|ToFit|Proportionally))|r(oll(er(NoPart|Increment(Page|Line|Arrow)|Decrement(Page|Line|Arrow)|Knob(Slot)?|Arrows(M(inEnd|axEnd)|None|DefaultSetting))|Wheel(Mask)?|LockFunctionKey)|eenChangedEventType))|t(opFunctionKey|r(ingDrawing(OneShot|DisableScreenFontSubstitution|Uses(DeviceMetrics|FontLeading|LineFragmentOrigin))|eam(Status(Reading|NotOpen|Closed|Open(ing)?|Error|Writing|AtEnd)|Event(Has(BytesAvailable|SpaceAvailable)|None|OpenCompleted|E(ndEncountered|rrorOccurred)))))|i(ngle(DateMode|UnderlineStyle)|ze(DownFontAction|UpFontAction))|olarisOperatingSystem|unOSOperatingSystem|pecialPageOrder|e(condCalendarUnit|lect(By(Character|Paragraph|Word)|i(ng(Next|Previous)|onAffinity(Downstream|Upstream))|edTab|FunctionKey)|gmentSwitchTracking(Momentary|Select(One|Any)))|quareLineCapStyle|witchButton|ave(ToOperation|Op(tions(Yes|No|Ask)|eration)|AsOperation)|mall(SquareBezelStyle|C(ontrolSize|apsFontMask)|IconButtonBezelStyle))|H(ighlightModeMatrix|SBModeColorPanel|o(ur(Minute(SecondDatePickerElementFlag|DatePickerElementFlag)|CalendarUnit)|rizontalRuler|meFunctionKey)|TTPCookieAcceptPolicy(Never|OnlyFromMainDocumentDomain|Always)|e(lp(ButtonBezelStyle|KeyMask|FunctionKey)|avierFontAction)|PUXOperatingSystem)|Year(MonthDa(yDatePickerElementFlag|tePickerElementFlag)|CalendarUnit)|N(o(n(StandardCharacterSetFontMask|ZeroWindingRule|activatingPanelMask|LossyASCIIStringEncoding)|Border|t(ification(SuspensionBehavior(Hold|Coalesce|D(eliverImmediately|rop))|NoCoalescing|CoalescingOn(Sender|Name)|DeliverImmediately|PostToAllSessions)|PredicateType|EqualToPredicateOperatorType)|S(cr(iptError|ollerParts)|ubelement|pecifierError)|CellMask|T(itle|opLevelContainersSpecifierError|abs(BezelBorder|NoBorder|LineBorder))|I(nterfaceStyle|mage)|UnderlineStyle|FontChangeAction)|u(ll(Glyph|CellType)|m(eric(Search|PadKeyMask)|berFormatter(Round(Half(Down|Up|Even)|Ceiling|Down|Up|Floor)|Behavior(10|Default)|S(cientificStyle|pellOutStyle)|NoStyle|CurrencyStyle|DecimalStyle|P(ercentStyle|ad(Before(Suffix|Prefix)|After(Suffix|Prefix))))))|e(t(Services(BadArgumentError|NotFoundError|C(ollisionError|ancelledError)|TimeoutError|InvalidError|UnknownError|ActivityInProgress)|workDomainMask)|wlineCharacter|xt(StepInterfaceStyle|FunctionKey))|EXTSTEPStringEncoding|a(t(iveShortGlyphPacking|uralTextAlignment)|rrowFontMask))|C(hange(ReadOtherContents|GrayCell(Mask)?|BackgroundCell(Mask)?|Cleared|Done|Undone|Autosaved)|MYK(ModeColorPanel|ColorSpaceModel)|ircular(BezelStyle|Slider)|o(n(stantValueExpressionType|t(inuousCapacityLevelIndicatorStyle|entsCellMask|ain(sComparison|erSpecifierError)|rol(Glyph|KeyMask))|densedFontMask)|lor(Panel(RGBModeMask|GrayModeMask|HSBModeMask|C(MYKModeMask|olorListModeMask|ustomPaletteModeMask|rayonModeMask)|WheelModeMask|AllModesMask)|ListModeColorPanel)|reServiceDirectory|m(p(osite(XOR|Source(In|O(ut|ver)|Atop)|Highlight|C(opy|lear)|Destination(In|O(ut|ver)|Atop)|Plus(Darker|Lighter))|ressedFontMask)|mandKeyMask))|u(stom(SelectorPredicateOperatorType|PaletteModeColorPanel)|r(sor(Update(Mask)?|PointingDevice)|veToBezierPathElement))|e(nterT(extAlignment|abStopType)|ll(State|H(ighlighted|as(Image(Horizontal|OnLeftOrBottom)|OverlappingImage))|ChangesContents|Is(Bordered|InsetButton)|Disabled|Editable|LightsBy(Gray|Background|Contents)|AllowsMixedState))|l(ipPagination|o(s(ePathBezierPathElement|ableWindowMask)|ckAndCalendarDatePickerStyle)|ear(ControlTint|DisplayFunctionKey|LineFunctionKey))|a(seInsensitive(Search|PredicateOption)|n(notCreateScriptCommandError|cel(Button|TextMovement))|chesDirectory|lculation(NoError|Overflow|DivideByZero|Underflow|LossOfPrecision)|rriageReturnCharacter)|r(itical(Request|AlertStyle)|ayonModeColorPanel))|T(hick(SquareBezelStyle|erSquareBezelStyle)|ypesetter(Behavior|HorizontalTabAction|ContainerBreakAction|ZeroAdvancementAction|OriginalBehavior|ParagraphBreakAction|WhitespaceAction|L(ineBreakAction|atestBehavior))|i(ckMark(Right|Below|Left|Above)|tledWindowMask|meZoneDatePickerElementFlag)|o(olbarItemVisibilityPriority(Standard|High|User|Low)|pTabsBezelBorder|ggleButton)|IFF(Compression(N(one|EXT)|CCITTFAX(3|4)|OldJPEG|JPEG|PackBits|LZW)|FileType)|e(rminate(Now|Cancel|Later)|xt(Read(InapplicableDocumentTypeError|WriteErrorM(inimum|aximum))|Block(M(i(nimum(Height|Width)|ddleAlignment)|a(rgin|ximum(Height|Width)))|B(o(ttomAlignment|rder)|aselineAlignment)|Height|TopAlignment|P(ercentageValueType|adding)|Width|AbsoluteValueType)|StorageEdited(Characters|Attributes)|CellType|ured(RoundedBezelStyle|BackgroundWindowMask|SquareBezelStyle)|Table(FixedLayoutAlgorithm|AutomaticLayoutAlgorithm)|Field(RoundedBezel|SquareBezel|AndStepperDatePickerStyle)|WriteInapplicableDocumentTypeError|ListPrependEnclosingMarker))|woByteGlyphPacking|ab(Character|TextMovement|le(tP(oint(Mask|EventSubtype)?|roximity(Mask|EventSubtype)?)|Column(NoResizing|UserResizingMask|AutoresizingMask)|View(ReverseSequentialColumnAutoresizingStyle|GridNone|S(olid(HorizontalGridLineMask|VerticalGridLineMask)|equentialColumnAutoresizingStyle)|NoColumnAutoresizing|UniformColumnAutoresizingStyle|FirstColumnOnlyAutoresizingStyle|LastColumnOnlyAutoresizingStyle)))|rackModeMatrix)|I(n(sert(CharFunctionKey|FunctionKey|LineFunctionKey)|t(Type|ernalS(criptError|pecifierError))|dexSubelement|validIndexSpecifierError|formational(Request|AlertStyle)|PredicateOperatorType)|talicFontMask|SO(2022JPStringEncoding|Latin(1StringEncoding|2StringEncoding))|dentityMappingCharacterCollection|llegalTextMovement|mage(R(ight|ep(MatchesDevice|LoadStatus(ReadingHeader|Completed|InvalidData|Un(expectedEOF|knownType)|WillNeedAllData)))|Below|C(ellType|ache(BySize|Never|Default|Always))|Interpolation(High|None|Default|Low)|O(nly|verlaps)|Frame(Gr(oove|ayBezel)|Button|None|Photo)|L(oadStatus(ReadError|C(ompleted|ancelled)|InvalidData|UnexpectedEOF)|eft)|A(lign(Right|Bottom(Right|Left)?|Center|Top(Right|Left)?|Left)|bove)))|O(n(State|eByteGlyphPacking|OffButton|lyScrollerArrows)|ther(Mouse(D(own(Mask)?|ragged(Mask)?)|Up(Mask)?)|TextMovement)|SF1OperatingSystem|pe(n(GL(GO(Re(setLibrary|tainRenderers)|ClearFormatCache|FormatCacheSize)|PFA(R(obust|endererID)|M(inimumPolicy|ulti(sample|Screen)|PSafe|aximumPolicy)|BackingStore|S(creenMask|te(ncilSize|reo)|ingleRenderer|upersample|ample(s|Buffers|Alpha))|NoRecovery|C(o(lor(Size|Float)|mpliant)|losestPolicy)|OffScreen|D(oubleBuffer|epthSize)|PixelBuffer|VirtualScreenCount|FullScreen|Window|A(cc(umSize|elerated)|ux(Buffers|DepthStencil)|l(phaSize|lRenderers))))|StepUnicodeReservedBase)|rationNotSupportedForKeyS(criptError|pecifierError))|ffState|KButton|rPredicateType|bjC(B(itfield|oolType)|S(hortType|tr(ingType|uctType)|electorType)|NoType|CharType|ObjectType|DoubleType|UnionType|PointerType|VoidType|FloatType|Long(Type|longType)|ArrayType))|D(i(s(c(losureBezelStyle|reteCapacityLevelIndicatorStyle)|playWindowRunLoopOrdering)|acriticInsensitivePredicateOption|rect(Selection|PredicateModifier))|o(c(ModalWindowMask|ument(Directory|ationDirectory))|ubleType|wn(TextMovement|ArrowFunctionKey))|e(s(cendingPageOrder|ktopDirectory)|cimalTabStopType|v(ice(NColorSpaceModel|IndependentModifierFlagsMask)|eloper(Directory|ApplicationDirectory))|fault(ControlTint|TokenStyle)|lete(Char(acter|FunctionKey)|FunctionKey|LineFunctionKey)|moApplicationDirectory)|a(yCalendarUnit|teFormatter(MediumStyle|Behavior(10|Default)|ShortStyle|NoStyle|FullStyle|LongStyle))|ra(wer(Clos(ingState|edState)|Open(ingState|State))|gOperation(Generic|Move|None|Copy|Delete|Private|Every|Link|All)))|U(ser(CancelledError|D(irectory|omainMask)|FunctionKey)|RL(Handle(NotLoaded|Load(Succeeded|InProgress|Failed))|CredentialPersistence(None|Permanent|ForSession))|n(scaledWindowMask|cachedRead|i(codeStringEncoding|talicFontMask|fiedTitleAndToolbarWindowMask)|d(o(CloseGroupingRunLoopOrdering|FunctionKey)|e(finedDateComponent|rline(Style(Single|None|Thick|Double)|Pattern(Solid|D(ot|ash(Dot(Dot)?)?)))))|known(ColorSpaceModel|P(ointingDevice|ageOrder)|KeyS(criptError|pecifierError))|boldFontMask)|tilityWindowMask|TF8StringEncoding|p(dateWindowsRunLoopOrdering|TextMovement|ArrowFunctionKey))|J(ustifiedTextAlignment|PEG(2000FileType|FileType)|apaneseEUC(GlyphPacking|StringEncoding))|P(o(s(t(Now|erFontMask|WhenIdle|ASAP)|iti(on(Replace|Be(fore|ginning)|End|After)|ve(IntType|DoubleType|FloatType)))|pUp(NoArrow|ArrowAt(Bottom|Center))|werOffEventType|rtraitOrientation)|NGFileType|ush(InCell(Mask)?|OnPushOffButton)|e(n(TipMask|UpperSideMask|PointingDevice|LowerSideMask)|riodic(Mask)?)|P(S(caleField|tatus(Title|Field)|aveButton)|N(ote(Title|Field)|ame(Title|Field))|CopiesField|TitleField|ImageButton|OptionsButton|P(a(perFeedButton|ge(Range(To|From)|ChoiceMatrix))|reviewButton)|LayoutButton)|lainTextTokenStyle|a(useFunctionKey|ragraphSeparatorCharacter|ge(DownFunctionKey|UpFunctionKey))|r(int(ing(ReplyLater|Success|Cancelled|Failure)|ScreenFunctionKey|erTable(NotFound|OK|Error)|FunctionKey)|o(p(ertyList(XMLFormat|MutableContainers(AndLeaves)?|BinaryFormat|Immutable|OpenStepFormat)|rietaryStringEncoding)|gressIndicator(BarStyle|SpinningStyle|Preferred(SmallThickness|Thickness|LargeThickness|AquaThickness)))|e(ssedTab|vFunctionKey))|L(HeightForm|CancelButton|TitleField|ImageButton|O(KButton|rientationMatrix)|UnitsButton|PaperNameButton|WidthForm))|E(n(terCharacter|d(sWith(Comparison|PredicateOperatorType)|FunctionKey))|v(e(nOddWindingRule|rySubelement)|aluatedObjectExpressionType)|qualTo(Comparison|PredicateOperatorType)|ra(serPointingDevice|CalendarUnit|DatePickerElementFlag)|x(clude(10|QuickDrawElementsIconCreationOption)|pandedFontMask|ecuteFunctionKey))|V(i(ew(M(in(XMargin|YMargin)|ax(XMargin|YMargin))|HeightSizable|NotSizable|WidthSizable)|aPanelFontAction)|erticalRuler|a(lidationErrorM(inimum|aximum)|riableExpressionType))|Key(SpecifierEvaluationScriptError|Down(Mask)?|Up(Mask)?|PathExpressionType|Value(MinusSetMutation|SetSetMutation|Change(Re(placement|moval)|Setting|Insertion)|IntersectSetMutation|ObservingOption(New|Old)|UnionSetMutation|ValidationError))|QTMovie(NormalPlayback|Looping(BackAndForthPlayback|Playback))|F(1(1FunctionKey|7FunctionKey|2FunctionKey|8FunctionKey|3FunctionKey|9FunctionKey|4FunctionKey|5FunctionKey|FunctionKey|0FunctionKey|6FunctionKey)|7FunctionKey|i(nd(PanelAction(Replace(A(ndFind|ll(InSelection)?))?|S(howFindPanel|e(tFindString|lectAll(InSelection)?))|Next|Previous)|FunctionKey)|tPagination|le(Read(No(SuchFileError|PermissionError)|CorruptFileError|In(validFileNameError|applicableStringEncodingError)|Un(supportedSchemeError|knownError))|HandlingPanel(CancelButton|OKButton)|NoSuchFileError|ErrorM(inimum|aximum)|Write(NoPermissionError|In(validFileNameError|applicableStringEncodingError)|OutOfSpaceError|Un(supportedSchemeError|knownError))|LockingError)|xedPitchFontMask)|2(1FunctionKey|7FunctionKey|2FunctionKey|8FunctionKey|3FunctionKey|9FunctionKey|4FunctionKey|5FunctionKey|FunctionKey|0FunctionKey|6FunctionKey)|o(nt(Mo(noSpaceTrait|dernSerifsClass)|BoldTrait|S(ymbolicClass|criptsClass|labSerifsClass|ansSerifClass)|C(o(ndensedTrait|llectionApplicationOnlyMask)|larendonSerifsClass)|TransitionalSerifsClass|I(ntegerAdvancementsRenderingMode|talicTrait)|O(ldStyleSerifsClass|rnamentalsClass)|DefaultRenderingMode|U(nknownClass|IOptimizedTrait)|Panel(S(hadowEffectModeMask|t(andardModesMask|rikethroughEffectModeMask)|izeModeMask)|CollectionModeMask|TextColorEffectModeMask|DocumentColorEffectModeMask|UnderlineEffectModeMask|FaceModeMask|All(ModesMask|EffectsModeMask))|ExpandedTrait|VerticalTrait|F(amilyClassMask|reeformSerifsClass)|Antialiased(RenderingMode|IntegerAdvancementsRenderingMode))|cusRing(Below|Type(None|Default|Exterior)|Only|Above)|urByteGlyphPacking|rm(attingError(M(inimum|aximum))?|FeedCharacter))|8FunctionKey|unction(ExpressionType|KeyMask)|3(1FunctionKey|2FunctionKey|3FunctionKey|4FunctionKey|5FunctionKey|FunctionKey|0FunctionKey)|9FunctionKey|4FunctionKey|P(RevertButton|S(ize(Title|Field)|etButton)|CurrentField|Preview(Button|Field))|l(oat(ingPointSamplesBitmapFormat|Type)|agsChanged(Mask)?)|axButton|5FunctionKey|6FunctionKey)|W(heelModeColorPanel|indow(s(NTOperatingSystem|CP125(1StringEncoding|2StringEncoding|3StringEncoding|4StringEncoding|0StringEncoding)|95(InterfaceStyle|OperatingSystem))|M(iniaturizeButton|ovedEventType)|Below|CloseButton|ToolbarButton|ZoomButton|Out|DocumentIconButton|ExposedEventType|Above)|orkspaceLaunch(NewInstance|InhibitingBackgroundOnly|Default|PreferringClassic|WithoutA(ctivation|ddingToRecents)|A(sync|nd(Hide(Others)?|Print)|llowingClassicStartup))|eek(day(CalendarUnit|OrdinalCalendarUnit)|CalendarUnit)|a(ntsBidiLevels|rningAlertStyle)|r(itingDirection(RightToLeft|Natural|LeftToRight)|apCalendarComponents))|L(i(stModeMatrix|ne(Moves(Right|Down|Up|Left)|B(order|reakBy(C(harWrapping|lipping)|Truncating(Middle|Head|Tail)|WordWrapping))|S(eparatorCharacter|weep(Right|Down|Up|Left))|ToBezierPathElement|DoesntMove|arSlider)|teralSearch|kePredicateOperatorType|ghterFontAction|braryDirectory)|ocalDomainMask|e(ssThan(Comparison|OrEqualTo(Comparison|PredicateOperatorType)|PredicateOperatorType)|ft(Mouse(D(own(Mask)?|ragged(Mask)?)|Up(Mask)?)|T(ext(Movement|Alignment)|ab(sBezelBorder|StopType))|ArrowFunctionKey))|a(yout(RightToLeft|NotDone|CantFit|OutOfGlyphs|Done|LeftToRight)|ndscapeOrientation)|ABColorSpaceModel)|A(sc(iiWithDoubleByteEUCGlyphPacking|endingPageOrder)|n(y(Type|PredicateModifier|EventMask)|choredSearch|imation(Blocking|Nonblocking(Threaded)?|E(ffect(DisappearingItemDefault|Poof)|ase(In(Out)?|Out))|Linear)|dPredicateType)|t(Bottom|tachmentCharacter|omicWrite|Top)|SCIIStringEncoding|d(obe(GB1CharacterCollection|CNS1CharacterCollection|Japan(1CharacterCollection|2CharacterCollection)|Korea1CharacterCollection)|dTraitFontAction|minApplicationDirectory)|uto(saveOperation|Pagination)|pp(lication(SupportDirectory|D(irectory|e(fined(Mask)?|legateReply(Success|Cancel|Failure)|activatedEventType))|ActivatedEventType)|KitDefined(Mask)?)|l(ternateKeyMask|pha(ShiftKeyMask|NonpremultipliedBitmapFormat|FirstBitmapFormat)|ert(SecondButtonReturn|ThirdButtonReturn|OtherReturn|DefaultReturn|ErrorReturn|FirstButtonReturn|AlternateReturn)|l(ScrollerParts|DomainsMask|PredicateModifier|LibrariesDirectory|ApplicationsDirectory))|rgument(sWrongScriptError|EvaluationScriptError)|bove(Bottom|Top)|WTEventType))\b + scope: support.constant.cocoa.objc + - match: \bNS(RuleEditor|G(arbageCollector|radient)|MapTable|HashTable|Co(ndition|llectionView(Item)?)|T(oolbarItemGroup|extInputClient|r(eeNode|ackingArea))|InvocationOperation|Operation(Queue)?|D(ictionaryController|ockTile)|P(ointer(Functions|Array)|athC(o(ntrol(Delegate)?|mponentCell)|ell(Delegate)?)|r(intPanelAccessorizing|edicateEditor(RowTemplate)?))|ViewController|FastEnumeration|Animat(ionContext|ablePropertyContainer))\b + scope: support.class.cocoa.leopard.objc + - match: \bNS(R(u(nLoop|ler(Marker|View))|e(sponder|cursiveLock|lativeSpecifier)|an(domSpecifier|geSpecifier))|G(etCommand|lyph(Generator|Storage|Info)|raphicsContext)|XML(Node|D(ocument|TD(Node)?)|Parser|Element)|M(iddleSpecifier|ov(ie(View)?|eCommand)|utable(S(tring|et)|C(haracterSet|opying)|IndexSet|D(ictionary|ata)|URLRequest|ParagraphStyle|A(ttributedString|rray))|e(ssagePort(NameServer)?|nu(Item(Cell)?|View)?|t(hodSignature|adata(Item|Query(ResultGroup|AttributeValueTuple)?)))|a(ch(BootstrapServer|Port)|trix))|B(itmapImageRep|ox|u(ndle|tton(Cell)?)|ezierPath|rowser(Cell)?)|S(hadow|c(anner|r(ipt(SuiteRegistry|C(o(ercionHandler|mmand(Description)?)|lassDescription)|ObjectSpecifier|ExecutionContext|WhoseTest)|oll(er|View)|een))|t(epper(Cell)?|atus(Bar|Item)|r(ing|eam))|imple(HorizontalTypesetter|CString)|o(cketPort(NameServer)?|und|rtDescriptor)|p(e(cifierTest|ech(Recognizer|Synthesizer)|ll(Server|Checker))|litView)|e(cureTextField(Cell)?|t(Command)?|archField(Cell)?|rializer|gmentedC(ontrol|ell))|lider(Cell)?|avePanel)|H(ost|TTP(Cookie(Storage)?|URLResponse)|elpManager)|N(ib(Con(nector|trolConnector)|OutletConnector)?|otification(Center|Queue)?|u(ll|mber(Formatter)?)|etService(Browser)?|ameSpecifier)|C(ha(ngeSpelling|racterSet)|o(n(stantString|nection|trol(ler)?|ditionLock)|d(ing|er)|unt(Command|edSet)|pying|lor(Space|P(ick(ing(Custom|Default)|er)|anel)|Well|List)?|m(p(oundPredicate|arisonPredicate)|boBox(Cell)?))|u(stomImageRep|rsor)|IImageRep|ell|l(ipView|o(seCommand|neCommand)|assDescription)|a(ched(ImageRep|URLResponse)|lendar(Date)?)|reateCommand)|T(hread|ypesetter|ime(Zone|r)|o(olbar(Item(Validations)?)?|kenField(Cell)?)|ext(Block|Storage|Container|Tab(le(Block)?)?|Input|View|Field(Cell)?|List|Attachment(Cell)?)?|a(sk|b(le(Header(Cell|View)|Column|View)|View(Item)?))|reeController)|I(n(dex(S(pecifier|et)|Path)|put(Manager|S(tream|erv(iceProvider|er(MouseTracker)?)))|vocation)|gnoreMisspelledWords|mage(Rep|Cell|View)?)|O(ut(putStream|lineView)|pen(GL(Context|Pixel(Buffer|Format)|View)|Panel)|bj(CTypeSerializationCallBack|ect(Controller)?))|D(i(st(antObject(Request)?|ributed(NotificationCenter|Lock))|ctionary|rectoryEnumerator)|ocument(Controller)?|e(serializer|cimalNumber(Behaviors|Handler)?|leteCommand)|at(e(Components|Picker(Cell)?|Formatter)?|a)|ra(wer|ggingInfo))|U(ser(InterfaceValidations|Defaults(Controller)?)|RL(Re(sponse|quest)|Handle(Client)?|C(onnection|ache|redential(Storage)?)|Download(Delegate)?|Prot(ocol(Client)?|ectionSpace)|AuthenticationChallenge(Sender)?)?|n(iqueIDSpecifier|doManager|archiver))|P(ipe|o(sitionalSpecifier|pUpButton(Cell)?|rt(Message|NameServer|Coder)?)|ICTImageRep|ersistentDocument|DFImageRep|a(steboard|nel|ragraphStyle|geLayout)|r(int(Info|er|Operation|Panel)|o(cessInfo|tocolChecker|perty(Specifier|ListSerialization)|gressIndicator|xy)|edicate))|E(numerator|vent|PSImageRep|rror|x(ception|istsCommand|pression))|V(iew(Animation)?|al(idated(ToobarItem|UserInterfaceItem)|ue(Transformer)?))|Keyed(Unarchiver|Archiver)|Qui(ckDrawView|tCommand)|F(ile(Manager|Handle|Wrapper)|o(nt(Manager|Descriptor|Panel)?|rm(Cell|atter)))|W(hoseSpecifier|indow(Controller)?|orkspace)|L(o(c(k(ing)?|ale)|gicalTest)|evelIndicator(Cell)?|ayoutManager)|A(ssertionHandler|nimation|ctionCell|ttributedString|utoreleasePool|TSTypesetter|ppl(ication|e(Script|Event(Manager|Descriptor)))|ffineTransform|lert|r(chiver|ray(Controller)?)))\b + scope: support.class.cocoa.objc + - match: \bNS(R(oundingMode|ule(Editor(RowType|NestingMode)|rOrientation)|e(questUserAttentionType|lativePosition))|G(lyphInscription|radientDrawingOptions)|XML(NodeKind|D(ocumentContentKind|TDNodeKind)|ParserError)|M(ultibyteGlyphPacking|apTableOptions)|B(itmapFormat|oxType|ezierPathElement|ackgroundStyle|rowserDropOperation)|S(tr(ing(CompareOptions|DrawingOptions|EncodingConversionOptions)|eam(Status|Event))|p(eechBoundary|litViewDividerStyle)|e(archPathD(irectory|omainMask)|gmentS(tyle|witchTracking))|liderType|aveOptions)|H(TTPCookieAcceptPolicy|ashTableOptions)|N(otification(SuspensionBehavior|Coalescing)|umberFormatter(RoundingMode|Behavior|Style|PadPosition)|etService(sError|Options))|C(haracterCollection|o(lor(RenderingIntent|SpaceModel|PanelMode)|mp(oundPredicateType|arisonPredicateModifier))|ellStateValue|al(culationError|endarUnit))|T(ypesetterControlCharacterAction|imeZoneNameStyle|e(stComparisonOperation|xt(Block(Dimension|V(erticalAlignment|alueType)|Layer)|TableLayoutAlgorithm|FieldBezelStyle))|ableView(SelectionHighlightStyle|ColumnAutoresizingStyle)|rackingAreaOptions)|I(n(sertionPosition|te(rfaceStyle|ger))|mage(RepLoadStatus|Scaling|CacheMode|FrameStyle|LoadStatus|Alignment))|Ope(nGLPixelFormatAttribute|rationQueuePriority)|Date(Picker(Mode|Style)|Formatter(Behavior|Style))|U(RL(RequestCachePolicy|HandleStatus|C(acheStoragePolicy|redentialPersistence))|Integer)|P(o(stingStyle|int(ingDeviceType|erFunctionsOptions)|pUpArrowPosition)|athStyle|r(int(ing(Orientation|PaginationMode)|erTableStatus|PanelOptions)|opertyList(MutabilityOptions|Format)|edicateOperatorType))|ExpressionType|KeyValue(SetMutationKind|Change)|QTMovieLoopMode|F(indPanel(SubstringMatchType|Action)|o(nt(RenderingMode|FamilyClass)|cusRingPlacement))|W(hoseSubelementIdentifier|ind(ingRule|ow(B(utton|ackingLocation)|SharingType|CollectionBehavior)))|L(ine(MovementDirection|SweepDirection|CapStyle|JoinStyle)|evelIndicatorStyle)|Animation(BlockingMode|Curve))\b + scope: support.type.cocoa.leopard.objc + - match: \bNS(R(ect(Edge)?|ange)|G(lyph(Relation|LayoutMode)?|radientType)|M(odalSession|a(trixMode|p(Table|Enumerator)))|B(itmapImageFileType|orderType|uttonType|ezelStyle|ackingStoreType|rowserColumnResizingType)|S(cr(oll(er(Part|Arrow)|ArrowPosition)|eenAuxiliaryOpaque)|tringEncoding|ize|ocketNativeHandle|election(Granularity|Direction|Affinity)|wapped(Double|Float)|aveOperationType)|Ha(sh(Table|Enumerator)|ndler(2)?)|C(o(ntrol(Size|Tint)|mp(ositingOperation|arisonResult))|ell(State|Type|ImagePosition|Attribute))|T(hreadPrivate|ypesetterGlyphInfo|i(ckMarkPosition|tlePosition|meInterval)|o(ol(TipTag|bar(SizeMode|DisplayMode))|kenStyle)|IFFCompression|ext(TabType|Alignment)|ab(State|leViewDropOperation|ViewType)|rackingRectTag)|ImageInterpolation|Zone|OpenGL(ContextAuxiliary|PixelFormatAuxiliary)|D(ocumentChangeType|atePickerElementFlags|ra(werState|gOperation))|UsableScrollerParts|P(oint|r(intingPageOrder|ogressIndicator(Style|Th(ickness|readInfo))))|EventType|KeyValueObservingOptions|Fo(nt(SymbolicTraits|TraitMask|Action)|cusRingType)|W(indow(OrderingMode|Depth)|orkspace(IconCreationOptions|LaunchOptions)|ritingDirection)|L(ineBreakMode|ayout(Status|Direction))|A(nimation(Progress|Effect)|ppl(ication(TerminateReply|DelegateReply|PrintReply)|eEventManagerSuspensionID)|ffineTransformStruct|lertStyle))\b + scope: support.type.cocoa.objc + # Catch-all + - match: \bN\w+\b + pop: 1 + - include: pop-immediately - preprocessor-other-include-common: - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.double.include.objc - - match: '"' - scope: punctuation.definition.string.end.objc - pop: true - - match: < - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.other.lt-gt.include.objc - - match: ">" - scope: punctuation.definition.string.end.objc - pop: true +variables: + fn_pointer: \(\s*(\*|\^)({{identifier}})\s*\)\s*(\() diff --git a/Objective-C/Symbol List - Methods.tmPreferences b/Objective-C/Symbol List - Methods.tmPreferences new file mode 100644 index 0000000000..ce71c9a9bd --- /dev/null +++ b/Objective-C/Symbol List - Methods.tmPreferences @@ -0,0 +1,21 @@ + + + + scope + + settings + + showInSymbolList + 1 + showInIndexedSymbolList + 1 + + symbolTransformation + + s/([-+])\s*.+?(?=\w+\s*:)/$1/; + s/:[^:]+?\)\w+\s+(\w+)/:$1/g; + s/\:[^:]+\;/:/; + + + + diff --git a/Objective-C/syntax_test_accessor.m b/Objective-C/syntax_test_accessor.m deleted file mode 100644 index 4faa52c7bb..0000000000 --- a/Objective-C/syntax_test_accessor.m +++ /dev/null @@ -1,35 +0,0 @@ -// SYNTAX TEST "Packages/Objective-C/Objective-C.sublime-syntax" - -typedef struct _X -{ - int a; - int b; -} X; - -int main() -{ - X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - X x; - x.. -// ^^ invalid.illegal - punctuation.accessor -} - -int main() -{ - X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - X* x = malloc(sizeof(X)); - x-> -// ^^ punctuation.accessor -} diff --git a/Objective-C/syntax_test_accessor.mm b/Objective-C/syntax_test_accessor.mm deleted file mode 100644 index 2c28b49af3..0000000000 --- a/Objective-C/syntax_test_accessor.mm +++ /dev/null @@ -1,68 +0,0 @@ -// SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" - -namespace N { - -class X -{ - public: - int a; - int b; -}; - -class Y : public X -{ - public: - int c; -} - -} // namespace N - -int main() -{ - N:: -// ^^ punctuation.accessor -} - -int main() -{ - N::X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - N::X x; - x.. -// ^^ - punctuation.accessor -} - -int main() -{ - N::X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - N::X* x = new X(); - x-> -// ^^ punctuation.accessor -} - -int main() -{ - N::Y y; - y.X:: -// ^ punctuation.accessor -// ^^ punctuation.accessor -} - -int main() -{ - N::Y* y = new Y(); - y->X:: -// ^^ punctuation.accessor -// ^^ punctuation.accessor -} diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index cecf257de1..fb86dd6421 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -1,2938 +1,2419 @@ -/* SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" */ - - -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ +// SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -Task natural_numbers() -{ - int n = 0; - while (true) { - co_yield n; - /* ^ keyword.control */ - n++; - } -} -Task foo() -{ - co_return 42; - /* ^ keyword.control */ - /* ^ meta.number */ -} -Task bar() -{ - co_await natural_numbers(); - /* ^ keyword.control */ - /* ^ variable.function */ -} - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number */ - /* ^^ keyword.operator.arithmetic */ -} + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c -///////////////////////////////////////////// -// Preprocessor -///////////////////////////////////////////// + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c -#ifndef IGUARD_ - /* <- keyword.control.import */ -#define IGUARD_ - /* <- keyword.control.import.define */ -struct foo* alloc_foo(); -/* <- keyword.declaration */ - /* <- - entity.name.type */ - /* <- entity.name.function */ -#endif - /* <- keyword.control.import */ - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -int g(int x = 5 \ - /* ^ punctuation.separator.continuation */ - , int y); - -#define MACRO_WITH_CURLY_BRACE { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ - - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} - -// This is a method/function with the return type on a separate line and so should not be a -// constructor. -FOOLIB_RESULT -some_namespace::some_function(int a_parameter, double another_parameter) { - /* <- meta.function meta.toc-list.full-identifier */ - /* ^ entity.name.function - entity.name.function.constructor */ - return FOOLIB_SUCCESS; -} - -#pragma foo(bar, \ -"baz", \ -1) -/* <- meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#if 0 -#ifdef moo -/* <- - keyword.control */ -#endif -/* <- - keyword.control */ -#endif - -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO -/* <- meta.assumed-macro */ - -struct FOO1 FOO2 FOO3 Test { - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - Test(); - Test() noexcept; - Test() final; - Test() noexcept final; - ~Test(); - ~Test() noexcept; - ~Test() override noexcept; - virtual ~Test(); - virtual ~Test() noexcept; - virtual ~Test() override noexcept; - DLL_API Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - DLL_API Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() noexcept final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API ~Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - DLL_API ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API virtual ~Test(); - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - DLL_API virtual ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API virtual ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -} - -struct X { - X(); - /* <- meta.group */ - /*^ meta.group - meta.group meta.group */ -}; - -#define DEPRECATED(msg) [[deprecated(msg)]] - -struct Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -}; - -namespace Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -} - -struct Test { -DEPRECATED("bla") -/* <- meta.assumed-macro variable.function.assumed-macro */ -bool foo (bool run=true) {} -/* ^ entity.name.function */ -}; - -///////////////////////////////////////////// -// Strings -///////////////////////////////////////////// - -char str1[] = "abc"; -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char8_t str2[] = u8"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char16_t str3[] = u"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char32_t str4[] = U"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -wchar_t str5[] = L"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char str6[] = "\a|\b|\e|\f|\n|\r|\t|\v|\'|\"|\?"; -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ - -char str7[] = "\0|\012"; -/* ^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ - -char str8[] = "\x0a|\x41|\xA|\x000065"; -/* ^^^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ -/* ^^^ constant.character.escape */ -/* ^^^^^^^^ constant.character.escape */ - -char8_t str9[] = u8"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char16_t str10[] = u"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char32_t str11[] = U"\U00000063"; -/* ^^^^^^^^^^ constant.character.escape */ - -char str12[] = "\q"; -/* ^^ invalid.illegal.unknown-escape */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ - -char rawStr1[] = R"("This is a raw string")"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char rawStr2[] = R"A*!34( )" )A*!34"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.definition.string.end */ - -const char IncludeRegexPattern[] = - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^^ - invalid */ -/* ^^ - invalid */ -/* ^ punctuation.definition.string.end */ + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c + */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Storage Types +// Numbers ///////////////////////////////////////////// -void* ptr; -/* <- storage.type */ - -bool b; -/* <- storage.type */ - -char ch; -/* <- storage.type */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -unsigned int ui; -/* <- storage.type */ -/* ^ storage.type */ - -signed long l; -/* <- storage.type */ -/* ^ storage.type */ - -short s; -/* <- storage.type */ - -auto a = 2; -/* <- storage.type */ - -decltype(s) dt; -/* <- keyword.declaration */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -float f; -/* <- storage.type */ - -double d; -/* <- storage.type */ - -typedef int my_int; -/* <- keyword.declaration */ -/* ^ entity.name.type */ - -typedef struct Books { -/* ^ keyword.declaration */ -/* ^ - entity.name.type */ - char title[50]; - int book_id; -} Book; -/*^ entity.name.type */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.objc++ */ -/* ^^^^^^ keyword.declaration.struct.objc++ */ -/* ^^^^^^^^^^^ entity.name.struct.objc++ */ -/* ^ punctuation.section.block.begin.objc++ */ -/* ^ punctuation.section.block.end.objc++ */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.objc++ */ - -typedef struct Books Book; -/* ^ - entity.name.type.struct */ -/* ^ entity.name.type.typedef */ - -using Alias = Foo; -/* <- keyword.control */ -/* ^^^^^ entity.name.type.using */ - -using Alias - = NewLineFoo; -/*^ - entity.name */ - -template -using TemplateAlias = Foo; -/* ^^^^^^^^^^^^^ entity.name.type.using */ - -using std::cout; -/* <- keyword.control */ -/* ^ - entity.name */ - -using std:: - cout; -/*^ - entity.name */ - -class MyClass : public SuperClass -{ - using This = MyClass; -/* ^ keyword.control */ -/* ^^^^ entity.name.type.using */ - - using MyInt -/* ^ keyword.control */ - = int32_t; - - using SuperClass::SuperClass; -/* ^ keyword.control */ -/* ^ - entity.name */ -}; - -class MyClass : public CrtpClass -{ - using typename CrtpClass::PointerType; -/* ^ keyword.control */ -/* ^ storage.modifier */ - using CrtpClass< -/* ^ keyword.control */ - MyClass>::method; -}; - -template class MyStack; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic */ -/* ^ storage.type */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic */ - -template class tupleTmpl; -/* <- keyword.declaration.template */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ keyword.declaration */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -template, typename... Rest> class tupleVariadic; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ keyword.declaration */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ punctuation.definition.generic.end */ - -template void SomeClass::function(); -/* ^^^ keyword.operator.variadic */ -/* ^^^^^^^^ entity.name.function */ - -template inline struct Foo* baz() -/* ^^^^^^ storage.modifier */ -/* ^ - entity.name */ -/* ^^^ meta.function entity.name.function */ -{} - -template -void classname::methodName() { -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^^^^ entity.name.function */ -} - -template -void funcName() { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -} -bool A::operator<(const A& a) { return false; } -/* ^ storage.type */ -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters punctuation.section.group.begin */ -template bool A::operator<(const A& a) { return false; } -/* ^ keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters meta.group punctuation.section.group.begin */ -template -SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ - -template SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.constructor */ - -template A::~A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.destructor */ - -template -bool A::operator > (const A& other) { return false; } -/* ^^^^^^^^^^^^ meta.function entity.name.function */ -template -bool A::operator == (const A& other) { return false; } -/* ^^^^^^^^^^^^^^ meta.function entity.name.function */ -template -bool A::operator <=> (const A& other) { return false; } -/* ^^^^^^^^^^^^^^ meta.function entity.name.function */ -typedef std :: vector > Table; -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.end */ - -template - /* ^ meta.template keyword.operator */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template meta.number */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template constant.language */ -struct Foo -{ - -/* <- meta.struct - meta.template */ - - void bar(int a = 3, bool b = true) {} - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template meta.number */ - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template constant.language */ -}; - -/* <- - meta.block - meta.struct - meta.template */ - -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template meta.number */ -class fixed_array : private std::array {}; - -constexpr std::size_t f() { return 128; } -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -/* ^ meta.template punctuation */ -class fixed_array : private std::array {}; - -template class A { /* ... */ }; -template class B { /* ... */ }; -/* ^ meta.template keyword.operator */ -/* ^ meta.template */ -/* ^ meta.template punctuation */ -/* ^ - meta.template */ -template class C { /* ... */ }; - -// templates inside templates... it's templates all the way down -template class P> class X { /* ... */ }; -/* ^ meta.template punctuation */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template meta.template keyword.declaration */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template keyword.declaration */ -/* ^ meta.template punctuation */ - -X xa; // OK -X xb; // OK in C++14 after CWG 150 - // Error earlier: not an exact match -X xc; // OK in C++14 after CWG 150 - -// template declarations spanning multiple lines -template -/* <- meta.template keyword.declaration */ -< -/* <- meta.template punctuation.definition.generic.begin */ - class T, - class U = T -> -class B -{ - /* ... */ -}; - -// template declarations spanning multiple lines -template -< -/* <- meta.template punctuation.definition.generic.begin */ - std::size_t Count = f() -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -> -/* <- meta.template punctuation.definition.generic.end */ -class fixed_array : private std::array {}; - -template -static bool decode(const Node& node, T& sequence) { - if (!node.IsSequence()) - return false; - sequence.clear(); - for (const auto& item : node) { - sequence.push_back(item.template as()); - /* ^ punctuation.accessor */ - /* ^ keyword.declaration - variable.other */ - /* ^ variable.function */ - /* ^ punctuation */ - /* ^^ punctuation.accessor */ - /* ^ punctuation */ - } - return true; -} - -#include -template struct A {}; -template struct B {}; -struct C {}; -A> f(std::function>()> g) { - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ variable.parameter */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - return g(); -} -int main() { - std::function foo1; - /* ^ - variable.function */ - std::function()> foo2; - /* ^ - variable.function */ - auto f = [](std::function>()> g) { return g(); }; - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - /* ^ punctuation.section.block.end */ - return 0; -} -/* <- - invalid.illegal */ - -// Example from section 14.2/4 of -// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf -struct X -{ - template - X* alloc(); - - template - static X* adjust(); -}; -template -void f(T* p) -{ - // Be optimistic: scope it as a template member function call anyway. - T* p1 = p->alloc<200>(); // ill-formed: < means less than - - T* p2 = p->template alloc<200>(); // OK: < starts template argument list - /* ^ punctuation.accessor */ - /* ^ keyword.declaration - variable.other */ - /* ^ variable.function */ - - // Be optimistic: scope it as a template member function call anyway. - T::adjust<100>(); // ill-formed: < means less than - - T::template adjust<100>(); // OK: < starts template argument list - /* <- - variable.function */ - /*^ punctuation.accessor */ - /* ^ keyword.declaration - variable.other */ - /* ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ - /* ^ variable.function */ -} - -struct X -{ - void template(); // <-- not allowed to be a function! - /* ^ - entity.name.function */ -}; - -void f() -{ - X x; - x.template(); // <-- should not be scoped as variable.function! - /* ^ - variable.function */ - - x /**/ . /**/ foo <5> /**/ () /**/ ; - /*^^^^ comment.block */ - /* ^ punctuation.accessor */ - /* ^^^ meta.method-call variable.function */ - /* ^ meta.method-call - variable.function */ - /* ^ meta.method-call punctuation.definition.generic.begin */ - /* ^ meta.method-call punctuation.definition.generic.end */ - /* ^ meta.method-call - punctuation - comment.block */ - /* ^^^^ meta.method-call comment.block */ - /* ^ meta.method-call - comment.block - punctuation */ - /* ^^ meta.method-call punctuation - comment.block */ - /* ^ - meta.method-call */ -}; - -template C f(T t) -{ - return C { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -template C> f(T t) -{ - return C> { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -struct A { int foo; }; -int main() { - A a; - a.foo = a.foo < 0 ? 1 : 2; - /* ^ - punctuation.definition.generic */ -} -/* <- - invalid.illegal */ - -template -struct A::value && !is_std_char_type::value>> { - using x = conditional_t; - /* ^^ keyword.operator.comparison */ - - template - struct Y { - constexpr int operator<=>(const Y&) { return 0; } - }; - Y{} <=> Y<0>> y; - /* ^^^ keyword.operator.comparison */ -}; -/* <- - invalid.illegal */ - + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.14L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-15 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c + 0x314.1p5af 0b10e20 +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Storage Modifiers +// Operators ///////////////////////////////////////////// -alignas(16) char array[256]; -/* <- storage.modifier */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -const int XYZ = 2; -/* <- storage.modifier */ - -constexpr int ABC = 3 + 5; -/* <- storage.modifier */ - -consteval int f() { return 42; } -/* <- storage.modifier */ - -constinit const int i = f(); -/* <- storage.modifier */ - -thread_local int x; -/* <- storage.modifier */ - + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 && 2 || 3 ? -4 : ~5 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ keyword.operator.word.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Control Keywords +// Strings ///////////////////////////////////////////// -static_assert(x >= 0); -/* <- keyword.operator */ - -noexcept(f()); -/* ^^^ meta.function-call */ -/* <- keyword.operator */ - -if (x < 5) -/* <- keyword.control */ -{} -else -/* <- keyword.control */ -{} - -switch (x) -/* <- keyword.control */ -{ -case 1: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -default: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -} - -do -/* <- keyword.control */ -{ - if (y == 3) - continue; - /* <- keyword.control.flow.continue */ -} while (y < x); -/*^ keyword.control */ - -switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ -} - -goto label; -/* <- keyword.control.flow.goto */ - -try -/* <- keyword.control */ -{ - throw std :: string("xyz"); - /* <- keyword.control.flow.throw */ - /* ^^^^^^ variable.function */ - /* ^^ punctuation.accessor */ -} -catch (...) -/* <- keyword.control */ -{ -} - -int* ptr = new int(2); -/* ^ keyword.control */ - -delete ptr; -/* <- keyword.control */ - -return 123; -/* <- keyword.control.flow.return */ - + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c++ + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c++ + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c++ + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c++ ///////////////////////////////////////////// -// Operator Keywords +// Constants ///////////////////////////////////////////// -int x = alignof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -int x = sizeof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Cast Keywords +// Enclosings ///////////////////////////////////////////// -const_cast(2.0); -/* <- keyword.operator.word.cast */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -dynamic_cast(2.0); -/* <- keyword.operator.word.cast */ - -reinterpret_cast(2.0); -/* <- keyword.operator.word.cast */ - -static_cast(2.0); -/* <- keyword.operator.word.cast */ - -auto var = *reinterpret_cast>*>(v); -/* ^ keyword.operator.word.cast */ -/* ^ - variable.function */ + [a, b, c] +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^^^^^^ meta.brackets.square.c +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end.c + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Language Constants +// Default Types ///////////////////////////////////////////// -bool t = true; -/* ^ constant.language */ - -bool f = false; -/* ^ constant.language */ - -int* p = nullptr; -/* ^ constant.language */ - -char ch[] = __func__; -/* ^ constant.language */ - + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Support Constants +// Storage Keywords ///////////////////////////////////////////// -std::cout << __FILE__ << '\n'; -/* ^ support.constant */ -/* ^^ punctuation.accessor */ - -std :: cout << __FUNCTION__ << '\n'; -/* ^^ punctuation.accessor */ -/* ^ support.constant */ - -std::cout << __LINE__ << '\n'; -/* ^ support.constant */ - - -///////////////////////////////////////////// -// Numeric Constants -///////////////////////////////////////////// + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1'924'013; -/* ^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec3 = 124ul; -/* ^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec4 = 9'204lu; -/* ^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec5 = 2'354'202'076LL; -/* ^^^^^^^^^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct1 = 0123_567; -/* ^^^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct2 = 014'70; -/* ^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0X1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex3 = 0x1234567890abcdef; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex4 = 0xA7'45'8C'38; -/* ^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex5 = 0x0+0xFL+0xaull+0xallu+0xfu+0xf'12_4_uz; -/* ^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic - constant.c++ */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -bin1 = 0b010110; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin2 = 0B010010; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin3 = 0b1001'1101'0010'1100; -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1'843'290.245'123; -/* ^^^^^^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 2'837e1'000; -/* ^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 23e-1'000; -/* ^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ constant.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ ///////////////////////////////////////////// // Functions ///////////////////////////////////////////// -// function prototype -void abcdWXYZ1234(); -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -// function definition -void abcdWXYZ1234() -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -struct foo **alloc_foo(); -/* ^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -long func -/* ^^^^ meta.function entity.name.function */ -(int x, void *MYMACRO(y) ) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ -entity.name.function */ -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^ meta.group meta.function-call meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end */ - // Ensure < and > aren't parsed as a generic - if (foo < bar && baz > bar ) { -/* ^ keyword.operator.comparison */ -/* ^ keyword.operator.comparison */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - + test(5, 10, 15, 20); +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.c + test( +// ^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.c++ + ); +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c - if (version.major == 10 && version.minor < 11) -/* ^ keyword.operator.comparison */ - { - - } -} -/* <- meta.function meta.block punctuation.section.block.end */ - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} +///////////////////////////////////////////// +// Control Flow +///////////////////////////////////////////// -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - struct Args { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - Args() -/* ^ entity.name.function.constructor */ - : hellp(nullptr), -/* ^ punctuation.separator.initializer-list */ - foobar(nullptr) - { + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c++ +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c++ +// ^ punctuation.section.group.end.c +// ^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^ punctuation.section.block.end.c + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a > b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } - }; - - struct Args args2; -/* ^ keyword.declaration */ -/* ^ - entity */ - - class LocalFoo MYMACRO -/* ^ keyword.declaration */ -/* ^ entity.name.class */ -/* ^ - entity */ - { - LocalFoo() {} -/* ^ entity.name.function.constructor */ +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c++ +// ^ punctuation.separator.c++ + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c } - - class LocalFoo test; -/* ^ keyword.declaration */ -/* ^ - entity */ - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -/* A comment. */ void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -// prevent leading comment from function recognition -/**/ HRESULT A::b() -/* ^ meta.function */ -/* ^ entity.name.function */ -{ - return S_OK; -} -FooBar::FooBar(int a) -/*^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ punctuation.section.group.end */ -{ -} - -FooBar :: FooBar(int a) & = -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.operator */ -/* ^ keyword.operator.assignment */ -default; -/*^^^^^ meta.function storage.modifier */ - -FooBar::~FooBar -/*^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ -() { } -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ - /* <- meta.function.parameters meta.group punctuation.section.group.end */ -/*^^^^ meta.function */ - -ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath:: - ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath() -/* <- meta.function meta.toc-list.full-identifier */ - : var_name(nullptr) { -} - -bool FooBar::operator==() {} -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^^^^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - -myns::FooBar::~FooBar() { } -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ - - extern "C" void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if 0 -void test_in_extern_c_block() -/* ^ comment.block */ -{ -} -#else - -/* temporary C++ preprocessor block */ -#ifdef __cplusplus -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -# ifndef _Bool -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ -/* ^ keyword.declaration */ -/* ^ entity.name.type.typedef */ -# endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -#endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - -void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ -#endif - -#ifdef __cplusplus -} -#endif -/* ^ - meta.extern-c */ - -gener func_returning_generic(int a); -/* ^ entity.name.function */ - -std::vector func_returning_path_generic(int a); -/* ^ punctuation.definition.generic */ -/* ^ entity.name.function */ - -void f() -{ - static_assert(false, "oops"); - /* ^ keyword.operator.word */ -} - -long double operator "" _km (long double x); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^^^^^^^^^^^^^ entity.name.function */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Namespace +// Data Structures ///////////////////////////////////////////// -namespace myNameSpace {} -/* <- keyword.control */ -/* ^ entity.name.namespace */ - -namespace new_name = current_name; -/* <- keyword.control */ - -using namespace NAME __attribute__((visibility ("hidden"))); -/* <- keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ - -using namespace -/* <- keyword.control */ -/* ^ keyword.control */ - -using namespace myNameSpace; -/* <- keyword.control */ -/* ^ keyword.control */ - -void func() { - using namespace NAME __attribute__((visibility ("hidden"))); -/* ^ keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ -} - -namespace ns :: abc /* Neither this comment... */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace */ -/* ^^^^^^^^^ entity.name.namespace */ -/* ^^ punctuation.accessor */ -/* ^ comment.block */ -// ...nor this comment is highlighted -/* <- comment.line */ -{ -/* <- meta.namespace meta.block punctuation.section.block.begin */ - void nsfunc() { - /* ^ entity.name.function */ - } -} -/* <- meta.namespace meta.block punctuation.section.block.end */ - -namespace tl { -/*^^^^^^^^^^^^ meta.namespace */ -/* ^ keyword.control */ - namespace { -/* ^ keyword.control */ -/* ^^^^^^^^^^^ meta.namespace meta.namespace */ -/* ^ meta.block meta.block punctuation.section.block.begin */ - void nested_func(){} -/* ^ entity.name.function */ + struct A; enum B; union C; +// ^^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.forward-declare.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.union.forward-declare.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ entity.name.class.c++ + { +//^^^ meta.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a1; +//^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^ meta.brackets.square.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.c +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ keyword.declaration.enum.c++ +// ^ punctuation.terminator.c +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + void* ptr; +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c } -} - -MACRONAME namespace ns3 {} -/* ^ keyword.control */ - -extern "C++" -// ^ storage.modifier -// ^^^^^ string.quoted.double -{ -namespace std _GLIBCXX_VISIBILITY(default) -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace -// ^ keyword.control -// ^ entity.name.namespace -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call -// ^^^^^^^^^ meta.group -// ^ keyword.control -{} -} - -#define MY_NAMESPACE_BEGIN namespace greatapp { -#define MY_NAMESPACE_END } -MY_NAMESPACE_BEGIN -class X { -private: -/* <- storage.modifier */ - int a; -protected: -/* <- storage.modifier */ - int b; -public: -/* <- storage.modifier */ - int c; -}; -MY_NAMESPACE_END - -MY_NAMESPACE_BEGIN int foo(); MY_NAMESPACE_END -/* ^ storage.type */ -/* ^ meta.function entity.name.function */ -/* ^^^ punctuation */ - -// Uncomment this some day -// MY_NAMESPACE_BEGIN class X : public std::true_type {}; MY_NAMESPACE_END +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^ keyword.operator.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Classes, structs, unions and enums +// Attributes and Declspec ///////////////////////////////////////////// -class BaseClass; -/*^^^^^^^^^^^^^ meta.class */ -/* ^ - meta.class meta.class */ -/* ^^^^^^^^^ entity.name.class.forward-decl */ - -class BaseClass // comment -/* <- keyword.declaration */ -/* ^ entity.name.class */ -{ -public : -/* <- storage.modifier */ - tupleTmpl max(tupleGen a, tupleGen b); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -protected: -/* <- storage.modifier */ -private: -/* <- storage.modifier */ - - static int a = 1 << 4; - /* <- storage.modifier */ - /* ^^ keyword.operator.arithmetic */ - - static int x; - /* <- storage.modifier */ - - virtual void doSomething() const = 0; - /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /* ^ - meta.method meta.method */ - /* ^^ meta.method.parameters meta.group */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* <- storage.modifier */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ meta.number */ - - template - void func(){} -/* ^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/* ^^^^ entity.name.function */ - - template - void func(){} -/* ^^^^^^^^^^^ meta.method */ -/* ^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - template - BaseClass(){} -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ meta.method.constructor */ -/* ^^^^^^^^^ entity.name.function */ - - ~BaseClass() {} -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^ meta.method.destructor */ -/* ^^^^^^^^^^ entity.name.function */ - - BaseClass operator [] () -/* ^^^^^^^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^^^^^^^^^^ entity.name.function */ - {} - - BaseClass operator= -/* ^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ entity.name.function */ - () {} -/* ^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^ meta.block */ -}; - -class DerivedClass : public ::BaseClass // Comment -/* ^ entity.other.inherited-class */ -/* ^ comment.line */ -{ - ~DerivedClass() override; - /* <- meta.method.destructor */ - /*^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /*^^^^^^^^^^^ meta.method.destructor */ - /* ^ storage.modifier */ - virtual void doSomething() const override final; - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - protected: -/*^^^^^^^^ storage.modifier */ - DerivedClass() override -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/*^^^^^^^^^^^^ meta.method.constructor */ -/* ^ storage.modifier */ - : a(a), -/* ^^^^^^^ meta.method.constructor.initializer-list */ - base_id_(BaseClass::None().ToInt()), -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ -/* ^ variable.other.readwrite.member */ -/* ^ punctuation.accessor */ -/* ^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^ variable.function */ -/* ^ punctuation - meta.method-call */ -/* ^^^^^^^ meta.method-call */ -/* ^^^^^ variable.function */ -/* ^ punctuation.separator */ - bounds_(NULL), -/* ^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - bit_field_(0) { -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - char * a = "sprintf"; - char * b = sprintf("Testing %s", a); -/* ^^^^^^^^^ meta.function-call */ -/* ^^^^^^^ support.function.C99 */ - - base_id_->foobar(1, "foo"); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^ variable.function */ - - base_id_->~BaseClass(); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^^^^^ variable.function */ - } -/* ^ meta.method meta.block punctuation.section.block.end */ - -/* <- - meta.class.constructor.initializer-list */ - - typedef std::vector qux; -/* ^^^ entity.name.type.typedef */ -}; - - -template -class class1 : class2 -/* ^^^^^^ entity.name.class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -/* ^^^^^^ entity.other.inherited-class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -{} - -class FooBar { -/* ^ meta.class meta.block punctuation.section.block.begin */ - explicit FooBar(int a); -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^ storage.modifier */ -/* ^^^^^^ entity.name.function */ - FooBar() =default; -/* ^^^^^^ entity.name.function */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - FooBar(void) =default; -/* ^^^^^^ entity.name.function */ -/* ^^^^ storage.type */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - - // If a constructor name is on a line without the opening (, it is not - // highlighted as a method/constructor. This prevents a bunch of false - // positives, including data types as they are being typed into a struct. - FooBar -/* ^ - entity.name.function */ - (); - - virtual ~FooBar(); -/* ^^^^^^^ entity.name.function */ - -#ifndef DEBUG - ~FooBar(); -/* ^^^^^^^ entity.name.function */ -#endif - - void insert () {} -/* ^^^^^^ entity.name.function */ - - explicit operator bool -/* ^^^^ entity.name.function */ - () {} - - FooBar::~FooBar(); -/* ^^^^^^^^^^^^^^^ entity.name.function */ - - void FooBar:: - Baz() { - /* <- entity.name.function */ - } - - auto f(int a) -> decltype(a.begin()) override final; -/* ^^ punctuation.separator */ -/* ^ punctuation.accessor */ -/* ^^^^^ variable.function */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - - auto g() -> std::vector override final { -/* ^^ punctuation.separator */ -/* ^^ punctuation.accessor */ -/* ^ storage.type */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - this->g(1); -/* ^ variable.language */ - } - -private: -/*^^^^^ storage.modifier */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - myns::subns::MyDataType -/* ^ - entity.name.function */ - and_now_method_name(); -/* ^ entity.name.function */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - std::shared_future> -/* ^ - entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ - and_now_method_name2(); -/* ^ entity.name.function */ - - enum { - FOO, - /* ^^^ entity.name.constant.objc++ */ - /* ^ punctuation.separator.objc++ */ - BAR - /* ^^^ entity.name.constant.objc++ */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c }; - - enum -/* ^^^^ meta.enum keyword.declaration */ - { -/* ^ meta.enum punctuation.section.block.begin */ - A = 1, -/* ^ entity.name.constant.objc++ */ -/* ^ punctuation.separator.objc++ */ - B = 20 / 5, -/* ^ entity.name.constant.objc++ */ -/* ^ punctuation.separator.objc++ */ - C = FOO -/* ^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^ - entity.name */ - } -/* ^ meta.enum punctuation.section.block.end */ -/* ^ - meta.enum */ - - friend int func(int a, int b); -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ - entity.name.function */ -/* ^ - meta.function-call */ - - friend int func(int a, int b) { -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ entity.name.function */ -/* ^ - meta.function-call */ -/* ^ meta.class meta.block meta.method meta.block punctuation.section.block.begin */ - int a = 1; - } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ - - friend class ::FooBar; -/* ^ storage.modifier */ -/* ^ keyword.declaration -/* ^^ punctuation.accessor */ -/* ^ - entity */ - - friend bool operator != (const X& lhs, const X& rhs) { - /* ^^^^^^^^^^^ entity.name.function */ - int a = 1; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackts.square.objc++ punctuation.section.brackets.begin.objc++ +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin - #if 0 - /* ^ meta.number */ - int disabled_func() { - /* ^ comment.block */ } - #endif - - #if 1 - /* ^ meta.number */ - int enabled_func() {} - /* ^ entity.name.function */ - #else - int disabled_func() { - /* ^ comment.block */ - } - #endif - - MACRO_NOT_CONSTRUCTOR(FooBar); -/* ^ meta.function-call variable.function - entity.name.function */ - - MACRO_NOT_CONSTRUCTOR2(FooBar, -/* ^ meta.function-call variable.function - entity.name.function */ - FriendClass); -} -/* <- meta.class meta.block punctuation.section.block.end */ - /* <- - meta.class meta.block */ - -struct X { - Y f() override noexcept final; - /*^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class X { - public: - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -union Y { - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class Child : public Parent { - ::anotherClass Func() override; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ -} - -class Adapter2 : public Abstraction, private Scenario { -/* ^ punctuation.separator */ -} - -class Adapter : public Abstraction - #if defined ASPECTO_MACRO -/* ^^^ keyword.control.import */ - , public Scenario -/* ^ punctuation.separator */ -/* ^ storage.modifier */ -/* ^ entity.other.inherited-class */ - #endif -/* ^^^^^^ keyword.control.import */ -{ - -} - -struct Base {}; -class Derived final : Base {}; -/* ^ storage.modifier */ -struct Derived final : Base {}; -/* ^ storage.modifier */ - -/* C++11 "uniform initialization" in initializer lists */ -class Foo { -public: - Foo() : var1(1), var(2), var3{3}, var4(4) {} - /* ^ meta.method.constructor.initializer-list */ - /* ^ - meta.function-call - variable.function */ -private: - int var1, var2, var3, var4; -}; - -class X { - int a, b, i, j; -public: - const int& r; - X(int i) - : r(a) // initializes X::r to refer to X::a - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , b{i} // initializes X::b to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , i(i) // initializes X::i to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j(this->i) // initializes X::j to the value of X::i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j - /*^ variable */ - (this->i) - /* <- meta.method.constructor.initializer-list punctuation */ - { } -/* ^ punctuation - meta.method.constructor.initializer-list */ -/* ^ punctuation - meta.method.constructor.initializer-list */ -}; - -struct A { - static_assert(0 < 1, ""); - /* ^ keyword.operator.word */ - /* ^ meta.function-call */ - /* ^ keyword.operator.comparison */ - - A(); -/*^ meta.method.constructor entity.name.function.constructor */ - - void f(); - /* ^ storage.type */ - /* ^ meta.method entity.name.function */ - /* ^ punctuation.terminator */ -}; -/* <- punctuation.section.block.end - invalid.illegal */ - -struct bar { -/*^^^^^^^^^^ meta.struct */ -/*^^^^ keyword.declaration */ -/* ^^^ entity.name.struct */ -/* ^ meta.block punctuation.section.block.begin */ - bar() -/* ^^^^^ meta.method */ -/* ^^^ entity.name.function */ - {} -} -/* <- meta.struct meta.block punctuation.section.block.end */ - /* <- - meta.struct meta.block */ - -enum baz { -/*^^^^^^^^ meta.enum */ -/* <- meta.enum keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ meta.block punctuation.section.block.begin */ - FOO = 1, -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAR = 2, - BAZ = 3, -#if 0 -/* ^ meta.number */ - QUX = 4, -/* ^ comment.block */ -#endif -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; - -enum class qux : std::uint8_t -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/*^^^^^^^^ keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ punctuation.separator */ -/* ^^^^^^^^^^^^ entity.other.inherited-class */ -{ -/* <- meta.block punctuation.section.block.begin */ - FOO = 1, - BAR = 2, -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAZ = 3 -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -typedef enum class funky -/*^^^^^ keyword.declaration */ -/* ^^^^^ entity.name.enum */ -{ - BAZ = 3 -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Funky; - -typedef enum -/*^^^^^ keyword.declaration */ -{ - FOO = 1, - BAR = 2, - BAZ = 3 -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Fun; - -enum LineEnding : uint32_t; -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/* ^^^^^^^^^^ entity.name.enum.forward-decl */ -/* ^ punctuation.separator */ -/* ^^^^^^^^ entity.other.inherited-class */ -/* ^ - meta.enum */ - -union foobaz { -/* <- meta.union keyword.declaration */ -/* ^^^^^^ entity.name.union */ -/* ^ meta.block punctuation.section.block.begin */ -} -/* <- meta.union meta.block punctuation.section.block.end */ - /* <- - meta.union meta.block */ - -// Class name that looks like a possible macro -class SP {} -/* ^^ entity.name.class */ - -class MyClass MACRO MACRO2 -/* ^ keyword.declaration */ -/* ^ entity.name.class */ -/* ^ - entity */ -/* ^ - entity */ -{} - -// Class using macro to handle __declspec() on Windows -class SK_API SkBitmap {} -/* ^ entity.name.class */ -class __declspec(property(get=foo)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ variable.parameter */ -/* ^ entity.name.class */ -class __declspec(align(8)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ meta.number */ -/* ^ entity.name.class */ -class __declspec(dllimport) SkBitmap {} -/* ^ constant.other */ -/* ^ entity.name.class */ - -// Make sure not to match macros that have "too few characters". -template class Sample { - public: - // The T here should not be consumed as a macro. - T operator() (const foo x) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - int operator == (const int x) { - /*^^^^^^^^^^^ entity.name.function */ - return 0; - } - // The T here should not be consumed as a macro. - T operator()(int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - // The T here should not be consumed as a macro. - T operator[](int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } -}; - -class Namespace::MyClass MACRO1 MACRO2 : public SuperClass -/* ^^^^^^^ entity.name.class */ -/* ^^ punctuation.accessor */ -/* ^ - entity.name */ -{ -}; - -struct Namespace::MyStruct -/* ^^^^^^^^ entity.name.struct */ -/* ^^ punctuation.accessor */ -{ -}; - -union Namespace::MyUnion -/* ^^^^^^^ entity.name.union */ -/* ^^ punctuation.accessor */ -{ -}; - -enum class Namespace::MyEnum -/* ^^^^^^ entity.name.enum */ -/* ^^ punctuation.accessor */ -{ -}; - -class Namespace:: -MyClass MACRO1 -/* <- entity.name.class */ -/* ^ - entity.name */ -{ -}; - -struct Namespace:: -MyStruct MACRO1 -/* <- entity.name.struct */ -/* ^ - entity.name */ -{ -}; - -union Namespace:: -MyUnion MACRO1 -/* <- entity.name.union */ -/* ^ - entity.name */ -{ -}; - -enum class Namespace:: -MyEnum MACRO1 -/* <- entity.name.enum */ -/* ^ - entity.name */ -{ - BAR = 1, -/* ^^^ entity.name.constant.objc++ */ -}; +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Preprocessor ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[], bool val3 = false) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -/* ^ punctuation.separator */ -/* ^^^^ storage.type */ -/* ^^^^ variable.parameter */ -/* ^ keyword.operator.assignment */ -/* ^^^^^ constant.language */ -{ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result == 0) { - return 0; -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifndef DEBUG - if (check_debug()) { - val /= 2; -#endif - val += 1; -#ifndef DEBUG - } -/* ^ meta.function meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ -#endif - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -#if 0 -/* ^ meta.number */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 -/* ^ meta.number */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number */ - int b = 2; -/* ^ comment.block */ + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c++ +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.separator.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c #else - int c = 3; +//^^^^^^^ keyword.control.import.c #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ - -///////////////////////////////////////////// -// Matching various function definitions -///////////////////////////////////////////// - -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ entity.name.function */ -(int * a) -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ punctuation.section.group.end */ -{ - -} - -void MyClass3:: -foo() { -/* <- entity.name.function */ -} - -MyClass3:: -~MyClass3() { -/* <- entity.name.function */ -} - -struct A -{ - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ - #endif - - void f() - { - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ - #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + # +// ^ keyword.control.c + #embed "file.txt" if_empty(0) +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ keyword.other.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c + + + "Hello {}!"_literal +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + 'h'_literal +// ^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + R"RAW( +// ^^^^^^ string.quoted.double.raw.c++ +// ^ storage.type.string.c++ +// ^ punctuation.definition.string.begin.c++ +// ^^^^ constant.other.placeholder.c++ + raw string )STR" +//^^^^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ + )RAW"_literal +//^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ +// ^^^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + + using std::cout; +// ^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^ entity.name.using.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.terminator.c + using namespace std; +// ^^^^^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.namespace.c++ +// ^ punctuation.terminator.c + + and and_eq or or_eq not not_eq xor xor_eq bitand bitor compl +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^ keyword.operator.logical.c++ +// ^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ + delete new typeid noexcept <=> +// ^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.word.c++ +// ^^^^^^ keyword.operator.word.c++ +// ^^^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.comparison.c++ + + constexpr consteval constinit +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ + wchar_t wchar8_t wchar16_t wchar32_t +// ^^^^^^^ storage.type.c++ +// ^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ + + enum class Test { +// ^^^^^^^^^^^^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^^^^^ keyword.declaration.class.c++ +// ^^^^ entity.name.enum.c +// ^ punctuation.section.block.begin.c + A = 314, +//^^^^^^^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + B, +//^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ punctuation.separator.c + }; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + namespace std::mynamespace { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ +// ^^^^^^^^^ keyword.declaration.namesace.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.namespace.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.block.c++ punctuation.section.block.begin.c++ + std::vector const& func(std::string const& a, std::function b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + template auto func(char param1, int param2 = f(20) - g(20)) const -> decltype(T::func(param)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ variable.function.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + try { +//^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + throw ns::func(param2); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^ keyword.control.exception.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^^^^ meta.function.c +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } catch (std::exception const& e) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^ keyword.control.exception.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_await func +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ + (e); +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + } finally { +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_yield func(param1); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ +// ^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end.c + + co_return 7; +//^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^^^^^^^ keyword.control.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c } - - void f() - { - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ +//^^^ meta.namespace.c++ meta.block.c++ +// ^ punctuation.section.block.end.c++ + + class Type; +// ^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + + template class V, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.separator.c + typename ...Args> requires std::same_as, std::string> +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^^^ keyword.operator.variadic.c +// ^^^^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ + struct MACRO Type> MACRO final : D> { +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^^^^^ entity.other.inherited-class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + private: +//^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ + alignas(20) std::string m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + protected: +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^ storage.modifier.c++ + int m_value2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + friend class V; +//^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + friend void someFunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + public: +//^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ + Type() && : m_value1("a"), m_value2(10); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.initializer-list.c++ +// ^ punctuation.separator.initializer-list.begin.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^ meta.group.c +// ^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.separator.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.group.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + ~Type() = default; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^^ keyword.control.c +// ^ punctuation.terminator.c + explicit Type(int) = delete; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ storage.type.c +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^ keyword.operator.word.c++ +// ^ punctuation.terminator.c + + template <> +//^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^ punctuation.section.generic.end.c++ + std::string const& doThing() const requires requires(std::tuple a) { a.get<0>().runThing(); } { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +//^^^^^^ meta.template.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.requires.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ keyword.operator.variadic.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.definition.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return this->m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^ variable.language.c++ +// ^^ punctuation.accessor.arrow.c +// ^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + }; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + export { +// ^^^^^^ keyword.other.c++ +// ^ meta.block.c punctuation.section.block.begin.c + class A : protected A, private B, public C { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.c++ +// ^^ entity.other.inherited-class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + virtual void vfunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ storage.type.c +// ^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + bool operator ==(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + int operator<=>(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + unsigned long long operator ""_label(unsigned long long a) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c } -}; - -void f() -{ - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ -} - -void f() -{ - #ifdef X - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ - #endif -} - -Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/); -/* ^^^^^^^^^ comment */ - -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + void A::vfunc() { +// ^^^^ storage.type.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + auto lambda = [=] mutable -> std::string { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return "test"; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + ([&, this, lambda](int a, char b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.separator.c +// ^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^^^^^^ meta.template.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + + })(5, 10); +//^^^^^^^^^^^^^^^^ meta.block.c +//^^^^^^^^^^^^^^^ meta.group.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + auto somestruct = { +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.block.c punctuation.section.block.begin.c + .thing = 5, "200", .other = lambda +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.separator.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c } - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + A::~A() { +// ^^ punctuation.accessor.double-colon.c++ +// ^^ variable.function.c++ +// ^ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + delete this; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.operator.word.c++ +// ^^^^ variable.language.c++ +// ^ punctuation.terminator.c + } +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + template +// ^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ + concept MyConcept = std::same_as || requires(T a) { something(a) == 0; }; +//^^ meta.template.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ entity.name.concept.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^ keyword.operator.assignment.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + export module test.module:part; +// ^^^^^^ keyword.other.c++ +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + module test.module:part; +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + import test.module:part; +// ^^^^^^ keyword.other.import.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + +#import +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^ keyword.control.import.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +@import Foundation; +//^^^^^ keyword.control.objc +// ^ punctuation.terminator.c + +typedef SEL(^sample)(IMP _Nullable a, id _Nonnull b, Class nonnull c, BOOL nullable d); +//^^^^^ keyword.declaration.type.c +// ^^^ storage.type.objc +// ^ keyword.operator.c +// ^^^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^ storage.type.objc +// ^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + +@class NSWindow; +//^^^^ keyword.declaration.class.objc +// ^^^^^^^^ entity.name.type.class.objc +// ^ punctuation.terminator.c + +@protocol MyProtocol +//^^^^^^^ meta.protocol.objc keyword.declaration.class.objc +// ^^^^^^^^^^ meta.protocol.objc entity.name.type.objc +@optional +//^^^^^^^ meta.protocol.objc storage.modifier.objc ++(instancetype) selector; +//^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc +//^^^^^^^^^^^^^ meta.group.c +//^^^^^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.terminator.objc +@required +//^^^^^^^ meta.protocol.objc storage.modifier.objc +-(NSRect) someSelector:(__nonnull id)param withOther:(__unused)param2; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc +//^^^^^^^ meta.group.c +//^^^^^^ support.type.cocoa.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.c +// ^^^^^^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.protocol.objc keyword.declaration.interface.end.objc + +@interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NSObject +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^^ keyword.declaration.class.objc +// ^^^^^^^ entity.name.type.objc +// ^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ entity.name.type.category.objc +// ^ meta.group.c punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^ storage.modifier.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ punctuation.separator.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ { - -} - -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -int& return_type_ref_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ - -///////////////////////////////////////////// -// Paths/identifiers -///////////////////////////////////////////// - -void sayHi() + @public int a; +//^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ punctuation.terminator.c + @protected NSDictionary* b; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ punctuation.terminator.c + @private char* d; +//^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + @package sample e; +//^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c +} + +@property(readwrite, nonatomic) IBOutlet NSButton* btn; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c +@property(readonly, getter=myGetE) IBInspectable sample e; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.objc +// ^ keyword.operator.assignment.objc +// ^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c + +-(void)someSelector:(void*)a; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.function.selector.objc +//^^^^^ meta.group.c +//^^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^ meta.group.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.interface.objc keyword.declaration.interface.end.objc + +@implementation MyClass +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc +//^^^^^^^^^^^^^ meta.implementation.objc keyword.declaration.class.objc +// ^^^^^^^ meta.implementation.objc entity.name.type.objc +@synthesize e; +//^^^^^^^^^^^^ meta.implementation.objc +//^^^^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c +@dynamic btn; +//^^^^^^^^^^^ meta.implementation.objc +//^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c + +-(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attribute__((objc_direct)) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.function.selector.objc +//^^^^^^^^^ meta.group.c +//^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.c +// ^^^^^^ variable.parameter.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.objc +// ^^ punctuation.section.group.end.c { - std::cout << "Hi!\n"; -/* ^ punctuation.accessor */ - Print(3); -/* ^ variable.function */ - func_call(foo -/* ^ meta.function-call */ - ); - - if (::std::foo()) {} -/* ^^^ variable.function */ -/* ^^ punctuation.accessor */ -/* ^^ punctuation.accessor */ - - foobaz(); -/* ^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<>(); -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<0>(); -/* ^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - ::myns::foo(); -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ storage.type */ - - myns::FooClass{42}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ - - ::myns::BarClass{}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ -/* ^^^ storage.type */ - - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ - - std::cout << ">> Hi!\n"; -/* ^^ keyword.operator.arithmetic.c */ + [super someSelector:param withOther:param2]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^ variable.language.objc +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __block int i = 1; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + __strong NSString* j = [NSString stringWithFormat:@"Hello, World! %@", @314, nil]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.objc +// ^^ punctuation.definition.string.begin.objc +// ^^ constant.other.placeholder.objc +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.separator.c +// ^ constant.numeric.objc +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ constant.language.null.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __weak NSNumber* k = @'3'; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^ string.quoted.single.c +// ^^ punctuation.definition.string.begin.objc +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.terminator.c + __autoreleasing NSView* a = [[NSView alloc] init]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^ support.class.cocoa.objc +// ^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + + NSArray* f = @[ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ support.class.cocoa.objc +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.definition.generic.end.c++ +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ + @314.5, +//^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ punctuation.separator.c + @0x314LL, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^ punctuation.separator.c + @0314e10, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + @0b1010u +//^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + ]; +//^^^^ meta.implementation.objc meta.block.c +//^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c + + NSDictionary* g = @{ +//^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^ meta.mapping.objc punctuation.section.mapping.begin.objc + (__bridge id)kValue1 : (__bridge NSViewController)kValue2, +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^^^^^ support.class.cocoa.leopard.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ punctuation.separator.c + (__bridge NSWindow)kValue3 : @YES +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^ constant.language.boolean.true.objc + }; +//^^^^ meta.implementation.objc meta.block.c +//^^^ meta.mapping.objc +// ^ punctuation.section.mapping.end +// ^ punctuation.terminator.c + + [g respondsToSelector:@selector(doSomething:withSomething:)]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.objc +// ^^^^^^^^^ keyword.operator.word.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.method-name.objc support.function.objc +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.brackets.end.objc + if (@available(iOS 10.4, macOS 11.3, *)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.available.objc +// ^^^^^^^^^^ keyword.operator.word.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^^^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + [[[g allValues] objectAtIndex: 1] +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.objc + perform: @encode(int) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ keyword.operator.word.objc +// ^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ punctuation.section.group.end + with: @NO +//^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^ constant.language.boolean.false.objc + ]; +//^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } +//^^^ meta.implementation.objc meta.block.c meta.block.c +// ^ punctuation.section.block.end + + return [NSClassFromString([NSString stringWithUTF8String:self.j.UTF8String]) someSelector:^(__contravariant NSObject* a, __covariant int const* b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^^^^^^^^^^ support.function.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^ variable.language.objc +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.function.block.objc keyword.operator.bitwise.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.objc punctuation.section.block.begin.objc + @try { +//^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +// ^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + [Nil message: (a + b) ? @true : @false]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^ constant.language.null.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ keyword.operator.ternary.c +// ^^^^^ constant.language.boolean.true.objc +// ^ keyword.operator.ternary.c +// ^^^^^^ constant.language.boolean.false.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } @catch(NSException* exc) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.bracketed.objc meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^^ keyword.control.exception.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^^^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.c punctuation.section.block.begin.c + return NO; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^ constant.language.boolean.false.objc +// ^ punctuation.terminator.c + } @finally { +//^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + return YES; +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^ constant.language.boolean.true.objc +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + }]; +//^^^^^ meta.implementation.objc meta.block.c +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c } - -///////////////////////////////////////////// -// Objective-C Interface -///////////////////////////////////////////// - -@interface Person : NSObject -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ -@property (readonly) NSString *firstName; -/* <- keyword.other punctuation.definition.keyword */ -/*^ keyword.other */ -@property (readonly, nullable, class) NSString *lastName; -/* <- keyword.other punctuation.definition.keyword */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute. */ -/* ^ punctuation.section.scope.end */ -- (NSString*)formatWithPattern:(NSString*)pattern __attribute__((swift_name("format(pattern:)"))); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.objc++*/ -/* ^^^^^^^^^^^^^ storage.modifier.objc++*/ -/* ^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/ @end -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ - -NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@", -/*^ support.class */ -/* ^ keyword.operator */ -/* ^ meta.bracketed punctuation.section.scope.begin */ -/* ^ support.function.any-method */ -/* ^^ string.quoted.double punctuation.definition.string.begin */ - attributeName, attributeValue]; -/* ^ meta.bracketed punctuation.section.scope.end */ - -@implementation Person -- (void)debugOutput:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2) -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ variable.function */ -{} -@end - -///////////////////////////////////////////// -// Includes -///////////////////////////////////////////// - -#import -/* <- meta.preprocessor.import keyword.control.import.import */ - -#include -/* <- meta.preprocessor.include keyword.control.import.include */ - -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ +//^^ meta.implementation.objc keyword.declaration.interface.end.objc +//^^ meta.implementation.objc keyword.declaration.interface.end.objc diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index b105d5fd49..0ba2c1f011 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -1,1233 +1,1739 @@ -/* SYNTAX TEST "Packages/Objective-C/Objective-C.sublime-syntax" */ - -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ +// SYNTAX TEST "Packages/Objective-C/Objective-C.sublime-syntax" - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number constant.numeric.value */ - /* ^^ keyword.operator.arithmetic */ -} - -enum Foo { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.enum */ -/* ^ entity.name.constant.objc */ -/* ^ entity.name.constant.objc */ -#define FOO Foo -enum FOO do_the_foo(void); -/* ^ entity.name.function */ -/* ^ storage.type */ - -#define APIC_CAPABILITY TheEnum -enum TheEnum { kFoo, kBar }; -static enum APIC_CAPABILITY apic_capabilities(void) { return kFoo; }; -/* ^ entity.name.function */ -/* ^ storage.type */ - -enum { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.constant.objc */ -/* ^ entity.name.constant.objc */ - -enum { kFoo = FOO, kBar = BAR }; -/* <- keyword.declaration */ -/* ^^^^ entity.name.constant.objc */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ -/* ^ punctuation.separator.objc */ -/* ^^^^ entity.name.constant.objc */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ - -typedef enum state { DEAD, ALIVE } State; -/* <- keyword.declaration -/* ^ entity.name.enum */ -/* ^ entity.name.constant.objc */ -/* ^ entity.name.constant.objc */ - -enum { - FOO, -/* ^^^ entity.name.constant.objc */ -/* ^ punctuation.separator.objc */ - BAR -/* ^^^ entity.name.constant.objc */ -}; - -struct __declspec(dllimport) X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct __declspec(dllimport) baz X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct foo { -/* ^ entity.name.struct */ - union { -/* ^ keyword.declaration */ - struct { -/* ^ keyword.declaration */ - int a; -/* ^ storage.type */ - int b; -/* ^ storage.type */ - } - } -} - -#define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS /* comment block */ * sizeof(struct ptp_extts_event)) // comment line -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group meta.group */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant.preprocessor */ -/* ^ comment.block */ -/* ^ keyword.operator.word */ -/* ^ keyword.declaration */ -/* ^ comment.line */ - -#pragma foo(bar, \ -"baz") -/*^^^^ meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#define PACKED __attribute__((aligned(1),packed)) -/* ^ entity.name.constant */ -/* ^ storage.modifier */ - -int i; -/* <- storage.type */ - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin */ -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.block */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number constant.numeric.value */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -#define CONST0 16 // Comment -#define CONST1 8 -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#if defined(VARIABLE) | // comment_line \ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor */ \ - defined(VAR2) -/*^^^^^^^^^^^^^^^ meta.preprocessor */ -/* ^ keyword.control */ -# error This is a long error message that need to \ -/* <- keyword.control.import */ \ -/* ^ string.unquoted */ \ - be splitted into two lines to prevent large lines. // comment -#error "Explicitly quoted string wrapped, \ - ensuring that the string quoting stops at some point \ - " -#warning This is a short warning -/* <- keyword.control.import */ -#endif - /* <- keyword.control.import */ - -#define MACRO_WITH_CURLY_BRACE { -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -bool still_C_code_here = true; -/* <- storage.type */ -/* ^ constant.language */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c -#if 0 -#ifdef moo -/* <- - keyword.control */ -#endif -/* <- - keyword.control */ -#endif - -#if 0 -/* ^ meta.number constant.numeric.value */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 -/* ^ meta.number constant.numeric.value */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number constant.numeric.value */ - int b = 2; -/* ^ comment.block */ - #else - int c = 3; - #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - - -FOO -/* <- meta.assumed-macro */ -FOO; -/* <- - meta.assumed-macro */ -foo -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO(); -/* <- - meta.assumed-macro */ -foo() -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ - -struct X -{ - ENABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - int foo; - /* <- storage.type */ + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c - DISABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - float bar; - /* <- storage.type */ -}; + */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Preprocessor branches starting blocks +// Numbers ///////////////////////////////////////////// -#ifdef FOO -if (1) { -#elif BAR -if (2) { -# elif BAZ -if (3) { -# else -if (4) { -#endif - int bar = 1; -} -/* <- meta.block punctuation.section.block.end */ - /* <- - meta.block */ + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.14L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-15 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c + 0x314.1p5af 0b10e20 314e+30llu +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^^^^ meta.number.float.decimal.c +// ^^^^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Typedefs +// Operators ///////////////////////////////////////////// -typedef int myint; -/* <- keyword.declaration */ -/* ^ entity.name.type */ - -typedef struct mystruct { -/* <- keyword.declaration */ -/* ^ keyword.declaration.struct.objc */ -/* ^ entity.name.struct.objc */ -} mystruct; -/* ^ entity.name.type */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.objc */ -/* ^^^^^^ keyword.declaration.struct.objc */ -/* ^^^^^^^^^^^ entity.name.struct.objc */ -/* ^ punctuation.section.block.begin.objc */ -/* ^ punctuation.section.block.end.objc */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.objc */ + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 ? -2 : ~3 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Data structures and return values +// Strings ///////////////////////////////////////////// -struct point -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ -{ - int x; - int y; -} - -struct point2 { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - int x; - int y; -} - -int main(void) { -/* ^^^^ entity.name.function */ -/* ^^^^ storage.type */ -} - -struct point get_point() {} -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin -/* ^ punctuation.section.block.end -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^ entity.name.function */ - -struct point **alloc_points(); -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -struct point* alloc_point(); -/* ^ entity.name.function - variable.function */ - -struct point FOO_API *alloc_point3(); -/* ^ entity.name.function - variable.function */ - - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Constants ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[]) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -{ -/* <- meta.function meta.block */ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result == 0) { - return 0; -/* ^^^^^^ keyword.control.flow.return */ -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifdef BAR - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifndef BAZ - /* <- keyword.control.import */ - if (val == -3) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -4) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Matching various function definitions +// Enclosings ///////////////////////////////////////////// -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.function entity.name.function */ -(int * a) -/*^^^^^^^ meta.function.parameters meta.group */ -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} - -MACRO1 void * MACRO2 myfuncname () { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; -/* ^^^^^ keyword.control.flow.break */ - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ - } + [a, b, c] +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^ meta.brackets.square.c +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end.c + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end - struct Args { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - }; +///////////////////////////////////////////// +// Default Types +///////////////////////////////////////////// - struct Args args; -/* ^ keyword.declaration */ -/* ^ - entity */ + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end -} +///////////////////////////////////////////// +// Storage Keywords +///////////////////////////////////////////// -static const uint32_t * const MACRO funcname(); -/* ^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() -{ - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -} + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ ///////////////////////////////////////////// -// Test function call in function parameters +// Functions ///////////////////////////////////////////// -static string foo(bar() + ';'); -/* ^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^ entity.name.function */ -/* ^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ string */ -/* ^ -string */ - -func_call(foo -/*^^^^^^^^^^^ meta.function-call */ -/* ^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -); -/* <- meta.function-call meta.group punctuation.section.group.end */ + test(5, 10, 15, 20); +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.c + test( +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^ variable.parameter.c + ); +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Invalid +// Control Flow ///////////////////////////////////////////// -) -/* <- invalid.illegal.stray-bracket-end */ -} -/* <- invalid.illegal.stray-bracket-end */ + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a > b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c +// ^ punctuation.separator.c + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Objective-C Interface +// Data Structures ///////////////////////////////////////////// -@interface Person : NSObject -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ -@property (readonly) NSString *firstName; -/* <- keyword.other punctuation.definition.keyword */ -/*^ keyword.other */ -@property (readonly, nullable, class) NSString *lastName; -/* <- keyword.other punctuation.definition.keyword */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute. */ -/* ^ punctuation.section.scope.end */ -- (NSString*)formatWithPattern:(NSString*)pattern __attribute__((swift_name("format(pattern:)"))); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.objc*/ -/* ^^^^^^^^^^^^^ storage.modifier.objc*/ -/* ^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/ -@end -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ - -NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@", -/*^ support.class */ -/* ^ keyword.operator */ -/* ^ meta.bracketed punctuation.section.scope.begin */ -/* ^ support.function.any-method */ -/* ^^ string.quoted.double punctuation.definition.string.begin */ - attributeName, attributeValue]; -/* ^ meta.bracketed punctuation.section.scope.end */ - -@implementation Person -- (void)debugOutput:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2) -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ variable.function */ -{} -@end - + struct A; enum B; union C; +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.forward-declare.c +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.forward-declare.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.union.forward-declare.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c + { +// ^ meta.struct.c meta.block.c punctuation.section.block.begin.c + int a1; +//^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^ meta.brackets.square.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.c +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ keyword.declaration.enum.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + void* ptr; +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ meta.block.c punctuation.section.block.begin.c + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Includes +// Attributes and Declspec ///////////////////////////////////////////// -#import -/* <- meta.preprocessor.import keyword.control.import.import */ - -#include -/* <- meta.preprocessor.include keyword.control.import.include */ - -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -static const unsigned char image_png[] = { -#embed -/* <- keyword.control.import.include */ -}; - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^^^^ entity.name.struct.c +// ^ meta.block.c punctuation.section.block.begin.c + int a; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.objc punctuation.section.brackts.begin.objc +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Numeric Constants +// Preprocessor ///////////////////////////////////////////// -dec0 = 0; -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1234567890f; -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec3 = 1234567890L; -/* ^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec4 = 1234567890ul; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec5 = 1234567890Lu; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec6 = 1234567890LLU; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec7 = 1234567890uLL; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec8 = 1'234_567'890s0f; -/* ^^^^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct1 = 01234567; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -oct2 = 01234567L; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct3 = 01234567LL; -/* ^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct4 = 01234567ulL; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct2 = 01284967Z0L; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^^^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x0+0xFL+0xaull+0xallu+0xfu+0x'f'12_4uz; -/* ^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic - constant.c */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c */ -/* ^ constant.numeric.value.c */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ - + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.separator.c +// ^ punctuation.section.group.end +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c + #else +//^^^^^^^ keyword.control.import.c + #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + # +// ^ keyword.control.c + #embed "file.txt" if_empty(0) +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ keyword.other.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c ///////////////////////////////////////////// -// Objective-C specific format specifiers +// Objective-C ///////////////////////////////////////////// -print ("%@", @"String") -/* ^ - invalid */ - -NSLog (@"%@", @"String") -/* ^ constant.other.placeholder.objc */ -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ +#import +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^ keyword.control.import.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +@import Foundation; +//^^^^^ keyword.control.objc +// ^ punctuation.terminator.c + +typedef SEL(^sample)(IMP _Nullable a, id _Nonnull b, Class nonnull c, BOOL nullable d); +//^^^^^ keyword.declaration.type.c +// ^^^ storage.type.objc +// ^ keyword.operator.c +// ^^^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^^ storage.type.objc +// ^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + +@class NSWindow; +//^^^^ keyword.declaration.class.objc +// ^^^^^^^^ entity.name.type.class.objc +// ^ punctuation.terminator.c + +@protocol MyProtocol +//^^^^^^^ meta.protocol.objc keyword.declaration.class.objc +// ^^^^^^^^^^ meta.protocol.objc entity.name.type.objc +@optional +//^^^^^^^ meta.protocol.objc storage.modifier.objc ++(instancetype) selector; +//^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc +//^^^^^^^^^^^^^ meta.group.c +//^^^^^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.terminator.objc +@required +//^^^^^^^ meta.protocol.objc storage.modifier.objc +-(NSRect) someSelector:(__nonnull id)param withOther:(__unused)param2; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc +//^^^^^^^ meta.group.c +//^^^^^^ support.type.cocoa.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.c +// ^^^^^^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.protocol.objc keyword.declaration.interface.end.objc + +@interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NSObject +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^^ keyword.declaration.class.objc +// ^^^^^^^ entity.name.type.objc +// ^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ entity.name.type.category.objc +// ^ meta.group.c punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^ storage.modifier.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ punctuation.separator.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^ meta.protocol-list.objc +// ^ punctuation.section.scope.begin.objc +// ^ punctuation.section.scope.end.objc +{ + @public int a; +//^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ punctuation.terminator.c + @protected NSDictionary* b; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ punctuation.terminator.c + @private char* d; +//^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + @package sample e; +//^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c +} -"foo % baz" -/* ^ - invalid */ +@property(readwrite, nonatomic) IBOutlet NSButton* btn; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c +@property(readonly, getter=myGetE) IBInspectable sample e; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.objc +// ^ keyword.operator.assignment.objc +// ^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c + +-(void)someSelector:(void*)a; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.function.selector.objc +//^^^^^ meta.group.c +//^^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^ meta.group.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.interface.objc keyword.declaration.interface.end.objc + +@implementation MyClass +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc +//^^^^^^^^^^^^^ meta.implementation.objc keyword.declaration.class.objc +// ^^^^^^^ meta.implementation.objc entity.name.type.objc +@synthesize e; +//^^^^^^^^^^^^ meta.implementation.objc +//^^^^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c +@dynamic btn; +//^^^^^^^^^^^ meta.implementation.objc +//^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c + +-(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attribute__((objc_direct)) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.function.selector.objc +//^^^^^^^^^ meta.group.c +//^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.c +// ^^^^^^ variable.parameter.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.objc +// ^^ punctuation.section.group.end.c +{ + [super someSelector:param withOther:param2]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^ variable.language.objc +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __block int i = 1; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + __strong NSString* j = [NSString stringWithFormat:@"Hello, World! %@", @314, nil]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.objc +// ^^ punctuation.definition.string.begin.objc +// ^^ constant.other.placeholder.objc +// ^ punctuation.definition.string.end.c +// ^ punctuation.separator.c +// ^ constant.numeric.objc +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ constant.language.null.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __weak NSNumber* k = @'3'; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^ string.quoted.single.c +// ^^ punctuation.definition.string.begin.objc +// ^ punctuation.definition.string.end.c +// ^ punctuation.terminator.c + __autoreleasing NSView* a = [[NSView alloc] init]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^ support.class.cocoa.objc +// ^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + + NSArray* f = @[ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^ meta.protocol-list.objc +// ^ punctuation.section.scope.begin.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ punctuation.section.scope.end.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc + @314.5, +//^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ punctuation.separator.c + @0x314LL, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^ punctuation.separator.c + @0314e10, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + @0b1010u +//^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + ]; +//^^^^ meta.implementation.objc meta.block.c +//^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c + + NSDictionary* g = @{ +//^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^ meta.mapping.objc punctuation.section.mapping.begin.objc + (__bridge id)kValue1 : (__bridge NSViewController)kValue2, +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^^^^^ support.class.cocoa.leopard.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ punctuation.separator.c + (__bridge NSWindow)kValue3 : @YES +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^ constant.language.boolean.true.objc + }; +//^^^^ meta.implementation.objc meta.block.c +//^^^ meta.mapping.objc +// ^ punctuation.section.mapping.end +// ^ punctuation.terminator.c + + [g respondsToSelector:@selector(doSomething:withSomething:)]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.objc +// ^^^^^^^^^ keyword.operator.word.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.method-name.objc support.function.objc +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.brackets.end.objc + if (@available(iOS 10.4, macOS 11.3, *)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.available.objc +// ^^^^^^^^^^ keyword.operator.word.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^^^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + [[[g allValues] objectAtIndex: 1] +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.objc + perform: @encode(int) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ keyword.operator.word.objc +// ^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ punctuation.section.group.end + with: @NO +//^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^ constant.language.boolean.false.objc + ]; +//^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } +//^^^ meta.implementation.objc meta.block.c meta.block.c +// ^ punctuation.section.block.end + + return [NSClassFromString([NSString stringWithUTF8String:self.j.UTF8String]) someSelector:^(__contravariant NSObject* a, __covariant int const* b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^ support.function.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^ variable.language.objc +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.function.block.objc keyword.operator.bitwise.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.objc + @try { +//^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +// ^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + [Nil message: (a + b) ? @true : @false]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^ constant.language.null.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ keyword.operator.ternary.c +// ^^^^^ constant.language.boolean.true.objc +// ^ keyword.operator.ternary.c +// ^^^^^^ constant.language.boolean.false.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } @catch(NSException* exc) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^^ keyword.control.exception.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^^^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin + return NO; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^ constant.language.boolean.false.objc +// ^ punctuation.terminator.c + } @finally { +//^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + return YES; +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^ constant.language.boolean.true.objc +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + }]; +//^^^^^ meta.implementation.objc meta.block.c +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c +} +@end +//^^ meta.implementation.objc keyword.declaration.interface.end.objc +//^^ meta.implementation.objc keyword.declaration.interface.end.objc