From ea0ba19ff3426cde5213c49a6407e85168700ab5 Mon Sep 17 00:00:00 2001 From: James Buren Date: Wed, 30 Oct 2024 16:40:10 -0500 Subject: [PATCH] [C] Add more standard types from ISO C This adds the types defined by stddef.h, wchar.h, and uchar.h. Some of these types were first defined by C++ but are now defined by C11 or C23 so we will defer to C instead now. --- C++/C++.sublime-syntax | 2 -- C++/C.sublime-syntax | 11 +++++++++- C++/syntax_test_c.c | 36 +++++++++++++++++++++++++++++++ C++/syntax_test_cpp.cpp | 9 -------- Objective-C/syntax_test_objc++.mm | 9 -------- 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 0d05fbef4f..0040b19645 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -148,8 +148,6 @@ contexts: scope: keyword.operator.word.c++ unique-types: - - match: \b(char8_t|char16_t|char32_t|wchar_t|nullptr_t)\b - scope: storage.type.c++ - match: \bclass\b scope: keyword.declaration.class.c++ diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index fb969d4b54..72c1479ca9 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -43,6 +43,9 @@ variables: 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' + stddef: 'size_t|ptrdiff_t|max_align_t|nullptr_t' + wchar: 'wchar_t|wint_t|wctrans_t|wctype_t' + uchar: 'mbstate_t|char8_t|char16_t|char32_t' declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' storage_classes: 'static|extern|register|thread_local|_Thread_local|constexpr|{{declspec}}' type_qualifier: 'const|volatile' @@ -236,12 +239,18 @@ contexts: scope: keyword.declaration.c - match: \b({{basic_types}})\b scope: storage.type.c - - match: \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|clock_t|size_t|ssize_t|time_t|useconds_t|suseconds_t|ptrdiff_t)\b + - 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|ssize_t|time_t|useconds_t|suseconds_t)\b scope: support.type.sys-types.c - match: \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b scope: support.type.pthread.c - match: \b({{stdint}})\b scope: support.type.stdint.c + - match: \b({{stddef}})\b + scope: support.type.stddef.c + - match: \b({{wchar}})\b + scope: support.type.wchar.c + - match: \b({{uchar}})\b + scope: support.type.uchar.c - match: '\b({{microsoft_types}})\b' scope: support.type.microsoft.c - match: '\b({{windows_types}})\b' diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 8d3fc0e247..486ce5fd31 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -313,6 +313,42 @@ bool still_C_code_here = true; /* <- storage.type */ /* ^ constant.language */ +size_t size_t_var; +/* <- support.type.stddef */ + +ptrdiff_t ptrdiff_t_var; +/* <- support.type.stddef */ + +max_align_t max_align_t_var; +/* <- support.type.stddef */ + +nullptr_t nullptr_t_var; +/* <- support.type.stddef */ + +wchar_t wchar_t_var; +/* <- support.type.wchar */ + +wint_t wint_t_var; +/* <- support.type.wchar */ + +wctrans_t wctrans_t_var; +/* <- support.type.wchar */ + +wctype_t wctype_t_var; +/* <- support.type.wchar */ + +mbstate_t mbstate_t_var; +/* <- support.type.uchar */ + +char8_t char8_t_var; +/* <- support.type.uchar */ + +char16_t char16_t_var; +/* <- support.type.uchar */ + +char32_t char32_t_var; +/* <- support.type.uchar */ + void *null_pointer1 = NULL; /* ^ constant.language.null */ diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index ab95fdab01..0bbbe1e621 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -460,15 +460,6 @@ bool b; char ch; /* <- storage.type */ -char16_t ch16; -/* <- storage.type */ - -char32_t ch32; -/* <- storage.type */ - -wchar_t wch; -/* <- storage.type */ - unsigned int ui; /* <- storage.type */ /* ^ storage.type */ diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index 49aa7018c1..6b2a931782 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -450,15 +450,6 @@ bool foo (bool run=true) {} char ch; /* <- storage.type */ -char16_t ch16; -/* <- storage.type */ - -char32_t ch32; -/* <- storage.type */ - -wchar_t wch; -/* <- storage.type */ - unsigned int ui; /* <- storage.type */ /* ^ storage.type */