From e0e37d7b163c3a250ca80484f430e0fb053cd119 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 9 Jan 2019 11:02:15 -0700
Subject: [PATCH 01/55] [C] Refactor struct handling

So correctly fixing this involved a lot more changes then I expected.

Fixes #1830

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax    | 306 ++++++++++++++++++++++++------
 C++/syntax_test_c.c     | 405 ++++++++++++++++++++++++++++++++++++++--
 C++/syntax_test_cpp.cpp |  66 ++++++-
 3 files changed, 697 insertions(+), 80 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 0f5385f48b..db398b2ea5 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -13,7 +13,7 @@ variables:
   macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars
   control_keywords: 'break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while'
   basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void'
-  before_tag: 'struct|union|enum'
+  before_tag: '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'
@@ -25,6 +25,14 @@ variables:
   non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__'
 
 contexts:
+  or_pop:
+    - match: '(?=\S)'
+      comment: Pop if nothing matched (whitespace are ignored).
+      pop: true
+
+  prototype:
+    - include: comments
+
   main:
     - include: preprocessor-global
     - include: global
@@ -47,6 +55,7 @@ contexts:
       scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.block.c
+          meta_include_prototype: false
         - match: \*/
           scope: punctuation.definition.comment.c
           pop: true
@@ -60,6 +69,7 @@ contexts:
       scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.line.double-slash.c
+          meta_include_prototype: false
         - match: '(\\)$\n'
           captures:
             1: punctuation.separator.continuation.c
@@ -72,7 +82,8 @@ contexts:
         1: storage.type.string.c
         2: punctuation.definition.string.begin.c
       push:
-        - meta_scope: string.quoted.double.c
+        - meta_include_prototype: false
+          meta_scope: string.quoted.double.c
         - match: '"'
           scope: punctuation.definition.string.end.c
           pop: true
@@ -84,6 +95,7 @@ contexts:
         2: punctuation.definition.string.begin.c
       push:
         - meta_scope: string.quoted.single.c
+          meta_include_prototype: false
         - match: "'"
           scope: punctuation.definition.string.end.c
           pop: true
@@ -122,7 +134,7 @@ contexts:
     - match: \b({{control_keywords}})\b
       scope: keyword.control.c
     - match: \bsizeof\b
-      scope: keyword.operator.word.c
+      scope: keyword.operator.word.c debug.keywords
 
   modifiers:
     - match: \b({{modifiers}})\b
@@ -150,6 +162,7 @@ contexts:
       scope: support.function.C99.c
 
   types:
+    - include: struct-keyword
     - match: \b({{basic_types}}|{{before_tag}})\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
@@ -243,18 +256,20 @@ contexts:
   # comment without a line continuation ends at the newline.
   preprocessor-comments:
     - match: /\*
-      scope: punctuation.definition.comment.c
+      scope: punctuation.definition.comment.c debug.preprocessor-comments
       push:
         - meta_scope: comment.block.c
+        - meta_include_prototype: false
         - match: '\\$\n'
           scope: punctuation.separator.continuation.c
         - match: \*/
           scope: punctuation.definition.comment.c
           pop: true
     - match: //
-      scope: punctuation.definition.comment.c
+      scope: punctuation.definition.comment.c debug.preprocessor-comments
       push:
         - meta_scope: comment.line.double-slash.c
+        - meta_include_prototype: false
         - match: '(\\)$\n'
           captures:
             1: punctuation.separator.continuation.c
@@ -320,6 +335,7 @@ contexts:
     - include: modifiers-parens
     - include: modifiers
     - include: types
+    - include: struct-keyword
     - include: function-call
     - match: ';'
       scope: punctuation.terminator.c
@@ -327,6 +343,7 @@ contexts:
   ## C-specific contexts
 
   global-modifier:
+    - meta_scope: debug.global-modifier
     - include: comments
     - include: modifiers-parens
     - include: modifiers
@@ -334,6 +351,7 @@ contexts:
       set: global-type
 
   global-type:
+    - meta_scope: debug.global-type
     - include: comments
     - match: \*
       scope: keyword.operator.c
@@ -350,12 +368,13 @@ contexts:
           )
         )
       captures:
-        1: storage.type.c
+        1: storage.type.c debug.global-type
       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
+    - include: struct-keyword
     - match: '(?=\b({{control_keywords}})\b)'
       pop: true
     - match: '(?=\s)'
@@ -396,8 +415,23 @@ contexts:
     - match: '{{identifier}}(?!\s*(\(|$))'
     # Real function definition
     - match: '{{identifier}}(?=\s*(\(|$))'
-      scope: meta.function.c entity.name.function.c
+      scope: meta.function.c entity.name.function.c debug.global
       set: function-definition-params
+    - match: '\((?=\s*\*)'
+      scope: punctuation.section.group.begin debug.global-maybe-function.function-pointer
+      comment: Function pointers are not really functions, but variables
+      push:
+        - meta_scope: meta.parens
+        - match: \)
+          scope: punctuation.section.parens.end
+          set:
+            - include: function-definition-params-group
+            - include: or_pop
+        - match: \*
+          scope: storage.modifier.c
+        - match: '{{identifier}}'
+          scope: variable.other.c debug.global-maybe-function.function-pointer
+        - include: or_pop
     - match: '(?=\S)'
       pop: true
 
@@ -406,21 +440,32 @@ contexts:
     - 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
+        - match : \)
+          scope: punctuation.section.group.end.c
+          pop: true
+        - match: '\bvoid\b'
+          scope: storage.type.c
+        - match: \*
+          scope: storage.modifier.c
+        - match: \.\.\.
+          scope: keyword.operator.variadic.c
+        - match: '{{identifier}}(?=\s*(\[|,|\)))'
+          scope: variable.parameter.c
+        - include: struct-keyword-parameter
+        - include: expressions
+        - match: '{{identifier}}'
+          scope: support.type.c
+          comment: We match the variable name above
+        - include: preprocessor-line-continuation
 
   function-definition-continue:
     - meta_content_scope: meta.function.c
@@ -429,33 +474,29 @@ 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 debug.function-definition-body
         - 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: struct-keyword
         - 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*[=;\[])'
+    - match: '\b({{before_tag}})(?=\s+{{identifier}}(?:\s+{{identifier}})*(?:\s*\*\s*|\s)+{{identifier}}\s*[,=;\[])'
       scope: storage.type.c
-    - match: '\bstruct\b'
-      scope: storage.type.c
-      set: data-structures-struct-definition
     - match: '\benum\b'
       scope: storage.type.c
       set: data-structures-enum-definition
@@ -465,23 +506,141 @@ contexts:
     - match: '(?=\S)'
       pop: true
 
-  data-structures-struct-definition:
-    - meta_scope: meta.struct.c
-    - include: data-structures-definition-common-begin
-    - match: '{{identifier}}(?=\s*;)'
-      scope: entity.name.struct.forward-decl.c
+  macro-identifiers:
+    - match: '{{macro_identifier}}'
+      comment: Not sure I think this is a good idea
+      scope: variable.annotation
+
+  parameter-variable-identifier:
+    - match: \*
+      scope: storage.modifier.c
+    - match: \(
+      scope: punctuation.section.group.begin debug.parameter-variable-identifier.function-pointer
+      comment: Function pointer declaration as variable
+      push:
+        - meta_scope: meta.parens
+        - match: \)
+          scope: punctuation.section.parens.end
+          set:
+            - include: function-definition-params-group
+            - include: or_pop
+        - match: \*
+          scope: storage.modifier.c
+        - match: '{{identifier}}'
+          scope: variable.parameter.c debug.parameter-variable-identifier.function-pointer
     - match: '{{identifier}}'
-      scope: entity.name.struct.c
-    - match: '(?=;)'
-      pop: true
-    - match: '\{'
-      scope: meta.block.c punctuation.section.block.begin.c
+      scope: variable.parameter.c debug.parameter-variable-identifier
+
+  variable-identifier-list:
+    - include: modifiers-parens
+    - match: \*
+      scope: storage.modifier.c
+    - match: '{{identifier}}(?=\s*\()'
+      scope: meta.function.c entity.name.function.c debug.variable-identifier-list.function-first
       set:
-        - meta_content_scope: meta.struct.c meta.block.c
+        - meta_scope: debug.variable-identifier-list.function
+        - include: function-definition-params-group
+        - include: function-definition-body
+        - match: '(?=\S)'
+          set: variable-identifier-list
+    - match: \(
+      scope: punctuation.section.group.begin debug.variable-identifier-list.function-pointer
+      comment: Function pointer declaration
+      push:
+        - meta_scope: meta.parens
+        - match: \)
+          scope: punctuation.section.parens.end
+          set:
+            - include: function-definition-params-group
+            - include: or_pop
+        - match: \*
+          scope: storage.modifier.c
+        - match: '{{identifier}}'
+          scope: variable.other.c debug.variable-identifier-list.function-pointer
+    - match: '{{identifier}}'
+      scope: variable.other.c debug.variable-identifier-list
+      push:
+        - meta_scope: debug.variable-identifier-list.array-or-assignment
+        - match: \[
+          scope: punctuation.section.brackets.begin.c storage.modifier.c
+          push:
+            - meta_scope: meta.brackets.c
+            - match: \]
+              scope: punctuation.section.brackets.end.c storage.modifier.c
+              pop: true
+            - include: expressions
+            # Expressions doesn't handle macro identifiers or enum constants
+            - match: '{{macro_identifier}}'
+              scope: support.constant.c
+        - match: \=
+          scope: keyword.operator.assignment.c
+          set:
+            - meta_scope: debug.variable-identifier-list.assignment
+            - match: '(?=,|;)'
+              pop: true
+            - include: expressions
+            - include: or_pop
+        - include: or_pop
+    - match: ','
+      scope: punctuation.separator debug.variable-identifier-list
+    - include: or_pop
+
+  struct-keyword-parameter:
+    - match: '\bstruct\b'
+      scope: storage.type.c
+      push:
+        - meta_scope: meta.struct.c debug.struct-keyword-parameter
+        - match: '{{identifier}}'
+          scope: support.type.c
+          comment: Type for variable declaration
+          set:
+            - include: parameter-variable-identifier
+            - include: or_pop
+        - include: or_pop
+
+  struct-keyword:
+    - match: '\bstruct\b'
+      scope: storage.type.c
+      push:
+        - meta_scope: meta.struct.c debug.struct-keyword
+        # - include: data-structures-definition-common-begin
+        # This handles __attribute__ and __declspec
+        - include: modifiers-parens
+        - include: macro-identifiers
+        - match: '{{identifier}}(?=\s*{|\s*\n)'
+          scope: entity.name.struct.c
+          comment: Struct definition
+          set: struct-body
+        - match: '(?={)'
+          comment: Anonymous struct definition
+          set: struct-body
+        - match: '{{identifier}}'
+          scope: support.type.c debug.data-structures-struct-definition
+          comment: Type for variable declaration
+          set: variable-identifier-list
+        - include: or_pop
+  struct-body:
+    - match: '\{'
+      scope: punctuation.section.block.begin.c
+      push:
+        - meta_scope: meta.struct.c meta.block.c debug.struct-body
         - match: '\}'
-          scope: meta.struct.c meta.block.c punctuation.section.block.end.c
-          pop: true
+          scope: punctuation.section.block.end.c
+          set:
+            - meta_scope: debug.struct-body.struct-end
+            - match: '\n'
+              comment: >
+                Struct body declarations should normally have an identifier
+                afterwards or ; to terminate them. If the ; is missing we don't
+                want to grab an identifier from another line. Typically variable
+                names are on the same line as the }, so if we find a new line
+                treat it as a terminator.
+              pop: true
+            - include: variable-identifier-list
+            - include: or_pop
+        - include: struct-keyword
         - include: data-structures-body
+    - include: or_pop
 
   data-structures-enum-definition:
     - meta_scope: meta.enum.c
@@ -493,14 +652,34 @@ contexts:
     - match: '(?=;)'
       pop: true
     - 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
+        - meta_scope: meta.enum.c meta.block.c debug.data-structures-enum-definition
         # Enums don't support methods so we have a simplified body
         - match: '\}'
           scope: meta.enum.c meta.block.c punctuation.section.block.end.c
           pop: true
-        - include: data-structures-body
+        - match: '{{identifier}}'
+          scope: constant.other.enum.c
+          push:
+            - meta_scope: debug.data-structures-enum-definition.pre-assignment
+            - match: '='
+              scope: keyword.operator.assignment
+              set:
+                - meta_scope: debug.data-structures-enum-definition.post
+                # 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: data-structures-body
 
   data-structures-union-definition:
     - meta_scope: meta.union.c
@@ -528,6 +707,7 @@ contexts:
     - include: modifiers
     # Handle macros so they aren't matched as the class name
     - match: '\b[[:upper:][:digit:]_]+\b'
+      scope: macro
 
   data-structures-definition-common-end:
     - match: '(?=;)'
@@ -535,13 +715,31 @@ contexts:
 
   data-structures-body:
     - include: preprocessor-data-structures
+    - include: preprocessor-expressions
+    - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon
     - match: '(?={{before_tag}})'
       push: data-structures
-    - include: expressions
+    # - include: modifiers-parens
+    - include: struct-keyword
+    - match: '\b{{type_qualifier}}\b'
+      scope: storage.modifier.c
+    - match: '{{basic_types}}'
+      scope: storage.type.c
+      comment: Improve this to better match built-in types
+      push:
+        - meta_scope: debug.data-structures-body.variable-identifier
+        - include: variable-identifier-list
+    - match: '{{identifier}}'
+      scope: support.type.c
+      comment: Improve this to better match built-in types
+      push:
+        - meta_scope: debug.data-structures-body.variable-identifier
+        - include: variable-identifier-list
+    #- include: expressions
 
   block:
     - match: '\{'
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.block
       push:
         - meta_scope: meta.block.c
         - match: (?=^\s*#\s*(elif|else|endif)\b)
@@ -625,7 +823,7 @@ contexts:
   keywords-parens:
     - match: '\b(sizeof)\b\s*(\()'
       captures:
-        1: keyword.operator.word.c
+        1: keyword.operator.word.c debug.keywords-parens
         2: meta.group.c punctuation.section.group.begin.c
       push:
         - meta_content_scope: meta.group.c
@@ -798,7 +996,8 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c
+        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-global
+        - meta_include_prototype: false
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -822,7 +1021,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-global
     - match: \{
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-global
       set: preprocessor-block-if-branch-global
     - include: preprocessor-global
     - include: negated-block
@@ -928,7 +1127,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c
+        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-statements
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1147,7 +1346,8 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c
+        - meta_scope: meta.preprocessor.c debug.preprocessor-other
+        - meta_include_prototype: false
         - include: preprocessor-line-continuation
         - include: preprocessor-line-ending
         - include: preprocessor-comments
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 838d21b7cb..4100526991 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -13,6 +13,8 @@ int main(){
 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */
 /*                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group meta.group */
+/*                                                                     ^^^^^^ storage.type */
+/*                                                                            ^ support.type */
 /* <- keyword.control.import.define */
 /*      ^ entity.name.constant.preprocessor */
 /*                                        ^ comment.block */
@@ -56,7 +58,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 */
@@ -69,6 +71,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 */
@@ -263,16 +271,20 @@ struct point
 /* ^ storage.type */
 /*     ^ entity.name.struct */
 {
+/* <- meta.struct.c meta.block.c punctuation.section.block.begin.c */
     int x;
     int y;
 }
+/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
 
 struct point2 {
 /* ^ storage.type */
 /*     ^ entity.name.struct */
+/*            ^ meta.struct.c meta.block.c punctuation.section.block.begin.c */
     int x;
     int y;
 }
+/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
 
 int main(void) {
 /*  ^^^^ entity.name.function */
@@ -280,39 +292,114 @@ int main(void) {
 }
 
 struct point get_point() {}
-/*           ^^^^^^^^^^^^^^ meta.function */
+/*           ^^^^^^^^^  meta.function */
+/*                    ^^ meta.function.parameters */
+/*                       ^^ meta.function */
 /*                    ^^ meta.function.parameters */
 /*                       ^^ meta.block */
 /*                       ^ punctuation.section.block.begin
 /*                        ^ punctuation.section.block.end
-/* ^ storage.type */
-/*     ^ - entity.name.struct */
+/* <- storage.type */
+/*     ^ support.type - entity.name.struct */
 /*           ^ entity.name.function */
 
-struct point **alloc_points();
-/* ^ storage.type */
-/*     ^ - entity.name.struct */
-/*           ^^ keyword.operator */
-/*             ^ entity.name.function */
+inline struct point **alloc_points();
+/*     ^ storage.type */
+/*            ^ support.type - entity.name.struct */
+/*                  ^^ storage.modifier.c */
+/*                    ^ entity.name.function */
 
 struct point* alloc_point();
+/* <- storage.type.c */
+/*     ^^^^^ meta.struct.c support.type.c */
+/*          ^ storage.modifier.c */
 /*                  ^ entity.name.function - variable.function */
 
-struct point FOO_API *alloc_point3();
+struct point FOO_API *alloc_point3(), alloc_point2(), struct_var2;
+/* <- storage.type.c */
+/*     ^^^^^ meta.struct.c support.type.c */
+/*                   ^ storage.modifier.c */
 /*                     ^ entity.name.function - variable.function */
+/*                                  ^ punctuation.separator */
+/*                                    ^ entity.name.function - variable.function */
+/*                                                    ^^^^^^^^^^^ variable.other.c */
+
+struct {
+/* <- storage.type.c */
+/*     ^ meta.struct.c meta.block.c punctuation.section.block.begin.c */
+  int a;
+/*^^^ storage.type.c */
+/*    ^ variable.other.c */
+} anon_s, *anon_b, anon_s_f(), anon_c = {
+/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+/*^^^^^^ variable.other.c  */
+/*         ^^^^^^ variable.other.c  */
+/*                 ^^^^^^^^ entity.name.function.c  */
+/*                             ^^^^^^ variable.other.c  */
+/*                                    ^ keyword.operator.assignment.c */
+  .a = 4
+}, anon_d = {.a = 6}, anon_arr[] = {{.a = 1}, {.a = 2}}, anon_g;
+ /* <- punctuation.separator */
+/* ^^^^^^ variable.other.c  */
+/*        ^ keyword.operator.assignment.c */
+/*                  ^ punctuation.separator */
+/*                    ^^^^^^^^ variable.other.c  */
+/*                            ^^ meta.brackets.c storage.modifier.c */
+/*                               ^ keyword.operator.assignment.c */
+/*                                                     ^ punctuation.separator */
+/*                                                       ^^^^^^ variable.other.c  */
+/*                                                             ^ punctuation.terminator.c */
+
+static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
+    __le64 __iomem *regs);
+
+typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
+// TODO
 
 int main(void)
 {
     struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10};
-/*         ^ - entity.name */
-/*                        ^ - entity.name */
+/*  ^^^^^^ storage.type */
+/*         ^ support.type - entity.name */
+/*                        ^ variable.other - entity.name */
 }
 
-struct foo MACRO {
-/*     ^ entity.name.struct */
-/*         ^ - entity.name */
+struct MACRO foo {
+/*     ^ variable.annotation - entity.name - support.type*/
+/*           ^ entity.name.struct */
 }
 
+struct UI_BoundingBox position;
+/*     ^ support.type.c - entity.name */
+/*                     ^ variable.other - entity.name */
+
+struct UI_BoundingBox *position_p;
+/*     ^ support.type.c - entity.name */
+/*                     ^ variable.other - entity.name */
+
+struct UI_BoundingBox * position_p1;
+/*     ^ support.type.c - entity.name */
+/*                      ^ variable.other - entity.name */
+
+struct UI_BoundingBox **position_p2;
+/*     ^ support.type.c - entity.name */
+/*                      ^ variable.other - entity.name */
+
+struct UI_BoundingBox ** position_p3;
+/*     ^ support.type.c - entity.name */
+/*                       ^ variable.other - entity.name */
+
+
+struct UI_BoundingBox ** position_p4, position_p5, * position_p6;
+/*     ^ support.type.c - entity.name */
+/*                       ^ variable.other - entity.name */
+/*                    ^^ storage.modifier.c */
+/*                                  ^ punctuation.separator */
+/*                                    ^ variable.other - entity.name */
+/*                                               ^ punctuation.separator */
+/*                                                 ^ storage.modifier.c */
+/*                                                   ^ variable.other - entity.name */
+
 // Partially-typed
 struct foo
 /*     ^ entity.name */
@@ -321,17 +408,297 @@ struct UI_MenuBoxData
 /* <- storage.type */
 /*     ^ entity.name.struct */
 {
+/* <- meta.struct.c meta.block.c punctuation.section.block.begin.c */
     struct UI_BoundingBox position;
-/*         ^ - entity.name */
-/*                        ^ - entity.name */
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^ variable.other.c - entity.name */
+    struct UI_BoundingBox *position_p;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^ storage.modifier.c */
+/*                         ^ variable.other.c - entity.name */
+    struct UI_BoundingBox * position_p1;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^ storage.modifier.c */
+/*                          ^ variable.other.c - entity.name */
+    struct UI_BoundingBox **position_p2;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^^ storage.modifier.c */
+/*                          ^ variable.other.c - entity.name */
+    struct UI_BoundingBox ** position_p3;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^^ storage.modifier.c */
+/*                           ^ variable.other.c - entity.name */
+    struct UI_BoundingBox* position_p4;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                       ^ storage.modifier.c */
+/*                         ^ variable.other.c - entity.name */
+    struct UI_BoundingBox** position_p5;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                       ^^ storage.modifier.c */
+/*                          ^ variable.other.c - entity.name */
+    struct UI_BoundingBox * * position_p5;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^ storage.modifier.c */
+/*                          ^ storage.modifier.c */
+/*                            ^ variable.other.c - entity.name */
+    struct UI_BoundingBox *pos_1, *pos_1;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                        ^ storage.modifier.c */
+/*                         ^ variable.other.c - entity.name */
+/*                                ^ storage.modifier.c */
+/*                                 ^ variable.other.c - entity.name */
+
+    const volatile struct UI_BoundingBox *cv_p;
+/*  ^^^^^ storage.modifier.c */
+/*        ^^^^^^^^ storage.modifier.c */
+/*                 ^^^^^^ storage.type */
+/*                        ^ support.type.c - entity.name */
+/*                                       ^ storage.modifier.c */
+/*                                        ^ variable.other.c - entity.name */
+
+    long resume_done[USB_MAXCHILDREN];
+/*  ^^^^ storage.type.c */
+/*       ^^^^^^^^^^^ variable.other.c */
+/*                  ^^^^^^^^^^^^^^^^^ meta.brackets.c */
+/*                  ^ punctuation.section.brackets.begin.c */
+/*                   ^^^^^^^^^^^^^^^ support.constant.c */
+/*                                  ^ punctuation.section.brackets.end.c */
+
+    struct xhci_run_regs __iomem *run_regs;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                       ^ - entity.name */
+/*                               ^ storage.modifier.c */
+/*                                 ^ variable.other.c - entity.name */
+    struct xhci_run_regs __attribute__((noderef)) *run_regs;
+/*  ^^^^^^ storage.type */
+/*         ^ support.type.c - entity.name */
+/*                       ^ - entity.name */
+/*                                                ^ storage.modifier.c */
+/*                                                 ^ variable.other.c - entity.name */
+
+    struct __attribute__((noderef)) xhci_run_regs *run_regs;
+/*  ^^^^^^ storage.type */
+/*                                  ^ support.type.c - entity.name */
+/*                                                ^ storage.modifier.c */
+/*                                                 ^ - entity.name */
+    struct nested_t {
+/*  ^^^^^^ storage.type */
+/*         ^^^^^^^^ entity.name.struct.c */
+/*                  ^ meta.struct.c meta.block.c meta.struct.c meta.block.c punctuation.section.block.begin.c */
+        int bar;
+/*      ^^^ storage.type.c */
+/*          ^^^ variable.other.c */
+    } nested;
+/*    ^^^^^^ variable.other.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 */
     unsigned int paddingX;
     unsigned int paddingY;
     struct UI_ScrollBoxText boxContents[];
+/*  ^^^^^^ storage.type */
 /*         ^ - entity.name */
 /*                          ^ - entity.name */
+
+    struct delayed_work monitor_work ____cacheline_aligned_in_smp;
+/*  ^^^^^^ storage.type */
+    const struct efx_channel_type *
+/*  ^^^^^storage.modifier.c */
+/*        ^^^^^^ storage.type.c */
+/*               ^^^^^^^^^^^^^^^^ support.type - entity.name */
+/*                                ^ storage.modifier.c */
+    extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
+/*  ^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */
+/*                     ^^^^^^^^^^^^^^^^^^^^^^ support.constant.c */
+/*                    ^ punctuation.section.brackets.begin.c storage.modifier.c */
+/*                                           ^ punctuation.section.brackets.end.c storage.modifier.c */
+
+#if 0
+    struct UI_BoundingBox bb1;
+/*  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.block.preprocessor.if-branch.c */
+#else
+    struct UI_BoundingBox bb1;
+#endif
+};
+/* <- meta.struct.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 {
+/* <- storage.type */
+/*     ^ meta.attribute.c storage.modifier.c */
+/*                             ^^^^^^^ entity.name.struct */
+    int foo;
+/*  ^^^ storage.type.c */
+/*      ^^^ variable.other.c */
+};
+
+struct child_t child1;
+
+struct __attribute__((packed)) child_t_line
+/* <- storage.type */
+/*     ^ meta.attribute.c storage.modifier.c */
+/*                             ^^^^^^^ entity.name.struct */
+{
+    int foo;
+/*  ^^^ storage.type.c */
+/*      ^^^ variable.other.c */
+};
+
+struct __attribute__((packed))
+/* <- storage.type */
+/*     ^ meta.attribute.c storage.modifier.c */
+{
+/* <- meta.struct.c meta.block.c punctuation.section.block.begin.c */
+    int foo;
+/*  ^^^ storage.type.c */
+/*      ^^^ variable.other.c */
+};
+/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+
+struct rproc_ops {
+/* <- storage.type */
+/*     ^ entity.name.struct */
+/*               ^ meta.struct.c meta.block.c punctuation.section.block.begin.c */
+    int (*start)(struct rproc *rproc);
+/*  ^^^ storage.type.c */
+/*        ^^^^^ variable.other.c */
+/*               ^^^^^^ storage.type.c */
+/*                      ^^^^^ support.type.c */
+/*                             ^^^^^ variable.parameter.c */
+    int (*start)(struct rproc *);
+/*  ^^^ storage.type.c */
+/*        ^^^^^ variable.other.c */
+/*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
+/*               ^^^^^^ storage.type.c */
+/*                      ^^^^^ support.type.c */
+/*                            ^ storage.modifier.c */
+/*                             ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */
+    int (*start)(struct rproc *, struct rproc *);
+/*  ^^^ storage.type.c */
+/*        ^^^^^ variable.other.c */
+/*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
+/*               ^^^^^^ storage.type.c */
+/*                      ^^^^^ support.type.c */
+/*                            ^ storage.modifier.c */
+/*                             ^ punctuation.separator.c */
+/*                               ^^^^^^ storage.type.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 */
+/*           ^^^^^^^^ variable.other.c */
+/*                     ^^^^^^ storage.type.c */
+/*                            ^^^^^ support.type.c */
+/*                                   ^^^^^ variable.parameter.c */
+/*                                          ^^^ support.type */
+/*                                              ^^ variable.parameter */
+/*                                                  ^^^ storage.type */
+/*                                                      ^^^ variable.parameter */
+    struct resource_table *(*find_loaded_rsc_table)(
+/*  ^^^^^^ storage.type.c */
+/*         ^^^^^^^^^^^^^^ support.type.c */
+/*                           ^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+                struct rproc *rproc, const struct firmware *fw);
+/*              ^^^^^^ storage.type.c */
+/*                     ^^^^^ support.type.c */
+/*                           ^ storage.modifier.c */
+/*                            ^^^^^ variable.parameter.c */
+/*                                 ^ punctuation.separator */
+/*                                   ^^^^^ storage.modifier.c */
+/*                                         ^^^^^^ storage.type.c */
+/*                                                ^^^^^^^^ support.type.c */
+/*                                                          ^^ variable.parameter.c */
+};
+/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+
+void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
+/* <- storage.type.c */
+/*       ^^^^^^^^ variable.other.c */
+/*                 ^^^^^^ storage.type.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)(
+/* <- storage.type.c */
+/*     ^^^^^^^^^^^^^^ support.type.c */
+/*                       ^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+            struct rproc *rproc, const struct firmware *fw);
+/*          ^^^^^^ storage.type.c */
+/*                 ^^^^^ support.type.c */
+/*                       ^ storage.modifier.c */
+/*                        ^^^^^ variable.parameter.c */
+/*                             ^ punctuation.separator */
+/*                               ^^^^^ storage.modifier.c */
+/*                                     ^^^^^^ storage.type.c */
+/*                                            ^^^^^^^^ support.type.c */
+/*                                                     ^ storage.modifier.c */
+/*                                                      ^^ variable.parameter.c */
+
+static const struct pci_driver my_driver __pci_driver = {
+  .ops      = &pci_my_device_ops,
+  .vendor   = PCI_VENDOR_ID,
+  .devices  = pci_device_ids,
+};
+
+static const struct spd_info {
+/*           ^^^^^^ meta.struct.c storage.type.c */
+/*                  ^^^^^^^^ entity.name.struct.c */
+    size_t spd_len;
+/*  ^^^^^^ support.type */
+/*         ^^^^^^^ variable.other.c */
+    size_t spd_part_len;
+/*  ^^^^^^ support.type */
+/*         ^^^^^^^ variable.other.c */
+} spd_mem_info[] = {
+/*^^^^^^^^^^^^  variable.other.c */
+/*            ^^ meta.brackets.c storage.modifier.c */
+    [SPD_INFO_DDR4] = {
+        .spd_len = SPD_DDR4_LENGTH,
+        .spd_part_len = SPD_DDR4_PART_LEN,
+    },
+    [SPD_INFO_DEFAULT] = {
+        .spd_len = SPD_DEFAULT_LENGTH,
+        .spd_part_len = SPD_DEFAULT_PART_LEN,
+    },
+};
+
+enum {
+/* <- storage.type */
+    ENUM_A,
+/*  ^ constant.other.enum.c */
+/*        ^ punctuation.separator.c */
+    ENUM_B = 6,
+/*  ^ constant.other.enum.c */
+/*         ^ keyword.operator.assignment */
+/*           ^ constant.numeric.c */
+/*            ^ punctuation.separator.c */
+    ENUM_C
+/*  ^ constant.other.enum.c */
 };
 
 /////////////////////////////////////////////
@@ -434,7 +801,7 @@ int /* comment */ * myfunc
 (int * a)
 /*^^^^^^^ meta.function.parameters meta.group */
 /* <- punctuation.section.group.begin */
-/*   ^ keyword.operator */
+/*   ^ storage.modifier */
 /*     ^ variable.parameter */
 /*      ^ punctuation.section.group.end */
 {
@@ -449,7 +816,7 @@ func_name() {
 }
 
 MACRO1 void * MACRO2 myfuncname () {
-/*                   ^^^^^^^^^^^^^^^ meta.function */
+/*                   ^^^^^^^^^^ meta.function */
 /*                              ^^ meta.function.parameters */
 /*                                 ^ meta.block punctuation.section.block.begin
 /*     ^ storage.type */
diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp
index 6a319a1ac3..a86082e8ca 100644
--- a/C++/syntax_test_cpp.cpp
+++ b/C++/syntax_test_cpp.cpp
@@ -237,6 +237,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
+/* <- storage.type */
+/*     ^ 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
 /////////////////////////////////////////////
@@ -478,7 +528,7 @@ template <typename T = float, int a = 3, bool b = true>
                   /*                  ^ meta.template constant.numeric              */
                   /*                            ^ meta.template keyword.operator    */
                   /*                              ^ meta.template constant.language */
-struct Foo 
+struct Foo
 {
 
 /* <- meta.struct - meta.template */
@@ -515,7 +565,7 @@ template<class T, class U = T> class B { /* ... */ };
 /*                            ^ - meta.template            */
 template <class ...Types> class C { /* ... */ };
 
-// templates inside templates... it's templates all the way down 
+// templates inside templates... it's templates all the way down
 template<template<class> class P> class X { /* ... */ };
 /*      ^ meta.template punctuation                              */
 /*               ^ meta.template meta.template punctuation       */
@@ -615,7 +665,7 @@ int main() {
 
 // Example from section 14.2/4 of
 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf
-struct X 
+struct X
 {
     template <std::size_t>
     X* alloc();
@@ -623,12 +673,12 @@ struct X
     template <std::size_t>
     static X* adjust();
 };
-template <class T> 
-void f(T* p) 
+template <class T>
+void f(T* p)
 {
     // Be optimistic: scope it as a template member function call anyway.
     T* p1 = p->alloc<200>(); // ill-formed: < means less than
-    
+
     T* p2 = p->template alloc<200>(); // OK: < starts template argument list
     /*        ^ punctuation.accessor           */
     /*         ^ storage.type - variable.other */
@@ -636,7 +686,7 @@ void f(T* p)
 
     // Be optimistic: scope it as a template member function call anyway.
     T::adjust<100>(); // ill-formed: < means less than
-    
+
     T::template adjust<100>(); // OK: < starts template argument list
     /* <- - variable.function                    */
     /*^ punctuation.accessor                     */
@@ -1783,7 +1833,7 @@ class Foo {
                                  /* ^ meta.method.constructor.initializer-list   */
                                  /*   ^ - meta.function-call - variable.function */
 private:
-    int var1, var2, var3, var4;    
+    int var1, var2, var3, var4;
 };
 
 class X {

From 26d0b657c6cf7a5243a273adab3bf7ad8b94d052 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 5 Mar 2019 09:43:24 -0700
Subject: [PATCH 02/55] Fix typedef with struct

I chose to mark the struct name in a typedef as an entity because it's
still possible to use `struct MyStruct` in code so we should be able to
navigate to the symbol if it's referenced that way.
---
 C++/C.sublime-syntax |  86 +++++++++++++++++++++++++++++++-----
 C++/syntax_test_c.c  | 103 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 175 insertions(+), 14 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index db398b2ea5..6b1d280206 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -402,6 +402,7 @@ contexts:
       pop: true
 
   global-maybe-function:
+    - meta_scope: debug.global-maybe-function
     - include: comments
     # Consume pointer info, macros and any type info that was offset by macros
     - match: \*
@@ -494,6 +495,7 @@ contexts:
         - include: statements
 
   data-structures:
+    - meta_scope: debug.data-structures
     # Detect variable type definitions using struct/enum/union followed by a tag
     - match: '\b({{before_tag}})(?=\s+{{identifier}}(?:\s+{{identifier}})*(?:\s*\*\s*|\s)+{{identifier}}\s*[,=;\[])'
       scope: storage.type.c
@@ -585,6 +587,38 @@ contexts:
       scope: punctuation.separator debug.variable-identifier-list
     - include: or_pop
 
+  struct-keyword-typedef:
+    - match: '\bstruct\b'
+      scope: storage.type.c
+      push:
+        - meta_scope: meta.struct.c debug.struct-keyword-typedef
+        - match: \*
+          scope: storage.modifier.c
+        - match: '(?={{identifier}}\s*;)'
+          pop: true
+          comment: Let the typedef scope handle the entity
+        - match: '{{identifier}}(?=\s*{|\s*\n)'
+          scope: entity.name.struct.c
+          comment: Struct definition
+          set: struct-body-typedef
+        - match: '(?={)'
+          comment: Anonymous struct definition
+          set: struct-body-typedef
+        - match: '{{identifier}}'
+          scope: support.type.c
+        - include: or_pop
+  struct-body-typedef:
+    - match: '\{'
+      scope: punctuation.section.block.begin.c
+      push:
+        - meta_scope: meta.struct.c meta.block.c debug.struct-body-typedef
+        - match: '\}'
+          scope: punctuation.section.block.end.c
+          comment: Let the typedef handle the entity
+          pop: true
+        - include: data-structures-body
+    - include: or_pop
+
   struct-keyword-parameter:
     - match: '\bstruct\b'
       scope: storage.type.c
@@ -610,24 +644,24 @@ contexts:
         - match: '{{identifier}}(?=\s*{|\s*\n)'
           scope: entity.name.struct.c
           comment: Struct definition
-          set: struct-body
+          set: struct-body-global
         - match: '(?={)'
           comment: Anonymous struct definition
-          set: struct-body
+          set: struct-body-global
         - match: '{{identifier}}'
           scope: support.type.c debug.data-structures-struct-definition
           comment: Type for variable declaration
           set: variable-identifier-list
         - include: or_pop
-  struct-body:
+  struct-body-global:
     - match: '\{'
       scope: punctuation.section.block.begin.c
       push:
-        - meta_scope: meta.struct.c meta.block.c debug.struct-body
+        - meta_scope: meta.struct.c meta.block.c debug.struct-body-global
         - match: '\}'
           scope: punctuation.section.block.end.c
           set:
-            - meta_scope: debug.struct-body.struct-end
+            - meta_scope: debug.struct-body-global.struct-end
             - match: '\n'
               comment: >
                 Struct body declarations should normally have an identifier
@@ -638,7 +672,6 @@ contexts:
               pop: true
             - include: variable-identifier-list
             - include: or_pop
-        - include: struct-keyword
         - include: data-structures-body
     - include: or_pop
 
@@ -836,13 +869,46 @@ contexts:
     - match: \btypedef\b
       scope: storage.type.c
       push:
-        - match: ({{identifier}})?\s*(?=;)
+        - meta_scope: debug.typedef
+        - match: ({{identifier}})(?=\s*;)
           captures:
             1: entity.name.type.typedef.c
           pop: true
-        - match: \b(struct)\s+({{identifier}})
-          captures:
-            1: storage.type.c
+        - match: '{{identifier}}(?=\s*\[)'
+          scope: entity.name.type.typedef.c debug.typedef.array
+          push:
+            - match: \[
+              scope: punctuation.section.brackets.begin.c storage.modifier.c
+              push:
+                - meta_scope: meta.brackets.c
+                - match: \]
+                  scope: punctuation.section.brackets.end.c storage.modifier.c
+                  pop: true
+                - include: expressions
+                # Expressions doesn't handle macro identifiers or enum constants
+                - match: '{{macro_identifier}}'
+                  scope: support.constant.c
+            - include: or_pop
+        - include: struct-keyword-typedef
+        - match: '\((?=\s*\*)'
+          scope: punctuation.section.group.begin debug.typedef.function-pointer
+          comment: Function pointers
+          set:
+            - meta_scope: meta.parens
+            - match: \)
+              scope: punctuation.section.parens.end
+              set:
+                - include: function-definition-params-group
+                - include: or_pop
+            - match: \*
+              scope: storage.modifier.c
+            - match: '{{identifier}}'
+              scope: entity.name.type.c debug.typedef.function-pointer
+            - include: or_pop
+        - match: \;
+          scope: punctuation.terminator.c
+          comment: Don't let expressions gobble up the ;
+          pop: true
         - include: expressions
 
   function-call:
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 4100526991..8bfac33de9 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -259,7 +259,7 @@ typedef int myint;
 
 typedef struct mystruct {
 /* <- storage.type */
-/*             ^ - entity */
+/*             ^ entity.name.struct.c */
 } mystruct;
 /* ^ entity.name.type */
 
@@ -351,10 +351,105 @@ struct {
 /*                                                             ^ punctuation.terminator.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 */
+/*                                   ^^^^^^ storage.type.c */
+/*                                          ^^^^^^^^ support.type.c */
+/*                                                   ^ storage.modifier.c */
+/*                                                    ^^^^ variable.parameter.c */
+/*                                                        ^ punctuation.separator.c */
     __le64 __iomem *regs);
-
-typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
-// TODO
+/*  ^^^^^^ support.type.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 */
+
+typedef void (*xhci_get_quirks_t)(struct device *d, struct xhci_hcd *);
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*            ^ storage.modifier.c */
+/*             ^^^^^^^^^^^^^^^^^ entity.name.type.c */
+/*                                ^^^^^^ storage.type.c */
+/*                                       ^^^^^^ support.type.c */
+/*                                              ^ storage.modifier.c */
+/*                                               ^ variable.parameter.c */
+/*                                                ^ punctuation.separator */
+/*                                                  ^^^^^^ storage.type.c */
+/*                                                         ^^^^^^^^ support.type.c */
+/*                                                                  ^ storage.modifier.c */
+
+typedef struct Node* (*get_node_t)(struct device *d, struct xhci_hcd *);
+/*<- storage.type.c */
+/*      ^^^^^^ storage.type.c */
+/*             ^^^^ support.type.c */
+/*                 ^ storage.modifier.c */
+/*                    ^ storage.modifier.c */
+/*                     ^^^^^^^^^^ entity.name.type.c */
+/*                                 ^^^^^^ storage.type.c */
+/*                                        ^^^^^^ support.type.c */
+/*                                               ^ storage.modifier.c */
+/*                                                ^ variable.parameter.c */
+/*                                                 ^ punctuation.separator */
+/*                                                   ^^^^^^ storage.type.c */
+/*                                                          ^^^^^^^^ support.type.c */
+/*                                                                   ^ storage.modifier.c */
+
+
+typedef struct Node Node;
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^^^^ support.type.c */
+/*                  ^^^^ entity.name.type.typedef.c */
+typedef struct Node* NodePtr;
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^^^^ support.type.c */
+/*                 ^ storage.modifier.c */
+/*                   ^^^^^^^ entity.name.type.typedef.c */
+
+typedef struct {
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^ meta.struct.c punctuation.section.block.begin.c */
+    int data1;
+/*  ^^^ storage.type.c */
+/*      ^^^^^ variable.other.c */
+} newtype;
+/* <- meta.struct.c punctuation.section.block.end.c */
+/*^^^^^^^ entity.name.type.typedef.c */
+
+typedef struct MyStruct {
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^^^^^^^^ entity.name.struct.c */
+/*                      ^ meta.struct.c punctuation.section.block.begin.c */
+    int data1;
+/*  ^^^ storage.type.c */
+/*      ^^^^^ variable.other.c */
+} newtype;
+/* <- meta.struct.c punctuation.section.block.end.c */
+/*^^^^^^^ entity.name.type.typedef.c */
+
+typedef char arrType[6];
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*           ^^^^^^^ entity.name.type */
+/*                  ^ storage.modifier */
+/*                   ^ constant.numeric.c */
+/*                    ^ storage.modifier */
+
+typedef char arrType[NUMBER_OF_ELEMENTS];
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*           ^^^^^^^ entity.name.type */
+/*                  ^ storage.modifier */
+/*                   ^^^^^^^^^^^^^^^^^^ support.constant.c */
+/*                                     ^ storage.modifier */
 
 int main(void)
 {

From ebbf5a2a1bae662d3c08f1dff6f403ecba956cdc Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 11 Mar 2019 13:00:19 -0600
Subject: [PATCH 03/55] Simplify all the data structure handling

The struct|union|enum keyword scopes now act like any other type. This
reduces the number of specific scopes required.
---
 C++/C.sublime-syntax | 436 +++++++++++++++++--------------------------
 C++/syntax_test_c.c  | 412 ++++++++++++++++++++++++++++------------
 2 files changed, 467 insertions(+), 381 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 6b1d280206..f6b8f5cd91 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -30,9 +30,6 @@ contexts:
       comment: Pop if nothing matched (whitespace are ignored).
       pop: true
 
-  prototype:
-    - include: comments
-
   main:
     - include: preprocessor-global
     - include: global
@@ -162,8 +159,8 @@ contexts:
       scope: support.function.C99.c
 
   types:
-    - include: struct-keyword
-    - match: \b({{basic_types}}|{{before_tag}})\b
+    - 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
       scope: support.type.sys-types.c
@@ -298,7 +295,9 @@ contexts:
   global:
     - include: early-expressions
     - match: '^\s*(?=\w+)'
-      push: global-modifier
+      push:
+        - global-modifier
+        - global-function-call
     - include: late-expressions
 
   statements:
@@ -335,109 +334,32 @@ contexts:
     - include: modifiers-parens
     - include: modifiers
     - include: types
-    - include: struct-keyword
     - include: function-call
     - match: ';'
       scope: punctuation.terminator.c
 
   ## C-specific contexts
 
-  global-modifier:
-    - meta_scope: debug.global-modifier
+  global-function-call:
+    - meta_scope: debug.global-function-call
     - include: comments
     - include: modifiers-parens
     - include: modifiers
-    - match: '(?=\S)'
-      set: global-type
-
-  global-type:
-    - meta_scope: debug.global-type
-    - include: comments
-    - match: \*
-      scope: keyword.operator.c
-    # If a struct/union/enum followed by a name that is not a macro or declspec
-    # then this is likely a return type of a function. This is uncommon.
-    - match: |-
-        (?x:
-          ({{before_tag}})
-          \s+
-          (?=
-            (?![[:upper:][:digit:]_]+\b|__declspec)
-            {{identifier}}
-            (\s+{{identifier}}(?!\s*[{=;])|\s*\*+)
-          )
-        )
-      captures:
-        1: storage.type.c debug.global-type
-      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
-    - include: struct-keyword
-    - match: '(?=\b({{control_keywords}})\b)'
-      pop: true
-    - match: '(?=\s)'
-      set: global-maybe-function
-    # Allow a macro call
-    - match: '({{identifier}})\s*(\()(?=[^\)]+\))'
-      captures:
-        1: variable.function.c
-        2: meta.group.c punctuation.section.group.begin.c
-      push:
-        - meta_scope: meta.function-call.c
-        - meta_content_scope: meta.group.c
-        - match: '\)'
-          scope: meta.group.c punctuation.section.group.end.c
-          pop: true
-        - include: expressions
-    - match: (?={{identifier}}\s*\()
-      set:
-        - include: function-call
-        - match: ''
-          pop: true
-    - include: types
-    - match: '{{identifier}}'
-    - match: (?=\W)
-      pop: true
+    - include: function-call
+    - include: or_pop
 
-  global-maybe-function:
-    - meta_scope: debug.global-maybe-function
+  global-modifier:
+    - meta_scope: debug.global-modifier
     - 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 debug.global
-      set: function-definition-params
-    - match: '\((?=\s*\*)'
-      scope: punctuation.section.group.begin debug.global-maybe-function.function-pointer
-      comment: Function pointers are not really functions, but variables
-      push:
-        - meta_scope: meta.parens
-        - match: \)
-          scope: punctuation.section.parens.end
-          set:
-            - include: function-definition-params-group
-            - include: or_pop
-        - match: \*
-          scope: storage.modifier.c
-        - match: '{{identifier}}'
-          scope: variable.other.c debug.global-maybe-function.function-pointer
-        - include: or_pop
     - match: '(?=\S)'
-      pop: true
+      set:
+        - variable-identifier-list
+        - typedef-types
 
   function-definition-params:
-    - meta_content_scope: meta.function.c
+    - meta_content_scope: meta.function.c debug.function-definition-params
     - include: comments
     - match: '(?=\()'
       set:
@@ -450,6 +372,7 @@ contexts:
       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
@@ -459,13 +382,29 @@ contexts:
           scope: storage.modifier.c
         - match: \.\.\.
           scope: keyword.operator.variadic.c
+        - include: modifiers
+        #- include: modifiers-parens
+        - match: '{{identifier}}(?=\s*\[)'
+          scope: variable.parameter.c
+          push:
+            - include: comments
+            - match: \[
+              scope: storage.modifier.c punctuation.section.brackets.begin
+              push:
+                - meta_scope: meta.brackets.c
+                - include: comments
+                - match: \]
+                  scope: storage.modifier.c punctuation.section.brackets.end
+                  pop: true
+            - include: or_pop
         - match: '{{identifier}}(?=\s*(\[|,|\)))'
           scope: variable.parameter.c
-        - include: struct-keyword-parameter
-        - include: expressions
+        - include: types
         - match: '{{identifier}}'
           scope: support.type.c
           comment: We match the variable name above
+        - match: ','
+          scope: punctuation.separator.c
         - include: preprocessor-line-continuation
 
   function-definition-continue:
@@ -489,24 +428,13 @@ contexts:
           pop: true
         - match: (?=^\s*#\s*(elif|else|endif)\b)
           pop: true
-        - match: '(?=({{before_tag}})([^(;]+$|.*\{))'
-          push: data-structures
-        - include: struct-keyword
         - include: statements
 
   data-structures:
     - meta_scope: debug.data-structures
-    # Detect variable type definitions using struct/enum/union followed by a tag
-    - match: '\b({{before_tag}})(?=\s+{{identifier}}(?:\s+{{identifier}})*(?:\s*\*\s*|\s)+{{identifier}}\s*[,=;\[])'
-      scope: storage.type.c
-    - match: '\benum\b'
-      scope: storage.type.c
-      set: data-structures-enum-definition
-    - match: '\bunion\b'
-      scope: storage.type.c
-      set: data-structures-union-definition
-    - match: '(?=\S)'
-      pop: true
+    - include: struct-keyword
+    - include: union-keyword
+    - include: enum-keyword
 
   macro-identifiers:
     - match: '{{macro_identifier}}'
@@ -534,13 +462,16 @@ contexts:
       scope: variable.parameter.c debug.parameter-variable-identifier
 
   variable-identifier-list:
+    - meta_scope: variable-identifier-list
+    - include: modifiers
     - include: modifiers-parens
     - match: \*
       scope: storage.modifier.c
-    - match: '{{identifier}}(?=\s*\()'
+    - match: '{{identifier}}(?=\s*\(|\s*\n)'
       scope: meta.function.c entity.name.function.c debug.variable-identifier-list.function-first
       set:
         - meta_scope: debug.variable-identifier-list.function
+        - include: comments
         - include: function-definition-params-group
         - include: function-definition-body
         - match: '(?=\S)'
@@ -584,111 +515,70 @@ contexts:
             - include: or_pop
         - include: or_pop
     - match: ','
-      scope: punctuation.separator debug.variable-identifier-list
+      scope: punctuation.separator.c debug.variable-identifier-list
+    - match: ';'
+      scope: punctuation.terminator.c
+      pop: true
     - include: or_pop
 
-  struct-keyword-typedef:
+  struct-keyword:
     - match: '\bstruct\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.struct.c debug.struct-keyword-typedef
-        - match: \*
-          scope: storage.modifier.c
-        - match: '(?={{identifier}}\s*;)'
-          pop: true
-          comment: Let the typedef scope handle the entity
+        - meta_scope: meta.struct.c debug.struct-keyword
+        - include: data-structures-definition-common-begin
         - match: '{{identifier}}(?=\s*{|\s*\n)'
           scope: entity.name.struct.c
           comment: Struct definition
-          set: struct-body-typedef
-        - match: '(?={)'
-          comment: Anonymous struct definition
-          set: struct-body-typedef
+          set: struct-body
         - match: '{{identifier}}'
           scope: support.type.c
+          comment: Struct declaration
+          pop: true
+        - match: '(?={)'
+          comment: Anonymous struct definition
+          set: struct-body
         - include: or_pop
-  struct-body-typedef:
+  struct-body:
+    - meta_scope: debug.struct-body
+    - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       push:
-        - meta_scope: meta.struct.c meta.block.c debug.struct-body-typedef
+        - meta_scope: meta.struct.body.c meta.block.c debug.struct-body.block
+        - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
-          comment: Let the typedef handle the entity
           pop: true
         - include: data-structures-body
     - include: or_pop
 
-  struct-keyword-parameter:
-    - match: '\bstruct\b'
-      scope: storage.type.c
-      push:
-        - meta_scope: meta.struct.c debug.struct-keyword-parameter
-        - match: '{{identifier}}'
-          scope: support.type.c
-          comment: Type for variable declaration
-          set:
-            - include: parameter-variable-identifier
-            - include: or_pop
-        - include: or_pop
-
-  struct-keyword:
-    - match: '\bstruct\b'
+  enum-keyword:
+    - match: '\benum\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.struct.c debug.struct-keyword
-        # - include: data-structures-definition-common-begin
-        # This handles __attribute__ and __declspec
-        - include: modifiers-parens
-        - include: macro-identifiers
+        - meta_scope: meta.enum.c debug.enum-keyword
+        - include: data-structures-definition-common-begin
         - match: '{{identifier}}(?=\s*{|\s*\n)'
-          scope: entity.name.struct.c
+          scope: entity.name.enum.c
           comment: Struct definition
-          set: struct-body-global
-        - match: '(?={)'
-          comment: Anonymous struct definition
-          set: struct-body-global
+          set: enum-body
         - match: '{{identifier}}'
-          scope: support.type.c debug.data-structures-struct-definition
-          comment: Type for variable declaration
-          set: variable-identifier-list
+          scope: support.type.c
+          comment: Struct declaration
+          pop: true
+        - match: '(?={)'
+          comment: Anonymous enum definition
+          set: enum-body
         - include: or_pop
-  struct-body-global:
-    - match: '\{'
-      scope: punctuation.section.block.begin.c
-      push:
-        - meta_scope: meta.struct.c meta.block.c debug.struct-body-global
-        - match: '\}'
-          scope: punctuation.section.block.end.c
-          set:
-            - meta_scope: debug.struct-body-global.struct-end
-            - match: '\n'
-              comment: >
-                Struct body declarations should normally have an identifier
-                afterwards or ; to terminate them. If the ; is missing we don't
-                want to grab an identifier from another line. Typically variable
-                names are on the same line as the }, so if we find a new line
-                treat it as a terminator.
-              pop: true
-            - include: variable-identifier-list
-            - include: or_pop
-        - include: data-structures-body
-    - include: or_pop
-
-  data-structures-enum-definition:
-    - meta_scope: meta.enum.c
-    - include: data-structures-definition-common-begin
-    - match: '{{identifier}}(?=\s*;)'
-      scope: entity.name.enum.forward-decl.c
-    - match: '{{identifier}}'
-      scope: entity.name.enum.c
-    - match: '(?=;)'
-      pop: true
+  enum-body:
+    - meta_scope: debug.enum-body
+    - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
         - meta_scope: meta.enum.c meta.block.c debug.data-structures-enum-definition
-        # Enums don't support methods so we have a simplified body
+        - include: comments
         - match: '\}'
           scope: meta.enum.c meta.block.c punctuation.section.block.end.c
           pop: true
@@ -696,10 +586,12 @@ contexts:
           scope: constant.other.enum.c
           push:
             - meta_scope: debug.data-structures-enum-definition.pre-assignment
+            - include: comments
             - match: '='
               scope: keyword.operator.assignment
               set:
                 - meta_scope: debug.data-structures-enum-definition.post
+                - 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.
@@ -711,36 +603,48 @@ contexts:
             - include: or_pop
         - match: ','
           scope: punctuation.separator.c
+    - include: or_pop
 
-        #- include: data-structures-body
-
-  data-structures-union-definition:
-    - meta_scope: meta.union.c
-    - include: data-structures-definition-common-begin
-    - match: '{{identifier}}(?=\s*;)'
-      scope: entity.name.union.forward-decl.c
-    - match: '{{identifier}}'
-      scope: entity.name.union.c
-    - match: '(?=;)'
-      pop: true
+  union-keyword:
+    - match: '\bunion\b'
+      scope: storage.type.c
+      push:
+        - meta_scope: meta.union.c debug.union-keyword
+        - include: data-structures-definition-common-begin
+        - match: '{{identifier}}(?=\s*{|\s*\n)'
+          scope: entity.name.union.c
+          comment: Struct definition
+          set: union-body
+        - match: '{{identifier}}'
+          scope: support.type.c
+          comment: Struct declaration
+          pop: true
+        - match: '(?={)'
+          comment: Anonymous union definition
+          set: union-body
+        - include: or_pop
+  union-body:
+    - meta_scope: debug.union-body
+    - include: comments
     - match: '\{'
-      scope: meta.block.c punctuation.section.block.begin.c
-      set:
-        - meta_content_scope: meta.union.c meta.block.c
+      scope: punctuation.section.block.begin.c
+      push:
+        - meta_scope: meta.union.body.c meta.block.c debug.union-body.block
+        - 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
+    #- include: macro-identifiers
     # Handle macros so they aren't matched as the class name
     - match: '\b[[:upper:][:digit:]_]+\b'
-      scope: macro
+      scope: variable.annotation.c
 
   data-structures-definition-common-end:
     - match: '(?=;)'
@@ -750,25 +654,12 @@ contexts:
     - include: preprocessor-data-structures
     - include: preprocessor-expressions
     - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon
-    - match: '(?={{before_tag}})'
-      push: data-structures
-    # - include: modifiers-parens
-    - include: struct-keyword
-    - match: '\b{{type_qualifier}}\b'
-      scope: storage.modifier.c
-    - match: '{{basic_types}}'
-      scope: storage.type.c
-      comment: Improve this to better match built-in types
-      push:
-        - meta_scope: debug.data-structures-body.variable-identifier
-        - include: variable-identifier-list
-    - match: '{{identifier}}'
-      scope: support.type.c
-      comment: Improve this to better match built-in types
+    - include: modifiers
+    - include: modifiers-parens
+    - match: '(?=\S)'
       push:
-        - meta_scope: debug.data-structures-body.variable-identifier
-        - include: variable-identifier-list
-    #- include: expressions
+        - variable-identifier-list
+        - typedef-types
 
   block:
     - match: '\{'
@@ -869,47 +760,66 @@ contexts:
     - match: \btypedef\b
       scope: storage.type.c
       push:
-        - meta_scope: debug.typedef
-        - match: ({{identifier}})(?=\s*;)
-          captures:
-            1: entity.name.type.typedef.c
-          pop: true
-        - match: '{{identifier}}(?=\s*\[)'
-          scope: entity.name.type.typedef.c debug.typedef.array
+        - typedef-identifier-list
+        - typedef-types
+  typedef-types:
+    - meta_scope: debug.typedef-types
+    - include: comments
+    - include: types
+    - match: ({{identifier}})(?!\s*;|\s*,|\s*;|\s*\[|\s*\()
+      captures:
+        1: support.type.c debug.typedef-types.identifier
+      comment: Must be a negative of typedef-identifier-list
+    - include: or_pop
+  typedef-identifier-list:
+    - meta_scope: debug.typedef-identifier-list
+    - include: comments
+    - match: \*
+      scope: storage.modifier.c
+    - match: ({{identifier}})(?=\s*;)
+      captures:
+        1: entity.name.type.typedef.c
+      pop: true
+    - match: ({{identifier}})(?=\s*,)
+      captures:
+        1: entity.name.type.typedef.c
+    - match: '{{identifier}}(?=\s*\[)'
+      scope: entity.name.type.typedef.c debug.typedef.array
+      push:
+        - match: \[
+          scope: punctuation.section.brackets.begin.c storage.modifier.c
           push:
-            - match: \[
-              scope: punctuation.section.brackets.begin.c storage.modifier.c
-              push:
-                - meta_scope: meta.brackets.c
-                - match: \]
-                  scope: punctuation.section.brackets.end.c storage.modifier.c
-                  pop: true
-                - include: expressions
-                # Expressions doesn't handle macro identifiers or enum constants
-                - match: '{{macro_identifier}}'
-                  scope: support.constant.c
-            - include: or_pop
-        - include: struct-keyword-typedef
-        - match: '\((?=\s*\*)'
-          scope: punctuation.section.group.begin debug.typedef.function-pointer
-          comment: Function pointers
+            - meta_scope: meta.brackets.c
+            - match: \]
+              scope: punctuation.section.brackets.end.c storage.modifier.c
+              pop: true
+            - include: expressions
+            # Expressions doesn't handle macro identifiers or enum constants
+            - match: '{{macro_identifier}}'
+              scope: support.constant.c
+        - include: or_pop
+    - match: '\((?=\s*\*)'
+      scope: punctuation.section.group.begin debug.typedef.function-pointer
+      comment: Function pointers
+      set:
+        - meta_scope: meta.parens
+        - match: \)
+          scope: punctuation.section.parens.end
           set:
-            - meta_scope: meta.parens
-            - match: \)
-              scope: punctuation.section.parens.end
-              set:
-                - include: function-definition-params-group
-                - include: or_pop
-            - match: \*
-              scope: storage.modifier.c
-            - match: '{{identifier}}'
-              scope: entity.name.type.c debug.typedef.function-pointer
+            - include: function-definition-params-group
             - include: or_pop
-        - match: \;
-          scope: punctuation.terminator.c
-          comment: Don't let expressions gobble up the ;
-          pop: true
-        - include: expressions
+        - match: \*
+          scope: storage.modifier.c
+        - match: '{{identifier}}'
+          scope: entity.name.type.c debug.typedef.function-pointer
+        - include: or_pop
+    - match: \,
+      scope: punctuation.separator.c
+    - match: \;
+      scope: punctuation.terminator.c
+      pop: true
+    - include: or_pop
+    # - include: expressions
 
   function-call:
     - match: (?={{identifier}}\s*\()
@@ -926,6 +836,8 @@ contexts:
               scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
               pop: true
             - include: expressions
+            - match: '{{identifier}}'
+              scope: variable.other.c
 
   ## Preprocessor for data-structures
 
@@ -1389,7 +1301,7 @@ contexts:
         # name of the function is on the subsequent line.
         - match: \s*({{identifier}})(?=\s*\()
           captures:
-            1: meta.function.c entity.name.function.c
+            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines
           set: function-definition-params
         - match: ^
           pop: true
@@ -1401,11 +1313,13 @@ contexts:
         1: variable.function.assumed-macro.c
         2: punctuation.section.group.begin.c
       push:
-        - meta_scope: meta.assumed-macro.c
+        - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
         - match: \)
           scope: punctuation.section.group.end.c
           pop: true
         - include: expressions
+        - match: '{{identifier}}'
+          scope: variable.other.c
 
   preprocessor-other:
     - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|else|line|pragma|undef))\b
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 8bfac33de9..508b4a812f 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -255,13 +255,167 @@ if (4) {
 
 typedef int myint;
 /* <- storage.type */
+/*      ^^^ storage.type.c */
 /*          ^ entity.name.type */
+/*               ^ punctuation.terminator.c */
+
+typedef unsigned long long ull_t,
+/* <- storage.type */
+/*      ^^^^^^^^ 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 {
 /* <- storage.type */
+/*      ^^^^^^ storage.type.c */
 /*             ^ entity.name.struct.c */
+/*                      ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
+  int a;
+/*^^^ storage.type.c */
+/*    ^ variable.other.c */
 } mystruct;
-/* ^ entity.name.type */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
+/*^^^^^^^^ entity.name.type */
+/*        ^ punctuation.terminator.c */
+
+typedef struct another
+/* <- storage.type */
+/*      ^^^^^^ storage.type.c */
+/*             ^ entity.name.struct.c */
+{
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
+  int f;
+/*^^^ storage.type.c */
+/*    ^ variable.other.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;
+/* <- storage.type */
+/*      ^^^^^^^^^ support.type.c */
+/*                ^^^^^^^^^^ entity.name.type.typedef.c */
+/*                          ^ punctuation.terminator.c */
+
+typedef another_t *anotherp_t;
+/* <- storage.type */
+/*      ^^^^^^^^^ 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 *);
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*            ^ storage.modifier.c */
+/*             ^^^^^^^^^^^^^^^^^ entity.name.type.c */
+/*                                ^^^^^^ storage.type.c */
+/*                                       ^^^^^^ support.type.c */
+/*                                              ^ storage.modifier.c */
+/*                                               ^ variable.parameter.c */
+/*                                                ^ punctuation.separator */
+/*                                                  ^^^^^^ storage.type.c */
+/*                                                         ^^^^^^^^ support.type.c */
+/*                                                                  ^ storage.modifier.c */
+
+typedef struct Node* (*get_node_t)(struct device *d, struct xhci_hcd *);
+/*<- storage.type.c */
+/*      ^^^^^^ storage.type.c */
+/*             ^^^^ support.type.c */
+/*                 ^ storage.modifier.c */
+/*                    ^ storage.modifier.c */
+/*                     ^^^^^^^^^^ entity.name.type.c */
+/*                                 ^^^^^^ storage.type.c */
+/*                                        ^^^^^^ support.type.c */
+/*                                               ^ storage.modifier.c */
+/*                                                ^ variable.parameter.c */
+/*                                                 ^ punctuation.separator */
+/*                                                   ^^^^^^ storage.type.c */
+/*                                                          ^^^^^^^^ support.type.c */
+/*                                                                   ^ storage.modifier.c */
+
+
+typedef struct Node Node;
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^^^^ support.type.c */
+/*                  ^^^^ entity.name.type.typedef.c */
+typedef struct Node* NodePtr;
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^^^^ support.type.c */
+/*                 ^ storage.modifier.c */
+/*                   ^^^^^^^ entity.name.type.typedef.c */
+
+typedef struct {
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^ meta.struct.body.c punctuation.section.block.begin.c */
+    int data1;
+/*  ^^^ storage.type.c */
+/*      ^^^^^ variable.other.c */
+} newtype;
+/* <- meta.struct.body.c punctuation.section.block.end.c */
+/*^^^^^^^ entity.name.type.typedef.c */
+
+typedef struct MyStruct {
+/*<- storage.type.c */
+/*      ^^^^^^storage.type.c */
+/*             ^^^^^^^^ entity.name.struct.c */
+/*                      ^ meta.struct.body.c punctuation.section.block.begin.c */
+    int data1;
+/*  ^^^ storage.type.c */
+/*      ^^^^^ variable.other.c */
+} newtype;
+/* <- meta.struct.body.c punctuation.section.block.end.c */
+/*^^^^^^^ entity.name.type.typedef.c */
+
+typedef char arrType[6];
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*           ^^^^^^^ entity.name.type */
+/*                  ^ storage.modifier */
+/*                   ^ constant.numeric.c */
+/*                    ^ storage.modifier */
+
+typedef char arrType[NUMBER_OF_ELEMENTS];
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*           ^^^^^^^ entity.name.type.typedef.c */
+/*                  ^ storage.modifier */
+/*                   ^^^^^^^^^^^^^^^^^^ support.constant.c */
+/*                                     ^ storage.modifier */
+
+typedef unsigned long ulong, *ulongptr;
+/*<- storage.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;
+/*<- storage.type.c */
+/*      ^^^^ storage.type.c */
+/*           ^^^^^ entity.name.enum.c */
+/*                  ^^^^ constant.other.enum.c */
+/*                      ^ punctuation.separator.c */
+/*                       ^^^^^ constant.other.enum.c */
+/*                              ^^^^^ entity.name.type.typedef.c */
+/*                                   ^ punctuation.terminator.c */
 
 /////////////////////////////////////////////
 // Data structures and return values
@@ -271,67 +425,103 @@ struct point
 /* ^ storage.type */
 /*     ^ entity.name.struct */
 {
-/* <- meta.struct.c meta.block.c punctuation.section.block.begin.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int x;
     int y;
 }
-/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 
 struct point2 {
 /* ^ storage.type */
 /*     ^ entity.name.struct */
-/*            ^ meta.struct.c meta.block.c punctuation.section.block.begin.c */
+/*            ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int x;
     int y;
 }
-/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 
 int main(void) {
 /*  ^^^^ entity.name.function */
 /*       ^^^^ storage.type */
 }
 
+enum codes get_code() {}
+/* <- storage.type */
+/*     ^ 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() {}
+/* <- storage.type */
+/*     ^ 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.function */
-/*                    ^^ meta.function.parameters */
-/*                       ^^ meta.block */
-/*                       ^ punctuation.section.block.begin
-/*                        ^ punctuation.section.block.end
 /* <- storage.type */
 /*     ^ 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 */
+
+EXPORT_SYMBOL(get_point);
+/* <- meta.function-call.c variable.function.c*/
+/*            ^^^^^^^^^ variable.other.c */
 
 inline struct point **alloc_points();
 /*     ^ storage.type */
 /*            ^ 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 variable.function.c*/
+/*            ^^^^^^^^^^^^ variable.other.c */
 
 struct point* alloc_point();
 /* <- storage.type.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.terminator.c */
 
 struct point FOO_API *alloc_point3(), alloc_point2(), struct_var2;
 /* <- storage.type.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 */
 /*                                                    ^^^^^^^^^^^ variable.other.c */
 
 struct {
 /* <- storage.type.c */
-/*     ^ meta.struct.c meta.block.c punctuation.section.block.begin.c */
+/*     ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int a;
 /*^^^ storage.type.c */
 /*    ^ variable.other.c */
 } anon_s, *anon_b, anon_s_f(), anon_c = {
-/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^ variable.other.c  */
 /*         ^^^^^^ variable.other.c  */
 /*                 ^^^^^^^^ entity.name.function.c  */
@@ -350,6 +540,37 @@ struct {
 /*                                                       ^^^^^^ variable.other.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 storage.type.c */
+/*                  ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
+/*                    ^^^ storage.type.c */
+/*                        ^ variable.other.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 variable.function.c */
+/*          ^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                           ^ punctuation.separator.c */
+  TP_PROTO(struct mmc_host *host, struct mmc_request *mrq)
+/*^^^^^^^^ meta.assumed-macro.c variable.function.assumed-macro.c */
+/*         ^^^^^^ storage.type.c */
+/*                ^^^^^^^^ support.type.c */
+/*                         ^ keyword.operator.c */
+/*                          ^^^^ variable.other.c */
+/*                              ^ punctuation.separator.c */
+/*                                ^^^^^^ storage.type.c */
+/*                                       ^^^^^^^^^^^ support.type.c */
+/*                                                   ^ keyword.operator.c */
+/*                                                    ^^^ variable.other.c */
+);
+
 static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 /*<- storage.modifier.c */
 /*     ^^^^^^ storage.modifier.c */
@@ -369,94 +590,11 @@ static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 /*                      ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */
 /*                       ^ punctuation.terminator.c */
 
-typedef void (*xhci_get_quirks_t)(struct device *d, struct xhci_hcd *);
-/*<- storage.type.c */
-/*      ^^^^ storage.type.c */
-/*            ^ storage.modifier.c */
-/*             ^^^^^^^^^^^^^^^^^ entity.name.type.c */
-/*                                ^^^^^^ storage.type.c */
-/*                                       ^^^^^^ support.type.c */
-/*                                              ^ storage.modifier.c */
-/*                                               ^ variable.parameter.c */
-/*                                                ^ punctuation.separator */
-/*                                                  ^^^^^^ storage.type.c */
-/*                                                         ^^^^^^^^ support.type.c */
-/*                                                                  ^ storage.modifier.c */
-
-typedef struct Node* (*get_node_t)(struct device *d, struct xhci_hcd *);
-/*<- storage.type.c */
-/*      ^^^^^^ storage.type.c */
-/*             ^^^^ support.type.c */
-/*                 ^ storage.modifier.c */
-/*                    ^ storage.modifier.c */
-/*                     ^^^^^^^^^^ entity.name.type.c */
-/*                                 ^^^^^^ storage.type.c */
-/*                                        ^^^^^^ support.type.c */
-/*                                               ^ storage.modifier.c */
-/*                                                ^ variable.parameter.c */
-/*                                                 ^ punctuation.separator */
-/*                                                   ^^^^^^ storage.type.c */
-/*                                                          ^^^^^^^^ support.type.c */
-/*                                                                   ^ storage.modifier.c */
-
-
-typedef struct Node Node;
-/*<- storage.type.c */
-/*      ^^^^^^storage.type.c */
-/*             ^^^^ support.type.c */
-/*                  ^^^^ entity.name.type.typedef.c */
-typedef struct Node* NodePtr;
-/*<- storage.type.c */
-/*      ^^^^^^storage.type.c */
-/*             ^^^^ support.type.c */
-/*                 ^ storage.modifier.c */
-/*                   ^^^^^^^ entity.name.type.typedef.c */
-
-typedef struct {
-/*<- storage.type.c */
-/*      ^^^^^^storage.type.c */
-/*             ^ meta.struct.c punctuation.section.block.begin.c */
-    int data1;
-/*  ^^^ storage.type.c */
-/*      ^^^^^ variable.other.c */
-} newtype;
-/* <- meta.struct.c punctuation.section.block.end.c */
-/*^^^^^^^ entity.name.type.typedef.c */
-
-typedef struct MyStruct {
-/*<- storage.type.c */
-/*      ^^^^^^storage.type.c */
-/*             ^^^^^^^^ entity.name.struct.c */
-/*                      ^ meta.struct.c punctuation.section.block.begin.c */
-    int data1;
-/*  ^^^ storage.type.c */
-/*      ^^^^^ variable.other.c */
-} newtype;
-/* <- meta.struct.c punctuation.section.block.end.c */
-/*^^^^^^^ entity.name.type.typedef.c */
-
-typedef char arrType[6];
-/*<- storage.type.c */
-/*      ^^^^ storage.type.c */
-/*           ^^^^^^^ entity.name.type */
-/*                  ^ storage.modifier */
-/*                   ^ constant.numeric.c */
-/*                    ^ storage.modifier */
-
-typedef char arrType[NUMBER_OF_ELEMENTS];
-/*<- storage.type.c */
-/*      ^^^^ storage.type.c */
-/*           ^^^^^^^ entity.name.type */
-/*                  ^ storage.modifier */
-/*                   ^^^^^^^^^^^^^^^^^^ support.constant.c */
-/*                                     ^ storage.modifier */
-
 int main(void)
 {
     struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10};
 /*  ^^^^^^ storage.type */
 /*         ^ support.type - entity.name */
-/*                        ^ variable.other - entity.name */
 }
 
 struct MACRO foo {
@@ -503,47 +641,55 @@ struct UI_MenuBoxData
 /* <- storage.type */
 /*     ^ entity.name.struct */
 {
-/* <- meta.struct.c meta.block.c punctuation.section.block.begin.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     struct UI_BoundingBox position;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ variable.other.c - entity.name */
+/*                                ^ punctuation.terminator.c */
     struct UI_BoundingBox *position_p;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
 /*                         ^ variable.other.c - entity.name */
+/*                                   ^ punctuation.terminator.c */
     struct UI_BoundingBox * position_p1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
 /*                          ^ variable.other.c - entity.name */
+/*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox **position_p2;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
 /*                          ^ variable.other.c - entity.name */
+/*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox ** position_p3;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
 /*                           ^ variable.other.c - entity.name */
+/*                                      ^ punctuation.terminator.c */
     struct UI_BoundingBox* position_p4;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ storage.modifier.c */
 /*                         ^ variable.other.c - entity.name */
+/*                                    ^ punctuation.terminator.c */
     struct UI_BoundingBox** position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^^ storage.modifier.c */
 /*                          ^ variable.other.c - entity.name */
+/*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox * * position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
 /*                          ^ storage.modifier.c */
 /*                            ^ variable.other.c - entity.name */
+/*                                       ^ punctuation.terminator.c */
     struct UI_BoundingBox *pos_1, *pos_1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
@@ -551,6 +697,7 @@ struct UI_MenuBoxData
 /*                         ^ variable.other.c - entity.name */
 /*                                ^ storage.modifier.c */
 /*                                 ^ variable.other.c - entity.name */
+/*                                      ^ punctuation.terminator.c */
 
     const volatile struct UI_BoundingBox *cv_p;
 /*  ^^^^^ storage.modifier.c */
@@ -559,7 +706,7 @@ struct UI_MenuBoxData
 /*                        ^ support.type.c - entity.name */
 /*                                       ^ storage.modifier.c */
 /*                                        ^ variable.other.c - entity.name */
-
+/*                                            ^ punctuation.terminator.c */
     long resume_done[USB_MAXCHILDREN];
 /*  ^^^^ storage.type.c */
 /*       ^^^^^^^^^^^ variable.other.c */
@@ -567,51 +714,71 @@ struct UI_MenuBoxData
 /*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^^^^^^^^^^^^^^^ support.constant.c */
 /*                                  ^ punctuation.section.brackets.end.c */
-
+/*                                   ^ punctuation.terminator.c */
     struct xhci_run_regs __iomem *run_regs;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ - entity.name */
 /*                               ^ storage.modifier.c */
 /*                                 ^ variable.other.c - entity.name */
+/*                                        ^ punctuation.terminator.c */
     struct xhci_run_regs __attribute__((noderef)) *run_regs;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ - entity.name */
 /*                                                ^ storage.modifier.c */
 /*                                                 ^ variable.other.c - entity.name */
-
+/*                                                         ^ punctuation.terminator.c */
     struct __attribute__((noderef)) xhci_run_regs *run_regs;
 /*  ^^^^^^ storage.type */
 /*                                  ^ support.type.c - entity.name */
 /*                                                ^ storage.modifier.c */
 /*                                                 ^ - entity.name */
+/*                                                         ^ punctuation.terminator.c */
     struct nested_t {
 /*  ^^^^^^ storage.type */
 /*         ^^^^^^^^ entity.name.struct.c */
-/*                  ^ meta.struct.c meta.block.c meta.struct.c meta.block.c punctuation.section.block.begin.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 */
 /*          ^^^ variable.other.c */
     } nested;
+/*  ^ meta.struct.body.c meta.block.c meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*    ^^^^^^ variable.other.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 */
+/*  ^^^^ storage.type.c */
+/*       ^^^^^^^^^^^^^^ support.type.c - entity.name */
+/*                      ^ variable.other.c - entity.name */
+/*                                ^ punctuation.terminator.c */
     unsigned int paddingX;
+/*  ^^^^^^^^ storage.type.c */
+/*           ^^^ storage.type.c */
+/*               ^^^^^^^^ variable.other.c */
+/*                       ^ punctuation.terminator.c */
     unsigned int paddingY;
+/*  ^^^^^^^^ storage.type.c */
+/*           ^^^ storage.type.c */
+/*               ^^^^^^^^ variable.other.c */
+/*                       ^ punctuation.terminator.c */
     struct UI_ScrollBoxText boxContents[];
-/*  ^^^^^^ storage.type */
-/*         ^ - entity.name */
-/*                          ^ - entity.name */
+/*  ^^^^^^ storage.type.c */
+/*         ^^^^^^^^^^^^^^^^ support.type.c */
+/*                          ^^^^^^^^^^^ variable.other.c */
+/*                                     ^ storage.modifier.c */
+/*                                       ^ punctuation.terminator.c */
 
     struct delayed_work monitor_work ____cacheline_aligned_in_smp;
 /*  ^^^^^^ storage.type */
+/*         ^^^^^^^^^^^^ support.type.c */
+/*                      ^^^^^^^^^^^^ support.type.c */
+/*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.c*/
+/*                                                               ^ punctuation.terminator.c */
     const struct efx_channel_type *
 /*  ^^^^^storage.modifier.c */
 /*        ^^^^^^ storage.type.c */
@@ -631,7 +798,7 @@ struct UI_MenuBoxData
     struct UI_BoundingBox bb1;
 #endif
 };
-/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+/* <- 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 */
@@ -662,17 +829,17 @@ struct __attribute__((packed))
 /* <- storage.type */
 /*     ^ meta.attribute.c storage.modifier.c */
 {
-/* <- meta.struct.c meta.block.c punctuation.section.block.begin.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int foo;
 /*  ^^^ storage.type.c */
 /*      ^^^ variable.other.c */
 };
-/* <- meta.struct.c meta.block.c punctuation.section.block.end.c */
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 
 struct rproc_ops {
 /* <- storage.type */
 /*     ^ entity.name.struct */
-/*               ^ meta.struct.c meta.block.c punctuation.section.block.begin.c */
+/*               ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int (*start)(struct rproc *rproc);
 /*  ^^^ storage.type.c */
 /*        ^^^^^ variable.other.c */
@@ -724,7 +891,7 @@ struct rproc_ops {
 /*                                                ^^^^^^^^ support.type.c */
 /*                                                          ^^ variable.parameter.c */
 };
-/* <- meta.struct.c meta.block.c punctuation.section.block.end.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 */
@@ -800,17 +967,20 @@ enum {
 // 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 storage.modifier.c */
 /*                         ^ punctuation.section.brackets.begin */
 /*                          ^ punctuation.section.brackets.end */
+/*                           ^^ meta.brackets.c storage.modifier.c */
+/*                           ^ punctuation.section.brackets.begin */
+/*                            ^ punctuation.section.brackets.end */
+/*                             ^ punctuation.section.group.end */
 {
 /* <- meta.function meta.block */
     myClass *result;
@@ -891,7 +1061,7 @@ 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 */
@@ -915,7 +1085,7 @@ MACRO1 void * MACRO2 myfuncname () {
 /*                              ^^ meta.function.parameters */
 /*                                 ^ meta.block punctuation.section.block.begin
 /*     ^ storage.type */
-/*          ^ keyword.operator */
+/*          ^ storage.modifier */
 /*                   ^ entity.name.function */
 
     label:
@@ -953,7 +1123,7 @@ static const uint32_t * const MACRO funcname();
 /* ^ storage.modifier */
 /*     ^ storage.modifier */
 /*           ^ support.type */
-/*                    ^ keyword.operator */
+/*                    ^ storage.modifier.c */
 /*                      ^ storage.modifier */
 /*                                  ^ entity.name.function */
 
@@ -977,6 +1147,8 @@ MACRO_CALL(int) macro_prefixed_func(){}
 /*              ^ entity.name.function */
 
 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

From 9f1e464781ae28ca92c38fbdbed8a95face0172a Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 11 Mar 2019 14:58:01 -0600
Subject: [PATCH 04/55] Fix highlighting for macro function calls

---
 C++/C.sublime-syntax |  34 +++++++-----
 C++/syntax_test_c.c  | 125 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 137 insertions(+), 22 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index f6b8f5cd91..910103b2ca 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -346,6 +346,8 @@ contexts:
     - include: modifiers-parens
     - include: modifiers
     - include: function-call
+    - match: ';'
+      scope: punctuation.terminator.c debug.global-function-call
     - include: or_pop
 
   global-modifier:
@@ -544,7 +546,7 @@ contexts:
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
-      push:
+      set:
         - meta_scope: meta.struct.body.c meta.block.c debug.struct-body.block
         - include: comments
         - match: '\}'
@@ -628,7 +630,7 @@ contexts:
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
-      push:
+      set:
         - meta_scope: meta.union.body.c meta.block.c debug.union-body.block
         - include: comments
         - match: '\}'
@@ -766,7 +768,7 @@ contexts:
     - meta_scope: debug.typedef-types
     - include: comments
     - include: types
-    - match: ({{identifier}})(?!\s*;|\s*,|\s*;|\s*\[|\s*\()
+    - match: ({{identifier}})(?!\s*;|\s*,|\s*;|\s*\[|\s*\(|\s*=)
       captures:
         1: support.type.c debug.typedef-types.identifier
       comment: Must be a negative of typedef-identifier-list
@@ -819,7 +821,6 @@ contexts:
       scope: punctuation.terminator.c
       pop: true
     - include: or_pop
-    # - include: expressions
 
   function-call:
     - match: (?={{identifier}}\s*\()
@@ -829,15 +830,22 @@ contexts:
         - match: '{{identifier}}'
           scope: variable.function.c
         - match: '\('
-          scope: meta.group.c punctuation.section.group.begin.c
+          scope: punctuation.section.group.begin.c
           set:
-            - meta_content_scope: meta.function-call.c meta.group.c
+            - meta_scope: meta.function-call.parameters.c meta.group.c debug.function-call.params
             - match : \)
               scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
               pop: true
+            # - include: macro-identifiers
+            - match: '{{macro_identifier}}(?!\()'
+              comment: Not sure I think we need this special case
+              scope: variable.annotation.c
             - include: expressions
             - match: '{{identifier}}'
               scope: variable.other.c
+            - match: '\b\w+\b'
+              scope: variable.other.c
+              comment: Inside macro params, the identifiers can start with numbers
 
   ## Preprocessor for data-structures
 
@@ -1137,7 +1145,7 @@ contexts:
     - include: statements
 
   preprocessor-if-branch-function-call:
-    - meta_content_scope: meta.function-call.c
+    - meta_content_scope: meta.function-call.c debug.preprocessor-if-branch-function-call
     - include: c99
     - match: '{{identifier}}'
       scope: variable.function.c
@@ -1146,7 +1154,7 @@ contexts:
       set: preprocessor-if-branch-function-call-arguments
 
   preprocessor-if-branch-function-call-arguments:
-    - meta_content_scope: meta.function-call.c meta.group.c
+    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments
     - match : \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       set: preprocessor-if-branch-statements
@@ -1161,7 +1169,7 @@ contexts:
     - include: expressions
 
   preprocessor-if-branch-function-call-arguments-finish:
-    - meta_content_scope: meta.function-call.c meta.group.c
+    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments-finish
     - match: \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       pop: true
@@ -1295,13 +1303,13 @@ contexts:
 
   preprocessor-convention-ignore-uppercase-ident-lines:
     - match: ^(\s*{{macro_identifier}})+\s*$
-      scope: meta.assumed-macro.c
+      scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-ident-lines
       push:
         # It's possible that we are dealing with a function return type on its own line, and the
         # name of the function is on the subsequent line.
         - match: \s*({{identifier}})(?=\s*\()
           captures:
-            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines
+            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines.params
           set: function-definition-params
         - match: ^
           pop: true
@@ -1310,7 +1318,7 @@ contexts:
   preprocessor-convention-ignore-uppercase-calls-without-semicolon:
     - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$)
       captures:
-        1: variable.function.assumed-macro.c
+        1: variable.function.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
         2: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
@@ -1369,4 +1377,4 @@ contexts:
             - match: ">"
               scope: punctuation.definition.string.end.c
               pop: true
-    - include: preprocessor-practical-workarounds
+    # - include: preprocessor-practical-workarounds
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 508b4a812f..968a7d1999 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -115,9 +115,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 */
+/*   ^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                     ^ keyword.operator.assignment.c */
 /*                       ^ constant.language */
+/*                                        ^ punctuation.terminator.c */
+/*                           ^ punctuation.separator.c */
+/*                             ^^^ variable.other.c*/
+/*                                 ^ keyword.operator.assignment.c */
+/*                                   ^^^^^ constant.language.c */
+/*                                        ^ punctuation.terminator.c */
 
 FOOBAR
 hello() {
@@ -142,20 +150,26 @@ UserStructCompare (
 }
 
 LIB_RESULT
+/* <- support.type.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()
+/* <- support.type.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 */
+/* <- support.type */
 
 int main() {
 /* <- storage.type */
@@ -202,19 +216,19 @@ int disabled_func() {
 #endif
 
 FOO
-/* <- meta.assumed-macro */
+/* <- support.type */
 FOO;
-/* <- - meta.assumed-macro */
+/* <- variable.other */
 foo
-/* <- - meta.assumed-macro */
+/* <- support.type */
 ; // fix highlighting
 /* <- punctuation.terminator */
 FOO()
-/* <- meta.assumed-macro variable.function.assumed-macro */
+/* <- meta.function-call.c variable.function.c */
 FOO();
-/* <- - meta.assumed-macro */
+/* <- meta.function-call.c variable.function.c */
 foo()
-/* <- - meta.assumed-macro */
+/* <- meta.function-call.c variable.function.c */
 ; // fix highlighting
 /* <- punctuation.terminator */
 
@@ -559,7 +573,7 @@ TRACE_EVENT(mmc_request_start,
 /*          ^^^^^^^^^^^^^^^^^ variable.other.c */
 /*                           ^ punctuation.separator.c */
   TP_PROTO(struct mmc_host *host, struct mmc_request *mrq)
-/*^^^^^^^^ meta.assumed-macro.c variable.function.assumed-macro.c */
+/*^^^^^^^^ variable.function */
 /*         ^^^^^^ storage.type.c */
 /*                ^^^^^^^^ support.type.c */
 /*                         ^ keyword.operator.c */
@@ -571,6 +585,99 @@ TRACE_EVENT(mmc_request_start,
 /*                                                    ^^^ variable.other.c */
 );
 
+TRACE_EVENT(802154_rdev_add_virtual_intf,
+/* <-meta.function-call.c variable.function.c */
+/*         ^ meta.function-call.c punctuation.section.group.begin.c */
+/*          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                                      ^ 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
+/*  ^^^^^^^^^^^^^^ variable.annotation.c */
+    __string(vir_intf_name, name ? name : "<noname>")
+/*  ^^^^^^^^ meta.function-call.c variable.function.c */
+/*          ^ punctuation.section.group.begin.c */
+/*           ^^^^^^^^^^^^^ variable.other.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 variable.function.c */
+/*         ^ punctuation.section.group.begin.c */
+/*          ^^^^ storage.type.c */
+/*               ^^^^^^^^^^^^^^^ support.type.c */
+/*                              ^ punctuation.separator.c */
+/*                                ^^^^ variable.other.c */
+/*                                    ^ punctuation.section.group.end.c */
+    __field(__le64, extended_addr)
+/*  ^^^^^^^ meta.function-call.c variable.function.c */
+/*         ^ punctuation.section.group.begin.c */
+/*          ^^^^^^ variable.other.c */
+/*                ^ punctuation.separator.c */
+/*                  ^^^^^^^^^^^^^ variable.other.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;
+/*  ^^^^^^^^^^^^^^^ variable.annotation.c */
+    __assign_str(vir_intf_name, name ? name : "<noname>");
+/*  ^^^^^^^^^^^^ meta.function-call.c variable.function.c */
+/*              ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
+/*               ^^^^^^^^^^^^^ variable.other.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.c */
+/*         ^^ punctuation.accessor.c */
+/*           ^^^^ variable.other.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 */
+/*          ^^^^^^^^^^^^^^^ variable.annotation */
+/*                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/
+/*                                                              ^ punctuation.separator.c */
+      WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
+/*    ^^^^^^^^^^^^^^^ variable.annotation */
+/*                   ^ punctuation.separator.c */
+/*                     ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                               ^^^^^^^^^^^^^ variable.other.c */
+/*                                             ^ punctuation.separator.c */
+/*                                               ^^^^^^^ variable.other.c */
+/*                                                      ^^ punctuation.accessor.c */
+/*                                                        ^^^^ variable.other.c */
+/*                                                            ^ punctuation.separator.c */
+      __le64_to_cpu(__entry->extended_addr))
+/*    ^^^^^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                  ^^^^^^^ variable.other.c */
+/*                         ^^ punctuation.accessor.c */
+/*                           ^^^^^^^^^^^^^ variable.other.c */
+/*                                        ^ meta.function-call.c meta.group.c punctuation.section.group.end.c */
+/*                                         ^ meta.function-call.c meta.group.c punctuation.section.group.end.c */
+);
+/* <- meta.function-call.c meta.group.c punctuation.section.group.end.c */
+ /* <- punctuation.terminator.c */
+
 static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 /*<- storage.modifier.c */
 /*     ^^^^^^ storage.modifier.c */

From fa0f4731b466de9094a1959a5d836e898a7c1652 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 11 Mar 2019 15:47:51 -0600
Subject: [PATCH 05/55] enums need to support pre-processor as well

This doesn't support disabling a block with `#if 0`. That requires that
we redefine `preprocessor-data-structures` since enum body has a different
context.
---
 C++/C.sublime-syntax |  2 +-
 C++/syntax_test_c.c  | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 910103b2ca..f95ebc6344 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -13,7 +13,6 @@ variables:
   macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars
   control_keywords: 'break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while'
   basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void'
-  before_tag: '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'
@@ -584,6 +583,7 @@ contexts:
         - match: '\}'
           scope: meta.enum.c meta.block.c punctuation.section.block.end.c
           pop: true
+        - include: preprocessor-expressions
         - match: '{{identifier}}'
           scope: constant.other.enum.c
           push:
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 968a7d1999..63b447d593 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1066,6 +1066,24 @@ enum {
 /*         ^ keyword.operator.assignment */
 /*           ^ constant.numeric.c */
 /*            ^ punctuation.separator.c */
+#ifdef ENABLED_FEATURE
+/* <- meta.preprocessor.c keyword.control.import.c */
+    ENUM_ENABLED,
+/*  ^^^^^^^^^^^^ constant.other.enum.c */
+#else
+/* <- meta.preprocessor.c keyword.control.import.c */
+    ENUM_DISABLED,
+/*  ^^^^^^^^^^^^^ constant.other.enum.c */
+#endif
+/* <- meta.preprocessor.c keyword.control.import.c */
+
+#if 0
+/* <- meta.preprocessor.c keyword.control.import.c */
+    ENUM_FIELD_DISABLED
+/*  ^^^^^^^^^^^^^^^^^^^ constant.other.enum.c */
+#endif
+/* <- meta.preprocessor.c keyword.control.import.c */
+
     ENUM_C
 /*  ^ constant.other.enum.c */
 };

From 9a2c107d18f66988d2e3a9ad0f6e30dd1349803a Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 1 Apr 2019 12:28:08 -0600
Subject: [PATCH 06/55] Fixed preprocessor attributes

linux kernel defines __macro as a prprocessor macro for setting
attributes. I also found this style in other firmware type C code.
---
 C++/C.sublime-syntax |  76 ++++++++++++++++++++----------
 C++/syntax_test_c.c  | 107 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 149 insertions(+), 34 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index f95ebc6344..12779c8526 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -11,6 +11,7 @@ scope: source.c
 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
   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'
   microsoft_types: '__int8|__int16|__int32|__int64'
@@ -136,6 +137,17 @@ contexts:
     - match: \b({{modifiers}})\b
       scope: storage.modifier.c
 
+  modifiers-macros:
+    - match: '{{attr_macro_identifier}}(?=\s*\()'
+      scope: variable.function.c
+      comment: Preprocessor Attributes with parameters
+      push:
+        - meta_scope: meta.function-call.c
+        - include: function-call-params
+    - match: '{{attr_macro_identifier}}(?!\s*->|\s*\.)'
+      scope: support.type.c # Should this be storage.modifier.c?
+      comment: Preprocessor Attributes
+
   variables:
     - match: '\bg[A-Z]\w*\b'
       scope: variable.other.readwrite.global.mac-classic.c
@@ -463,15 +475,16 @@ contexts:
       scope: variable.parameter.c debug.parameter-variable-identifier
 
   variable-identifier-list:
-    - meta_scope: variable-identifier-list
+    - meta_scope: debug.variable-identifier-list
     - 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 debug.variable-identifier-list.function-first
+      scope: entity.name.function.c debug.variable-identifier-list.function-first
       set:
-        - meta_scope: debug.variable-identifier-list.function
+        - meta_scope: meta.function.c debug.variable-identifier-list.function
         - include: comments
         - include: function-definition-params-group
         - include: function-definition-body
@@ -648,10 +661,6 @@ contexts:
     - match: '\b[[:upper:][:digit:]_]+\b'
       scope: variable.annotation.c
 
-  data-structures-definition-common-end:
-    - match: '(?=;)'
-      pop: true
-
   data-structures-body:
     - include: preprocessor-data-structures
     - include: preprocessor-expressions
@@ -767,6 +776,23 @@ contexts:
   typedef-types:
     - meta_scope: debug.typedef-types
     - include: comments
+    - include: modifiers
+    # Make sure to pop when a data structure keyword is found
+    - match: (?=\bstruct\b)
+      set:
+        - meta_scope: debug.typedef-types.struct
+        - include: struct-keyword
+        - include: or_pop
+    - match: (?=\benum\b)
+      set:
+        - meta_scope: debug.typedef-types.enum
+        - include: enum-keyword
+        - include: or_pop
+    - match: (?=\bunion\b)
+      set:
+        - meta_scope: debug.typedef-types.union
+        - include: union-keyword
+        - include: or_pop
     - include: types
     - match: ({{identifier}})(?!\s*;|\s*,|\s*;|\s*\[|\s*\(|\s*=)
       captures:
@@ -829,23 +855,25 @@ contexts:
         - include: c99
         - match: '{{identifier}}'
           scope: variable.function.c
-        - match: '\('
-          scope: punctuation.section.group.begin.c
-          set:
-            - meta_scope: meta.function-call.parameters.c meta.group.c debug.function-call.params
-            - match : \)
-              scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
-              pop: true
-            # - include: macro-identifiers
-            - match: '{{macro_identifier}}(?!\()'
-              comment: Not sure I think we need this special case
-              scope: variable.annotation.c
-            - include: expressions
-            - match: '{{identifier}}'
-              scope: variable.other.c
-            - match: '\b\w+\b'
-              scope: variable.other.c
-              comment: Inside macro params, the identifiers can start with numbers
+        - 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 debug.function-call.params
+        - match : \)
+          scope: meta.group.c punctuation.section.group.end.c
+          pop: true
+        # - include: macro-identifiers
+        - match: '{{macro_identifier}}(?!\()'
+          comment: Not sure I think we need this special case
+          scope: support.constant.c
+        - include: expressions
+        - match: '{{identifier}}'
+          scope: variable.other.c
+        - match: '\b\w+\b'
+          scope: variable.other.c
+          comment: Inside macro params, the identifiers can start with numbers
 
   ## Preprocessor for data-structures
 
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 63b447d593..10a7b1e6a8 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -594,7 +594,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*^^^^^^^^^^^^^^^^ 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
-/*  ^^^^^^^^^^^^^^ variable.annotation.c */
+/*  ^^^^^^^^^^^^^^ support.constant.c */
     __string(vir_intf_name, name ? name : "<noname>")
 /*  ^^^^^^^^ meta.function-call.c variable.function.c */
 /*          ^ punctuation.section.group.begin.c */
@@ -628,7 +628,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*^^^^^^^^^^^^^^ variable.function.c */
 /*              ^ meta.function-call.parameters.c meta.function-call.parameters.c punctuation.section.group.begin.c */
     WPAN_PHY_ASSIGN;
-/*  ^^^^^^^^^^^^^^^ variable.annotation.c */
+/*  ^^^^^^^^^^^^^^^ support.constant.c */
     __assign_str(vir_intf_name, name ? name : "<noname>");
 /*  ^^^^^^^^^^^^ meta.function-call.c variable.function.c */
 /*              ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
@@ -654,11 +654,11 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
   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 */
-/*          ^^^^^^^^^^^^^^^ variable.annotation */
+/*          ^^^^^^^^^^^^^^^ support.constant.c */
 /*                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/
 /*                                                              ^ punctuation.separator.c */
       WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
-/*    ^^^^^^^^^^^^^^^ variable.annotation */
+/*    ^^^^^^^^^^^^^^^ support.constant.c */
 /*                   ^ punctuation.separator.c */
 /*                     ^^^^^^^^^ meta.function-call.c variable.function.c */
 /*                               ^^^^^^^^^^^^^ variable.other.c */
@@ -672,10 +672,10 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*                  ^^^^^^^ variable.other.c */
 /*                         ^^ punctuation.accessor.c */
 /*                           ^^^^^^^^^^^^^ variable.other.c */
-/*                                        ^ meta.function-call.c meta.group.c punctuation.section.group.end.c */
-/*                                         ^ meta.function-call.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 */
 );
-/* <- meta.function-call.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 inline u64 xhci_read_64(const struct xhci_hcd *xhci,
@@ -883,8 +883,8 @@ struct UI_MenuBoxData
     struct delayed_work monitor_work ____cacheline_aligned_in_smp;
 /*  ^^^^^^ storage.type */
 /*         ^^^^^^^^^^^^ support.type.c */
-/*                      ^^^^^^^^^^^^ support.type.c */
-/*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.c*/
+/*                      ^^^^^^^^^^^^ variable.other.c */
+/*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ support.type.c */
 /*                                                               ^ punctuation.terminator.c */
     const struct efx_channel_type *
 /*  ^^^^^storage.modifier.c */
@@ -1028,7 +1028,14 @@ struct resource_table *(*find_loaded_rsc_table)(
 /*                                                     ^ storage.modifier.c */
 /*                                                      ^^ variable.parameter.c */
 
-static const struct pci_driver my_driver __pci_driver = {
+static const struct pci_driver my_driver __pci_driver __driver = {
+/* <- storage.modifier.c */
+/*     ^^^^^ storage.modifier.c */
+/*           ^^^^^^ storage.type.c */
+/*                  ^^^^^^^^^^ support.type.c */
+/*                             ^^^^^^^^^ variable.other.c */
+/*                                       ^^^^^^^^^^^^ support.type.c */
+/*                                                    ^^^^^^^^ support.type.c */
   .ops      = &pci_my_device_ops,
   .vendor   = PCI_VENDOR_ID,
   .devices  = pci_device_ids,
@@ -1056,6 +1063,86 @@ static const struct spd_info {
     },
 };
 
+void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
+/* <- storage.type.c */
+/*   ^ storage.modifier.c */
+/*     ^^^^^ storage.modifier.c */
+/*           ^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                                ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
+/*                                                     ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
+/*                                                       ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                                                                ^^^^^^ meta.function-call.parameters.c */
+/*                                                                 ^^^^ constant.numeric.c */
+/*                                                                       ^ keyword.operator.assignment.c */
+/*                                                                         ^ meta.block.c punctuation.section.block.begin.c */
+  [0 ... __NR_compat_syscalls - 1] = sys_ni_syscall,
+#include <asm/unistd32.h>
+};
+/* <- 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 */
+/*    ^^^^^^^^^^^^^^ variable.other.c */
+/*                  ^^^^^^^^^^^^^^ meta.brackets.c
+/*                  ^ punctuation.section.brackets.begin.c storage.modifier.c */
+/*                   ^^^^^^^^^^^^ support.constant.c */
+/*                               ^ punctuation.section.brackets.end.c storage.modifier.c */
+/*                                 ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                                          ^^^^^^^^^^^ meta.function-call.parameters.c
+/*                                          ^ meta.group.c punctuation.section.group.begin.c */
+/*                                           ^^^^^^^^^ support.constant.c */
+/*                                                    ^ meta.group.c punctuation.section.group.end.c */
+/*                                                     ^ punctuation.terminator.c */
+
+struct mac_tfm_ctx {
+/* <- storage.type.c */
+/*     ^^^^^^^^^^^ entity.name.struct.c */
+/*                 ^ meta.block.c  punctuation.section.block.begin.c */
+  struct crypto_aes_ctx key;
+/*^^^^^^ storage.type.c */
+/*       ^^^^^^^^^^^^^^ support.type.c */
+/*                      ^^^ variable.other.c */
+/*                         ^ punctuation.terminator.c */
+  struct crypto_aes_ctx __aligned(8) key2;
+/*^^^^^^ storage.type.c */
+/*       ^^^^^^^^^^^^^^ support.type.c */
+/*                      ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                               ^^^ meta.function-call.parameters.c
+/*                               ^ meta.group.c punctuation.section.group.begin.c */
+/*                                ^ constant.numeric.c */
+/*                                 ^ meta.group.c punctuation.section.group.end.c */
+/*                                   ^^^^ variable.other.c */
+/*                                       ^ punctuation.terminator.c */
+  u8 __aligned(8) consts[];
+/*^^ support.type.c */
+/*   ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*            ^^^ meta.function-call.parameters.c
+/*            ^ meta.group.c punctuation.section.group.begin.c */
+/*             ^ constant.numeric.c */
+/*              ^ meta.group.c punctuation.section.group.end.c */
+/*                ^^^^^^ variable.other.c */
+/*                      ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
+/*                       ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
+/*                        ^ punctuation.terminator.c */
+} __packed __aligned(4);
+/* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
+/*^^^^^^^^ support.type.c */
+/*         ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                  ^^^ meta.function-call.parameters.c
+/*                  ^ meta.group.c punctuation.section.group.begin.c */
+/*                   ^ constant.numeric.c */
+/*                    ^ meta.group.c punctuation.section.group.end.c */
+/*                     ^ punctuation.terminator.c */
+
+static const struct print_field const err_flags[];
+/*<- storage.modifier.c */
+/*     ^^^^^ storage.modifier.c */
+/*                              ^^^^^ storage.modifier.c */
+/*                                    ^^^^^^^^^ variable.other.c */
+/*                                             ^^ storage.modifier.c */
+/*                                               ^ punctuation.terminator.c */
+
 enum {
 /* <- storage.type */
     ENUM_A,

From 80225042a798d47cad338192688030c2ec2c9716 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 1 Apr 2019 14:19:11 -0600
Subject: [PATCH 07/55] Fix function pointer parameter

---
 C++/C.sublime-syntax | 31 ++++++++++++++++++++++++-------
 C++/syntax_test_c.c  | 22 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 12779c8526..65c5db4db0 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -389,6 +389,20 @@ contexts:
         - match : \)
           scope: punctuation.section.group.end.c
           pop: true
+        - match: \(
+          scope: punctuation.section.group.begin.c debug.function-definition-params-group.function-pointer
+          comment: Function pointer declaration
+          push:
+            - meta_scope: meta.group.c
+            - match: \)
+              scope: punctuation.section.group.end.c
+              set:
+                - include: function-definition-params-group
+                - include: or_pop
+            - match: \*
+              scope: storage.modifier.c
+            - match: '{{identifier}}'
+              scope: variable.parameter.c debug.function-definition-params-group.function-pointer
         - match: '\bvoid\b'
           scope: storage.type.c
         - match: \*
@@ -482,14 +496,17 @@ contexts:
     - match: \*
       scope: storage.modifier.c
     - match: '{{identifier}}(?=\s*\(|\s*\n)'
-      scope: entity.name.function.c debug.variable-identifier-list.function-first
+      scope: meta.function.c entity.name.function.c debug.variable-identifier-list.function
       set:
-        - meta_scope: meta.function.c debug.variable-identifier-list.function
-        - include: comments
-        - include: function-definition-params-group
-        - include: function-definition-body
-        - match: '(?=\S)'
-          set: variable-identifier-list
+        - - meta_scope: debug.variable-identifier-list.function-body
+          - include: comments
+          - include: function-definition-body
+          - match: '(?=\S)'
+            set: variable-identifier-list
+        - - meta_scope: debug.variable-identifier-list.function-params
+          - include: comments
+          - include: function-definition-params-group
+          - include: or_pop
     - match: \(
       scope: punctuation.section.group.begin debug.variable-identifier-list.function-pointer
       comment: Function pointer declaration
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 10a7b1e6a8..bf08e04461 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1028,6 +1028,28 @@ struct resource_table *(*find_loaded_rsc_table)(
 /*                                                     ^ 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 */
+/*                      ^^^^^^ storage.type.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.group.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 */
+
 static const struct pci_driver my_driver __pci_driver __driver = {
 /* <- storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */

From eb4283cedb6202500969ce6c344a08975f67393a Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 1 Apr 2019 14:56:40 -0600
Subject: [PATCH 08/55] Fix function pointer return type highlighting.

---
 C++/C.sublime-syntax | 3 +--
 C++/syntax_test_c.c  | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 65c5db4db0..a738b69e92 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -811,10 +811,9 @@ contexts:
         - include: union-keyword
         - include: or_pop
     - include: types
-    - match: ({{identifier}})(?!\s*;|\s*,|\s*;|\s*\[|\s*\(|\s*=)
+    - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
         1: support.type.c debug.typedef-types.identifier
-      comment: Must be a negative of typedef-identifier-list
     - include: or_pop
   typedef-identifier-list:
     - meta_scope: debug.typedef-identifier-list
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index bf08e04461..f99a06401e 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -961,8 +961,8 @@ struct rproc_ops {
 /*                      ^^^^^ support.type.c */
 /*                            ^ storage.modifier.c */
 /*                             ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */
-    int (*start)(struct rproc *, struct rproc *);
-/*  ^^^ storage.type.c */
+    u32 (*start)(struct rproc *, struct rproc *);
+/*  ^^^ support.type.c */
 /*        ^^^^^ variable.other.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */

From 81217fc59dca6e7a3abc470555ad58f684765acd Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 2 Apr 2019 09:17:22 -0600
Subject: [PATCH 09/55] Limit the __attr to only single parameters

We don't want to gobble up actual function definitions.
---
 C++/C.sublime-syntax | 8 +++++---
 C++/syntax_test_c.c  | 4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index a738b69e92..b672f8841a 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -138,13 +138,15 @@ contexts:
       scope: storage.modifier.c
 
   modifiers-macros:
-    - match: '{{attr_macro_identifier}}(?=\s*\()'
+    - match: '{{attr_macro_identifier}}(?=\s*\((?:\d+|{{macro_identifier}})\))'
       scope: variable.function.c
-      comment: Preprocessor Attributes with parameters
+      comment: Preprocessor Attributes with parameters.
+        We only support a very limited definition so it doesn't gobble up
+        actual function definitions.
       push:
         - meta_scope: meta.function-call.c
         - include: function-call-params
-    - match: '{{attr_macro_identifier}}(?!\s*->|\s*\.)'
+    - match: '{{attr_macro_identifier}}(?!\s*\()'
       scope: support.type.c # Should this be storage.modifier.c?
       comment: Preprocessor Attributes
 
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index f99a06401e..a43a731f39 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -177,6 +177,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 */

From ba713d989b86f8cc0959c753004737a8669b5b9b Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 2 Apr 2019 11:49:36 -0600
Subject: [PATCH 10/55] Scope enum values as entity.name.constant

Also made it so the assignment expressions highlight constants.
---
 C++/C.sublime-syntax |  7 +++++--
 C++/syntax_test_c.c  | 39 +++++++++++++++++++++++++++++++--------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index b672f8841a..828e819e74 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -617,12 +617,12 @@ contexts:
           pop: true
         - include: preprocessor-expressions
         - match: '{{identifier}}'
-          scope: constant.other.enum.c
+          scope: entity.name.constant.enum.c
           push:
             - meta_scope: debug.data-structures-enum-definition.pre-assignment
             - include: comments
             - match: '='
-              scope: keyword.operator.assignment
+              scope: keyword.operator.assignment.c
               set:
                 - meta_scope: debug.data-structures-enum-definition.post
                 - include: comments
@@ -632,6 +632,9 @@ contexts:
                 - match: '(?=,|})'
                   pop: true
                 - include: expressions
+                # Expressions doesn't handle macro identifiers or enum constants
+                - match: '{{macro_identifier}}'
+                  scope: support.constant.c
                 - include: or_pop
             # No equals
             - include: or_pop
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index a43a731f39..74633db31a 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -429,9 +429,9 @@ typedef enum state {DEAD,ALIVE} State;
 /*<- storage.type.c */
 /*      ^^^^ storage.type.c */
 /*           ^^^^^ entity.name.enum.c */
-/*                  ^^^^ constant.other.enum.c */
+/*                  ^^^^ entity.name.constant.enum.c */
 /*                      ^ punctuation.separator.c */
-/*                       ^^^^^ constant.other.enum.c */
+/*                       ^^^^^ entity.name.constant.enum.c */
 /*                              ^^^^^ entity.name.type.typedef.c */
 /*                                   ^ punctuation.terminator.c */
 
@@ -1172,35 +1172,58 @@ static const struct print_field const err_flags[];
 enum {
 /* <- storage.type */
     ENUM_A,
-/*  ^ constant.other.enum.c */
+/*  ^ entity.name.constant.enum.c */
 /*        ^ punctuation.separator.c */
     ENUM_B = 6,
-/*  ^ constant.other.enum.c */
+/*  ^ entity.name.constant.enum.c */
 /*         ^ keyword.operator.assignment */
 /*           ^ constant.numeric.c */
 /*            ^ punctuation.separator.c */
 #ifdef ENABLED_FEATURE
 /* <- meta.preprocessor.c keyword.control.import.c */
     ENUM_ENABLED,
-/*  ^^^^^^^^^^^^ constant.other.enum.c */
+/*  ^^^^^^^^^^^^ entity.name.constant.enum.c */
 #else
 /* <- meta.preprocessor.c keyword.control.import.c */
     ENUM_DISABLED,
-/*  ^^^^^^^^^^^^^ constant.other.enum.c */
+/*  ^^^^^^^^^^^^^ 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
-/*  ^^^^^^^^^^^^^^^^^^^ constant.other.enum.c */
+/*  ^^^^^^^^^^^^^^^^^^^ entity.name.constant.enum.c */
 #endif
 /* <- meta.preprocessor.c keyword.control.import.c */
 
     ENUM_C
-/*  ^ constant.other.enum.c */
+/*  ^ entity.name.constant.enum.c */
 };
 
+enum typec_mux {
+/* <- meta.enum.c storage.type.c */
+/*   ^^^^^^^^^ entity.name.enum.c */
+  TYPEC_MUX_NONE = 0,
+/*^^^^^^^^^^^^^^ entity.name.constant.enum.c */
+/*               ^ keyword.operator.assignment.c */
+/*                 ^ constant.numeric.c */
+/*                  ^ punctuation.separator.c */
+  TYPEC_MUX_USB  = MUX_USB_ENABLED,
+/*^^^^^^^^^^^^^ entity.name.constant.enum.c */
+/*               ^ keyword.operator.assignment.c */
+/*                 ^^^^^^^^^^^^^^^ support.constant.c */
+/*                                ^ punctuation.separator.c */
+  TYPEC_MUX_DOCK = MUX_USB_ENABLED | MUX_DP_ENABLED,
+/*^^^^^^^^^^^^^^ entity.name.constant.enum.c */
+/*               ^ keyword.operator.assignment.c */
+/*                 ^^^^^^^^^^^^^^^ support.constant.c */
+/*                                 ^ keyword.operator */
+/*                                   ^^^^^^^^^^^^^^ support.constant.c */
+};
+/* <-meta.enum.c meta.block.c punctuation.section.block.end.c */
+ /* <- punctuation.terminator.c */
+
 /////////////////////////////////////////////
 // Test preprocessor branching and C blocks
 /////////////////////////////////////////////

From 3614d1cee25265efdc5d56f80f3c6921a69ed60b Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 3 Apr 2019 13:43:47 -0600
Subject: [PATCH 11/55] Add support for function attributes

---
 C++/C.sublime-syntax | 18 +++++++++++++-----
 C++/syntax_test_c.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 828e819e74..24c2737abd 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -139,7 +139,7 @@ contexts:
 
   modifiers-macros:
     - match: '{{attr_macro_identifier}}(?=\s*\((?:\d+|{{macro_identifier}})\))'
-      scope: variable.function.c
+      scope: variable.function.c debug.modifiers-macros
       comment: Preprocessor Attributes with parameters.
         We only support a very limited definition so it doesn't gobble up
         actual function definitions.
@@ -505,6 +505,14 @@ contexts:
           - include: function-definition-body
           - match: '(?=\S)'
             set: variable-identifier-list
+        - - meta_scope: debug.variable-identifier-list.function-modifiers
+          - include: comments
+          - include: modifiers-parens
+          # Macro invocations
+          - include: function-call
+          - match: '{{identifier}}'
+            scope: support.type.c debug.variable-identifier-list.function-attribute
+          - include: or_pop
         - - meta_scope: debug.variable-identifier-list.function-params
           - include: comments
           - include: function-definition-params-group
@@ -696,13 +704,13 @@ contexts:
 
   block:
     - match: '\{'
-      scope: punctuation.section.block.begin.c debug.block
+      scope: punctuation.section.block.begin.c debug.block.open-brace
       push:
-        - meta_scope: meta.block.c
+        - meta_scope: meta.block.c debug.block
         - match: (?=^\s*#\s*(elif|else|endif)\b)
           pop: true
         - match: '\}'
-          scope: punctuation.section.block.end.c
+          scope: punctuation.section.block.end.c debug.block.close-brace
           pop: true
         - include: statements
 
@@ -883,7 +891,7 @@ contexts:
       set:
         - meta_scope: meta.function-call.parameters.c meta.group.c debug.function-call.params
         - match : \)
-          scope: meta.group.c punctuation.section.group.end.c
+          scope: punctuation.section.group.end.c
           pop: true
         # - include: macro-identifiers
         - match: '{{macro_identifier}}(?!\()'
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 74633db31a..88d116f89e 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1161,6 +1161,49 @@ struct mac_tfm_ctx {
 /*                    ^ 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
+/*  ^^^^^^ support.type.c */
+    SAFE
+/*  ^^^^ support.type.c */
+    __blah(bar)
+/*  ^^^^^^ meta.function-call.c variable.function.c */
+/*         ^^^ variable.other.c */
+    __blah(bar, foo)
+/*  ^^^^^^ meta.function-call.c variable.function.c */
+/*        ^^^^^^^^^^ meta.function-call.parameters.c */
+/*         ^^^ variable.other.c */
+/*              ^^^ variable.other.c */
+    __must_hold(&abc->lock)
+/*  ^^^^^^^^^^^ meta.function-call.c */
+/*             ^^^^^^^^^^^^ meta.function-call.parameters.c */
+/*              ^ keyword.operator.c
+/*               ^^^ variable.other.c */
+/*                  ^^ punctuation.accessor.c */
+/*                    ^^^^ variable.other.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 */
+
 static const struct print_field const err_flags[];
 /*<- storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */

From 5d3efbf2f8ded3a90022625d6d933923fed2f2d8 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 5 Apr 2019 10:43:38 -0600
Subject: [PATCH 12/55] Add more debug scopes to preprocessor macros

---
 C++/C.sublime-syntax | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 24c2737abd..d951a5df29 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -147,7 +147,8 @@ contexts:
         - meta_scope: meta.function-call.c
         - include: function-call-params
     - match: '{{attr_macro_identifier}}(?!\s*\()'
-      scope: support.type.c # Should this be storage.modifier.c?
+      # Should this be storage.modifier.c?
+      scope: support.type.c debug.modifiers-macros
       comment: Preprocessor Attributes
 
   variables:
@@ -1187,6 +1188,7 @@ contexts:
   # when the preprocessor is used to create different scope beginnings, such
   # as a different if/while condition
   preprocessor-if-branch-statements:
+    - meta_scope: debug.preprocessor-if-branch-statements
     - match: ^\s*(#\s*endif)\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
@@ -1194,7 +1196,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \{
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-statements.opening-brace
       set: preprocessor-block-if-branch-statements
     - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\()
       set: preprocessor-if-branch-function-call
@@ -1233,26 +1235,26 @@ contexts:
     - include: expressions
 
   preprocessor-block-if-branch-statements:
-    - meta_scope: meta.block.c
+    - meta_scope: meta.block.c debug.preprocessor-block-if-branch-statements
     - match: ^\s*(#\s*endif)\b
       captures:
-        1: meta.preprocessor.c keyword.control.import.c
+        1: meta.preprocessor.c keyword.control.import.c debug.preprocessor-block-if-branch-statements.endif
       set: preprocessor-block-finish-statements
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.preprocessor-block-if-branch-statements.closing-brace
       set: preprocessor-if-branch-statements
     - include: statements
 
   preprocessor-block-finish-statements:
-    - meta_scope: meta.block.c
+    - meta_scope: meta.block.c debug.preprocessor-block-finish-statements
     - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
       set: preprocessor-block-finish-if-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.preprocessor-block-finish-statements.closing-brace
       pop: true
     - include: statements
 
@@ -1267,6 +1269,7 @@ contexts:
     - include: statements
 
   preprocessor-elif-else-branch-statements:
+    - meta_scope: debug.preprocessor-elif-else-branch-statements
     - match: (?=^\s*#\s*endif\b)
       pop: true
     - include: negated-block
@@ -1276,8 +1279,9 @@ contexts:
 
   negated-block:
     - match: '\}'
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.negated-block
       push:
+        - meta_scope: debug.negated-block.new-block
         - match: '\{'
           scope: punctuation.section.block.begin.c
           pop: true
@@ -1349,9 +1353,9 @@ contexts:
     - include: preprocessor-comments
     # Don't define blocks in define statements
     - match: '\{'
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.preprocessor-macro-definition.begin-block
     - match: '\}'
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.preprocessor-macro-definition.end-block
     - include: expressions
 
   preprocessor-practical-workarounds:

From b307a839c9411c9685a8073df740f3373555ad40 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 5 Apr 2019 11:49:00 -0600
Subject: [PATCH 13/55] Fix macro as part of variable definition.

---
 C++/C.sublime-syntax |   5 +-
 C++/syntax_test_c.c  | 142 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 143 insertions(+), 4 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index d951a5df29..0f80f1e7ad 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -148,8 +148,10 @@ contexts:
         - include: function-call-params
     - match: '{{attr_macro_identifier}}(?!\s*\()'
       # Should this be storage.modifier.c?
-      scope: support.type.c debug.modifiers-macros
+      scope: support.type.c debug.modifiers-macros.underscore
       comment: Preprocessor Attributes
+    - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*)'
+      scope: support.type.c debug.modifiers-macros.caps
 
   variables:
     - match: '\bg[A-Z]\w*\b'
@@ -493,6 +495,7 @@ contexts:
 
   variable-identifier-list:
     - meta_scope: debug.variable-identifier-list
+    - include: comments
     - include: modifiers
     - include: modifiers-parens
     - include: modifiers-macros
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 88d116f89e..2bd8295fb7 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -446,7 +446,7 @@ struct point
 /* <- 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 {
@@ -455,7 +455,7 @@ struct point2 {
 /*            ^ 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) {
@@ -1204,6 +1204,110 @@ void f_attributes(int *bar) __attribute__((context(&foo,1,1))) {}
 /*                          ^^^^^^^^^^^^^ 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 */
+/*                                 ^ variable.other.c */
+/*                                  ^ punctuation.separator.c */
+  *f,
+/*^ storage.modifier.c */
+/* ^ variable.other.c */
+/*  ^ punctuation.separator.c */
+  __attribute__((aligned(8))) * g,
+/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
+/*^^^^^^^^^^^^^ storage.modifier.c */
+/*                            ^ storage.modifier.c */
+/*                              ^ variable.other.c */
+/*                               ^ punctuation.separator.c */
+  * __attribute__((aligned(8))) h;
+/*^ storage.modifier.c */
+/*  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
+/*  ^^^^^^^^^^^^^ storage.modifier.c */
+/*                              ^ variable.other.c */
+/*                               ^ punctuation.terminator.c */
+
+char *MACRO1 *e,
+/* <- storage.type.c */
+/*   ^ storage.modifier.c */
+/*    ^^^^^^ support.type.c */
+/*           ^ storage.modifier.c */
+/*            ^ variable.other.c */
+/*             ^ punctuation.separator.c */
+  *f,
+/*^ storage.modifier.c */
+/* ^ variable.other.c */
+/*  ^ punctuation.separator.c */
+  MACRO1 * g,
+/*^^^^^^ support.type.c */
+/*       ^ storage.modifier.c */
+/*         ^ variable.other.c */
+/*          ^ punctuation.separator.c */
+  * MACRO1 * h;
+/*^ storage.modifier.c */
+/*  ^^^^^^ support.type.c*/
+/*         ^ storage.modifier.c */
+/*           ^ variable.other.c */
+/*            ^ punctuation.terminator.c */
+
+char *MACRO1 e,
+/* <- storage.type.c */
+/*   ^ storage.modifier.c */
+/*    ^^^^^^ support.type.c */
+/*           ^ variable.other.c */
+/*            ^ punctuation.separator.c */
+  f,
+/*^ variable.other.c */
+/* ^ punctuation.separator.c */
+  MACRO1 g,
+/*^^^^^^ support.type.c */
+/*       ^ variable.other.c */
+/*        ^ punctuation.separator.c */
+  * MACRO1 h;
+/*^ storage.modifier.c */
+/*  ^^^^^^ support.type.c*/
+/*         ^ variable.other.c */
+/*          ^ punctuation.terminator.c */
+
+char *__aligned(8) *e,
+/* <- storage.type.c */
+/*   ^ storage.modifier.c */
+/*    ^^^^^^^^^^^^ meta.function-call */
+/*                 ^ storage.modifier.c */
+/*                  ^ variable.other.c */
+/*                   ^ punctuation.separator.c */
+  *f,
+/*^ storage.modifier.c */
+/* ^ variable.other.c */
+/*  ^ punctuation.separator.c */
+  __aligned(8) * g,
+/*^^^^^^^^^^^^ meta.function-call */
+/*             ^ storage.modifier.c */
+/*               ^ variable.other.c */
+/*                ^ punctuation.separator.c */
+  * __aligned(8) h;
+/*^ storage.modifier.c */
+/*  ^^^^^^^^^^^^ meta.function-call */
+/*               ^ variable.other.c */
+/*                ^ punctuation.terminator.c */
+
+MACRO1 UPPER_VAR;
+/* <- support.type.c */
+/*     ^^^^^^^^^ variable.other.c */
+/*              ^ punctuation.terminator.c */
+
+__safe UPPER_VAR;
+/* <- support.type.c */
+/*     ^^^^^^^^^ variable.other.c */
+/*              ^ punctuation.terminator.c */
+
+TYPE(int) UPPER_VAR;
+/* <- meta.function-call */
+/*        ^^^^^^^^^ variable.other.c */
+/*                 ^ punctuation.terminator.c */
+
 static const struct print_field const err_flags[];
 /*<- storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */
@@ -1378,13 +1482,44 @@ int /* comment */ * myfunc
 }
 
 MACRO1
+/* <- support.type.c */
 RETURN_TYPE
-/* <- - entity.name.function */
+/* <- support.type.c */
 func_name() {
 /* < entity.name.function */
 }
 
+MACRO1 void MACRO2 * myfuncname ();
+/* <- support.type.c */
+/*     ^ storage.type.c */
+/*          ^ support.type.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();
+/* <- support.type.c */
+/*     ^ storage.type.c */
+/*          ^ support.type.c */
+/*                 ^^^^^^^^^^ meta.function.c entity.name.function.c */
+/*                            ^^ meta.group.c*/
+/*                              ^ punctuation.separator.c */
+/*                                ^^^^^^ support.type.c */
+/*                                       ^^^ entity.name.function.c */
+/*                                          ^^ meta.function.parameters.c
+/*                                            ^ punctuation.separator.c */
+/*                                              ^^^^^^^^^ variable.other.c */
+/*                                                       ^ punctuation.separator.c */
+/*                                                         ^^^^^^^ entity.name.function.c */
+/*                                                                ^^ meta.function.parameters.c */
+/*                                                                  ^ punctuation.terminator.c */
+
 MACRO1 void * MACRO2 myfuncname () {
+/* <- support.type.c */
+/*     ^^^^ storage.type.c */
+/*          ^ storage.modifier.c */
+/*            ^^^^^^ support.type.c */
 /*                   ^^^^^^^^^^ meta.function */
 /*                              ^^ meta.function.parameters */
 /*                                 ^ meta.block punctuation.section.block.begin
@@ -1429,6 +1564,7 @@ static const uint32_t * const MACRO funcname();
 /*           ^ support.type */
 /*                    ^ storage.modifier.c */
 /*                      ^ storage.modifier */
+/*                            ^^^^^ support.type.c */
 /*                                  ^ entity.name.function */
 
 MACRO int

From a0ebd41d9a995f6fd508e07d37b3dfb62b487b82 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 5 Apr 2019 12:42:24 -0600
Subject: [PATCH 14/55] Allow macro calls to define variable/function type

---
 C++/C.sublime-syntax | 31 ++++++++++++++++++---------
 C++/syntax_test_c.c  | 51 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 68 insertions(+), 14 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 0f80f1e7ad..463958a4ee 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -138,7 +138,7 @@ contexts:
       scope: storage.modifier.c
 
   modifiers-macros:
-    - match: '{{attr_macro_identifier}}(?=\s*\((?:\d+|{{macro_identifier}})\))'
+    - match: '(?:{{macro_identifier}}|{{attr_macro_identifier}})(?=\s*\((?:\d+|{{macro_identifier}})\))'
       scope: variable.function.c debug.modifiers-macros
       comment: Preprocessor Attributes with parameters.
         We only support a very limited definition so it doesn't gobble up
@@ -310,10 +310,10 @@ contexts:
 
   global:
     - include: early-expressions
-    - match: '^\s*(?=\w+)'
+    - match: '(?=\w+)'
       push:
-        - global-modifier
-        - global-function-call
+        - include: global-function-call
+        - include: global-modifier
     - include: late-expressions
 
   statements:
@@ -359,18 +359,29 @@ contexts:
   global-function-call:
     - meta_scope: debug.global-function-call
     - include: comments
+    - match: \bextern\b
+      scope: storage.modifier.c
     - include: modifiers-parens
-    - include: modifiers
-    - include: function-call
-    - match: ';'
-      scope: punctuation.terminator.c debug.global-function-call
+    - match: (?={{identifier}}\s*\()
+      set:
+        - - meta_scope: debug.global-function-call.type-or-terminator
+          - match: ';'
+            scope: punctuation.terminator.c debug.global-function-call
+            pop: true
+          - match: '(?=\S)'
+            set: global-modifier
+        - - meta_scope: debug.global-function-call.params
+          - include: function-call-params
+        - - meta_scope: meta.function-call.c
+          - match: '{{identifier}}'
+            # Really a macro
+            scope: variable.function.c
+            pop: true
     - include: or_pop
 
   global-modifier:
     - meta_scope: debug.global-modifier
     - include: comments
-    - include: modifiers-parens
-    - include: modifiers
     - match: '(?=\S)'
       set:
         - variable-identifier-list
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 2bd8295fb7..c8a7d83596 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -230,7 +230,7 @@ foo
 FOO()
 /* <- meta.function-call.c variable.function.c */
 FOO();
-/* <- meta.function-call.c variable.function.c */
+/* <- meta.function.c entity.name.function.c */
 foo()
 /* <- meta.function-call.c variable.function.c */
 ; // fix highlighting
@@ -591,7 +591,7 @@ TRACE_EVENT(mmc_request_start,
 
 TRACE_EVENT(802154_rdev_add_virtual_intf,
 /* <-meta.function-call.c variable.function.c */
-/*         ^ meta.function-call.c punctuation.section.group.begin.c */
+/*         ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
 /*          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
 /*                                      ^ punctuation.separator.c */
   TP_STRUCT__entry(
@@ -1570,7 +1570,7 @@ static const uint32_t * const MACRO funcname();
 MACRO int
 /*    ^ storage.type */
 funcname2
-/* ^ entity.name.function */
+/* ^ support.type.c */
 ()
 {
     int a[5];
@@ -1579,13 +1579,56 @@ funcname2
 /*         ^ punctuation.section.brackets.end */
 }
 
-MACRO_CALL(int) macro_prefixed_func(){}
+MACRO_CALL(int) foo;
 /*^^^^^^^^^^^^^ meta.function-call */
 /*        ^^^^^ meta.group */
+/*              ^^^ variable.other.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 */
+/*                         ^^^ variable.other.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 */
+/*                             ^^^^^^ variable.other.c */
+
 int* return_type_pointer_no_space(){}
 /* <- storage.type.c */
 /* ^ storage.modifier.c */

From 88700a981ad3ec7497b2d2b55ecd3d6ab29dd7e2 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 5 Apr 2019 15:18:36 -0600
Subject: [PATCH 15/55] Support attributes in method params

I think the function params block might need to be rewritten. It can't
handle the case: fn(int var __attribute__((unused).
---
 C++/C.sublime-syntax |  4 ++--
 C++/syntax_test_c.c  | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 463958a4ee..c079d73d7a 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -426,7 +426,7 @@ contexts:
         - match: \.\.\.
           scope: keyword.operator.variadic.c
         - include: modifiers
-        #- include: modifiers-parens
+        - include: modifiers-parens
         - match: '{{identifier}}(?=\s*\[)'
           scope: variable.parameter.c
           push:
@@ -440,7 +440,7 @@ contexts:
                   scope: storage.modifier.c punctuation.section.brackets.end
                   pop: true
             - include: or_pop
-        - match: '{{identifier}}(?=\s*(\[|,|\)))'
+        - match: '{{identifier}}(?=\s*(,|\)|\n))'
           scope: variable.parameter.c
         - include: types
         - match: '{{identifier}}'
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index c8a7d83596..615b750087 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1515,6 +1515,25 @@ MACRO1 void MACRO2 myfuncname (), MACRO2 foo(), UPPER_VAR, UPPERFN();
 /*                                                                ^^ 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
+/*^^^^^^ storage.type.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 () {
 /* <- support.type.c */
 /*     ^^^^ storage.type.c */

From 8969bdc7fc801ff6fb240c910e94e86a82bf5a4a Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 10 Apr 2019 16:01:05 -0600
Subject: [PATCH 16/55] Fix more pre-processor macro invocations.

---
 C++/C.sublime-syntax | 13 ++++++----
 C++/syntax_test_c.c  | 58 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index c079d73d7a..f294eb13e9 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -138,7 +138,7 @@ contexts:
       scope: storage.modifier.c
 
   modifiers-macros:
-    - match: '(?:{{macro_identifier}}|{{attr_macro_identifier}})(?=\s*\((?:\d+|{{macro_identifier}})\))'
+    - match: '(?:{{macro_identifier}}|{{attr_macro_identifier}})(?=\s*\((?:\d+|0x\d+|sizeof\([^\)]*\)|{{macro_identifier}})\))'
       scope: variable.function.c debug.modifiers-macros
       comment: Preprocessor Attributes with parameters.
         We only support a very limited definition so it doesn't gobble up
@@ -368,6 +368,12 @@ contexts:
           - match: ';'
             scope: punctuation.terminator.c debug.global-function-call
             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-modifier
         - - meta_scope: debug.global-function-call.params
@@ -701,10 +707,7 @@ contexts:
     - include: comments
     - include: modifiers-parens
     - include: modifiers
-    #- include: macro-identifiers
-    # Handle macros so they aren't matched as the class name
-    - match: '\b[[:upper:][:digit:]_]+\b'
-      scope: variable.annotation.c
+    - include: modifiers-macros
 
   data-structures-body:
     - include: preprocessor-data-structures
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 615b750087..ab17f4fc4e 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -230,7 +230,7 @@ foo
 FOO()
 /* <- meta.function-call.c variable.function.c */
 FOO();
-/* <- meta.function.c entity.name.function.c */
+/* <- meta.function-call.c variable.function.c */
 foo()
 /* <- meta.function-call.c variable.function.c */
 ; // fix highlighting
@@ -682,6 +682,24 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /* <- meta.function-call.parameters.c meta.group.c punctuation.section.group.end.c */
  /* <- punctuation.terminator.c */
 
+MACRO_CALL_NO_SEMI(
+/* <- meta.function-call.c variable.function.c */
+/*                ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
+  __with_complex_params(34)
+/*^ meta.function-call.c variable.function.c */
+/*                     ^^^^ meta.function-call.parameters.c */
+)
+/* <- meta.function-call.parameters.c punctuation.section.group.end.c */
+
+MACRO_CALL_NO_SEMI(
+/* <- meta.function-call.c variable.function.c */
+/*                ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
+  __with_complex_params(34)
+/*^ meta.function-call.c variable.function.c */
+/*                     ^^^^ meta.function-call.parameters.c */
+)
+/* <- meta.function-call.parameters.c punctuation.section.group.end.c */
+
 static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 /*<- storage.modifier.c */
 /*     ^^^^^^ storage.modifier.c */
@@ -709,7 +727,8 @@ int main(void)
 }
 
 struct MACRO foo {
-/*     ^ variable.annotation - entity.name - support.type*/
+/* <- storage.type.c */
+/*     ^ support.type.c */
 /*           ^ entity.name.struct */
 }
 
@@ -1067,6 +1086,21 @@ static const struct pci_driver my_driver __pci_driver __driver = {
   .devices  = pci_device_ids,
 };
 
+struct __ec_align4 ec_response_get_version {};
+/* <- storage.type.c */
+/*     ^^^^^^^^^^^ support.type.c */
+/*                 ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
+struct __align(4) ec_response_get_version {};
+/* <- storage.type.c */
+/*     ^^^^^^^ meta.function-call.c variable.function.c */
+/*            ^^^ meta.function-call.parameters.c  */
+/*                ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
+
+struct ALIGN4 ec_response_get_version {};
+/* <- storage.type.c */
+/*     ^^^^^^ support.type.c */
+/*            ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
+
 static const struct spd_info {
 /*           ^^^^^^ meta.struct.c storage.type.c */
 /*                  ^^^^^^^^ entity.name.struct.c */
@@ -1287,11 +1321,27 @@ char *__aligned(8) *e,
 /*             ^ storage.modifier.c */
 /*               ^ variable.other.c */
 /*                ^ punctuation.separator.c */
-  * __aligned(8) h;
+  * __aligned(8) h,
 /*^ storage.modifier.c */
 /*  ^^^^^^^^^^^^ meta.function-call */
 /*               ^ variable.other.c */
-/*                ^ punctuation.terminator.c */
+/*                ^ punctuation.separator.c */
+
+  __aligned(sizeof(int)) * i,
+/*^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */
+/*                       ^ storage.modifier.c */
+/*                         ^ variable.other.c */
+/*                          ^ punctuation.separator.c */
+  __aligned(sizeof(void *)) * j,
+/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */
+/*                          ^ storage.modifier.c */
+/*                            ^ variable.other.c */
+/*                             ^ punctuation.separator.c */
+  __aligned(0x8) * k;
+/*^^^^^^^^^^^^^^ meta.function-call */
+/*               ^ storage.modifier.c */
+/*                 ^ variable.other.c */
+/*                  ^ punctuation.terminator.c */
 
 MACRO1 UPPER_VAR;
 /* <- support.type.c */

From 31118e73a18e149e3f3ce232daee9bf5f975d8ba Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 10 Apr 2019 16:20:03 -0600
Subject: [PATCH 17/55] Fix macro invocations with storage modifiers

---
 C++/C.sublime-syntax | 16 +++++++---------
 C++/syntax_test_c.c  |  6 ++++++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index f294eb13e9..c470787ef2 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -18,7 +18,7 @@ variables:
   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}}'
@@ -312,6 +312,12 @@ contexts:
     - include: early-expressions
     - match: '(?=\w+)'
       push:
+        - meta_scope: debug.global.token
+        - 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-modifier
     - include: late-expressions
@@ -357,11 +363,6 @@ contexts:
   ## C-specific contexts
 
   global-function-call:
-    - meta_scope: debug.global-function-call
-    - include: comments
-    - match: \bextern\b
-      scope: storage.modifier.c
-    - include: modifiers-parens
     - match: (?={{identifier}}\s*\()
       set:
         - - meta_scope: debug.global-function-call.type-or-terminator
@@ -383,11 +384,8 @@ contexts:
             # Really a macro
             scope: variable.function.c
             pop: true
-    - include: or_pop
 
   global-modifier:
-    - meta_scope: debug.global-modifier
-    - include: comments
     - match: '(?=\S)'
       set:
         - variable-identifier-list
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index ab17f4fc4e..640b797757 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -682,6 +682,12 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /* <- 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 variable.function.c */
+/*                    ^^^^^^^^^ meta.function-call.parameters.c */
+/*                     ^^^^^^^ variable.other.c */
+
 MACRO_CALL_NO_SEMI(
 /* <- meta.function-call.c variable.function.c */
 /*                ^ meta.function-call.parameters.c punctuation.section.group.begin.c */

From b10575bb6163960df4dd1bb7848207f19d77899f Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 10 Apr 2019 16:50:42 -0600
Subject: [PATCH 18/55] Switch over to constant.other.macro.c

We need to label macro function calls as well, but that will require
changing the indexing.
---
 C++/C.sublime-syntax | 21 ++++---------
 C++/syntax_test_c.c  | 70 ++++++++++++++++++++++++--------------------
 2 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index c470787ef2..18bd891594 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -147,11 +147,10 @@ contexts:
         - meta_scope: meta.function-call.c
         - include: function-call-params
     - match: '{{attr_macro_identifier}}(?!\s*\()'
-      # Should this be storage.modifier.c?
-      scope: support.type.c debug.modifiers-macros.underscore
+      scope: constant.other.macro.c debug.modifiers-macros.underscore
       comment: Preprocessor Attributes
     - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*)'
-      scope: support.type.c debug.modifiers-macros.caps
+      scope: constant.other.macro.c debug.modifiers-macros.caps
 
   variables:
     - match: '\bg[A-Z]\w*\b'
@@ -330,6 +329,8 @@ contexts:
   expressions:
     - include: early-expressions
     - include: late-expressions
+    - match: '{{macro_identifier}}'
+      scope: constant.other.macro.c
 
   early-expressions:
     - include: preprocessor-expressions
@@ -530,7 +531,7 @@ contexts:
           # Macro invocations
           - include: function-call
           - match: '{{identifier}}'
-            scope: support.type.c debug.variable-identifier-list.function-attribute
+            scope: constant.other.macro.c debug.variable-identifier-list.function-attribute
           - include: or_pop
         - - meta_scope: debug.variable-identifier-list.function-params
           - include: comments
@@ -562,9 +563,6 @@ contexts:
               scope: punctuation.section.brackets.end.c storage.modifier.c
               pop: true
             - include: expressions
-            # Expressions doesn't handle macro identifiers or enum constants
-            - match: '{{macro_identifier}}'
-              scope: support.constant.c
         - match: \=
           scope: keyword.operator.assignment.c
           set:
@@ -659,9 +657,6 @@ contexts:
                 - match: '(?=,|})'
                   pop: true
                 - include: expressions
-                # Expressions doesn't handle macro identifiers or enum constants
-                - match: '{{macro_identifier}}'
-                  scope: support.constant.c
                 - include: or_pop
             # No equals
             - include: or_pop
@@ -867,9 +862,6 @@ contexts:
               scope: punctuation.section.brackets.end.c storage.modifier.c
               pop: true
             - include: expressions
-            # Expressions doesn't handle macro identifiers or enum constants
-            - match: '{{macro_identifier}}'
-              scope: support.constant.c
         - include: or_pop
     - match: '\((?=\s*\*)'
       scope: punctuation.section.group.begin debug.typedef.function-pointer
@@ -911,8 +903,7 @@ contexts:
           pop: true
         # - include: macro-identifiers
         - match: '{{macro_identifier}}(?!\()'
-          comment: Not sure I think we need this special case
-          scope: support.constant.c
+          scope: constant.other.macro.c
         - include: expressions
         - match: '{{identifier}}'
           scope: variable.other.c
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 640b797757..b835eb8b6a 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -413,7 +413,7 @@ typedef char arrType[NUMBER_OF_ELEMENTS];
 /*      ^^^^ storage.type.c */
 /*           ^^^^^^^ entity.name.type.typedef.c */
 /*                  ^ storage.modifier */
-/*                   ^^^^^^^^^^^^^^^^^^ support.constant.c */
+/*                   ^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                     ^ storage.modifier */
 
 typedef unsigned long ulong, *ulongptr;
@@ -598,7 +598,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*^^^^^^^^^^^^^^^^ 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
-/*  ^^^^^^^^^^^^^^ support.constant.c */
+/*  ^^^^^^^^^^^^^^ constant.other.macro.c */
     __string(vir_intf_name, name ? name : "<noname>")
 /*  ^^^^^^^^ meta.function-call.c variable.function.c */
 /*          ^ punctuation.section.group.begin.c */
@@ -632,7 +632,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*^^^^^^^^^^^^^^ variable.function.c */
 /*              ^ meta.function-call.parameters.c meta.function-call.parameters.c punctuation.section.group.begin.c */
     WPAN_PHY_ASSIGN;
-/*  ^^^^^^^^^^^^^^^ support.constant.c */
+/*  ^^^^^^^^^^^^^^^ constant.other.macro.c */
     __assign_str(vir_intf_name, name ? name : "<noname>");
 /*  ^^^^^^^^^^^^ meta.function-call.c variable.function.c */
 /*              ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
@@ -658,11 +658,11 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
   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 */
-/*          ^^^^^^^^^^^^^^^ support.constant.c */
+/*          ^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/
 /*                                                              ^ punctuation.separator.c */
       WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
-/*    ^^^^^^^^^^^^^^^ support.constant.c */
+/*    ^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                   ^ punctuation.separator.c */
 /*                     ^^^^^^^^^ meta.function-call.c variable.function.c */
 /*                               ^^^^^^^^^^^^^ variable.other.c */
@@ -734,7 +734,7 @@ int main(void)
 
 struct MACRO foo {
 /* <- storage.type.c */
-/*     ^ support.type.c */
+/*     ^ constant.other.macro */
 /*           ^ entity.name.struct */
 }
 
@@ -848,13 +848,13 @@ struct UI_MenuBoxData
 /*       ^^^^^^^^^^^ variable.other.c */
 /*                  ^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c */
-/*                   ^^^^^^^^^^^^^^^ support.constant.c */
+/*                   ^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                  ^ punctuation.section.brackets.end.c */
 /*                                   ^ punctuation.terminator.c */
     struct xhci_run_regs __iomem *run_regs;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
-/*                       ^ - entity.name */
+/*                       ^ constant.other.macro.c */
 /*                               ^ storage.modifier.c */
 /*                                 ^ variable.other.c - entity.name */
 /*                                        ^ punctuation.terminator.c */
@@ -913,7 +913,7 @@ struct UI_MenuBoxData
 /*  ^^^^^^ storage.type */
 /*         ^^^^^^^^^^^^ support.type.c */
 /*                      ^^^^^^^^^^^^ variable.other.c */
-/*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ support.type.c */
+/*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                                               ^ punctuation.terminator.c */
     const struct efx_channel_type *
 /*  ^^^^^storage.modifier.c */
@@ -923,7 +923,7 @@ struct UI_MenuBoxData
     extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
 /*  ^^^^^^^^^^^^^^^^^^ variable.other.c */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */
-/*                     ^^^^^^^^^^^^^^^^^^^^^^ support.constant.c */
+/*                     ^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                    ^ punctuation.section.brackets.begin.c storage.modifier.c */
 /*                                           ^ punctuation.section.brackets.end.c storage.modifier.c */
 
@@ -1085,8 +1085,8 @@ static const struct pci_driver my_driver __pci_driver __driver = {
 /*           ^^^^^^ storage.type.c */
 /*                  ^^^^^^^^^^ support.type.c */
 /*                             ^^^^^^^^^ variable.other.c */
-/*                                       ^^^^^^^^^^^^ support.type.c */
-/*                                                    ^^^^^^^^ support.type.c */
+/*                                       ^^^^^^^^^^^^ constant.other.macro.c */
+/*                                                    ^^^^^^^^ constant.other.macro.c */
   .ops      = &pci_my_device_ops,
   .vendor   = PCI_VENDOR_ID,
   .devices  = pci_device_ids,
@@ -1094,7 +1094,7 @@ static const struct pci_driver my_driver __pci_driver __driver = {
 
 struct __ec_align4 ec_response_get_version {};
 /* <- storage.type.c */
-/*     ^^^^^^^^^^^ support.type.c */
+/*     ^^^^^^^^^^^ constant.other.macro.c */
 /*                 ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
 struct __align(4) ec_response_get_version {};
 /* <- storage.type.c */
@@ -1104,7 +1104,7 @@ struct __align(4) ec_response_get_version {};
 
 struct ALIGN4 ec_response_get_version {};
 /* <- storage.type.c */
-/*     ^^^^^^ support.type.c */
+/*     ^^^^^^ constant.other.macro */
 /*            ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
 
 static const struct spd_info {
@@ -1120,12 +1120,18 @@ static const struct spd_info {
 /*^^^^^^^^^^^^  variable.other.c */
 /*            ^^ meta.brackets.c storage.modifier.c */
     [SPD_INFO_DDR4] = {
+/*   ^^^^^^^^^^^^^ constant.other.macro.c */
         .spd_len = SPD_DDR4_LENGTH,
+/*                 ^^^^^^^^^^^^^^^ constant.other.macro.c */
         .spd_part_len = SPD_DDR4_PART_LEN,
+/*                      ^^^^^^^^^^^^^^^^^ constant.other.macro.c */
     },
     [SPD_INFO_DEFAULT] = {
+/*   ^^^^^^^^^^^^^^^^ constant.other.macro.c */
         .spd_len = SPD_DEFAULT_LENGTH,
+/*                 ^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
         .spd_part_len = SPD_DEFAULT_PART_LEN,
+/*                      ^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
     },
 };
 
@@ -1152,12 +1158,12 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 /*    ^^^^^^^^^^^^^^ variable.other.c */
 /*                  ^^^^^^^^^^^^^^ meta.brackets.c
 /*                  ^ punctuation.section.brackets.begin.c storage.modifier.c */
-/*                   ^^^^^^^^^^^^ support.constant.c */
+/*                   ^^^^^^^^^^^^ constant.other.macro.c */
 /*                               ^ punctuation.section.brackets.end.c storage.modifier.c */
 /*                                 ^^^^^^^^^ meta.function-call.c variable.function.c */
 /*                                          ^^^^^^^^^^^ meta.function-call.parameters.c
 /*                                          ^ meta.group.c punctuation.section.group.begin.c */
-/*                                           ^^^^^^^^^ support.constant.c */
+/*                                           ^^^^^^^^^ constant.other.macro.c */
 /*                                                    ^ meta.group.c punctuation.section.group.end.c */
 /*                                                     ^ punctuation.terminator.c */
 
@@ -1193,7 +1199,7 @@ struct mac_tfm_ctx {
 /*                        ^ punctuation.terminator.c */
 } __packed __aligned(4);
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
-/*^^^^^^^^ support.type.c */
+/*^^^^^^^^ constant.other.macro.c */
 /*         ^^^^^^^^^ meta.function-call.c variable.function.c */
 /*                  ^^^ meta.function-call.parameters.c
 /*                  ^ meta.group.c punctuation.section.group.begin.c */
@@ -1212,9 +1218,9 @@ void __attributes(int *bar) __must_hold(&foo)
 /*                                      ^ keyword.operator.c
 /*                                       ^^^ variable.other.c */
     __safe
-/*  ^^^^^^ support.type.c */
+/*  ^^^^^^ constant.other.macro.c */
     SAFE
-/*  ^^^^ support.type.c */
+/*  ^^^^ constant.other.macro.c */
     __blah(bar)
 /*  ^^^^^^ meta.function-call.c variable.function.c */
 /*         ^^^ variable.other.c */
@@ -1272,7 +1278,7 @@ char *__attribute__((aligned(8))) *e,
 char *MACRO1 *e,
 /* <- storage.type.c */
 /*   ^ storage.modifier.c */
-/*    ^^^^^^ support.type.c */
+/*    ^^^^^^ constant.other.macro.c */
 /*           ^ storage.modifier.c */
 /*            ^ variable.other.c */
 /*             ^ punctuation.separator.c */
@@ -1281,13 +1287,13 @@ char *MACRO1 *e,
 /* ^ variable.other.c */
 /*  ^ punctuation.separator.c */
   MACRO1 * g,
-/*^^^^^^ support.type.c */
+/*^^^^^^ constant.other.macro.c */
 /*       ^ storage.modifier.c */
 /*         ^ variable.other.c */
 /*          ^ punctuation.separator.c */
   * MACRO1 * h;
 /*^ storage.modifier.c */
-/*  ^^^^^^ support.type.c*/
+/*  ^^^^^^ constant.other.macro.c */
 /*         ^ storage.modifier.c */
 /*           ^ variable.other.c */
 /*            ^ punctuation.terminator.c */
@@ -1295,19 +1301,19 @@ char *MACRO1 *e,
 char *MACRO1 e,
 /* <- storage.type.c */
 /*   ^ storage.modifier.c */
-/*    ^^^^^^ support.type.c */
+/*    ^^^^^^ constant.other.macro.c */
 /*           ^ variable.other.c */
 /*            ^ punctuation.separator.c */
   f,
 /*^ variable.other.c */
 /* ^ punctuation.separator.c */
   MACRO1 g,
-/*^^^^^^ support.type.c */
+/*^^^^^^ constant.other.macro.c */
 /*       ^ variable.other.c */
 /*        ^ punctuation.separator.c */
   * MACRO1 h;
 /*^ storage.modifier.c */
-/*  ^^^^^^ support.type.c*/
+/*  ^^^^^^ constant.other.macro.c */
 /*         ^ variable.other.c */
 /*          ^ punctuation.terminator.c */
 
@@ -1415,14 +1421,14 @@ enum typec_mux {
   TYPEC_MUX_USB  = MUX_USB_ENABLED,
 /*^^^^^^^^^^^^^ entity.name.constant.enum.c */
 /*               ^ keyword.operator.assignment.c */
-/*                 ^^^^^^^^^^^^^^^ support.constant.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 */
-/*                 ^^^^^^^^^^^^^^^ support.constant.c */
+/*                 ^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                 ^ keyword.operator */
-/*                                   ^^^^^^^^^^^^^^ support.constant.c */
+/*                                   ^^^^^^^^^^^^^^ constant.other.macro.c */
 };
 /* <-meta.enum.c meta.block.c punctuation.section.block.end.c */
  /* <- punctuation.terminator.c */
@@ -1561,7 +1567,7 @@ MACRO1 void MACRO2 myfuncname (), MACRO2 foo(), UPPER_VAR, UPPERFN();
 /*                 ^^^^^^^^^^ meta.function.c entity.name.function.c */
 /*                            ^^ meta.group.c*/
 /*                              ^ punctuation.separator.c */
-/*                                ^^^^^^ support.type.c */
+/*                                ^^^^^^ constant.other.macro.c */
 /*                                       ^^^ entity.name.function.c */
 /*                                          ^^ meta.function.parameters.c
 /*                                            ^ punctuation.separator.c */
@@ -1594,7 +1600,7 @@ MACRO1 void * MACRO2 myfuncname () {
 /* <- support.type.c */
 /*     ^^^^ storage.type.c */
 /*          ^ storage.modifier.c */
-/*            ^^^^^^ support.type.c */
+/*            ^^^^^^ constant.other.macro */
 /*                   ^^^^^^^^^^ meta.function */
 /*                              ^^ meta.function.parameters */
 /*                                 ^ meta.block punctuation.section.block.begin
@@ -1639,7 +1645,7 @@ static const uint32_t * const MACRO funcname();
 /*           ^ support.type */
 /*                    ^ storage.modifier.c */
 /*                      ^ storage.modifier */
-/*                            ^^^^^ support.type.c */
+/*                            ^^^^^ constant.other.macro */
 /*                                  ^ entity.name.function */
 
 MACRO int
@@ -1717,6 +1723,7 @@ int32
 
 _declspec(deprecated("bla")) void func2(int) {}
 /* <- meta.function-call variable.function                    */
+/*                           ^^^^ storage.type.c */
 /*                                ^ entity.name.function      */
 __declspec(deprecated("bla")) void func2(int) {}
 /* <- storage.modifier - variable.function                    */
@@ -1729,6 +1736,7 @@ __declspec(deprecated("bla")) void func2(int) {}
 /*                                 ^ entity.name.function     */
 __notdeclspec(deprecated("bla")) void func2(int) {}
 /* <- meta.function-call variable.function                    */
+/*                               ^^^^ storage.type.c */
 /*                                    ^ entity.name.function  */
 
 /////////////////////////////////////////////

From 96191fac1ba5d7d720b19b56cab998b084de2d1c Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 11 Apr 2019 09:43:44 -0600
Subject: [PATCH 19/55] Fix missing comment endings

---
 C++/syntax_test_c.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index b835eb8b6a..0f3cf3b877 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -74,7 +74,7 @@ int func() {
 
   print("// String");
 /*^^^^^ meta.function-call.c variable.function.c */
-/*      ^^^^^^^^^^^ string.quoted.double.c
+/*      ^^^^^^^^^^^ string.quoted.double.c */
 /*      ^ punctuation.definition.string.begin.c */
 /*                ^ punctuation.definition.string.end.c */
 }
@@ -1156,12 +1156,12 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 /* <- support.type.c */
 /*    ^^^^^^^^^^^^^^ variable.other.c */
-/*                  ^^^^^^^^^^^^^^ meta.brackets.c
+/*                  ^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c storage.modifier.c */
 /*                   ^^^^^^^^^^^^ constant.other.macro.c */
 /*                               ^ punctuation.section.brackets.end.c storage.modifier.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 */
 /*                                           ^^^^^^^^^ constant.other.macro.c */
 /*                                                    ^ meta.group.c punctuation.section.group.end.c */
@@ -1180,7 +1180,7 @@ struct mac_tfm_ctx {
 /*^^^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.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 */
 /*                                ^ constant.numeric.c */
 /*                                 ^ meta.group.c punctuation.section.group.end.c */
@@ -1189,7 +1189,7 @@ struct mac_tfm_ctx {
   u8 __aligned(8) consts[];
 /*^^ support.type.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 */
 /*             ^ constant.numeric.c */
 /*              ^ meta.group.c punctuation.section.group.end.c */
@@ -1201,7 +1201,7 @@ struct mac_tfm_ctx {
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^^^ constant.other.macro.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 */
 /*                   ^ constant.numeric.c */
 /*                    ^ meta.group.c punctuation.section.group.end.c */
@@ -1215,7 +1215,7 @@ void __attributes(int *bar) __must_hold(&foo)
 /*                     ^^^ variable.parameter.c */
 /*                          ^^^^^^^^^^^ meta.function-call.c */
 /*                                     ^^^^^^ meta.function-call.parameters.c */
-/*                                      ^ keyword.operator.c
+/*                                      ^ keyword.operator.c */
 /*                                       ^^^ variable.other.c */
     __safe
 /*  ^^^^^^ constant.other.macro.c */
@@ -1232,7 +1232,7 @@ void __attributes(int *bar) __must_hold(&foo)
     __must_hold(&abc->lock)
 /*  ^^^^^^^^^^^ meta.function-call.c */
 /*             ^^^^^^^^^^^^ meta.function-call.parameters.c */
-/*              ^ keyword.operator.c
+/*              ^ keyword.operator.c */
 /*               ^^^ variable.other.c */
 /*                  ^^ punctuation.accessor.c */
 /*                    ^^^^ variable.other.c */
@@ -1569,7 +1569,7 @@ MACRO1 void MACRO2 myfuncname (), MACRO2 foo(), UPPER_VAR, UPPERFN();
 /*                              ^ punctuation.separator.c */
 /*                                ^^^^^^ constant.other.macro.c */
 /*                                       ^^^ entity.name.function.c */
-/*                                          ^^ meta.function.parameters.c
+/*                                          ^^ meta.function.parameters.c */
 /*                                            ^ punctuation.separator.c */
 /*                                              ^^^^^^^^^ variable.other.c */
 /*                                                       ^ punctuation.separator.c */
@@ -1584,7 +1584,7 @@ void func(int pack __attribute__((unused)),
 /*        ^^^ storage.type.c */
 /*            ^^^^ - variable.parameter.c - This is wrong */
 /*                 ^^^^^^^^^^^^^ storage.modifier.c */
-/*                 ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c
+/*                 ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
 /*                                        ^ punctuation.separator.c */
   struct usbip_usb_interface *udev
 /*^^^^^^ storage.type.c */
@@ -1603,7 +1603,7 @@ MACRO1 void * MACRO2 myfuncname () {
 /*            ^^^^^^ constant.other.macro */
 /*                   ^^^^^^^^^^ meta.function */
 /*                              ^^ meta.function.parameters */
-/*                                 ^ meta.block punctuation.section.block.begin
+/*                                 ^ meta.block punctuation.section.block.begin */
 /*     ^ storage.type */
 /*          ^ storage.modifier */
 /*                   ^ entity.name.function */

From baff1a8b68735a484e1bcc392269c621bf1cc0da Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 12 Apr 2019 12:09:22 -0600
Subject: [PATCH 20/55] Support functions without parameter identifiers

i.e., function prototypes.

Also cleaned up more `const.other.macro.c` scopes.
---
 C++/C.sublime-syntax |  96 +++++++++++-----------
 C++/syntax_test_c.c  | 187 +++++++++++++++++++++++++++++++++++++++----
 2 files changed, 220 insertions(+), 63 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 18bd891594..fa12ae03ec 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -149,7 +149,7 @@ contexts:
     - match: '{{attr_macro_identifier}}(?!\s*\()'
       scope: constant.other.macro.c debug.modifiers-macros.underscore
       comment: Preprocessor Attributes
-    - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*)'
+    - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*|\)|\s*\n)'
       scope: constant.other.macro.c debug.modifiers-macros.caps
 
   variables:
@@ -410,50 +410,50 @@ contexts:
         - match : \)
           scope: punctuation.section.group.end.c
           pop: true
-        - match: \(
-          scope: punctuation.section.group.begin.c debug.function-definition-params-group.function-pointer
-          comment: Function pointer declaration
+        - match: ','
+          scope: punctuation.separator.c
+        - include: preprocessor-line-continuation
+        - match: '(?=\S)'
           push:
-            - meta_scope: meta.group.c
-            - match: \)
-              scope: punctuation.section.group.end.c
-              set:
-                - include: function-definition-params-group
-                - include: or_pop
-            - match: \*
-              scope: storage.modifier.c
-            - match: '{{identifier}}'
-              scope: variable.parameter.c debug.function-definition-params-group.function-pointer
-        - match: '\bvoid\b'
-          scope: storage.type.c
+            - parameter-identifier
+            - typedef-types
+
+  parameter-identifier:
+    - meta_scope: debug.parameter-identifier
+    - include: comments
+    - include: modifiers
+    - include: modifiers-parens
+    - include: modifiers-macros
+    - match: \*
+      scope: storage.modifier.c
+    - match: \(
+      scope: punctuation.section.group.begin.c debug.parameter-identifier.function-pointer
+      comment: Function pointer declaration
+      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: \.\.\.
-          scope: keyword.operator.variadic.c
-        - include: modifiers
-        - include: modifiers-parens
-        - match: '{{identifier}}(?=\s*\[)'
-          scope: variable.parameter.c
-          push:
-            - include: comments
-            - match: \[
-              scope: storage.modifier.c punctuation.section.brackets.begin
-              push:
-                - meta_scope: meta.brackets.c
-                - include: comments
-                - match: \]
-                  scope: storage.modifier.c punctuation.section.brackets.end
-                  pop: true
-            - include: or_pop
-        - match: '{{identifier}}(?=\s*(,|\)|\n))'
-          scope: variable.parameter.c
-        - include: types
         - match: '{{identifier}}'
-          scope: support.type.c
-          comment: We match the variable name above
-        - match: ','
-          scope: punctuation.separator.c
-        - include: preprocessor-line-continuation
+          scope: variable.parameter.c debug.parameter-identifier.function-pointer
+    - match: '{{identifier}}'
+      scope: variable.parameter.c debug.parameter-identifier
+      push:
+        - meta_scope: debug.parameter-identifier.array-or-assignment
+        - match: \[
+          scope: punctuation.section.brackets.begin.c storage.modifier.c
+          push:
+            - meta_scope: meta.brackets.c
+            - match: \]
+              scope: punctuation.section.brackets.end.c storage.modifier.c
+              pop: true
+            - include: expressions
+        - include: or_pop
+    - include: or_pop
 
   function-definition-continue:
     - meta_content_scope: meta.function.c
@@ -493,7 +493,7 @@ contexts:
     - match: \*
       scope: storage.modifier.c
     - match: \(
-      scope: punctuation.section.group.begin debug.parameter-variable-identifier.function-pointer
+      scope: punctuation.section.group.begin.c debug.parameter-variable-identifier.function-pointer
       comment: Function pointer declaration as variable
       push:
         - meta_scope: meta.parens
@@ -538,7 +538,7 @@ contexts:
           - include: function-definition-params-group
           - include: or_pop
     - match: \(
-      scope: punctuation.section.group.begin debug.variable-identifier-list.function-pointer
+      scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
       comment: Function pointer declaration
       push:
         - meta_scope: meta.parens
@@ -598,7 +598,7 @@ contexts:
           set: struct-body
         - include: or_pop
   struct-body:
-    - meta_scope: debug.struct-body
+    - meta_content_scope: debug.struct-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
@@ -630,7 +630,7 @@ contexts:
           set: enum-body
         - include: or_pop
   enum-body:
-    - meta_scope: debug.enum-body
+    - meta_content_scope: debug.enum-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
@@ -683,7 +683,7 @@ contexts:
           set: union-body
         - include: or_pop
   union-body:
-    - meta_scope: debug.union-body
+    - meta_content_scope: debug.union-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
@@ -818,6 +818,8 @@ contexts:
     - meta_scope: debug.typedef-types
     - include: comments
     - include: modifiers
+    - include: modifiers-macros
+    - include: modifiers-parens
     # Make sure to pop when a data structure keyword is found
     - match: (?=\bstruct\b)
       set:
@@ -864,7 +866,7 @@ contexts:
             - include: expressions
         - include: or_pop
     - match: '\((?=\s*\*)'
-      scope: punctuation.section.group.begin debug.typedef.function-pointer
+      scope: punctuation.section.group.begin.c debug.typedef.function-pointer
       comment: Function pointers
       set:
         - meta_scope: meta.parens
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 0f3cf3b877..612caea906 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -150,7 +150,7 @@ UserStructCompare (
 }
 
 LIB_RESULT
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 foo()
 /* <- meta.function entity.name.function */
 {
@@ -160,7 +160,7 @@ foo()
 /* <- meta.function.c punctuation.section.block.end.c */
 
 LIB_RESULT bar()
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 /*           ^ meta.function entity.name.function */
 {
 /* <- meta.function.c punctuation.section.block.begin.c */
@@ -169,7 +169,7 @@ LIB_RESULT bar()
 /* <- meta.function.c punctuation.section.block.end.c */
 
 THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE
-/* <- support.type */
+/* <- constant.other.macro.c */
 
 int main() {
 /* <- storage.type */
@@ -220,7 +220,7 @@ int disabled_func() {
 #endif
 
 FOO
-/* <- support.type */
+/* <- constant.other.macro.c */
 FOO;
 /* <- variable.other */
 foo
@@ -435,6 +435,158 @@ typedef enum state {DEAD,ALIVE} State;
 /*                              ^^^^^ entity.name.type.typedef.c */
 /*                                   ^ punctuation.terminator.c */
 
+/////////////////////////////////////////////
+// Parameter Declarations
+/////////////////////////////////////////////
+
+typedef void (*attrs_t)(
+/* <- storage.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 */
+/*                           ^^^^^^ storage.type.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 */
+/*              ^^^ variable.other.c */
+/*                 ^ punctuation.terminator.c */
+  volatile MACRO foo;
+/*^^^^^^^^ storage.modifier.c */
+/*         ^^^^^ constant.other.macro.c */
+/*               ^^^ variable.other.c */
+/*                  ^ punctuation.terminator.c */
+  MACRO int MACRO bar;
+/*^^^^^ constant.other.macro.c */
+/*      ^^^ storage.type.c */
+/*          ^^^^^ constant.other.macro.c */
+/*                ^^^ variable.other.c */
+/*                   ^ punctuation.terminator.c */
+
 /////////////////////////////////////////////
 // Data structures and return values
 /////////////////////////////////////////////
@@ -718,8 +870,8 @@ static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 /*                                                    ^^^^ variable.parameter.c */
 /*                                                        ^ punctuation.separator.c */
     __le64 __iomem *regs);
-/*  ^^^^^^ support.type.c */
-/*         ^^^^^^^ support.type.c */
+/*  ^^^^^^ 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 */
@@ -1071,7 +1223,7 @@ void do_pci_scan_bridge(struct device *dev,
 /*     ^ 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.group.end.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 */
@@ -1356,12 +1508,12 @@ char *__aligned(8) *e,
 /*                  ^ punctuation.terminator.c */
 
 MACRO1 UPPER_VAR;
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 /*     ^^^^^^^^^ variable.other.c */
 /*              ^ punctuation.terminator.c */
 
 __safe UPPER_VAR;
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 /*     ^^^^^^^^^ variable.other.c */
 /*              ^ punctuation.terminator.c */
 
@@ -1544,26 +1696,26 @@ int /* comment */ * myfunc
 }
 
 MACRO1
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 RETURN_TYPE
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 func_name() {
 /* < entity.name.function */
 }
 
 MACRO1 void MACRO2 * myfuncname ();
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 /*     ^ storage.type.c */
-/*          ^ support.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();
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 /*     ^ storage.type.c */
-/*          ^ support.type.c */
+/*          ^ constant.other.macro.c */
 /*                 ^^^^^^^^^^ meta.function.c entity.name.function.c */
 /*                            ^^ meta.group.c*/
 /*                              ^ punctuation.separator.c */
@@ -1597,7 +1749,7 @@ void func(int pack __attribute__((unused)),
 /*                        ^ punctuation.terminator.c */
 
 MACRO1 void * MACRO2 myfuncname () {
-/* <- support.type.c */
+/* <- constant.other.macro.c */
 /*     ^^^^ storage.type.c */
 /*          ^ storage.modifier.c */
 /*            ^^^^^^ constant.other.macro */
@@ -1725,6 +1877,7 @@ _declspec(deprecated("bla")) void func2(int) {}
 /* <- meta.function-call variable.function                    */
 /*                           ^^^^ storage.type.c */
 /*                                ^ entity.name.function      */
+/*                                      ^^^ storage.type.c */
 __declspec(deprecated("bla")) void func2(int) {}
 /* <- storage.modifier - variable.function                    */
 /*         ^ storage.modifier - variable.function             */
@@ -1734,10 +1887,12 @@ __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                    */
 /*                               ^^^^ storage.type.c */
 /*                                    ^ entity.name.function  */
+/*                                          ^^^ storage.type.c */
 
 /////////////////////////////////////////////
 // Test function call in function parameters

From 7abc5f4b4b59695361e786a5d3bb41a04c077990 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 12 Apr 2019 12:13:53 -0600
Subject: [PATCH 21/55] Delete expression in param declarations

Supporting this invalid syntax is difficult.
---
 C++/syntax_test_c.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 612caea906..e206af0e9a 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1894,19 +1894,6 @@ __notdeclspec(deprecated("bla")) void func2(int) {}
 /*                                    ^ entity.name.function  */
 /*                                          ^^^ storage.type.c */
 
-/////////////////////////////////////////////
-// 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 */
-
 func_call(foo
 /*^^^^^^^^^^^ meta.function-call */
 /*       ^^^^ meta.group */

From f255503fa00ab1ab9fb598e8d17e741a71e85ce0 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 12 Apr 2019 12:21:36 -0600
Subject: [PATCH 22/55] Remove unused metascope

---
 C++/C.sublime-syntax | 1 -
 1 file changed, 1 deletion(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index fa12ae03ec..4762ba94db 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -479,7 +479,6 @@ contexts:
         - include: statements
 
   data-structures:
-    - meta_scope: debug.data-structures
     - include: struct-keyword
     - include: union-keyword
     - include: enum-keyword

From 549b4d00197842cea51a2c0fb86cf5c953505e05 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 12 Apr 2019 16:44:10 -0600
Subject: [PATCH 23/55] Fix missing comment scope

---
 C++/C.sublime-syntax |  1 +
 C++/syntax_test_c.c  | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 4762ba94db..9802e9b231 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -367,6 +367,7 @@ contexts:
     - match: (?={{identifier}}\s*\()
       set:
         - - meta_scope: debug.global-function-call.type-or-terminator
+          - include: comments
           - match: ';'
             scope: punctuation.terminator.c debug.global-function-call
             pop: true
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index e206af0e9a..e5ce46eb20 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -858,6 +858,17 @@ MACRO_CALL_NO_SEMI(
 )
 /* <- meta.function-call.parameters.c punctuation.section.group.end.c */
 
+SHOW(temp0, temp0)   /* a comment */
+/* <- meta.function-call.c variable.function.c */
+/*   ^^^^ variable.other.c */
+/*          ^^^^^ variable.other.c */
+/*                   ^^^^^^^^^^^^^^^ comment.block.c */
+SHOW(temp1, temp1)   /* a comment */
+/* <- meta.function-call.c variable.function.c */
+/*   ^^^^ variable.other.c */
+/*          ^^^^^ variable.other.c */
+/*                   ^^^^^^^^^^^^^^^ comment.block.c */
+
 static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 /*<- storage.modifier.c */
 /*     ^^^^^^ storage.modifier.c */

From 9f90c28dcab6642603bcafa8e59a6d86bea5d0a5 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 12 Apr 2019 16:46:22 -0600
Subject: [PATCH 24/55] Add constant macros and support types to reference list

Navigating is sooo much nicer now!

I still need to get variables indexed correctly.
---
 C++/Indexed Reference List.tmPreferences | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 C++/Indexed Reference List.tmPreferences

diff --git a/C++/Indexed Reference List.tmPreferences b/C++/Indexed Reference List.tmPreferences
new file mode 100644
index 0000000000..b82e888425
--- /dev/null
+++ b/C++/Indexed Reference List.tmPreferences	
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+    <key>scope</key>
+    <string>
+        source.c constant.other.macro.c,
+        source.c support.type.c
+    </string>
+    <key>settings</key>
+    <dict>
+        <key>showInIndexedReferenceList</key>
+        <string>1</string>
+    </dict>
+</dict>
+</plist>

From c1d35148e4b72b2f0ed2ee337c8ef60f71c3bd0c Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 15 Apr 2019 10:59:47 -0600
Subject: [PATCH 25/55] Support variable.other.member.c

---
 C++/C.sublime-syntax | 44 +++++++++++++++++++++++-
 C++/syntax_test_c.c  | 82 ++++++++++++++++++++++----------------------
 2 files changed, 84 insertions(+), 42 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 9802e9b231..07e9e11c2a 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -579,6 +579,48 @@ contexts:
       pop: true
     - include: or_pop
 
+  member-variable-identifier-list:
+    - meta_scope: debug.member-variable-identifier-list
+    - include: comments
+    - include: modifiers
+    - include: modifiers-parens
+    - include: modifiers-macros
+    - match: \*
+      scope: storage.modifier.c
+    - match: \(
+      scope: punctuation.section.group.begin.c debug.member-variable-identifier-list.function-pointer
+      comment: Function pointer declaration
+      push:
+        - meta_scope: meta.parens
+        - match: \)
+          scope: punctuation.section.parens.end
+          set:
+            - include: function-definition-params-group
+            - include: or_pop
+        - match: \*
+          scope: storage.modifier.c
+        - match: '{{identifier}}'
+          scope: variable.other.member.c debug.member-variable-identifier-list.function-pointer
+    - match: '{{identifier}}'
+      scope: variable.other.member.c debug.member-variable-identifier-list
+      push:
+        - meta_scope: debug.member-variable-identifier-list.array-or-assignment
+        - match: \[
+          scope: punctuation.section.brackets.begin.c storage.modifier.c
+          push:
+            - meta_scope: meta.brackets.c
+            - match: \]
+              scope: punctuation.section.brackets.end.c storage.modifier.c
+              pop: true
+            - include: expressions
+        - include: or_pop
+    - match: ','
+      scope: punctuation.separator.c debug.member-variable-identifier-list
+    - match: ';'
+      scope: punctuation.terminator.c
+      pop: true
+    - include: or_pop
+
   struct-keyword:
     - match: '\bstruct\b'
       scope: storage.type.c
@@ -710,7 +752,7 @@ contexts:
     - include: modifiers-parens
     - match: '(?=\S)'
       push:
-        - variable-identifier-list
+        - member-variable-identifier-list
         - typedef-types
 
   block:
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index e5ce46eb20..15a34a175f 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -299,7 +299,7 @@ typedef struct mystruct {
 /*                      ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int a;
 /*^^^ storage.type.c */
-/*    ^ variable.other.c */
+/*    ^ variable.other.member.c */
 } mystruct;
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^^^ entity.name.type */
@@ -313,7 +313,7 @@ typedef struct another
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int f;
 /*^^^ storage.type.c */
-/*    ^ variable.other.c */
+/*    ^ variable.other.member.c */
 } another_t, another2_t;
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^^^^ entity.name.type */
@@ -383,7 +383,7 @@ typedef struct {
 /*             ^ meta.struct.body.c punctuation.section.block.begin.c */
     int data1;
 /*  ^^^ storage.type.c */
-/*      ^^^^^ variable.other.c */
+/*      ^^^^^ variable.other.member.c */
 } newtype;
 /* <- meta.struct.body.c punctuation.section.block.end.c */
 /*^^^^^^^ entity.name.type.typedef.c */
@@ -395,7 +395,7 @@ typedef struct MyStruct {
 /*                      ^ meta.struct.body.c punctuation.section.block.begin.c */
     int data1;
 /*  ^^^ storage.type.c */
-/*      ^^^^^ variable.other.c */
+/*      ^^^^^ variable.other.member.c */
 } newtype;
 /* <- meta.struct.body.c punctuation.section.block.end.c */
 /*^^^^^^^ entity.name.type.typedef.c */
@@ -689,7 +689,7 @@ struct {
 /*     ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int a;
 /*^^^ storage.type.c */
-/*    ^ variable.other.c */
+/*    ^ variable.other.member.c */
 } anon_s, *anon_b, anon_s_f(), anon_c = {
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^ variable.other.c  */
@@ -717,7 +717,7 @@ int f_with_s(struct { int a; } *s);
 /*           ^^^^^^ meta.struct.c storage.type.c */
 /*                  ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
 /*                    ^^^ storage.type.c */
-/*                        ^ variable.other.c */
+/*                        ^ variable.other.member.c */
 /*                           ^ meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*                             ^ storage.modifier.c */
 /*                              ^ variable.parameter.c */
@@ -944,58 +944,58 @@ struct UI_MenuBoxData
     struct UI_BoundingBox position;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
-/*                        ^ variable.other.c - entity.name */
+/*                        ^ variable.other.member.c */
 /*                                ^ punctuation.terminator.c */
     struct UI_BoundingBox *position_p;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                         ^ variable.other.c - entity.name */
+/*                         ^ variable.other.member.c */
 /*                                   ^ punctuation.terminator.c */
     struct UI_BoundingBox * position_p1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                          ^ variable.other.c - entity.name */
+/*                          ^ variable.other.member.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox **position_p2;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
-/*                          ^ variable.other.c - entity.name */
+/*                          ^ variable.other.member.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox ** position_p3;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
-/*                           ^ variable.other.c - entity.name */
+/*                           ^ variable.other.member.c */
 /*                                      ^ punctuation.terminator.c */
     struct UI_BoundingBox* position_p4;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ storage.modifier.c */
-/*                         ^ variable.other.c - entity.name */
+/*                         ^ variable.other.member.c */
 /*                                    ^ punctuation.terminator.c */
     struct UI_BoundingBox** position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^^ storage.modifier.c */
-/*                          ^ variable.other.c - entity.name */
+/*                          ^ variable.other.member.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox * * position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
 /*                          ^ storage.modifier.c */
-/*                            ^ variable.other.c - entity.name */
+/*                            ^ variable.other.member.c */
 /*                                       ^ punctuation.terminator.c */
     struct UI_BoundingBox *pos_1, *pos_1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                         ^ variable.other.c - entity.name */
+/*                         ^ variable.other.member.c */
 /*                                ^ storage.modifier.c */
-/*                                 ^ variable.other.c - entity.name */
+/*                                 ^ variable.other.member.c */
 /*                                      ^ punctuation.terminator.c */
 
     const volatile struct UI_BoundingBox *cv_p;
@@ -1004,11 +1004,11 @@ struct UI_MenuBoxData
 /*                 ^^^^^^ storage.type */
 /*                        ^ support.type.c - entity.name */
 /*                                       ^ storage.modifier.c */
-/*                                        ^ variable.other.c - entity.name */
+/*                                        ^ variable.other.member.c */
 /*                                            ^ punctuation.terminator.c */
     long resume_done[USB_MAXCHILDREN];
 /*  ^^^^ storage.type.c */
-/*       ^^^^^^^^^^^ variable.other.c */
+/*       ^^^^^^^^^^^ variable.other.member.c */
 /*                  ^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^^^^^^^^^^^^^^^ constant.other.macro.c */
@@ -1019,14 +1019,14 @@ struct UI_MenuBoxData
 /*         ^ support.type.c - entity.name */
 /*                       ^ constant.other.macro.c */
 /*                               ^ storage.modifier.c */
-/*                                 ^ variable.other.c - entity.name */
+/*                                 ^ variable.other.member.c */
 /*                                        ^ punctuation.terminator.c */
     struct xhci_run_regs __attribute__((noderef)) *run_regs;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ - entity.name */
 /*                                                ^ storage.modifier.c */
-/*                                                 ^ variable.other.c - entity.name */
+/*                                                 ^ variable.other.member.c */
 /*                                                         ^ punctuation.terminator.c */
     struct __attribute__((noderef)) xhci_run_regs *run_regs;
 /*  ^^^^^^ storage.type */
@@ -1040,10 +1040,10 @@ struct UI_MenuBoxData
 /*                  ^ meta.struct.body.c meta.block.c meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
         int bar;
 /*      ^^^ storage.type.c */
-/*          ^^^ variable.other.c */
+/*          ^^^ variable.other.member.c */
     } nested;
 /*  ^ meta.struct.body.c meta.block.c meta.struct.body.c meta.block.c punctuation.section.block.end.c */
-/*    ^^^^^^ variable.other.c */
+/*    ^^^^^^ variable.other.member.c */
 /*          ^ punctuation.terminator.c */
 
 #define CMD_RING_STATE_RUNNING         (1 << 0)
@@ -1053,29 +1053,29 @@ struct UI_MenuBoxData
     enum UI_BoxCharType borderType;
 /*  ^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.c - entity.name */
-/*                      ^ variable.other.c - entity.name */
+/*                      ^ variable.other.member.c */
 /*                                ^ punctuation.terminator.c */
     unsigned int paddingX;
 /*  ^^^^^^^^ storage.type.c */
 /*           ^^^ storage.type.c */
-/*               ^^^^^^^^ variable.other.c */
+/*               ^^^^^^^^ variable.other.member.c */
 /*                       ^ punctuation.terminator.c */
     unsigned int paddingY;
 /*  ^^^^^^^^ storage.type.c */
 /*           ^^^ storage.type.c */
-/*               ^^^^^^^^ variable.other.c */
+/*               ^^^^^^^^ variable.other.member.c */
 /*                       ^ punctuation.terminator.c */
     struct UI_ScrollBoxText boxContents[];
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^^^ support.type.c */
-/*                          ^^^^^^^^^^^ variable.other.c */
+/*                          ^^^^^^^^^^^ variable.other.member.c */
 /*                                     ^ storage.modifier.c */
 /*                                       ^ punctuation.terminator.c */
 
     struct delayed_work monitor_work ____cacheline_aligned_in_smp;
 /*  ^^^^^^ storage.type */
 /*         ^^^^^^^^^^^^ support.type.c */
-/*                      ^^^^^^^^^^^^ variable.other.c */
+/*                      ^^^^^^^^^^^^ variable.other.member.c */
 /*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                                               ^ punctuation.terminator.c */
     const struct efx_channel_type *
@@ -1084,7 +1084,7 @@ struct UI_MenuBoxData
 /*               ^^^^^^^^^^^^^^^^ support.type - entity.name */
 /*                                ^ storage.modifier.c */
     extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
-/*  ^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*  ^^^^^^^^^^^^^^^^^^ variable.other.member.c */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                     ^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                    ^ punctuation.section.brackets.begin.c storage.modifier.c */
@@ -1109,7 +1109,7 @@ struct __attribute__((packed)) child_t {
 /*                             ^^^^^^^ entity.name.struct */
     int foo;
 /*  ^^^ storage.type.c */
-/*      ^^^ variable.other.c */
+/*      ^^^ variable.other.member.c */
 };
 
 struct child_t child1;
@@ -1121,7 +1121,7 @@ struct __attribute__((packed)) child_t_line
 {
     int foo;
 /*  ^^^ storage.type.c */
-/*      ^^^ variable.other.c */
+/*      ^^^ variable.other.member.c */
 };
 
 struct __attribute__((packed))
@@ -1131,7 +1131,7 @@ struct __attribute__((packed))
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int foo;
 /*  ^^^ storage.type.c */
-/*      ^^^ variable.other.c */
+/*      ^^^ variable.other.member.c */
 };
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 
@@ -1141,13 +1141,13 @@ struct rproc_ops {
 /*               ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int (*start)(struct rproc *rproc);
 /*  ^^^ storage.type.c */
-/*        ^^^^^ variable.other.c */
+/*        ^^^^^ variable.other.member.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
 /*                             ^^^^^ variable.parameter.c */
     int (*start)(struct rproc *);
 /*  ^^^ storage.type.c */
-/*        ^^^^^ variable.other.c */
+/*        ^^^^^ variable.other.member.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
@@ -1155,7 +1155,7 @@ struct rproc_ops {
 /*                             ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */
     u32 (*start)(struct rproc *, struct rproc *);
 /*  ^^^ support.type.c */
-/*        ^^^^^ variable.other.c */
+/*        ^^^^^ variable.other.member.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
@@ -1167,7 +1167,7 @@ struct rproc_ops {
 /*                                             ^ 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 */
-/*           ^^^^^^^^ variable.other.c */
+/*           ^^^^^^^^ variable.other.member.c */
 /*                     ^^^^^^ storage.type.c */
 /*                            ^^^^^ support.type.c */
 /*                                   ^^^^^ variable.parameter.c */
@@ -1178,7 +1178,7 @@ struct rproc_ops {
     struct resource_table *(*find_loaded_rsc_table)(
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^ support.type.c */
-/*                           ^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                           ^^^^^^^^^^^^^^^^^^^^^ variable.other.member.c */
                 struct rproc *rproc, const struct firmware *fw);
 /*              ^^^^^^ storage.type.c */
 /*                     ^^^^^ support.type.c */
@@ -1275,10 +1275,10 @@ static const struct spd_info {
 /*                  ^^^^^^^^ entity.name.struct.c */
     size_t spd_len;
 /*  ^^^^^^ support.type */
-/*         ^^^^^^^ variable.other.c */
+/*         ^^^^^^^ variable.other.member.c */
     size_t spd_part_len;
 /*  ^^^^^^ support.type */
-/*         ^^^^^^^ variable.other.c */
+/*         ^^^^^^^ variable.other.member.c */
 } spd_mem_info[] = {
 /*^^^^^^^^^^^^  variable.other.c */
 /*            ^^ meta.brackets.c storage.modifier.c */
@@ -1337,7 +1337,7 @@ struct mac_tfm_ctx {
   struct crypto_aes_ctx key;
 /*^^^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.c */
-/*                      ^^^ variable.other.c */
+/*                      ^^^ variable.other.member.c */
 /*                         ^ punctuation.terminator.c */
   struct crypto_aes_ctx __aligned(8) key2;
 /*^^^^^^ storage.type.c */
@@ -1347,7 +1347,7 @@ struct mac_tfm_ctx {
 /*                               ^ meta.group.c punctuation.section.group.begin.c */
 /*                                ^ constant.numeric.c */
 /*                                 ^ meta.group.c punctuation.section.group.end.c */
-/*                                   ^^^^ variable.other.c */
+/*                                   ^^^^ variable.other.member.c */
 /*                                       ^ punctuation.terminator.c */
   u8 __aligned(8) consts[];
 /*^^ support.type.c */
@@ -1356,7 +1356,7 @@ struct mac_tfm_ctx {
 /*            ^ meta.group.c punctuation.section.group.begin.c */
 /*             ^ constant.numeric.c */
 /*              ^ meta.group.c punctuation.section.group.end.c */
-/*                ^^^^^^ variable.other.c */
+/*                ^^^^^^ variable.other.member.c */
 /*                      ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
 /*                       ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
 /*                        ^ punctuation.terminator.c */

From 4660097a2dd4d4da687d521d653a0d9efb0f179c Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 15 Apr 2019 11:05:36 -0600
Subject: [PATCH 26/55] Scope global vars as entity.name.variable.c

We can now navigate to global variables with Goto Definition and Goto
References. Don't know if the indexing is too aggressive now.
---
 C++/C.sublime-syntax                     |   4 +-
 C++/Indexed Reference List.tmPreferences |   3 +-
 C++/Symbol List.tmPreferences            |   2 +-
 C++/syntax_test_c.c                      | 108 +++++++++++------------
 4 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 07e9e11c2a..1e8983d5ac 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -550,9 +550,9 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.other.c debug.variable-identifier-list.function-pointer
+          scope: entity.name.variable.c debug.variable-identifier-list.function-pointer
     - match: '{{identifier}}'
-      scope: variable.other.c debug.variable-identifier-list
+      scope: entity.name.variable.c debug.variable-identifier-list
       push:
         - meta_scope: debug.variable-identifier-list.array-or-assignment
         - match: \[
diff --git a/C++/Indexed Reference List.tmPreferences b/C++/Indexed Reference List.tmPreferences
index b82e888425..fbd673eacb 100644
--- a/C++/Indexed Reference List.tmPreferences	
+++ b/C++/Indexed Reference List.tmPreferences	
@@ -5,7 +5,8 @@
     <key>scope</key>
     <string>
         source.c constant.other.macro.c,
-        source.c support.type.c
+        source.c support.type.c,
+        source.c variable.other.c
     </string>
     <key>settings</key>
     <dict>
diff --git a/C++/Symbol List.tmPreferences b/C++/Symbol List.tmPreferences
index e2373a45b8..5998549eb4 100644
--- a/C++/Symbol List.tmPreferences	
+++ b/C++/Symbol List.tmPreferences	
@@ -4,7 +4,7 @@
 	<key>name</key>
 	<string>Symbol List</string>
 	<key>scope</key>
-	<string><![CDATA[(source.c | source.c++ | source.objc | source.objc++) & (entity.name.class | entity.name.struct | entity.name.union | entity.name.enum)]]></string>
+	<string><![CDATA[(source.c | source.c++ | source.objc | source.objc++) & (entity.name.class | entity.name.struct | entity.name.union | entity.name.enum | entity.name.variable)]]></string>
 	<key>settings</key>
 	<dict>
 		<key>showInSymbolList</key>
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 15a34a175f..668ea210fb 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -117,12 +117,12 @@ int f(int x, \
 
 bool still_C_code_here = true, foo = false;
 /* <- storage.type */
-/*   ^^^^^^^^^^^^^^^^^ variable.other.c */
+/*   ^^^^^^^^^^^^^^^^^ entity.name.variable.c */
 /*                     ^ keyword.operator.assignment.c */
 /*                       ^ constant.language */
 /*                                        ^ punctuation.terminator.c */
 /*                           ^ punctuation.separator.c */
-/*                             ^^^ variable.other.c*/
+/*                             ^^^ entity.name.variable.c*/
 /*                                 ^ keyword.operator.assignment.c */
 /*                                   ^^^^^ constant.language.c */
 /*                                        ^ punctuation.terminator.c */
@@ -222,7 +222,7 @@ int disabled_func() {
 FOO
 /* <- constant.other.macro.c */
 FOO;
-/* <- variable.other */
+/* <- entity.name.variable.c */
 foo
 /* <- support.type */
 ; // fix highlighting
@@ -573,18 +573,18 @@ static string foo(__attribute__((unused)));
   __unused char foo;
 /*^^^^^^^^ constant.other.macro.c */
 /*         ^^^^ storage.type.c */
-/*              ^^^ variable.other.c */
+/*              ^^^ entity.name.variable.c */
 /*                 ^ punctuation.terminator.c */
   volatile MACRO foo;
 /*^^^^^^^^ storage.modifier.c */
 /*         ^^^^^ constant.other.macro.c */
-/*               ^^^ variable.other.c */
+/*               ^^^ entity.name.variable.c */
 /*                  ^ punctuation.terminator.c */
   MACRO int MACRO bar;
 /*^^^^^ constant.other.macro.c */
 /*      ^^^ storage.type.c */
 /*          ^^^^^ constant.other.macro.c */
-/*                ^^^ variable.other.c */
+/*                ^^^ entity.name.variable.c */
 /*                   ^ punctuation.terminator.c */
 
 /////////////////////////////////////////////
@@ -682,7 +682,7 @@ struct point FOO_API *alloc_point3(), alloc_point2(), struct_var2;
 /*                                 ^ punctuation.section.group.end.c */
 /*                                  ^ punctuation.separator */
 /*                                    ^ entity.name.function - variable.function */
-/*                                                    ^^^^^^^^^^^ variable.other.c */
+/*                                                    ^^^^^^^^^^^ entity.name.variable.c */
 
 struct {
 /* <- storage.type.c */
@@ -692,22 +692,22 @@ struct {
 /*    ^ variable.other.member.c */
 } anon_s, *anon_b, anon_s_f(), anon_c = {
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
-/*^^^^^^ variable.other.c  */
-/*         ^^^^^^ variable.other.c  */
+/*^^^^^^ entity.name.variable.c  */
+/*         ^^^^^^ entity.name.variable.c  */
 /*                 ^^^^^^^^ entity.name.function.c  */
-/*                             ^^^^^^ variable.other.c  */
+/*                             ^^^^^^ entity.name.variable.c  */
 /*                                    ^ keyword.operator.assignment.c */
   .a = 4
 }, anon_d = {.a = 6}, anon_arr[] = {{.a = 1}, {.a = 2}}, anon_g;
  /* <- punctuation.separator */
-/* ^^^^^^ variable.other.c  */
+/* ^^^^^^ entity.name.variable.c  */
 /*        ^ keyword.operator.assignment.c */
 /*                  ^ punctuation.separator */
-/*                    ^^^^^^^^ variable.other.c  */
+/*                    ^^^^^^^^ entity.name.variable.c  */
 /*                            ^^ meta.brackets.c storage.modifier.c */
 /*                               ^ keyword.operator.assignment.c */
 /*                                                     ^ punctuation.separator */
-/*                                                       ^^^^^^ variable.other.c  */
+/*                                                       ^^^^^^ entity.name.variable.c  */
 /*                                                             ^ punctuation.terminator.c */
 
 int f_with_s(struct { int a; } *s);
@@ -903,34 +903,34 @@ struct MACRO foo {
 
 struct UI_BoundingBox position;
 /*     ^ support.type.c - entity.name */
-/*                     ^ variable.other - entity.name */
+/*                     ^ entity.name.variable.c */
 
 struct UI_BoundingBox *position_p;
 /*     ^ support.type.c - entity.name */
-/*                     ^ variable.other - entity.name */
+/*                     ^ entity.name.variable.c */
 
 struct UI_BoundingBox * position_p1;
 /*     ^ support.type.c - entity.name */
-/*                      ^ variable.other - entity.name */
+/*                      ^ entity.name.variable.c */
 
 struct UI_BoundingBox **position_p2;
 /*     ^ support.type.c - entity.name */
-/*                      ^ variable.other - entity.name */
+/*                      ^ entity.name.variable.c */
 
 struct UI_BoundingBox ** position_p3;
 /*     ^ support.type.c - entity.name */
-/*                       ^ variable.other - entity.name */
+/*                       ^ entity.name.variable.c */
 
 
 struct UI_BoundingBox ** position_p4, position_p5, * position_p6;
 /*     ^ support.type.c - entity.name */
-/*                       ^ variable.other - entity.name */
+/*                       ^ entity.name.variable.c */
 /*                    ^^ storage.modifier.c */
 /*                                  ^ punctuation.separator */
-/*                                    ^ variable.other - entity.name */
+/*                                    ^ entity.name.variable.c */
 /*                                               ^ punctuation.separator */
 /*                                                 ^ storage.modifier.c */
-/*                                                   ^ variable.other - entity.name */
+/*                                                   ^ entity.name.variable.c */
 
 // Partially-typed
 struct foo
@@ -1194,7 +1194,7 @@ struct rproc_ops {
 
 void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
 /* <- storage.type.c */
-/*       ^^^^^^^^ variable.other.c */
+/*       ^^^^^^^^ entity.name.variable.c */
 /*                 ^^^^^^ storage.type.c */
 /*                        ^^^^^ support.type.c */
 /*                              ^ storage.modifier.c */
@@ -1207,7 +1207,7 @@ void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
 struct resource_table *(*find_loaded_rsc_table)(
 /* <- storage.type.c */
 /*     ^^^^^^^^^^^^^^ support.type.c */
-/*                       ^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                       ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.c */
             struct rproc *rproc, const struct firmware *fw);
 /*          ^^^^^^ storage.type.c */
 /*                 ^^^^^ support.type.c */
@@ -1247,7 +1247,7 @@ static const struct pci_driver my_driver __pci_driver __driver = {
 /*     ^^^^^ storage.modifier.c */
 /*           ^^^^^^ storage.type.c */
 /*                  ^^^^^^^^^^ support.type.c */
-/*                             ^^^^^^^^^ variable.other.c */
+/*                             ^^^^^^^^^ entity.name.variable.c */
 /*                                       ^^^^^^^^^^^^ constant.other.macro.c */
 /*                                                    ^^^^^^^^ constant.other.macro.c */
   .ops      = &pci_my_device_ops,
@@ -1280,7 +1280,7 @@ static const struct spd_info {
 /*  ^^^^^^ support.type */
 /*         ^^^^^^^ variable.other.member.c */
 } spd_mem_info[] = {
-/*^^^^^^^^^^^^  variable.other.c */
+/*^^^^^^^^^^^^  entity.name.variable.c */
 /*            ^^ meta.brackets.c storage.modifier.c */
     [SPD_INFO_DDR4] = {
 /*   ^^^^^^^^^^^^^ constant.other.macro.c */
@@ -1302,7 +1302,7 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 /* <- storage.type.c */
 /*   ^ storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */
-/*           ^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*           ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.c */
 /*                                ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
 /*                                                     ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
 /*                                                       ^^^^^^^^^ meta.function-call.c variable.function.c */
@@ -1318,7 +1318,7 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 /* <- support.type.c */
-/*    ^^^^^^^^^^^^^^ variable.other.c */
+/*    ^^^^^^^^^^^^^^ entity.name.variable.c */
 /*                  ^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c storage.modifier.c */
 /*                   ^^^^^^^^^^^^ constant.other.macro.c */
@@ -1419,23 +1419,23 @@ char *__attribute__((aligned(8))) *e,
 /*    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
 /*    ^^^^^^^^^^^^^ storage.modifier.c */
 /*                                ^ storage.modifier.c */
-/*                                 ^ variable.other.c */
+/*                                 ^ entity.name.variable.c */
 /*                                  ^ punctuation.separator.c */
   *f,
 /*^ storage.modifier.c */
-/* ^ variable.other.c */
+/* ^ entity.name.variable.c */
 /*  ^ punctuation.separator.c */
   __attribute__((aligned(8))) * g,
 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
 /*^^^^^^^^^^^^^ storage.modifier.c */
 /*                            ^ storage.modifier.c */
-/*                              ^ variable.other.c */
+/*                              ^ entity.name.variable.c */
 /*                               ^ punctuation.separator.c */
   * __attribute__((aligned(8))) h;
 /*^ storage.modifier.c */
 /*  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
 /*  ^^^^^^^^^^^^^ storage.modifier.c */
-/*                              ^ variable.other.c */
+/*                              ^ entity.name.variable.c */
 /*                               ^ punctuation.terminator.c */
 
 char *MACRO1 *e,
@@ -1443,41 +1443,41 @@ char *MACRO1 *e,
 /*   ^ storage.modifier.c */
 /*    ^^^^^^ constant.other.macro.c */
 /*           ^ storage.modifier.c */
-/*            ^ variable.other.c */
+/*            ^ entity.name.variable.c */
 /*             ^ punctuation.separator.c */
   *f,
 /*^ storage.modifier.c */
-/* ^ variable.other.c */
+/* ^ entity.name.variable.c */
 /*  ^ punctuation.separator.c */
   MACRO1 * g,
 /*^^^^^^ constant.other.macro.c */
 /*       ^ storage.modifier.c */
-/*         ^ variable.other.c */
+/*         ^ entity.name.variable.c */
 /*          ^ punctuation.separator.c */
   * MACRO1 * h;
 /*^ storage.modifier.c */
 /*  ^^^^^^ constant.other.macro.c */
 /*         ^ storage.modifier.c */
-/*           ^ variable.other.c */
+/*           ^ entity.name.variable.c */
 /*            ^ punctuation.terminator.c */
 
 char *MACRO1 e,
 /* <- storage.type.c */
 /*   ^ storage.modifier.c */
 /*    ^^^^^^ constant.other.macro.c */
-/*           ^ variable.other.c */
+/*           ^ entity.name.variable.c */
 /*            ^ punctuation.separator.c */
   f,
-/*^ variable.other.c */
+/*^ entity.name.variable.c */
 /* ^ punctuation.separator.c */
   MACRO1 g,
 /*^^^^^^ constant.other.macro.c */
-/*       ^ variable.other.c */
+/*       ^ entity.name.variable.c */
 /*        ^ punctuation.separator.c */
   * MACRO1 h;
 /*^ storage.modifier.c */
 /*  ^^^^^^ constant.other.macro.c */
-/*         ^ variable.other.c */
+/*         ^ entity.name.variable.c */
 /*          ^ punctuation.terminator.c */
 
 char *__aligned(8) *e,
@@ -1485,59 +1485,59 @@ char *__aligned(8) *e,
 /*   ^ storage.modifier.c */
 /*    ^^^^^^^^^^^^ meta.function-call */
 /*                 ^ storage.modifier.c */
-/*                  ^ variable.other.c */
+/*                  ^ entity.name.variable.c */
 /*                   ^ punctuation.separator.c */
   *f,
 /*^ storage.modifier.c */
-/* ^ variable.other.c */
+/* ^ entity.name.variable.c */
 /*  ^ punctuation.separator.c */
   __aligned(8) * g,
 /*^^^^^^^^^^^^ meta.function-call */
 /*             ^ storage.modifier.c */
-/*               ^ variable.other.c */
+/*               ^ entity.name.variable.c */
 /*                ^ punctuation.separator.c */
   * __aligned(8) h,
 /*^ storage.modifier.c */
 /*  ^^^^^^^^^^^^ meta.function-call */
-/*               ^ variable.other.c */
+/*               ^ entity.name.variable.c */
 /*                ^ punctuation.separator.c */
 
   __aligned(sizeof(int)) * i,
 /*^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */
 /*                       ^ storage.modifier.c */
-/*                         ^ variable.other.c */
+/*                         ^ entity.name.variable.c */
 /*                          ^ punctuation.separator.c */
   __aligned(sizeof(void *)) * j,
 /*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */
 /*                          ^ storage.modifier.c */
-/*                            ^ variable.other.c */
+/*                            ^ entity.name.variable.c */
 /*                             ^ punctuation.separator.c */
   __aligned(0x8) * k;
 /*^^^^^^^^^^^^^^ meta.function-call */
 /*               ^ storage.modifier.c */
-/*                 ^ variable.other.c */
+/*                 ^ entity.name.variable.c */
 /*                  ^ punctuation.terminator.c */
 
 MACRO1 UPPER_VAR;
 /* <- constant.other.macro.c */
-/*     ^^^^^^^^^ variable.other.c */
+/*     ^^^^^^^^^ entity.name.variable.c */
 /*              ^ punctuation.terminator.c */
 
 __safe UPPER_VAR;
 /* <- constant.other.macro.c */
-/*     ^^^^^^^^^ variable.other.c */
+/*     ^^^^^^^^^ entity.name.variable.c */
 /*              ^ punctuation.terminator.c */
 
 TYPE(int) UPPER_VAR;
 /* <- meta.function-call */
-/*        ^^^^^^^^^ variable.other.c */
+/*        ^^^^^^^^^ entity.name.variable.c */
 /*                 ^ punctuation.terminator.c */
 
 static const struct print_field const err_flags[];
 /*<- storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */
 /*                              ^^^^^ storage.modifier.c */
-/*                                    ^^^^^^^^^ variable.other.c */
+/*                                    ^^^^^^^^^ entity.name.variable.c */
 /*                                             ^^ storage.modifier.c */
 /*                                               ^ punctuation.terminator.c */
 
@@ -1734,7 +1734,7 @@ MACRO1 void MACRO2 myfuncname (), MACRO2 foo(), UPPER_VAR, UPPERFN();
 /*                                       ^^^ entity.name.function.c */
 /*                                          ^^ meta.function.parameters.c */
 /*                                            ^ punctuation.separator.c */
-/*                                              ^^^^^^^^^ variable.other.c */
+/*                                              ^^^^^^^^^ entity.name.variable.c */
 /*                                                       ^ punctuation.separator.c */
 /*                                                         ^^^^^^^ entity.name.function.c */
 /*                                                                ^^ meta.function.parameters.c */
@@ -1826,14 +1826,14 @@ funcname2
 MACRO_CALL(int) foo;
 /*^^^^^^^^^^^^^ meta.function-call */
 /*        ^^^^^ meta.group */
-/*              ^^^ variable.other.c */
+/*              ^^^ entity.name.variable.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 */
-/*                         ^^^ variable.other.c */
+/*                         ^^^ entity.name.variable.c */
 /*                            ^ punctuation.terminator.c */
 
 MACRO_CALL(int) ALIGNED(8) macro_prefixed_func(){}
@@ -1871,7 +1871,7 @@ extern NCURSES_EXPORT_VAR(int) COLORS;
 /* <- storage.modifier.c */
 /*     ^^^^^^^^^^^^^^^^^ meta.function-call.c */
 /*                       ^^^^^ meta.function-call.parameters.c */
-/*                             ^^^^^^ variable.other.c */
+/*                             ^^^^^^ entity.name.variable.c */
 
 int* return_type_pointer_no_space(){}
 /* <- storage.type.c */

From 7d2e9128d121f4e7c6b6e89435536115a5d3c956 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 15 Apr 2019 11:32:44 -0600
Subject: [PATCH 27/55] Don't match function pointer declaration as a function
 call

This will block calling a macro with a dereferenecd pointer, but I think
that's rare.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax |  4 ++--
 C++/syntax_test_c.c  | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 1e8983d5ac..d106620187 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -364,7 +364,7 @@ contexts:
   ## C-specific contexts
 
   global-function-call:
-    - match: (?={{identifier}}\s*\()
+    - match: (?={{identifier}}\s*\((?!\s*\*))
       set:
         - - meta_scope: debug.global-function-call.type-or-terminator
           - include: comments
@@ -537,7 +537,7 @@ contexts:
           - include: comments
           - include: function-definition-params-group
           - include: or_pop
-    - match: \(
+    - match: \((?=\s*\*)
       scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
       comment: Function pointer declaration
       push:
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 668ea210fb..6bef2e366d 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1242,6 +1242,44 @@ void do_pci_scan_bridge(struct device *dev,
 /*                                  ^ 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.c */
+/*                     ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
+/*                      ^^^^^ storage.modifier.c */
+/*                            ^^^^^^ storage.type.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 */
+/*   ^^^^^^ storage.type.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 debug.block punctuation.section.block.begin.c */
+  return 0;
+}
+/* <- meta.block.c debug.block punctuation.section.block.end.c */
+
+
 static const struct pci_driver my_driver __pci_driver __driver = {
 /* <- storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */

From 7365084ed84b8d8bd89ea34af7e931c6002a65ba Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 15 Apr 2019 12:30:32 -0600
Subject: [PATCH 28/55] Scope everything else as variable.other.c

---
 C++/C.sublime-syntax |  2 ++
 C++/syntax_test_c.c  | 50 +++++++++++++++++++++++++++++++++++++-------
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index d106620187..2382181ec6 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -331,6 +331,8 @@ contexts:
     - include: late-expressions
     - match: '{{macro_identifier}}'
       scope: constant.other.macro.c
+    - match: '{{identifier}}'
+      scope: variable.other.c
 
   early-expressions:
     - include: preprocessor-expressions
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 6bef2e366d..44e5ed0bb3 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1266,12 +1266,12 @@ static ssize_t function_with_params_on_newline
 /*   ^^^^^^ storage.type.c */
 /*          ^^^^^^ support.type.c */
 /*                 ^ keyword.operator.c */
-/*                  ^^^ - variable.other.c */
+/*                  ^^^ variable.other.c */
 /*                     ^ punctuation.separator.c */
      char *buf)
 /*   ^^^^ storage.type.c */
 /*        ^ keyword.operator.c */
-/*         ^^^ - variable.other.c */
+/*         ^^^ variable.other.c */
 /*            ^ punctuation.section.group.end.c */
 {
 /* <- meta.block.c debug.block punctuation.section.block.begin.c */
@@ -1289,8 +1289,24 @@ static const struct pci_driver my_driver __pci_driver __driver = {
 /*                                       ^^^^^^^^^^^^ 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.c */
+/*                              ^ punctuation.separator.c */
   .vendor   = PCI_VENDOR_ID,
+/*^ punctuation.accessor.c */
+/* ^^^^^^ variable.other.member.c */
+/*          ^ keyword.operator.assignment.c */
+/*            ^^^^^^^^^^^^^ constant.other.macro.c */
+/*                         ^ punctuation.separator.c */
   .devices  = pci_device_ids,
+/*^ punctuation.accessor.c */
+/* ^^^^^^^ variable.other.member.c */
+/*          ^ keyword.operator.assignment.c */
+/*            ^^^^^^^^^^^^^^ variable.other.c */
+/*                          ^ punctuation.separator.c */
 };
 
 struct __ec_align4 ec_response_get_version {};
@@ -1329,10 +1345,10 @@ static const struct spd_info {
     },
     [SPD_INFO_DEFAULT] = {
 /*   ^^^^^^^^^^^^^^^^ constant.other.macro.c */
-        .spd_len = SPD_DEFAULT_LENGTH,
-/*                 ^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
-        .spd_part_len = SPD_DEFAULT_PART_LEN,
-/*                      ^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
+        .spd_len = spd_default_length,
+/*                 ^^^^^^^^^^^^^^^^^^ variable.other.c */
+        .spd_part_len = spd_default_part_len,
+/*                      ^^^^^^^^^^^^^^^^^^^^ variable.other.c */
     },
 };
 
@@ -1655,9 +1671,14 @@ int foo(int val, float val2[][])
 {
 /* <- meta.function meta.block */
     myClass *result;
+/*           ^^^^^^ variable.other.c */
     result->kk = func(val);
 /*        ^^ punctuation.accessor */
+/*  ^^^^^^ variable.other.c */
+/*          ^^ variable.other.c */
+/*                    ^^^ variable.other.c */
     if (result != 0) {
+/*      ^^^^^^ variable.other.c */
 /*             ^^ keyword.operator.comparison.c */
         return 0;
 #if CROSS_SCOPE_MACRO
@@ -1673,7 +1694,7 @@ int foo(int val, float val2[][])
 #ifdef FOO
  /* <- keyword.control.import */
     int foobar
-/*      ^^^^^^ - entity.name.function */
+/*      ^^^^^^ variable.other.c */
     ;
 
     if (val == -1) {
@@ -1712,7 +1733,9 @@ GetTextMetrics(
 #endif
 /* <- keyword.control.import */
         hdc,
+/*      ^^^ variable.other.c */
         lptm
+/*      ^^^^ variable.other.c */
         );
 /*      ^ meta.function-call */
 /*       ^ - meta.function-call */
@@ -1829,13 +1852,15 @@ MACRO1 void * MACRO2 myfuncname () {
 /*  ^ storage.type */
 /*         ^ entity.name.struct */
         void* hello;
+/*            ^^^^^ variable.other.member.c */
         void* foobar;
+/*            ^^^^^^ variable.other.member.c */
     };
 
     struct Args args;
 /*  ^ storage.type */
 /*         ^ - entity */
-
+/*              ^^^^ variable.other.c */
 }
 
 static const uint32_t * const MACRO funcname();
@@ -1946,6 +1971,7 @@ __notdeclspec(deprecated("bla")) void func2(int) {}
 func_call(foo
 /*^^^^^^^^^^^ meta.function-call */
 /*       ^^^^ meta.group */
+/*        ^^^ variable.other.c */
 /*       ^ punctuation.section.group.begin */
 );
 /* <- meta.function-call meta.group punctuation.section.group.end */
@@ -2025,6 +2051,8 @@ scanf("%ms %as %*[, ]", &buf);
 /*     ^^^ constant.other.placeholder */
 /*         ^^^ constant.other.placeholder */
 /*             ^^^^^^ constant.other.placeholder */
+/*                      ^ keyword.operator.c */
+/*                       ^^^ variable.other.c */
 
 "foo % baz"
 /*   ^ - invalid */
@@ -2038,6 +2066,7 @@ int control_keywords()
 {
   if (x < 5)
   /* <- keyword.control */
+/*    ^ variable.other.c */
   {}
   else
   /* <- keyword.control */
@@ -2045,6 +2074,7 @@ int control_keywords()
 
   switch (x)
   /* <- keyword.control */
+/*        ^ variable.other.c */
   {
   case 1:
   /* <- keyword.control */
@@ -2060,12 +2090,16 @@ int control_keywords()
   /* <- 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;

From 574d15b377659ab3544977481210cee6215b8262 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 17 Apr 2019 13:39:55 -0600
Subject: [PATCH 29/55] Remove meta_include_prototype that was never used

---
 C++/C.sublime-syntax | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 2382181ec6..6a23aa6f4b 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -52,7 +52,6 @@ contexts:
       scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.block.c
-          meta_include_prototype: false
         - match: \*/
           scope: punctuation.definition.comment.c
           pop: true
@@ -66,7 +65,6 @@ contexts:
       scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.line.double-slash.c
-          meta_include_prototype: false
         - match: '(\\)$\n'
           captures:
             1: punctuation.separator.continuation.c
@@ -79,8 +77,7 @@ contexts:
         1: storage.type.string.c
         2: punctuation.definition.string.begin.c
       push:
-        - meta_include_prototype: false
-          meta_scope: string.quoted.double.c
+        - meta_scope: string.quoted.double.c
         - match: '"'
           scope: punctuation.definition.string.end.c
           pop: true
@@ -92,7 +89,6 @@ contexts:
         2: punctuation.definition.string.begin.c
       push:
         - meta_scope: string.quoted.single.c
-          meta_include_prototype: false
         - match: "'"
           scope: punctuation.definition.string.end.c
           pop: true
@@ -271,7 +267,6 @@ contexts:
       scope: punctuation.definition.comment.c debug.preprocessor-comments
       push:
         - meta_scope: comment.block.c
-        - meta_include_prototype: false
         - match: '\\$\n'
           scope: punctuation.separator.continuation.c
         - match: \*/
@@ -281,7 +276,6 @@ contexts:
       scope: punctuation.definition.comment.c debug.preprocessor-comments
       push:
         - meta_scope: comment.line.double-slash.c
-        - meta_include_prototype: false
         - match: '(\\)$\n'
           captures:
             1: punctuation.separator.continuation.c
@@ -1093,7 +1087,6 @@ contexts:
         1: keyword.control.import.c
       push:
         - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-global
-        - meta_include_prototype: false
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b

From 26c1b9bed17d8fc1fb125efb32b758a62efe09dc Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 17 Apr 2019 14:52:41 -0600
Subject: [PATCH 30/55] Rename some scopes

---
 C++/C.sublime-syntax | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 6a23aa6f4b..c9ad6e870b 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -312,7 +312,7 @@ contexts:
         # 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-modifier
+        - include: global-declaration
     - include: late-expressions
 
   statements:
@@ -374,7 +374,7 @@ contexts:
                       a macro invocation followed by a function definition.
             pop: true
           - match: '(?=\S)'
-            set: global-modifier
+            set: global-declaration
         - - meta_scope: debug.global-function-call.params
           - include: function-call-params
         - - meta_scope: meta.function-call.c
@@ -383,11 +383,11 @@ contexts:
             scope: variable.function.c
             pop: true
 
-  global-modifier:
+  global-declaration:
     - match: '(?=\S)'
       set:
         - variable-identifier-list
-        - typedef-types
+        - type-declaration
 
   function-definition-params:
     - meta_content_scope: meta.function.c debug.function-definition-params
@@ -413,7 +413,7 @@ contexts:
         - match: '(?=\S)'
           push:
             - parameter-identifier
-            - typedef-types
+            - type-declaration
 
   parameter-identifier:
     - meta_scope: debug.parameter-identifier
@@ -749,7 +749,7 @@ contexts:
     - match: '(?=\S)'
       push:
         - member-variable-identifier-list
-        - typedef-types
+        - type-declaration
 
   block:
     - match: '\{'
@@ -851,9 +851,9 @@ contexts:
       scope: storage.type.c
       push:
         - typedef-identifier-list
-        - typedef-types
-  typedef-types:
-    - meta_scope: debug.typedef-types
+        - type-declaration
+  type-declaration:
+    - meta_scope: debug.type-declaration
     - include: comments
     - include: modifiers
     - include: modifiers-macros
@@ -861,23 +861,23 @@ contexts:
     # Make sure to pop when a data structure keyword is found
     - match: (?=\bstruct\b)
       set:
-        - meta_scope: debug.typedef-types.struct
+        - meta_scope: debug.type-declaration.struct
         - include: struct-keyword
         - include: or_pop
     - match: (?=\benum\b)
       set:
-        - meta_scope: debug.typedef-types.enum
+        - meta_scope: debug.type-declaration.enum
         - include: enum-keyword
         - include: or_pop
     - match: (?=\bunion\b)
       set:
-        - meta_scope: debug.typedef-types.union
+        - meta_scope: debug.type-declaration.union
         - include: union-keyword
         - include: or_pop
     - include: types
     - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
-        1: support.type.c debug.typedef-types.identifier
+        1: support.type.c debug.type-declaration.identifier
     - include: or_pop
   typedef-identifier-list:
     - meta_scope: debug.typedef-identifier-list

From 3fb5fbe5e8e671878956ff85331d631d3eba03d0 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 17 Apr 2019 15:01:47 -0600
Subject: [PATCH 31/55] Scope macro function calls identifiers

---
 C++/C.sublime-syntax | 10 +++++++--
 C++/syntax_test_c.c  | 52 ++++++++++++++++++++++----------------------
 2 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index c9ad6e870b..cfa5ea67b1 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -379,8 +379,7 @@ contexts:
           - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
-            # Really a macro
-            scope: variable.function.c
+            scope: constant.other.macro.c
             pop: true
 
   global-declaration:
@@ -926,6 +925,13 @@ contexts:
     - include: or_pop
 
   function-call:
+    - 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
     - match: (?={{identifier}}\s*\()
       push:
         - meta_content_scope: meta.function-call.c
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 44e5ed0bb3..46f65ddf35 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -228,11 +228,11 @@ foo
 ; // fix highlighting
 /* <- punctuation.terminator */
 FOO()
-/* <- meta.function-call.c variable.function.c */
+/* <- meta.function-call.c constant.other.macro.c */
 FOO();
-/* <- meta.function-call.c variable.function.c */
+/* <- meta.function-call.c constant.other.macro.c */
 foo()
-/* <- meta.function-call.c variable.function.c */
+/* <- meta.function-call.c constant.other.macro.c */
 ; // fix highlighting
 /* <- punctuation.terminator */
 
@@ -646,7 +646,7 @@ struct point get_point() {}
 /*                        ^ punctuation.section.block.end */
 
 EXPORT_SYMBOL(get_point);
-/* <- meta.function-call.c variable.function.c*/
+/* <- meta.function-call.c constant.other.macro.c*/
 /*            ^^^^^^^^^ variable.other.c */
 
 inline struct point **alloc_points();
@@ -659,7 +659,7 @@ inline struct point **alloc_points();
 /*                                 ^ punctuation.section.group.end.c */
 /*                                  ^ punctuation.terminator.c */
 EXPORT_SYMBOL(alloc_points);
-/* <- meta.function-call.c variable.function.c*/
+/* <- meta.function-call.c constant.other.macro.c*/
 /*            ^^^^^^^^^^^^ variable.other.c */
 
 struct point* alloc_point();
@@ -725,11 +725,11 @@ int f_with_s(struct { int a; } *s);
 /*                                ^ punctuation.terminator.c */
 
 TRACE_EVENT(mmc_request_start,
-/* <- meta.function-call.c variable.function.c */
+/* <- meta.function-call.c constant.other.macro.c */
 /*          ^^^^^^^^^^^^^^^^^ variable.other.c */
 /*                           ^ punctuation.separator.c */
   TP_PROTO(struct mmc_host *host, struct mmc_request *mrq)
-/*^^^^^^^^ variable.function */
+/*^^^^^^^^ constant.other.macro.c */
 /*         ^^^^^^ storage.type.c */
 /*                ^^^^^^^^ support.type.c */
 /*                         ^ keyword.operator.c */
@@ -742,7 +742,7 @@ TRACE_EVENT(mmc_request_start,
 );
 
 TRACE_EVENT(802154_rdev_add_virtual_intf,
-/* <-meta.function-call.c variable.function.c */
+/* <-meta.function-call.c constant.other.macro.c */
 /*         ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
 /*          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.c */
 /*                                      ^ punctuation.separator.c */
@@ -752,7 +752,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
     WPAN_PHY_ENTRY
 /*  ^^^^^^^^^^^^^^ constant.other.macro.c */
     __string(vir_intf_name, name ? name : "<noname>")
-/*  ^^^^^^^^ meta.function-call.c variable.function.c */
+/*  ^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*          ^ punctuation.section.group.begin.c */
 /*           ^^^^^^^^^^^^^ variable.other.c */
 /*                        ^ punctuation.separator.c */
@@ -763,7 +763,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*                                        ^^^^^^^^^^ string.quoted.double.c */
 /*                                                  ^ punctuation.section.group.end.c */
     __field(enum nl802154_iftype, type)
-/*  ^^^^^^^ meta.function-call.c variable.function.c */
+/*  ^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*         ^ punctuation.section.group.begin.c */
 /*          ^^^^ storage.type.c */
 /*               ^^^^^^^^^^^^^^^ support.type.c */
@@ -771,7 +771,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*                                ^^^^ variable.other.c */
 /*                                    ^ punctuation.section.group.end.c */
     __field(__le64, extended_addr)
-/*  ^^^^^^^ meta.function-call.c variable.function.c */
+/*  ^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*         ^ punctuation.section.group.begin.c */
 /*          ^^^^^^ variable.other.c */
 /*                ^ punctuation.separator.c */
@@ -786,7 +786,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
     WPAN_PHY_ASSIGN;
 /*  ^^^^^^^^^^^^^^^ constant.other.macro.c */
     __assign_str(vir_intf_name, name ? name : "<noname>");
-/*  ^^^^^^^^^^^^ meta.function-call.c variable.function.c */
+/*  ^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*              ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
 /*               ^^^^^^^^^^^^^ variable.other.c */
 /*                            ^ punctuation.separator.c */
@@ -816,7 +816,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
       WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
 /*    ^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                   ^ punctuation.separator.c */
-/*                     ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                     ^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                               ^^^^^^^^^^^^^ variable.other.c */
 /*                                             ^ punctuation.separator.c */
 /*                                               ^^^^^^^ variable.other.c */
@@ -824,7 +824,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*                                                        ^^^^ variable.other.c */
 /*                                                            ^ punctuation.separator.c */
       __le64_to_cpu(__entry->extended_addr))
-/*    ^^^^^^^^^^^^^ meta.function-call.c variable.function.c */
+/*    ^^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                  ^^^^^^^ variable.other.c */
 /*                         ^^ punctuation.accessor.c */
 /*                           ^^^^^^^^^^^^^ variable.other.c */
@@ -836,35 +836,35 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 
 static DEFINE_SPINLOCK(my_lock);
 /* <- storage.modifier.c */
-/*     ^^^^^^^^^^^^^^^ meta.function-call.c variable.function.c */
+/*     ^^^^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                    ^^^^^^^^^ meta.function-call.parameters.c */
 /*                     ^^^^^^^ variable.other.c */
 
 MACRO_CALL_NO_SEMI(
-/* <- meta.function-call.c variable.function.c */
+/* <- 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 variable.function.c */
+/*^ 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 variable.function.c */
+/* <- 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 variable.function.c */
+/*^ 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 variable.function.c */
+/* <- meta.function-call.c constant.other.macro.c */
 /*   ^^^^ variable.other.c */
 /*          ^^^^^ variable.other.c */
 /*                   ^^^^^^^^^^^^^^^ comment.block.c */
 SHOW(temp1, temp1)   /* a comment */
-/* <- meta.function-call.c variable.function.c */
+/* <- meta.function-call.c constant.other.macro.c */
 /*   ^^^^ variable.other.c */
 /*          ^^^^^ variable.other.c */
 /*                   ^^^^^^^^^^^^^^^ comment.block.c */
@@ -1439,15 +1439,15 @@ void __attributes(int *bar) __must_hold(&foo)
     SAFE
 /*  ^^^^ constant.other.macro.c */
     __blah(bar)
-/*  ^^^^^^ meta.function-call.c variable.function.c */
+/*  ^^^^^^ meta.function-call.c constant.other.macro.c */
 /*         ^^^ variable.other.c */
     __blah(bar, foo)
-/*  ^^^^^^ meta.function-call.c variable.function.c */
+/*  ^^^^^^ 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 */
+/*  ^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*             ^^^^^^^^^^^^ meta.function-call.parameters.c */
 /*              ^ keyword.operator.c */
 /*               ^^^ variable.other.c */
@@ -1948,7 +1948,7 @@ 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 */
@@ -1963,7 +1963,7 @@ __declspec(deprecated("bla")) void func2(int) {}
 /*                                 ^ 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  */
 /*                                          ^^^ storage.type.c */

From cb40beac8e1cff4fd849c7519180ff98da386217 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 17 Apr 2019 15:24:14 -0600
Subject: [PATCH 32/55] Get rid of preprocessor workarounds

---
 C++/C.sublime-syntax | 56 +++++++++++---------------------------------
 C++/syntax_test_c.c  | 16 +++++++++++--
 2 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index cfa5ea67b1..1be112a18f 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -388,15 +388,6 @@ contexts:
         - variable-identifier-list
         - type-declaration
 
-  function-definition-params:
-    - meta_content_scope: meta.function.c debug.function-definition-params
-    - include: comments
-    - match: '(?=\()'
-      set:
-        - include: function-definition-params-group
-        - include: function-definition-continue
-    - match: (?=\S)
-      pop: true
   function-definition-params-group:
     - match: \(
       scope: punctuation.section.group.begin.c
@@ -745,11 +736,25 @@ contexts:
     - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon
     - 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:
+        - - meta_scope: debug.data-structures-body-function-call.params
+          - include: function-call-params
+        - - meta_scope: meta.function-call.c
+          - match: '{{identifier}}'
+            scope: constant.other.macro.c
+            pop: true
+
   block:
     - match: '\{'
       scope: punctuation.section.block.begin.c debug.block.open-brace
@@ -1409,38 +1414,6 @@ contexts:
       scope: punctuation.section.block.end.c debug.preprocessor-macro-definition.end-block
     - include: expressions
 
-  preprocessor-practical-workarounds:
-    - include: preprocessor-convention-ignore-uppercase-ident-lines
-    - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon
-
-  preprocessor-convention-ignore-uppercase-ident-lines:
-    - match: ^(\s*{{macro_identifier}})+\s*$
-      scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-ident-lines
-      push:
-        # It's possible that we are dealing with a function return type on its own line, and the
-        # name of the function is on the subsequent line.
-        - match: \s*({{identifier}})(?=\s*\()
-          captures:
-            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines.params
-          set: function-definition-params
-        - match: ^
-          pop: true
-
-
-  preprocessor-convention-ignore-uppercase-calls-without-semicolon:
-    - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$)
-      captures:
-        1: variable.function.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
-        2: punctuation.section.group.begin.c
-      push:
-        - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
-        - match: \)
-          scope: punctuation.section.group.end.c
-          pop: true
-        - include: expressions
-        - match: '{{identifier}}'
-          scope: variable.other.c
-
   preprocessor-other:
     - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|else|line|pragma|undef))\b
       captures:
@@ -1489,4 +1462,3 @@ contexts:
             - match: ">"
               scope: punctuation.definition.string.end.c
               pop: true
-    # - include: preprocessor-practical-workarounds
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 46f65ddf35..21bd05ee13 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -238,16 +238,28 @@ foo()
 
 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 */
+/*      ^^^ variable.other.member.c */
 
     DISABLED("reason")
-    /* <- meta.assumed-macro variable.function.assumed-macro */
+    /* <- meta.function-call.c constant.other.macro.c */
     float bar;
     /* <- storage.type */
+/*        ^^^ variable.other.member.c */
+/*           ^ punctuation.terminator.c */
+
+    EXPORT(int) baz;
+/*  ^^^^^^ meta.function-call.c constant.other.macro.c */
+/*        ^^^^^ meta.function-call.parameters.c */
+/*              ^^^ variable.other.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*/
 
 /////////////////////////////////////////////
 // Preprocessor branches starting blocks

From 3547ea2cbdd71b4d54e0bc4b0f0de6a01465f5bf Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Wed, 17 Apr 2019 15:29:33 -0600
Subject: [PATCH 33/55] Use macro_identifiers

---
 C++/C.sublime-syntax | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 1be112a18f..6b90bddecf 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -323,8 +323,7 @@ contexts:
   expressions:
     - include: early-expressions
     - include: late-expressions
-    - match: '{{macro_identifier}}'
-      scope: constant.other.macro.c
+    - include: macro-identifiers
     - match: '{{identifier}}'
       scope: variable.other.c
 
@@ -472,8 +471,7 @@ contexts:
 
   macro-identifiers:
     - match: '{{macro_identifier}}'
-      comment: Not sure I think this is a good idea
-      scope: variable.annotation
+      scope: constant.other.macro.c
 
   parameter-variable-identifier:
     - match: \*

From fb50af35896fb4da6f9a890418efe0279705f529 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 18 Apr 2019 09:37:19 -0600
Subject: [PATCH 34/55] Fix test failures

Turns out we need the practical workarounds for other syntaxes.

Objective C also uses the function-call, so I make a function-call-c so
we don't break their tests.
---
 C++/C.sublime-syntax | 53 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 49 insertions(+), 4 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 6b90bddecf..36db40ae4e 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -352,7 +352,7 @@ contexts:
     - include: modifiers-parens
     - include: modifiers
     - include: types
-    - include: function-call
+    - include: function-call-c
     - match: ';'
       scope: punctuation.terminator.c
 
@@ -387,6 +387,15 @@ contexts:
         - variable-identifier-list
         - type-declaration
 
+  function-definition-params:
+    - meta_content_scope: meta.function.c debug.function-definition-params
+    - include: comments
+    - match: '(?=\()'
+      set:
+        - include: function-definition-params-group
+        - include: function-definition-continue
+    - match: (?=\S)
+      pop: true
   function-definition-params-group:
     - match: \(
       scope: punctuation.section.group.begin.c
@@ -513,7 +522,7 @@ contexts:
           - include: comments
           - include: modifiers-parens
           # Macro invocations
-          - include: function-call
+          - include: function-call-c
           - match: '{{identifier}}'
             scope: constant.other.macro.c debug.variable-identifier-list.function-attribute
           - include: or_pop
@@ -731,7 +740,6 @@ contexts:
   data-structures-body:
     - include: preprocessor-data-structures
     - include: preprocessor-expressions
-    - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon
     - include: modifiers
     - include: modifiers-parens
     - include: data-structures-body-function-call
@@ -927,7 +935,8 @@ contexts:
       pop: true
     - include: or_pop
 
-  function-call:
+  # 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
@@ -935,6 +944,10 @@ contexts:
         - 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:
         - meta_content_scope: meta.function-call.c
@@ -1412,6 +1425,38 @@ contexts:
       scope: punctuation.section.block.end.c debug.preprocessor-macro-definition.end-block
     - include: expressions
 
+  preprocessor-practical-workarounds:
+    - include: preprocessor-convention-ignore-uppercase-ident-lines
+    - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon
+
+  preprocessor-convention-ignore-uppercase-ident-lines:
+    - match: ^(\s*{{macro_identifier}})+\s*$
+      scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-ident-lines
+      push:
+        # It's possible that we are dealing with a function return type on its own line, and the
+        # name of the function is on the subsequent line.
+        - match: \s*({{identifier}})(?=\s*\()
+          captures:
+            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines.params
+          set: function-definition-params
+        - match: ^
+          pop: true
+
+
+  preprocessor-convention-ignore-uppercase-calls-without-semicolon:
+    - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$)
+      captures:
+        1: variable.function.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
+        2: punctuation.section.group.begin.c
+      push:
+        - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
+        - match: \)
+          scope: punctuation.section.group.end.c
+          pop: true
+        - include: expressions
+        - match: '{{identifier}}'
+          scope: variable.other.c
+
   preprocessor-other:
     - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|else|line|pragma|undef))\b
       captures:

From 7c3007cae404620e1592c427f82a170f09b66482 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 18 Apr 2019 12:03:08 -0600
Subject: [PATCH 35/55] Scope -> access as variable.other.member.c

---
 C++/C.sublime-syntax |  2 +-
 C++/syntax_test_c.c  | 20 +++++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 36db40ae4e..f99e269e25 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -219,7 +219,7 @@ contexts:
       scope: invalid.illegal.syntax.c
 
   access:
-    - match: '(\.)({{identifier}})(?!\s*\()'
+    - match: '(\.|->)({{identifier}})(?!\s*\()'
       captures:
         1: punctuation.accessor.c
         2: variable.other.member.c
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 21bd05ee13..95eb973a2b 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -812,7 +812,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
     __entry->type = type;
 /*  ^^^^^^^ variable.other.c */
 /*         ^^ punctuation.accessor.c */
-/*           ^^^^ variable.other.c */
+/*           ^^^^ variable.other.member.c */
 /*                ^ keyword.operator.assignment.c */
 /*                  ^^^^ variable.other.c */
 /*                      ^ punctuation.terminator.c */
@@ -833,13 +833,13 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*                                             ^ punctuation.separator.c */
 /*                                               ^^^^^^^ variable.other.c */
 /*                                                      ^^ punctuation.accessor.c */
-/*                                                        ^^^^ variable.other.c */
+/*                                                        ^^^^ variable.other.member.c */
 /*                                                            ^ punctuation.separator.c */
       __le64_to_cpu(__entry->extended_addr))
 /*    ^^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                  ^^^^^^^ variable.other.c */
 /*                         ^^ punctuation.accessor.c */
-/*                           ^^^^^^^^^^^^^ variable.other.c */
+/*                           ^^^^^^^^^^^^^ variable.other.member.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 */
 );
@@ -1464,7 +1464,7 @@ void __attributes(int *bar) __must_hold(&foo)
 /*              ^ keyword.operator.c */
 /*               ^^^ variable.other.c */
 /*                  ^^ punctuation.accessor.c */
-/*                    ^^^^ variable.other.c */
+/*                    ^^^^ variable.other.member.c */
     {}
 /*  ^^ meta.function.c meta.block.c */
 
@@ -1687,7 +1687,7 @@ int foo(int val, float val2[][])
     result->kk = func(val);
 /*        ^^ punctuation.accessor */
 /*  ^^^^^^ variable.other.c */
-/*          ^^ variable.other.c */
+/*          ^^ variable.other.member.c */
 /*                    ^^^ variable.other.c */
     if (result != 0) {
 /*      ^^^^^^ variable.other.c */
@@ -2097,6 +2097,16 @@ int control_keywords()
       break;
       /* <- keyword.control.flow.break */
   }
+  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 */
 
   do
   /* <- keyword.control */

From fe28324ae6c09d7e22bb2f6a548af3d843ee6267 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 18 Apr 2019 12:11:49 -0600
Subject: [PATCH 36/55] Scope members as entity.name.member.c

---
 C++/C.sublime-syntax          |  4 +-
 C++/Symbol List.tmPreferences |  2 +-
 C++/syntax_test_c.c           | 96 +++++++++++++++++------------------
 3 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index f99e269e25..545ad7155e 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -593,9 +593,9 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.other.member.c debug.member-variable-identifier-list.function-pointer
+          scope: entity.name.member.c debug.member-variable-identifier-list.function-pointer
     - match: '{{identifier}}'
-      scope: variable.other.member.c debug.member-variable-identifier-list
+      scope: entity.name.member.c debug.member-variable-identifier-list
       push:
         - meta_scope: debug.member-variable-identifier-list.array-or-assignment
         - match: \[
diff --git a/C++/Symbol List.tmPreferences b/C++/Symbol List.tmPreferences
index 5998549eb4..dc32263a36 100644
--- a/C++/Symbol List.tmPreferences	
+++ b/C++/Symbol List.tmPreferences	
@@ -4,7 +4,7 @@
 	<key>name</key>
 	<string>Symbol List</string>
 	<key>scope</key>
-	<string><![CDATA[(source.c | source.c++ | source.objc | source.objc++) & (entity.name.class | entity.name.struct | entity.name.union | entity.name.enum | entity.name.variable)]]></string>
+	<string><![CDATA[(source.c | source.c++ | source.objc | source.objc++) & (entity.name.class | entity.name.struct | entity.name.union | entity.name.enum | entity.name.variable | entity.name.member)]]></string>
 	<key>settings</key>
 	<dict>
 		<key>showInSymbolList</key>
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 95eb973a2b..3f74c9dde5 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -243,19 +243,19 @@ struct X
     /* <- meta.function-call.c constant.other.macro.c */
     int foo;
     /* <- storage.type */
-/*      ^^^ variable.other.member.c */
+/*      ^^^ entity.name.member.c */
 
     DISABLED("reason")
     /* <- meta.function-call.c constant.other.macro.c */
     float bar;
     /* <- storage.type */
-/*        ^^^ variable.other.member.c */
+/*        ^^^ entity.name.member.c */
 /*           ^ punctuation.terminator.c */
 
     EXPORT(int) baz;
 /*  ^^^^^^ meta.function-call.c constant.other.macro.c */
 /*        ^^^^^ meta.function-call.parameters.c */
-/*              ^^^ variable.other.member.c */
+/*              ^^^ entity.name.member.c */
 /*                 ^ punctuation.terminator.c */
 };
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
@@ -311,7 +311,7 @@ typedef struct mystruct {
 /*                      ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int a;
 /*^^^ storage.type.c */
-/*    ^ variable.other.member.c */
+/*    ^ entity.name.member.c */
 } mystruct;
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^^^ entity.name.type */
@@ -325,7 +325,7 @@ typedef struct another
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int f;
 /*^^^ storage.type.c */
-/*    ^ variable.other.member.c */
+/*    ^ entity.name.member.c */
 } another_t, another2_t;
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^^^^ entity.name.type */
@@ -395,7 +395,7 @@ typedef struct {
 /*             ^ meta.struct.body.c punctuation.section.block.begin.c */
     int data1;
 /*  ^^^ storage.type.c */
-/*      ^^^^^ variable.other.member.c */
+/*      ^^^^^ entity.name.member.c */
 } newtype;
 /* <- meta.struct.body.c punctuation.section.block.end.c */
 /*^^^^^^^ entity.name.type.typedef.c */
@@ -407,7 +407,7 @@ typedef struct MyStruct {
 /*                      ^ meta.struct.body.c punctuation.section.block.begin.c */
     int data1;
 /*  ^^^ storage.type.c */
-/*      ^^^^^ variable.other.member.c */
+/*      ^^^^^ entity.name.member.c */
 } newtype;
 /* <- meta.struct.body.c punctuation.section.block.end.c */
 /*^^^^^^^ entity.name.type.typedef.c */
@@ -701,7 +701,7 @@ struct {
 /*     ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
   int a;
 /*^^^ storage.type.c */
-/*    ^ variable.other.member.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.c  */
@@ -729,7 +729,7 @@ int f_with_s(struct { int a; } *s);
 /*           ^^^^^^ meta.struct.c storage.type.c */
 /*                  ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
 /*                    ^^^ storage.type.c */
-/*                        ^ variable.other.member.c */
+/*                        ^ entity.name.member.c */
 /*                           ^ meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*                             ^ storage.modifier.c */
 /*                              ^ variable.parameter.c */
@@ -956,58 +956,58 @@ struct UI_MenuBoxData
     struct UI_BoundingBox position;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
-/*                        ^ variable.other.member.c */
+/*                        ^ entity.name.member.c */
 /*                                ^ punctuation.terminator.c */
     struct UI_BoundingBox *position_p;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                         ^ variable.other.member.c */
+/*                         ^ entity.name.member.c */
 /*                                   ^ punctuation.terminator.c */
     struct UI_BoundingBox * position_p1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                          ^ variable.other.member.c */
+/*                          ^ entity.name.member.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox **position_p2;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
-/*                          ^ variable.other.member.c */
+/*                          ^ entity.name.member.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox ** position_p3;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
-/*                           ^ variable.other.member.c */
+/*                           ^ entity.name.member.c */
 /*                                      ^ punctuation.terminator.c */
     struct UI_BoundingBox* position_p4;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ storage.modifier.c */
-/*                         ^ variable.other.member.c */
+/*                         ^ entity.name.member.c */
 /*                                    ^ punctuation.terminator.c */
     struct UI_BoundingBox** position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^^ storage.modifier.c */
-/*                          ^ variable.other.member.c */
+/*                          ^ entity.name.member.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox * * position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
 /*                          ^ storage.modifier.c */
-/*                            ^ variable.other.member.c */
+/*                            ^ entity.name.member.c */
 /*                                       ^ punctuation.terminator.c */
     struct UI_BoundingBox *pos_1, *pos_1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                         ^ variable.other.member.c */
+/*                         ^ entity.name.member.c */
 /*                                ^ storage.modifier.c */
-/*                                 ^ variable.other.member.c */
+/*                                 ^ entity.name.member.c */
 /*                                      ^ punctuation.terminator.c */
 
     const volatile struct UI_BoundingBox *cv_p;
@@ -1016,11 +1016,11 @@ struct UI_MenuBoxData
 /*                 ^^^^^^ storage.type */
 /*                        ^ support.type.c - entity.name */
 /*                                       ^ storage.modifier.c */
-/*                                        ^ variable.other.member.c */
+/*                                        ^ entity.name.member.c */
 /*                                            ^ punctuation.terminator.c */
     long resume_done[USB_MAXCHILDREN];
 /*  ^^^^ storage.type.c */
-/*       ^^^^^^^^^^^ variable.other.member.c */
+/*       ^^^^^^^^^^^ entity.name.member.c */
 /*                  ^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^^^^^^^^^^^^^^^ constant.other.macro.c */
@@ -1031,20 +1031,20 @@ struct UI_MenuBoxData
 /*         ^ support.type.c - entity.name */
 /*                       ^ constant.other.macro.c */
 /*                               ^ storage.modifier.c */
-/*                                 ^ variable.other.member.c */
+/*                                 ^ entity.name.member.c */
 /*                                        ^ punctuation.terminator.c */
     struct xhci_run_regs __attribute__((noderef)) *run_regs;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ - entity.name */
 /*                                                ^ storage.modifier.c */
-/*                                                 ^ variable.other.member.c */
+/*                                                 ^ entity.name.member.c */
 /*                                                         ^ punctuation.terminator.c */
     struct __attribute__((noderef)) xhci_run_regs *run_regs;
 /*  ^^^^^^ storage.type */
 /*                                  ^ support.type.c - entity.name */
 /*                                                ^ storage.modifier.c */
-/*                                                 ^ - entity.name */
+/*                                                 ^ entity.name.member.c */
 /*                                                         ^ punctuation.terminator.c */
     struct nested_t {
 /*  ^^^^^^ storage.type */
@@ -1052,10 +1052,10 @@ struct UI_MenuBoxData
 /*                  ^ meta.struct.body.c meta.block.c meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
         int bar;
 /*      ^^^ storage.type.c */
-/*          ^^^ variable.other.member.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 */
-/*    ^^^^^^ variable.other.member.c */
+/*    ^^^^^^ entity.name.member.c */
 /*          ^ punctuation.terminator.c */
 
 #define CMD_RING_STATE_RUNNING         (1 << 0)
@@ -1065,29 +1065,29 @@ struct UI_MenuBoxData
     enum UI_BoxCharType borderType;
 /*  ^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.c - entity.name */
-/*                      ^ variable.other.member.c */
+/*                      ^ entity.name.member.c */
 /*                                ^ punctuation.terminator.c */
     unsigned int paddingX;
 /*  ^^^^^^^^ storage.type.c */
 /*           ^^^ storage.type.c */
-/*               ^^^^^^^^ variable.other.member.c */
+/*               ^^^^^^^^ entity.name.member.c */
 /*                       ^ punctuation.terminator.c */
     unsigned int paddingY;
 /*  ^^^^^^^^ storage.type.c */
 /*           ^^^ storage.type.c */
-/*               ^^^^^^^^ variable.other.member.c */
+/*               ^^^^^^^^ entity.name.member.c */
 /*                       ^ punctuation.terminator.c */
     struct UI_ScrollBoxText boxContents[];
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^^^ support.type.c */
-/*                          ^^^^^^^^^^^ variable.other.member.c */
+/*                          ^^^^^^^^^^^ entity.name.member.c */
 /*                                     ^ storage.modifier.c */
 /*                                       ^ punctuation.terminator.c */
 
     struct delayed_work monitor_work ____cacheline_aligned_in_smp;
 /*  ^^^^^^ storage.type */
 /*         ^^^^^^^^^^^^ support.type.c */
-/*                      ^^^^^^^^^^^^ variable.other.member.c */
+/*                      ^^^^^^^^^^^^ entity.name.member.c */
 /*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                                               ^ punctuation.terminator.c */
     const struct efx_channel_type *
@@ -1096,7 +1096,7 @@ struct UI_MenuBoxData
 /*               ^^^^^^^^^^^^^^^^ support.type - entity.name */
 /*                                ^ storage.modifier.c */
     extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
-/*  ^^^^^^^^^^^^^^^^^^ variable.other.member.c */
+/*  ^^^^^^^^^^^^^^^^^^ entity.name.member.c */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                     ^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                    ^ punctuation.section.brackets.begin.c storage.modifier.c */
@@ -1121,7 +1121,7 @@ struct __attribute__((packed)) child_t {
 /*                             ^^^^^^^ entity.name.struct */
     int foo;
 /*  ^^^ storage.type.c */
-/*      ^^^ variable.other.member.c */
+/*      ^^^ entity.name.member.c */
 };
 
 struct child_t child1;
@@ -1133,7 +1133,7 @@ struct __attribute__((packed)) child_t_line
 {
     int foo;
 /*  ^^^ storage.type.c */
-/*      ^^^ variable.other.member.c */
+/*      ^^^ entity.name.member.c */
 };
 
 struct __attribute__((packed))
@@ -1143,7 +1143,7 @@ struct __attribute__((packed))
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int foo;
 /*  ^^^ storage.type.c */
-/*      ^^^ variable.other.member.c */
+/*      ^^^ entity.name.member.c */
 };
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 
@@ -1153,13 +1153,13 @@ struct rproc_ops {
 /*               ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int (*start)(struct rproc *rproc);
 /*  ^^^ storage.type.c */
-/*        ^^^^^ variable.other.member.c */
+/*        ^^^^^ entity.name.member.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
 /*                             ^^^^^ variable.parameter.c */
     int (*start)(struct rproc *);
 /*  ^^^ storage.type.c */
-/*        ^^^^^ variable.other.member.c */
+/*        ^^^^^ entity.name.member.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
@@ -1167,7 +1167,7 @@ struct rproc_ops {
 /*                             ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */
     u32 (*start)(struct rproc *, struct rproc *);
 /*  ^^^ support.type.c */
-/*        ^^^^^ variable.other.member.c */
+/*        ^^^^^ entity.name.member.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
@@ -1179,7 +1179,7 @@ struct rproc_ops {
 /*                                             ^ 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 */
-/*           ^^^^^^^^ variable.other.member.c */
+/*           ^^^^^^^^ entity.name.member.c */
 /*                     ^^^^^^ storage.type.c */
 /*                            ^^^^^ support.type.c */
 /*                                   ^^^^^ variable.parameter.c */
@@ -1190,7 +1190,7 @@ struct rproc_ops {
     struct resource_table *(*find_loaded_rsc_table)(
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^ support.type.c */
-/*                           ^^^^^^^^^^^^^^^^^^^^^ variable.other.member.c */
+/*                           ^^^^^^^^^^^^^^^^^^^^^ entity.name.member.c */
                 struct rproc *rproc, const struct firmware *fw);
 /*              ^^^^^^ storage.type.c */
 /*                     ^^^^^ support.type.c */
@@ -1341,10 +1341,10 @@ static const struct spd_info {
 /*                  ^^^^^^^^ entity.name.struct.c */
     size_t spd_len;
 /*  ^^^^^^ support.type */
-/*         ^^^^^^^ variable.other.member.c */
+/*         ^^^^^^^ entity.name.member.c */
     size_t spd_part_len;
 /*  ^^^^^^ support.type */
-/*         ^^^^^^^ variable.other.member.c */
+/*         ^^^^^^^ entity.name.member.c */
 } spd_mem_info[] = {
 /*^^^^^^^^^^^^  entity.name.variable.c */
 /*            ^^ meta.brackets.c storage.modifier.c */
@@ -1403,7 +1403,7 @@ struct mac_tfm_ctx {
   struct crypto_aes_ctx key;
 /*^^^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.c */
-/*                      ^^^ variable.other.member.c */
+/*                      ^^^ entity.name.member.c */
 /*                         ^ punctuation.terminator.c */
   struct crypto_aes_ctx __aligned(8) key2;
 /*^^^^^^ storage.type.c */
@@ -1413,7 +1413,7 @@ struct mac_tfm_ctx {
 /*                               ^ meta.group.c punctuation.section.group.begin.c */
 /*                                ^ constant.numeric.c */
 /*                                 ^ meta.group.c punctuation.section.group.end.c */
-/*                                   ^^^^ variable.other.member.c */
+/*                                   ^^^^ entity.name.member.c */
 /*                                       ^ punctuation.terminator.c */
   u8 __aligned(8) consts[];
 /*^^ support.type.c */
@@ -1422,7 +1422,7 @@ struct mac_tfm_ctx {
 /*            ^ meta.group.c punctuation.section.group.begin.c */
 /*             ^ constant.numeric.c */
 /*              ^ meta.group.c punctuation.section.group.end.c */
-/*                ^^^^^^ variable.other.member.c */
+/*                ^^^^^^ entity.name.member.c */
 /*                      ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
 /*                       ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
 /*                        ^ punctuation.terminator.c */
@@ -1864,14 +1864,14 @@ MACRO1 void * MACRO2 myfuncname () {
 /*  ^ storage.type */
 /*         ^ entity.name.struct */
         void* hello;
-/*            ^^^^^ variable.other.member.c */
+/*            ^^^^^ entity.name.member.c */
         void* foobar;
-/*            ^^^^^^ variable.other.member.c */
+/*            ^^^^^^ entity.name.member.c */
     };
 
     struct Args args;
 /*  ^ storage.type */
-/*         ^ - entity */
+/*         ^ support.type.c - entity */
 /*              ^^^^ variable.other.c */
 }
 

From 8ea1642941392b2bb7a31b8d1a323f1242c0dc72 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 18 Apr 2019 14:33:07 -0600
Subject: [PATCH 37/55] Support typedefing stdint types

---
 C++/C.sublime-syntax |  3 +++
 C++/syntax_test_c.c  | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 545ad7155e..0a01a5b500 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -884,6 +884,9 @@ contexts:
         - meta_scope: debug.type-declaration.union
         - include: union-keyword
         - include: or_pop
+    - match: (?={{identifier}};)
+      pop: true
+      comment: Used for typedefing things defined in types.
     - include: types
     - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 3f74c9dde5..68bedca400 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -447,6 +447,16 @@ typedef enum state {DEAD,ALIVE} State;
 /*                              ^^^^^ entity.name.type.typedef.c */
 /*                                   ^ punctuation.terminator.c */
 
+
+typedef   __u8    u_int8_t;
+/* <- storage.type.c */
+/*        ^^^^ constant.other.macro.c */
+/*                ^^^^^^^^ entity.name.type.typedef.c */
+typedef   __s8    int8_t;
+/* <- storage.type.c */
+/*        ^^^^ constant.other.macro.c */
+/*                ^^^^^^ entity.name.type.typedef.c */
+
 /////////////////////////////////////////////
 // Parameter Declarations
 /////////////////////////////////////////////
@@ -2097,6 +2107,10 @@ int control_keywords()
       break;
       /* <- keyword.control.flow.break */
   }
+  int8_t foo;
+/*^^^^^^ support.type.stdint.c */
+  const int8_t foo;
+/*      ^^^^^^ support.type.stdint.c */
   foo->bar.baz->hello("World");
 /*^^^ variable.other.c */
 /*   ^^ punctuation.accessor.c */

From bf1d311bed3044fa7532a984f713fb90e70cfb27 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 18 Apr 2019 14:49:41 -0600
Subject: [PATCH 38/55] Match macros in preprocessor

---
 C++/C.sublime-syntax | 2 ++
 C++/syntax_test_c.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 0a01a5b500..170399882d 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -1116,6 +1116,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
@@ -1472,6 +1473,7 @@ contexts:
         - 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
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 68bedca400..d10251ec56 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1629,6 +1629,7 @@ enum {
 /*            ^ 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
@@ -2023,6 +2024,7 @@ func_call(foo
 /*               ^ punctuation.definition.string.end */
 
 #ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+/*     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 #include_next <math.h>
 /* <- keyword.control.import.include */
 /*            ^ punctuation.definition.string.begin */

From 29590f73764fa5375b1682b3f2bd8dc30d94f415 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 22 Apr 2019 08:48:40 -0600
Subject: [PATCH 39/55] Refactor brackets into common scope

---
 C++/C.sublime-syntax | 46 ++++++++++++++------------------------------
 C++/syntax_test_c.c  | 14 ++++++++++++++
 2 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 170399882d..9631530c94 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -439,14 +439,7 @@ contexts:
       scope: variable.parameter.c debug.parameter-identifier
       push:
         - meta_scope: debug.parameter-identifier.array-or-assignment
-        - match: \[
-          scope: punctuation.section.brackets.begin.c storage.modifier.c
-          push:
-            - meta_scope: meta.brackets.c
-            - match: \]
-              scope: punctuation.section.brackets.end.c storage.modifier.c
-              pop: true
-            - include: expressions
+        - include: declaration-brackets
         - include: or_pop
     - include: or_pop
 
@@ -548,14 +541,7 @@ contexts:
       scope: entity.name.variable.c debug.variable-identifier-list
       push:
         - meta_scope: debug.variable-identifier-list.array-or-assignment
-        - match: \[
-          scope: punctuation.section.brackets.begin.c storage.modifier.c
-          push:
-            - meta_scope: meta.brackets.c
-            - match: \]
-              scope: punctuation.section.brackets.end.c storage.modifier.c
-              pop: true
-            - include: expressions
+        - include: declaration-brackets
         - match: \=
           scope: keyword.operator.assignment.c
           set:
@@ -598,14 +584,7 @@ contexts:
       scope: entity.name.member.c debug.member-variable-identifier-list
       push:
         - meta_scope: debug.member-variable-identifier-list.array-or-assignment
-        - match: \[
-          scope: punctuation.section.brackets.begin.c storage.modifier.c
-          push:
-            - meta_scope: meta.brackets.c
-            - match: \]
-              scope: punctuation.section.brackets.end.c storage.modifier.c
-              pop: true
-            - include: expressions
+        - include: declaration-brackets
         - include: or_pop
     - match: ','
       scope: punctuation.separator.c debug.member-variable-identifier-list
@@ -793,6 +772,16 @@ contexts:
           pop: true
         - include: expressions
 
+  declaration-brackets:
+    - match: \[
+      scope: punctuation.section.brackets.begin.c storage.modifier.c
+      push:
+        - meta_scope: meta.brackets.c
+        - match: \]
+          scope: punctuation.section.brackets.end.c storage.modifier.c
+          pop: true
+        - include: expressions
+
   case-default:
     - match: '\b(default|case)\b'
       scope: keyword.control.c
@@ -907,14 +896,7 @@ contexts:
     - match: '{{identifier}}(?=\s*\[)'
       scope: entity.name.type.typedef.c debug.typedef.array
       push:
-        - match: \[
-          scope: punctuation.section.brackets.begin.c storage.modifier.c
-          push:
-            - meta_scope: meta.brackets.c
-            - match: \]
-              scope: punctuation.section.brackets.end.c storage.modifier.c
-              pop: true
-            - include: expressions
+        - include: declaration-brackets
         - include: or_pop
     - match: '\((?=\s*\*)'
       scope: punctuation.section.group.begin.c debug.typedef.function-pointer
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index d10251ec56..e31dac07cb 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1359,14 +1359,18 @@ static const struct spd_info {
 /*^^^^^^^^^^^^  entity.name.variable.c */
 /*            ^^ meta.brackets.c storage.modifier.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.c */
         .spd_part_len = spd_default_part_len,
@@ -1387,6 +1391,16 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 /*                                                                       ^ 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.c */
+/*   ^^^ keyword.operator.variadic.c */
+/*       ^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                            ^ keyword.operator.arithmetic.c */
+/*                              ^ constant.numeric.c */
+/*                               ^ meta.brackets.c punctuation.section.brackets.end.c */
+/*                                 ^ keyword.operator.assignment.c */
+/*                                   ^^^^^^^^^^^^^^ variable.other.c */
+/*                                                 ^ punctuation.separator.c */
 #include <asm/unistd32.h>
 };
 /* <- meta.block.c punctuation.section.block.end.c */

From 119d68294bdf47242bee427d529803c4b04f3e7a Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 22 Apr 2019 09:03:13 -0600
Subject: [PATCH 40/55] Only index variables and members longer than 4
 characters

Indexing common words is pretty useless. It also slows down sublime a
lot when hovering over a common variable name.

I just added a .indexed to the scopes. Not sure if this will fly. It
might be better to add a meta.indexed scope to all the variable.other
and entity.name.members that should be indexed.
---
 C++/C.sublime-syntax                     |  41 ++--
 C++/Indexed Reference List.tmPreferences |   3 +-
 C++/Symbol List.tmPreferences            |   2 +-
 C++/syntax_test_c.c                      | 251 ++++++++++++-----------
 4 files changed, 164 insertions(+), 133 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 9631530c94..15f8514ed5 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -12,6 +12,7 @@ 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 # 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'
   microsoft_types: '__int8|__int16|__int32|__int64'
@@ -219,10 +220,14 @@ 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: \.(?!\.)
       scope: punctuation.accessor.c
@@ -320,12 +325,21 @@ contexts:
     - include: label
     - include: expressions
 
+  # We can't merge this with the variables scope because it will break the C++
+  # syntax.
+  variables-c:
+    - match: '{{common_identifier}}'
+      scope: variable.other.c
+      comment: 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: '{{identifier}}'
+      scope: variable.other.indexed.c
+
   expressions:
     - include: early-expressions
     - include: late-expressions
     - include: macro-identifiers
-    - match: '{{identifier}}'
-      scope: variable.other.c
+    - include: variables-c
 
   early-expressions:
     - include: preprocessor-expressions
@@ -536,9 +550,9 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.variable.c debug.variable-identifier-list.function-pointer
+          scope: entity.name.variable.indexed.c debug.variable-identifier-list.function-pointer
     - match: '{{identifier}}'
-      scope: entity.name.variable.c debug.variable-identifier-list
+      scope: entity.name.variable.indexed.c debug.variable-identifier-list
       push:
         - meta_scope: debug.variable-identifier-list.array-or-assignment
         - include: declaration-brackets
@@ -579,11 +593,18 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.member.c debug.member-variable-identifier-list.function-pointer
-    - match: '{{identifier}}'
+          scope: entity.name.member.indexed.c debug.member-variable-identifier-list.function-pointer
+    - match: '{{common_identifier}}'
       scope: entity.name.member.c debug.member-variable-identifier-list
+      comment: There are a lot of common variable names 4 characters or under.
+      push:
+        - meta_scope: debug.member-variable-identifier-list.array
+        - include: declaration-brackets
+        - include: or_pop
+    - match: '{{identifier}}'
+      scope: entity.name.member.indexed.c debug.member-variable-identifier-list
       push:
-        - meta_scope: debug.member-variable-identifier-list.array-or-assignment
+        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: ','
@@ -952,8 +973,6 @@ contexts:
         - match: '{{macro_identifier}}(?!\()'
           scope: constant.other.macro.c
         - include: expressions
-        - match: '{{identifier}}'
-          scope: variable.other.c
         - match: '\b\w+\b'
           scope: variable.other.c
           comment: Inside macro params, the identifiers can start with numbers
@@ -1440,8 +1459,6 @@ contexts:
           scope: punctuation.section.group.end.c
           pop: true
         - include: expressions
-        - match: '{{identifier}}'
-          scope: variable.other.c
 
   preprocessor-other:
     - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|else|line|pragma|undef))\b
diff --git a/C++/Indexed Reference List.tmPreferences b/C++/Indexed Reference List.tmPreferences
index fbd673eacb..214727ab80 100644
--- a/C++/Indexed Reference List.tmPreferences	
+++ b/C++/Indexed Reference List.tmPreferences	
@@ -6,7 +6,8 @@
     <string>
         source.c constant.other.macro.c,
         source.c support.type.c,
-        source.c variable.other.c
+        source.c variable.other.indexed.c,
+        source.c variable.other.member.indexed.c
     </string>
     <key>settings</key>
     <dict>
diff --git a/C++/Symbol List.tmPreferences b/C++/Symbol List.tmPreferences
index dc32263a36..ed6b09c159 100644
--- a/C++/Symbol List.tmPreferences	
+++ b/C++/Symbol List.tmPreferences	
@@ -4,7 +4,7 @@
 	<key>name</key>
 	<string>Symbol List</string>
 	<key>scope</key>
-	<string><![CDATA[(source.c | source.c++ | source.objc | source.objc++) & (entity.name.class | entity.name.struct | entity.name.union | entity.name.enum | entity.name.variable | entity.name.member)]]></string>
+	<string><![CDATA[(source.c | source.c++ | source.objc | source.objc++) & (entity.name.class | entity.name.struct | entity.name.union | entity.name.enum | entity.name.variable.indexed | entity.name.member.indexed)]]></string>
 	<key>settings</key>
 	<dict>
 		<key>showInSymbolList</key>
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index e31dac07cb..aa1a4ae59f 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -117,12 +117,12 @@ int f(int x, \
 
 bool still_C_code_here = true, foo = false;
 /* <- storage.type */
-/*   ^^^^^^^^^^^^^^^^^ entity.name.variable.c */
+/*   ^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */
 /*                     ^ keyword.operator.assignment.c */
 /*                       ^ constant.language */
 /*                                        ^ punctuation.terminator.c */
 /*                           ^ punctuation.separator.c */
-/*                             ^^^ entity.name.variable.c*/
+/*                             ^^^ entity.name.variable.indexed.c*/
 /*                                 ^ keyword.operator.assignment.c */
 /*                                   ^^^^^ constant.language.c */
 /*                                        ^ punctuation.terminator.c */
@@ -222,7 +222,7 @@ int disabled_func() {
 FOO
 /* <- constant.other.macro.c */
 FOO;
-/* <- entity.name.variable.c */
+/* <- entity.name.variable.indexed.c */
 foo
 /* <- support.type */
 ; // fix highlighting
@@ -395,7 +395,7 @@ typedef struct {
 /*             ^ meta.struct.body.c punctuation.section.block.begin.c */
     int data1;
 /*  ^^^ storage.type.c */
-/*      ^^^^^ entity.name.member.c */
+/*      ^^^^^ entity.name.member.indexed.c */
 } newtype;
 /* <- meta.struct.body.c punctuation.section.block.end.c */
 /*^^^^^^^ entity.name.type.typedef.c */
@@ -407,7 +407,7 @@ typedef struct MyStruct {
 /*                      ^ meta.struct.body.c punctuation.section.block.begin.c */
     int data1;
 /*  ^^^ storage.type.c */
-/*      ^^^^^ entity.name.member.c */
+/*      ^^^^^ entity.name.member.indexed.c */
 } newtype;
 /* <- meta.struct.body.c punctuation.section.block.end.c */
 /*^^^^^^^ entity.name.type.typedef.c */
@@ -595,18 +595,18 @@ static string foo(__attribute__((unused)));
   __unused char foo;
 /*^^^^^^^^ constant.other.macro.c */
 /*         ^^^^ storage.type.c */
-/*              ^^^ entity.name.variable.c */
+/*              ^^^ entity.name.variable.indexed.c */
 /*                 ^ punctuation.terminator.c */
   volatile MACRO foo;
 /*^^^^^^^^ storage.modifier.c */
 /*         ^^^^^ constant.other.macro.c */
-/*               ^^^ entity.name.variable.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.c */
+/*                ^^^ entity.name.variable.indexed.c */
 /*                   ^ punctuation.terminator.c */
 
 /////////////////////////////////////////////
@@ -669,7 +669,7 @@ struct point get_point() {}
 
 EXPORT_SYMBOL(get_point);
 /* <- meta.function-call.c constant.other.macro.c*/
-/*            ^^^^^^^^^ variable.other.c */
+/*            ^^^^^^^^^ variable.other.indexed.c */
 
 inline struct point **alloc_points();
 /*     ^ storage.type */
@@ -682,7 +682,7 @@ inline struct point **alloc_points();
 /*                                  ^ punctuation.terminator.c */
 EXPORT_SYMBOL(alloc_points);
 /* <- meta.function-call.c constant.other.macro.c*/
-/*            ^^^^^^^^^^^^ variable.other.c */
+/*            ^^^^^^^^^^^^ variable.other.indexed.c */
 
 struct point* alloc_point();
 /* <- storage.type.c */
@@ -704,7 +704,7 @@ struct point FOO_API *alloc_point3(), alloc_point2(), struct_var2;
 /*                                 ^ punctuation.section.group.end.c */
 /*                                  ^ punctuation.separator */
 /*                                    ^ entity.name.function - variable.function */
-/*                                                    ^^^^^^^^^^^ entity.name.variable.c */
+/*                                                    ^^^^^^^^^^^ entity.name.variable.indexed.c */
 
 struct {
 /* <- storage.type.c */
@@ -714,22 +714,22 @@ struct {
 /*    ^ 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.c  */
-/*         ^^^^^^ entity.name.variable.c  */
+/*^^^^^^ entity.name.variable.indexed.c  */
+/*         ^^^^^^ entity.name.variable.indexed.c  */
 /*                 ^^^^^^^^ entity.name.function.c  */
-/*                             ^^^^^^ entity.name.variable.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.c  */
+/* ^^^^^^ entity.name.variable.indexed.c  */
 /*        ^ keyword.operator.assignment.c */
 /*                  ^ punctuation.separator */
-/*                    ^^^^^^^^ entity.name.variable.c  */
+/*                    ^^^^^^^^ entity.name.variable.indexed.c  */
 /*                            ^^ meta.brackets.c storage.modifier.c */
 /*                               ^ keyword.operator.assignment.c */
 /*                                                     ^ punctuation.separator */
-/*                                                       ^^^^^^ entity.name.variable.c  */
+/*                                                       ^^^^^^ entity.name.variable.indexed.c  */
 /*                                                             ^ punctuation.terminator.c */
 
 int f_with_s(struct { int a; } *s);
@@ -748,7 +748,7 @@ int f_with_s(struct { int a; } *s);
 
 TRACE_EVENT(mmc_request_start,
 /* <- meta.function-call.c constant.other.macro.c */
-/*          ^^^^^^^^^^^^^^^^^ variable.other.c */
+/*          ^^^^^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                           ^ punctuation.separator.c */
   TP_PROTO(struct mmc_host *host, struct mmc_request *mrq)
 /*^^^^^^^^ constant.other.macro.c */
@@ -776,7 +776,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
     __string(vir_intf_name, name ? name : "<noname>")
 /*  ^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*          ^ punctuation.section.group.begin.c */
-/*           ^^^^^^^^^^^^^ variable.other.c */
+/*           ^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                        ^ punctuation.separator.c */
 /*                          ^^^^ variable.other.c */
 /*                               ^ keyword.operator.ternary.c */
@@ -795,9 +795,9 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
     __field(__le64, extended_addr)
 /*  ^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*         ^ punctuation.section.group.begin.c */
-/*          ^^^^^^ variable.other.c */
+/*          ^^^^^^ variable.other.indexed.c */
 /*                ^ punctuation.separator.c */
-/*                  ^^^^^^^^^^^^^ variable.other.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 */
@@ -810,7 +810,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
     __assign_str(vir_intf_name, name ? name : "<noname>");
 /*  ^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*              ^ meta.function-call.parameters.c punctuation.section.group.begin.c */
-/*               ^^^^^^^^^^^^^ variable.other.c */
+/*               ^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                            ^ punctuation.separator.c */
 /*                              ^^^^ variable.other.c */
 /*                                   ^ keyword.operator.ternary.c */
@@ -820,7 +820,7 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*                                                      ^ meta.function-call.parameters.c punctuation.section.group.end.c */
 /*                                                       ^ punctuation.terminator.c */
     __entry->type = type;
-/*  ^^^^^^^ variable.other.c */
+/*  ^^^^^^^ variable.other.indexed.c */
 /*         ^^ punctuation.accessor.c */
 /*           ^^^^ variable.other.member.c */
 /*                ^ keyword.operator.assignment.c */
@@ -839,17 +839,17 @@ TRACE_EVENT(802154_rdev_add_virtual_intf,
 /*    ^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                   ^ punctuation.separator.c */
 /*                     ^^^^^^^^^ meta.function-call.c constant.other.macro.c */
-/*                               ^^^^^^^^^^^^^ variable.other.c */
+/*                               ^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                                             ^ punctuation.separator.c */
-/*                                               ^^^^^^^ variable.other.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.c */
+/*                  ^^^^^^^ variable.other.indexed.c */
 /*                         ^^ punctuation.accessor.c */
-/*                           ^^^^^^^^^^^^^ variable.other.member.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 */
 );
@@ -860,7 +860,7 @@ static DEFINE_SPINLOCK(my_lock);
 /* <- storage.modifier.c */
 /*     ^^^^^^^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                    ^^^^^^^^^ meta.function-call.parameters.c */
-/*                     ^^^^^^^ variable.other.c */
+/*                     ^^^^^^^ variable.other.indexed.c */
 
 MACRO_CALL_NO_SEMI(
 /* <- meta.function-call.c constant.other.macro.c */
@@ -882,13 +882,13 @@ MACRO_CALL_NO_SEMI(
 
 SHOW(temp0, temp0)   /* a comment */
 /* <- meta.function-call.c constant.other.macro.c */
-/*   ^^^^ variable.other.c */
-/*          ^^^^^ variable.other.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.c */
-/*          ^^^^^ variable.other.c */
+/*   ^^^^ variable.other.indexed.c */
+/*          ^^^^^ variable.other.indexed.c */
 /*                   ^^^^^^^^^^^^^^^ comment.block.c */
 
 static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
@@ -925,34 +925,34 @@ struct MACRO foo {
 
 struct UI_BoundingBox position;
 /*     ^ support.type.c - entity.name */
-/*                     ^ entity.name.variable.c */
+/*                     ^ entity.name.variable.indexed.c */
 
 struct UI_BoundingBox *position_p;
 /*     ^ support.type.c - entity.name */
-/*                     ^ entity.name.variable.c */
+/*                     ^ entity.name.variable.indexed.c */
 
 struct UI_BoundingBox * position_p1;
 /*     ^ support.type.c - entity.name */
-/*                      ^ entity.name.variable.c */
+/*                      ^ entity.name.variable.indexed.c */
 
 struct UI_BoundingBox **position_p2;
 /*     ^ support.type.c - entity.name */
-/*                      ^ entity.name.variable.c */
+/*                      ^ entity.name.variable.indexed.c */
 
 struct UI_BoundingBox ** position_p3;
 /*     ^ support.type.c - entity.name */
-/*                       ^ entity.name.variable.c */
+/*                       ^ entity.name.variable.indexed.c */
 
 
 struct UI_BoundingBox ** position_p4, position_p5, * position_p6;
 /*     ^ support.type.c - entity.name */
-/*                       ^ entity.name.variable.c */
+/*                       ^ entity.name.variable.indexed.c */
 /*                    ^^ storage.modifier.c */
 /*                                  ^ punctuation.separator */
-/*                                    ^ entity.name.variable.c */
+/*                                    ^ entity.name.variable.indexed.c */
 /*                                               ^ punctuation.separator */
 /*                                                 ^ storage.modifier.c */
-/*                                                   ^ entity.name.variable.c */
+/*                                                   ^ entity.name.variable.indexed.c */
 
 // Partially-typed
 struct foo
@@ -966,58 +966,58 @@ struct UI_MenuBoxData
     struct UI_BoundingBox position;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
-/*                        ^ entity.name.member.c */
+/*                        ^ entity.name.member.indexed.c */
 /*                                ^ punctuation.terminator.c */
     struct UI_BoundingBox *position_p;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                         ^ entity.name.member.c */
+/*                         ^ entity.name.member.indexed.c */
 /*                                   ^ punctuation.terminator.c */
     struct UI_BoundingBox * position_p1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                          ^ entity.name.member.c */
+/*                          ^ entity.name.member.indexed.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox **position_p2;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
-/*                          ^ entity.name.member.c */
+/*                          ^ entity.name.member.indexed.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox ** position_p3;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^^ storage.modifier.c */
-/*                           ^ entity.name.member.c */
+/*                           ^ entity.name.member.indexed.c */
 /*                                      ^ punctuation.terminator.c */
     struct UI_BoundingBox* position_p4;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ storage.modifier.c */
-/*                         ^ entity.name.member.c */
+/*                         ^ entity.name.member.indexed.c */
 /*                                    ^ punctuation.terminator.c */
     struct UI_BoundingBox** position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^^ storage.modifier.c */
-/*                          ^ entity.name.member.c */
+/*                          ^ entity.name.member.indexed.c */
 /*                                     ^ punctuation.terminator.c */
     struct UI_BoundingBox * * position_p5;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
 /*                          ^ storage.modifier.c */
-/*                            ^ entity.name.member.c */
+/*                            ^ entity.name.member.indexed.c */
 /*                                       ^ punctuation.terminator.c */
     struct UI_BoundingBox *pos_1, *pos_1;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                        ^ storage.modifier.c */
-/*                         ^ entity.name.member.c */
+/*                         ^ entity.name.member.indexed.c */
 /*                                ^ storage.modifier.c */
-/*                                 ^ entity.name.member.c */
+/*                                 ^ entity.name.member.indexed.c */
 /*                                      ^ punctuation.terminator.c */
 
     const volatile struct UI_BoundingBox *cv_p;
@@ -1026,11 +1026,11 @@ struct UI_MenuBoxData
 /*                 ^^^^^^ storage.type */
 /*                        ^ support.type.c - entity.name */
 /*                                       ^ storage.modifier.c */
-/*                                        ^ entity.name.member.c */
+/*                                        ^ entity.name.member.indexed.c */
 /*                                            ^ punctuation.terminator.c */
     long resume_done[USB_MAXCHILDREN];
 /*  ^^^^ storage.type.c */
-/*       ^^^^^^^^^^^ entity.name.member.c */
+/*       ^^^^^^^^^^^ entity.name.member.indexed.c */
 /*                  ^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^^^^^^^^^^^^^^^ constant.other.macro.c */
@@ -1041,20 +1041,20 @@ struct UI_MenuBoxData
 /*         ^ support.type.c - entity.name */
 /*                       ^ constant.other.macro.c */
 /*                               ^ storage.modifier.c */
-/*                                 ^ entity.name.member.c */
+/*                                 ^ entity.name.member.indexed.c */
 /*                                        ^ punctuation.terminator.c */
     struct xhci_run_regs __attribute__((noderef)) *run_regs;
 /*  ^^^^^^ storage.type */
 /*         ^ support.type.c - entity.name */
 /*                       ^ - entity.name */
 /*                                                ^ storage.modifier.c */
-/*                                                 ^ entity.name.member.c */
+/*                                                 ^ entity.name.member.indexed.c */
 /*                                                         ^ punctuation.terminator.c */
     struct __attribute__((noderef)) xhci_run_regs *run_regs;
 /*  ^^^^^^ storage.type */
 /*                                  ^ support.type.c - entity.name */
 /*                                                ^ storage.modifier.c */
-/*                                                 ^ entity.name.member.c */
+/*                                                 ^ entity.name.member.indexed.c */
 /*                                                         ^ punctuation.terminator.c */
     struct nested_t {
 /*  ^^^^^^ storage.type */
@@ -1065,7 +1065,7 @@ struct UI_MenuBoxData
 /*          ^^^ 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.c */
+/*    ^^^^^^ entity.name.member.indexed.c */
 /*          ^ punctuation.terminator.c */
 
 #define CMD_RING_STATE_RUNNING         (1 << 0)
@@ -1075,29 +1075,29 @@ struct UI_MenuBoxData
     enum UI_BoxCharType borderType;
 /*  ^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.c - entity.name */
-/*                      ^ entity.name.member.c */
+/*                      ^ entity.name.member.indexed.c */
 /*                                ^ punctuation.terminator.c */
     unsigned int paddingX;
 /*  ^^^^^^^^ storage.type.c */
 /*           ^^^ storage.type.c */
-/*               ^^^^^^^^ entity.name.member.c */
+/*               ^^^^^^^^ entity.name.member.indexed.c */
 /*                       ^ punctuation.terminator.c */
     unsigned int paddingY;
 /*  ^^^^^^^^ storage.type.c */
 /*           ^^^ storage.type.c */
-/*               ^^^^^^^^ entity.name.member.c */
+/*               ^^^^^^^^ entity.name.member.indexed.c */
 /*                       ^ punctuation.terminator.c */
     struct UI_ScrollBoxText boxContents[];
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^^^ support.type.c */
-/*                          ^^^^^^^^^^^ entity.name.member.c */
+/*                          ^^^^^^^^^^^ entity.name.member.indexed.c */
 /*                                     ^ storage.modifier.c */
 /*                                       ^ punctuation.terminator.c */
 
     struct delayed_work monitor_work ____cacheline_aligned_in_smp;
 /*  ^^^^^^ storage.type */
 /*         ^^^^^^^^^^^^ support.type.c */
-/*                      ^^^^^^^^^^^^ entity.name.member.c */
+/*                      ^^^^^^^^^^^^ entity.name.member.indexed.c */
 /*                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                                                               ^ punctuation.terminator.c */
     const struct efx_channel_type *
@@ -1106,7 +1106,7 @@ struct UI_MenuBoxData
 /*               ^^^^^^^^^^^^^^^^ support.type - entity.name */
 /*                                ^ storage.modifier.c */
     extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
-/*  ^^^^^^^^^^^^^^^^^^ entity.name.member.c */
+/*  ^^^^^^^^^^^^^^^^^^ entity.name.member.indexed.c */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                     ^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                    ^ punctuation.section.brackets.begin.c storage.modifier.c */
@@ -1163,13 +1163,13 @@ struct rproc_ops {
 /*               ^ meta.struct.body.c meta.block.c punctuation.section.block.begin.c */
     int (*start)(struct rproc *rproc);
 /*  ^^^ storage.type.c */
-/*        ^^^^^ entity.name.member.c */
+/*        ^^^^^ entity.name.member.indexed.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
 /*                             ^^^^^ variable.parameter.c */
     int (*start)(struct rproc *);
 /*  ^^^ storage.type.c */
-/*        ^^^^^ entity.name.member.c */
+/*        ^^^^^ entity.name.member.indexed.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
@@ -1177,7 +1177,7 @@ struct rproc_ops {
 /*                             ^ meta.function.parameters.c meta.group.c punctuation.section.group.end.c */
     u32 (*start)(struct rproc *, struct rproc *);
 /*  ^^^ support.type.c */
-/*        ^^^^^ entity.name.member.c */
+/*        ^^^^^ entity.name.member.indexed.c */
 /*              ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*               ^^^^^^ storage.type.c */
 /*                      ^^^^^ support.type.c */
@@ -1189,7 +1189,7 @@ struct rproc_ops {
 /*                                             ^ 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.c */
+/*           ^^^^^^^^ entity.name.member.indexed.c */
 /*                     ^^^^^^ storage.type.c */
 /*                            ^^^^^ support.type.c */
 /*                                   ^^^^^ variable.parameter.c */
@@ -1200,7 +1200,7 @@ struct rproc_ops {
     struct resource_table *(*find_loaded_rsc_table)(
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^ support.type.c */
-/*                           ^^^^^^^^^^^^^^^^^^^^^ entity.name.member.c */
+/*                           ^^^^^^^^^^^^^^^^^^^^^ entity.name.member.indexed.c */
                 struct rproc *rproc, const struct firmware *fw);
 /*              ^^^^^^ storage.type.c */
 /*                     ^^^^^ support.type.c */
@@ -1216,7 +1216,7 @@ struct rproc_ops {
 
 void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
 /* <- storage.type.c */
-/*       ^^^^^^^^ entity.name.variable.c */
+/*       ^^^^^^^^ entity.name.variable.indexed.c */
 /*                 ^^^^^^ storage.type.c */
 /*                        ^^^^^ support.type.c */
 /*                              ^ storage.modifier.c */
@@ -1229,7 +1229,7 @@ void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
 struct resource_table *(*find_loaded_rsc_table)(
 /* <- storage.type.c */
 /*     ^^^^^^^^^^^^^^ support.type.c */
-/*                       ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.c */
+/*                       ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */
             struct rproc *rproc, const struct firmware *fw);
 /*          ^^^^^^ storage.type.c */
 /*                 ^^^^^ support.type.c */
@@ -1268,7 +1268,7 @@ extern int (*something)(const struct pci_dev *dev);
 /* <- storage.modifier.c */
 /*     ^^^ storage.type.c */
 /*          ^ storage.modifier.c */
-/*           ^^^^^^^^^ entity.name.variable.c */
+/*           ^^^^^^^^^ entity.name.variable.indexed.c */
 /*                     ^ meta.function.parameters.c meta.group.c punctuation.section.group.begin.c */
 /*                      ^^^^^ storage.modifier.c */
 /*                            ^^^^^^ storage.type.c */
@@ -1307,7 +1307,7 @@ static const struct pci_driver my_driver __pci_driver __driver = {
 /*     ^^^^^ storage.modifier.c */
 /*           ^^^^^^ storage.type.c */
 /*                  ^^^^^^^^^^ support.type.c */
-/*                             ^^^^^^^^^ entity.name.variable.c */
+/*                             ^^^^^^^^^ entity.name.variable.indexed.c */
 /*                                       ^^^^^^^^^^^^ constant.other.macro.c */
 /*                                                    ^^^^^^^^ constant.other.macro.c */
   .ops      = &pci_my_device_ops,
@@ -1315,19 +1315,19 @@ static const struct pci_driver my_driver __pci_driver __driver = {
 /* ^^^ variable.other.member.c */
 /*          ^ keyword.operator.assignment.c */
 /*            ^ keyword.operator.c */
-/*             ^^^^^^^^^^^^^^^^^ variable.other.c */
+/*             ^^^^^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                              ^ punctuation.separator.c */
   .vendor   = PCI_VENDOR_ID,
 /*^ punctuation.accessor.c */
-/* ^^^^^^ variable.other.member.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.c */
+/* ^^^^^^^ variable.other.member.indexed.c */
 /*          ^ keyword.operator.assignment.c */
-/*            ^^^^^^^^^^^^^^ variable.other.c */
+/*            ^^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                          ^ punctuation.separator.c */
 };
 
@@ -1351,12 +1351,12 @@ static const struct spd_info {
 /*                  ^^^^^^^^ entity.name.struct.c */
     size_t spd_len;
 /*  ^^^^^^ support.type */
-/*         ^^^^^^^ entity.name.member.c */
+/*         ^^^^^^^ entity.name.member.indexed.c */
     size_t spd_part_len;
 /*  ^^^^^^ support.type */
-/*         ^^^^^^^ entity.name.member.c */
+/*         ^^^^^^^ entity.name.member.indexed.c */
 } spd_mem_info[] = {
-/*^^^^^^^^^^^^  entity.name.variable.c */
+/*^^^^^^^^^^^^  entity.name.variable.indexed.c */
 /*            ^^ meta.brackets.c storage.modifier.c */
     [SPD_INFO_DDR4] = {
 /*  ^ meta.brackets.c punctuation.section.brackets.begin.c */
@@ -1372,9 +1372,9 @@ static const struct spd_info {
 /*   ^^^^^^^^^^^^^^^^ constant.other.macro.c */
 /*                   ^ meta.brackets.c punctuation.section.brackets.end.c */
         .spd_len = spd_default_length,
-/*                 ^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                 ^^^^^^^^^^^^^^^^^^ variable.other.indexed.c */
         .spd_part_len = spd_default_part_len,
-/*                      ^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*                      ^^^^^^^^^^^^^^^^^^^^ variable.other.indexed.c */
     },
 };
 
@@ -1382,7 +1382,7 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 /* <- storage.type.c */
 /*   ^ storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */
-/*           ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.c */
+/*           ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */
 /*                                ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
 /*                                                     ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
 /*                                                       ^^^^^^^^^ meta.function-call.c variable.function.c */
@@ -1394,12 +1394,12 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 /*^ meta.brackets.c punctuation.section.brackets.begin.c */
 /* ^ constant.numeric.c */
 /*   ^^^ keyword.operator.variadic.c */
-/*       ^^^^^^^^^^^^^^^^^^^^ variable.other.c */
+/*       ^^^^^^^^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                            ^ keyword.operator.arithmetic.c */
 /*                              ^ constant.numeric.c */
 /*                               ^ meta.brackets.c punctuation.section.brackets.end.c */
 /*                                 ^ keyword.operator.assignment.c */
-/*                                   ^^^^^^^^^^^^^^ variable.other.c */
+/*                                   ^^^^^^^^^^^^^^ variable.other.indexed.c */
 /*                                                 ^ punctuation.separator.c */
 #include <asm/unistd32.h>
 };
@@ -1408,7 +1408,7 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 /* <- support.type.c */
-/*    ^^^^^^^^^^^^^^ entity.name.variable.c */
+/*    ^^^^^^^^^^^^^^ entity.name.variable.indexed.c */
 /*                  ^^^^^^^^^^^^^^ meta.brackets.c */
 /*                  ^ punctuation.section.brackets.begin.c storage.modifier.c */
 /*                   ^^^^^^^^^^^^ constant.other.macro.c */
@@ -1437,7 +1437,7 @@ struct mac_tfm_ctx {
 /*                               ^ meta.group.c punctuation.section.group.begin.c */
 /*                                ^ constant.numeric.c */
 /*                                 ^ meta.group.c punctuation.section.group.end.c */
-/*                                   ^^^^ entity.name.member.c */
+/*                                   ^^^^ entity.name.member.indexed.c */
 /*                                       ^ punctuation.terminator.c */
   u8 __aligned(8) consts[];
 /*^^ support.type.c */
@@ -1446,7 +1446,7 @@ struct mac_tfm_ctx {
 /*            ^ meta.group.c punctuation.section.group.begin.c */
 /*             ^ constant.numeric.c */
 /*              ^ meta.group.c punctuation.section.group.end.c */
-/*                ^^^^^^ entity.name.member.c */
+/*                ^^^^^^ entity.name.member.indexed.c */
 /*                      ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
 /*                       ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
 /*                        ^ punctuation.terminator.c */
@@ -1509,23 +1509,23 @@ char *__attribute__((aligned(8))) *e,
 /*    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.c */
 /*    ^^^^^^^^^^^^^ storage.modifier.c */
 /*                                ^ storage.modifier.c */
-/*                                 ^ entity.name.variable.c */
+/*                                 ^ entity.name.variable.indexed.c */
 /*                                  ^ punctuation.separator.c */
   *f,
 /*^ storage.modifier.c */
-/* ^ entity.name.variable.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.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.c */
+/*                              ^ entity.name.variable.indexed.c */
 /*                               ^ punctuation.terminator.c */
 
 char *MACRO1 *e,
@@ -1533,41 +1533,41 @@ char *MACRO1 *e,
 /*   ^ storage.modifier.c */
 /*    ^^^^^^ constant.other.macro.c */
 /*           ^ storage.modifier.c */
-/*            ^ entity.name.variable.c */
+/*            ^ entity.name.variable.indexed.c */
 /*             ^ punctuation.separator.c */
   *f,
 /*^ storage.modifier.c */
-/* ^ entity.name.variable.c */
+/* ^ entity.name.variable.indexed.c */
 /*  ^ punctuation.separator.c */
   MACRO1 * g,
 /*^^^^^^ constant.other.macro.c */
 /*       ^ storage.modifier.c */
-/*         ^ entity.name.variable.c */
+/*         ^ entity.name.variable.indexed.c */
 /*          ^ punctuation.separator.c */
   * MACRO1 * h;
 /*^ storage.modifier.c */
 /*  ^^^^^^ constant.other.macro.c */
 /*         ^ storage.modifier.c */
-/*           ^ entity.name.variable.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.c */
+/*           ^ entity.name.variable.indexed.c */
 /*            ^ punctuation.separator.c */
   f,
-/*^ entity.name.variable.c */
+/*^ entity.name.variable.indexed.c */
 /* ^ punctuation.separator.c */
   MACRO1 g,
 /*^^^^^^ constant.other.macro.c */
-/*       ^ entity.name.variable.c */
+/*       ^ entity.name.variable.indexed.c */
 /*        ^ punctuation.separator.c */
   * MACRO1 h;
 /*^ storage.modifier.c */
 /*  ^^^^^^ constant.other.macro.c */
-/*         ^ entity.name.variable.c */
+/*         ^ entity.name.variable.indexed.c */
 /*          ^ punctuation.terminator.c */
 
 char *__aligned(8) *e,
@@ -1575,59 +1575,59 @@ char *__aligned(8) *e,
 /*   ^ storage.modifier.c */
 /*    ^^^^^^^^^^^^ meta.function-call */
 /*                 ^ storage.modifier.c */
-/*                  ^ entity.name.variable.c */
+/*                  ^ entity.name.variable.indexed.c */
 /*                   ^ punctuation.separator.c */
   *f,
 /*^ storage.modifier.c */
-/* ^ entity.name.variable.c */
+/* ^ entity.name.variable.indexed.c */
 /*  ^ punctuation.separator.c */
   __aligned(8) * g,
 /*^^^^^^^^^^^^ meta.function-call */
 /*             ^ storage.modifier.c */
-/*               ^ entity.name.variable.c */
+/*               ^ entity.name.variable.indexed.c */
 /*                ^ punctuation.separator.c */
   * __aligned(8) h,
 /*^ storage.modifier.c */
 /*  ^^^^^^^^^^^^ meta.function-call */
-/*               ^ entity.name.variable.c */
+/*               ^ entity.name.variable.indexed.c */
 /*                ^ punctuation.separator.c */
 
   __aligned(sizeof(int)) * i,
 /*^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */
 /*                       ^ storage.modifier.c */
-/*                         ^ entity.name.variable.c */
+/*                         ^ entity.name.variable.indexed.c */
 /*                          ^ punctuation.separator.c */
   __aligned(sizeof(void *)) * j,
 /*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */
 /*                          ^ storage.modifier.c */
-/*                            ^ entity.name.variable.c */
+/*                            ^ entity.name.variable.indexed.c */
 /*                             ^ punctuation.separator.c */
   __aligned(0x8) * k;
 /*^^^^^^^^^^^^^^ meta.function-call */
 /*               ^ storage.modifier.c */
-/*                 ^ entity.name.variable.c */
+/*                 ^ entity.name.variable.indexed.c */
 /*                  ^ punctuation.terminator.c */
 
 MACRO1 UPPER_VAR;
 /* <- constant.other.macro.c */
-/*     ^^^^^^^^^ entity.name.variable.c */
+/*     ^^^^^^^^^ entity.name.variable.indexed.c */
 /*              ^ punctuation.terminator.c */
 
 __safe UPPER_VAR;
 /* <- constant.other.macro.c */
-/*     ^^^^^^^^^ entity.name.variable.c */
+/*     ^^^^^^^^^ entity.name.variable.indexed.c */
 /*              ^ punctuation.terminator.c */
 
 TYPE(int) UPPER_VAR;
 /* <- meta.function-call */
-/*        ^^^^^^^^^ entity.name.variable.c */
+/*        ^^^^^^^^^ entity.name.variable.indexed.c */
 /*                 ^ punctuation.terminator.c */
 
 static const struct print_field const err_flags[];
 /*<- storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */
 /*                              ^^^^^ storage.modifier.c */
-/*                                    ^^^^^^^^^ entity.name.variable.c */
+/*                                    ^^^^^^^^^ entity.name.variable.indexed.c */
 /*                                             ^^ storage.modifier.c */
 /*                                               ^ punctuation.terminator.c */
 
@@ -1708,14 +1708,14 @@ int foo(int val, float val2[][])
 {
 /* <- meta.function meta.block */
     myClass *result;
-/*           ^^^^^^ variable.other.c */
+/*           ^^^^^^ variable.other.indexed.c */
     result->kk = func(val);
 /*        ^^ punctuation.accessor */
-/*  ^^^^^^ variable.other.c */
+/*  ^^^^^^ variable.other.indexed.c */
 /*          ^^ variable.other.member.c */
 /*                    ^^^ variable.other.c */
     if (result != 0) {
-/*      ^^^^^^ variable.other.c */
+/*      ^^^^^^ variable.other.indexed.c */
 /*             ^^ keyword.operator.comparison.c */
         return 0;
 #if CROSS_SCOPE_MACRO
@@ -1731,7 +1731,7 @@ int foo(int val, float val2[][])
 #ifdef FOO
  /* <- keyword.control.import */
     int foobar
-/*      ^^^^^^ variable.other.c */
+/*      ^^^^^^ variable.other.indexed.c */
     ;
 
     if (val == -1) {
@@ -1832,7 +1832,7 @@ MACRO1 void MACRO2 myfuncname (), MACRO2 foo(), UPPER_VAR, UPPERFN();
 /*                                       ^^^ entity.name.function.c */
 /*                                          ^^ meta.function.parameters.c */
 /*                                            ^ punctuation.separator.c */
-/*                                              ^^^^^^^^^ entity.name.variable.c */
+/*                                              ^^^^^^^^^ entity.name.variable.indexed.c */
 /*                                                       ^ punctuation.separator.c */
 /*                                                         ^^^^^^^ entity.name.function.c */
 /*                                                                ^^ meta.function.parameters.c */
@@ -1889,9 +1889,9 @@ MACRO1 void * MACRO2 myfuncname () {
 /*  ^ storage.type */
 /*         ^ entity.name.struct */
         void* hello;
-/*            ^^^^^ entity.name.member.c */
+/*            ^^^^^ entity.name.member.indexed.c */
         void* foobar;
-/*            ^^^^^^ entity.name.member.c */
+/*            ^^^^^^ entity.name.member.indexed.c */
     };
 
     struct Args args;
@@ -1926,14 +1926,14 @@ funcname2
 MACRO_CALL(int) foo;
 /*^^^^^^^^^^^^^ meta.function-call */
 /*        ^^^^^ meta.group */
-/*              ^^^ entity.name.variable.c */
+/*              ^^^ 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.c */
+/*                         ^^^ entity.name.variable.indexed.c */
 /*                            ^ punctuation.terminator.c */
 
 MACRO_CALL(int) ALIGNED(8) macro_prefixed_func(){}
@@ -1971,7 +1971,7 @@ extern NCURSES_EXPORT_VAR(int) COLORS;
 /* <- storage.modifier.c */
 /*     ^^^^^^^^^^^^^^^^^ meta.function-call.c */
 /*                       ^^^^^ meta.function-call.parameters.c */
-/*                             ^^^^^^ entity.name.variable.c */
+/*                             ^^^^^^ entity.name.variable.indexed.c */
 
 int* return_type_pointer_no_space(){}
 /* <- storage.type.c */
@@ -2125,8 +2125,12 @@ int control_keywords()
   }
   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 */
@@ -2138,6 +2142,15 @@ int control_keywords()
 /*                   ^^^^^^^^^ 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.c */
+/*                          ^ punctuation.terminator.c */
   do
   /* <- keyword.control */
   {

From 464010a5fea250e805478ef515a432a4c9114bcd Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 25 Apr 2019 08:51:15 -0600
Subject: [PATCH 41/55] Match macros with multiple arguments

---
 C++/C.sublime-syntax | 20 ++++++++++++++++-
 C++/syntax_test_c.c  | 53 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 15f8514ed5..d9cd59a60d 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -135,7 +135,25 @@ contexts:
       scope: storage.modifier.c
 
   modifiers-macros:
-    - match: '(?:{{macro_identifier}}|{{attr_macro_identifier}})(?=\s*\((?:\d+|0x\d+|sizeof\([^\)]*\)|{{macro_identifier}})\))'
+    - match: |-
+        (?x:
+          (?:{{macro_identifier}}|{{attr_macro_identifier}})
+          (?=
+            \(
+            \s*
+            (?>
+              (?>
+                0[xX][[:xdigit:]]+ |
+                \d+ |
+                sizeof\([^\)]*\) |
+                {{macro_identifier}}
+              )
+              \s*
+              (?:,\s*|(?=\)))
+            )+
+            \)
+          )
+        )
       scope: variable.function.c debug.modifiers-macros
       comment: Preprocessor Attributes with parameters.
         We only support a very limited definition so it doesn't gobble up
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index aa1a4ae59f..c5dfe1dad4 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1623,6 +1623,59 @@ TYPE(int) UPPER_VAR;
 /*        ^^^^^^^^^ entity.name.variable.indexed.c */
 /*                 ^ punctuation.terminator.c */
 
+void __printf(1)
+/* <- storage.type.c */
+/*   ^^^^^^^^ meta.function-call.c variable.function.c  */
+/*            ^ constant.numeric.c */
+/*           ^^^ meta.function-call.parameters.c */
+__printf(1,)
+/* ^^^^^ meta.function-call.c variable.function.c */
+/*      ^^^^ meta.function-call.parameters.c */
+/*      ^ punctuation.section.group.begin.c */
+/*       ^ constant.numeric.c */
+/*        ^ punctuation.separator.c */
+/*         ^ punctuation.section.group.end.c */
+__printf(1, )
+/* ^^^^^ meta.function-call.c variable.function.c */
+/*      ^^^^^ meta.function-call.parameters.c */
+/*      ^ punctuation.section.group.begin.c */
+/*       ^ constant.numeric.c */
+/*        ^ punctuation.separator.c */
+/*          ^ punctuation.section.group.end.c */
+__printf(1, 2)
+/* ^^^^^ meta.function-call.c variable.function.c */
+/*      ^^^^^^ meta.function-call.parameters.c */
+/*      ^ punctuation.section.group.begin.c */
+/*       ^ constant.numeric.c */
+/*        ^ punctuation.separator.c */
+/*          ^ constant.numeric.c */
+/*           ^ punctuation.section.group.end.c */
+__printf(1, 2, 3)
+/* ^^^^^ meta.function-call.c variable.function.c */
+/*      ^^^^^^^^^ meta.function-call.parameters.c */
+/*      ^ punctuation.section.group.begin.c */
+/*       ^ constant.numeric.c */
+/*        ^ punctuation.separator.c */
+/*          ^ constant.numeric.c */
+/*           ^ punctuation.separator.c */
+/*             ^ constant.numeric.c */
+/*              ^ punctuation.section.group.end.c */
+__printf(0x1, 0xA, sizeof(int))
+/* ^^^^^ meta.function-call.c variable.function.c */
+/*      ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.parameters.c */
+/*      ^ punctuation.section.group.begin.c */
+/*       ^^^ constant.numeric.c */
+/*          ^ punctuation.separator.c */
+/*            ^^^ constant.numeric.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 */

From ede174b180f5c80e2336514bbde7d5ac8b0cfcd1 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Thu, 25 Apr 2019 08:54:52 -0600
Subject: [PATCH 42/55] Change macro calls to constant.other.macro.c

---
 C++/C.sublime-syntax |  2 +-
 C++/syntax_test_c.c  | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index d9cd59a60d..8ec7cbc6ef 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -154,7 +154,7 @@ contexts:
             \)
           )
         )
-      scope: variable.function.c debug.modifiers-macros
+      scope: constant.other.macro.c debug.modifiers-macros
       comment: Preprocessor Attributes with parameters.
         We only support a very limited definition so it doesn't gobble up
         actual function definitions.
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index c5dfe1dad4..9752532627 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1337,7 +1337,7 @@ struct __ec_align4 ec_response_get_version {};
 /*                 ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
 struct __align(4) ec_response_get_version {};
 /* <- storage.type.c */
-/*     ^^^^^^^ meta.function-call.c variable.function.c */
+/*     ^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*            ^^^ meta.function-call.parameters.c  */
 /*                ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.c */
 
@@ -1385,7 +1385,7 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 /*           ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */
 /*                                ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
 /*                                                     ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.c */
-/*                                                       ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                                                       ^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                                                                ^^^^^^ meta.function-call.parameters.c */
 /*                                                                 ^^^^ constant.numeric.c */
 /*                                                                       ^ keyword.operator.assignment.c */
@@ -1413,7 +1413,7 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 /*                  ^ punctuation.section.brackets.begin.c storage.modifier.c */
 /*                   ^^^^^^^^^^^^ constant.other.macro.c */
 /*                               ^ punctuation.section.brackets.end.c storage.modifier.c */
-/*                                 ^^^^^^^^^ meta.function-call.c variable.function.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 */
@@ -1432,7 +1432,7 @@ struct mac_tfm_ctx {
   struct crypto_aes_ctx __aligned(8) key2;
 /*^^^^^^ storage.type.c */
 /*       ^^^^^^^^^^^^^^ support.type.c */
-/*                      ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*                      ^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                               ^^^ meta.function-call.parameters.c */
 /*                               ^ meta.group.c punctuation.section.group.begin.c */
 /*                                ^ constant.numeric.c */
@@ -1441,7 +1441,7 @@ struct mac_tfm_ctx {
 /*                                       ^ punctuation.terminator.c */
   u8 __aligned(8) consts[];
 /*^^ support.type.c */
-/*   ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*   ^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*            ^^^ meta.function-call.parameters.c */
 /*            ^ meta.group.c punctuation.section.group.begin.c */
 /*             ^ constant.numeric.c */
@@ -1453,7 +1453,7 @@ struct mac_tfm_ctx {
 } __packed __aligned(4);
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
 /*^^^^^^^^ constant.other.macro.c */
-/*         ^^^^^^^^^ meta.function-call.c variable.function.c */
+/*         ^^^^^^^^^ meta.function-call.c constant.other.macro.c */
 /*                  ^^^ meta.function-call.parameters.c */
 /*                  ^ meta.group.c punctuation.section.group.begin.c */
 /*                   ^ constant.numeric.c */
@@ -1625,25 +1625,25 @@ TYPE(int) UPPER_VAR;
 
 void __printf(1)
 /* <- storage.type.c */
-/*   ^^^^^^^^ meta.function-call.c variable.function.c  */
+/*   ^^^^^^^^ meta.function-call.c constant.other.macro.c  */
 /*            ^ constant.numeric.c */
 /*           ^^^ meta.function-call.parameters.c */
 __printf(1,)
-/* ^^^^^ meta.function-call.c variable.function.c */
+/* ^^^^^ meta.function-call.c constant.other.macro.c */
 /*      ^^^^ meta.function-call.parameters.c */
 /*      ^ punctuation.section.group.begin.c */
 /*       ^ constant.numeric.c */
 /*        ^ punctuation.separator.c */
 /*         ^ punctuation.section.group.end.c */
 __printf(1, )
-/* ^^^^^ meta.function-call.c variable.function.c */
+/* ^^^^^ meta.function-call.c constant.other.macro.c */
 /*      ^^^^^ meta.function-call.parameters.c */
 /*      ^ punctuation.section.group.begin.c */
 /*       ^ constant.numeric.c */
 /*        ^ punctuation.separator.c */
 /*          ^ punctuation.section.group.end.c */
 __printf(1, 2)
-/* ^^^^^ meta.function-call.c variable.function.c */
+/* ^^^^^ meta.function-call.c constant.other.macro.c */
 /*      ^^^^^^ meta.function-call.parameters.c */
 /*      ^ punctuation.section.group.begin.c */
 /*       ^ constant.numeric.c */
@@ -1651,7 +1651,7 @@ __printf(1, 2)
 /*          ^ constant.numeric.c */
 /*           ^ punctuation.section.group.end.c */
 __printf(1, 2, 3)
-/* ^^^^^ meta.function-call.c variable.function.c */
+/* ^^^^^ meta.function-call.c constant.other.macro.c */
 /*      ^^^^^^^^^ meta.function-call.parameters.c */
 /*      ^ punctuation.section.group.begin.c */
 /*       ^ constant.numeric.c */
@@ -1661,7 +1661,7 @@ __printf(1, 2, 3)
 /*             ^ constant.numeric.c */
 /*              ^ punctuation.section.group.end.c */
 __printf(0x1, 0xA, sizeof(int))
-/* ^^^^^ meta.function-call.c variable.function.c */
+/* ^^^^^ meta.function-call.c constant.other.macro.c */
 /*      ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.parameters.c */
 /*      ^ punctuation.section.group.begin.c */
 /*       ^^^ constant.numeric.c */

From 5ba0fe6831d9bf556d884d72c9e147f326962ea5 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 6 May 2019 09:19:52 -0600
Subject: [PATCH 43/55] Don't use atomic groups!

---
 C++/C.sublime-syntax | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 8ec7cbc6ef..b79d7a7f36 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -141,8 +141,8 @@ contexts:
           (?=
             \(
             \s*
-            (?>
-              (?>
+            (?:
+              (?:
                 0[xX][[:xdigit:]]+ |
                 \d+ |
                 sizeof\([^\)]*\) |

From 194b0ff9cba3566a5b51b4a0e5e124f7f3d59c9b Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 28 Oct 2019 16:34:39 -0600
Subject: [PATCH 44/55] state is very common, don't index it

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index b79d7a7f36..25e0d336bc 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -12,7 +12,7 @@ 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 # host, dev, i, port, attr, buf, args
+  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'
   microsoft_types: '__int8|__int16|__int32|__int64'

From 8fd5123e5a9911705bbbe8694818f191e7365569 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 28 Oct 2019 16:35:45 -0600
Subject: [PATCH 45/55] Support modifiers before typedef

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 12 +++++++++---
 C++/syntax_test_c.c  | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 25e0d336bc..c209f18bd9 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -894,8 +894,17 @@ contexts:
     - meta_scope: debug.type-declaration
     - include: comments
     - include: modifiers
+    - match: (?={{identifier}};)
+      pop: true
+      comment: Used for typedefing things defined in types.
     - include: modifiers-macros
     - include: modifiers-parens
+    - match: \btypedef\b
+      scope: storage.type.c
+      comment: There could be modifiers before typedef
+      set:
+        - typedef-identifier-list
+        - type-declaration
     # Make sure to pop when a data structure keyword is found
     - match: (?=\bstruct\b)
       set:
@@ -912,9 +921,6 @@ contexts:
         - meta_scope: debug.type-declaration.union
         - include: union-keyword
         - include: or_pop
-    - match: (?={{identifier}};)
-      pop: true
-      comment: Used for typedefing things defined in types.
     - include: types
     - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 9752532627..e77890d19f 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -457,6 +457,23 @@ typedef   __s8    int8_t;
 /*        ^^^^ constant.other.macro.c */
 /*                ^^^^^^ entity.name.type.typedef.c */
 
+typedef unsigned long long __u64;
+/* <- storage.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
 /////////////////////////////////////////////

From 03f4cc5c3154a0a4e32c5f9f3bfb13fb20a78905 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 28 Oct 2019 16:51:12 -0600
Subject: [PATCH 46/55] Use YAML commnets

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 51 ++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index c209f18bd9..2bea6fcb89 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -27,8 +27,8 @@ variables:
 
 contexts:
   or_pop:
+    # Pop if nothing matched (whitespace is ignored).
     - match: '(?=\S)'
-      comment: Pop if nothing matched (whitespace are ignored).
       pop: true
 
   main:
@@ -135,6 +135,9 @@ contexts:
       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}})
@@ -155,15 +158,12 @@ contexts:
           )
         )
       scope: constant.other.macro.c debug.modifiers-macros
-      comment: Preprocessor Attributes with parameters.
-        We only support a very limited definition so it doesn't gobble up
-        actual function definitions.
       push:
         - meta_scope: meta.function-call.c
         - include: function-call-params
+    # Preprocessor Attributes
     - match: '{{attr_macro_identifier}}(?!\s*\()'
       scope: constant.other.macro.c debug.modifiers-macros.underscore
-      comment: Preprocessor Attributes
     - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*|\)|\s*\n)'
       scope: constant.other.macro.c debug.modifiers-macros.caps
 
@@ -346,10 +346,10 @@ contexts:
   # 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
-      comment: 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: '{{identifier}}'
       scope: variable.other.indexed.c
 
@@ -453,9 +453,9 @@ contexts:
     - include: modifiers-macros
     - match: \*
       scope: storage.modifier.c
+    # Function pointer declaration
     - match: \(
       scope: punctuation.section.group.begin.c debug.parameter-identifier.function-pointer
-      comment: Function pointer declaration
       push:
         - meta_scope: meta.group.c
         - match: \)
@@ -510,9 +510,9 @@ contexts:
   parameter-variable-identifier:
     - match: \*
       scope: storage.modifier.c
+    # Function pointer declaration as variable
     - match: \(
       scope: punctuation.section.group.begin.c debug.parameter-variable-identifier.function-pointer
-      comment: Function pointer declaration as variable
       push:
         - meta_scope: meta.parens
         - match: \)
@@ -555,9 +555,9 @@ contexts:
           - include: comments
           - include: function-definition-params-group
           - include: or_pop
+    # Function pointer declaration
     - match: \((?=\s*\*)
       scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
-      comment: Function pointer declaration
       push:
         - meta_scope: meta.parens
         - match: \)
@@ -598,9 +598,9 @@ contexts:
     - include: modifiers-macros
     - match: \*
       scope: storage.modifier.c
+    # Function pointer declaration
     - match: \(
       scope: punctuation.section.group.begin.c debug.member-variable-identifier-list.function-pointer
-      comment: Function pointer declaration
       push:
         - meta_scope: meta.parens
         - match: \)
@@ -612,9 +612,10 @@ contexts:
           scope: storage.modifier.c
         - match: '{{identifier}}'
           scope: entity.name.member.indexed.c debug.member-variable-identifier-list.function-pointer
+    # 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 debug.member-variable-identifier-list
-      comment: There are a lot of common variable names 4 characters or under.
       push:
         - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
@@ -638,16 +639,16 @@ contexts:
       push:
         - meta_scope: meta.struct.c debug.struct-keyword
         - include: data-structures-definition-common-begin
+        # struct definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
           scope: entity.name.struct.c
-          comment: Struct definition
           set: struct-body
+        # struct declaration
         - match: '{{identifier}}'
           scope: support.type.c
-          comment: Struct declaration
           pop: true
+        # Anonymous struct definition
         - match: '(?={)'
-          comment: Anonymous struct definition
           set: struct-body
         - include: or_pop
   struct-body:
@@ -670,16 +671,16 @@ contexts:
       push:
         - meta_scope: meta.enum.c debug.enum-keyword
         - include: data-structures-definition-common-begin
+        # enum definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
           scope: entity.name.enum.c
-          comment: Struct definition
           set: enum-body
+        # enum declaration
         - match: '{{identifier}}'
           scope: support.type.c
-          comment: Struct declaration
           pop: true
+        # Anonymous enum definition
         - match: '(?={)'
-          comment: Anonymous enum definition
           set: enum-body
         - include: or_pop
   enum-body:
@@ -723,16 +724,16 @@ contexts:
       push:
         - meta_scope: meta.union.c debug.union-keyword
         - include: data-structures-definition-common-begin
+        # union definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
           scope: entity.name.union.c
-          comment: Struct definition
           set: union-body
+        # union declaration
         - match: '{{identifier}}'
           scope: support.type.c
-          comment: Struct declaration
           pop: true
+        # Anonymous union definition
         - match: '(?={)'
-          comment: Anonymous union definition
           set: union-body
         - include: or_pop
   union-body:
@@ -894,14 +895,14 @@ contexts:
     - meta_scope: debug.type-declaration
     - include: comments
     - include: modifiers
+    # Used for typedefing things defined in types.
     - match: (?={{identifier}};)
       pop: true
-      comment: Used for typedefing things defined in types.
     - include: modifiers-macros
     - include: modifiers-parens
+    # There could be modifiers before typedef
     - match: \btypedef\b
       scope: storage.type.c
-      comment: There could be modifiers before typedef
       set:
         - typedef-identifier-list
         - type-declaration
@@ -943,9 +944,9 @@ contexts:
       push:
         - include: declaration-brackets
         - include: or_pop
+    # Function pointers
     - match: '\((?=\s*\*)'
       scope: punctuation.section.group.begin.c debug.typedef.function-pointer
-      comment: Function pointers
       set:
         - meta_scope: meta.parens
         - match: \)
@@ -997,9 +998,9 @@ contexts:
         - 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
-          comment: Inside macro params, the identifiers can start with numbers
 
   ## Preprocessor for data-structures
 

From 91729f25aa757dbcb583ab1fddc5596d4db8babf Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 28 Oct 2019 16:59:51 -0600
Subject: [PATCH 47/55] Fix missing .c

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 2bea6fcb89..e5dd2d4ca1 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -514,9 +514,9 @@ contexts:
     - match: \(
       scope: punctuation.section.group.begin.c debug.parameter-variable-identifier.function-pointer
       push:
-        - meta_scope: meta.parens
+        - meta_scope: meta.parens.c
         - match: \)
-          scope: punctuation.section.parens.end
+          scope: punctuation.section.parens.end.c
           set:
             - include: function-definition-params-group
             - include: or_pop
@@ -559,9 +559,9 @@ contexts:
     - match: \((?=\s*\*)
       scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
       push:
-        - meta_scope: meta.parens
+        - meta_scope: meta.parens.c
         - match: \)
-          scope: punctuation.section.parens.end
+          scope: punctuation.section.parens.end.c
           set:
             - include: function-definition-params-group
             - include: or_pop
@@ -602,9 +602,9 @@ contexts:
     - match: \(
       scope: punctuation.section.group.begin.c debug.member-variable-identifier-list.function-pointer
       push:
-        - meta_scope: meta.parens
+        - meta_scope: meta.parens.c
         - match: \)
-          scope: punctuation.section.parens.end
+          scope: punctuation.section.parens.end.c
           set:
             - include: function-definition-params-group
             - include: or_pop
@@ -948,9 +948,9 @@ contexts:
     - match: '\((?=\s*\*)'
       scope: punctuation.section.group.begin.c debug.typedef.function-pointer
       set:
-        - meta_scope: meta.parens
+        - meta_scope: meta.parens.c
         - match: \)
-          scope: punctuation.section.parens.end
+          scope: punctuation.section.parens.end.c
           set:
             - include: function-definition-params-group
             - include: or_pop

From 7707941aec25d78cd7732672d51d525a6108986b Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 29 Oct 2019 09:56:30 -0600
Subject: [PATCH 48/55] Remove storage.modifer on array declarations

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax |  4 ++--
 C++/syntax_test_c.c  | 42 ++++++++++++++++++++++++------------------
 2 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index e5dd2d4ca1..73e45d693e 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -814,11 +814,11 @@ contexts:
 
   declaration-brackets:
     - match: \[
-      scope: punctuation.section.brackets.begin.c storage.modifier.c
+      scope: punctuation.section.brackets.begin.c
       push:
         - meta_scope: meta.brackets.c
         - match: \]
-          scope: punctuation.section.brackets.end.c storage.modifier.c
+          scope: punctuation.section.brackets.end.c
           pop: true
         - include: expressions
 
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index e77890d19f..a196968153 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -416,17 +416,17 @@ typedef char arrType[6];
 /*<- storage.type.c */
 /*      ^^^^ storage.type.c */
 /*           ^^^^^^^ entity.name.type */
-/*                  ^ storage.modifier */
+/*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^ constant.numeric.c */
-/*                    ^ storage.modifier */
+/*                    ^ punctuation.section.brackets.end.c */
 
 typedef char arrType[NUMBER_OF_ELEMENTS];
 /*<- storage.type.c */
 /*      ^^^^ storage.type.c */
 /*           ^^^^^^^ entity.name.type.typedef.c */
-/*                  ^ storage.modifier */
+/*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
-/*                                     ^ storage.modifier */
+/*                                     ^ punctuation.section.brackets.end.c */
 
 typedef unsigned long ulong, *ulongptr;
 /*<- storage.type.c */
@@ -743,7 +743,9 @@ struct {
 /*        ^ keyword.operator.assignment.c */
 /*                  ^ punctuation.separator */
 /*                    ^^^^^^^^ entity.name.variable.indexed.c  */
-/*                            ^^ meta.brackets.c storage.modifier.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  */
@@ -1108,7 +1110,8 @@ struct UI_MenuBoxData
 /*  ^^^^^^ storage.type.c */
 /*         ^^^^^^^^^^^^^^^^ support.type.c */
 /*                          ^^^^^^^^^^^ entity.name.member.indexed.c */
-/*                                     ^ storage.modifier.c */
+/*                                     ^ punctuation.section.brackets.begin.c */
+/*                                      ^ punctuation.section.brackets.end.c */
 /*                                       ^ punctuation.terminator.c */
 
     struct delayed_work monitor_work ____cacheline_aligned_in_smp;
@@ -1126,8 +1129,8 @@ struct UI_MenuBoxData
 /*  ^^^^^^^^^^^^^^^^^^ entity.name.member.indexed.c */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.c */
 /*                     ^^^^^^^^^^^^^^^^^^^^^^ constant.other.macro.c */
-/*                    ^ punctuation.section.brackets.begin.c storage.modifier.c */
-/*                                           ^ punctuation.section.brackets.end.c storage.modifier.c */
+/*                    ^ punctuation.section.brackets.begin.c */
+/*                                           ^ punctuation.section.brackets.end.c */
 
 #if 0
     struct UI_BoundingBox bb1;
@@ -1374,7 +1377,9 @@ static const struct spd_info {
 /*         ^^^^^^^ entity.name.member.indexed.c */
 } spd_mem_info[] = {
 /*^^^^^^^^^^^^  entity.name.variable.indexed.c */
-/*            ^^ meta.brackets.c storage.modifier.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 */
@@ -1400,8 +1405,8 @@ void * const compat_sys_call_table[__NR_compat_syscalls] __aligned(4096) = {
 /*   ^ storage.modifier.c */
 /*     ^^^^^ storage.modifier.c */
 /*           ^^^^^^^^^^^^^^^^^^^^^ entity.name.variable.indexed.c */
-/*                                ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
-/*                                                     ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.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.c */
@@ -1427,9 +1432,9 @@ 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 storage.modifier.c */
+/*                  ^ punctuation.section.brackets.begin.c */
 /*                   ^^^^^^^^^^^^ constant.other.macro.c */
-/*                               ^ punctuation.section.brackets.end.c storage.modifier.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 */
@@ -1464,8 +1469,8 @@ struct mac_tfm_ctx {
 /*             ^ constant.numeric.c */
 /*              ^ meta.group.c punctuation.section.group.end.c */
 /*                ^^^^^^ entity.name.member.indexed.c */
-/*                      ^ meta.brackets.c punctuation.section.brackets.begin.c storage.modifier.c */
-/*                       ^ meta.brackets.c punctuation.section.brackets.end.c storage.modifier.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 */
@@ -1698,7 +1703,8 @@ static const struct print_field const err_flags[];
 /*     ^^^^^ storage.modifier.c */
 /*                              ^^^^^ storage.modifier.c */
 /*                                    ^^^^^^^^^ entity.name.variable.indexed.c */
-/*                                             ^^ storage.modifier.c */
+/*                                             ^ punctuation.section.brackets.begin.c */
+/*                                              ^ punctuation.section.brackets.end.c */
 /*                                               ^ punctuation.terminator.c */
 
 enum {
@@ -1768,10 +1774,10 @@ int foo(int val, float val2[][])
 /*          ^^^ variable.parameter */
 /*             ^ punctuation.separator */
 /*                     ^^^^ variable.parameter */
-/*                         ^^ meta.brackets.c storage.modifier.c */
+/*                         ^^ meta.brackets.c */
 /*                         ^ punctuation.section.brackets.begin */
 /*                          ^ punctuation.section.brackets.end */
-/*                           ^^ meta.brackets.c storage.modifier.c */
+/*                           ^^ meta.brackets.c */
 /*                           ^ punctuation.section.brackets.begin */
 /*                            ^ punctuation.section.brackets.end */
 /*                             ^ punctuation.section.group.end */

From 61b936b2bd4a45618f56474f19284f0afc3d2670 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 29 Oct 2019 10:02:33 -0600
Subject: [PATCH 49/55] Conver to scope

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 73e45d693e..4691256f88 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -932,13 +932,11 @@ contexts:
     - include: comments
     - match: \*
       scope: storage.modifier.c
-    - match: ({{identifier}})(?=\s*;)
-      captures:
-        1: entity.name.type.typedef.c
+    - match: '{{identifier}}(?=\s*;)'
+      scope: entity.name.type.typedef.c
       pop: true
-    - match: ({{identifier}})(?=\s*,)
-      captures:
-        1: entity.name.type.typedef.c
+    - match: '{{identifier}}(?=\s*,)'
+      scope: entity.name.type.typedef.c
     - match: '{{identifier}}(?=\s*\[)'
       scope: entity.name.type.typedef.c debug.typedef.array
       push:

From 4da2d3bb643df54f98b146c8a62058d369099032 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 29 Oct 2019 10:18:04 -0600
Subject: [PATCH 50/55] Remove debug scopes

These are very helpful when debugging the syntax. If you run into
problems, revert this so you know what the context chain looks like.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 162 ++++++++++++++++++-------------------------
 C++/syntax_test_c.c  |   4 +-
 2 files changed, 69 insertions(+), 97 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 4691256f88..fa1ec84dc4 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -128,7 +128,7 @@ contexts:
     - match: \b({{control_keywords}})\b
       scope: keyword.control.c
     - match: \bsizeof\b
-      scope: keyword.operator.word.c debug.keywords
+      scope: keyword.operator.word.c
 
   modifiers:
     - match: \b({{modifiers}})\b
@@ -157,15 +157,15 @@ contexts:
             \)
           )
         )
-      scope: constant.other.macro.c debug.modifiers-macros
+      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 debug.modifiers-macros.underscore
+      scope: constant.other.macro.c
     - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*|\)|\s*\n)'
-      scope: constant.other.macro.c debug.modifiers-macros.caps
+      scope: constant.other.macro.c
 
   variables:
     - match: '\bg[A-Z]\w*\b'
@@ -287,7 +287,7 @@ contexts:
   # comment without a line continuation ends at the newline.
   preprocessor-comments:
     - match: /\*
-      scope: punctuation.definition.comment.c debug.preprocessor-comments
+      scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.block.c
         - match: '\\$\n'
@@ -296,7 +296,7 @@ contexts:
           scope: punctuation.definition.comment.c
           pop: true
     - match: //
-      scope: punctuation.definition.comment.c debug.preprocessor-comments
+      scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.line.double-slash.c
         - match: '(\\)$\n'
@@ -328,7 +328,6 @@ contexts:
     - include: early-expressions
     - match: '(?=\w+)'
       push:
-        - meta_scope: debug.global.token
         - include: comments
         - include: modifiers-parens
         - include: modifiers
@@ -393,10 +392,9 @@ contexts:
   global-function-call:
     - match: (?={{identifier}}\s*\((?!\s*\*))
       set:
-        - - meta_scope: debug.global-function-call.type-or-terminator
-          - include: comments
+        - - include: comments
           - match: ';'
-            scope: punctuation.terminator.c debug.global-function-call
+            scope: punctuation.terminator.c
             pop: true
           - match: \n
             comments: Macro invocations sometimes don't require a ; to terminate
@@ -406,8 +404,7 @@ contexts:
             pop: true
           - match: '(?=\S)'
             set: global-declaration
-        - - meta_scope: debug.global-function-call.params
-          - include: function-call-params
+        - - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
             scope: constant.other.macro.c
@@ -420,7 +417,7 @@ contexts:
         - type-declaration
 
   function-definition-params:
-    - meta_content_scope: meta.function.c debug.function-definition-params
+    - meta_content_scope: meta.function.c
     - include: comments
     - match: '(?=\()'
       set:
@@ -446,7 +443,6 @@ contexts:
             - type-declaration
 
   parameter-identifier:
-    - meta_scope: debug.parameter-identifier
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -455,7 +451,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration
     - match: \(
-      scope: punctuation.section.group.begin.c debug.parameter-identifier.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.group.c
         - match: \)
@@ -466,11 +462,10 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.parameter.c debug.parameter-identifier.function-pointer
+          scope: variable.parameter.c
     - match: '{{identifier}}'
-      scope: variable.parameter.c debug.parameter-identifier
+      scope: variable.parameter.c
       push:
-        - meta_scope: debug.parameter-identifier.array-or-assignment
         - include: declaration-brackets
         - include: or_pop
     - include: or_pop
@@ -490,7 +485,7 @@ contexts:
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.function.c meta.block.c debug.function-definition-body
+        - meta_scope: meta.function.c meta.block.c
         - match: '\}'
           scope: punctuation.section.block.end.c
           pop: true
@@ -512,7 +507,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration as variable
     - match: \(
-      scope: punctuation.section.group.begin.c debug.parameter-variable-identifier.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -523,12 +518,11 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.parameter.c debug.parameter-variable-identifier.function-pointer
+          scope: variable.parameter.c
     - match: '{{identifier}}'
-      scope: variable.parameter.c debug.parameter-variable-identifier
+      scope: variable.parameter.c
 
   variable-identifier-list:
-    - meta_scope: debug.variable-identifier-list
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -536,28 +530,25 @@ contexts:
     - match: \*
       scope: storage.modifier.c
     - match: '{{identifier}}(?=\s*\(|\s*\n)'
-      scope: meta.function.c entity.name.function.c debug.variable-identifier-list.function
+      scope: meta.function.c entity.name.function.c
       set:
-        - - meta_scope: debug.variable-identifier-list.function-body
-          - include: comments
+        - - include: comments
           - include: function-definition-body
           - match: '(?=\S)'
             set: variable-identifier-list
-        - - meta_scope: debug.variable-identifier-list.function-modifiers
-          - include: comments
+        - - include: comments
           - include: modifiers-parens
           # Macro invocations
           - include: function-call-c
           - match: '{{identifier}}'
-            scope: constant.other.macro.c debug.variable-identifier-list.function-attribute
+            scope: constant.other.macro.c
           - include: or_pop
-        - - meta_scope: debug.variable-identifier-list.function-params
-          - include: comments
+        - - include: comments
           - include: function-definition-params-group
           - include: or_pop
     # Function pointer declaration
     - match: \((?=\s*\*)
-      scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -568,30 +559,27 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.variable.indexed.c debug.variable-identifier-list.function-pointer
+          scope: entity.name.variable.indexed.c
     - match: '{{identifier}}'
-      scope: entity.name.variable.indexed.c debug.variable-identifier-list
+      scope: entity.name.variable.indexed.c
       push:
-        - meta_scope: debug.variable-identifier-list.array-or-assignment
         - include: declaration-brackets
         - match: \=
           scope: keyword.operator.assignment.c
           set:
-            - meta_scope: debug.variable-identifier-list.assignment
             - match: '(?=,|;)'
               pop: true
             - include: expressions
             - include: or_pop
         - include: or_pop
     - match: ','
-      scope: punctuation.separator.c debug.variable-identifier-list
+      scope: punctuation.separator.c
     - match: ';'
       scope: punctuation.terminator.c
       pop: true
     - include: or_pop
 
   member-variable-identifier-list:
-    - meta_scope: debug.member-variable-identifier-list
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -600,7 +588,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration
     - match: \(
-      scope: punctuation.section.group.begin.c debug.member-variable-identifier-list.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -611,23 +599,21 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.member.indexed.c debug.member-variable-identifier-list.function-pointer
+          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 debug.member-variable-identifier-list
+      scope: entity.name.member.c
       push:
-        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: '{{identifier}}'
-      scope: entity.name.member.indexed.c debug.member-variable-identifier-list
+      scope: entity.name.member.indexed.c
       push:
-        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: ','
-      scope: punctuation.separator.c debug.member-variable-identifier-list
+      scope: punctuation.separator.c
     - match: ';'
       scope: punctuation.terminator.c
       pop: true
@@ -637,7 +623,7 @@ contexts:
     - match: '\bstruct\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.struct.c debug.struct-keyword
+        - meta_scope: meta.struct.c
         - include: data-structures-definition-common-begin
         # struct definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
@@ -652,12 +638,11 @@ contexts:
           set: struct-body
         - include: or_pop
   struct-body:
-    - meta_content_scope: debug.struct-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.struct.body.c meta.block.c debug.struct-body.block
+        - meta_scope: meta.struct.body.c meta.block.c
         - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
@@ -669,7 +654,7 @@ contexts:
     - match: '\benum\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.enum.c debug.enum-keyword
+        - meta_scope: meta.enum.c
         - include: data-structures-definition-common-begin
         # enum definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
@@ -684,12 +669,11 @@ contexts:
           set: enum-body
         - include: or_pop
   enum-body:
-    - meta_content_scope: debug.enum-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.enum.c meta.block.c debug.data-structures-enum-definition
+        - meta_scope: meta.enum.c meta.block.c
         - include: comments
         - match: '\}'
           scope: meta.enum.c meta.block.c punctuation.section.block.end.c
@@ -698,12 +682,10 @@ contexts:
         - match: '{{identifier}}'
           scope: entity.name.constant.enum.c
           push:
-            - meta_scope: debug.data-structures-enum-definition.pre-assignment
             - include: comments
             - match: '='
               scope: keyword.operator.assignment.c
               set:
-                - meta_scope: debug.data-structures-enum-definition.post
                 - include: comments
                 # expressions gobbles up the , and } (which it shouldn't)
                 # so we need to match before so we break out of the scope
@@ -722,7 +704,7 @@ contexts:
     - match: '\bunion\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.union.c debug.union-keyword
+        - meta_scope: meta.union.c
         - include: data-structures-definition-common-begin
         # union definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
@@ -737,12 +719,11 @@ contexts:
           set: union-body
         - include: or_pop
   union-body:
-    - meta_content_scope: debug.union-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.union.body.c meta.block.c debug.union-body.block
+        - meta_scope: meta.union.body.c meta.block.c
         - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
@@ -773,8 +754,7 @@ contexts:
   data-structures-body-function-call:
     - match: (?={{identifier}}\s*\((?!\s*\*))
       push:
-        - - meta_scope: debug.data-structures-body-function-call.params
-          - include: function-call-params
+        - - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
             scope: constant.other.macro.c
@@ -782,13 +762,13 @@ contexts:
 
   block:
     - match: '\{'
-      scope: punctuation.section.block.begin.c debug.block.open-brace
+      scope: punctuation.section.block.begin.c
       push:
-        - meta_scope: meta.block.c debug.block
+        - meta_scope: meta.block.c
         - match: (?=^\s*#\s*(elif|else|endif)\b)
           pop: true
         - match: '\}'
-          scope: punctuation.section.block.end.c debug.block.close-brace
+          scope: punctuation.section.block.end.c
           pop: true
         - include: statements
 
@@ -876,7 +856,7 @@ contexts:
   keywords-parens:
     - match: '\b(sizeof)\b\s*(\()'
       captures:
-        1: keyword.operator.word.c debug.keywords-parens
+        1: keyword.operator.word.c
         2: meta.group.c punctuation.section.group.begin.c
       push:
         - meta_content_scope: meta.group.c
@@ -892,7 +872,6 @@ contexts:
         - typedef-identifier-list
         - type-declaration
   type-declaration:
-    - meta_scope: debug.type-declaration
     - include: comments
     - include: modifiers
     # Used for typedefing things defined in types.
@@ -909,26 +888,22 @@ contexts:
     # Make sure to pop when a data structure keyword is found
     - match: (?=\bstruct\b)
       set:
-        - meta_scope: debug.type-declaration.struct
         - include: struct-keyword
         - include: or_pop
     - match: (?=\benum\b)
       set:
-        - meta_scope: debug.type-declaration.enum
         - include: enum-keyword
         - include: or_pop
     - match: (?=\bunion\b)
       set:
-        - meta_scope: debug.type-declaration.union
         - include: union-keyword
         - include: or_pop
     - include: types
     - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
-        1: support.type.c debug.type-declaration.identifier
+        1: support.type.c
     - include: or_pop
   typedef-identifier-list:
-    - meta_scope: debug.typedef-identifier-list
     - include: comments
     - match: \*
       scope: storage.modifier.c
@@ -938,13 +913,13 @@ contexts:
     - match: '{{identifier}}(?=\s*,)'
       scope: entity.name.type.typedef.c
     - match: '{{identifier}}(?=\s*\[)'
-      scope: entity.name.type.typedef.c debug.typedef.array
+      scope: entity.name.type.typedef.c
       push:
         - include: declaration-brackets
         - include: or_pop
     # Function pointers
     - match: '\((?=\s*\*)'
-      scope: punctuation.section.group.begin.c debug.typedef.function-pointer
+      scope: punctuation.section.group.begin.c
       set:
         - meta_scope: meta.parens.c
         - match: \)
@@ -955,7 +930,7 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.type.c debug.typedef.function-pointer
+          scope: entity.name.type.c
         - include: or_pop
     - match: \,
       scope: punctuation.separator.c
@@ -988,7 +963,7 @@ contexts:
     - match: '\('
       scope: punctuation.section.group.begin.c
       set:
-        - meta_scope: meta.function-call.parameters.c meta.group.c debug.function-call.params
+        - meta_scope: meta.function-call.parameters.c meta.group.c
         - match : \)
           scope: punctuation.section.group.end.c
           pop: true
@@ -1135,7 +1110,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-global
+        - meta_scope: meta.preprocessor.c
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1160,7 +1135,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-global
     - match: \{
-      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-global
+      scope: punctuation.section.block.begin.c
       set: preprocessor-block-if-branch-global
     - include: preprocessor-global
     - include: negated-block
@@ -1266,7 +1241,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-statements
+        - meta_scope: meta.preprocessor.c
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1283,7 +1258,6 @@ contexts:
   # when the preprocessor is used to create different scope beginnings, such
   # as a different if/while condition
   preprocessor-if-branch-statements:
-    - meta_scope: debug.preprocessor-if-branch-statements
     - match: ^\s*(#\s*endif)\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
@@ -1291,7 +1265,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \{
-      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-statements.opening-brace
+      scope: punctuation.section.block.begin.c
       set: preprocessor-block-if-branch-statements
     - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\()
       set: preprocessor-if-branch-function-call
@@ -1299,7 +1273,7 @@ contexts:
     - include: statements
 
   preprocessor-if-branch-function-call:
-    - meta_content_scope: meta.function-call.c debug.preprocessor-if-branch-function-call
+    - meta_content_scope: meta.function-call.c
     - include: c99
     - match: '{{identifier}}'
       scope: variable.function.c
@@ -1308,7 +1282,7 @@ contexts:
       set: preprocessor-if-branch-function-call-arguments
 
   preprocessor-if-branch-function-call-arguments:
-    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments
+    - meta_content_scope: meta.function-call.c meta.group.c
     - match : \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       set: preprocessor-if-branch-statements
@@ -1323,33 +1297,33 @@ contexts:
     - include: expressions
 
   preprocessor-if-branch-function-call-arguments-finish:
-    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments-finish
+    - meta_content_scope: meta.function-call.c meta.group.c
     - match: \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       pop: true
     - include: expressions
 
   preprocessor-block-if-branch-statements:
-    - meta_scope: meta.block.c debug.preprocessor-block-if-branch-statements
+    - meta_scope: meta.block.c
     - match: ^\s*(#\s*endif)\b
       captures:
-        1: meta.preprocessor.c keyword.control.import.c debug.preprocessor-block-if-branch-statements.endif
+        1: meta.preprocessor.c keyword.control.import.c
       set: preprocessor-block-finish-statements
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c debug.preprocessor-block-if-branch-statements.closing-brace
+      scope: punctuation.section.block.end.c
       set: preprocessor-if-branch-statements
     - include: statements
 
   preprocessor-block-finish-statements:
-    - meta_scope: meta.block.c debug.preprocessor-block-finish-statements
+    - meta_scope: meta.block.c
     - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
       set: preprocessor-block-finish-if-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c debug.preprocessor-block-finish-statements.closing-brace
+      scope: punctuation.section.block.end.c
       pop: true
     - include: statements
 
@@ -1364,7 +1338,6 @@ contexts:
     - include: statements
 
   preprocessor-elif-else-branch-statements:
-    - meta_scope: debug.preprocessor-elif-else-branch-statements
     - match: (?=^\s*#\s*endif\b)
       pop: true
     - include: negated-block
@@ -1374,9 +1347,8 @@ contexts:
 
   negated-block:
     - match: '\}'
-      scope: punctuation.section.block.end.c debug.negated-block
+      scope: punctuation.section.block.end.c
       push:
-        - meta_scope: debug.negated-block.new-block
         - match: '\{'
           scope: punctuation.section.block.begin.c
           pop: true
@@ -1448,9 +1420,9 @@ contexts:
     - include: preprocessor-comments
     # Don't define blocks in define statements
     - match: '\{'
-      scope: punctuation.section.block.begin.c debug.preprocessor-macro-definition.begin-block
+      scope: punctuation.section.block.begin.c
     - match: '\}'
-      scope: punctuation.section.block.end.c debug.preprocessor-macro-definition.end-block
+      scope: punctuation.section.block.end.c
     - include: expressions
 
   preprocessor-practical-workarounds:
@@ -1459,13 +1431,13 @@ contexts:
 
   preprocessor-convention-ignore-uppercase-ident-lines:
     - match: ^(\s*{{macro_identifier}})+\s*$
-      scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-ident-lines
+      scope: meta.assumed-macro.c
       push:
         # It's possible that we are dealing with a function return type on its own line, and the
         # name of the function is on the subsequent line.
         - match: \s*({{identifier}})(?=\s*\()
           captures:
-            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines.params
+            1: meta.function.c entity.name.function.c
           set: function-definition-params
         - match: ^
           pop: true
@@ -1474,10 +1446,10 @@ contexts:
   preprocessor-convention-ignore-uppercase-calls-without-semicolon:
     - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$)
       captures:
-        1: variable.function.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
+        1: variable.function.assumed-macro.c
         2: punctuation.section.group.begin.c
       push:
-        - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
+        - meta_scope: meta.assumed-macro.c
         - match: \)
           scope: punctuation.section.group.end.c
           pop: true
@@ -1488,7 +1460,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c debug.preprocessor-other
+        - meta_scope: meta.preprocessor.c
         - meta_include_prototype: false
         - include: preprocessor-line-continuation
         - include: preprocessor-line-ending
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index a196968153..e2c89cd478 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1316,10 +1316,10 @@ static ssize_t function_with_params_on_newline
 /*         ^^^ variable.other.c */
 /*            ^ punctuation.section.group.end.c */
 {
-/* <- meta.block.c debug.block punctuation.section.block.begin.c */
+/* <- meta.block.c punctuation.section.block.begin.c */
   return 0;
 }
-/* <- meta.block.c debug.block punctuation.section.block.end.c */
+/* <- meta.block.c punctuation.section.block.end.c */
 
 
 static const struct pci_driver my_driver __pci_driver __driver = {

From 3fb815b4304d8d4866c8ddd0779c6651efc0176c Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 13 Dec 2019 16:42:12 -0700
Subject: [PATCH 51/55] Revert "Remove debug scopes"

This reverts commit 4da2d3bb643df54f98b146c8a62058d369099032.
---
 C++/C.sublime-syntax | 162 +++++++++++++++++++++++++------------------
 C++/syntax_test_c.c  |   4 +-
 2 files changed, 97 insertions(+), 69 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index fa1ec84dc4..4691256f88 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -128,7 +128,7 @@ contexts:
     - match: \b({{control_keywords}})\b
       scope: keyword.control.c
     - match: \bsizeof\b
-      scope: keyword.operator.word.c
+      scope: keyword.operator.word.c debug.keywords
 
   modifiers:
     - match: \b({{modifiers}})\b
@@ -157,15 +157,15 @@ contexts:
             \)
           )
         )
-      scope: constant.other.macro.c
+      scope: constant.other.macro.c debug.modifiers-macros
       push:
         - meta_scope: meta.function-call.c
         - include: function-call-params
     # Preprocessor Attributes
     - match: '{{attr_macro_identifier}}(?!\s*\()'
-      scope: constant.other.macro.c
+      scope: constant.other.macro.c debug.modifiers-macros.underscore
     - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*|\)|\s*\n)'
-      scope: constant.other.macro.c
+      scope: constant.other.macro.c debug.modifiers-macros.caps
 
   variables:
     - match: '\bg[A-Z]\w*\b'
@@ -287,7 +287,7 @@ contexts:
   # comment without a line continuation ends at the newline.
   preprocessor-comments:
     - match: /\*
-      scope: punctuation.definition.comment.c
+      scope: punctuation.definition.comment.c debug.preprocessor-comments
       push:
         - meta_scope: comment.block.c
         - match: '\\$\n'
@@ -296,7 +296,7 @@ contexts:
           scope: punctuation.definition.comment.c
           pop: true
     - match: //
-      scope: punctuation.definition.comment.c
+      scope: punctuation.definition.comment.c debug.preprocessor-comments
       push:
         - meta_scope: comment.line.double-slash.c
         - match: '(\\)$\n'
@@ -328,6 +328,7 @@ contexts:
     - include: early-expressions
     - match: '(?=\w+)'
       push:
+        - meta_scope: debug.global.token
         - include: comments
         - include: modifiers-parens
         - include: modifiers
@@ -392,9 +393,10 @@ contexts:
   global-function-call:
     - match: (?={{identifier}}\s*\((?!\s*\*))
       set:
-        - - include: comments
+        - - meta_scope: debug.global-function-call.type-or-terminator
+          - include: comments
           - match: ';'
-            scope: punctuation.terminator.c
+            scope: punctuation.terminator.c debug.global-function-call
             pop: true
           - match: \n
             comments: Macro invocations sometimes don't require a ; to terminate
@@ -404,7 +406,8 @@ contexts:
             pop: true
           - match: '(?=\S)'
             set: global-declaration
-        - - include: function-call-params
+        - - meta_scope: debug.global-function-call.params
+          - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
             scope: constant.other.macro.c
@@ -417,7 +420,7 @@ contexts:
         - type-declaration
 
   function-definition-params:
-    - meta_content_scope: meta.function.c
+    - meta_content_scope: meta.function.c debug.function-definition-params
     - include: comments
     - match: '(?=\()'
       set:
@@ -443,6 +446,7 @@ contexts:
             - type-declaration
 
   parameter-identifier:
+    - meta_scope: debug.parameter-identifier
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -451,7 +455,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration
     - match: \(
-      scope: punctuation.section.group.begin.c
+      scope: punctuation.section.group.begin.c debug.parameter-identifier.function-pointer
       push:
         - meta_scope: meta.group.c
         - match: \)
@@ -462,10 +466,11 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.parameter.c
+          scope: variable.parameter.c debug.parameter-identifier.function-pointer
     - match: '{{identifier}}'
-      scope: variable.parameter.c
+      scope: variable.parameter.c debug.parameter-identifier
       push:
+        - meta_scope: debug.parameter-identifier.array-or-assignment
         - include: declaration-brackets
         - include: or_pop
     - include: or_pop
@@ -485,7 +490,7 @@ contexts:
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.function.c meta.block.c
+        - meta_scope: meta.function.c meta.block.c debug.function-definition-body
         - match: '\}'
           scope: punctuation.section.block.end.c
           pop: true
@@ -507,7 +512,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration as variable
     - match: \(
-      scope: punctuation.section.group.begin.c
+      scope: punctuation.section.group.begin.c debug.parameter-variable-identifier.function-pointer
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -518,11 +523,12 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.parameter.c
+          scope: variable.parameter.c debug.parameter-variable-identifier.function-pointer
     - match: '{{identifier}}'
-      scope: variable.parameter.c
+      scope: variable.parameter.c debug.parameter-variable-identifier
 
   variable-identifier-list:
+    - meta_scope: debug.variable-identifier-list
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -530,25 +536,28 @@ contexts:
     - match: \*
       scope: storage.modifier.c
     - match: '{{identifier}}(?=\s*\(|\s*\n)'
-      scope: meta.function.c entity.name.function.c
+      scope: meta.function.c entity.name.function.c debug.variable-identifier-list.function
       set:
-        - - include: comments
+        - - meta_scope: debug.variable-identifier-list.function-body
+          - include: comments
           - include: function-definition-body
           - match: '(?=\S)'
             set: variable-identifier-list
-        - - include: comments
+        - - meta_scope: debug.variable-identifier-list.function-modifiers
+          - include: comments
           - include: modifiers-parens
           # Macro invocations
           - include: function-call-c
           - match: '{{identifier}}'
-            scope: constant.other.macro.c
+            scope: constant.other.macro.c debug.variable-identifier-list.function-attribute
           - include: or_pop
-        - - include: comments
+        - - meta_scope: debug.variable-identifier-list.function-params
+          - include: comments
           - include: function-definition-params-group
           - include: or_pop
     # Function pointer declaration
     - match: \((?=\s*\*)
-      scope: punctuation.section.group.begin.c
+      scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -559,27 +568,30 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.variable.indexed.c
+          scope: entity.name.variable.indexed.c debug.variable-identifier-list.function-pointer
     - match: '{{identifier}}'
-      scope: entity.name.variable.indexed.c
+      scope: entity.name.variable.indexed.c debug.variable-identifier-list
       push:
+        - meta_scope: debug.variable-identifier-list.array-or-assignment
         - include: declaration-brackets
         - match: \=
           scope: keyword.operator.assignment.c
           set:
+            - meta_scope: debug.variable-identifier-list.assignment
             - match: '(?=,|;)'
               pop: true
             - include: expressions
             - include: or_pop
         - include: or_pop
     - match: ','
-      scope: punctuation.separator.c
+      scope: punctuation.separator.c debug.variable-identifier-list
     - match: ';'
       scope: punctuation.terminator.c
       pop: true
     - include: or_pop
 
   member-variable-identifier-list:
+    - meta_scope: debug.member-variable-identifier-list
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -588,7 +600,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration
     - match: \(
-      scope: punctuation.section.group.begin.c
+      scope: punctuation.section.group.begin.c debug.member-variable-identifier-list.function-pointer
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -599,21 +611,23 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.member.indexed.c
+          scope: entity.name.member.indexed.c debug.member-variable-identifier-list.function-pointer
     # 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
+      scope: entity.name.member.c debug.member-variable-identifier-list
       push:
+        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: '{{identifier}}'
-      scope: entity.name.member.indexed.c
+      scope: entity.name.member.indexed.c debug.member-variable-identifier-list
       push:
+        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: ','
-      scope: punctuation.separator.c
+      scope: punctuation.separator.c debug.member-variable-identifier-list
     - match: ';'
       scope: punctuation.terminator.c
       pop: true
@@ -623,7 +637,7 @@ contexts:
     - match: '\bstruct\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.struct.c
+        - meta_scope: meta.struct.c debug.struct-keyword
         - include: data-structures-definition-common-begin
         # struct definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
@@ -638,11 +652,12 @@ contexts:
           set: struct-body
         - include: or_pop
   struct-body:
+    - meta_content_scope: debug.struct-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.struct.body.c meta.block.c
+        - meta_scope: meta.struct.body.c meta.block.c debug.struct-body.block
         - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
@@ -654,7 +669,7 @@ contexts:
     - match: '\benum\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.enum.c
+        - meta_scope: meta.enum.c debug.enum-keyword
         - include: data-structures-definition-common-begin
         # enum definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
@@ -669,11 +684,12 @@ contexts:
           set: enum-body
         - include: or_pop
   enum-body:
+    - meta_content_scope: debug.enum-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.enum.c meta.block.c
+        - meta_scope: meta.enum.c meta.block.c debug.data-structures-enum-definition
         - include: comments
         - match: '\}'
           scope: meta.enum.c meta.block.c punctuation.section.block.end.c
@@ -682,10 +698,12 @@ contexts:
         - match: '{{identifier}}'
           scope: entity.name.constant.enum.c
           push:
+            - meta_scope: debug.data-structures-enum-definition.pre-assignment
             - include: comments
             - match: '='
               scope: keyword.operator.assignment.c
               set:
+                - meta_scope: debug.data-structures-enum-definition.post
                 - include: comments
                 # expressions gobbles up the , and } (which it shouldn't)
                 # so we need to match before so we break out of the scope
@@ -704,7 +722,7 @@ contexts:
     - match: '\bunion\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.union.c
+        - meta_scope: meta.union.c debug.union-keyword
         - include: data-structures-definition-common-begin
         # union definition
         - match: '{{identifier}}(?=\s*{|\s*\n)'
@@ -719,11 +737,12 @@ contexts:
           set: union-body
         - include: or_pop
   union-body:
+    - meta_content_scope: debug.union-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.union.body.c meta.block.c
+        - meta_scope: meta.union.body.c meta.block.c debug.union-body.block
         - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
@@ -754,7 +773,8 @@ contexts:
   data-structures-body-function-call:
     - match: (?={{identifier}}\s*\((?!\s*\*))
       push:
-        - - include: function-call-params
+        - - meta_scope: debug.data-structures-body-function-call.params
+          - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
             scope: constant.other.macro.c
@@ -762,13 +782,13 @@ contexts:
 
   block:
     - match: '\{'
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.block.open-brace
       push:
-        - meta_scope: meta.block.c
+        - meta_scope: meta.block.c debug.block
         - match: (?=^\s*#\s*(elif|else|endif)\b)
           pop: true
         - match: '\}'
-          scope: punctuation.section.block.end.c
+          scope: punctuation.section.block.end.c debug.block.close-brace
           pop: true
         - include: statements
 
@@ -856,7 +876,7 @@ contexts:
   keywords-parens:
     - match: '\b(sizeof)\b\s*(\()'
       captures:
-        1: keyword.operator.word.c
+        1: keyword.operator.word.c debug.keywords-parens
         2: meta.group.c punctuation.section.group.begin.c
       push:
         - meta_content_scope: meta.group.c
@@ -872,6 +892,7 @@ contexts:
         - typedef-identifier-list
         - type-declaration
   type-declaration:
+    - meta_scope: debug.type-declaration
     - include: comments
     - include: modifiers
     # Used for typedefing things defined in types.
@@ -888,22 +909,26 @@ contexts:
     # Make sure to pop when a data structure keyword is found
     - match: (?=\bstruct\b)
       set:
+        - meta_scope: debug.type-declaration.struct
         - include: struct-keyword
         - include: or_pop
     - match: (?=\benum\b)
       set:
+        - meta_scope: debug.type-declaration.enum
         - include: enum-keyword
         - include: or_pop
     - match: (?=\bunion\b)
       set:
+        - meta_scope: debug.type-declaration.union
         - include: union-keyword
         - include: or_pop
     - include: types
     - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
-        1: support.type.c
+        1: support.type.c debug.type-declaration.identifier
     - include: or_pop
   typedef-identifier-list:
+    - meta_scope: debug.typedef-identifier-list
     - include: comments
     - match: \*
       scope: storage.modifier.c
@@ -913,13 +938,13 @@ contexts:
     - match: '{{identifier}}(?=\s*,)'
       scope: entity.name.type.typedef.c
     - match: '{{identifier}}(?=\s*\[)'
-      scope: entity.name.type.typedef.c
+      scope: entity.name.type.typedef.c debug.typedef.array
       push:
         - include: declaration-brackets
         - include: or_pop
     # Function pointers
     - match: '\((?=\s*\*)'
-      scope: punctuation.section.group.begin.c
+      scope: punctuation.section.group.begin.c debug.typedef.function-pointer
       set:
         - meta_scope: meta.parens.c
         - match: \)
@@ -930,7 +955,7 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.type.c
+          scope: entity.name.type.c debug.typedef.function-pointer
         - include: or_pop
     - match: \,
       scope: punctuation.separator.c
@@ -963,7 +988,7 @@ contexts:
     - match: '\('
       scope: punctuation.section.group.begin.c
       set:
-        - meta_scope: meta.function-call.parameters.c meta.group.c
+        - meta_scope: meta.function-call.parameters.c meta.group.c debug.function-call.params
         - match : \)
           scope: punctuation.section.group.end.c
           pop: true
@@ -1110,7 +1135,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c
+        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-global
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1135,7 +1160,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-global
     - match: \{
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-global
       set: preprocessor-block-if-branch-global
     - include: preprocessor-global
     - include: negated-block
@@ -1241,7 +1266,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c
+        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-statements
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1258,6 +1283,7 @@ contexts:
   # when the preprocessor is used to create different scope beginnings, such
   # as a different if/while condition
   preprocessor-if-branch-statements:
+    - meta_scope: debug.preprocessor-if-branch-statements
     - match: ^\s*(#\s*endif)\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
@@ -1265,7 +1291,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \{
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-statements.opening-brace
       set: preprocessor-block-if-branch-statements
     - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\()
       set: preprocessor-if-branch-function-call
@@ -1273,7 +1299,7 @@ contexts:
     - include: statements
 
   preprocessor-if-branch-function-call:
-    - meta_content_scope: meta.function-call.c
+    - meta_content_scope: meta.function-call.c debug.preprocessor-if-branch-function-call
     - include: c99
     - match: '{{identifier}}'
       scope: variable.function.c
@@ -1282,7 +1308,7 @@ contexts:
       set: preprocessor-if-branch-function-call-arguments
 
   preprocessor-if-branch-function-call-arguments:
-    - meta_content_scope: meta.function-call.c meta.group.c
+    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments
     - match : \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       set: preprocessor-if-branch-statements
@@ -1297,33 +1323,33 @@ contexts:
     - include: expressions
 
   preprocessor-if-branch-function-call-arguments-finish:
-    - meta_content_scope: meta.function-call.c meta.group.c
+    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments-finish
     - match: \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       pop: true
     - include: expressions
 
   preprocessor-block-if-branch-statements:
-    - meta_scope: meta.block.c
+    - meta_scope: meta.block.c debug.preprocessor-block-if-branch-statements
     - match: ^\s*(#\s*endif)\b
       captures:
-        1: meta.preprocessor.c keyword.control.import.c
+        1: meta.preprocessor.c keyword.control.import.c debug.preprocessor-block-if-branch-statements.endif
       set: preprocessor-block-finish-statements
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.preprocessor-block-if-branch-statements.closing-brace
       set: preprocessor-if-branch-statements
     - include: statements
 
   preprocessor-block-finish-statements:
-    - meta_scope: meta.block.c
+    - meta_scope: meta.block.c debug.preprocessor-block-finish-statements
     - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
       set: preprocessor-block-finish-if-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.preprocessor-block-finish-statements.closing-brace
       pop: true
     - include: statements
 
@@ -1338,6 +1364,7 @@ contexts:
     - include: statements
 
   preprocessor-elif-else-branch-statements:
+    - meta_scope: debug.preprocessor-elif-else-branch-statements
     - match: (?=^\s*#\s*endif\b)
       pop: true
     - include: negated-block
@@ -1347,8 +1374,9 @@ contexts:
 
   negated-block:
     - match: '\}'
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.negated-block
       push:
+        - meta_scope: debug.negated-block.new-block
         - match: '\{'
           scope: punctuation.section.block.begin.c
           pop: true
@@ -1420,9 +1448,9 @@ contexts:
     - include: preprocessor-comments
     # Don't define blocks in define statements
     - match: '\{'
-      scope: punctuation.section.block.begin.c
+      scope: punctuation.section.block.begin.c debug.preprocessor-macro-definition.begin-block
     - match: '\}'
-      scope: punctuation.section.block.end.c
+      scope: punctuation.section.block.end.c debug.preprocessor-macro-definition.end-block
     - include: expressions
 
   preprocessor-practical-workarounds:
@@ -1431,13 +1459,13 @@ contexts:
 
   preprocessor-convention-ignore-uppercase-ident-lines:
     - match: ^(\s*{{macro_identifier}})+\s*$
-      scope: meta.assumed-macro.c
+      scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-ident-lines
       push:
         # It's possible that we are dealing with a function return type on its own line, and the
         # name of the function is on the subsequent line.
         - match: \s*({{identifier}})(?=\s*\()
           captures:
-            1: meta.function.c entity.name.function.c
+            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines.params
           set: function-definition-params
         - match: ^
           pop: true
@@ -1446,10 +1474,10 @@ contexts:
   preprocessor-convention-ignore-uppercase-calls-without-semicolon:
     - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$)
       captures:
-        1: variable.function.assumed-macro.c
+        1: variable.function.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
         2: punctuation.section.group.begin.c
       push:
-        - meta_scope: meta.assumed-macro.c
+        - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
         - match: \)
           scope: punctuation.section.group.end.c
           pop: true
@@ -1460,7 +1488,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c
+        - meta_scope: meta.preprocessor.c debug.preprocessor-other
         - meta_include_prototype: false
         - include: preprocessor-line-continuation
         - include: preprocessor-line-ending
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index e2c89cd478..a196968153 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -1316,10 +1316,10 @@ static ssize_t function_with_params_on_newline
 /*         ^^^ variable.other.c */
 /*            ^ punctuation.section.group.end.c */
 {
-/* <- meta.block.c punctuation.section.block.begin.c */
+/* <- meta.block.c debug.block punctuation.section.block.begin.c */
   return 0;
 }
-/* <- meta.block.c punctuation.section.block.end.c */
+/* <- meta.block.c debug.block punctuation.section.block.end.c */
 
 
 static const struct pci_driver my_driver __pci_driver __driver = {

From d4329e825b018b595c1992ab95f5cd8203eef33e Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 13 Dec 2019 16:58:13 -0700
Subject: [PATCH 52/55] Cherry pick b94f72a6

b94f72a6 [C/ObjC] Fix: be more lenient about macro identifiers with enum return types (#1718)

Makes the merge easier

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax |  9 +++++++++
 C++/syntax_test_c.c  | 42 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 4691256f88..2af16bcd5c 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -639,6 +639,9 @@ contexts:
       push:
         - meta_scope: meta.struct.c debug.struct-keyword
         - 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
@@ -671,6 +674,9 @@ contexts:
       push:
         - meta_scope: meta.enum.c debug.enum-keyword
         - 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
@@ -724,6 +730,9 @@ contexts:
       push:
         - meta_scope: meta.union.c debug.union-keyword
         - 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
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index a196968153..3015e49639 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -9,6 +9,44 @@ int main(){
     /*          ^^ keyword.operator.arithmetic */
 }
 
+enum Foo { kFoo, kBar };
+#define FOO Foo
+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; };
+/*                          ^ entity.name.function */
+/*                                            ^ storage.type */
+
+struct __declspec(dllimport) X {};
+/*     ^ storage.modifier */
+/*                           ^ entity.name.struct */
+
+struct foo {
+/*     ^ entity.name.struct */
+    union {
+/*  ^ storage.type */
+        struct {
+/*      ^ storage.type */
+            int a;
+/*          ^ storage.type */
+            int b;
+/*          ^ storage.type */
+        }
+    }
+};
+
 #define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS /* comment block */ * sizeof(struct ptp_extts_event)) // comment line
 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */
 /*                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */
@@ -1316,10 +1354,10 @@ static ssize_t function_with_params_on_newline
 /*         ^^^ variable.other.c */
 /*            ^ punctuation.section.group.end.c */
 {
-/* <- meta.block.c debug.block punctuation.section.block.begin.c */
+/* <- meta.block.c punctuation.section.block.begin.c */
   return 0;
 }
-/* <- meta.block.c debug.block punctuation.section.block.end.c */
+/* <- meta.block.c punctuation.section.block.end.c */
 
 
 static const struct pci_driver my_driver __pci_driver __driver = {

From 8fa29863d1e49164f95b482223497513f8122d09 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Mon, 16 Dec 2019 10:12:13 -0700
Subject: [PATCH 53/55] cherry-pick 561df1cafe96965deed25bcdaece7feeef275919

To make merging easier

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 3 +++
 C++/syntax_test_c.c  | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index 2af16bcd5c..859b0f3e7d 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -56,6 +56,9 @@ contexts:
         - match: \*/
           scope: punctuation.definition.comment.c
           pop: true
+        - match: ^\s*(\*)(?!/)
+          captures:
+            1: punctuation.definition.comment.c
     - match: \*/(?!\*)
       scope: invalid.illegal.stray-comment-end.c
     - match: ^// =(\s*.*?)\s*=\s*$\n?
diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c
index 3015e49639..27707f701a 100644
--- a/C++/syntax_test_c.c
+++ b/C++/syntax_test_c.c
@@ -299,6 +299,10 @@ struct X
 /* <- meta.struct.body.c meta.block.c punctuation.section.block.end.c */
  /* <- punctuation.terminator.c - meta.struct.body.c - meta.block.c*/
 
+/**
+    *
+/*  ^ comment.block.c punctuation.definition.comment.c */
+
 /////////////////////////////////////////////
 // Preprocessor branches starting blocks
 /////////////////////////////////////////////

From f5009616c027a076da8051341bd6801824e40f0a Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Tue, 29 Oct 2019 10:18:04 -0600
Subject: [PATCH 54/55] Remove debug scopes

These are very helpful when debugging the syntax. If you run into
problems, revert this so you know what the context chain looks like.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/C.sublime-syntax | 162 ++++++++++++++++++-------------------------
 1 file changed, 67 insertions(+), 95 deletions(-)

diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax
index b6f96819a4..a8b347c73e 100644
--- a/C++/C.sublime-syntax
+++ b/C++/C.sublime-syntax
@@ -140,7 +140,7 @@ contexts:
     - match: \b({{control_keywords}})\b
       scope: keyword.control.c
     - match: \bsizeof\b
-      scope: keyword.operator.word.c debug.keywords
+      scope: keyword.operator.word.c
 
   modifiers:
     - match: \b({{modifiers}})\b
@@ -169,15 +169,15 @@ contexts:
             \)
           )
         )
-      scope: constant.other.macro.c debug.modifiers-macros
+      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 debug.modifiers-macros.underscore
+      scope: constant.other.macro.c
     - match: '{{macro_identifier}}(?=\s{{identifier}}|\s\*|\)|\s*\n)'
-      scope: constant.other.macro.c debug.modifiers-macros.caps
+      scope: constant.other.macro.c
 
   variables:
     - match: '\bg[A-Z]\w*\b'
@@ -371,7 +371,7 @@ contexts:
   # comment without a line continuation ends at the newline.
   preprocessor-comments:
     - match: /\*
-      scope: punctuation.definition.comment.c debug.preprocessor-comments
+      scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.block.c
         - match: '\\$\n'
@@ -380,7 +380,7 @@ contexts:
           scope: punctuation.definition.comment.c
           pop: true
     - match: //
-      scope: punctuation.definition.comment.c debug.preprocessor-comments
+      scope: punctuation.definition.comment.c
       push:
         - meta_scope: comment.line.double-slash.c
         - match: '(\\)$\n'
@@ -412,7 +412,6 @@ contexts:
     - include: early-expressions
     - match: '(?=\w+)'
       push:
-        - meta_scope: debug.global.token
         - include: comments
         - include: modifiers-parens
         - include: modifiers
@@ -477,10 +476,9 @@ contexts:
   global-function-call:
     - match: (?={{identifier}}\s*\((?!\s*\*))
       set:
-        - - meta_scope: debug.global-function-call.type-or-terminator
-          - include: comments
+        - - include: comments
           - match: ';'
-            scope: punctuation.terminator.c debug.global-function-call
+            scope: punctuation.terminator.c
             pop: true
           - match: \n
             comments: Macro invocations sometimes don't require a ; to terminate
@@ -490,8 +488,7 @@ contexts:
             pop: true
           - match: '(?=\S)'
             set: global-declaration
-        - - meta_scope: debug.global-function-call.params
-          - include: function-call-params
+        - - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
             scope: constant.other.macro.c
@@ -504,7 +501,7 @@ contexts:
         - type-declaration
 
   function-definition-params:
-    - meta_content_scope: meta.function.c debug.function-definition-params
+    - meta_content_scope: meta.function.c
     - include: comments
     - match: '(?=\()'
       set:
@@ -530,7 +527,6 @@ contexts:
             - type-declaration
 
   parameter-identifier:
-    - meta_scope: debug.parameter-identifier
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -539,7 +535,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration
     - match: \(
-      scope: punctuation.section.group.begin.c debug.parameter-identifier.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.group.c
         - match: \)
@@ -550,11 +546,10 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.parameter.c debug.parameter-identifier.function-pointer
+          scope: variable.parameter.c
     - match: '{{identifier}}'
-      scope: variable.parameter.c debug.parameter-identifier
+      scope: variable.parameter.c
       push:
-        - meta_scope: debug.parameter-identifier.array-or-assignment
         - include: declaration-brackets
         - include: or_pop
     - include: or_pop
@@ -574,7 +569,7 @@ contexts:
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.function.c meta.block.c debug.function-definition-body
+        - meta_scope: meta.function.c meta.block.c
         - match: '\}'
           scope: punctuation.section.block.end.c
           pop: true
@@ -596,7 +591,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration as variable
     - match: \(
-      scope: punctuation.section.group.begin.c debug.parameter-variable-identifier.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -607,12 +602,11 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: variable.parameter.c debug.parameter-variable-identifier.function-pointer
+          scope: variable.parameter.c
     - match: '{{identifier}}'
-      scope: variable.parameter.c debug.parameter-variable-identifier
+      scope: variable.parameter.c
 
   variable-identifier-list:
-    - meta_scope: debug.variable-identifier-list
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -620,28 +614,25 @@ contexts:
     - match: \*
       scope: storage.modifier.c
     - match: '{{identifier}}(?=\s*\(|\s*\n)'
-      scope: meta.function.c entity.name.function.c debug.variable-identifier-list.function
+      scope: meta.function.c entity.name.function.c
       set:
-        - - meta_scope: debug.variable-identifier-list.function-body
-          - include: comments
+        - - include: comments
           - include: function-definition-body
           - match: '(?=\S)'
             set: variable-identifier-list
-        - - meta_scope: debug.variable-identifier-list.function-modifiers
-          - include: comments
+        - - include: comments
           - include: modifiers-parens
           # Macro invocations
           - include: function-call-c
           - match: '{{identifier}}'
-            scope: constant.other.macro.c debug.variable-identifier-list.function-attribute
+            scope: constant.other.macro.c
           - include: or_pop
-        - - meta_scope: debug.variable-identifier-list.function-params
-          - include: comments
+        - - include: comments
           - include: function-definition-params-group
           - include: or_pop
     # Function pointer declaration
     - match: \((?=\s*\*)
-      scope: punctuation.section.group.begin.c debug.variable-identifier-list.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -652,30 +643,27 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.variable.indexed.c debug.variable-identifier-list.function-pointer
+          scope: entity.name.variable.indexed.c
     - match: '{{identifier}}'
-      scope: entity.name.variable.indexed.c debug.variable-identifier-list
+      scope: entity.name.variable.indexed.c
       push:
-        - meta_scope: debug.variable-identifier-list.array-or-assignment
         - include: declaration-brackets
         - match: \=
           scope: keyword.operator.assignment.c
           set:
-            - meta_scope: debug.variable-identifier-list.assignment
             - match: '(?=,|;)'
               pop: true
             - include: expressions
             - include: or_pop
         - include: or_pop
     - match: ','
-      scope: punctuation.separator.c debug.variable-identifier-list
+      scope: punctuation.separator.c
     - match: ';'
       scope: punctuation.terminator.c
       pop: true
     - include: or_pop
 
   member-variable-identifier-list:
-    - meta_scope: debug.member-variable-identifier-list
     - include: comments
     - include: modifiers
     - include: modifiers-parens
@@ -684,7 +672,7 @@ contexts:
       scope: storage.modifier.c
     # Function pointer declaration
     - match: \(
-      scope: punctuation.section.group.begin.c debug.member-variable-identifier-list.function-pointer
+      scope: punctuation.section.group.begin.c
       push:
         - meta_scope: meta.parens.c
         - match: \)
@@ -695,23 +683,21 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.member.indexed.c debug.member-variable-identifier-list.function-pointer
+          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 debug.member-variable-identifier-list
+      scope: entity.name.member.c
       push:
-        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: '{{identifier}}'
-      scope: entity.name.member.indexed.c debug.member-variable-identifier-list
+      scope: entity.name.member.indexed.c
       push:
-        - meta_scope: debug.member-variable-identifier-list.array
         - include: declaration-brackets
         - include: or_pop
     - match: ','
-      scope: punctuation.separator.c debug.member-variable-identifier-list
+      scope: punctuation.separator.c
     - match: ';'
       scope: punctuation.terminator.c
       pop: true
@@ -721,7 +707,7 @@ contexts:
     - match: '\bstruct\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.struct.c debug.struct-keyword
+        - meta_scope: meta.struct.c
         - include: data-structures-definition-common-begin
         # function name
         - match: '(?={{identifier}}\s*\()'
@@ -739,12 +725,11 @@ contexts:
           set: struct-body
         - include: or_pop
   struct-body:
-    - meta_content_scope: debug.struct-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.struct.body.c meta.block.c debug.struct-body.block
+        - meta_scope: meta.struct.body.c meta.block.c
         - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
@@ -756,7 +741,7 @@ contexts:
     - match: '\benum\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.enum.c debug.enum-keyword
+        - meta_scope: meta.enum.c
         - include: data-structures-definition-common-begin
         # function name
         - match: '(?={{identifier}}\s*\()'
@@ -774,12 +759,11 @@ contexts:
           set: enum-body
         - include: or_pop
   enum-body:
-    - meta_content_scope: debug.enum-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.enum.c meta.block.c debug.data-structures-enum-definition
+        - meta_scope: meta.enum.c meta.block.c
         - include: comments
         - match: '\}'
           scope: meta.enum.c meta.block.c punctuation.section.block.end.c
@@ -788,12 +772,10 @@ contexts:
         - match: '{{identifier}}'
           scope: entity.name.constant.enum.c
           push:
-            - meta_scope: debug.data-structures-enum-definition.pre-assignment
             - include: comments
             - match: '='
               scope: keyword.operator.assignment.c
               set:
-                - meta_scope: debug.data-structures-enum-definition.post
                 - include: comments
                 # expressions gobbles up the , and } (which it shouldn't)
                 # so we need to match before so we break out of the scope
@@ -812,7 +794,7 @@ contexts:
     - match: '\bunion\b'
       scope: storage.type.c
       push:
-        - meta_scope: meta.union.c debug.union-keyword
+        - meta_scope: meta.union.c
         - include: data-structures-definition-common-begin
         # function name
         - match: '(?={{identifier}}\s*\()'
@@ -830,12 +812,11 @@ contexts:
           set: union-body
         - include: or_pop
   union-body:
-    - meta_content_scope: debug.union-body
     - include: comments
     - match: '\{'
       scope: punctuation.section.block.begin.c
       set:
-        - meta_scope: meta.union.body.c meta.block.c debug.union-body.block
+        - meta_scope: meta.union.body.c meta.block.c
         - include: comments
         - match: '\}'
           scope: punctuation.section.block.end.c
@@ -866,8 +847,7 @@ contexts:
   data-structures-body-function-call:
     - match: (?={{identifier}}\s*\((?!\s*\*))
       push:
-        - - meta_scope: debug.data-structures-body-function-call.params
-          - include: function-call-params
+        - - include: function-call-params
         - - meta_scope: meta.function-call.c
           - match: '{{identifier}}'
             scope: constant.other.macro.c
@@ -875,13 +855,13 @@ contexts:
 
   block:
     - match: '\{'
-      scope: punctuation.section.block.begin.c debug.block.open-brace
+      scope: punctuation.section.block.begin.c
       push:
-        - meta_scope: meta.block.c debug.block
+        - meta_scope: meta.block.c
         - match: (?=^\s*#\s*(elif|else|endif)\b)
           pop: true
         - match: '\}'
-          scope: punctuation.section.block.end.c debug.block.close-brace
+          scope: punctuation.section.block.end.c
           pop: true
         - include: statements
 
@@ -969,7 +949,7 @@ contexts:
   keywords-parens:
     - match: '\b(sizeof)\b\s*(\()'
       captures:
-        1: keyword.operator.word.c debug.keywords-parens
+        1: keyword.operator.word.c
         2: meta.group.c punctuation.section.group.begin.c
       push:
         - meta_content_scope: meta.group.c
@@ -985,7 +965,6 @@ contexts:
         - typedef-identifier-list
         - type-declaration
   type-declaration:
-    - meta_scope: debug.type-declaration
     - include: comments
     - include: modifiers
     # Used for typedefing things defined in types.
@@ -1002,26 +981,22 @@ contexts:
     # Make sure to pop when a data structure keyword is found
     - match: (?=\bstruct\b)
       set:
-        - meta_scope: debug.type-declaration.struct
         - include: struct-keyword
         - include: or_pop
     - match: (?=\benum\b)
       set:
-        - meta_scope: debug.type-declaration.enum
         - include: enum-keyword
         - include: or_pop
     - match: (?=\bunion\b)
       set:
-        - meta_scope: debug.type-declaration.union
         - include: union-keyword
         - include: or_pop
     - include: types
     - match: ({{identifier}})\s*(?={{identifier}}|\(\*|\n|\*)
       captures:
-        1: support.type.c debug.type-declaration.identifier
+        1: support.type.c
     - include: or_pop
   typedef-identifier-list:
-    - meta_scope: debug.typedef-identifier-list
     - include: comments
     - match: \*
       scope: storage.modifier.c
@@ -1031,13 +1006,13 @@ contexts:
     - match: '{{identifier}}(?=\s*,)'
       scope: entity.name.type.typedef.c
     - match: '{{identifier}}(?=\s*\[)'
-      scope: entity.name.type.typedef.c debug.typedef.array
+      scope: entity.name.type.typedef.c
       push:
         - include: declaration-brackets
         - include: or_pop
     # Function pointers
     - match: '\((?=\s*\*)'
-      scope: punctuation.section.group.begin.c debug.typedef.function-pointer
+      scope: punctuation.section.group.begin.c
       set:
         - meta_scope: meta.parens.c
         - match: \)
@@ -1048,7 +1023,7 @@ contexts:
         - match: \*
           scope: storage.modifier.c
         - match: '{{identifier}}'
-          scope: entity.name.type.c debug.typedef.function-pointer
+          scope: entity.name.type.c
         - include: or_pop
     - match: \,
       scope: punctuation.separator.c
@@ -1081,7 +1056,7 @@ contexts:
     - match: '\('
       scope: punctuation.section.group.begin.c
       set:
-        - meta_scope: meta.function-call.parameters.c meta.group.c debug.function-call.params
+        - meta_scope: meta.function-call.parameters.c meta.group.c
         - match : \)
           scope: punctuation.section.group.end.c
           pop: true
@@ -1228,7 +1203,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-global
+        - meta_scope: meta.preprocessor.c
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1253,7 +1228,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-global
     - match: \{
-      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-global
+      scope: punctuation.section.block.begin.c
       set: preprocessor-block-if-branch-global
     - include: preprocessor-global
     - include: negated-block
@@ -1359,7 +1334,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c debug.preprocessor-rule-other-statements
+        - meta_scope: meta.preprocessor.c
         - include: preprocessor-line-continuation
         - include: preprocessor-comments
         - match: \bdefined\b
@@ -1376,7 +1351,6 @@ contexts:
   # when the preprocessor is used to create different scope beginnings, such
   # as a different if/while condition
   preprocessor-if-branch-statements:
-    - meta_scope: debug.preprocessor-if-branch-statements
     - match: ^\s*(#\s*endif)\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
@@ -1384,7 +1358,7 @@ contexts:
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \{
-      scope: punctuation.section.block.begin.c debug.preprocessor-if-branch-statements.opening-brace
+      scope: punctuation.section.block.begin.c
       set: preprocessor-block-if-branch-statements
     - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\()
       set: preprocessor-if-branch-function-call
@@ -1392,7 +1366,7 @@ contexts:
     - include: statements
 
   preprocessor-if-branch-function-call:
-    - meta_content_scope: meta.function-call.c debug.preprocessor-if-branch-function-call
+    - meta_content_scope: meta.function-call.c
     - include: c99
     - match: '{{identifier}}'
       scope: variable.function.c
@@ -1401,7 +1375,7 @@ contexts:
       set: preprocessor-if-branch-function-call-arguments
 
   preprocessor-if-branch-function-call-arguments:
-    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments
+    - meta_content_scope: meta.function-call.c meta.group.c
     - match : \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       set: preprocessor-if-branch-statements
@@ -1416,33 +1390,33 @@ contexts:
     - include: expressions
 
   preprocessor-if-branch-function-call-arguments-finish:
-    - meta_content_scope: meta.function-call.c meta.group.c debug.preprocessor-if-branch-function-call-arguments-finish
+    - meta_content_scope: meta.function-call.c meta.group.c
     - match: \)
       scope: meta.function-call.c meta.group.c punctuation.section.group.end.c
       pop: true
     - include: expressions
 
   preprocessor-block-if-branch-statements:
-    - meta_scope: meta.block.c debug.preprocessor-block-if-branch-statements
+    - meta_scope: meta.block.c
     - match: ^\s*(#\s*endif)\b
       captures:
-        1: meta.preprocessor.c keyword.control.import.c debug.preprocessor-block-if-branch-statements.endif
+        1: meta.preprocessor.c keyword.control.import.c
       set: preprocessor-block-finish-statements
     - match: (?=^\s*#\s*(elif|else)\b)
       push: preprocessor-elif-else-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c debug.preprocessor-block-if-branch-statements.closing-brace
+      scope: punctuation.section.block.end.c
       set: preprocessor-if-branch-statements
     - include: statements
 
   preprocessor-block-finish-statements:
-    - meta_scope: meta.block.c debug.preprocessor-block-finish-statements
+    - meta_scope: meta.block.c
     - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b
       captures:
         1: meta.preprocessor.c keyword.control.import.c
       set: preprocessor-block-finish-if-branch-statements
     - match: \}
-      scope: punctuation.section.block.end.c debug.preprocessor-block-finish-statements.closing-brace
+      scope: punctuation.section.block.end.c
       pop: true
     - include: statements
 
@@ -1457,7 +1431,6 @@ contexts:
     - include: statements
 
   preprocessor-elif-else-branch-statements:
-    - meta_scope: debug.preprocessor-elif-else-branch-statements
     - match: (?=^\s*#\s*endif\b)
       pop: true
     - include: negated-block
@@ -1467,9 +1440,8 @@ contexts:
 
   negated-block:
     - match: '\}'
-      scope: punctuation.section.block.end.c debug.negated-block
+      scope: punctuation.section.block.end.c
       push:
-        - meta_scope: debug.negated-block.new-block
         - match: '\{'
           scope: punctuation.section.block.begin.c
           pop: true
@@ -1541,9 +1513,9 @@ contexts:
     - include: preprocessor-comments
     # Don't define blocks in define statements
     - match: '\{'
-      scope: punctuation.section.block.begin.c debug.preprocessor-macro-definition.begin-block
+      scope: punctuation.section.block.begin.c
     - match: '\}'
-      scope: punctuation.section.block.end.c debug.preprocessor-macro-definition.end-block
+      scope: punctuation.section.block.end.c
     - include: expressions
 
   preprocessor-practical-workarounds:
@@ -1552,13 +1524,13 @@ contexts:
 
   preprocessor-convention-ignore-uppercase-ident-lines:
     - match: ^(\s*{{macro_identifier}})+\s*$
-      scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-ident-lines
+      scope: meta.assumed-macro.c
       push:
         # It's possible that we are dealing with a function return type on its own line, and the
         # name of the function is on the subsequent line.
         - match: \s*({{identifier}})(?=\s*\()
           captures:
-            1: meta.function.c entity.name.function.c debug.preprocessor-convention-ignore-uppercase-ident-lines.params
+            1: meta.function.c entity.name.function.c
           set: function-definition-params
         - match: ^
           pop: true
@@ -1567,10 +1539,10 @@ contexts:
   preprocessor-convention-ignore-uppercase-calls-without-semicolon:
     - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$)
       captures:
-        1: variable.function.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
+        1: variable.function.assumed-macro.c
         2: punctuation.section.group.begin.c
       push:
-        - meta_scope: meta.assumed-macro.c debug.preprocessor-convention-ignore-uppercase-calls-without-semicolon
+        - meta_scope: meta.assumed-macro.c
         - match: \)
           scope: punctuation.section.group.end.c
           pop: true
@@ -1581,7 +1553,7 @@ contexts:
       captures:
         1: keyword.control.import.c
       push:
-        - meta_scope: meta.preprocessor.c debug.preprocessor-other
+        - meta_scope: meta.preprocessor.c
         - meta_include_prototype: false
         - include: preprocessor-line-continuation
         - include: preprocessor-line-ending

From 36561ed90ea681b22dc14ffe49be914bc5e2b932 Mon Sep 17 00:00:00 2001
From: Raul E Rangel <rrangel@chromium.org>
Date: Fri, 19 Nov 2021 16:38:49 -0700
Subject: [PATCH 55/55] Fix broken cpp test after merge

This file never conflicted in the chain of merges, so the merge
algorithm missed it somehow.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---
 C++/syntax_test_cpp.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp
index f8afab8492..b654bde9b0 100644
--- a/C++/syntax_test_cpp.cpp
+++ b/C++/syntax_test_cpp.cpp
@@ -293,7 +293,7 @@ struct UI_BoundingBox ** position_p2;
 /*                       ^ - entity.name */
 
 struct UI_MenuBoxData
-/* <- storage.type */
+/* <- keyword.declaration.struct.type.c++ */
 /*     ^ entity.name.struct */
 {
     struct UI_BoundingBox position;