diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 384ff773c0..1cdc5146b0 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -37,20 +37,26 @@ variables: identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars + attr_macro_identifier: \b__[[:alnum:]_]{2,}\b # __aligned, __pci_driver + common_identifier: '\b[[:lower:]]{1,4}\b|\bstate\b' # host, dev, i, port, attr, buf, args 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|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' 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' declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|extern|register|{{declspec}}' + storage_classes: 'static|extern|register' type_qualifier: 'const|volatile' compiler_directive: 'inline|restrict|__restrict__|__restrict' modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}' non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__' contexts: + or_pop: + # Pop if nothing matched (whitespace is ignored). + - match: '(?=\S)' + pop: true + main: - include: preprocessor-global - include: global @@ -157,6 +163,39 @@ contexts: - match: \b({{modifiers}})\b scope: storage.modifier.c + modifiers-macros: + # Preprocessor Attributes with parameters. + # We only support a very limited definition so it doesn't gobble up + # actual function definitions. + - match: |- + (?x: + (?:{{macro_identifier}}|{{attr_macro_identifier}}) + (?= + \( + \s* + (?: + (?: + 0[xX][[:xdigit:]]+ | + \d+ | + sizeof\([^\)]*\) | + {{macro_identifier}} + ) + \s* + (?:,\s*|(?=\))) + )+ + \) + ) + ) + scope: constant.other.macro.c + push: + - meta_scope: meta.function-call.c + - include: function-call-params + # Preprocessor Attributes + - match: '{{attr_macro_identifier}}(?!\s*\()' + scope: constant.other.macro.c + - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*|\)|\s*\n)' + scope: constant.other.macro.c + variables: - match: '\bg[A-Z]\w*\b' scope: variable.other.readwrite.global.mac-classic.c @@ -179,8 +218,7 @@ contexts: scope: support.function.C99.c types: - - match: \b({{before_tag}})\b - scope: keyword.declaration.c + - include: data-structures - 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|clock_t|size_t|ssize_t|time_t|useconds_t|suseconds_t|ptrdiff_t)\b @@ -311,12 +349,16 @@ contexts: scope: invalid.illegal.syntax.c access: - - match: '(\.)({{identifier}})(?!\s*\()' + - match: '(\.|->)({{common_identifier}})(?!\s*\()' captures: 1: punctuation.accessor.c 2: variable.other.member.c + - match: '(\.|->)({{identifier}})(?!\s*\()' + captures: + 1: punctuation.accessor.c + 2: variable.other.member.indexed.c - include: access-illegal - - match: \.(?!\.) + - match: \.(?!\.|\d) scope: punctuation.accessor.c label: @@ -395,8 +437,15 @@ contexts: global: - include: early-expressions - - match: '^\s*(?=\w+)' - push: global-modifier + - match: '(?=\w+)' + push: + - include: comments + - include: modifiers-parens + - include: modifiers + # We don't include modifiers-macros because these could be types + # We only want to include the modifiers that don't identify a type. + - include: global-function-call + - include: global-declaration - include: late-expressions statements: @@ -404,14 +453,27 @@ contexts: - include: label - include: expressions + # We can't merge this with the variables scope because it will break the C++ + # syntax. + variables-c: + # There are a lot of common variable names 4 characters or under. + # They cause a lot of noise when indexed. So we skip them. + - match: '{{common_identifier}}' + scope: variable.other.c + - match: '{{identifier}}' + scope: variable.other.indexed.c + expressions: - include: early-expressions - include: late-expressions + - include: macro-identifiers + - include: variables-c early-expressions: - include: preprocessor-expressions - include: comments - include: case-default + - include: access - include: typedef - include: keywords-parens - include: keywords @@ -423,7 +485,6 @@ contexts: - include: block - include: variables - include: constants - - include: access - match: ',' scope: punctuation.separator.c - match: '\)|\}' @@ -433,104 +494,92 @@ contexts: - include: modifiers-parens - include: modifiers - include: types - - include: function-call + - include: function-call-c - 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 - - 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*\() + global-function-call: + - match: (?={{identifier}}\s*\((?!\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 + - - include: comments + - match: ';' + scope: punctuation.terminator.c + pop: true + - match: \n + comments: Macro invocations sometimes don't require a ; to terminate + so we need to treat a new line as a terminiator so we + don't confuse two macro invocations one after another as + a macro invocation followed by a function definition. + pop: true + - match: '(?=\S)' + set: global-declaration + - - include: function-call-params + - - meta_scope: meta.function-call.c + - match: '{{identifier}}' + scope: constant.other.macro.c + pop: true + + global-declaration: - match: '(?=\S)' - pop: true + set: + - variable-identifier-list + - type-declaration 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 - - match: '\bvoid\b' - scope: storage.type.c - - match: '{{identifier}}(?=\s*(\[|,|\)))' - scope: variable.parameter.c - - include: expressions - - include: preprocessor-line-continuation + - include: function-definition-params-group + - include: function-definition-continue - match: (?=\S) pop: true + function-definition-params-group: + - match: \( + scope: punctuation.section.group.begin.c + push: + - meta_scope: meta.function.parameters.c meta.group.c + - include: comments + - match : \) + scope: punctuation.section.group.end.c + pop: true + - match: ',' + scope: punctuation.separator.c + - include: preprocessor-line-continuation + - match: '(?=\S)' + push: + - parameter-identifier + - type-declaration + + parameter-identifier: + - include: comments + - include: modifiers + - include: modifiers-parens + - include: modifiers-macros + - match: \* + scope: storage.modifier.c + # Function pointer declaration + - match: \( + scope: punctuation.section.group.begin.c + push: + - meta_scope: meta.group.c + - match: \) + scope: punctuation.section.parens.end.c + set: + - include: function-definition-params-group + - include: or_pop + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}' + scope: variable.parameter.c + - match: '{{identifier}}' + scope: variable.parameter.c + push: + - include: declaration-brackets + - include: or_pop + - include: or_pop function-definition-continue: - meta_content_scope: meta.function.c @@ -539,153 +588,297 @@ contexts: pop: true - match: \b(const|final|noexcept|override)\b scope: storage.modifier.c - - match: '(?=\{)' - set: function-definition-body + - include: 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 + scope: punctuation.section.block.begin.c set: - - meta_content_scope: meta.function.c meta.block.c + - meta_scope: meta.function.c meta.block.c - match: '\}' - scope: meta.function.c meta.block.c punctuation.section.block.end.c + scope: punctuation.section.block.end.c pop: true - match: (?=^\s*#\s*(elif|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 + - include: struct-keyword + - include: union-keyword + - include: enum-keyword - 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 + macro-identifiers: + - match: '{{macro_identifier}}' + scope: constant.other.macro.c + + parameter-variable-identifier: + - match: \* + scope: storage.modifier.c + # Function pointer declaration as variable + - match: \( + scope: punctuation.section.group.begin.c + push: + - meta_scope: meta.parens.c + - match: \) + scope: punctuation.section.parens.end.c + set: + - include: function-definition-params-group + - include: or_pop + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}' + scope: variable.parameter.c - match: '{{identifier}}' - scope: entity.name.struct.c - set: data-structures-struct-definition-after-name - - include: data-structures-struct-definition-block-start - - match: '(?=;)' + scope: variable.parameter.c + + variable-identifier-list: + - include: comments + - include: modifiers + - include: modifiers-parens + - include: modifiers-macros + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}(?=\s*\(|\s*\n)' + scope: meta.function.c entity.name.function.c + set: + - - include: comments + - include: function-definition-body + - match: '(?=\S)' + set: variable-identifier-list + - - include: comments + - include: modifiers-parens + # Macro invocations + - include: function-call-c + - match: '{{identifier}}' + scope: constant.other.macro.c + - include: or_pop + - - include: comments + - include: function-definition-params-group + - include: or_pop + # Function pointer declaration + - match: \((?=\s*\*) + scope: punctuation.section.group.begin.c + push: + - meta_scope: meta.parens.c + - match: \) + scope: punctuation.section.parens.end.c + set: + - include: function-definition-params-group + - include: or_pop + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}' + scope: entity.name.variable.indexed.c + - match: '{{identifier}}' + scope: entity.name.variable.indexed.c + push: + - include: declaration-brackets + - match: \= + scope: keyword.operator.assignment.c + set: + - match: '(?=,|;)' + pop: true + - include: expressions + - include: or_pop + - include: or_pop + - match: ',' + scope: punctuation.separator.c + - match: ';' + scope: punctuation.terminator.c pop: true + - include: or_pop - data-structures-struct-definition-after-name: - - meta_scope: meta.struct.c - - include: data-structures-definition-common-begin - - match: '(?=;)' + member-variable-identifier-list: + - include: comments + - include: modifiers + - include: modifiers-parens + - include: modifiers-macros + - match: \* + scope: storage.modifier.c + # Function pointer declaration + - match: \( + scope: punctuation.section.group.begin.c + push: + - meta_scope: meta.parens.c + - match: \) + scope: punctuation.section.parens.end.c + set: + - include: function-definition-params-group + - include: or_pop + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}' + scope: entity.name.member.indexed.c + # There are a lot of common variable names 4 characters or under. + # We want to make sure to not index those. + - match: '{{common_identifier}}' + scope: entity.name.member.c + push: + - include: declaration-brackets + - include: or_pop + - match: '{{identifier}}' + scope: entity.name.member.indexed.c + push: + - include: declaration-brackets + - include: or_pop + - match: ',' + scope: punctuation.separator.c + - match: ';' + scope: punctuation.terminator.c pop: true - - include: data-structures-struct-definition-block-start + - include: or_pop - data-structures-struct-definition-block-start: + struct-keyword: + - match: '\bstruct\b' + scope: keyword.declaration.struct.c + push: + - meta_scope: meta.struct.c + - include: data-structures-definition-common-begin + # function name + - match: '(?={{identifier}}\s*\()' + pop: true + # struct definition + - match: '{{identifier}}(?=\s*{|\s*\n)' + scope: entity.name.struct.c + set: struct-body + # struct declaration + - match: '{{identifier}}' + scope: support.type.c + pop: true + # Anonymous struct definition + - match: '(?={)' + set: struct-body + - include: or_pop + struct-body: + - include: comments - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c + scope: punctuation.section.block.begin.c set: - - meta_content_scope: meta.struct.c meta.block.c + - meta_scope: meta.struct.body.c meta.block.c + - include: comments - match: '\}' - scope: meta.struct.c meta.block.c punctuation.section.block.end.c + scope: punctuation.section.block.end.c pop: true - include: data-structures-body + - include: or_pop - 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: + enum-keyword: + - match: '\benum\b' + scope: keyword.declaration.enum.c + push: + - meta_scope: meta.enum.c + - include: data-structures-definition-common-begin + # function name + - match: '(?={{identifier}}\s*\()' + pop: true + # enum definition + - match: '{{identifier}}(?=\s*{|\s*\n)' + scope: entity.name.enum.c + set: enum-body + # enum declaration + - match: '{{identifier}}' + scope: support.type.c + pop: true + # Anonymous enum definition + - match: '(?={)' + set: enum-body + - include: or_pop + enum-body: + - include: comments - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c + scope: 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 + - meta_scope: meta.enum.c meta.block.c + - include: comments - match: '\}' scope: meta.enum.c meta.block.c punctuation.section.block.end.c pop: true - - include: data-structures-body - - 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 + - include: preprocessor-expressions + - match: '{{identifier}}' + scope: entity.name.constant.enum.c + push: + - include: comments + - match: '=' + scope: keyword.operator.assignment.c + set: + - include: comments + # expressions gobbles up the , and } (which it shouldn't) + # so we need to match before so we break out of the scope + # correctly. We need to fix expressions. + - match: '(?=,|})' + pop: true + - include: expressions + - include: or_pop + # No equals + - include: or_pop + - match: ',' + scope: punctuation.separator.c + - include: or_pop - data-structures-union-definition-block-start: + union-keyword: + - match: '\bunion\b' + scope: keyword.declaration.union.c + push: + - meta_scope: meta.union.c + - include: data-structures-definition-common-begin + # function name + - match: '(?={{identifier}}\s*\()' + pop: true + # union definition + - match: '{{identifier}}(?=\s*{|\s*\n)' + scope: entity.name.union.c + set: union-body + # union declaration + - match: '{{identifier}}' + scope: support.type.c + pop: true + # Anonymous union definition + - match: '(?={)' + set: union-body + - include: or_pop + union-body: + - include: comments - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c + scope: punctuation.section.block.begin.c set: - - meta_content_scope: meta.union.c meta.block.c + - meta_scope: meta.union.body.c meta.block.c + - include: comments - match: '\}' - scope: meta.union.c meta.block.c punctuation.section.block.end.c + scope: punctuation.section.block.end.c pop: true - include: data-structures-body + - include: or_pop 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 + - include: modifiers-macros data-structures-body: - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - include: expressions + - include: preprocessor-expressions + - include: modifiers + - include: modifiers-parens + - include: data-structures-body-function-call + - include: data-structures-body-declaration + + data-structures-body-declaration: + - match: '(?=\S)' + push: + - member-variable-identifier-list + - type-declaration + + data-structures-body-function-call: + - match: (?={{identifier}}\s*\((?!\s*\*)) + push: + - - include: function-call-params + - - meta_scope: meta.function-call.c + - match: '{{identifier}}' + scope: constant.other.macro.c + pop: true block: - match: '\{' @@ -719,6 +912,16 @@ contexts: pop: true - include: expressions + declaration-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 @@ -786,14 +989,88 @@ contexts: - 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 + - typedef-identifier-list + - type-declaration + type-declaration: + - include: comments + - include: modifiers + # Used for typedefing things defined in types. + - match: (?={{identifier}};) + pop: true + - include: modifiers-macros + - include: modifiers-parens + # There could be modifiers before typedef + - match: \btypedef\b + scope: storage.type.c + set: + - typedef-identifier-list + - type-declaration + # Make sure to pop when a data structure keyword is found + - match: (?=\bstruct\b) + set: + - include: struct-keyword + - include: or_pop + - match: (?=\benum\b) + set: + - include: enum-keyword + - include: or_pop + - match: (?=\bunion\b) + set: + - include: union-keyword + - include: or_pop + - include: types + - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*) + captures: + 1: support.type.c + - include: or_pop + typedef-identifier-list: + - include: comments + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}(?=\s*;)' + scope: entity.name.type.typedef.c + pop: true + - match: '{{identifier}}(?=\s*,)' + scope: entity.name.type.typedef.c + - match: '{{identifier}}(?=\s*\[)' + scope: entity.name.type.typedef.c + push: + - include: declaration-brackets + - include: or_pop + # Function pointers + - match: '\((?=\s*\*)' + scope: punctuation.section.group.begin.c + set: + - meta_scope: meta.parens.c + - match: \) + scope: punctuation.section.parens.end.c + set: + - include: function-definition-params-group + - include: or_pop + - match: \* + scope: storage.modifier.c + - match: '{{identifier}}' + scope: entity.name.type.c + - include: or_pop + - match: \, + scope: punctuation.separator.c + - match: \; + scope: punctuation.terminator.c + pop: true + - include: or_pop + + # Scope used only by the c syntax + function-call-c: + - match: (?=(?:{{macro_identifier}}|{{attr_macro_identifier}})\s*\() + push: + - meta_content_scope: meta.function-call.c + - include: c99 + - match: '{{identifier}}' + scope: constant.other.macro.c + - include: function-call-params + - include: function-call + # This is used by other syntaxes function-call: - match: (?={{identifier}}\s*\() push: @@ -801,14 +1078,22 @@ contexts: - 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 + - include: function-call-params + function-call-params: + - match: '\(' + scope: punctuation.section.group.begin.c + set: + - meta_scope: meta.function-call.parameters.c meta.group.c + - match : \) + scope: punctuation.section.group.end.c + pop: true + # - include: macro-identifiers + - match: '{{macro_identifier}}(?!\()' + scope: constant.other.macro.c + - include: expressions + # Inside macro params, the identifiers can start with numbers + - match: '\b\w+\b' + scope: variable.other.c ## Preprocessor for data-structures @@ -942,6 +1227,7 @@ contexts: - include: preprocessor-comments - match: \bdefined\b scope: keyword.control.c + - include: macro-identifiers # Enter a new scope where all elif/else branches have their # contexts popped by a subsequent elif/else/endif. This ensures that # preprocessor branches don't push multiple meta.block scopes on @@ -1276,11 +1562,13 @@ contexts: 1: keyword.control.import.c push: - meta_scope: meta.preprocessor.c + - meta_include_prototype: false - include: preprocessor-line-continuation - include: preprocessor-line-ending - include: preprocessor-comments - match: \bdefined\b scope: keyword.control.c + - include: macro-identifiers - match: ^\s*(#\s*endif)\b captures: 1: meta.preprocessor.c keyword.control.import.c @@ -1317,4 +1605,3 @@ contexts: - match: ">" scope: punctuation.definition.string.end.c pop: true - - include: preprocessor-practical-workarounds diff --git a/C++/Indexed Reference List.tmPreferences b/C++/Indexed Reference List.tmPreferences new file mode 100644 index 0000000000..214727ab80 --- /dev/null +++ b/C++/Indexed Reference List.tmPreferences @@ -0,0 +1,18 @@ + + + + + scope + + source.c constant.other.macro.c, + source.c support.type.c, + source.c variable.other.indexed.c, + source.c variable.other.member.indexed.c + + settings + + showInIndexedReferenceList + 1 + + + diff --git a/C++/Symbol List.tmPreferences b/C++/Symbol List.tmPreferences index f450797df8..9fb412d1ea 100644 --- a/C++/Symbol List.tmPreferences +++ b/C++/Symbol List.tmPreferences @@ -2,7 +2,7 @@ scope - + settings showInSymbolList diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 95c8291333..d59be715ef 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -15,6 +15,14 @@ enum FOO do_the_foo(void); /* ^ entity.name.function */ /* ^ storage.type */ +struct FOO do_the_foo(void); +/* ^ entity.name.function */ +/* ^ storage.type */ + +union 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; }; @@ -25,10 +33,6 @@ 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 { @@ -41,12 +45,14 @@ struct foo { /* ^ 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.declaration.struct.c */ +/* ^ support.type */ /* <- keyword.control.import.define */ /* ^ entity.name.constant.preprocessor */ /* ^ comment.block */ @@ -90,7 +96,7 @@ int i; // The following example ensures that comments at the end of preprocessor // directives don't mess with context transitions int func() { -/* ^^^^^^^^ meta.function */ +/* ^^^^^^ meta.function */ /* ^^ meta.function.parameters */ /* ^ meta.block punctuation.section.block.begin */ /* ^ entity.name.function */ @@ -103,6 +109,12 @@ int func() { /* ^ comment.line */ #endif /* ^ keyword.control.import */ + + print("// String"); +/*^^^^^ meta.function-call.c variable.function.c */ +/* ^^^^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ } /* <- meta.function meta.block punctuation.section.block.end */ /* <- - meta.function meta.block */ @@ -141,9 +153,17 @@ int f(int x, \ /* <- keyword.control.import.define */ /* ^ entity.name.constant */ -bool still_C_code_here = true; +bool still_C_code_here = true, foo = false; /* <- storage.type */ +/* ^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ keyword.operator.assignment.c */ /* ^ constant.language */ +/* ^ punctuation.terminator.c */ +/* ^ punctuation.separator.c */ +/* ^^^ entity.name.variable.indexed.c*/ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^ constant.language.c */ +/* ^ punctuation.terminator.c */ FOOBAR hello() { @@ -168,20 +188,26 @@ UserStructCompare ( } LIB_RESULT +/* <- constant.other.macro.c */ foo() /* <- meta.function entity.name.function */ { +/* <- meta.function.c punctuation.section.block.begin.c */ return LIB_SUCCESS; } +/* <- meta.function.c punctuation.section.block.end.c */ LIB_RESULT bar() +/* <- constant.other.macro.c */ /* ^ meta.function entity.name.function */ { +/* <- meta.function.c punctuation.section.block.begin.c */ return LIB_SUCCESS; } +/* <- meta.function.c punctuation.section.block.end.c */ THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ +/* <- constant.other.macro.c */ int main() { /* <- storage.type */ @@ -189,6 +215,10 @@ int main() { return 0; } +void __sdhci_read_caps(struct sdhci_host *host, u16 *ver); +/* <- storage.type.c */ +/* ^^^^^^^^^^^^^^^^^ meta.function entity.name.function */ + #if 0 #ifdef moo /* <- - keyword.control @@ -242,34 +272,46 @@ int disabled_func() { #endif FOO -/* <- meta.assumed-macro */ +/* <- constant.other.macro.c */ FOO; -/* <- - meta.assumed-macro */ +/* <- entity.name.variable.indexed.c */ foo -/* <- - meta.assumed-macro */ +/* <- support.type */ ; // fix highlighting /* <- punctuation.terminator */ FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ +/* <- meta.function-call.c constant.other.macro.c */ FOO(); -/* <- - meta.assumed-macro */ +/* <- meta.function-call.c constant.other.macro.c */ foo() -/* <- - meta.assumed-macro */ +/* <- meta.function-call.c constant.other.macro.c */ ; // fix highlighting /* <- punctuation.terminator */ struct X { +/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ ENABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ + /* <- meta.function-call.c constant.other.macro.c */ int foo; /* <- storage.type */ +/* ^^^ entity.name.member.c */ DISABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ + /* <- meta.function-call.c constant.other.macro.c */ float bar; /* <- storage.type */ +/* ^^^ entity.name.member.c */ +/* ^ punctuation.terminator.c */ + + EXPORT(int) baz; +/* ^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^ meta.function-call.parameters.c */ +/* ^^^ entity.name.member.c */ +/* ^ punctuation.terminator.c */ }; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ + /* <- punctuation.terminator.c - meta.struct.body.c - meta.block.c*/ /** * @@ -298,15 +340,38 @@ if (4) { ///////////////////////////////////////////// typedef int myint; -/* <- keyword.declaration */ +/* <- keyword.declaration.type.c */ +/* ^^^ storage.type.c */ /* ^ entity.name.type */ +/* ^ punctuation.terminator.c */ + +typedef unsigned long long ull_t, +/* <- keyword.declaration.type.c */ +/* ^^^^^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.separator.c */ + ull2_t, +/* ^^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.separator.c */ + *ullp_t; +/* ^ storage.modifier.c */ +/* ^^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ typedef struct mystruct { -/* <- keyword.declaration */ -/* ^ keyword.declaration.struct.c */ +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ /* ^ entity.name.struct.c */ +/* ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ + int a; +/*^^^ storage.type.c */ +/* ^ entity.name.member.c */ } mystruct; -/* ^ entity.name.type.typedef.c */ +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ +/*^^^^^^^^ entity.name.type */ +/* ^ punctuation.terminator.c */ typedef struct MyStructure {} MyStructure_t; /* <- keyword.declaration.type.c */ @@ -316,106 +381,1483 @@ typedef struct MyStructure {} MyStructure_t; /* ^ punctuation.section.block.end.c */ /* ^^^^^^^^^^^^^ entity.name.type.typedef.c */ +typedef struct another +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ entity.name.struct.c */ +{ +/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ + int f; +/*^^^ storage.type.c */ +/* ^ entity.name.member.c */ +} another_t, another2_t; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ +/*^^^^^^^^^ entity.name.type */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ + +typedef another_t another2_t; +/* <- keyword.declaration.type.c */ +/* ^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ + +typedef another_t *anotherp_t; +/* <- keyword.declaration.type.c */ +/* ^^^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ + +typedef void (*xhci_get_quirks_t)(struct device *d, struct xhci_hcd *); +/* <- keyword.declaration.type.c */ +/* ^^^^ storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^ entity.name.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^ variable.parameter.c */ +/* ^ punctuation.separator */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ + +typedef struct Node* (*get_node_t)(struct device *d, struct xhci_hcd *); +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^ entity.name.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^ variable.parameter.c */ +/* ^ punctuation.separator */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ + + +typedef struct Node Node; +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^ support.type.c */ +/* ^^^^ entity.name.type.typedef.c */ +typedef struct Node* NodePtr; +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^ entity.name.type.typedef.c */ + +typedef struct { +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ meta.struct.body.c punctuation.section.block.begin.c */ + int data1; +/* ^^^ storage.type.c */ +/* ^^^^^ entity.name.member.indexed.c */ +} newtype; +/* <- meta.struct.body.c punctuation.section.block.end.c */ +/*^^^^^^^ entity.name.type.typedef.c */ + +typedef struct MyStruct { +/* <- keyword.declaration.type.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ entity.name.struct.c */ +/* ^ meta.struct.body.c punctuation.section.block.begin.c */ + int data1; +/* ^^^ storage.type.c */ +/* ^^^^^ entity.name.member.indexed.c */ +} newtype; +/* <- meta.struct.body.c punctuation.section.block.end.c */ +/*^^^^^^^ entity.name.type.typedef.c */ + +typedef char arrType[6]; +/* <- keyword.declaration.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^ entity.name.type */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.section.brackets.end.c */ + +typedef char arrType[NUMBER_OF_ELEMENTS]; +/* <- keyword.declaration.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^^^^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.section.brackets.end.c */ + +typedef unsigned long ulong, *ulongptr; +/* <- keyword.declaration.type.c */ +/* ^^^^^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.separator.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^ entity.name.type.typedef.c */ + +typedef enum state {DEAD,ALIVE} State; +/* <- keyword.declaration.type.c */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^^^^^ entity.name.enum.c */ +/* ^^^^ entity.name.constant.enum.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^ entity.name.constant.enum.c */ +/* ^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ + + +typedef __u8 u_int8_t; +/* <- keyword.declaration.type.c */ +/* ^^^^ constant.other.macro.c */ +/* ^^^^^^^^ entity.name.type.typedef.c */ +typedef __s8 int8_t; +/* <- keyword.declaration.type.c */ +/* ^^^^ constant.other.macro.c */ +/* ^^^^^^ entity.name.type.typedef.c */ + +typedef unsigned long long __u64; +/* <- keyword.declaration.type.c */ +/* ^^^^^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ + +__extension__ typedef unsigned long long __u64; +/* <- constant.other.macro.c */ +/* ^^^^^^^ storage.type.c */ +/* ^^^^^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ + +///////////////////////////////////////////// +// Parameter Declarations +///////////////////////////////////////////// + +typedef void (*attrs_t)( +/* <- keyword.declaration.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^ entity.name.type.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */ + const __aligned(4) char __aligned(8) * __aligned(2) bob __aligned(2), +/*^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^^^ variable.parameter.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^ punctuation.separator.c */ + + __unused char foo, +/*^^^^^^^^ constant.other.macro.c */ +/* ^^^^ storage.type.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + volatile MACRO foo, +/*^^^^^^^^ storage.modifier.c */ +/* ^^^^^ constant.other.macro.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + MACRO int MACRO bar, +/*^^^^^ constant.other.macro.c */ +/* ^^^ storage.type.c */ +/* ^^^^^ constant.other.macro.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + FOO(BAR) bar, +/*^^^^^^^^ meta.function-call */ +/* ^^^ constant.other.macro.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + const char foo __attribute__((unused)), +/*^^^^^ storage.modifier.c */ +/* ^^^^ storage.type.c */ +/* ^^^ - variable.parameter.c This is broken :( */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^ punctuation.separator.c */ + __attribute__((unused)) char foo1, +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + char __attribute__((unused)) foo2); +/*^^^^ storage.type.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^ variable.parameter.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ + +void attrs( +/* <- storage.type.c */ +/* ^^^^^ entity.name.function.c */ + const __aligned(4) char __aligned(8) * __aligned(2) bob __aligned(2), +/*^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^^^ variable.parameter.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^ punctuation.separator.c */ + + __unused char foo, +/*^^^^^^^^ constant.other.macro.c */ +/* ^^^^ storage.type.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + volatile MACRO foo, +/*^^^^^^^^ storage.modifier.c */ +/* ^^^^^ constant.other.macro.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + MACRO int MACRO bar, +/*^^^^^ constant.other.macro.c */ +/* ^^^ storage.type.c */ +/* ^^^^^ constant.other.macro.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + FOO(BAR) bar, +/*^^^^^^^^ meta.function-call */ +/* ^^^ constant.other.macro.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + const char foo __attribute__((unused)), +/*^^^^^ storage.modifier.c */ +/* ^^^^ storage.type.c */ +/* ^^^ - variable.parameter.c This is broken :( */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^ punctuation.separator.c */ + __attribute__((unused)) char foo1, +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + char __attribute__((unused)) foo2); +/*^^^^ storage.type.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^ variable.parameter.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ + +void proto(int, char*, char, struct foobar); +/* <- storage.type.c */ +/* ^^^^^ entity.name.function.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ storage.type.c */ +/* ^ storage.modifier.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ storage.type.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^ support.type.c */ +/* ^ punctuation.terminator.c */ + +static string foo(__bar); +/* ^^^^^ constant.other.macro.c */ +static string foo(BAR); +/* ^^^ constant.other.macro.c */ +static string foo(FOO(1)); +/* ^^^^^^ meta.function-call */ +static string foo(__align(1)); +/* ^^^^^^^^^^ meta.function-call */ +static string foo(__attribute__((unused))); +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ + + __unused char foo; +/*^^^^^^^^ constant.other.macro.c */ +/* ^^^^ storage.type.c */ +/* ^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + volatile MACRO foo; +/*^^^^^^^^ storage.modifier.c */ +/* ^^^^^ constant.other.macro.c */ +/* ^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + MACRO int MACRO bar; +/*^^^^^ constant.other.macro.c */ +/* ^^^ storage.type.c */ +/* ^^^^^ constant.other.macro.c */ +/* ^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + ///////////////////////////////////////////// // Data structures and return values ///////////////////////////////////////////// struct point -/* ^ keyword.declaration */ +/* ^ keyword.declaration.struct.c */ /* ^ entity.name.struct */ { +/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ int x; int y; -} +}; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ struct point2 { -/* ^ keyword.declaration */ +/* ^ keyword.declaration.struct.c */ /* ^ entity.name.struct */ +/* ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ int x; int y; -} +}; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ int main(void) { /* ^^^^ entity.name.function */ /* ^^^^ storage.type */ } +enum codes get_code() {} +/* <- keyword.declaration.enum.c */ +/* ^ support.type - entity.name.struct */ +/* ^^^^^^^^^ meta.function */ +/* ^ entity.name.function */ +/* ^^ meta.function.parameters */ +/* ^^ meta.function meta.block */ +/* ^ punctuation.section.block.begin */ +/* ^ punctuation.section.block.end */ + +union codes get_code() {} +/* <- keyword.declaration.union.c */ +/* ^ support.type - entity.name.struct */ +/* ^^^^^^^^^ meta.function */ +/* ^ entity.name.function */ +/* ^^ meta.function.parameters */ +/* ^^ meta.function meta.block */ +/* ^ punctuation.section.block.begin */ +/* ^ punctuation.section.block.end */ + struct point get_point() {} -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin -/* ^ punctuation.section.block.end -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ +/* <- keyword.declaration.struct.c */ +/* ^ support.type - entity.name.struct */ +/* ^^^^^^^^^ meta.function */ /* ^ entity.name.function */ - -struct point **alloc_points(); -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ +/* ^^ meta.function.parameters */ +/* ^^ meta.function meta.block */ +/* ^ punctuation.section.block.begin */ +/* ^ punctuation.section.block.end */ + +EXPORT_SYMBOL(get_point); +/* <- meta.function-call.c constant.other.macro.c*/ +/* ^^^^^^^^^ variable.other.indexed.c */ + +inline struct point **alloc_points(); +/* ^ keyword.declaration.struct.c */ +/* ^ support.type - entity.name.struct */ +/* ^^ storage.modifier.c */ +/* ^ entity.name.function */ +/* ^^ meta.function.parameters.c meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ +EXPORT_SYMBOL(alloc_points); +/* <- meta.function-call.c constant.other.macro.c*/ +/* ^^^^^^^^^^^^ variable.other.indexed.c */ struct point* alloc_point(); +/* <- keyword.declaration.struct.c */ +/* ^^^^^ meta.struct.c support.type.c */ +/* ^ storage.modifier.c */ /* ^ entity.name.function - variable.function */ - -struct point FOO_API *alloc_point3(); +/* ^^ meta.function.parameters.c meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + +struct point FOO_API *alloc_point3(), alloc_point2(), struct_var2; +/* <- keyword.declaration.struct.c */ +/* ^^^^^ meta.struct.c support.type.c */ +/* ^ storage.modifier.c */ /* ^ entity.name.function - variable.function */ +/* ^^ meta.function.parameters.c meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ punctuation.separator */ +/* ^ entity.name.function - variable.function */ +/* ^^^^^^^^^^^ entity.name.variable.indexed.c */ + +struct { +/* <- keyword.declaration.struct.c */ +/* ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ + int a; +/*^^^ storage.type.c */ +/* ^ entity.name.member.c */ +} anon_s, *anon_b, anon_s_f(), anon_c = { +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ +/*^^^^^^ entity.name.variable.indexed.c */ +/* ^^^^^^ entity.name.variable.indexed.c */ +/* ^^^^^^^^ entity.name.function.c */ +/* ^^^^^^ entity.name.variable.indexed.c */ +/* ^ keyword.operator.assignment.c */ + .a = 4 +}, anon_d = {.a = 6}, anon_arr[] = {{.a = 1}, {.a = 2}}, anon_g; + /* <- punctuation.separator */ +/* ^^^^^^ entity.name.variable.indexed.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ punctuation.separator */ +/* ^^^^^^^^ entity.name.variable.indexed.c */ +/* ^^ meta.brackets.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^ punctuation.section.brackets.end.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ punctuation.separator */ +/* ^^^^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +int f_with_s(struct { int a; } *s); +/*<- storage.type.c */ +/* ^^^^^^^^ meta.function.c entity.name.function.c */ +/* ^ meta.function.parameters.c punctuation.section.group.begin.c */ +/* ^^^^^^ meta.struct.c keyword.declaration.struct.c */ +/* ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ +/* ^^^ storage.type.c */ +/* ^ entity.name.member.c */ +/* ^ meta.struct.body.c meta.block.c punctuation.section.block.end.c */ +/* ^ storage.modifier.c */ +/* ^ variable.parameter.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + +TRACE_EVENT(mmc_request_start, +/* <- meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ + TP_PROTO(struct mmc_host *host, struct mmc_request *mrq) +/*^^^^^^^^ constant.other.macro.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ support.type.c */ +/* ^ keyword.operator.c */ +/* ^^^^ variable.other.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^ support.type.c */ +/* ^ keyword.operator.c */ +/* ^^^ variable.other.c */ +); + +TRACE_EVENT(802154_rdev_add_virtual_intf, +/* <-meta.function-call.c constant.other.macro.c */ +/* ^ meta.function-call.parameters.c punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable.other.c TODO: Figure this out */ +/* ^ punctuation.separator.c */ + TP_STRUCT__entry( +/*^^^^^^^^^^^^^^^^ meta.function-call.parameters.c meta.function-call.c variable.function.c */ +/* ^ meta.function-call.parameters.c meta.function-call.parameters.c meta.group.c punctuation.section.group.begin.c */ + WPAN_PHY_ENTRY +/* ^^^^^^^^^^^^^^ constant.other.macro.c */ + __string(vir_intf_name, name ? name : "") +/* ^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ variable.other.c */ +/* ^ keyword.operator.ternary.c */ +/* ^^^^ variable.other.c */ +/* ^ keyword.operator.ternary.c */ +/* ^^^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.section.group.end.c */ + __field(enum nl802154_iftype, type) +/* ^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^^^^^^^^^^^^^^^ support.type.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ variable.other.c */ +/* ^ punctuation.section.group.end.c */ + __field(__le64, extended_addr) +/* ^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.section.group.end.c */ + ), +/*^ meta.function-call.parameters.c meta.function-call.parameters.c meta.group.c punctuation.section.group.end.c */ +/* ^ punctuation.separator.c */ + TP_fast_assign( +/*^^^^^^^^^^^^^^ variable.function.c */ +/* ^ meta.function-call.parameters.c meta.function-call.parameters.c punctuation.section.group.begin.c */ + WPAN_PHY_ASSIGN; +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ + __assign_str(vir_intf_name, name ? name : ""); +/* ^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^ meta.function-call.parameters.c punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ variable.other.c */ +/* ^ keyword.operator.ternary.c */ +/* ^^^^ variable.other.c */ +/* ^ keyword.operator.ternary.c */ +/* ^^^^^^^^^^ string.quoted.double.c */ +/* ^ meta.function-call.parameters.c punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + __entry->type = type; +/* ^^^^^^^ variable.other.indexed.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^^ variable.other.member.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^ variable.other.c */ +/* ^ punctuation.terminator.c */ + ), +/*^ meta.function-call.parameters.c meta.function-call.parameters.c punctuation.section.group.end.c */ +/* ^ punctuation.separator.c */ + TP_printk(WPAN_PHY_PR_FMT ", name: %s, type: %d, addr: 0x%llx", +/*^^^^^^^^^ meta.function-call.c variable.function.c */ +/* ^ meta.function-call.parameters.c meta.function-call.parameters.c punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/ +/* ^ punctuation.separator.c */ + WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type, +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^ variable.other.indexed.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^^ variable.other.member.c */ +/* ^ punctuation.separator.c */ + __le64_to_cpu(__entry->extended_addr)) +/* ^^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^ variable.other.indexed.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^^^^^^^^^^^ variable.other.member.indexed.c */ +/* ^ meta.function-call.parameters.c meta.group.c punctuation.section.group.end.c */ +/* ^ meta.function-call.parameters.c meta.group.c punctuation.section.group.end.c */ +); +/* <- meta.function-call.parameters.c meta.group.c punctuation.section.group.end.c */ + /* <- punctuation.terminator.c */ + +static DEFINE_SPINLOCK(my_lock); +/* <- storage.modifier.c */ +/* ^^^^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^ meta.function-call.parameters.c */ +/* ^^^^^^^ variable.other.indexed.c */ + +MACRO_CALL_NO_SEMI( +/* <- meta.function-call.c constant.other.macro.c */ +/* ^ meta.function-call.parameters.c punctuation.section.group.begin.c */ + __with_complex_params(34) +/*^ meta.function-call.c constant.other.macro.c */ +/* ^^^^ meta.function-call.parameters.c */ +) +/* <- meta.function-call.parameters.c punctuation.section.group.end.c */ + +MACRO_CALL_NO_SEMI( +/* <- meta.function-call.c constant.other.macro.c */ +/* ^ meta.function-call.parameters.c punctuation.section.group.begin.c */ + __with_complex_params(34) +/*^ meta.function-call.c constant.other.macro.c */ +/* ^^^^ meta.function-call.parameters.c */ +) +/* <- meta.function-call.parameters.c punctuation.section.group.end.c */ + +SHOW(temp0, temp0) /* a comment */ +/* <- meta.function-call.c constant.other.macro.c */ +/* ^^^^ variable.other.indexed.c */ +/* ^^^^^ variable.other.indexed.c */ +/* ^^^^^^^^^^^^^^^ comment.block.c */ +SHOW(temp1, temp1) /* a comment */ +/* <- meta.function-call.c constant.other.macro.c */ +/* ^^^^ variable.other.indexed.c */ +/* ^^^^^ variable.other.indexed.c */ +/* ^^^^^^^^^^^^^^^ comment.block.c */ + +static inline u64 xhci_read_64(const struct xhci_hcd *xhci, +/*<- storage.modifier.c */ +/* ^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^ entity.name.function.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + __le64 __iomem *regs); +/* ^^^^^^ constant.other.macro.c */ +/* ^^^^^^^ constant.other.macro.c */ +/* ^ storage.modifier.c */ +/* ^^^^ variable.parameter.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ int main(void) { struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type - entity.name */ } -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ +struct MACRO foo { +/* <- keyword.declaration.struct.c */ +/* ^ constant.other.macro */ +/* ^ entity.name.struct */ } +struct UI_BoundingBox position; +/* ^ support.type.c - entity.name */ +/* ^ entity.name.variable.indexed.c */ + +struct UI_BoundingBox *position_p; +/* ^ support.type.c - entity.name */ +/* ^ entity.name.variable.indexed.c */ + +struct UI_BoundingBox * position_p1; +/* ^ support.type.c - entity.name */ +/* ^ entity.name.variable.indexed.c */ + +struct UI_BoundingBox **position_p2; +/* ^ support.type.c - entity.name */ +/* ^ entity.name.variable.indexed.c */ + +struct UI_BoundingBox ** position_p3; +/* ^ support.type.c - entity.name */ +/* ^ entity.name.variable.indexed.c */ + + +struct UI_BoundingBox ** position_p4, position_p5, * position_p6; +/* ^ support.type.c - entity.name */ +/* ^ entity.name.variable.indexed.c */ +/* ^^ storage.modifier.c */ +/* ^ punctuation.separator */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ + // Partially-typed struct foo /* ^ entity.name */ struct UI_MenuBoxData -/* <- keyword.declaration */ +/* <- keyword.declaration.struct.c */ /* ^ entity.name.struct */ { +/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox *position_p; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox * position_p1; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox **position_p2; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox ** position_p3; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox* position_p4; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox** position_p5; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox * * position_p5; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct UI_BoundingBox *pos_1, *pos_1; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + + const volatile struct UI_BoundingBox *cv_p; +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + long resume_done[USB_MAXCHILDREN]; +/* ^^^^ storage.type.c */ +/* ^^^^^^^^^^^ entity.name.member.indexed.c */ +/* ^^^^^^^^^^^^^^^^^ meta.brackets.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.section.brackets.end.c */ +/* ^ punctuation.terminator.c */ + struct xhci_run_regs __iomem *run_regs; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ constant.other.macro.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct xhci_run_regs __attribute__((noderef)) *run_regs; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct __attribute__((noderef)) xhci_run_regs *run_regs; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity.name */ +/* ^ storage.modifier.c */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + struct nested_t { +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ entity.name.struct.c */ +/* ^ meta.struct.body.c meta.block.c meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ + int bar; +/* ^^^ storage.type.c */ +/* ^^^ entity.name.member.c */ + } nested; +/* ^ meta.struct.body.c meta.block.c meta.struct.body.c meta.block.c punctuation.section.block.end.c */ +/* ^^^^^^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + +#define CMD_RING_STATE_RUNNING (1 << 0) +/* <- meta.preprocessor.macro.c keyword.control.import.define.c */ +/* ^ meta.preprocessor.macro.c entity.name.constant.preprocessor.c */ + enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^^^^^^^^^^^^^^ support.type.c - entity.name */ +/* ^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ unsigned int paddingX; +/* ^^^^^^^^ storage.type.c */ +/* ^^^ storage.type.c */ +/* ^^^^^^^^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ unsigned int paddingY; +/* ^^^^^^^^ storage.type.c */ +/* ^^^ storage.type.c */ +/* ^^^^^^^^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^^^ entity.name.member.indexed.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^ punctuation.section.brackets.end.c */ +/* ^ punctuation.terminator.c */ + + struct delayed_work monitor_work ____cacheline_aligned_in_smp; +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^^^^ entity.name.member.indexed.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.terminator.c */ + const struct efx_channel_type * +/* ^^^^^storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^^^ support.type - entity.name */ +/* ^ storage.modifier.c */ + extra_channel_type[EFX_MAX_EXTRA_CHANNELS]; +/* ^^^^^^^^^^^^^^^^^^ entity.name.member.indexed.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^ punctuation.section.brackets.end.c */ + +#if 0 + struct UI_BoundingBox bb1; +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.preprocessor.if-branch.c */ +#else + struct UI_BoundingBox bb1; +#endif +}; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ + +#define CMD_RING_STATE_RUNNING (1 << 0) +/* <- meta.preprocessor.macro.c keyword.control.import.define.c */ +/* ^ meta.preprocessor.macro.c entity.name.constant.preprocessor.c */ + +struct __attribute__((packed)) child_t { +/* <- keyword.declaration.struct.c */ +/* ^ meta.attribute.c storage.modifier.c */ +/* ^^^^^^^ entity.name.struct */ + int foo; +/* ^^^ storage.type.c */ +/* ^^^ entity.name.member.c */ }; +struct child_t child1; + +struct __attribute__((packed)) child_t_line +/* <- keyword.declaration.struct.c */ +/* ^ meta.attribute.c storage.modifier.c */ +/* ^^^^^^^ entity.name.struct */ +{ + int foo; +/* ^^^ storage.type.c */ +/* ^^^ entity.name.member.c */ +}; + +struct __attribute__((packed)) +/* <- keyword.declaration.struct.c */ +/* ^ meta.attribute.c storage.modifier.c */ +{ +/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ + int foo; +/* ^^^ storage.type.c */ +/* ^^^ entity.name.member.c */ +}; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ + +struct rproc_ops { +/* <- keyword.declaration.struct.c */ +/* ^ entity.name.struct */ +/* ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */ + int (*start)(struct rproc *rproc); +/* ^^^ storage.type.c */ +/* ^^^^^ entity.name.member.indexed.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^^^^^ variable.parameter.c */ + int (*start)(struct rproc *); +/* ^^^ storage.type.c */ +/* ^^^^^ entity.name.member.indexed.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ + u32 (*start)(struct rproc *, struct rproc *); +/* ^^^ support.type.c */ +/* ^^^^^ entity.name.member.indexed.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ + void * (*da_to_va)(struct rproc *rproc, u64 da, int len); +/* ^^^ storage.type.c */ +/* ^^^^^^^^ entity.name.member.indexed.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^^^^^ variable.parameter.c */ +/* ^^^ support.type */ +/* ^^ variable.parameter */ +/* ^^^ storage.type */ +/* ^^^ variable.parameter */ + struct resource_table *(*find_loaded_rsc_table)( +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^^^^^^^^^^^^^ entity.name.member.indexed.c */ + struct rproc *rproc, const struct firmware *fw); +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^ variable.parameter.c */ +/* ^ punctuation.separator */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ support.type.c */ +/* ^^ variable.parameter.c */ +}; +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ + +void * (*da_to_va)(struct rproc *rproc, u64 da, int len); +/* <- storage.type.c */ +/* ^^^^^^^^ entity.name.variable.indexed.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^ variable.parameter.c */ +/* ^^^ support.type.c */ +/* ^^ variable.parameter */ +/* ^^^ storage.type */ +/* ^^^ variable.parameter */ + +struct resource_table *(*find_loaded_rsc_table)( +/* <- keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */ + struct rproc *rproc, const struct firmware *fw); +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^ variable.parameter.c */ +/* ^ punctuation.separator */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^ variable.parameter.c */ + + +void do_pci_scan_bridge(struct device *dev, +/* ^^^^^^^^^^^^^^^^^^ meta.function.c entity.name.function.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c - meta.function.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ + void (*do_scan_bus)(int max_devfn)); +/*^^^^ storage.type.c */ +/* ^ meta.function.parameters.c meta.group.c meta.group.c punctuation.section.group.begin.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^^ variable.parameter.c */ +/* ^ meta.function.parameters.c meta.group.c meta.group.c punctuation.section.parens.end.c */ +/* ^ meta.function.parameters.c meta.group.c meta.function.parameters.c meta.group.c punctuation.section.group.begin.c - meta.function.c */ +/* ^^^ storage.type.c */ +/* ^^^^^^^^^ variable.parameter.c */ +/* ^ meta.function.parameters.c meta.group.c meta.function.parameters.c meta.group.c punctuation.section.group.end.c - meta.function.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c - meta.function.c */ +/* ^ punctuation.terminator.c - meta.function */ + +extern int (*something)(const struct pci_dev *dev); +/* <- storage.modifier.c */ +/* ^^^ storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^ variable.parameter.c*/ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + +/* We can't match this as a function */ +static ssize_t function_with_params_on_newline +/* <- storage.modifier.c */ +/* ^^^^^^^ support.type.sys-types.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ support.type.c*/ + (struct device *dev, +/* ^ meta.group.c punctuation.section.group.begin.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^ support.type.c */ +/* ^ keyword.operator.c */ +/* ^^^ variable.other.c */ +/* ^ punctuation.separator.c */ + char *buf) +/* ^^^^ storage.type.c */ +/* ^ keyword.operator.c */ +/* ^^^ variable.other.c */ +/* ^ punctuation.section.group.end.c */ +{ +/* <- meta.block.c punctuation.section.block.begin.c */ + return 0; +} +/* <- meta.block.c punctuation.section.block.end.c */ + + +static const struct pci_driver my_driver __pci_driver __driver = { +/* <- storage.modifier.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^^^^^^^^^^^^ constant.other.macro.c */ +/* ^^^^^^^^ constant.other.macro.c */ + .ops = &pci_my_device_ops, +/*^ punctuation.accessor.c */ +/* ^^^ variable.other.member.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ keyword.operator.c */ +/* ^^^^^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ + .vendor = PCI_VENDOR_ID, +/*^ punctuation.accessor.c */ +/* ^^^^^^ variable.other.member.indexed.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.separator.c */ + .devices = pci_device_ids, +/*^ punctuation.accessor.c */ +/* ^^^^^^^ variable.other.member.indexed.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ +}; + +struct __ec_align4 ec_response_get_version {}; +/* <- keyword.declaration.struct.c */ +/* ^^^^^^^^^^^ constant.other.macro.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */ +struct __align(4) ec_response_get_version {}; +/* <- keyword.declaration.struct.c */ +/* ^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^ meta.function-call.parameters.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */ + +struct ALIGN4 ec_response_get_version {}; +/* <- keyword.declaration.struct.c */ +/* ^^^^^^ constant.other.macro */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */ + +static const struct spd_info { +/* ^^^^^^ meta.struct.c keyword.declaration.struct.c */ +/* ^^^^^^^^ entity.name.struct.c */ + size_t spd_len; +/* ^^^^^^ support.type */ +/* ^^^^^^^ entity.name.member.indexed.c */ + size_t spd_part_len; +/* ^^^^^^ support.type */ +/* ^^^^^^^ entity.name.member.indexed.c */ +} spd_mem_info[] = { +/*^^^^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^^ meta.brackets.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^ punctuation.section.brackets.end.c */ + [SPD_INFO_DDR4] = { +/* ^ meta.brackets.c punctuation.section.brackets.begin.c */ +/* ^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ meta.brackets.c punctuation.section.brackets.end.c */ + .spd_len = SPD_DDR4_LENGTH, +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ + .spd_part_len = SPD_DDR4_PART_LEN, +/* ^^^^^^^^^^^^^^^^^ constant.other.macro.c */ + }, + [SPD_INFO_DEFAULT] = { +/* ^ meta.brackets.c punctuation.section.brackets.begin.c */ +/* ^^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ meta.brackets.c punctuation.section.brackets.end.c */ + .spd_len = spd_default_length, +/* ^^^^^^^^^^^^^^^^^^ variable.other.indexed.c */ + .spd_part_len = spd_default_part_len, +/* ^^^^^^^^^^^^^^^^^^^^ variable.other.indexed.c */ + }, +}; + +void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = { +/* <- storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ meta.brackets.c punctuation.section.brackets.begin.c */ +/* ^ meta.brackets.c punctuation.section.brackets.end.c */ +/* ^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^ meta.function-call.parameters.c */ +/* ^^^^ constant.numeric.value.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ meta.block.c punctuation.section.block.begin.c */ + [0 ... __NR_compat_syscalls - 1] = sys_ni_syscall, +/*^ meta.brackets.c punctuation.section.brackets.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^^^ keyword.operator.variadic.c */ +/* ^^^^^^^^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ constant.numeric.value.c */ +/* ^ meta.brackets.c punctuation.section.brackets.end.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^^^^^ variable.other.indexed.c */ +/* ^ punctuation.separator.c */ +#include +}; +/* <- meta.block.c punctuation.section.block.end.c */ + /* <- punctuation.terminator.c */ + +pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE); +/* <- support.type.c */ +/* ^^^^^^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^^^^^^^^^^^^^^ meta.brackets.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.section.brackets.end.c */ +/* ^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^^^ meta.function-call.parameters.c */ +/* ^ meta.group.c punctuation.section.group.begin.c */ +/* ^^^^^^^^^ constant.other.macro.c */ +/* ^ meta.group.c punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + +struct mac_tfm_ctx { +/* <- keyword.declaration.struct.c */ +/* ^^^^^^^^^^^ entity.name.struct.c */ +/* ^ meta.block.c punctuation.section.block.begin.c */ + struct crypto_aes_ctx key; +/*^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^ support.type.c */ +/* ^^^ entity.name.member.c */ +/* ^ punctuation.terminator.c */ + struct crypto_aes_ctx __aligned(8) key2; +/*^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^ support.type.c */ +/* ^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^ meta.function-call.parameters.c */ +/* ^ meta.group.c punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ meta.group.c punctuation.section.group.end.c */ +/* ^^^^ entity.name.member.indexed.c */ +/* ^ punctuation.terminator.c */ + u8 __aligned(8) consts[]; +/*^^ support.type.c */ +/* ^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^ meta.function-call.parameters.c */ +/* ^ meta.group.c punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ meta.group.c punctuation.section.group.end.c */ +/* ^^^^^^ entity.name.member.indexed.c */ +/* ^ meta.brackets.c punctuation.section.brackets.begin.c */ +/* ^ meta.brackets.c punctuation.section.brackets.end.c */ +/* ^ punctuation.terminator.c */ +} __packed __aligned(4); +/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */ +/*^^^^^^^^ constant.other.macro.c */ +/* ^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^ meta.function-call.parameters.c */ +/* ^ meta.group.c punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ meta.group.c punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + +void __attributes(int *bar) __must_hold(&foo) +/* <- storage.type.c */ +/* ^^^^^^^^^^^^ entity.name.function.c */ +/* ^^^ storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^ variable.parameter.c */ +/* ^^^^^^^^^^^ meta.function-call.c */ +/* ^^^^^^ meta.function-call.parameters.c */ +/* ^ keyword.operator.c */ +/* ^^^ variable.other.c */ + __safe +/* ^^^^^^ constant.other.macro.c */ + SAFE +/* ^^^^ constant.other.macro.c */ + __blah(bar) +/* ^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^ variable.other.c */ + __blah(bar, foo) +/* ^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^^ meta.function-call.parameters.c */ +/* ^^^ variable.other.c */ +/* ^^^ variable.other.c */ + __must_hold(&abc->lock) +/* ^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^^^^ meta.function-call.parameters.c */ +/* ^ keyword.operator.c */ +/* ^^^ variable.other.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^^ variable.other.member.c */ + {} +/* ^^ meta.function.c meta.block.c */ + + +void f_attributes(int *bar) __attribute__((context(&foo,1,1))) {} +/* <- storage.type.c */ +/* ^^^^^^^^^^^^ entity.name.function.c */ +/* ^^^ storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^ variable.parameter.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^^^^^^^^^^ storage.modifier.c */ +/* ^^ meta.function.c meta.block.c */ + +char *__attribute__((aligned(8))) *e, +/* <- storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^^^^^^^^^^ storage.modifier.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + *f, +/*^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + __attribute__((aligned(8))) * g, +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/*^^^^^^^^^^^^^ storage.modifier.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + * __attribute__((aligned(8))) h; +/*^ storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^^^^^^^^^^^^^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +char *MACRO1 *e, +/* <- storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^ constant.other.macro.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + *f, +/*^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + MACRO1 * g, +/*^^^^^^ constant.other.macro.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + * MACRO1 * h; +/*^ storage.modifier.c */ +/* ^^^^^^ constant.other.macro.c */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +char *MACRO1 e, +/* <- storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^ constant.other.macro.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + f, +/*^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + MACRO1 g, +/*^^^^^^ constant.other.macro.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + * MACRO1 h; +/*^ storage.modifier.c */ +/* ^^^^^^ constant.other.macro.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +char *__aligned(8) *e, +/* <- storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + *f, +/*^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + __aligned(8) * g, +/*^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + * __aligned(8) h, +/*^ storage.modifier.c */ +/* ^^^^^^^^^^^^ meta.function-call */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + + __aligned(sizeof(int)) * i, +/*^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + __aligned(sizeof(void *)) * j, +/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ + __aligned(0x8) * k; +/*^^^^^^^^^^^^^^ meta.function-call */ +/* ^ storage.modifier.c */ +/* ^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +MACRO1 UPPER_VAR; +/* <- constant.other.macro.c */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +__safe UPPER_VAR; +/* <- constant.other.macro.c */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +TYPE(int) UPPER_VAR; +/* <- meta.function-call */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +void __printf(1) +/* <- storage.type.c */ +/* ^^^^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^ constant.numeric.value.c */ +/* ^^^ meta.function-call.parameters.c */ +__printf(1,) +/* ^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^ meta.function-call.parameters.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ punctuation.section.group.end.c */ +__printf(1, ) +/* ^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^ meta.function-call.parameters.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ punctuation.section.group.end.c */ +__printf(1, 2) +/* ^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^ meta.function-call.parameters.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.section.group.end.c */ +__printf(1, 2, 3) +/* ^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^ meta.function-call.parameters.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.section.group.end.c */ +__printf(0x1, 0xA, sizeof(int)) +/* ^^^^^ meta.function-call.c constant.other.macro.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.parameters.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^ constant.numeric.base.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^^ constant.numeric.base.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^ keyword.operator */ +/* ^^^ storage.type.c */ +/* ^ punctuation.section.group.end.c */ +__i915_printk(void); +/* <- entity.name.function.c */ +/* ^^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ + +static const struct print_field const err_flags[]; +/*<- storage.modifier.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.section.brackets.begin.c */ +/* ^ punctuation.section.brackets.end.c */ +/* ^ punctuation.terminator.c */ + +enum { +/* <- keyword.declaration.enum.c */ + ENUM_A, +/* ^ entity.name.constant.enum.c */ +/* ^ punctuation.separator.c */ + ENUM_B = 6, +/* ^ entity.name.constant.enum.c */ +/* ^ keyword.operator.assignment */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +#ifdef ENABLED_FEATURE +/* <- meta.preprocessor.c keyword.control.import.c */ +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ + ENUM_ENABLED, +/* ^^^^^^^^^^^^ entity.name.constant.enum.c */ +#else +/* <- meta.preprocessor.c keyword.control.import.c */ + ENUM_DISABLED, +/* ^^^^^^^^^^^^^ entity.name.constant.enum.c */ +#endif +/* <- meta.preprocessor.c keyword.control.import.c */ + +#if 0 +/* <- meta.preprocessor.c keyword.control.import.c */ + ENUM_FIELD_DISABLED +/* ^^^^^^^^^^^^^^^^^^^ entity.name.constant.enum.c */ +#endif +/* <- meta.preprocessor.c keyword.control.import.c */ + + ENUM_C +/* ^ entity.name.constant.enum.c */ +}; + +enum typec_mux { +/* <- meta.enum.c keyword.declaration.enum.c */ +/* ^^^^^^^^^ entity.name.enum.c */ + TYPEC_MUX_NONE = 0, +/*^^^^^^^^^^^^^^ entity.name.constant.enum.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.separator.c */ + TYPEC_MUX_USB = MUX_USB_ENABLED, +/*^^^^^^^^^^^^^ entity.name.constant.enum.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ punctuation.separator.c */ + TYPEC_MUX_DOCK = MUX_USB_ENABLED | MUX_DP_ENABLED, +/*^^^^^^^^^^^^^^ entity.name.constant.enum.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^^^^^^ constant.other.macro.c */ +/* ^ keyword.operator */ +/* ^^^^^^^^^^^^^^ constant.other.macro.c */ +}; +/* <-meta.enum.c meta.block.c punctuation.section.block.end.c */ + /* <- punctuation.terminator.c */ + ///////////////////////////////////////////// // Test preprocessor branching and C blocks ///////////////////////////////////////////// -int foo(int val, float val2[]) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ +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 */ +/* ^^ meta.brackets.c */ /* ^ punctuation.section.brackets.begin */ /* ^ punctuation.section.brackets.end */ +/* ^^ meta.brackets.c */ +/* ^ punctuation.section.brackets.begin */ +/* ^ punctuation.section.brackets.end */ +/* ^ punctuation.section.group.end */ { /* <- meta.function meta.block */ myClass *result; +/* ^^^^^^ variable.other.indexed.c */ result->kk = func(val); /* ^^ punctuation.accessor */ +/* ^^^^^^ variable.other.indexed.c */ +/* ^^ variable.other.member.c */ +/* ^^^ variable.other.c */ if (result != 0) { +/* ^^^^^^ variable.other.indexed.c */ /* ^^ keyword.operator.comparison.c */ return 0; #if CROSS_SCOPE_MACRO @@ -431,7 +1873,7 @@ int foo(int val, float val2[]) #ifdef FOO /* <- keyword.control.import */ int foobar -/* ^^^^^^ - entity.name.function */ +/* ^^^^^^ variable.other.indexed.c */ ; if (val == -1) { @@ -470,7 +1912,9 @@ GetTextMetrics( #endif /* <- keyword.control.import */ hdc, +/* ^^^ variable.other.c */ lptm +/* ^^^^ variable.other.c */ ); /* ^ meta.function-call */ /* ^ - meta.function-call */ @@ -490,12 +1934,12 @@ int a; int /* comment */ * myfunc /* <- storage.type */ /* ^ comment.block */ -/* ^ keyword.operator */ +/* ^ storage.modifier.c */ /* ^^^^^^ meta.function entity.name.function */ (int * a) /*^^^^^^^ meta.function.parameters meta.group */ /* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ +/* ^ storage.modifier */ /* ^ variable.parameter */ /* ^ punctuation.section.group.end */ { @@ -503,18 +1947,68 @@ int /* comment */ * myfunc } MACRO1 +/* <- constant.other.macro.c */ RETURN_TYPE -/* <- - entity.name.function */ +/* <- constant.other.macro.c */ func_name() { /* < entity.name.function */ } +MACRO1 void MACRO2 * myfuncname (); +/* <- constant.other.macro.c */ +/* ^ storage.type.c */ +/* ^ constant.other.macro.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^^^^^ meta.function.c entity.name.function.c */ +/* ^^ meta.function.parameters.c*/ +/* ^ punctuation.terminator.c */ + +MACRO1 void MACRO2 myfuncname (), MACRO2 foo(), UPPER_VAR, UPPERFN(); +/* <- constant.other.macro.c */ +/* ^ storage.type.c */ +/* ^ constant.other.macro.c */ +/* ^^^^^^^^^^ meta.function.c entity.name.function.c */ +/* ^^ meta.group.c*/ +/* ^ punctuation.separator.c */ +/* ^^^^^^ constant.other.macro.c */ +/* ^^^ entity.name.function.c */ +/* ^^ meta.function.parameters.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^ entity.name.function.c */ +/* ^^ meta.function.parameters.c */ +/* ^ punctuation.terminator.c */ + +void func(int pack __attribute__((unused)), +/* <- storage.type.c */ +/* ^^^^ meta.function.c entity.name.function.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */ +/* ^^^ storage.type.c */ +/* ^^^^ - variable.parameter.c - This is wrong */ +/* ^^^^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^ punctuation.separator.c */ + struct usbip_usb_interface *udev +/*^^^^^^ keyword.declaration.struct.c */ +/* ^^^^^^^^^^^^^^^^^^^ support.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^ variable.parameter.c */ + __attribute__((unused))); +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */ +/* ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */ +/* ^ punctuation.terminator.c */ + MACRO1 void * MACRO2 myfuncname () { -/* ^^^^^^^^^^^^^^^ meta.function */ +/* <- constant.other.macro.c */ +/* ^^^^ storage.type.c */ +/* ^ storage.modifier.c */ +/* ^^^^^^ constant.other.macro */ +/* ^^^^^^^^^^ meta.function */ /* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin +/* ^ meta.block punctuation.section.block.begin */ /* ^ storage.type */ -/* ^ keyword.operator */ +/* ^ storage.modifier */ /* ^ entity.name.function */ label: @@ -534,16 +2028,18 @@ MACRO1 void * MACRO2 myfuncname () { } struct Args { -/* ^ keyword.declaration */ +/* ^ keyword.declaration.struct.c */ /* ^ entity.name.struct */ void* hello; +/* ^^^^^ entity.name.member.indexed.c */ void* foobar; +/* ^^^^^^ entity.name.member.indexed.c */ }; struct Args args; -/* ^ keyword.declaration */ -/* ^ - entity */ - +/* ^ keyword.declaration.struct.c */ +/* ^ support.type.c - entity */ +/* ^^^^ variable.other.c */ } static const uint32_t * const MACRO funcname(); @@ -552,14 +2048,15 @@ static const uint32_t * const MACRO funcname(); /* ^ storage.modifier */ /* ^ storage.modifier */ /* ^ support.type */ -/* ^ keyword.operator */ +/* ^ storage.modifier.c */ /* ^ storage.modifier */ +/* ^^^^^ constant.other.macro */ /* ^ entity.name.function */ MACRO int /* ^ storage.type */ funcname2 -/* ^ entity.name.function */ +/* ^ support.type.c */ () { int a[5]; @@ -568,14 +2065,59 @@ funcname2 /* ^ punctuation.section.brackets.end */ } -MACRO_CALL(int) macro_prefixed_func(){} +MACRO_CALL(int) foo; /*^^^^^^^^^^^^^ meta.function-call */ /* ^^^^^ meta.group */ +/* ^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ +MACRO_CALL(int) ALIGNED(8) foo; +/*^^^^^^^^^^^^^ meta.function-call */ +/* ^^^^^ meta.function-call.parameters.c */ +/* ^^^^^^^^^^ meta.function-call */ +/* ^^^ meta.function-call.parameters.c */ +/* ^^^ entity.name.variable.indexed.c */ +/* ^ punctuation.terminator.c */ + +MACRO_CALL(int) ALIGNED(8) macro_prefixed_func(){} +/*^^^^^^^^^^^^^ meta.function-call */ +/* ^^^^^ meta.function-call.parameters.c */ +/* ^^^^^^^^^^ meta.function-call */ +/* ^^^ meta.function-call.parameters.c */ +/* ^ entity.name.function */ + + +MACRO_CALL(int) macro_prefixed_func(){} +/*^^^^^^^^^^^^^ meta.function-call */ +/* ^^^^^ meta.function-call.parameters.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ /* ^ entity.name.function */ +extern NCURSES_EXPORT(int) use_default_colors (void); +/* <- storage.modifier.c */ +/* ^^^^^^^^^^^^^^ meta.function-call.c */ +/* ^^^^^ meta.function-call.parameters.c */ +/* ^^^^^^^^^^^^^^^^^^ meta.function.c */ +/* ^^^^^^ meta.function.parameters.c */ +/* ^ punctuation.terminator.c */ + +extern NCURSES_EXPORT(const char *) curses_version (void); +/* <- storage.modifier.c */ +/* ^^^^^^^^^^^^^^ meta.function-call.c */ +/* ^^^^^^^^^^^^^^ meta.function-call.parameters.c */ +/* ^^^^^^^^^^^^^^ meta.function.c */ +/* ^^^^^^ meta.function.parameters.c */ +/* ^ punctuation.terminator.c */ + +extern NCURSES_EXPORT_VAR(int) COLORS; +/* <- storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^ meta.function-call.c */ +/* ^^^^^ meta.function-call.parameters.c */ +/* ^^^^^^ entity.name.variable.indexed.c */ + int* return_type_pointer_no_space(){} +/* <- storage.type.c */ +/* ^ storage.modifier.c */ /* ^ entity.name.function */ // Make sure there isn't an incorrect match here since this is not a valid @@ -585,8 +2127,10 @@ int32 () {} _declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ +/* <- meta.function-call constant.other.macro.c */ +/* ^^^^ storage.type.c */ /* ^ entity.name.function */ +/* ^^^ storage.type.c */ __declspec(deprecated("bla")) void func2(int) {} /* <- storage.modifier - variable.function */ /* ^ storage.modifier - variable.function */ @@ -596,26 +2140,17 @@ __declspec(deprecated("bla")) void func2(int) {} /* ^ string.quoted.double punctuation */ /* ^^ punctuation - invalid */ /* ^ entity.name.function */ +/* ^^^ storage.type.c */ __notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ +/* <- meta.function-call constant.other.macro.c */ +/* ^^^^ storage.type.c */ /* ^ entity.name.function */ - -///////////////////////////////////////////// -// Test function call in function parameters -///////////////////////////////////////////// - -static string foo(bar() + ';'); -/* ^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^ entity.name.function */ -/* ^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ string */ -/* ^ -string */ +/* ^^^ storage.type.c */ func_call(foo /*^^^^^^^^^^^ meta.function-call */ /* ^^^^ meta.group */ +/* ^^^ variable.other.c */ /* ^ punctuation.section.group.begin */ ); /* <- meta.function-call meta.group punctuation.section.group.end */ @@ -645,6 +2180,7 @@ func_call(foo /* ^ punctuation.definition.string.end */ #ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */ #include_next /* <- keyword.control.import.include */ /* ^ punctuation.definition.string.begin */ @@ -994,6 +2530,8 @@ scanf("%ms %as %*[, ]", &buf); /* ^^^ constant.other.placeholder */ /* ^^^ constant.other.placeholder */ /* ^^^^^^ constant.other.placeholder */ +/* ^ keyword.operator.c */ +/* ^^^ variable.other.c */ "foo % baz" /* ^ - invalid */ @@ -1007,6 +2545,7 @@ int control_keywords() { if (x < 5) /* <- keyword.control */ +/* ^ variable.other.c */ {} else /* <- keyword.control */ @@ -1014,6 +2553,7 @@ int control_keywords() switch (x) /* <- keyword.control */ +/* ^ variable.other.c */ { case 1: /* <- keyword.control */ @@ -1024,17 +2564,48 @@ int control_keywords() break; /* <- keyword.control.flow.break */ } - + int8_t foo; +/*^^^^^^ support.type.stdint.c */ +/* ^^^ variable.other.c */ + const int8_t foo; +/* ^^^^^^ support.type.stdint.c */ +/* ^^^ variable.other.c */ + int my_var; +/* ^^^^^^ variable.other.indexed.c */ + foo->bar.baz->hello("World"); +/*^^^ variable.other.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^ variable.other.member.c */ +/* ^ punctuation.accessor.c */ +/* ^^^ variable.other.member.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^^^ meta.function-call.c variable.function.c */ +/* ^^^^^^^^^ meta.function-call.parameters.c */ +/* ^ punctuation.terminator.c */ + + foo->indexed.something = 4; +/*^^^ variable.other.c */ +/* ^^ punctuation.accessor.c */ +/* ^^^^^^^ variable.other.member.indexed.c */ +/* ^ punctuation.accessor.c */ +/* ^^^^^^^^^ variable.other.member.indexed.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ constant.numeric.value.c */ +/* ^ punctuation.terminator.c */ do /* <- keyword.control */ { if (y == 3) +/* ^ variable.other.c */ continue; /* <- keyword.control.flow.continue */ } while (y < x); /*^ keyword.control */ +/* ^ variable.other.c */ +/* ^ variable.other.c */ switch (a) { +/* ^ variable.other.c */ case 1: break; /* ^ punctuation.separator */ case 100 - 10: break; diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 9f20da2b7a..b654bde9b0 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -272,6 +272,56 @@ bool foo (bool run=true) {} /* ^ entity.name.function */ }; +struct UI_BoundingBox position; +/* ^ - entity.name */ +/* ^ - entity.name */ + +struct UI_BoundingBox *position_p; +/* ^ - entity.name */ +/* ^ - entity.name */ + +struct UI_BoundingBox * position_p2; +/* ^ - entity.name */ +/* ^ - entity.name */ + +struct UI_BoundingBox **position_p2; +/* ^ - entity.name */ +/* ^ - entity.name */ + +struct UI_BoundingBox ** position_p2; +/* ^ - entity.name */ +/* ^ - entity.name */ + +struct UI_MenuBoxData +/* <- keyword.declaration.struct.type.c++ */ +/* ^ entity.name.struct */ +{ + struct UI_BoundingBox position; +/* ^ - entity.name */ +/* ^ - entity.name */ + struct UI_BoundingBox *position_p; +/* ^ - entity.name */ +/* ^ - entity.name */ + struct UI_BoundingBox * position_p1; +/* ^ - entity.name */ +/* ^ - entity.name */ + struct UI_BoundingBox **position_p2; +/* ^ - entity.name */ +/* ^ - entity.name */ + struct UI_BoundingBox ** position_p3; +/* ^ - 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 */ +}; + + ///////////////////////////////////////////// // Strings /////////////////////////////////////////////