From d46975e4bce36c4d65a33f93e3f8a48ca008cfcb Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 7 Feb 2025 13:53:42 -0600 Subject: [PATCH 01/66] Initial Commit for rewrite --- C++/C.sublime-syntax | 1754 +++++++++++------------------------------- 1 file changed, 469 insertions(+), 1285 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 779b35d7b7..5b22d3723a 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -14,1426 +14,610 @@ first_line_match: |- ) variables: - # number digits - bin_digit: '[01'']' - oct_digit: '[0-7'']' - dec_digit: '[\d'']' - hex_digit: '[\h'']' + identifier: \b[[:alpha:]_][[:alnum:]_]*\b + likely_macro: \b[[:upper:]][[:upper:][:digit:]_]+\b - # number exponents - dec_exponent: '(?:[eE][-+]?{{dec_digit}}*)' - hex_exponent: '(?:[pP][-+]?{{dec_digit}}*)' - - # number suffixes bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' dec_suffix: '[a-zA-Z_][[:alnum:]_]*' hex_suffix: '[g-zG-Z_][[:alnum:]_]*' - double_suffix: 'df|DF|dd|DD|dl|DL|[fFlL]' - integer_suffix: 'u?wb|[lL]{1,2}[uU]?|[uU][lL]{0,2}' - - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - control_keywords: 'break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|_Decimal(32|64|128)|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum' - microsoft_types: '__int8|__int16|__int32|__int64' - windows_types: 'APIENTRY|ATOM|BOOL|BOOLEAN|BYTE|CALLBACK|CCHAR|CHAR|COLORREF|CONST|DWORD|DWORDLONG|DWORD_PTR|DWORD32|DWORD64|FLOAT|HACCEL|HALF_PTR|HANDLE|HBITMAP|HBRUSH|HCOLORSPACE|HCONV|HCONVLIST|HCURSOR|HDC|HDDEDATA|HDESK|HDROP|HDWP|HENHMETAFILE|HFILE|HFONT|HGDIOBJ|HGLOBAL|HHOOK|HICON|HINSTANCE|HKEY|HKL|HLOCAL|HMENU|HMETAFILE|HMODULE|HMONITOR|HPALETTE|HPEN|HRESULT|HRGN|HRSRC|HSZ|HWINSTA|HWND|INT|INT_PTR|INT8|INT16|INT32|INT64|LANGID|LCID|LCTYPE|LGRPID|LONG|LONGLONG|LONG_PTR|LONG32|LONG64|LPARAM|LPBOOL|LPBYTE|LPCOLORREF|LPCSTR|LPCTSTR|LPCVOID|LPCWSTR|LPDWORD|LPHANDLE|LPINT|LPLONG|LPSTR|LPTSTR|LPVOID|LPWORD|LPWSTR|LRESULT|PBOOL|PBOOLEAN|PBYTE|PCHAR|PCSTR|PCTSTR|PCWSTR|PDWORD|PDWORDLONG|PDWORD_PTR|PDWORD32|PDWORD64|PFLOAT|PHALF_PTR|PHANDLE|PHKEY|PINT|PINT_PTR|PINT8|PINT16|PINT32|PINT64|PLCID|PLONG|PLONGLONG|PLONG_PTR|PLONG32|PLONG64|POINTER_32|POINTER_64|POINTER_SIGNED|POINTER_UNSIGNED|PSHORT|PSIZE_T|PSSIZE_T|PSTR|PTBYTE|PTCHAR|PTSTR|PUCHAR|PUHALF_PTR|PUINT|PUINT_PTR|PUINT8|PUINT16|PUINT32|PUINT64|PULONG|PULONGLONG|PULONG_PTR|PULONG32|PULONG64|PUSHORT|PVOID|PWCHAR|PWORD|PWSTR|QWORD|SC_HANDLE|SC_LOCK|SERVICE_STATUS_HANDLE|SHORT|SIZE_T|SSIZE_T|TBYTE|TCHAR|UCHAR|UHALF_PTR|UINT|UINT_PTR|UINT8|UINT16|UINT32|UINT64|ULONG|ULONGLONG|ULONG_PTR|ULONG32|ULONG64|UNICODE_STRING|USHORT|USN|VOID|WCHAR|WINAPI|WORD|WPARAM' - complex: 'complex|imaginary' - fenv: 'fenv_t|fexcept_t' - setjmp: 'jmp_buf' - signal: 'sig_atomic_t' - stdarg: 'va_list' - stdatomic: 'atomic_(bool|char|schar|uchar|short|ushort|int|uint|long|ulong|llong|ullong|char8_t|char16_t|char32_t|wchar_t|int_least8_t|uint_least8_t|int_least16_t|uint_least16_t|int_least32_t|uint_least32_t|int_least64_t|uint_least64_t|int_fast8_t|uint_fast8_t|int_fast16_t|uint_fast16_t|int_fast32_t|uint_fast32_t|int_fast64_t|uint_fast64_t|intptr_t|uintptr_t|size_t|ptrdiff_t|intmax_t|uintmax_t|flag)|memory_order' - stdint: 'int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t' - stdio: 'FILE|fpos_t' - stdlib: 'div_t|ldiv_t|lldiv_t|imaxdiv_t' - stddef: 'size_t|ptrdiff_t|max_align_t|nullptr_t' - time: 'time_t|clock_t' - threads: 'thrd_t|thrd_start_t|mtx_t|cnd_t|tss_t|tss_dtor_t|once_flag' - wchar: 'wchar_t|wint_t|wctrans_t|wctype_t' - uchar: 'mbstate_t|char8_t|char16_t|char32_t' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|extern|register|thread_local|_Thread_local|constexpr|{{declspec}}' - type_qualifier: 'const|volatile|_Atomic' - compiler_directive: 'inline|restrict|__restrict__|__restrict|_Noreturn|noreturn' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}' - non_func_keywords: 'if|for|switch|while|decltype|typeof|typeof_unqual|_Atomic|_BitInt|sizeof|alignof|_Alignof|alignas|_Alignas|static_assert|_Static_assert|__declspec|__attribute__' + double_suffix: '[fFlL]' + float_suffix: '[fF]' + integer_suffix: '(?:(?:ll|LL)(?!\s*[lL])|(?i)(?:u(?!\w*u)|l(?!\w*l)|i(?!\w*[ij])|j(?!\w*[ij])))+\b' + dec_exponent: '(?:[eE][-+]?\d*)' + hex_exponent: '(?:[pP][-+]?\d*)' contexts: - main: - - include: preprocessor-global - - include: global - - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the C++ - # syntax. They are specifically constructed to not push into sub-contexts, - # which ensures that C++ code isn't accidentally lexed as plain C. They also - # should not use the {{identifier}} variable since that is different for C++. - ############################################################################# - - comments: - - include: block-comments - - include: line-comments - - block-comments: - - match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n? - scope: comment.block.banner.c - captures: - 1: punctuation.definition.comment.begin.c - 2: meta.toc-list.banner.block.c - 3: punctuation.definition.comment.end.c - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.c punctuation.definition.comment.c - # documentation block comments - - match: (?:/\*!|/\*{2,}) - scope: punctuation.definition.comment.begin.c - push: block-comment-documentation-body - # normal block comments - - match: /\* - scope: punctuation.definition.comment.begin.c - push: block-comment-body - # stray block comment end - - match: \*+/(?!\*) - scope: invalid.illegal.stray-comment-end.c + # Helpers - block-comment-documentation-body: - - meta_include_prototype: false - - meta_scope: comment.block.documentation.c - - match: \*+/ - scope: punctuation.definition.comment.end.c + pop-immediately: + - match: "" pop: true - - match: ^\s*(\*)(?!\**/) - captures: - 1: punctuation.definition.comment.c - - block-comment-body: - - meta_include_prototype: false - - meta_scope: comment.block.c - - match: \*/ - scope: punctuation.definition.comment.end.c + else-pop: + - match: (?=\S) pop: true - - match: ^\s*(\*)(?!\**/) - captures: - 1: punctuation.definition.comment.c - line-comments: - - match: ^(//) =\s*(.*?)\s*=\s*$\n? - scope: comment.line.banner.c - captures: - 1: punctuation.definition.comment.c - 2: meta.toc-list.banner.line.c - - match: //(?:!|/(?!/)) - scope: punctuation.definition.comment.c - push: line-comment-documentation-body - - match: //+ - scope: punctuation.definition.comment.c - push: line-comment-body - - line-comment-body: - - meta_include_prototype: false - - meta_scope: comment.line.double-slash.c - - include: line-comment-end - - line-comment-documentation-body: - - meta_include_prototype: false - - meta_scope: comment.line.documentation.c - - include: line-comment-end + # Basic Objects - line-comment-end: - - match: (?:(//+)\s*)?$\n? - captures: - 1: punctuation.definition.comment.c - pop: 1 - - match: (\\)$\n? - captures: - 1: punctuation.separator.continuation.c - - strings: - - match: '(L|u8|u|U)?(")' + string.escape: + - match: \\([abfnrtv\\'\"?]|[eE]|\d{1,3}|x[0-9A-Fa-f]+|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}) + scope: constant.character.escape.c + - match: \\. + scope: invalid.illegal.unknown-escape.c + string.format: + - match: |- + (?x)% + (\d+\$)? # field (argument #) + [#0\- +']* # flags + [,;:_]? # separator character (AltiVec) + ((-?\d+)|\*(-?\d+\$)?)? # minimum field width + (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision + (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier + (\[[^\]]+\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type + scope: constant.other.placeholder.c + string: + - match: (L|u8?|U)?(\") captures: 1: storage.type.string.c 2: punctuation.definition.string.begin.c push: - meta_scope: string.quoted.double.c - - match: '"' + - include: string.escape + - include: string.format + - match: \" scope: punctuation.definition.string.end.c pop: true - - include: string_escaped_char - - include: string_placeholder - - match: "(L|u8|u|U)?(')" + - match: (L?)(\') captures: 1: storage.type.string.c 2: punctuation.definition.string.begin.c push: - - meta_scope: string.quoted.single.c - - match: "'" + - meta_scope: string.quoted.double.c + - include: string.escape + - match: \' scope: punctuation.definition.string.end.c pop: true - - include: string_escaped_char - - string_escaped_char: - - match: '(\\)$\n' - captures: - 1: punctuation.separator.continuation.c - - match: \\(?:\\|[abefnrtv\'"?]|[0-3][0-9]{0,2}|[4-7][0-9]?|x[a-fA-F0-9]+|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}) - scope: constant.character.escape.c - - match: \\. - scope: invalid.illegal.unknown-escape.c - - string_placeholder: - - match: |- - (?x)% - (\d+\$)? # field (argument #) - [#0\- +']* # flags - [,;:_]? # separator character (AltiVec) - ((-?\d+)|\*(-?\d+\$)?)? # minimum field width - (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision - (hh|h|ll|l|j|t|z|q|L|H|D|DD|vh|vl|v|hv|hl|wf?[0-9]+)? # length modifier - (\[[^\]]+\]|[am]s|[diouxXbDOUeEfFgGaACcSspn%]) # conversion type - scope: constant.other.placeholder.c - keywords: - - match: \bbreak\b - scope: keyword.control.flow.break.c - - match: \bcontinue\b - scope: keyword.control.flow.continue.c - - match: \bgoto\b - scope: keyword.control.flow.goto.c - - match: \breturn\b - scope: keyword.control.flow.return.c - - match: \b({{control_keywords}})\b - scope: keyword.control.c - - match: \b(sizeof|alignof|_Alignof|static_assert|_Static_assert)\b + operator.assignment: + - match: = + scope: keyword.operator.assignment.c + - match: \+=|-=|\*=|/=|%=|&=|\|=|\^=|<<=|>>=|>>= + scope: keyword.operator.assignment.augmented.c + operator.arithmetic: + - match: \+|-|\*|/|%|! + scope: keyword.operator.arithmetic.c + operator.logical: + - match: \&\&|\|\| + scope: keyword.operator.logical.c + operator.bitwise: + - match: \&|\||\^|~|<<|>>|>> + scope: keyword.operator.bitwise.c + operator.comparison: + - match: ==|!=|<=|>=|<|> + scope: keyword.operator.comparison.c + operator.word: + - match: \bsizeof|_Alignof|alignof|offsetof\b scope: keyword.operator.word.c + operator.ternary: + - match: '\?|\:' + scope: keyword.operator.ternary.c + operator.variadic: + - match: \.\.\. + scope: keyword.operator.variadic.c + operator.increment-decrement: + - match: \+\+|-- + scope: keyword.operator.arithmetic.c + operator.accessor: + - match: \.|\-\> + scope: punctuation.accessor.c + operator.pointer: + - match: \&|\* + scope: keyword.operator.arithmetic.c + operator: + - include: operator.accessor + - include: operator.assignment + - include: operator.arithmetic + - include: operator.logical + - include: operator.bitwise + - include: operator.comparison + - include: operator.word + - include: operator.ternary + - include: operator.variadic + - include: operator.increment-decrement + + punctuation.comma: + - match: ',' + scope: punctuation.separator.c + punctuation.semicolon: + - match: ; + scope: punctuation.terminator.c + punctuation: + - include: punctuation.comma + - include: punctuation.semicolon - modifiers: - - match: \b({{modifiers}})\b - scope: storage.modifier.c - - variables: - - match: '\bg[A-Z]\w*\b' - scope: variable.other.readwrite.global.mac-classic.c - - match: '\bs[A-Z]\w*\b' - scope: variable.other.readwrite.static.mac-classic.c - - constants: - - match: \b(false|FALSE)\b - scope: constant.language.boolean.false.c - - match: \b(true|TRUE)\b - scope: constant.language.boolean.true.c - - match: \b(nullptr|NULL)\b - scope: constant.language.null.c - - match: \b__func__\b - scope: constant.language.c - - match: \b(__FILE__|__FUNCTION__|__LINE__)\b - scope: support.constant.c - # common C constant naming idiom -- kConstantVariable - - match: '\bk[A-Z]\w*\b' - scope: constant.other.variable.mac-classic.c - - match: \b(noErr|kNilOptions|kInvalidID|kVariableLengthArray)\b - scope: support.constant.mac-classic.c - - c99: - - match: \b(hypot(f|l)?|s(scanf|ystem|nprintf|ca(nf|lb(n(f|l)?|ln(f|l)?))|i(n(h(f|l)?|f|l)?|gn(al|bit))|tr(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(jmp|vbuf|locale|buf)|qrt(f|l)?|w(scanf|printf)|rand)|n(e(arbyint(f|l)?|xt(toward(f|l)?|after(f|l)?))|an(f|l)?)|c(s(in(h(f|l)?|f|l)?|qrt(f|l)?)|cos(h(f)?|f|l)?|imag(f|l)?|t(ime|an(h(f|l)?|f|l)?)|o(s(h(f|l)?|f|l)?|nj(f|l)?|pysign(f|l)?)|p(ow(f|l)?|roj(f|l)?)|e(il(f|l)?|xp(f|l)?)|l(o(ck|g(f|l)?)|earerr)|a(sin(h(f|l)?|f|l)?|cos(h(f|l)?|f|l)?|tan(h(f|l)?|f|l)?|lloc|rg(f|l)?|bs(f|l)?)|real(f|l)?|brt(f|l)?)|t(ime|o(upper|lower)|an(h(f|l)?|f|l)?|runc(f|l)?|gamma(f|l)?|mp(nam|file))|i(s(space|n(ormal|an)|cntrl|inf|digit|u(nordered|pper)|p(unct|rint)|finite|w(space|c(ntrl|type)|digit|upper|p(unct|rint)|lower|al(num|pha)|graph|xdigit|blank)|l(ower|ess(equal|greater)?)|al(num|pha)|gr(eater(equal)?|aph)|xdigit|blank)|logb(f|l)?|max(div|abs))|di(v|fftime)|_Exit|unget(c|wc)|p(ow(f|l)?|ut(s|c(har)?|wc(har)?)|error|rintf)|e(rf(c(f|l)?|f|l)?|x(it|p(2(f|l)?|f|l|m1(f|l)?)?))|v(s(scanf|nprintf|canf|printf|w(scanf|printf))|printf|f(scanf|printf|w(scanf|printf))|w(scanf|printf)|a_(start|copy|end|arg))|qsort|f(s(canf|e(tpos|ek))|close|tell|open|dim(f|l)?|p(classify|ut(s|c|w(s|c))|rintf)|e(holdexcept|set(e(nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(aiseexcept|ror)|get(e(nv|xceptflag)|round))|flush|w(scanf|ide|printf|rite)|loor(f|l)?|abs(f|l)?|get(s|c|pos|w(s|c))|re(open|e|ad|xp(f|l)?)|m(in(f|l)?|od(f|l)?|a(f|l|x(f|l)?)?))|l(d(iv|exp(f|l)?)|o(ngjmp|cal(time|econv)|g(1(p(f|l)?|0(f|l)?)|2(f|l)?|f|l|b(f|l)?)?)|abs|l(div|abs|r(int(f|l)?|ound(f|l)?))|r(int(f|l)?|ound(f|l)?)|gamma(f|l)?)|w(scanf|c(s(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?|mbs)|pbrk|ftime|len|r(chr|tombs)|xfrm)|to(b|mb)|rtomb)|printf|mem(set|c(hr|py|mp)|move))|a(s(sert|ctime|in(h(f|l)?|f|l)?)|cos(h(f|l)?|f|l)?|t(o(i|f|l(l)?)|exit|an(h(f|l)?|2(f|l)?|f|l)?)|b(s|ort))|g(et(s|c(har)?|env|wc(har)?)|mtime)|r(int(f|l)?|ound(f|l)?|e(name|alloc|wind|m(ove|quo(f|l)?|ainder(f|l)?))|a(nd|ise))|b(search|towc)|m(odf(f|l)?|em(set|c(hr|py|mp)|move)|ktime|alloc|b(s(init|towcs|rtowcs)|towc|len|r(towc|len))))\b - scope: support.function.C99.c - - types: - - match: \b({{before_tag}})\b - scope: keyword.declaration.c - - match: \b({{basic_types}})\b - scope: storage.type.c - - match: \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|ssize_t|useconds_t|suseconds_t)\b - scope: support.type.sys-types.c - - match: \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b - scope: support.type.pthread.c - - match: \b({{complex}})\b - scope: support.type.complex.c - - match: \b({{fenv}})\b - scope: support.type.fenv.c - - match: \b({{setjmp}})\b - scope: support.type.setjmp.c - - match: \b({{signal}})\b - scope: support.type.signal.c - - match: \b({{stdarg}})\b - scope: support.type.stdarg.c - - match: \b({{stdatomic}})\b - scope: support.type.stdatomic.c - - match: \b({{stdint}})\b - scope: support.type.stdint.c - - match: \b({{stdio}})\b - scope: support.type.stdio.c - - match: \b({{stdlib}})\b - scope: support.type.stdlib.c - - match: \b({{stddef}})\b - scope: support.type.stddef.c - - match: \b({{wchar}})\b - scope: support.type.wchar.c - - match: \b({{uchar}})\b - scope: support.type.uchar.c - - match: \b({{time}})\b - scope: support.type.time.c - - match: \b({{threads}})\b - scope: support.type.threads.c - - match: '\b({{microsoft_types}})\b' - scope: support.type.microsoft.c - - match: '\b({{windows_types}})\b' - scope: support.type.windows.c - - match: \b(AbsoluteTime|Boolean|Byte|ByteCount|ByteOffset|BytePtr|CompTimeValue|ConstLogicalAddress|ConstStrFileNameParam|ConstStringPtr|Duration|Fixed|FixedPtr|Float32|Float32Point|Float64|Float80|Float96|FourCharCode|Fract|FractPtr|Handle|ItemCount|LogicalAddress|OptionBits|OSErr|OSStatus|OSType|OSTypePtr|PhysicalAddress|ProcessSerialNumber|ProcessSerialNumberPtr|ProcHandle|Ptr|ResType|ResTypePtr|ShortFixed|ShortFixedPtr|SignedByte|SInt16|SInt32|SInt64|SInt8|Size|StrFileName|StringHandle|StringPtr|TimeBase|TimeRecord|TimeScale|TimeValue|TimeValue64|UInt16|UInt32|UInt64|UInt8|UniChar|UniCharCount|UniCharCountPtr|UniCharPtr|UnicodeScalarValue|UniversalProcHandle|UniversalProcPtr|UnsignedFixed|UnsignedFixedPtr|UnsignedWide|UTF16Char|UTF32Char|UTF8Char)\b - scope: support.type.mac-classic.c - - include: types-parens - - types-parens: - - match: '\b(typeof|__typeof|__typeof__|typeof_unqual|alignas|_Alignas|_Atomic|_BitInt)\b\s*(\()' - captures: - 1: keyword.declaration.type.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - numbers: - # https://en.cppreference.com/w/c/language/floating_constant - + number: # decimal floats - match: |- - (?x) - ( - \b{{dec_digit}}+ + (?x: + \b(\d+) (?: - # 1., 1.f, 1.L, 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L - (\.) (?: {{dec_digit}}+ | (?!\.) ) {{dec_exponent}}? - # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L - | {{dec_exponent}} - ) - # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L - | (\.) {{dec_digit}}+ {{dec_exponent}}? + ( (\.) + (?: + # 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L + \d+ {{dec_exponent}}? + # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L + | {{dec_exponent}} + # 1., 1.f, 1.L # but not `..` + | (?!\.) + ) + # 1e1 1e1f 1e1L + | {{dec_exponent}} + ) ({{double_suffix}})? + # 1f + | ({{float_suffix}}) + ) ({{dec_suffix}})? + # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L + | ( (\.) \d+ {{dec_exponent}}? ) (?: ({{double_suffix}}) | ({{dec_suffix}}) )? ) - (?: ({{double_suffix}}) | ({{dec_suffix}}) )? scope: meta.number.float.decimal.c captures: 1: constant.numeric.value.c - 2: punctuation.separator.decimal.c + 2: constant.numeric.value.c 3: punctuation.separator.decimal.c 4: constant.numeric.suffix.c - 5: invalid.illegal.numeric.suffix.c - - # hexadecimal float (C99) - - match: |- - (?x) - \b(0[xX]) - ( - (?: - # 0xfp1, 0xf.p1, 0xfp1f, 0xf.p1f - {{hex_digit}}+ (\.)? - # 0x.fp1, 0xf.fp1, 0x.fp1f, 0xf.fp1f - | {{hex_digit}}* (\.) {{hex_digit}}+ - ) - {{hex_exponent}} - ) - (?: ({{double_suffix}}) | ({{dec_suffix}}) )? + 5: constant.numeric.suffix.c + 6: invalid.illegal.numeric.suffix.c + 7: constant.numeric.value.c + 8: punctuation.separator.decimal.c + 9: constant.numeric.suffix.c + 10: invalid.illegal.numeric.suffix.c + # hexadecimal float + - match: \b(0[xX])(\h*(\.)\h*{{hex_exponent}})(?:([fFlL]\b)|({{dec_suffix}}))? scope: meta.number.float.hexadecimal.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: punctuation.separator.decimal.c - 4: punctuation.separator.decimal.c - 5: constant.numeric.suffix.c - 6: invalid.illegal.numeric.suffix.c - - # https://en.cppreference.com/w/c/language/integer_constant - + 4: constant.numeric.suffix.c + 5: invalid.illegal.numeric.suffix.c # binary integer (C23) - - match: \b(0[bB])({{bin_digit}}*)(?:({{integer_suffix}})|({{bin_suffix}}))? + - match: \b(0[bB])([0-1]*)(?:({{integer_suffix}})|({{bin_suffix}}))? scope: meta.number.integer.binary.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c - # hexadecimal integer - - match: \b(0[xX])({{hex_digit}}*)(?:({{integer_suffix}})|({{hex_suffix}}))? + - match: \b(0[xX])(\h*)(?:({{integer_suffix}})|({{hex_suffix}}))? scope: meta.number.integer.hexadecimal.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c - # octal integer - - match: \b(0)({{oct_digit}}+)(?:({{integer_suffix}})|({{oct_suffix}}))? + - match: \b(0)([0-7]+)(?:({{integer_suffix}})|({{oct_suffix}}))? scope: meta.number.integer.octal.c captures: 1: constant.numeric.base.c 2: constant.numeric.value.c 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c - # decimal integer - - match: \b({{dec_digit}}+)(?:({{integer_suffix}})|({{dec_suffix}}))? + - match: \b(\d+)(?:({{integer_suffix}})|({{dec_suffix}}))? scope: meta.number.integer.decimal.c captures: 1: constant.numeric.value.c 2: constant.numeric.suffix.c 3: invalid.illegal.numeric.suffix.c - operators: - - match: (?:\+\+|--) - scope: keyword.operator.arithmetic.c - - match: '->' - scope: punctuation.accessor.c - - match: \+\=|-\=|\*\=|/\=|%\=|&\=|\|\=|\^\=|>>\=|<<\= - scope: keyword.operator.assignment.augmented.c - - match: <<|>>|&&|\|\| - scope: keyword.operator.arithmetic.c - - match: <\=|>\=|\=\=|<|>|\!\= - scope: keyword.operator.comparison.c - - match: \+|\-|/|%|\||\^|~|! - scope: keyword.operator.arithmetic.c - # These two operator can be both arithmetic and pointer/address related - - match: \*|& - scope: keyword.operator.c - - match: \= - scope: keyword.operator.assignment.c - # Negative lookahead prevents match :: when included in C++ - - match: '\?|:(?!:)' - scope: keyword.operator.ternary.c - - match: '\.\.\.' - scope: keyword.operator.variadic.c - - access-illegal: - - match: \.\.(?!\.) - scope: invalid.illegal.syntax.c - - access: - - match: '(\.)({{identifier}})(?!\s*\()' - captures: - 1: punctuation.accessor.c - 2: variable.other.member.c - - include: access-illegal - - match: \.(?!\.) - scope: punctuation.accessor.c + constant: + - match: \b(true|TRUE)\b + scope: constant.language.boolean.true.c + - match: \b(false|FALSE)\b + scope: constant.language.boolean.false.c + - match: \bNULL\b + scope: constant.language.null.c + - match: \b__(func)__\b + scope: constant.language.c + - match: \b(__[a-zA-Z_]+__|__cplusplus)\b + scope: support.constant.c + - match: '\bk[A-Z]\w*\b' + scope: constant.other.variable.mac-classic.c - label: - - match: '^\s*((?!default){{identifier}})(:)(?!:)' + declspec: + - meta_scope: meta.group.c + - match: \b(allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)\b + scope: constant.other.c + - match: \b(align|allocate|code_seg|spectre|uuid|deprecated)\s*(\() captures: - 1: entity.name.label.c - 2: punctuation.separator.c + 1: storage.modifier.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis - preprocessor-disabled: - - match: ^\s*(#\s*if(n?def)?)\b + - match: \b(property)\s*(\() captures: - 1: meta.preprocessor.c + 1: storage.modifier.c + 2: punctuation.section.group.begin.c push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c - pop: true - - include: preprocessor-disabled - - include: pragma-mark - - include: pragma-mark - - preprocessor-line-continuation: - - match: '(\\)$\n' - captures: - 1: punctuation.separator.continuation.c - - match: \\(\s+?)$ - captures: - 1: invalid.illegal.space-after-continuation.c - - preprocessor-line-ending: - - match: $\n - pop: true + - match: \b(get|put)\b + scope: variable.parameter.c + - include: enclosure.parenthesis - # Comment handling in preprocessor directives are complicated by the fact - # that a single-line comment will normally consume the newline to prevent - # completions from being presented to the user. Additionally, a multi-line - # comment without a line continuation ends at the newline. - preprocessor-comments: - - match: /\* - scope: punctuation.definition.comment.c - push: - - meta_scope: comment.block.c - - match: '\\$\n' - scope: punctuation.separator.continuation.c - - match: \*/ - scope: punctuation.definition.comment.c - pop: true - - match: // - scope: punctuation.definition.comment.c - push: - - meta_scope: comment.line.double-slash.c - - match: '(\\)$\n' - captures: - 1: punctuation.separator.continuation.c - pop: true - - match: (?=\n) - pop: true + - include: expression + - match: \) + scope: punctuation.section.group.end.c + pop: 2 - pragma-mark: - - match: ^\s*((#\s*pragma\s+mark)\s+(.*)) - scope: meta.section.c + gnu-attribute: + - meta_scope: meta.group.c meta.attribute.c + # too many attributes, these are the ones commonly used + - include: punctuation.comma + - match: \b(noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)\b + scope: constant.other.c + - match: \b(aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)\s*(\() captures: - 1: meta.preprocessor.c - 2: keyword.control.import.pragma.c - 3: meta.toc-list.pragma-mark.c - - # Used by "inc" snippets to prevent double ##include - incomplete-inc: - - match: '^\s*(#i(nc?)?)\b\s*' - scope: meta.preprocessor.incomplete.c - - ############################################################################# - # The following are C-specific scopes that should not be reused. This is - # because they push into subcontexts and use variables that are C-specific. - ############################################################################# - - global: - - include: early-expressions - - match: '^\s*(?=\w+)' - push: global-modifier - - include: late-expressions - - statements: - - include: preprocessor-statements - - include: label - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: typedef - - include: keywords-parens - - include: keywords - - include: numbers - - include: operators - - include: strings - - include: parens - - include: brackets - - include: block - - include: variables - - include: constants - - include: access - - match: ',' - scope: punctuation.separator.c - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.c - - late-expressions: - - include: modifiers-parens - - include: modifiers - - include: types - - include: function-call - - match: ';' - scope: punctuation.terminator.c - - ## C-specific contexts + 1: storage.modifier.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \)\) + scope: punctuation.section.group.end.c + pop: 2 - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '(?=\S)' - set: global-type + keyword.storage: + - match: \bauto\b + scope: storage.type.c + - match: \b(const|volatile|restrict|_Atomic|register|static|inline|extern|register|thread_local|_Thread_local|_Noreturn|noreturn|_Alignas)\b + scope: storage.modifier.c - global-type: - - include: comments - - include: types-parens - - match: \* - scope: keyword.operator.c - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - {{identifier}} - (\s+{{identifier}}(?!\s*[{=;])|\s*\*+) - ) - ) - captures: - 1: keyword.declaration.c - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/union - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{control_keywords}})\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c - 2: meta.group.c punctuation.section.group.begin.c + - match: \b__declspec\b + scope: storage.modifier.c push: - - meta_scope: meta.function-call.c - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - match: (?={{identifier}}\s*\() - set: - - include: function-call - - match: '' - pop: true - - include: types - - match: '{{identifier}}' - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \* - scope: keyword.operator.c - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Identifier that is not the function name - likely a macro - - match: '{{identifier}}(?!\s*(\(|$))' - # Real function definition - - match: '{{identifier}}(?=\s*(\(|$))' - scope: meta.function.c entity.name.function.c - set: function-definition-params - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.c - - include: comments - - match: '(?=\()' - set: - match: \( - scope: meta.function.parameters.c meta.group.c punctuation.section.group.begin.c - set: - - meta_content_scope: meta.function.parameters.c meta.group.c - - match : \) - scope: punctuation.section.group.end.c - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)))' - scope: variable.parameter.c - - include: expressions - - include: preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.c - - include: comments - - match: '(?=;)' - pop: true - - match: \b(const|final|noexcept|override)\b - scope: storage.modifier.c - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-body: - - meta_content_scope: meta.function.c - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.function.c meta.block.c - - match: '\}' - scope: meta.function.c meta.block.c punctuation.section.block.end.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - data-structures: - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{identifier}}\s+{{identifier}}\s*[=;\[])' + scope: punctuation.section.group.begin.c + push: declspec + # __attribute__ alone will already be storage.modifier.c from constant + - match: \b(__attribute__)\s*(\(\() + captures: + 1: storage.modifier.c + 2: punctuation.section.group.begin.c + push: gnu-attribute + keyword.declaration: + - match: \b(struct|enum|union)\b scope: keyword.declaration.c - - match: '\bstruct\b' - scope: keyword.declaration.struct.c - set: data-structures-struct-definition - - match: '\benum\b' - scope: keyword.declaration.enum.c - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.c - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - - data-structures-struct-definition: - - meta_scope: meta.struct.c - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.struct.forward-decl.c - - match: '{{identifier}}' - scope: entity.name.struct.c - set: data-structures-struct-definition-after-name - - include: data-structures-struct-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-name: - - meta_scope: meta.struct.c - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-struct-definition-block-start - - data-structures-struct-definition-block-start: - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.struct.c meta.block.c - - match: '\}' - scope: meta.struct.c meta.block.c punctuation.section.block.end.c - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.c - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.enum.forward-decl.c - - match: '{{identifier}}' - scope: entity.name.enum.c - set: data-structures-enum-definition-after-name - - include: data-structures-enum-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-name: - - meta_scope: meta.enum.c - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-enum-definition-block-start - - data-structures-enum-definition-block-start: - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.enum.c meta.block.c - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.c meta.block.c punctuation.section.block.end.c - pop: true - - include: data-structures-body-enum - - data-structures-union-definition: - - meta_scope: meta.union.c - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.union.forward-decl.c - - match: '{{identifier}}' - scope: entity.name.union.c - set: data-structures-union-definition-after-name - - include: data-structures-union-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-name: - - meta_scope: meta.union.c - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-union-definition-block-start - - data-structures-union-definition-block-start: - - match: '\{' - scope: meta.block.c punctuation.section.block.begin.c - set: - - meta_content_scope: meta.union.c meta.block.c - - match: '\}' - scope: meta.union.c meta.block.c punctuation.section.block.end.c - pop: true - - include: data-structures-body - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: modifiers-parens - - include: modifiers - - data-structures-definition-common-macro: - # Handle macros so they aren't matched as the class name - - match: '\b[[:upper:][:digit:]_]+\b(?!\s*($|\{))' - - data-structures-definition-common-end: - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - include: expressions - - data-structures-body-enum: - - include: comments - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - match: '{{identifier}}' - scope: entity.name.constant.c - push: constant-value - - match: ',' - scope: punctuation.separator.c - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - block: - - match: '\{' - scope: punctuation.section.block.begin.c - push: - - meta_scope: meta.block.c - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.c - pop: true - - include: statements - - parens: + - match: \btypedef\b + scope: keyword.declaration.type.c + keyword.control-flow: + - match: \bcontinue\b + scope: keyword.control.flow.continue.c + - match: \bbreak\b + scope: keyword.control.flow.break.c + - match: \breturn\b + scope: keyword.control.flow.return.c + - match: \bgoto\b + scope: keyword.control.flow.goto.c + keyword.control: + - match: \b(?:if|else|for|while|do|switch|case|default)\b + scope: keyword.control.c + keyword.asm: + - match: \b(asm|__asm|__asm__)\b + scope: keyword.control.import.c + keyword.type: + - match: \b(?:bool|void|char|short|int|long|float|double|signed|unsigned|_Complex|_Imaginary|_Bool)\b + scope: storage.type.c + - match: \b(u?intptr|u?intmax|ptrdiff|nullptr|max_align|size|u?int(_fast|_least)?(8|16|32|64))_t\b + scope: support.type.stdint.c + - match: \b(typeof_unqual|__typeof__|__typeof|typeof)\b + scope: keyword.declaration.type.c + keyword: + - include: keyword.control-flow + - include: keyword.control + - include: keyword.storage + - include: keyword.declaration + - include: keyword.asm + - include: keyword.type + + # More complicated structures + + enclosure.parenthesis: + - meta_scope: meta.group.c + - include: expression + - match: \) + scope: punctuation.section.group.end + pop: 1 + enclosure.brackets: + - meta_scope: meta.brackets.square.c + - include: expression + - match: \] + scope: punctuation.section.brackets.end + pop: 1 + enclosure.block: + - meta_scope: meta.block.c + - include: expression + - match: \} + scope: punctuation.section.block.end + pop: 1 + enclosure: - match: \( - scope: punctuation.section.group.begin.c - push: - - meta_scope: meta.group.c - - match: \) - scope: punctuation.section.group.end.c - pop: true - - include: expressions - - brackets: + scope: punctuation.section.group.begin + push: enclosure.parenthesis - match: \[ - scope: punctuation.section.brackets.begin.c - push: - - meta_scope: meta.brackets.c - - match: \] - scope: punctuation.section.brackets.end.c - pop: true - - include: expressions + scope: punctuation.section.brackets.begin + push: enclosure.brackets + - match: \{ + scope: punctuation.section.block.begin + push: enclosure.block - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.c + type.enum-body: + - meta_content_scope: meta.block.c + - meta_include_prototype: false + - match: \b{{identifier}}\b + scope: entity.name.constant.c push: - - match: ':' - scope: punctuation.separator.c + - match: (?=,|}) pop: true - - include: expressions - - modifiers-parens: - - match: \b(__attribute__)\s*(\(\() + - include: expression + - include: punctuation.comma + - match: \} + scope: punctuation.section.block.end.c + pop: 1 + type.enum: + - meta_scope: meta.enum.c + - include: expression.call + - match: ({{identifier}})\s*(?=;) captures: - 1: storage.modifier.c - 2: meta.group.c punctuation.section.group.begin.c - push : - - meta_scope: meta.attribute.c - - meta_content_scope: meta.group.c - - include: parens - - include: strings - - match: \)\) - scope: meta.group.c punctuation.section.group.end.c - pop: true - - match: \b(__declspec)(\() + 1: entity.name.enum.forward-decl.c + pop: true + - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) captures: - 1: storage.modifier.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.c - - match: ',' - scope: punctuation.separator.c - - match: '=' - scope: keyword.operator.assignment.c - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.c - - keywords-parens: - - match: '\b(sizeof|alignof|_Alignof|static_assert|_Static_assert)\b\s*(\()' + 1: entity.name.enum.c + set: + - match: \{ + scope: meta.enum.c punctuation.section.block.begin.c + set: type.enum-body + - match: (?=\S) + fail: enum + - match: (?=\S) + fail: enum + type.struct: + - meta_scope: meta.struct.c + - include: expression.call + - match: ({{identifier}})\s*(?=;) captures: - 1: keyword.operator.word.c - 2: meta.group.c punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: '\)' - scope: meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.c - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.c - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions - - function-call: - - match: (?={{identifier}}\s*\() - push: - - meta_content_scope: meta.function-call.c - - include: c99 - - match: '{{identifier}}' - scope: variable.function.c - - match: '\(' - scope: meta.group.c punctuation.section.group.begin.c - set: - - meta_content_scope: meta.function-call.c meta.group.c - - match : \) - scope: meta.function-call.c meta.group.c punctuation.section.group.end.c - pop: true - - include: expressions - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0+))\b + 1: entity.name.enum.forward-decl.c + pop: true + - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-disabled - - preprocessor-if-true: - - match: ^\s*(#\s*endif)\b + 1: entity.name.struct.c + set: + - match: \{ + scope: meta.struct.c punctuation.section.block.begin.c + set: enclosure.block + - match: (?=\S) + fail: struct + - match: (?=\S) + fail: struct + type.union: + - meta_scope: meta.union.c + - include: expression.call + - match: ({{identifier}})\s*(?=;) captures: - 1: meta.preprocessor.c keyword.control.import.c + 1: entity.name.enum.forward-decl.c pop: true - - match: ^\s*(#\s*else)\b + - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - include: preprocessor-if-true - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: incomplete-inc - - include: preprocessor-macro-define - - include: pragma-mark - - include: preprocessor-other + 1: entity.name.union.c + set: + - match: \{ + scope: meta.union.c punctuation.section.block.begin.c + set: enclosure.block + - match: (?=\S) + fail: union + - match: (?=\S) + fail: union + type: + - match: \benum\b + scope: keyword.declaration.enum.c + branch_point: enum + branch: [type.enum, pop-immediately] + - match: \bstruct\b + scope: keyword.declaration.struct.c + branch_point: struct + branch: [type.struct, pop-immediately] + - match: \bunion\b + scope: keyword.declaration.union.c + branch_point: union + branch: [type.union, pop-immediately] - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c + generic.body: + - match: ':' + scope: keyword.operator.c push: - - match: ^\s*(#\s*endif)\b + - match: ({{identifier}})\s*(?=,|\)) captures: - 1: meta.preprocessor.c keyword.control.import.c + 1: variable.function.c pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-disabled + - include: expression - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b + generic: + - match: \b(_Generic)\s*(\() captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - include: preprocessor-if-true - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global + 1: keyword.declaration.c + 2: punctuation.section.group.begin.c + push: generic.body - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global + # Expression objects - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.c - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global + expression-identifiers: + - include: operator.word + - include: type + - include: keyword + - include: constant - preprocessor-block-if-branch-global: - - meta_scope: meta.block.c - - match: ^\s*(#\s*endif)\b + expression.call: + - match: \b({{identifier}})\s*(\() captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.c - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b + 1: variable.function.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis + expression: + - include: number + - include: string + - include: type + - include: keyword + - include: constant + - include: operator + - include: punctuation + - include: generic + - include: expression.call + - include: enclosure + + function.label: + - match: '({{identifier}})\s*(:)' captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-if-branch-global + 1: entity.name.label.c + 2: punctuation.separator.c + function.body: + - meta_scope: meta.function.c meta.block.c - match: \} scope: punctuation.section.block.end.c pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*endif\b) + - include: expression + - include: function.label + function.tail: + - meta_scope: meta.function.c + - match: ; pop: true - - include: negated-block - - include: preprocessor-global - - include: global - - ## Preprocessor for statements + - match: \{ + scope: punctuation.section.block.begin + set: function.body + - include: expression + function.params: + - meta_content_scope: meta.function.parameters.c meta.group.c + - match: \) + scope: punctuation.section.group.end.c + set: function.tail - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0+))\b + - match: ({{identifier}})(?=\[) captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c + 1: variable.parameter.c push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c + - match: (?=[,\)]|$) pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c keyword.control.import.else.c - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-disabled + - include: enclosure - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b + - match: ({{identifier}})\b(?=[,\)]|$) captures: - 1: meta.preprocessor.c - 2: keyword.control.import.c - 3: meta.number.integer.decimal.c constant.numeric.value.c - push: - - include: preprocessor-if-true - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b + 1: variable.parameter.c + - include: expression + function: + - include: expression-identifiers + - include: operator.pointer + - match: ({{identifier}})\s*(\() captures: - 1: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements + 1: entity.name.function.c + 2: punctuation.section.group.begin.c + push: function.params + - match: \b{{identifier}}\b - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.c - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements + statement: + - match: (?=\S) + push: + - match: ; + scope: punctuation.terminator.c + pop: true + - include: expression - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.c - - include: c99 - - match: '{{identifier}}' - scope: variable.function.c - - match: '\(' - scope: meta.group.c punctuation.section.group.begin.c - set: preprocessor-if-branch-function-call-arguments + main: + - include: preprocessor + - include: function + - include: statement - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.c meta.group.c - - match : \) - scope: meta.function-call.c meta.group.c punctuation.section.group.end.c - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions + prototype: + - include: preprocessor.comment + - match: \\$ + scope: punctuation.separator.continuation.c + push: + - match: ^ + pop: true - 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 + # Everything after this comment needs to be rewritten so don't pay too much mind - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.c - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-statements - - include: statements + preprocessor: + - include: preprocessor.comment + - match: ^\s*#\s*(?=(if|elif|endif|else|ifndef|ifdef|undef|include(_next)?|define|error|warning|pragma)\b) + scope: keyword.control.import.c + push: preprocessor.directive + preprocessor.directive: + - meta_scope: meta.preprocessor.c - preprocessor-block-finish-statements: - - meta_scope: meta.block.c - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.c - pop: true - - include: statements + - match: \bifndef|ifdef|if|elif\b + scope: keyword.control.import.c + set: + - match: ^ + pop: true - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c + - match: \belse|endif\b + scope: keyword.control.import.c pop: true - - match: \} - scope: punctuation.section.block.end.c - set: preprocessor-if-branch-statements - - include: statements - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements + - match: \b(warning|error)\b + scope: meta.preprocessor.diagnostic.c keyword.control.import.error.c + set: + - meta_content_scope: meta.preprocessor.diagnostic.c string.quoted.c + - include: string + - match: $ + pop: true - ## Preprocessor other + - match: \binclude(_next)?\b + scope: meta.preprocessor.include.c keyword.control.import.include.c + set: + - meta_content_scope: meta.preprocessor.include.c + - match: < + push: + - meta_scope: string.quoted.c + - match: ">" + pop: true + - match: \" + push: + - meta_scope: string.quoted.c + - match: \" + pop: true - negated-block: - - match: '\}' - scope: punctuation.section.block.end.c - push: - - match: '\{' - scope: punctuation.section.block.begin.c - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) + - match: ^ pop: true - - include: statements - preprocessor-macro-define: - - match: ^\s*(#\s*define)\b - captures: - 1: meta.preprocessor.macro.c keyword.control.import.define.c - push: - - meta_content_scope: meta.preprocessor.macro.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.c - set: - - match: '\(' - scope: punctuation.section.group.begin.c - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.c - set: preprocessor-macro-definition + - match: \bundef|pragma\b + scope: keyword.control.import.c + set: + - meta_content_scope: meta.preprocessor.c + - match: ^ + pop: true - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.c meta.group.c - - match: '{{identifier}}' - scope: variable.parameter.c - - match: \) - scope: punctuation.section.group.end.c - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.c - push: - - match: '{{identifier}}' - scope: variable.parameter.c + - match: \bdefine\b + scope: keyword.control.import.c + set: + - match: ^ pop: true - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c - - match: '(?=\))' + preprocessor.comment: + - match: /\* + scope: punctuation.definition.comment.c + push: + - meta_scope: comment.block.c + - match: '\\$\n' + scope: punctuation.separator.continuation.c + - match: \*/ + scope: punctuation.definition.comment.c pop: true - - match: (/\*).*(\*/) - scope: comment.block.c - captures: - 1: punctuation.definition.comment.c - 2: punctuation.definition.comment.c - - match: '\S+' - scope: invalid.illegal.unexpected-character.c - - include: preprocessor-line-continuation - - include: preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c - - match: (/\*).*(\*/) - scope: comment.block.c - captures: - 1: punctuation.definition.comment.c - 2: punctuation.definition.comment.c - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.c - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.c - - match: '\}' - scope: punctuation.section.block.end.c - - include: expressions - - preprocessor-practical-workarounds: - - include: preprocessor-convention-ignore-uppercase-ident-lines - - include: preprocessor-convention-ignore-uppercase-calls-without-semicolon - - preprocessor-convention-ignore-uppercase-ident-lines: - - match: ^(\s*{{macro_identifier}})+\s*$ - scope: meta.assumed-macro.c + - match: // + scope: punctuation.definition.comment.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*\() + - meta_scope: comment.line.double-slash.c + - match: '(\\)$\n' captures: - 1: meta.function.c entity.name.function.c - set: function-definition-params - - match: ^ + 1: punctuation.separator.continuation.c pop: true - - - preprocessor-convention-ignore-uppercase-calls-without-semicolon: - - match: ^\s*({{macro_identifier}})\s*(\()(?=[^)]*\)\s*$) - captures: - 1: variable.function.assumed-macro.c - 2: punctuation.section.group.begin.c - push: - - meta_scope: meta.assumed-macro.c - - match: \) - scope: punctuation.section.group.end.c + - match: (?=\n) pop: true - - include: expressions - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c keyword.control.import.c - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.c - push: - - meta_scope: meta.preprocessor.diagnostic.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.c - - match: ^\s*(#\s*(?:include|include_next|embed|import))\b - captures: - 1: keyword.control.import.include.c - push: - - meta_scope: meta.preprocessor.include.c - - include: preprocessor-line-continuation - - include: preprocessor-line-ending - - include: preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.c - push: - - meta_scope: string.quoted.double.include.c - - match: '"' - scope: punctuation.definition.string.end.c - pop: true - - match: < - scope: punctuation.definition.string.begin.c - push: - - meta_scope: string.quoted.other.lt-gt.include.c - - match: ">" - scope: punctuation.definition.string.end.c - pop: true - - include: preprocessor-practical-workarounds From 8546556614cd12b6c63c4e25ddb9fdae692df501 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:02:12 -0600 Subject: [PATCH 02/66] syntax test file wip --- C++/syntax_test_c.c | 1626 ++++--------------------------------------- 1 file changed, 128 insertions(+), 1498 deletions(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index ec3bd38270..dbbf40d5e0 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,1555 +1,185 @@ -/* SYNTAX TEST "Packages/C++/C.sublime-syntax" */ +// SYNTAX TEST "Packages/C++/C.sublime-syntax" -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ - - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number constant.numeric.value */ - /* ^^ keyword.operator.arithmetic */ -} - -enum Foo { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.enum */ -/* ^ entity.name.constant.c */ -/* ^ entity.name.constant.c */ -#define FOO Foo -enum FOO do_the_foo(void); -/* ^ entity.name.function */ -/* ^ storage.type */ - -#define APIC_CAPABILITY TheEnum -enum TheEnum { kFoo, kBar }; -static enum APIC_CAPABILITY apic_capabilities(void) { return kFoo; }; -/* ^ entity.name.function */ -/* ^ storage.type */ - -enum { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.constant.c */ -/* ^ entity.name.constant.c */ - -enum { kFoo = FOO, kBar = BAR }; -/* <- keyword.declaration */ -/* ^^^^ entity.name.constant.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ -/* ^ punctuation.separator.c */ -/* ^^^^ entity.name.constant.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ - -enum { - FOO, -/* ^^^ entity.name.constant.c */ -/* ^ punctuation.separator.c */ - BAR -/* ^^^ entity.name.constant.c */ -}; - -typedef enum state { DEAD, ALIVE } State; -/* <- keyword.declaration -/* ^ entity.name.enum */ -/* ^ entity.name.constant.c */ -/* ^ entity.name.constant.c */ - -struct __declspec(dllimport) X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct __declspec(dllimport) baz X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct foo { -/* ^ entity.name.struct */ - union { -/* ^ keyword.declaration */ - struct { -/* ^ keyword.declaration */ - int a; -/* ^ storage.type */ - int b; -/* ^ storage.type */ - } - } -} - -#define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS /* comment block */ * sizeof(struct ptp_extts_event)) // comment line -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group meta.group */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant.preprocessor */ -/* ^ comment.block */ -/* ^ keyword.operator.word */ -/* ^ keyword.declaration */ -/* ^ comment.line */ - -#pragma foo(bar, \ -"baz") -/*^^^^ meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#define PACKED __attribute__((aligned(1),packed)) -/* ^ entity.name.constant */ -/* ^ storage.modifier */ - -int i; -/* <- storage.type */ - -signed _BitInt(4) bi1 = 1wb; -/* ^ keyword.declaration.type */ -/* ^ constant.numeric.suffix */ - -unsigned _BitInt(4) bi2 = 1uwb; -/* ^ keyword.declaration.type */ -/* ^ constant.numeric.suffix */ - -_Atomic int ai1; -/* <- storage.modifier */ - -_Atomic(int) ai2; -/* <- storage.modifier */ - -_Alignas(int) int aa1; -/* <- keyword.declaration.type */ - -alignas(int) int aa2; -/* <- keyword.declaration.type */ - -thread_local int tl1; -/* <- storage.modifier */ - -_Thread_local int tl2; -/* <- storage.modifier */ - -typeof(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -__typeof(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -__typeof__(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -typeof_unqual(i) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -static_assert(alignof(int) == 4); -/* ^ keyword.operator.word */ - -_Static_assert(_Alignof(int) == 4); -/* ^ keyword.operator.word */ - -static_assert(sizeof(int) == 4); -/* <- keyword.operator.word */ - -_Static_assert(sizeof(int) == 4); -/* <- keyword.operator.word */ - -void build_default_prototype(Function *ret) { - static typeof(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - static __typeof(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - static __typeof__(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - static typeof_unqual(*ret->params) params[4]; - /* <- keyword.declaration.type */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ -} - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin */ -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.block */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number constant.numeric.value */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -#define CONST0 16 // Comment -#define CONST1 8 -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#if defined(VARIABLE) | // comment_line \ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor */ \ - defined(VAR2) -/*^^^^^^^^^^^^^^^ meta.preprocessor */ -/* ^ keyword.control */ -# error This is a long error message that need to \ -/* <- keyword.control.import */ \ -/* ^ string.unquoted */ \ - be splitted into two lines to prevent large lines. // comment -#error "Explicitly quoted string wrapped, \ - ensuring that the string quoting stops at some point \ - " -#warning This is a short warning -/* <- keyword.control.import */ -#endif - /* <- keyword.control.import */ - -#define MACRO_WITH_CURLY_BRACE { -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -bool still_C_code_here = true; -/* <- storage.type */ -/* ^ constant.language */ - -_Decimal32 d32; -/* <- storage.type */ - -_Decimal64 d64; -/* <- storage.type */ - -_Decimal128 d128; -/* <- storage.type */ - -complex complex_t_var; -/* <- support.type.complex */ - -imaginary imaginary_t_var; -/* <- support.type.complex */ - -fenv_t fenv_t_var; -/* <- support.type.fenv */ - -fexcept_t fexcept_t_var; -/* <- support.type.fenv */ - -jmp_buf jmp_buf_var; -/* <- support.type.setjmp */ - -sig_atomic_t sig_atomic_t_var; -/* <- support.type.signal */ - -va_list va_list_var; -/* <- support.type.stdarg */ - -atomic_bool atomic_bool_var; -/* <- support.type.stdatomic */ - -atomic_char atomic_char_var; -/* <- support.type.stdatomic */ - -atomic_schar atomic_schar_var; -/* <- support.type.stdatomic */ - -atomic_uchar atomic_uchar_var; -/* <- support.type.stdatomic */ - -atomic_short atomic_short_var; -/* <- support.type.stdatomic */ - -atomic_ushort atomic_ushort_var; -/* <- support.type.stdatomic */ - -atomic_int atomic_int_var; -/* <- support.type.stdatomic */ - -atomic_uint atomic_uint_var; -/* <- support.type.stdatomic */ - -atomic_long atomic_long_var; -/* <- support.type.stdatomic */ - -atomic_ulong atomic_ulong_var; -/* <- support.type.stdatomic */ - -atomic_llong atomic_llong_var; -/* <- support.type.stdatomic */ - -atomic_ullong atomic_ullong_var; -/* <- support.type.stdatomic */ - -atomic_char8_t atomic_char8_t_var; -/* <- support.type.stdatomic */ - -atomic_char16_t atomic_char16_t_var; -/* <- support.type.stdatomic */ - -atomic_char32_t atomic_char32_t_var; -/* <- support.type.stdatomic */ - -atomic_wchar_t atomic_wchar_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least8_t atomic_int_least8_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least8_t atomic_uint_least8_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least16_t atomic_int_least16_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least16_t atomic_uint_least16_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least32_t atomic_int_least32_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least32_t atomic_uint_least32_t_var; -/* <- support.type.stdatomic */ - -atomic_int_least64_t atomic_int_least64_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_least64_t atomic_uint_least64_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast8_t atomic_int_fast8_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast8_t atomic_uint_fast8_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast16_t atomic_int_fast16_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast16_t atomic_uint_fast16_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast32_t atomic_int_fast32_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast32_t atomic_uint_fast32_t_var; -/* <- support.type.stdatomic */ - -atomic_int_fast64_t atomic_int_fast64_t_var; -/* <- support.type.stdatomic */ - -atomic_uint_fast64_t atomic_uint_fast64_t_var; -/* <- support.type.stdatomic */ - -atomic_intptr_t atomic_intptr_t_var; -/* <- support.type.stdatomic */ - -atomic_uintptr_t atomic_uintptr_t_var; -/* <- support.type.stdatomic */ - -atomic_size_t atomic_size_t_var; -/* <- support.type.stdatomic */ - -atomic_ptrdiff_t atomic_ptrdiff_t_var; -/* <- support.type.stdatomic */ - -atomic_intmax_t atomic_intmax_t_var; -/* <- support.type.stdatomic */ - -atomic_uintmax_t atomic_uintmax_t_var; -/* <- support.type.stdatomic */ - -atomic_flag atomic_flag_var; -/* <- support.type.stdatomic */ - -memory_order memory_order_var; -/* <- support.type.stdatomic */ - -FILE *FILE_var; -/* <- support.type.stdio */ - -fpos_t fpos_t_var; -/* <- support.type.stdio */ - -div_t div_t_var; -/* <- support.type.stdlib */ - -ldiv_t ldiv_t_var; -/* <- support.type.stdlib */ - -lldiv_t lldiv_t_var; -/* <- support.type.stdlib */ - -imaxdiv_t imaxdiv_t_var; -/* <- support.type.stdlib */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -time_t time_t_var; -/* <- support.type.time */ - -clock_t clock_t_var; -/* <- support.type.time */ - -thrd_t thrd_t_var; -/* <- support.type.threads */ - -thrd_start_t thrd_start_t_var; -/* <- support.type.threads */ - -mtx_t mtx_t_var; -/* <- support.type.threads */ - -cnd_t cnd_t_var; -/* <- support.type.threads */ - -tss_t tss_t_var; -/* <- support.type.threads */ - -tss_dtor_t tss_dtor_t_var; -/* <- support.type.threads */ - -once_flag once_flag_var; -/* <- support.type.threads */ - -void *null_pointer1 = NULL; - /* ^ constant.language.null */ - -void *null_pointer2 = nullptr; - /* ^ constant.language.null */ - -_Noreturn -/* <- storage.modifier */ -void foo(void) { abort(); } - -noreturn -/* <- storage.modifier */ -void bar(void) { abort(); } - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ - - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} - -#if 0 -#ifdef moo -/* <- - keyword.control - ^ meta.number constant.numeric.value -*/ -#endif -/* <- - keyword.control */ -#endif - -#if 0 -/* ^ meta.number constant.numeric.value */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 0000000 -/* ^^^^^^^ meta.number constant.numeric.value -*/ -#endif - -#if 1 -/* ^ meta.number constant.numeric.value */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 0090 -/* ^^^^ meta.number constant.numeric.value -*/ -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number constant.numeric.value */ - int b = 2; -/* ^ comment.block */ - #else - int c = 3; - #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - -FOO -/* <- meta.assumed-macro */ -FOO; -/* <- - meta.assumed-macro */ -foo -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO(); -/* <- - meta.assumed-macro */ -foo() -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ - -struct X -{ - ENABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - int foo; - /* <- storage.type */ +///////////////////////////////////////////// +// Numbers +///////////////////////////////////////////// - DISABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - float bar; - /* <- storage.type */ -}; +1234567890 +0x123456789abcdef +012345670 +0b100110 -/** - * -/* ^ comment.block.documentation.c punctuation.definition.comment.c */ +314lUJ 314uLLj 314iLu 314llI 314F 314f +3.14f 314.l 3.14L +314e15 3.14e-15 +0xdead.beefp+7f +012345670 0314llU +0b10 0b10iLu -/* - * -/* ^ comment.block.c punctuation.definition.comment.c */ +0271828 0b10410 0xbag50 314a123 +314Ll 314lul 314iJ 314.ll 314.lf +0x314.1p5af 0b10e20 314e+30llu ///////////////////////////////////////////// -// Preprocessor branches starting blocks +// Operators ///////////////////////////////////////////// -#ifdef FOO -if (1) { -#elif BAR -if (2) { -# elif BAZ -if (3) { -# else -if (4) { -#endif - int bar = 1; -} -/* <- meta.block punctuation.section.block.end */ - /* <- - meta.block */ - +1 + 2 - 3 * 4 / 5 % 6 +1 | 2 & 3 ^ 4 >> 5 << 6 +1 > 2 >= 3 == 4 != 5 <= 6 < 7 +!1 ? -2 : ~3 +0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +sizeof(a) alignof(b) _Alignof(c) offsetof(c) +a,b = b.c; ///////////////////////////////////////////// -// Typedefs +// Strings ///////////////////////////////////////////// +"abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +"\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\9" +'\u\w\x\y\z\/' +"%ms %as %*[, ]" -typedef int myint; -/* <- keyword.declaration */ -/* ^ entity.name.type */ - -typedef struct mystruct { -/* <- keyword.declaration */ -/* ^ keyword.declaration.struct.c */ -/* ^ entity.name.struct.c */ -} mystruct; -/* ^ entity.name.type.typedef.c */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^^^^^^^^^^^ entity.name.struct.c */ -/* ^ punctuation.section.block.begin.c */ -/* ^ punctuation.section.block.end.c */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.c */ +"314 \ + 159" ///////////////////////////////////////////// -// Data structures and return values +// Constants ///////////////////////////////////////////// -struct point -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ -{ - int x; - int y; -} - -struct point2 { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - int x; - int y; -} - -int main(void) { -/* ^^^^ entity.name.function */ -/* ^^^^ storage.type */ -} - -struct point get_point() {} -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin -/* ^ punctuation.section.block.end -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^ entity.name.function */ - -struct point **alloc_points(); -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -struct point* alloc_point(); -/* ^ entity.name.function - variable.function */ - -struct point FOO_API *alloc_point3(); -/* ^ entity.name.function - variable.function */ - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; +true TRUE false FALSE NULL __func__ +__FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Enclosings ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[]) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -{ -/* <- meta.function meta.block */ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result != 0) { -/* ^^ keyword.operator.comparison.c */ - return 0; -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^^ keyword.control */ -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifdef BAR - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifndef BAZ - /* <- keyword.control.import */ - if (val == -3) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -4) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ +[a, b, c] +{1, 2, 3} +(6 - 7 == -1 && true) ///////////////////////////////////////////// -// Matching various function definitions +// Default Types ///////////////////////////////////////////// -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.function entity.name.function */ -(int * a) -/*^^^^^^^ meta.function.parameters meta.group */ -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} +auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} +typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) -MACRO1 void * MACRO2 myfuncname () { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ - } - - struct Args { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - }; +///////////////////////////////////////////// +// Storage Keywords +///////////////////////////////////////////// - struct Args args; -/* ^ keyword.declaration */ -/* ^ - entity */ +register static inline extern register thread_local _Thread_local _Noreturn noreturn +const volatile restrict _Atomic _Alignas(4) -} -static const uint32_t * const MACRO funcname(); -/* ^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ +///////////////////////////////////////////// +// Functions +///////////////////////////////////////////// -static constexpr int bar = 1; -/* ^ storage.modifier */ +test(5, 10, 15, 20); +h(f(5) - g(6)); -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() -{ - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ +int main(int argc, char const* argv[]) { + int out = in("abcdefg"); } -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ +int b = main(argc); -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ +static extern int* +test( + const uint64_t a, + typeof(b) b +); ///////////////////////////////////////////// -// Test function call in function parameters +// Control Flow ///////////////////////////////////////////// -static string foo(bar() + ';'); -/* ^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^ entity.name.function */ -/* ^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ string */ -/* ^ -string */ - -func_call(foo -/*^^^^^^^^^^^ meta.function-call */ -/* ^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -); -/* <- meta.function-call meta.group punctuation.section.group.end */ +void fun(int const a[]) { + while (true) { + do { + for (int i = 0; i < 12; ++i) { + switch (i) + { + case 0: + goto exit; + case 1: + case 2 + 3: + if (a + b < i) {} + else if (b == -1) { + continue; + } + break; + default: + continue; + } + } + } while (a > b); + } -///////////////////////////////////////////// -// Invalid -///////////////////////////////////////////// -) -/* <- invalid.illegal.stray-bracket-end */ +exit: + return; } -/* <- invalid.illegal.stray-bracket-end */ ///////////////////////////////////////////// -// Includes +// Data Structures ///////////////////////////////////////////// -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ +struct A; enum B; union C; -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif +enum B +{ + kTest1, + kTest2 = kTest1 + 1, + kTest3, +}myEnum; -static const unsigned char image_png[] = { -#embed -/* <- keyword.control.import.include */ +const volatile struct A +{ + int a1; + char a3[12]; + void* h5; + enum B out; }; + +union MACRO myUnion { + struct A { + int f; + } s1; + struct B { + int f2; + } s2; + void* ptr; + int a, *ptr2; }; -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -///////////////////////////////////////////// -// Numeric Constants -///////////////////////////////////////////// - -dec0 = 0; -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1234567890f; -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec3 = 1234567890L; -/* ^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec4 = 1234567890ul; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec5 = 1234567890Lu; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec6 = 1234567890LLU; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec7 = 1234567890uLL; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec8 = 1'234_567'890s0f; -/* ^^^^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec9 = 2'354'202'076LL; -/* ^^^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct1 = 01234567; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -oct2 = 01234567L; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct3 = 01234567LL; -/* ^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct4 = 01234567ulL; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct5 = 01284967Z0L; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^^^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct6 = 014'70; -/* ^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x0+0xFL+0xaull+0xallu+0xfu+0x'f'12_4uz; -/* ^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic - constant.c */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex3 = 0xA7'45'8C'38; -/* ^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -bin1 = 0b010110; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin2 = 0B010010; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin3 = 0b1001'1101'0010'1100; -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c */ -/* ^ constant.numeric.value.c */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ +int test() { + union C myunion; + myunion.s2.f = 20; +} +typedef struct { + myCustomType* a; +} b; ///////////////////////////////////////////// -// Control Keywords +// Attributes and Declspec ///////////////////////////////////////////// -int control_keywords() -{ - if (x < 5) - /* <- keyword.control */ - {} - else - /* <- keyword.control */ - {} - - switch (x) - /* <- keyword.control */ - { - case 1: - /* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ - default: - /* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ - } - do - /* <- keyword.control */ - { - if (y == 3) - continue; - /* <- keyword.control.flow.continue */ - } while (y < x); - /*^ keyword.control */ +__declspec(align(5)) struct Test { + int a; + int b; + int c; +}; +void __declspec(dllimport) importedFn() const; +__declspec(property(get=5, put=10)) void runForever(); - switch (a) { - case 1: break; - /* ^ punctuation.separator */ - case 100 - 10: break; - /* ^ punctuation.separator */ - default: break; - /* ^ punctuation.separator */ - } - goto label; - /* <- keyword.control.flow.goto */ +void on_load() __attribute__((constructor, visibility("hidden"))) {} -label: - return 123; - /* <- keyword.control.flow.return */ -} From c7b239addbd72a6492a418b4565e7ca50b95cc0d Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:14:01 -0600 Subject: [PATCH 03/66] \9 shouldn't be a valid escape --- C++/C.sublime-syntax | 2 +- C++/syntax_test_c.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 5b22d3723a..c6d8a179d3 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -40,7 +40,7 @@ contexts: # Basic Objects string.escape: - - match: \\([abfnrtv\\'\"?]|[eE]|\d{1,3}|x[0-9A-Fa-f]+|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}) + - match: \\([abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x[0-9A-Fa-f]+|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}) scope: constant.character.escape.c - match: \\. scope: invalid.illegal.unknown-escape.c diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index dbbf40d5e0..d2dd8238bf 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -35,7 +35,7 @@ a,b = b.c; // Strings ///////////////////////////////////////////// "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' -"\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\9" +"\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" '\u\w\x\y\z\/' "%ms %as %*[, ]" From ab7b69155915b931b77ab0421cf21b0f4d052d9e Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:33:55 -0600 Subject: [PATCH 04/66] Fix some issues pointed out --- C++/C.sublime-syntax | 146 +++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 67 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index c6d8a179d3..af911c94c8 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -3,6 +3,7 @@ # http://www.sublimetext.com/docs/3/syntax.html name: C scope: source.c +version: 2 file_extensions: - c @@ -13,34 +14,11 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \bc\b(?![#+]) .*? -\*- # editorconfig ) -variables: - identifier: \b[[:alpha:]_][[:alnum:]_]*\b - likely_macro: \b[[:upper:]][[:upper:][:digit:]_]+\b - - bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' - oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' - dec_suffix: '[a-zA-Z_][[:alnum:]_]*' - hex_suffix: '[g-zG-Z_][[:alnum:]_]*' - double_suffix: '[fFlL]' - float_suffix: '[fF]' - integer_suffix: '(?:(?:ll|LL)(?!\s*[lL])|(?i)(?:u(?!\w*u)|l(?!\w*l)|i(?!\w*[ij])|j(?!\w*[ij])))+\b' - dec_exponent: '(?:[eE][-+]?\d*)' - hex_exponent: '(?:[pP][-+]?\d*)' - contexts: - # Helpers - - pop-immediately: - - match: "" - pop: true - else-pop: - - match: (?=\S) - pop: true - # Basic Objects string.escape: - - match: \\([abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x[0-9A-Fa-f]+|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}) + - match: \\([abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x\h+|u\h{4}|U\h{8}) scope: constant.character.escape.c - match: \\. scope: invalid.illegal.unknown-escape.c @@ -55,29 +33,30 @@ contexts: (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier (\[[^\]]+\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type scope: constant.other.placeholder.c + string.double: + - meta_scope: string.quoted.double.c + - match: \" + scope: punctuation.definition.string.end.c + pop: 1 + - include: string.escape + - include: string.format + string.single: + - meta_scope: string.quoted.single.c + - match: \' + scope: punctuation.definition.string.end.c + pop: 1 + - include: string.escape string: - match: (L|u8?|U)?(\") captures: 1: storage.type.string.c 2: punctuation.definition.string.begin.c - push: - - meta_scope: string.quoted.double.c - - include: string.escape - - include: string.format - - match: \" - scope: punctuation.definition.string.end.c - pop: true + push: string.double - match: (L?)(\') captures: 1: storage.type.string.c 2: punctuation.definition.string.begin.c - push: - - meta_scope: string.quoted.double.c - - include: string.escape - - match: \' - scope: punctuation.definition.string.end.c - pop: true - + push: string.single operator.assignment: - match: = scope: keyword.operator.assignment.c @@ -90,13 +69,13 @@ contexts: - match: \&\&|\|\| scope: keyword.operator.logical.c operator.bitwise: - - match: \&|\||\^|~|<<|>>|>> + - match: \&|\||\^|~|<<|>> scope: keyword.operator.bitwise.c operator.comparison: - match: ==|!=|<=|>=|<|> scope: keyword.operator.comparison.c operator.word: - - match: \bsizeof|_Alignof|alignof|offsetof\b + - match: \b(?:sizeof|_Alignof|alignof|offsetof)\b scope: keyword.operator.word.c operator.ternary: - match: '\?|\:' @@ -212,6 +191,9 @@ contexts: 2: constant.numeric.suffix.c 3: invalid.illegal.numeric.suffix.c + constant.malformed: + - match: \b(?i:true|false|null|__func__|__cplusplus)\b + scope: invalid.illegal.malformed-constant-language.c constant: - match: \b(true|TRUE)\b scope: constant.language.boolean.true.c @@ -219,18 +201,19 @@ contexts: scope: constant.language.boolean.false.c - match: \bNULL\b scope: constant.language.null.c - - match: \b__(func)__\b + - match: \b__func__\b scope: constant.language.c - match: \b(__[a-zA-Z_]+__|__cplusplus)\b scope: support.constant.c - match: '\bk[A-Z]\w*\b' scope: constant.other.variable.mac-classic.c + - include: constant.malformed declspec: - meta_scope: meta.group.c - - match: \b(allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)\b + - match: \b{{declspec_item}}\b scope: constant.other.c - - match: \b(align|allocate|code_seg|spectre|uuid|deprecated)\s*(\() + - match: \b{{declspec_func}}\s*(\() captures: 1: storage.modifier.c 2: punctuation.section.group.begin.c @@ -254,9 +237,9 @@ contexts: - meta_scope: meta.group.c meta.attribute.c # too many attributes, these are the ones commonly used - include: punctuation.comma - - match: \b(noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)\b + - match: \b{{attribute_item}}\b scope: constant.other.c - - match: \b(aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)\s*(\() + - match: \b{{attribute_func}}\s*(\() captures: 1: storage.modifier.c 2: punctuation.section.group.begin.c @@ -356,7 +339,7 @@ contexts: scope: entity.name.constant.c push: - match: (?=,|}) - pop: true + pop: 1 - include: expression - include: punctuation.comma - match: \} @@ -368,7 +351,7 @@ contexts: - match: ({{identifier}})\s*(?=;) captures: 1: entity.name.enum.forward-decl.c - pop: true + pop: 1 - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) captures: 1: entity.name.enum.c @@ -386,7 +369,7 @@ contexts: - match: ({{identifier}})\s*(?=;) captures: 1: entity.name.enum.forward-decl.c - pop: true + pop: 1 - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) captures: 1: entity.name.struct.c @@ -404,7 +387,7 @@ contexts: - match: ({{identifier}})\s*(?=;) captures: 1: entity.name.enum.forward-decl.c - pop: true + pop: 1 - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) captures: 1: entity.name.union.c @@ -437,7 +420,7 @@ contexts: - match: ({{identifier}})\s*(?=,|\)) captures: 1: variable.function.c - pop: true + pop: 1 - include: expression generic: @@ -482,13 +465,13 @@ contexts: - meta_scope: meta.function.c meta.block.c - match: \} scope: punctuation.section.block.end.c - pop: true + pop: 1 - include: expression - include: function.label function.tail: - meta_scope: meta.function.c - match: ; - pop: true + pop: 1 - match: \{ scope: punctuation.section.block.begin set: function.body @@ -504,7 +487,7 @@ contexts: 1: variable.parameter.c push: - match: (?=[,\)]|$) - pop: true + pop: 1 - include: enclosure - match: ({{identifier}})\b(?=[,\)]|$) @@ -526,7 +509,7 @@ contexts: push: - match: ; scope: punctuation.terminator.c - pop: true + pop: 1 - include: expression main: @@ -540,7 +523,7 @@ contexts: scope: punctuation.separator.continuation.c push: - match: ^ - pop: true + pop: 1 # Everything after this comment needs to be rewritten so don't pay too much mind @@ -556,19 +539,18 @@ contexts: scope: keyword.control.import.c set: - match: ^ - pop: true + pop: 1 - match: \belse|endif\b scope: keyword.control.import.c - pop: true + pop: 1 - match: \b(warning|error)\b scope: meta.preprocessor.diagnostic.c keyword.control.import.error.c set: - meta_content_scope: meta.preprocessor.diagnostic.c string.quoted.c - include: string - - match: $ - pop: true + - include: eol-pop - match: \binclude(_next)?\b scope: meta.preprocessor.include.c keyword.control.import.include.c @@ -578,28 +560,28 @@ contexts: push: - meta_scope: string.quoted.c - match: ">" - pop: true + pop: 1 - match: \" push: - meta_scope: string.quoted.c - match: \" - pop: true + pop: 1 - match: ^ - pop: true + pop: 1 - match: \bundef|pragma\b scope: keyword.control.import.c set: - meta_content_scope: meta.preprocessor.c - match: ^ - pop: true + pop: 1 - match: \bdefine\b scope: keyword.control.import.c set: - match: ^ - pop: true + pop: 1 preprocessor.comment: - match: /\* scope: punctuation.definition.comment.c @@ -609,7 +591,7 @@ contexts: scope: punctuation.separator.continuation.c - match: \*/ scope: punctuation.definition.comment.c - pop: true + pop: 1 - match: // scope: punctuation.definition.comment.c push: @@ -617,7 +599,37 @@ contexts: - match: '(\\)$\n' captures: 1: punctuation.separator.continuation.c - pop: true + pop: 1 - match: (?=\n) - pop: true + pop: 1 + + # Helpers + + pop-immediately: + - match: "" + pop: 1 + else-pop: + - match: (?=\S) + pop: 1 + eol-pop: + - match: $\n? + pop: 1 + +variables: + identifier: \b[[:alpha:]_][[:alnum:]_]*\b + likely_macro: \b[:upper:][[:upper:][:digit:]_]+\b + + bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' + oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' + dec_suffix: '[a-zA-Z_][[:alnum:]_]*' + hex_suffix: '[g-zG-Z_][[:alnum:]_]*' + double_suffix: '[fFlL]' + float_suffix: '[fF]' + integer_suffix: '(?:(?:ll|LL)(?!\s*[lL])|(?i)(?:u(?!\w*u)|l(?!\w*l)|i(?!\w*[ij])|j(?!\w*[ij])))+\b' + dec_exponent: '(?:[eE][-+]?\d*)' + hex_exponent: '(?:[pP][-+]?\d*)' + declspec_item: '(allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' + declspec_func: '(align|allocate|code_seg|spectre|uuid|deprecated)' + attribute_item: '(noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' + attribute_func: '(aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' \ No newline at end of file From 074878326535cc7c2a991225091dd55db534785f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sat, 8 Feb 2025 14:33:40 -0600 Subject: [PATCH 05/66] - Add _Static_assert, static_assert, _Pragma word operators - Add digit separator `'` (C23) - Add scopes for __VA_ARGS__ and __VA_OPT__ - Give defined macro a `suport.macro.c` scope - Add #embed, #elifdef, and #elifndef directives - Add multi-line double-slashed comments via `\` - Fix some bugs --- C++/C.sublime-syntax | 226 +++++++++++++++++++++++++++---------------- 1 file changed, 141 insertions(+), 85 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index af911c94c8..84a60dc72e 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -46,6 +46,11 @@ contexts: scope: punctuation.definition.string.end.c pop: 1 - include: string.escape + string.angled: + - meta_scope: string.quoted.other.c + - match: \> + scope: punctuation.definition.string.end.c + pop: 1 string: - match: (L|u8?|U)?(\") captures: @@ -75,7 +80,7 @@ contexts: - match: ==|!=|<=|>=|<|> scope: keyword.operator.comparison.c operator.word: - - match: \b(?:sizeof|_Alignof|alignof|offsetof)\b + - match: \b(?:sizeof|_Alignof|alignof|offsetof|_Static_assert|static_assert|_Pragma)\b scope: keyword.operator.word.c operator.ternary: - match: '\?|\:' @@ -118,7 +123,7 @@ contexts: # decimal floats - match: |- (?x: - \b(\d+) + \b(\d(?:\d|'(?=[^']))*) (?: ( (\.) (?: @@ -160,7 +165,7 @@ contexts: 4: constant.numeric.suffix.c 5: invalid.illegal.numeric.suffix.c # binary integer (C23) - - match: \b(0[bB])([0-1]*)(?:({{integer_suffix}})|({{bin_suffix}}))? + - match: \b(0[bB])([01](?:[01]|'(?=[^']))*)?(?:({{integer_suffix}})|({{bin_suffix}}))? scope: meta.number.integer.binary.c captures: 1: constant.numeric.base.c @@ -168,7 +173,7 @@ contexts: 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c # hexadecimal integer - - match: \b(0[xX])(\h*)(?:({{integer_suffix}})|({{hex_suffix}}))? + - match: \b(0[xX])(\h(?:\h|'(?=[^']))*)?(?:({{integer_suffix}})|({{hex_suffix}}))? scope: meta.number.integer.hexadecimal.c captures: 1: constant.numeric.base.c @@ -176,7 +181,7 @@ contexts: 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c # octal integer - - match: \b(0)([0-7]+)(?:({{integer_suffix}})|({{oct_suffix}}))? + - match: \b(0)([0-7](?:[0-7]|'(?=[^']))*)(?:({{integer_suffix}})|({{oct_suffix}}))? scope: meta.number.integer.octal.c captures: 1: constant.numeric.base.c @@ -184,7 +189,7 @@ contexts: 3: constant.numeric.suffix.c 4: invalid.illegal.numeric.suffix.c # decimal integer - - match: \b(\d+)(?:({{integer_suffix}})|({{dec_suffix}}))? + - match: \b(\d(?:\d|'(?=[^']))*)(?:({{integer_suffix}})|({{dec_suffix}}))? scope: meta.number.integer.decimal.c captures: 1: constant.numeric.value.c @@ -192,14 +197,14 @@ contexts: 3: invalid.illegal.numeric.suffix.c constant.malformed: - - match: \b(?i:true|false|null|__func__|__cplusplus)\b + - match: \b(?i:true|false|null|nullptr|__cplusplus)\b scope: invalid.illegal.malformed-constant-language.c constant: - match: \b(true|TRUE)\b scope: constant.language.boolean.true.c - match: \b(false|FALSE)\b scope: constant.language.boolean.false.c - - match: \bNULL\b + - match: \b(NULL|nullptr)\b scope: constant.language.null.c - match: \b__func__\b scope: constant.language.c @@ -213,7 +218,7 @@ contexts: - meta_scope: meta.group.c - match: \b{{declspec_item}}\b scope: constant.other.c - - match: \b{{declspec_func}}\s*(\() + - match: \b({{declspec_func}})\s*(\() captures: 1: storage.modifier.c 2: punctuation.section.group.begin.c @@ -239,14 +244,14 @@ contexts: - include: punctuation.comma - match: \b{{attribute_item}}\b scope: constant.other.c - - match: \b{{attribute_func}}\s*(\() + - match: \b({{attribute_func}})\s*(\() captures: 1: storage.modifier.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis - match: \)\) scope: punctuation.section.group.end.c - pop: 2 + pop: 1 keyword.storage: - match: \bauto\b @@ -334,7 +339,6 @@ contexts: type.enum-body: - meta_content_scope: meta.block.c - - meta_include_prototype: false - match: \b{{identifier}}\b scope: entity.name.constant.c push: @@ -472,6 +476,7 @@ contexts: - meta_scope: meta.function.c - match: ; pop: 1 + - include: gnu-attribute - match: \{ scope: punctuation.section.block.begin set: function.body @@ -490,7 +495,7 @@ contexts: pop: 1 - include: enclosure - - match: ({{identifier}})\b(?=[,\)]|$) + - match: ({{identifier}})\s*(?=[,\)]|$) captures: 1: variable.parameter.c - include: expression @@ -505,103 +510,151 @@ contexts: - match: \b{{identifier}}\b statement: - - match: (?=\S) - push: - - match: ; - scope: punctuation.terminator.c - pop: 1 - - include: expression + - match: ; + scope: punctuation.terminator.c + pop: 1 + - include: expression main: - - include: preprocessor - include: function - - include: statement + - match: (?=\S) + push: statement prototype: - - include: preprocessor.comment - - match: \\$ + - include: comment + - include: preprocessor + + preprocessor.line-escape: + - match: \\$\n scope: punctuation.separator.continuation.c push: - match: ^ pop: 1 + preprocessor.include: + - meta_scope: meta.preprocessor.c + - match: \" + scope: punctuation.definition.string.begin.c + push: string.double + - match: \< + scope: punctuation.definition.string.begin.c + push: string.angled + - include: eol-pop + preprocessor.diagnostic: + - meta_scope: meta.preprocessor.diagnostic.c + - meta_content_scope: string.unquoted.c + - include: preprocessor.line-escape + - include: eol-pop + + preprocessor.define-body: + - match: '' + set: main + with_prototype: + - match: \b__VA_ARGS__\b + scope: constant.other.c + - match: \b__VA_OPT__\b + scope: keyword.operator.word.c + - match: \# + scope: keyword.operator.c + - include: preprocessor.line-escape + preprocessor.define-params: + - include: eol-pop + - match: \b{{identifier}}\b + scope: variable.parameter.c + - include: punctuation.comma + - include: operator.variadic + - match: \) + scope: punctuation.section.group.end.c + embed: preprocessor.define-body + escape: (?" - pop: 1 - - match: \" - push: - - meta_scope: string.quoted.c - - match: \" - pop: 1 + - match: ^\s*#\s*(error)\b + scope: keyword.control.import.error.c + push: preprocessor.diagnostic - - match: ^ - pop: 1 + - match: ^\s*#\s*(warning)\b + scope: keyword.control.import.warning.c + push: preprocessor.diagnostic - - match: \bundef|pragma\b - scope: keyword.control.import.c - set: - - meta_content_scope: meta.preprocessor.c - - match: ^ - pop: 1 + comment: + - match: // + scope: punctuation.definition.comment.c + push: + - meta_scope: comment.line.double-slash.c + - include: preprocessor.line-escape + - include: eol-pop - - match: \bdefine\b - scope: keyword.control.import.c - set: - - match: ^ - pop: 1 - preprocessor.comment: - match: /\* scope: punctuation.definition.comment.c push: - meta_scope: comment.block.c - - match: '\\$\n' - scope: punctuation.separator.continuation.c + - include: preprocessor.line-escape - match: \*/ scope: punctuation.definition.comment.c pop: 1 - - match: // - scope: punctuation.definition.comment.c - push: - - meta_scope: comment.line.double-slash.c - - match: '(\\)$\n' - captures: - 1: punctuation.separator.continuation.c - pop: 1 - - match: (?=\n) - pop: 1 + - match: \*/ + scope: invalid.illegal.stray-comment-end.c # Helpers @@ -614,6 +667,9 @@ contexts: eol-pop: - match: $\n? pop: 1 + consume-pop: + - match: . + pop: 1 variables: identifier: \b[[:alpha:]_][[:alnum:]_]*\b @@ -629,7 +685,7 @@ variables: dec_exponent: '(?:[eE][-+]?\d*)' hex_exponent: '(?:[pP][-+]?\d*)' - declspec_item: '(allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' - declspec_func: '(align|allocate|code_seg|spectre|uuid|deprecated)' - attribute_item: '(noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' - attribute_func: '(aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' \ No newline at end of file + declspec_item: '(?:allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' + declspec_func: '(?:align|allocate|code_seg|spectre|uuid|deprecated)' + attribute_item: '(?:noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' + From e09a040214210e16334aae90102f13d0aa62f43f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sat, 8 Feb 2025 14:36:15 -0600 Subject: [PATCH 06/66] Fix line escape in string --- C++/C.sublime-syntax | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 84a60dc72e..d5775eeaa6 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -35,6 +35,8 @@ contexts: scope: constant.other.placeholder.c string.double: - meta_scope: string.quoted.double.c + - meta_include_prototype: false + - include: preprocessor.line-escape - match: \" scope: punctuation.definition.string.end.c pop: 1 From 85a129e9d8fa88634fbe4ceb3e1da905947f26de Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sat, 8 Feb 2025 14:38:53 -0600 Subject: [PATCH 07/66] Update Syntax Test --- C++/syntax_test_c.c | 56 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index d2dd8238bf..07029dc276 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,13 +1,29 @@ // SYNTAX TEST "Packages/C++/C.sublime-syntax" +// Comment + +// My \ +Comment + +/* Foo + Bar + Baz*/ + +*/ + ///////////////////////////////////////////// // Numbers ///////////////////////////////////////////// 1234567890 +1'234'567'890 + 0x123456789abcdef +0x123'456'789'abc'def 012345670 +012'345'670 0b100110 +0b100'110 314lUJ 314uLLj 314iLu 314llI 314F 314f 3.14f 314.l 3.14L @@ -29,7 +45,7 @@ 1 > 2 >= 3 == 4 != 5 <= 6 < 7 !1 ? -2 : ~3 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 -sizeof(a) alignof(b) _Alignof(c) offsetof(c) +sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) a,b = b.c; ///////////////////////////////////////////// // Strings @@ -49,6 +65,8 @@ a,b = b.c; true TRUE false FALSE NULL __func__ __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +True False Null __CplusPlus + ///////////////////////////////////////////// // Enclosings ///////////////////////////////////////////// @@ -170,16 +188,46 @@ typedef struct { // Attributes and Declspec ///////////////////////////////////////////// - __declspec(align(5)) struct Test { int a; int b; int c; }; void __declspec(dllimport) importedFn() const; -__declspec(property(get=5, put=10)) void runForever(); +__declspec(property(get=10, put=10)) void runForever(); + +void on_load() __attribute__((constructor, visibility("hidden"))) { +} + +///////////////////////////////////////////// +// Preprocessor +///////////////////////////////////////////// + +#include +#include_next "file.h" + +#error Error Message \ +(this is an "error") +#warning Warning Message \ +(this is a "warning") + +#define FOO __declspec(dllimport) +#define BAR(x, y, ...) enum MyEnum ## x { \ + kEnumValue1 = y __VA_OPT__(,) \ + __VA_ARGS__ \ +}; -void on_load() __attribute__((constructor, visibility("hidden"))) {} +#if FOO +#ifndef FOO +#ifdef FOO +#elif FOO +#elifdef FOO +#elifndef FOO +#else +#endif +#undef FOO +#pragma FOO +#embed "file.txt" if_empty(0) From 0f0ac074876ae282ea19ff584630dae0818f8aeb Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:04:43 -0600 Subject: [PATCH 08/66] Add typedef entity (with fn pointer) and make function params highlight for fn pointer types in a typedef. --- C++/C.sublime-syntax | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index d5775eeaa6..b79884eea3 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -339,6 +339,19 @@ contexts: scope: punctuation.section.block.begin push: enclosure.block + type.typedef: + - match: \(\s*(\*)({{identifier}})\s*\)\s*(\() + captures: + 1: keyword.operator.c + 2: entity.name.type.typedef.c + 3: punctuation.section.group.begin.c + push: [function.params, pop-immediately] + + - match: ({{identifier}})\s*(?=;) + captures: + 1: entity.name.type.typedef.c + pop: 1 + - include: expression type.enum-body: - meta_content_scope: meta.block.c - match: \b{{identifier}}\b @@ -406,6 +419,9 @@ contexts: - match: (?=\S) fail: union type: + - match: \btypedef\b + scope: keyword.declaration.type.c + push: type.typedef - match: \benum\b scope: keyword.declaration.enum.c branch_point: enum @@ -445,12 +461,22 @@ contexts: - include: constant expression.call: - - match: \b({{identifier}})\s*(\() + - match: \b(?:({{std_funcs}}))\s*(\() + captures: + 1: variable.function.c support.function.std.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b(?:({{identifier}}))\s*(\() captures: 1: variable.function.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis expression: + # most likely function definition + - match: (?=^\s*{{identifier}}\s+{{identifier}}\s*\() + push: + - include: function + - include: else-pop - include: number - include: string - include: type @@ -488,8 +514,9 @@ contexts: - match: \) scope: punctuation.section.group.end.c set: function.tail + - include: keyword - - match: ({{identifier}})(?=\[) + - match: (? Date: Mon, 10 Feb 2025 11:05:11 -0600 Subject: [PATCH 09/66] Remove consume-pop --- C++/C.sublime-syntax | 3 --- 1 file changed, 3 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index b79884eea3..db3fe47659 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -696,9 +696,6 @@ contexts: eol-pop: - match: $\n? pop: 1 - consume-pop: - - match: . - pop: 1 variables: identifier: \b[[:alpha:]_][[:alnum:]_]*\b From f1abee331293daa866a726ef03d35c904fe5d5f1 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:05:20 -0600 Subject: [PATCH 10/66] Add std funcs --- C++/C.sublime-syntax | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index db3fe47659..adc7117d3f 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -714,4 +714,7 @@ variables: declspec_item: '(?:allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' declspec_func: '(?:align|allocate|code_seg|spectre|uuid|deprecated)' attribute_item: '(?:noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' + attribute_func: '(?:aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' + + std_funcs: '(?:assert|(?:exp(?:2|m1)|log(?:10|2|1p)|cbrt|hypot|erfc?|[lt]gamma|ceil|floor|trunc|l{0,2}round|f(?:absmod|max|min|dim)|c(?:abs|real|imag|arg|onj|proj|)|c?(?:exp|log|pow|sqrt|a?(?:sin|cos|tan)h?))[fl]?|abs|l{0,2}div|is(?:finite|inf|nan|normal|greater(?:equal)?|less(?:equal|greater)?|unordered|alnum|alpha|lower|upper|x?digit|cntrl|graph|space|blank|print|punct)(?:set|long)jmp|jmp_buf|signal|raise|va_(?:list|start|arg|copy|end)|std(?:in|out|err)|setv?buf|re(?:wind|move|name)|tmp(?:nam|file)(?:_s)?|f(?:(?:re)?open(?:_s)?|close|flush|wide|read|write|tell|getpos|seek|setpos|error)|gets_s|f?(?:get|put)?(?:c|s|char)|v?f?s?w?scanf(?:s|sn)?w?printf(?:_s)?|abort|(?:(?:at_)?quick_|at)?exit|_Exit|unreachable|system|getenv(?:_s)?|to(?:lower|upper)|ato(?:f|i|l|ll)|str(?:to(?:u?ll?|f|l?d)|from[dfl]|(?:n?cpy|cat|nlen|tok|error(?:len)?)(?:_s)?|xfrm|n?dup|n?cmp|coll|r?chr|c?spn|pbrk|str|len)|mem(?:chr|cmp|set(?:_explicit|_s)?|(?:move|cpy)(?:_s)?|ccpy)|thrd_(?:create|equal|current|sleep|yield|exit|detach|join|success|timedout|busy|nomem|error)|(?:diff|mk|strf)?time|clock|timespec_get(?:res)?|(?:as)?ctime(?:_s)?|(?:gm|local)time(?:_[rs])?)' From 5497d8382adcbf3eeadc1cd7b8d326e574268d52 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:06:17 -0600 Subject: [PATCH 11/66] Syntax Test --- C++/syntax_test_c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 07029dc276..a458e6db26 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -184,6 +184,8 @@ typedef struct { myCustomType* a; } b; +typedef void(*func)(int param, int, char param2); + ///////////////////////////////////////////// // Attributes and Declspec ///////////////////////////////////////////// @@ -200,6 +202,11 @@ void on_load() __attribute__((constructor, visibility("hidden"))) { } +int a = +int main(int argc, char const* argv[]) { + +} + ///////////////////////////////////////////// // Preprocessor ///////////////////////////////////////////// From a8887aba9e07a17deedfcc6dadf53f2aa8d12fdb Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 12:14:58 -0600 Subject: [PATCH 12/66] Add actual tests to the syntax test file --- C++/syntax_test_c.c | 1181 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 1031 insertions(+), 150 deletions(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index a458e6db26..da1bc69d7b 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,240 +1,1121 @@ -// SYNTAX TEST "Packages/C++/C.sublime-syntax" +/* SYNTAX TEST "Packages/User/NewC.sublime-syntax" */ -// Comment + // Comment +/* ^^^^^^^^^^ comment.line.double-slash.c */ +/* ^^ punctuation.definition.comment.c */ -// My \ -Comment + // My \ + Comment +/*^^^^^^^^^ comment.line.double-slash.c */ -/* Foo - Bar - Baz*/ + /* Foo Bar Baz*/ +/* ^^^^^^^^^^^^^^^^ comment.block.c */ +/* ^^ punctuation.definition.comment.c */ +/* ^^ punctuation.definition.comment.c */ -*/ + */ +/* ^^ invalid.illegal.stray-comment-end.c-2 */ ///////////////////////////////////////////// // Numbers ///////////////////////////////////////////// -1234567890 -1'234'567'890 + 1234567890 +/* ^^^^^^^^^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ + 1'234'567'890 +/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -0x123456789abcdef -0x123'456'789'abc'def -012345670 -012'345'670 -0b100110 -0b100'110 + 0x123456789abcdef +/* ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^^^^^^^^^^^^^^ constant.numeric.value.c-2 */ + 0x123'456'789'abc'def +/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c-2 */ + 012345670 +/* ^^^^^^^^^ meta.number.integer.octal.c-2 */ +/* ^ constant.numeric.base.c-2 */ +/* ^^^^^^^^ constant.numeric.value.c-2 */ + 012'345'670 +/* ^^^^^^^^^^^ meta.number.integer.octal.c-2 */ +/* ^ constant.numeric.base.c-2 */ +/* ^^^^^^^^^^ constant.numeric.value.c-2 */ + 0b100110 +/* ^^^^^^^^ meta.number.integer.binary.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^^^^^ constant.numeric.value.c-2 */ + 0b100'110 +/* ^^^^^^^^^ meta.number.integer.binary.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^^^^^^ constant.numeric.value.c-2 */ -314lUJ 314uLLj 314iLu 314llI 314F 314f -3.14f 314.l 3.14L -314e15 3.14e-15 -0xdead.beefp+7f -012345670 0314llU -0b10 0b10iLu + 314lUJ 314uLLj 314iLu 314llI 314F 314f +/* ^^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^ constant.numeric.suffix.c-2 */ +/* ^^^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^^ constant.numeric.suffix.c-2 */ +/* ^^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^ constant.numeric.suffix.c-2 */ +/* ^^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^ constant.numeric.suffix.c-2 */ +/* ^^^^ meta.number.float.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ +/* ^^^^ meta.number.float.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ + 3.14f 314.l 3.14L +/* ^^^^^ meta.number.float.decimal.c-2 */ +/* ^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ +/* ^^^^^ meta.number.float.decimal.c-2 */ +/* ^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ +/* ^^^^^ meta.number.float.decimal.c-2 */ +/* ^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ + 314e15 3.14e-15 +/* ^^^^^^ meta.number.float.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^^^^^^ meta.number.float.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ + 0xdead.beefp+7f +/* ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^^^^^^^^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ + 012345670 0314llU +/* ^^^^^^^^^ meta.number.integer.octal.c-2 */ +/* ^ constant.numeric.base.c-2 */ +/* ^^^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^ meta.number.integer.octal.c-2 */ +/* ^ constant.numeric.base.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^ constant.numeric.suffix.c-2 */ + 0b10 0b10iLu +/* ^^^^ meta.number.integer.binary.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^ constant.numeric.value.c-2 */ +/* ^^^^^^^ meta.number.integer.binary.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^ constant.numeric.value.c-2 */ +/* ^^^ constant.numeric.suffix.c-2 */ -0271828 0b10410 0xbag50 314a123 -314Ll 314lul 314iJ 314.ll 314.lf -0x314.1p5af 0b10e20 314e+30llu + 0271828 0b10410 0xbag50 314a123 +/* ^^^^^^^ meta.number.integer.octal.c-2 */ +/* ^ constant.numeric.base.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^ meta.number.integer.binary.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^ constant.numeric.value.c-2 */ +/* ^^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^ meta.number.integer.hexadecimal.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^ constant.numeric.value.c-2 */ +/* ^^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^^ invalid.illegal.numeric.suffix.c-2 */ + 314Ll 314lul 314iJ 314.ll 314.lf +/* ^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^ meta.number.integer.decimal.c-2 */ +/* ^^^ constant.numeric.value.c-2 */ +/* ^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^ meta.number.float.decimal.c-2 */ +/* ^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ +/* ^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^ meta.number.float.decimal.c-2 */ +/* ^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ +/* ^ invalid.illegal.numeric.suffix.c-2 */ + 0x314.1p5af 0b10e20 314e+30llu +/* ^^^^^^^^^^^ meta.number.float.hexadecimal.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^^^^^^ constant.numeric.value.c-2 */ +/* ^ punctuation.separator.decimal.c-2 */ +/* ^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^ meta.number.integer.binary.c-2 */ +/* ^^ constant.numeric.base.c-2 */ +/* ^^ constant.numeric.value.c-2 */ +/* ^^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^^^^ meta.number.float.decimal.c-2 */ +/* ^^^^^^^ constant.numeric.value.c-2 */ +/* ^ constant.numeric.suffix.c-2 */ +/* ^^ invalid.illegal.numeric.suffix.c-2 */ ///////////////////////////////////////////// // Operators ///////////////////////////////////////////// -1 + 2 - 3 * 4 / 5 % 6 -1 | 2 & 3 ^ 4 >> 5 << 6 -1 > 2 >= 3 == 4 != 5 <= 6 < 7 -!1 ? -2 : ~3 -0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 -sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) -a,b = b.c; + 1 + 2 - 3 * 4 / 5 % 6 +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ + 1 | 2 & 3 ^ 4 >> 5 << 6 +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.bitwise.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.bitwise.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.bitwise.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.bitwise.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.bitwise.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.comparison.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.comparison.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.comparison.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.comparison.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ + !1 ? -2 : ~3 +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.ternary.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.ternary.c-2 */ +/* ^ keyword.operator.bitwise.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^ keyword.operator.assignment.augmented.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^ keyword.operator.assignment.augmented.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +/* ^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ + a,b = b.c; +/* ^ punctuation.separator.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^ punctuation.accessor.c-2 */ +/* ^ punctuation.terminator.c-2 */ + ///////////////////////////////////////////// // Strings ///////////////////////////////////////////// -"abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' -"\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" -'\u\w\x\y\z\/' -"%ms %as %*[, ]" -"314 \ - 159" + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +/* ^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ storage.type.string.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^^ string.quoted.double.c-2 */ +/* ^^ storage.type.string.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ storage.type.string.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ storage.type.string.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^ string.quoted.single.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^ string.quoted.single.c-2 */ +/* ^ storage.type.string.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ + '\u\w\x\y\z\/' +/* ^^^^^^^^^^^^^^ string.quoted.single.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ + "%ms %as %*[, ]" +/* ^^^^^^^^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^^^ constant.other.placeholder.c */ +/* ^^^ constant.other.placeholder.c */ +/* ^^^^^^ constant.other.placeholder.c */ +/* ^ punctuation.definition.string.end.c-2 */ + "314 \ +/* ^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.separator.continuation.c-2 */ + 159" +/*^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ ///////////////////////////////////////////// // Constants ///////////////////////////////////////////// -true TRUE false FALSE NULL __func__ -__FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus + true TRUE false FALSE NULL __func__ +/* ^^^^ constant.language.boolean.true.c-2 */ +/* ^^^^ constant.language.boolean.true.c-2 */ +/* ^^^^^ constant.language.boolean.false.c-2 */ +/* ^^^^^ constant.language.boolean.false.c-2 */ +/* ^^^^ constant.language.null.c-2 */ +/* ^^^^^^^^ constant.language.c-2 */ + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +/* ^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^^^^ support.constant.c-2 */ -True False Null __CplusPlus + True False Null __CplusPlus +/* ^^^^ invalid.illegal.malformed-constant-language.c-2 */ +/* ^^^^^ invalid.illegal.malformed-constant-language.c-2 */ +/* ^^^^ invalid.illegal.malformed-constant-language.c-2 */ +/* ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c-2 */ ///////////////////////////////////////////// // Enclosings ///////////////////////////////////////////// -[a, b, c] -{1, 2, 3} -(6 - 7 == -1 && true) + [a, b, c] +/* ^^^^^^^^^ meta.brackets.square.c-2 */ +/* ^ punctuation.section.brackets.begin */ +/* ^ punctuation.separator.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^ punctuation.section.brackets.end */ + {1, 2, 3} +/* ^^^^^^^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.begin */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.block.end */ + (6 - 7 == -1 && true) +/* ^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.logical.c-2 */ +/* ^^^^ constant.language.boolean.true.c-2 */ +/* ^ punctuation.section.group.end */ ///////////////////////////////////////////// // Default Types ///////////////////////////////////////////// -auto void char short int long float double signed unsigned _Complex _Imaginary _Bool -size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t -uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t -uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t -uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +/* ^^^^ storage.type.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^^ storage.type.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^^ storage.type.c-2 */ +/* ^^^^^^ storage.type.c-2 */ +/* ^^^^^^ storage.type.c-2 */ +/* ^^^^^^^^ storage.type.c-2 */ +/* ^^^^^^^^ storage.type.c-2 */ +/* ^^^^^^^^^^ storage.type.c-2 */ +/* ^^^^^ storage.type.c-2 */ + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +/* ^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^ support.type.stdint.c-2 */ + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +/* ^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^ support.type.stdint.c-2 */ + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +/* ^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ ///////////////////////////////////////////// // Storage Keywords ///////////////////////////////////////////// -register static inline extern register thread_local _Thread_local _Noreturn noreturn -const volatile restrict _Atomic _Alignas(4) + register static inline extern register thread_local _Thread_local _Noreturn noreturn +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ + const volatile restrict _Atomic _Alignas(4) +/* ^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ ///////////////////////////////////////////// // Functions ///////////////////////////////////////////// -test(5, 10, 15, 20); -h(f(5) - g(6)); + test(5, 10, 15, 20); +/* ^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^^^^ variable.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ punctuation.terminator.c-2 */ + h(f(5) - g(6)); +/* ^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^^^ meta.group.c-2 */ +/* ^ variable.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^^^^ meta.group.c-2 */ +/* ^ variable.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ -int main(int argc, char const* argv[]) { - int out = in("abcdefg"); -} + int main(int argc, char const* argv[]) { +/* ^^^ storage.type.c-2 */ +/* ^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^^^^ variable.parameter.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^^ storage.modifier.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^^^^ variable.parameter.c-2 */ +/* ^^ meta.brackets.square.c-2 */ +/* ^ punctuation.section.brackets.begin */ +/* ^ punctuation.section.brackets.end */ +/* ^^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ + int out = in("abcdefg"); +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^^ variable.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ punctuation.terminator.c-2 */ + } +/*^^^ meta.function.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end.c-2 */ -int b = main(argc); + int b = main(argc); +/* ^^^ storage.type.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^^^^^^^^^ meta.group.c-2 */ +/* ^^^^ variable.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ punctuation.terminator.c-2 */ -static extern int* -test( - const uint64_t a, - typeof(b) b -); + static extern int* +/* ^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^ storage.modifier.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ + test( +/* ^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ + const uint64_t a, +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ support.type.stdint.c-2 */ +/* ^ variable.parameter.c-2 */ +/* ^ punctuation.separator.c-2 */ + typeof(b) b +/*^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ +/* ^ variable.parameter.c-2 */ + ); +/*^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ ///////////////////////////////////////////// // Control Flow ///////////////////////////////////////////// -void fun(int const a[]) { - while (true) { - do { - for (int i = 0; i < 12; ++i) { - switch (i) - { - case 0: - goto exit; - case 1: - case 2 + 3: - if (a + b < i) {} - else if (b == -1) { + void fun(int const a[]) { + while (true) { +/*^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ +/* ^^^^^ keyword.control.c-2 */ +/* ^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^^^^ constant.language.boolean.true.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ meta.block.c-2 punctuation.section.block.begin */ + do { +/*^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^ keyword.control.c-2 */ +/* ^ meta.block.c-2 punctuation.section.block.begin */ + for (int i = 0; i < 12; ++i) { +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^ keyword.control.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^^^ storage.type.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.terminator.c-2 */ +/* ^ keyword.operator.comparison.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.terminator.c-2 */ +/* ^^ keyword.operator.arithmetic.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ meta.block.c-2 punctuation.section.block.begin */ + switch (i) +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^^^ keyword.control.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.section.group.end */ + { +/*^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^ meta.block.c-2 punctuation.section.block.begin */ + case 0: +/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^ keyword.control.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.ternary.c-2 */ + goto exit; +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^ keyword.control.flow.goto.c-2 */ +/* ^ punctuation.terminator.c-2 */ + case 1: +/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^ keyword.control.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.ternary.c-2 */ + case 2 + 3: +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^ keyword.control.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.ternary.c-2 */ + if (a + b < i) {} +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^ keyword.control.c-2 */ +/* ^^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ keyword.operator.comparison.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^^ meta.block.c-2 */ +/* ^ punctuation.section.block.begin */ +/* ^ punctuation.section.block.end */ + else if (b == -1) { +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^ keyword.control.c-2 */ +/* ^^ keyword.control.c-2 */ +/* ^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^^ keyword.operator.assignment.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ meta.block.c-2 punctuation.section.block.begin */ + continue; +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^^^^^ keyword.control.flow.continue.c-2 */ +/* ^ punctuation.terminator.c-2 */ + } +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end */ + break; +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^^ keyword.control.flow.break.c-2 */ +/* ^ punctuation.terminator.c-2 */ + default: +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^^^^ keyword.control.c-2 */ +/* ^ keyword.operator.ternary.c-2 */ continue; +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^^^^^^^^ keyword.control.flow.continue.c-2 */ +/* ^ punctuation.terminator.c-2 */ } - break; - default: - continue; +/*^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end */ } - } - } while (a > b); - } +/*^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end */ + } while (a > b); +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 */ +/*^^^^^^^^^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^^^^^ keyword.control.c-2 */ +/* ^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ keyword.operator.comparison.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ punctuation.terminator.c-2 */ + } +/*^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end */ -exit: - return; -} + exit: +/*^^^^^^^ meta.function.c-2 meta.block.c-2 */ +/* ^^^^ entity.name.label.c-2 */ +/* ^ punctuation.separator.c-2 */ + return; +/*^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ +/* ^^^^^^ keyword.control.flow.return.c-2 */ +/* ^ punctuation.terminator.c-2 */ + } +/*^^^ meta.function.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end.c-2 */ ///////////////////////////////////////////// // Data Structures ///////////////////////////////////////////// -struct A; enum B; union C; + struct A; enum B; union C; +/* ^^^^^^^^ meta.struct.c-2 */ +/* ^^^^^^ keyword.declaration.struct.c-2 */ +/* ^ entity.name.enum.forward-decl.c-2 */ +/* ^ punctuation.terminator.c-2 */ +/* ^^^^^^ meta.enum.c-2 */ +/* ^^^^ keyword.declaration.enum.c-2 */ +/* ^ entity.name.enum.forward-decl.c-2 */ +/* ^ punctuation.terminator.c-2 */ +/* ^^^^^^^ meta.union.c-2 */ +/* ^^^^^ keyword.declaration.union.c-2 */ +/* ^ entity.name.enum.forward-decl.c-2 */ +/* ^ punctuation.terminator.c-2 */ -enum B -{ - kTest1, - kTest2 = kTest1 + 1, - kTest3, -}myEnum; + enum B +/* ^^^^^^ meta.enum.c-2 */ +/* ^^^^ keyword.declaration.enum.c-2 */ +/* ^ entity.name.enum.c-2 */ + { +/* ^ meta.enum.c-2 punctuation.section.block.begin.c-2 */ + kTest1, +/*^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^^^ entity.name.constant.c-2 */ +/* ^ punctuation.separator.c-2 */ + kTest2 = kTest1 + 1, +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^^^ entity.name.constant.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^^^^^ constant.other.variable.mac-classic.c */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ + kTest3, +/*^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^^^ entity.name.constant.c-2 */ +/* ^ punctuation.separator.c-2 */ + }myEnum; +/*^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end.c-2 */ +/* ^ punctuation.terminator.c-2 */ -const volatile struct A -{ - int a1; - char a3[12]; - void* h5; - enum B out; }; + const volatile struct A +/* ^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ meta.struct.c-2 */ +/* ^^^^^^ keyword.declaration.struct.c-2 */ +/* ^ entity.name.struct.c-2 */ + { +/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ + int a1; +/*^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.terminator.c-2 */ + char a3[12]; +/*^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^ meta.brackets.square.c-2 */ +/* ^ punctuation.section.brackets.begin */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.brackets.end */ +/* ^ punctuation.terminator.c-2 */ + void* h5; +/*^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ punctuation.terminator.c-2 */ + enum B out; }; +/*^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^ keyword.declaration.enum.c-2 */ +/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ punctuation.terminator.c-2 */ -union MACRO myUnion { - struct A { - int f; - } s1; - struct B { - int f2; - } s2; - void* ptr; - int a, *ptr2; -}; + union MACRO myUnion { +/* ^^^^^^^^^^^^^^^^^^^^ meta.union.c-2 */ +/* ^^^^^ keyword.declaration.union.c-2 */ +/* ^^^^^^^ entity.name.union.c-2 */ +/* ^ meta.block.c-2 meta.union.c-2 punctuation.section.block.begin.c-2 */ + struct A { +/*^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^^^^^^ meta.struct.c-2 */ +/* ^^^^^^ keyword.declaration.struct.c-2 */ +/* ^ entity.name.struct.c-2 */ +/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ + int f; +/*^^^^^^^^^^^^^^^^ meta.block.c-2 meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.terminator.c-2 */ + } s1; +/*^^^^^^^^^^^ meta.block.c-2 */ +/*^^^^^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ punctuation.terminator.c-2 */ + struct B { +/*^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^^^^^^ meta.struct.c-2 */ +/* ^^^^^^ keyword.declaration.struct.c-2 */ +/* ^ entity.name.struct.c-2 */ +/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ + int f2; +/*^^^^^^^^^^^^^^^^^ meta.block.c-2 meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.terminator.c-2 */ + } s2; +/*^^^^^^^^^^^ meta.block.c-2 */ +/*^^^^^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ punctuation.terminator.c-2 */ + void* ptr; +/*^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ punctuation.terminator.c-2 */ + int a, *ptr2; +/*^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ punctuation.terminator.c-2 */ + }; +/*^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ punctuation.terminator.c-2 */ -int test() { - union C myunion; - myunion.s2.f = 20; -} + int test() { +/* ^^^ storage.type.c-2 */ +/* ^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ + union C myunion; +/*^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ +/* ^^^^^ keyword.declaration.union.c-2 */ +/* ^ punctuation.terminator.c-2 */ + myunion.s2.f = 20; +/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ +/* ^ punctuation.accessor.c-2 */ +/* ^ punctuation.accessor.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.terminator.c-2 */ + } +/*^^^ meta.function.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end.c-2 */ -typedef struct { - myCustomType* a; -} b; + typedef struct { +/* ^^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^^^^^ meta.struct.c-2 */ +/* ^^^^^^ keyword.declaration.struct.c-2 */ +/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ + myCustomType* a; +/*^^^^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^ punctuation.terminator.c-2 */ + } b; +/*^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ entity.name.type.typedef.c-2 */ +/* ^ punctuation.terminator.c-2 */ -typedef void(*func)(int param, int, char param2); + typedef void(*func)(int param, int, char param2); +/* ^^^^^^^ keyword.declaration.type.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^ keyword.operator.c-2 */ +/* ^^^^ entity.name.type.typedef.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^^^^^ variable.parameter.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^^^ variable.parameter.c-2 */ +/* ^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ ///////////////////////////////////////////// // Attributes and Declspec ///////////////////////////////////////////// -__declspec(align(5)) struct Test { - int a; - int b; - int c; -}; -void __declspec(dllimport) importedFn() const; -__declspec(property(get=10, put=10)) void runForever(); + __declspec(align(5)) struct Test { +/* ^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^ meta.group.c-2 */ +/* ^^^^^ storage.modifier.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^^^^^^^^^ meta.struct.c-2 */ +/* ^^^^^^ keyword.declaration.struct.c-2 */ +/* ^^^^ entity.name.struct.c-2 */ +/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ + int a; +/*^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.terminator.c-2 */ + int b; +/*^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.terminator.c-2 */ + int c; +/*^^^^^^^^^^^^ meta.block.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^ punctuation.terminator.c-2 */ + }; +/*^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ punctuation.terminator.c-2 */ -void on_load() __attribute__((constructor, visibility("hidden"))) { + void __declspec(dllimport) importedFn() const; +/* ^^^^ storage.type.c-2 */ +/* ^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^ constant.other.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^^^^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^^ constant.other.c-2 */ + __declspec(property(get=10, put=10)) void runForever(); +/* ^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^ variable.parameter.c */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^ variable.parameter.c */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^^^^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ -} + void on_load() __attribute__((constructor, visibility("hidden"))) {} +/* ^^^^ storage.type.c-2 */ +/* ^^^^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 meta.attribute.c-2 */ +/* ^^^^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^^ constant.other.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^^^^^^^^^^ storage.modifier.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^^ punctuation.section.group.end.c-2 */ +/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ +/* ^ meta.block.c-2 punctuation.section.block.end.c-2 */ -int a = -int main(int argc, char const* argv[]) { + int a = +/* ^^^ storage.type.c-2 */ +/* ^ keyword.operator.assignment.c-2 */ + int main(int argc, char const* argv[]) { +/* ^^^ storage.type.c-2 */ +/* ^^^^ entity.name.function.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ +/* ^^^ storage.type.c-2 */ +/* ^^^^ variable.parameter.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^^ storage.type.c-2 */ +/* ^^^^^ storage.modifier.c-2 */ +/* ^ keyword.operator.arithmetic.c-2 */ +/* ^^^^ variable.parameter.c-2 */ +/* ^^ meta.brackets.square.c-2 */ +/* ^ punctuation.section.brackets.begin */ +/* ^ punctuation.section.brackets.end */ +/* ^^^ meta.function.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ -} + } +/*^^^ meta.function.c-2 meta.block.c-2 */ +/* ^ punctuation.section.block.end.c-2 */ ///////////////////////////////////////////// // Preprocessor ///////////////////////////////////////////// -#include -#include_next "file.h" - -#error Error Message \ -(this is an "error") -#warning Warning Message \ -(this is a "warning") + #include +/*^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^^^ keyword.control.import.c-2 */ +/* ^^^^^^^^^^ string.quoted.other.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ + #include_next "file.h" +/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^^^^^^^^ keyword.control.import.c-2 */ +/* ^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ + #error Error Message +/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c-2 */ +/*^^^^^^^^ keyword.control.import.error.c-2 */ +/* ^^^^^^^^^^^^^^ string.unquoted.c-2 */ + #error Error Message \ + (this is an "error") +/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c-2 string.unquoted.c-2 */ + #warning Warning Message +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c-2 */ +/*^^^^^^^^^^ keyword.control.import.warning.c-2 */ +/* ^^^^^^^^^^^^^^^^ string.unquoted.c-2 */ + #warning Warning Message \ + (this is a "warning") -#define FOO __declspec(dllimport) -#define BAR(x, y, ...) enum MyEnum ## x { \ - kEnumValue1 = y __VA_OPT__(,) \ - __VA_ARGS__ \ -}; + #define FOO __declspec(dllimport) +/*^^^^^^^^^ keyword.control.import.c-2 */ +/* ^^^ entity.name.macro.c-2 support.macro.c-2 */ +/* ^^^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^ constant.other.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +/*^^^^^^^^^ keyword.control.import.c-2 */ +/* ^^^ entity.name.macro.c-2 support.macro.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ variable.parameter.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^ variable.parameter.c-2 */ +/* ^ punctuation.separator.c-2 */ +/* ^^^ keyword.operator.variadic.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^ keyword.declaration.enum.c-2 */ +/* ^^ keyword.operator.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/* ^ punctuation.section.block.begin */ +/* ^^^^^^^^^^^ constant.other.variable.mac-classic.c */ +/* ^ keyword.operator.assignment.c-2 */ +/* ^^^^^^^^^^ keyword.operator.word.c-2 */ +/* ^^^ meta.group.c-2 */ +/* ^ punctuation.section.group.begin */ +/* ^ punctuation.separator.c-2 */ +/* ^ punctuation.section.group.end */ +/* ^^^^^^^^^^^ constant.other.c-2 */ +/* ^ punctuation.section.block.end */ +/* ^ punctuation.terminator.c-2 */ -#if FOO -#ifndef FOO -#ifdef FOO -#elif FOO -#elifdef FOO -#elifndef FOO -#else -#endif + #if FOO +/*^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^ keyword.control.import.c-2 */ + #ifndef FOO +/*^^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^^ keyword.control.import.c-2 */ + #ifdef FOO +/*^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^ keyword.control.import.c-2 */ + #elif FOO +/*^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^ keyword.control.import.c-2 */ + #elifdef FOO +/*^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^^^ keyword.control.import.c-2 */ + #elifndef FOO +/*^^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^^^^ keyword.control.import.c-2 */ + #else +/*^^^^^^^ keyword.control.import.c-2 */ + #endif +/*^^^^^^^^ keyword.control.import.c-2 */ -#undef FOO -#pragma FOO + #undef FOO +/*^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^ keyword.control.import.c-2 */ + #pragma FOO +/*^^^^^^^^^^^^^ meta.preprocessor.c-2 */ +/*^^^^^^^^^ keyword.control.import.c-2 */ -#embed "file.txt" if_empty(0) + #embed "file.txt" if_empty(0) +/*^^^^^^^^ keyword.control.import.c-2 */ +/* ^^^^^^^^^^ string.quoted.double.c-2 */ +/* ^ punctuation.definition.string.begin.c-2 */ +/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^ keyword.other.c-2 */ +/* ^ punctuation.section.group.begin.c-2 */ +/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ punctuation.section.group.end.c-2 */ From a60ca7000deb1384a6af4d6c1d73527838c21185 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 12:32:40 -0600 Subject: [PATCH 13/66] Fix name in syntax test --- C++/syntax_test_c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index da1bc69d7b..4da88d4a32 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,4 +1,4 @@ -/* SYNTAX TEST "Packages/User/NewC.sublime-syntax" */ +/* SYNTAX TEST "Packages/C++/C.sublime-syntax" */ // Comment /* ^^^^^^^^^^ comment.line.double-slash.c */ From 332929ed987cf984fd661ce6dc8fa0c5a70034cd Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 12:33:26 -0600 Subject: [PATCH 14/66] Reformat file to be top-down instead of bottom-up --- C++/C.sublime-syntax | 961 ++++++++++++++++++++++--------------------- 1 file changed, 481 insertions(+), 480 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index adc7117d3f..933556cd44 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -15,24 +15,397 @@ first_line_match: |- ) contexts: - # Basic Objects + main: + - include: function + - match: (?=\S) + push: statement - string.escape: - - match: \\([abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x\h+|u\h{4}|U\h{8}) - scope: constant.character.escape.c - - match: \\. - scope: invalid.illegal.unknown-escape.c - string.format: - - match: |- - (?x)% - (\d+\$)? # field (argument #) - [#0\- +']* # flags - [,;:_]? # separator character (AltiVec) - ((-?\d+)|\*(-?\d+\$)?)? # minimum field width - (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision - (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier - (\[[^\]]+\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type - scope: constant.other.placeholder.c + prototype: + - include: comment + - include: preprocessor + + ###[PREPROCESSOR]### + + comment: + - match: // + scope: punctuation.definition.comment.c + push: + - meta_scope: comment.line.double-slash.c + - include: preprocessor.line-escape + - include: eol-pop + + - match: /\* + scope: punctuation.definition.comment.c + push: + - meta_scope: comment.block.c + - include: preprocessor.line-escape + - match: \*/ + scope: punctuation.definition.comment.c + pop: 1 + - match: \*/ + scope: invalid.illegal.stray-comment-end.c + + preprocessor: + - include: preprocessor.line-escape + + - match: ^\s*#\s*((?:el)?if(?:n?def)?|undef|pragma)\b + scope: keyword.control.import.c + push: + - meta_scope: meta.preprocessor.c + - include: eol-pop + + - match: ^\s*#\s*(else|endif)\b + scope: keyword.control.import.c + + - match: ^\s*#\s*(include|include_next)\b + scope: keyword.control.import.c + push: preprocessor.include + + - match: ^\s*#\s*(embed)\b + scope: keyword.control.import.c + push: preprocessor.embed + + - match: ^\s*#\s*(define)\b + scope: keyword.control.import.c + push: preprocessor.define + + - match: ^\s*#\s*(undef)\b + scope: keyword.control.import.c + push: + - meta_scope: meta.preprocessor.c + - include: eol-pop + + - match: ^\s*#\s*(error)\b + scope: keyword.control.import.error.c + push: preprocessor.diagnostic + + - match: ^\s*#\s*(warning)\b + scope: keyword.control.import.warning.c + push: preprocessor.diagnostic + preprocessor.line-escape: + - match: \\$\n + scope: punctuation.separator.continuation.c + push: + - match: ^ + pop: 1 + preprocessor.include: + - meta_scope: meta.preprocessor.c + - match: \" + scope: punctuation.definition.string.begin.c + push: string.double + - match: \< + scope: punctuation.definition.string.begin.c + push: string.angled + - include: eol-pop + preprocessor.diagnostic: + - meta_scope: meta.preprocessor.diagnostic.c + - meta_content_scope: string.unquoted.c + - include: preprocessor.line-escape + - include: eol-pop + preprocessor.define: + - include: eol-pop + - match: \s*({{identifier}})\s*(\() + captures: + 1: entity.name.macro.c support.macro.c + 2: punctuation.section.group.begin.c + set: preprocessor.define-params + - match: \b{{identifier}}\b + scope: entity.name.macro.c support.macro.c + embed: preprocessor.define-body + escape: (? scope: punctuation.definition.string.end.c pop: 1 - string: - - match: (L|u8?|U)?(\") - captures: - 1: storage.type.string.c - 2: punctuation.definition.string.begin.c - push: string.double - - match: (L?)(\') - captures: - 1: storage.type.string.c - 2: punctuation.definition.string.begin.c - push: string.single + string.escape: + - match: \\([abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x\h+|u\h{4}|U\h{8}) + scope: constant.character.escape.c + - match: \\. + scope: invalid.illegal.unknown-escape.c + string.format: + - match: |- + (?x)% + (\d+\$)? # field (argument #) + [#0\- +']* # flags + [,;:_]? # separator character (AltiVec) + ((-?\d+)|\*(-?\d+\$)?)? # minimum field width + (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision + (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier + (\[[^\]]+\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type + scope: constant.other.placeholder.c + + operator: + - include: operator.accessor + - include: operator.assignment + - include: operator.arithmetic + - include: operator.logical + - include: operator.bitwise + - include: operator.comparison + - include: operator.word + - include: operator.ternary + - include: operator.variadic + - include: operator.increment-decrement operator.assignment: - match: = scope: keyword.operator.assignment.c @@ -99,27 +489,16 @@ contexts: operator.pointer: - match: \&|\* scope: keyword.operator.arithmetic.c - operator: - - include: operator.accessor - - include: operator.assignment - - include: operator.arithmetic - - include: operator.logical - - include: operator.bitwise - - include: operator.comparison - - include: operator.word - - include: operator.ternary - - include: operator.variadic - - include: operator.increment-decrement + punctuation: + - include: punctuation.comma + - include: punctuation.semicolon punctuation.comma: - match: ',' scope: punctuation.separator.c punctuation.semicolon: - match: ; scope: punctuation.terminator.c - punctuation: - - include: punctuation.comma - - include: punctuation.semicolon number: # decimal floats @@ -198,9 +577,6 @@ contexts: 2: constant.numeric.suffix.c 3: invalid.illegal.numeric.suffix.c - constant.malformed: - - match: \b(?i:true|false|null|nullptr|__cplusplus)\b - scope: invalid.illegal.malformed-constant-language.c constant: - match: \b(true|TRUE)\b scope: constant.language.boolean.true.c @@ -215,46 +591,17 @@ contexts: - match: '\bk[A-Z]\w*\b' scope: constant.other.variable.mac-classic.c - include: constant.malformed + constant.malformed: + - match: \b(?i:true|false|null|nullptr|__cplusplus)\b + scope: invalid.illegal.malformed-constant-language.c - declspec: - - meta_scope: meta.group.c - - match: \b{{declspec_item}}\b - scope: constant.other.c - - match: \b({{declspec_func}})\s*(\() - captures: - 1: storage.modifier.c - 2: punctuation.section.group.begin.c - push: enclosure.parenthesis - - - match: \b(property)\s*(\() - captures: - 1: storage.modifier.c - 2: punctuation.section.group.begin.c - push: - - match: \b(get|put)\b - scope: variable.parameter.c - - include: enclosure.parenthesis - - - include: expression - - match: \) - scope: punctuation.section.group.end.c - pop: 2 - - gnu-attribute: - - meta_scope: meta.group.c meta.attribute.c - # too many attributes, these are the ones commonly used - - include: punctuation.comma - - match: \b{{attribute_item}}\b - scope: constant.other.c - - match: \b({{attribute_func}})\s*(\() - captures: - 1: storage.modifier.c - 2: punctuation.section.group.begin.c - push: enclosure.parenthesis - - match: \)\) - scope: punctuation.section.group.end.c - pop: 1 - + keyword: + - include: keyword.control-flow + - include: keyword.control + - include: keyword.storage + - include: keyword.declaration + - include: keyword.asm + - include: keyword.type keyword.storage: - match: \bauto\b scope: storage.type.c @@ -273,419 +620,74 @@ contexts: 1: storage.modifier.c 2: punctuation.section.group.begin.c push: gnu-attribute - keyword.declaration: - - match: \b(struct|enum|union)\b - scope: keyword.declaration.c - - match: \btypedef\b - scope: keyword.declaration.type.c - keyword.control-flow: - - match: \bcontinue\b - scope: keyword.control.flow.continue.c - - match: \bbreak\b - scope: keyword.control.flow.break.c - - match: \breturn\b - scope: keyword.control.flow.return.c - - match: \bgoto\b - scope: keyword.control.flow.goto.c - keyword.control: - - match: \b(?:if|else|for|while|do|switch|case|default)\b - scope: keyword.control.c - keyword.asm: - - match: \b(asm|__asm|__asm__)\b - scope: keyword.control.import.c - keyword.type: - - match: \b(?:bool|void|char|short|int|long|float|double|signed|unsigned|_Complex|_Imaginary|_Bool)\b - scope: storage.type.c - - match: \b(u?intptr|u?intmax|ptrdiff|nullptr|max_align|size|u?int(_fast|_least)?(8|16|32|64))_t\b - scope: support.type.stdint.c - - match: \b(typeof_unqual|__typeof__|__typeof|typeof)\b - scope: keyword.declaration.type.c - keyword: - - include: keyword.control-flow - - include: keyword.control - - include: keyword.storage - - include: keyword.declaration - - include: keyword.asm - - include: keyword.type - - # More complicated structures - - enclosure.parenthesis: - - meta_scope: meta.group.c - - include: expression - - match: \) - scope: punctuation.section.group.end - pop: 1 - enclosure.brackets: - - meta_scope: meta.brackets.square.c - - include: expression - - match: \] - scope: punctuation.section.brackets.end - pop: 1 - enclosure.block: - - meta_scope: meta.block.c - - include: expression - - match: \} - scope: punctuation.section.block.end - pop: 1 - enclosure: - - match: \( - scope: punctuation.section.group.begin - push: enclosure.parenthesis - - match: \[ - scope: punctuation.section.brackets.begin - push: enclosure.brackets - - match: \{ - scope: punctuation.section.block.begin - push: enclosure.block - - type.typedef: - - match: \(\s*(\*)({{identifier}})\s*\)\s*(\() - captures: - 1: keyword.operator.c - 2: entity.name.type.typedef.c - 3: punctuation.section.group.begin.c - push: [function.params, pop-immediately] - - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.type.typedef.c - pop: 1 - - include: expression - type.enum-body: - - meta_content_scope: meta.block.c - - match: \b{{identifier}}\b - scope: entity.name.constant.c - push: - - match: (?=,|}) - pop: 1 - - include: expression - - include: punctuation.comma - - match: \} - scope: punctuation.section.block.end.c - pop: 1 - type.enum: - - meta_scope: meta.enum.c - - include: expression.call - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.enum.forward-decl.c - pop: 1 - - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) - captures: - 1: entity.name.enum.c - set: - - match: \{ - scope: meta.enum.c punctuation.section.block.begin.c - set: type.enum-body - - match: (?=\S) - fail: enum - - match: (?=\S) - fail: enum - type.struct: - - meta_scope: meta.struct.c - - include: expression.call - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.enum.forward-decl.c - pop: 1 - - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) - captures: - 1: entity.name.struct.c - set: - - match: \{ - scope: meta.struct.c punctuation.section.block.begin.c - set: enclosure.block - - match: (?=\S) - fail: struct - - match: (?=\S) - fail: struct - type.union: - - meta_scope: meta.union.c - - include: expression.call - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.enum.forward-decl.c - pop: 1 - - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) - captures: - 1: entity.name.union.c - set: - - match: \{ - scope: meta.union.c punctuation.section.block.begin.c - set: enclosure.block - - match: (?=\S) - fail: union - - match: (?=\S) - fail: union - type: - - match: \btypedef\b - scope: keyword.declaration.type.c - push: type.typedef - - match: \benum\b - scope: keyword.declaration.enum.c - branch_point: enum - branch: [type.enum, pop-immediately] - - match: \bstruct\b - scope: keyword.declaration.struct.c - branch_point: struct - branch: [type.struct, pop-immediately] - - match: \bunion\b - scope: keyword.declaration.union.c - branch_point: union - branch: [type.union, pop-immediately] - - generic.body: - - match: ':' - scope: keyword.operator.c - push: - - match: ({{identifier}})\s*(?=,|\)) - captures: - 1: variable.function.c - pop: 1 - - include: expression - - generic: - - match: \b(_Generic)\s*(\() - captures: - 1: keyword.declaration.c - 2: punctuation.section.group.begin.c - push: generic.body - - # Expression objects - - expression-identifiers: - - include: operator.word - - include: type - - include: keyword - - include: constant + keyword.declaration: + - match: \b(struct|enum|union)\b + scope: keyword.declaration.c + - match: \btypedef\b + scope: keyword.declaration.type.c + keyword.control-flow: + - match: \bcontinue\b + scope: keyword.control.flow.continue.c + - match: \bbreak\b + scope: keyword.control.flow.break.c + - match: \breturn\b + scope: keyword.control.flow.return.c + - match: \bgoto\b + scope: keyword.control.flow.goto.c + keyword.control: + - match: \b(?:if|else|for|while|do|switch|case|default)\b + scope: keyword.control.c + keyword.asm: + - match: \b(asm|__asm|__asm__)\b + scope: keyword.control.import.c + keyword.type: + - match: \b(?:bool|void|char|short|int|long|float|double|signed|unsigned|_Complex|_Imaginary|_Bool)\b + scope: storage.type.c + - match: \b(u?intptr|u?intmax|ptrdiff|nullptr|max_align|size|u?int(_fast|_least)?(8|16|32|64))_t\b + scope: support.type.stdint.c + - match: \b(typeof_unqual|__typeof__|__typeof|typeof)\b + scope: keyword.declaration.type.c - expression.call: - - match: \b(?:({{std_funcs}}))\s*(\() + declspec: + - meta_scope: meta.group.c + - match: \b{{declspec_item}}\b + scope: constant.other.c + - match: \b({{declspec_func}})\s*(\() captures: - 1: variable.function.c support.function.std.c + 1: storage.modifier.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis - - match: \b(?:({{identifier}}))\s*(\() + + - match: \b(property)\s*(\() captures: - 1: variable.function.c + 1: storage.modifier.c 2: punctuation.section.group.begin.c - push: enclosure.parenthesis - expression: - # most likely function definition - - match: (?=^\s*{{identifier}}\s+{{identifier}}\s*\() push: - - include: function - - include: else-pop - - include: number - - include: string - - include: type - - include: keyword - - include: constant - - include: operator - - include: punctuation - - include: generic - - include: expression.call - - include: enclosure + - match: \b(get|put)\b + scope: variable.parameter.c + - include: enclosure.parenthesis - function.label: - - match: '({{identifier}})\s*(:)' - captures: - 1: entity.name.label.c - 2: punctuation.separator.c - function.body: - - meta_scope: meta.function.c meta.block.c - - match: \} - scope: punctuation.section.block.end.c - pop: 1 - - include: expression - - include: function.label - function.tail: - - meta_scope: meta.function.c - - match: ; - pop: 1 - - include: gnu-attribute - - match: \{ - scope: punctuation.section.block.begin - set: function.body - include: expression - function.params: - - meta_content_scope: meta.function.parameters.c meta.group.c - match: \) scope: punctuation.section.group.end.c - set: function.tail - - include: keyword - - - match: (? Date: Mon, 10 Feb 2025 12:34:09 -0600 Subject: [PATCH 15/66] fix scopes in test file (oops) --- C++/syntax_test_c.c | 1598 +++++++++++++++++++++---------------------- 1 file changed, 799 insertions(+), 799 deletions(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 4da88d4a32..3155c7bcd8 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -14,371 +14,371 @@ /* ^^ punctuation.definition.comment.c */ */ -/* ^^ invalid.illegal.stray-comment-end.c-2 */ +/* ^^ invalid.illegal.stray-comment-end.c */ ///////////////////////////////////////////// // Numbers ///////////////////////////////////////////// 1234567890 -/* ^^^^^^^^^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ 1'234'567'890 -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ 0x123456789abcdef -/* ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^^^^^^^^^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c */ +/* ^^ constant.numeric.base.c */ +/* ^^^^^^^^^^^^^^^ constant.numeric.value.c */ 0x123'456'789'abc'def -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c */ +/* ^^ constant.numeric.base.c */ +/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c */ 012345670 -/* ^^^^^^^^^ meta.number.integer.octal.c-2 */ -/* ^ constant.numeric.base.c-2 */ -/* ^^^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^^^ meta.number.integer.octal.c */ +/* ^ constant.numeric.base.c */ +/* ^^^^^^^^ constant.numeric.value.c */ 012'345'670 -/* ^^^^^^^^^^^ meta.number.integer.octal.c-2 */ -/* ^ constant.numeric.base.c-2 */ -/* ^^^^^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^^^^^ meta.number.integer.octal.c */ +/* ^ constant.numeric.base.c */ +/* ^^^^^^^^^^ constant.numeric.value.c */ 0b100110 -/* ^^^^^^^^ meta.number.integer.binary.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^^ meta.number.integer.binary.c */ +/* ^^ constant.numeric.base.c */ +/* ^^^^^^ constant.numeric.value.c */ 0b100'110 -/* ^^^^^^^^^ meta.number.integer.binary.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^^^^^^ constant.numeric.value.c-2 */ +/* ^^^^^^^^^ meta.number.integer.binary.c */ +/* ^^ constant.numeric.base.c */ +/* ^^^^^^^ constant.numeric.value.c */ 314lUJ 314uLLj 314iLu 314llI 314F 314f -/* ^^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^ constant.numeric.suffix.c-2 */ -/* ^^^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^^ constant.numeric.suffix.c-2 */ -/* ^^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^ constant.numeric.suffix.c-2 */ -/* ^^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^ constant.numeric.suffix.c-2 */ -/* ^^^^ meta.number.float.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ -/* ^^^^ meta.number.float.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ +/* ^^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^ constant.numeric.suffix.c */ +/* ^^^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^^ constant.numeric.suffix.c */ +/* ^^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^ constant.numeric.suffix.c */ +/* ^^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^ constant.numeric.suffix.c */ +/* ^^^^ meta.number.float.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^ constant.numeric.suffix.c */ +/* ^^^^ meta.number.float.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^ constant.numeric.suffix.c */ 3.14f 314.l 3.14L -/* ^^^^^ meta.number.float.decimal.c-2 */ -/* ^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ -/* ^^^^^ meta.number.float.decimal.c-2 */ -/* ^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ -/* ^^^^^ meta.number.float.decimal.c-2 */ -/* ^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ +/* ^^^^^ meta.number.float.decimal.c */ +/* ^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^ constant.numeric.suffix.c */ +/* ^^^^^ meta.number.float.decimal.c */ +/* ^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^ constant.numeric.suffix.c */ +/* ^^^^^ meta.number.float.decimal.c */ +/* ^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^ constant.numeric.suffix.c */ 314e15 3.14e-15 -/* ^^^^^^ meta.number.float.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^^^^^^^ meta.number.float.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ +/* ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c */ +/* ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ 0xdead.beefp+7f -/* ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^^^^^^^^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ +/* ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ +/* ^^ constant.numeric.base.c */ +/* ^^^^^^^^^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^ constant.numeric.suffix.c */ 012345670 0314llU -/* ^^^^^^^^^ meta.number.integer.octal.c-2 */ -/* ^ constant.numeric.base.c-2 */ -/* ^^^^^^^^ constant.numeric.value.c-2 */ -/* ^^^^^^^ meta.number.integer.octal.c-2 */ -/* ^ constant.numeric.base.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^ constant.numeric.suffix.c-2 */ +/* ^^^^^^^^^ meta.number.integer.octal.c */ +/* ^ constant.numeric.base.c */ +/* ^^^^^^^^ constant.numeric.value.c */ +/* ^^^^^^^ meta.number.integer.octal.c */ +/* ^ constant.numeric.base.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^ constant.numeric.suffix.c */ 0b10 0b10iLu -/* ^^^^ meta.number.integer.binary.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^ constant.numeric.value.c-2 */ -/* ^^^^^^^ meta.number.integer.binary.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^ constant.numeric.value.c-2 */ -/* ^^^ constant.numeric.suffix.c-2 */ +/* ^^^^ meta.number.integer.binary.c */ +/* ^^ constant.numeric.base.c */ +/* ^^ constant.numeric.value.c */ +/* ^^^^^^^ meta.number.integer.binary.c */ +/* ^^ constant.numeric.base.c */ +/* ^^ constant.numeric.value.c */ +/* ^^^ constant.numeric.suffix.c */ 0271828 0b10410 0xbag50 314a123 -/* ^^^^^^^ meta.number.integer.octal.c-2 */ -/* ^ constant.numeric.base.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^^ meta.number.integer.binary.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^ constant.numeric.value.c-2 */ -/* ^^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^^ meta.number.integer.hexadecimal.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^ constant.numeric.value.c-2 */ -/* ^^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^ meta.number.integer.octal.c */ +/* ^ constant.numeric.base.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^^ meta.number.integer.binary.c */ +/* ^^ constant.numeric.base.c */ +/* ^^ constant.numeric.value.c */ +/* ^^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^^ meta.number.integer.hexadecimal.c */ +/* ^^ constant.numeric.base.c */ +/* ^^ constant.numeric.value.c */ +/* ^^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^^ invalid.illegal.numeric.suffix.c */ 314Ll 314lul 314iJ 314.ll 314.lf -/* ^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^ meta.number.integer.decimal.c-2 */ -/* ^^^ constant.numeric.value.c-2 */ -/* ^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^ meta.number.float.decimal.c-2 */ -/* ^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ -/* ^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^ meta.number.float.decimal.c-2 */ -/* ^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ -/* ^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^ meta.number.integer.decimal.c */ +/* ^^^ constant.numeric.value.c */ +/* ^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^ meta.number.float.decimal.c */ +/* ^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^ constant.numeric.suffix.c */ +/* ^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^ meta.number.float.decimal.c */ +/* ^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^ constant.numeric.suffix.c */ +/* ^ invalid.illegal.numeric.suffix.c */ 0x314.1p5af 0b10e20 314e+30llu -/* ^^^^^^^^^^^ meta.number.float.hexadecimal.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^^^^^^ constant.numeric.value.c-2 */ -/* ^ punctuation.separator.decimal.c-2 */ -/* ^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^^ meta.number.integer.binary.c-2 */ -/* ^^ constant.numeric.base.c-2 */ -/* ^^ constant.numeric.value.c-2 */ -/* ^^^ invalid.illegal.numeric.suffix.c-2 */ -/* ^^^^^^^^^^ meta.number.float.decimal.c-2 */ -/* ^^^^^^^ constant.numeric.value.c-2 */ -/* ^ constant.numeric.suffix.c-2 */ -/* ^^ invalid.illegal.numeric.suffix.c-2 */ +/* ^^^^^^^^^^^ meta.number.float.hexadecimal.c */ +/* ^^ constant.numeric.base.c */ +/* ^^^^^^^ constant.numeric.value.c */ +/* ^ punctuation.separator.decimal.c */ +/* ^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^^ meta.number.integer.binary.c */ +/* ^^ constant.numeric.base.c */ +/* ^^ constant.numeric.value.c */ +/* ^^^ invalid.illegal.numeric.suffix.c */ +/* ^^^^^^^^^^ meta.number.float.decimal.c */ +/* ^^^^^^^ constant.numeric.value.c */ +/* ^ constant.numeric.suffix.c */ +/* ^^ invalid.illegal.numeric.suffix.c */ ///////////////////////////////////////////// // Operators ///////////////////////////////////////////// 1 + 2 - 3 * 4 / 5 % 6 -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ 1 | 2 & 3 ^ 4 >> 5 << 6 -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.bitwise.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.bitwise.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.bitwise.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.bitwise.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.bitwise.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.bitwise.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.bitwise.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.bitwise.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.bitwise.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.bitwise.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ 1 > 2 >= 3 == 4 != 5 <= 6 < 7 -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.comparison.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.comparison.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.comparison.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.comparison.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.comparison.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.comparison.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.comparison.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.comparison.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ !1 ? -2 : ~3 -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.ternary.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.ternary.c-2 */ -/* ^ keyword.operator.bitwise.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.ternary.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.ternary.c */ +/* ^ keyword.operator.bitwise.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^^ keyword.operator.assignment.augmented.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^^ keyword.operator.assignment.augmented.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^^ keyword.operator.assignment.augmented.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^^ keyword.operator.assignment.augmented.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) -/* ^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ a,b = b.c; -/* ^ punctuation.separator.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^ punctuation.accessor.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.separator.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ punctuation.accessor.c */ +/* ^ punctuation.terminator.c */ ///////////////////////////////////////////// // Strings ///////////////////////////////////////////// "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' -/* ^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ storage.type.string.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^^^ string.quoted.double.c-2 */ -/* ^^ storage.type.string.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ storage.type.string.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ storage.type.string.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^ string.quoted.single.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^^ string.quoted.single.c-2 */ -/* ^ storage.type.string.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^^ string.quoted.double.c */ +/* ^ storage.type.string.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^^^ string.quoted.double.c */ +/* ^^ storage.type.string.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^^ string.quoted.double.c */ +/* ^ storage.type.string.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^^ string.quoted.double.c */ +/* ^ storage.type.string.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^ string.quoted.single.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^^ string.quoted.single.c */ +/* ^ storage.type.string.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c */ +/* ^ punctuation.definition.string.end.c */ '\u\w\x\y\z\/' -/* ^^^^^^^^^^^^^^ string.quoted.single.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^^^^^^^^^^^ string.quoted.single.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c */ +/* ^ punctuation.definition.string.end.c */ "%ms %as %*[, ]" -/* ^^^^^^^^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ /* ^^^ constant.other.placeholder.c */ /* ^^^ constant.other.placeholder.c */ /* ^^^^^^ constant.other.placeholder.c */ -/* ^ punctuation.definition.string.end.c-2 */ +/* ^ punctuation.definition.string.end.c */ "314 \ -/* ^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.separator.continuation.c-2 */ +/* ^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.separator.continuation.c */ 159" -/*^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/*^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.end.c */ ///////////////////////////////////////////// // Constants ///////////////////////////////////////////// true TRUE false FALSE NULL __func__ -/* ^^^^ constant.language.boolean.true.c-2 */ -/* ^^^^ constant.language.boolean.true.c-2 */ -/* ^^^^^ constant.language.boolean.false.c-2 */ -/* ^^^^^ constant.language.boolean.false.c-2 */ -/* ^^^^ constant.language.null.c-2 */ -/* ^^^^^^^^ constant.language.c-2 */ +/* ^^^^ constant.language.boolean.true.c */ +/* ^^^^ constant.language.boolean.true.c */ +/* ^^^^^ constant.language.boolean.false.c */ +/* ^^^^^ constant.language.boolean.false.c */ +/* ^^^^ constant.language.null.c */ +/* ^^^^^^^^ constant.language.c */ __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus -/* ^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^^ support.constant.c-2 */ -/* ^^^^^^^^^^^ support.constant.c-2 */ +/* ^^^^^^^^ support.constant.c */ +/* ^^^^^^^^ support.constant.c */ +/* ^^^^^^^^ support.constant.c */ +/* ^^^^^^^^ support.constant.c */ +/* ^^^^^^^^ support.constant.c */ +/* ^^^^^^^^^^^^^^^^ support.constant.c */ +/* ^^^^^^^^ support.constant.c */ +/* ^^^^^^^^^ support.constant.c */ +/* ^^^^^^^^^^^ support.constant.c */ True False Null __CplusPlus -/* ^^^^ invalid.illegal.malformed-constant-language.c-2 */ -/* ^^^^^ invalid.illegal.malformed-constant-language.c-2 */ -/* ^^^^ invalid.illegal.malformed-constant-language.c-2 */ -/* ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c-2 */ +/* ^^^^ invalid.illegal.malformed-constant-language.c */ +/* ^^^^^ invalid.illegal.malformed-constant-language.c */ +/* ^^^^ invalid.illegal.malformed-constant-language.c */ +/* ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c */ ///////////////////////////////////////////// // Enclosings ///////////////////////////////////////////// [a, b, c] -/* ^^^^^^^^^ meta.brackets.square.c-2 */ +/* ^^^^^^^^^ meta.brackets.square.c */ /* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.separator.c-2 */ -/* ^ punctuation.separator.c-2 */ +/* ^ punctuation.separator.c */ +/* ^ punctuation.separator.c */ /* ^ punctuation.section.brackets.end */ {1, 2, 3} -/* ^^^^^^^^^ meta.block.c-2 */ +/* ^^^^^^^^^ meta.block.c */ /* ^ punctuation.section.block.begin */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.block.end */ (6 - 7 == -1 && true) -/* ^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.assignment.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^^ keyword.operator.logical.c-2 */ -/* ^^^^ constant.language.boolean.true.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.assignment.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^^ keyword.operator.logical.c */ +/* ^^^^ constant.language.boolean.true.c */ /* ^ punctuation.section.group.end */ ///////////////////////////////////////////// @@ -386,71 +386,71 @@ ///////////////////////////////////////////// auto void char short int long float double signed unsigned _Complex _Imaginary _Bool -/* ^^^^ storage.type.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^^ storage.type.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^^ storage.type.c-2 */ -/* ^^^^^^ storage.type.c-2 */ -/* ^^^^^^ storage.type.c-2 */ -/* ^^^^^^^^ storage.type.c-2 */ -/* ^^^^^^^^ storage.type.c-2 */ -/* ^^^^^^^^^^ storage.type.c-2 */ -/* ^^^^^ storage.type.c-2 */ +/* ^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ storage.type.c */ +/* ^^^ storage.type.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ storage.type.c */ +/* ^^^^^^ storage.type.c */ +/* ^^^^^^ storage.type.c */ +/* ^^^^^^^^ storage.type.c */ +/* ^^^^^^^^ storage.type.c */ +/* ^^^^^^^^^^ storage.type.c */ +/* ^^^^^ storage.type.c */ size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t -/* ^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^ support.type.stdint.c */ uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t -/* ^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^ support.type.stdint.c */ +/* ^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^ support.type.stdint.c */ uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t -/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^ support.type.stdint.c */ uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ -/* ^^^^^^^^^^^^^ support.type.stdint.c-2 */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ +/* ^^^^^^^^^^^^^ support.type.stdint.c */ typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) -/* ^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^ keyword.declaration.type.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^^^ keyword.declaration.type.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^ keyword.declaration.type.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^^^^^^^^^ keyword.declaration.type.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ @@ -459,24 +459,24 @@ ///////////////////////////////////////////// register static inline extern register thread_local _Thread_local _Noreturn noreturn -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^^^^ storage.modifier.c */ +/* ^^^^^^ storage.modifier.c */ +/* ^^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ const volatile restrict _Atomic _Alignas(4) -/* ^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ @@ -485,104 +485,104 @@ ///////////////////////////////////////////// test(5, 10, 15, 20); -/* ^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ -/* ^^^^ variable.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^ meta.group.c */ +/* ^^^^ variable.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ h(f(5) - g(6)); -/* ^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^^^ meta.group.c-2 */ -/* ^ variable.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ +/* ^^^^ meta.group.c */ +/* ^ variable.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^^^^ meta.group.c-2 */ -/* ^ variable.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.arithmetic.c */ +/* ^^^^ meta.group.c */ +/* ^ variable.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ -/* ^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ +/* ^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ int main(int argc, char const* argv[]) { -/* ^^^ storage.type.c-2 */ -/* ^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^^^^ variable.parameter.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^^ storage.modifier.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^^^^ variable.parameter.c-2 */ -/* ^^ meta.brackets.square.c-2 */ +/* ^^^ storage.type.c */ +/* ^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ +/* ^^^ storage.type.c */ +/* ^^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ storage.modifier.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^^^^ variable.parameter.c */ +/* ^^ meta.brackets.square.c */ /* ^ punctuation.section.brackets.begin */ /* ^ punctuation.section.brackets.end */ -/* ^^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ +/* ^^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ int out = in("abcdefg"); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^^^^^^^^^^^^^ meta.group.c-2 */ -/* ^^ variable.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^^^^ meta.group.c */ +/* ^^ variable.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ /* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ } -/*^^^ meta.function.c-2 meta.block.c-2 */ -/* ^ punctuation.section.block.end.c-2 */ +/*^^^ meta.function.c meta.block.c */ +/* ^ punctuation.section.block.end.c */ int b = main(argc); -/* ^^^ storage.type.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^^^^^^^^^^ meta.group.c-2 */ -/* ^^^^ variable.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^ storage.type.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^ meta.group.c */ +/* ^^^^ variable.function.c */ +/* ^ punctuation.section.group.begin.c */ /* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ static extern int* -/* ^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^ storage.modifier.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ +/* ^^^^^^ storage.modifier.c */ +/* ^^^^^^ storage.modifier.c */ +/* ^^^ storage.type.c */ +/* ^ keyword.operator.arithmetic.c */ test( -/* ^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ const uint64_t a, -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ support.type.stdint.c-2 */ -/* ^ variable.parameter.c-2 */ -/* ^ punctuation.separator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^^^ support.type.stdint.c */ +/* ^ variable.parameter.c */ +/* ^ punctuation.separator.c */ typeof(b) b -/*^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^ meta.group.c-2 */ +/*^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ +/* ^^^^^^ keyword.declaration.type.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ -/* ^ variable.parameter.c-2 */ +/* ^ variable.parameter.c */ ); -/*^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ +/*^^ meta.function.parameters.c meta.group.c */ +/* ^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ ///////////////////////////////////////////// // Control Flow @@ -590,532 +590,532 @@ void fun(int const a[]) { while (true) { -/*^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ -/* ^^^^^ keyword.control.c-2 */ -/* ^^^^^^ meta.group.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ +/* ^^^^^ keyword.control.c */ +/* ^^^^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^^^^ constant.language.boolean.true.c-2 */ +/* ^^^^ constant.language.boolean.true.c */ /* ^ punctuation.section.group.end */ -/* ^ meta.block.c-2 punctuation.section.block.begin */ +/* ^ meta.block.c punctuation.section.block.begin */ do { -/*^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^ keyword.control.c-2 */ -/* ^ meta.block.c-2 punctuation.section.block.begin */ +/*^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c */ +/* ^^ keyword.control.c */ +/* ^ meta.block.c punctuation.section.block.begin */ for (int i = 0; i < 12; ++i) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^ keyword.control.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c */ +/* ^^^ keyword.control.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^^^ storage.type.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.terminator.c-2 */ -/* ^ keyword.operator.comparison.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.terminator.c-2 */ -/* ^^ keyword.operator.arithmetic.c-2 */ +/* ^^^ storage.type.c */ +/* ^ keyword.operator.assignment.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.terminator.c */ +/* ^ keyword.operator.comparison.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.terminator.c */ +/* ^^ keyword.operator.arithmetic.c */ /* ^ punctuation.section.group.end */ -/* ^ meta.block.c-2 punctuation.section.block.begin */ +/* ^ meta.block.c punctuation.section.block.begin */ switch (i) -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^^^ keyword.control.c-2 */ -/* ^^^ meta.group.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^^^ keyword.control.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ /* ^ punctuation.section.group.end */ { -/*^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^ meta.block.c-2 punctuation.section.block.begin */ +/*^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^ meta.block.c punctuation.section.block.begin */ case 0: -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^ keyword.control.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.ternary.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^ keyword.control.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.ternary.c */ goto exit; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^ keyword.control.flow.goto.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^ keyword.control.flow.goto.c */ +/* ^ punctuation.terminator.c */ case 1: -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^ keyword.control.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.ternary.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^ keyword.control.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.ternary.c */ case 2 + 3: -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^ keyword.control.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ keyword.operator.ternary.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^ keyword.control.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ keyword.operator.ternary.c */ if (a + b < i) {} -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^ keyword.control.c-2 */ -/* ^^^^^^^^^^^ meta.group.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^ keyword.control.c */ +/* ^^^^^^^^^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ keyword.operator.comparison.c-2 */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ keyword.operator.comparison.c */ /* ^ punctuation.section.group.end */ -/* ^^ meta.block.c-2 */ +/* ^^ meta.block.c */ /* ^ punctuation.section.block.begin */ /* ^ punctuation.section.block.end */ else if (b == -1) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^ keyword.control.c-2 */ -/* ^^ keyword.control.c-2 */ -/* ^^^^^^^^^ meta.group.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^ keyword.control.c */ +/* ^^ keyword.control.c */ +/* ^^^^^^^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^^ keyword.operator.assignment.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ keyword.operator.assignment.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ -/* ^ meta.block.c-2 punctuation.section.block.begin */ +/* ^ meta.block.c punctuation.section.block.begin */ continue; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^^^^^ keyword.control.flow.continue.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^^^^^ keyword.control.flow.continue.c */ +/* ^ punctuation.terminator.c */ } -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ /* ^ punctuation.section.block.end */ break; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^^ keyword.control.flow.break.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^^ keyword.control.flow.break.c */ +/* ^ punctuation.terminator.c */ default: -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^^^^ keyword.control.c-2 */ -/* ^ keyword.operator.ternary.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^^^^ keyword.control.c */ +/* ^ keyword.operator.ternary.c */ continue; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ -/* ^^^^^^^^ keyword.control.flow.continue.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ +/* ^^^^^^^^ keyword.control.flow.continue.c */ +/* ^ punctuation.terminator.c */ } -/*^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/*^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ /* ^ punctuation.section.block.end */ } -/*^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 meta.block.c-2 */ +/*^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c */ /* ^ punctuation.section.block.end */ } while (a > b); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 */ -/*^^^^^^^^^^^ meta.block.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c */ +/*^^^^^^^^^^^ meta.block.c */ /* ^ punctuation.section.block.end */ -/* ^^^^^ keyword.control.c-2 */ -/* ^^^^^^^ meta.group.c-2 */ +/* ^^^^^ keyword.control.c */ +/* ^^^^^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^ keyword.operator.comparison.c-2 */ +/* ^ keyword.operator.comparison.c */ /* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ } -/*^^^^^^^ meta.function.c-2 meta.block.c-2 meta.block.c-2 */ +/*^^^^^^^ meta.function.c meta.block.c meta.block.c */ /* ^ punctuation.section.block.end */ exit: -/*^^^^^^^ meta.function.c-2 meta.block.c-2 */ -/* ^^^^ entity.name.label.c-2 */ -/* ^ punctuation.separator.c-2 */ +/*^^^^^^^ meta.function.c meta.block.c */ +/* ^^^^ entity.name.label.c */ +/* ^ punctuation.separator.c */ return; -/*^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ -/* ^^^^^^ keyword.control.flow.return.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^ meta.function.c meta.block.c */ +/* ^^^^^^ keyword.control.flow.return.c */ +/* ^ punctuation.terminator.c */ } -/*^^^ meta.function.c-2 meta.block.c-2 */ -/* ^ punctuation.section.block.end.c-2 */ +/*^^^ meta.function.c meta.block.c */ +/* ^ punctuation.section.block.end.c */ ///////////////////////////////////////////// // Data Structures ///////////////////////////////////////////// struct A; enum B; union C; -/* ^^^^^^^^ meta.struct.c-2 */ -/* ^^^^^^ keyword.declaration.struct.c-2 */ -/* ^ entity.name.enum.forward-decl.c-2 */ -/* ^ punctuation.terminator.c-2 */ -/* ^^^^^^ meta.enum.c-2 */ -/* ^^^^ keyword.declaration.enum.c-2 */ -/* ^ entity.name.enum.forward-decl.c-2 */ -/* ^ punctuation.terminator.c-2 */ -/* ^^^^^^^ meta.union.c-2 */ -/* ^^^^^ keyword.declaration.union.c-2 */ -/* ^ entity.name.enum.forward-decl.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/* ^^^^^^^^ meta.struct.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ entity.name.enum.forward-decl.c */ +/* ^ punctuation.terminator.c */ +/* ^^^^^^ meta.enum.c */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^ entity.name.enum.forward-decl.c */ +/* ^ punctuation.terminator.c */ +/* ^^^^^^^ meta.union.c */ +/* ^^^^^ keyword.declaration.union.c */ +/* ^ entity.name.enum.forward-decl.c */ +/* ^ punctuation.terminator.c */ enum B -/* ^^^^^^ meta.enum.c-2 */ -/* ^^^^ keyword.declaration.enum.c-2 */ -/* ^ entity.name.enum.c-2 */ +/* ^^^^^^ meta.enum.c */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^ entity.name.enum.c */ { -/* ^ meta.enum.c-2 punctuation.section.block.begin.c-2 */ +/* ^ meta.enum.c punctuation.section.block.begin.c */ kTest1, -/*^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^^^ entity.name.constant.c-2 */ -/* ^ punctuation.separator.c-2 */ +/*^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^^^ entity.name.constant.c */ +/* ^ punctuation.separator.c */ kTest2 = kTest1 + 1, -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^^^ entity.name.constant.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^^^ entity.name.constant.c */ +/* ^ keyword.operator.assignment.c */ /* ^^^^^^ constant.other.variable.mac-classic.c */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ kTest3, -/*^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^^^ entity.name.constant.c-2 */ -/* ^ punctuation.separator.c-2 */ +/*^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^^^ entity.name.constant.c */ +/* ^ punctuation.separator.c */ }myEnum; -/*^^ meta.block.c-2 */ -/* ^ punctuation.section.block.end.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^ meta.block.c */ +/* ^ punctuation.section.block.end.c */ +/* ^ punctuation.terminator.c */ const volatile struct A -/* ^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^ meta.struct.c-2 */ -/* ^^^^^^ keyword.declaration.struct.c-2 */ -/* ^ entity.name.struct.c-2 */ +/* ^^^^^ storage.modifier.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^ meta.struct.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ entity.name.struct.c */ { -/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ +/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ int a1; -/*^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^ meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ char a3[12]; -/*^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^ meta.brackets.square.c-2 */ +/*^^^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^ storage.type.c */ +/* ^^^^ meta.brackets.square.c */ /* ^ punctuation.section.brackets.begin */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.brackets.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ void* h5; -/*^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^ storage.type.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ punctuation.terminator.c */ enum B out; }; -/*^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^ keyword.declaration.enum.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^ punctuation.terminator.c */ /* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ union MACRO myUnion { -/* ^^^^^^^^^^^^^^^^^^^^ meta.union.c-2 */ -/* ^^^^^ keyword.declaration.union.c-2 */ -/* ^^^^^^^ entity.name.union.c-2 */ -/* ^ meta.block.c-2 meta.union.c-2 punctuation.section.block.begin.c-2 */ +/* ^^^^^^^^^^^^^^^^^^^^ meta.union.c */ +/* ^^^^^ keyword.declaration.union.c */ +/* ^^^^^^^ entity.name.union.c */ +/* ^ meta.block.c meta.union.c punctuation.section.block.begin.c */ struct A { -/*^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^^^^^^ meta.struct.c-2 */ -/* ^^^^^^ keyword.declaration.struct.c-2 */ -/* ^ entity.name.struct.c-2 */ -/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ +/*^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^^^^^^ meta.struct.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ entity.name.struct.c */ +/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ int f; -/*^^^^^^^^^^^^^^^^ meta.block.c-2 meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^ meta.block.c meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ } s1; -/*^^^^^^^^^^^ meta.block.c-2 */ -/*^^^^^^^ meta.block.c-2 */ +/*^^^^^^^^^^^ meta.block.c */ +/*^^^^^^^ meta.block.c */ /* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ struct B { -/*^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^^^^^^ meta.struct.c-2 */ -/* ^^^^^^ keyword.declaration.struct.c-2 */ -/* ^ entity.name.struct.c-2 */ -/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ +/*^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^^^^^^ meta.struct.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ entity.name.struct.c */ +/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ int f2; -/*^^^^^^^^^^^^^^^^^ meta.block.c-2 meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ } s2; -/*^^^^^^^^^^^ meta.block.c-2 */ -/*^^^^^^^ meta.block.c-2 */ +/*^^^^^^^^^^^ meta.block.c */ +/*^^^^^^^ meta.block.c */ /* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ void* ptr; -/*^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^^ storage.type.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ punctuation.terminator.c */ int a, *ptr2; -/*^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.separator.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ punctuation.terminator.c */ }; -/*^^^ meta.block.c-2 */ +/*^^^ meta.block.c */ /* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ int test() { -/* ^^^ storage.type.c-2 */ -/* ^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ +/* ^^^ storage.type.c */ +/* ^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ union C myunion; -/*^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ -/* ^^^^^ keyword.declaration.union.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ +/* ^^^^^ keyword.declaration.union.c */ +/* ^ punctuation.terminator.c */ myunion.s2.f = 20; -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 meta.block.c-2 */ -/* ^ punctuation.accessor.c-2 */ -/* ^ punctuation.accessor.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ +/* ^ punctuation.accessor.c */ +/* ^ punctuation.accessor.c */ +/* ^ keyword.operator.assignment.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.terminator.c */ } -/*^^^ meta.function.c-2 meta.block.c-2 */ -/* ^ punctuation.section.block.end.c-2 */ +/*^^^ meta.function.c meta.block.c */ +/* ^ punctuation.section.block.end.c */ typedef struct { -/* ^^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^^^^^ meta.struct.c-2 */ -/* ^^^^^^ keyword.declaration.struct.c-2 */ -/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ +/* ^^^^^^^ keyword.declaration.type.c */ +/* ^^^^^^^ meta.struct.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ myCustomType* a; -/*^^^^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^ meta.block.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^ punctuation.terminator.c */ } b; -/*^^^ meta.block.c-2 */ +/*^^^ meta.block.c */ /* ^ punctuation.section.block.end */ -/* ^ entity.name.type.typedef.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/* ^ entity.name.type.typedef.c */ +/* ^ punctuation.terminator.c */ typedef void(*func)(int param, int, char param2); -/* ^^^^^^^ keyword.declaration.type.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^ keyword.operator.c-2 */ -/* ^^^^ entity.name.type.typedef.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^^^^^ variable.parameter.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^^^ variable.parameter.c-2 */ -/* ^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ +/* ^^^^^^^ keyword.declaration.type.c */ +/* ^^^^ storage.type.c */ +/* ^ keyword.operator.c */ +/* ^^^^ entity.name.type.typedef.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ +/* ^^^ storage.type.c */ +/* ^^^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^^ variable.parameter.c */ +/* ^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ ///////////////////////////////////////////// // Attributes and Declspec ///////////////////////////////////////////// __declspec(align(5)) struct Test { -/* ^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^^ meta.group.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^ meta.group.c-2 */ -/* ^^^^^ storage.modifier.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^ meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^ meta.group.c */ +/* ^^^^^ storage.modifier.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^^^^^^^^^^^^ meta.struct.c-2 */ -/* ^^^^^^ keyword.declaration.struct.c-2 */ -/* ^^^^ entity.name.struct.c-2 */ -/* ^ meta.block.c-2 meta.struct.c-2 punctuation.section.block.begin.c-2 */ +/* ^ punctuation.section.group.end.c */ +/* ^^^^^^^^^^^^ meta.struct.c */ +/* ^^^^^^ keyword.declaration.struct.c */ +/* ^^^^ entity.name.struct.c */ +/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ int a; -/*^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^ meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ int b; -/*^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^ meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ int c; -/*^^^^^^^^^^^^ meta.block.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^ punctuation.terminator.c-2 */ +/*^^^^^^^^^^^^ meta.block.c */ +/* ^^^ storage.type.c */ +/* ^ punctuation.terminator.c */ }; -/*^^^ meta.block.c-2 */ +/*^^^ meta.block.c */ /* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ void __declspec(dllimport) importedFn() const; -/* ^^^^ storage.type.c-2 */ -/* ^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^^^ meta.group.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^ constant.other.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^^^^^^^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^^^^^ constant.other.c-2 */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^ meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^ constant.other.c */ +/* ^ punctuation.section.group.end.c */ +/* ^^^^^^^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ +/* ^^^^^ constant.other.c */ __declspec(property(get=10, put=10)) void runForever(); -/* ^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^ storage.modifier.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ +/* ^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^ storage.modifier.c */ +/* ^ punctuation.section.group.begin.c */ /* ^^^ variable.parameter.c */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.separator.c-2 */ +/* ^ keyword.operator.assignment.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.separator.c */ /* ^^^ variable.parameter.c */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ +/* ^ keyword.operator.assignment.c */ +/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ /* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^^^^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ +/* ^ punctuation.section.group.end.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ void on_load() __attribute__((constructor, visibility("hidden"))) {} -/* ^^^^ storage.type.c-2 */ -/* ^^^^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 meta.attribute.c-2 */ -/* ^^^^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^^^ constant.other.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^ meta.group.c-2 */ -/* ^^^^^^^^^^ storage.modifier.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/* ^^^^ storage.type.c */ +/* ^^^^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c */ +/* ^^^^^^^^^^^^^ storage.modifier.c */ +/* ^^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^ constant.other.c */ +/* ^ punctuation.separator.c */ +/* ^^^^^^^^^^^^^^^^^^^^ meta.group.c */ +/* ^^^^^^^^^^ storage.modifier.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ /* ^ punctuation.section.group.end */ -/* ^^ punctuation.section.group.end.c-2 */ -/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ -/* ^ meta.block.c-2 punctuation.section.block.end.c-2 */ +/* ^^ punctuation.section.group.end.c */ +/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ +/* ^ meta.block.c punctuation.section.block.end.c */ int a = -/* ^^^ storage.type.c-2 */ -/* ^ keyword.operator.assignment.c-2 */ +/* ^^^ storage.type.c */ +/* ^ keyword.operator.assignment.c */ int main(int argc, char const* argv[]) { -/* ^^^ storage.type.c-2 */ -/* ^^^^ entity.name.function.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c-2 meta.group.c-2 */ -/* ^^^ storage.type.c-2 */ -/* ^^^^ variable.parameter.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^^^ storage.type.c-2 */ -/* ^^^^^ storage.modifier.c-2 */ -/* ^ keyword.operator.arithmetic.c-2 */ -/* ^^^^ variable.parameter.c-2 */ -/* ^^ meta.brackets.square.c-2 */ +/* ^^^ storage.type.c */ +/* ^^^^ entity.name.function.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ +/* ^^^ storage.type.c */ +/* ^^^^ variable.parameter.c */ +/* ^ punctuation.separator.c */ +/* ^^^^ storage.type.c */ +/* ^^^^^ storage.modifier.c */ +/* ^ keyword.operator.arithmetic.c */ +/* ^^^^ variable.parameter.c */ +/* ^^ meta.brackets.square.c */ /* ^ punctuation.section.brackets.begin */ /* ^ punctuation.section.brackets.end */ -/* ^^^ meta.function.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^ meta.function.c-2 meta.block.c-2 punctuation.section.block.begin */ +/* ^^^ meta.function.c */ +/* ^ punctuation.section.group.end.c */ +/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ } -/*^^^ meta.function.c-2 meta.block.c-2 */ -/* ^ punctuation.section.block.end.c-2 */ +/*^^^ meta.function.c meta.block.c */ +/* ^ punctuation.section.block.end.c */ ///////////////////////////////////////////// // Preprocessor ///////////////////////////////////////////// #include -/*^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^^^ keyword.control.import.c-2 */ -/* ^^^^^^^^^^ string.quoted.other.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^^^ keyword.control.import.c */ +/* ^^^^^^^^^^ string.quoted.other.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ #include_next "file.h" -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^^^^^^^^ keyword.control.import.c-2 */ -/* ^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^^^^^^^^ keyword.control.import.c */ +/* ^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ #error Error Message -/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c-2 */ -/*^^^^^^^^ keyword.control.import.error.c-2 */ -/* ^^^^^^^^^^^^^^ string.unquoted.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c */ +/*^^^^^^^^ keyword.control.import.error.c */ +/* ^^^^^^^^^^^^^^ string.unquoted.c */ #error Error Message \ (this is an "error") -/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c-2 string.unquoted.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c */ #warning Warning Message -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c-2 */ -/*^^^^^^^^^^ keyword.control.import.warning.c-2 */ -/* ^^^^^^^^^^^^^^^^ string.unquoted.c-2 */ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c */ +/*^^^^^^^^^^ keyword.control.import.warning.c */ +/* ^^^^^^^^^^^^^^^^ string.unquoted.c */ #warning Warning Message \ (this is a "warning") #define FOO __declspec(dllimport) -/*^^^^^^^^^ keyword.control.import.c-2 */ -/* ^^^ entity.name.macro.c-2 support.macro.c-2 */ -/* ^^^^^^^^^^ storage.modifier.c-2 */ -/* ^^^^^^^^^^^ meta.group.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^^^^^^^^^ constant.other.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ +/*^^^^^^^^^ keyword.control.import.c */ +/* ^^^ entity.name.macro.c support.macro.c */ +/* ^^^^^^^^^^ storage.modifier.c */ +/* ^^^^^^^^^^^ meta.group.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^^^^^^^^^ constant.other.c */ +/* ^ punctuation.section.group.end.c */ #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; -/*^^^^^^^^^ keyword.control.import.c-2 */ -/* ^^^ entity.name.macro.c-2 support.macro.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^ variable.parameter.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^ variable.parameter.c-2 */ -/* ^ punctuation.separator.c-2 */ -/* ^^^ keyword.operator.variadic.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ -/* ^^^^ keyword.declaration.enum.c-2 */ -/* ^^ keyword.operator.c-2 */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c-2 */ +/*^^^^^^^^^ keyword.control.import.c */ +/* ^^^ entity.name.macro.c support.macro.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ variable.parameter.c */ +/* ^ punctuation.separator.c */ +/* ^ variable.parameter.c */ +/* ^ punctuation.separator.c */ +/* ^^^ keyword.operator.variadic.c */ +/* ^ punctuation.section.group.end.c */ +/* ^^^^ keyword.declaration.enum.c */ +/* ^^ keyword.operator.c */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c */ /* ^ punctuation.section.block.begin */ /* ^^^^^^^^^^^ constant.other.variable.mac-classic.c */ -/* ^ keyword.operator.assignment.c-2 */ -/* ^^^^^^^^^^ keyword.operator.word.c-2 */ -/* ^^^ meta.group.c-2 */ +/* ^ keyword.operator.assignment.c */ +/* ^^^^^^^^^^ keyword.operator.word.c */ +/* ^^^ meta.group.c */ /* ^ punctuation.section.group.begin */ -/* ^ punctuation.separator.c-2 */ +/* ^ punctuation.separator.c */ /* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^ constant.other.c-2 */ +/* ^^^^^^^^^^^ constant.other.c */ /* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c-2 */ +/* ^ punctuation.terminator.c */ #if FOO -/*^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^ keyword.control.import.c */ #ifndef FOO -/*^^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^^ keyword.control.import.c */ #ifdef FOO -/*^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^ keyword.control.import.c */ #elif FOO -/*^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^ keyword.control.import.c */ #elifdef FOO -/*^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^^^ keyword.control.import.c */ #elifndef FOO -/*^^^^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^^^^ keyword.control.import.c */ #else -/*^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^ keyword.control.import.c */ #endif -/*^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^ keyword.control.import.c */ #undef FOO -/*^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^ keyword.control.import.c */ #pragma FOO -/*^^^^^^^^^^^^^ meta.preprocessor.c-2 */ -/*^^^^^^^^^ keyword.control.import.c-2 */ +/*^^^^^^^^^^^^^ meta.preprocessor.c */ +/*^^^^^^^^^ keyword.control.import.c */ #embed "file.txt" if_empty(0) -/*^^^^^^^^ keyword.control.import.c-2 */ -/* ^^^^^^^^^^ string.quoted.double.c-2 */ -/* ^ punctuation.definition.string.begin.c-2 */ -/* ^ punctuation.definition.string.end.c-2 */ -/* ^^^^^^^^ keyword.other.c-2 */ -/* ^ punctuation.section.group.begin.c-2 */ -/* ^ meta.number.integer.decimal.c-2 constant.numeric.value.c-2 */ -/* ^ punctuation.section.group.end.c-2 */ +/*^^^^^^^^ keyword.control.import.c */ +/* ^^^^^^^^^^ string.quoted.double.c */ +/* ^ punctuation.definition.string.begin.c */ +/* ^ punctuation.definition.string.end.c */ +/* ^^^^^^^^ keyword.other.c */ +/* ^ punctuation.section.group.begin.c */ +/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +/* ^ punctuation.section.group.end.c */ From 8e6534c757ad6ebc540aec079d77492f8cc9dc34 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 19:06:14 -0600 Subject: [PATCH 16/66] Start ObjC --- Objective-C/Objective-C.sublime-syntax | 1627 ++++-------------------- 1 file changed, 257 insertions(+), 1370 deletions(-) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 812e5d05af..0727860c8a 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -3,6 +3,8 @@ # http://www.sublimetext.com/docs/3/syntax.html name: Objective-C scope: source.objc +version: 2 +extends: Packages/C++/C.sublime-syntax file_extensions: - m @@ -13,200 +15,278 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \bobj(ective-)?c\b(?![#+]) .*? -\*- # editorconfig ) -variables: - identifier: '\b[[:alpha:]_][[:alnum:]_]*\b' - control_keywords: 'break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while' - before_tag: 'struct|union|enum' - common_protocols: '\bNS(GlyphStorage|M(utableCopying|enuItem)|C(hangeSpelling|o(ding|pying|lorPicking(Custom|Default)))|T(oolbarItemValidations|ext(Input|AttachmentCell))|I(nputServ(iceProvider|erMouseTracker)|gnoreMisspelledWords)|Obj(CTypeSerializationCallBack|ect)|D(ecimalNumberBehaviors|raggingInfo)|U(serInterfaceValidations|RL(HandleClient|DownloadDelegate|ProtocolClient|AuthenticationChallengeSender))|Validated(ToolbarItem|UserInterfaceItem)|Locking)\b' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__' - contexts: main: - - include: preprocessor-global - - include: global - - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the - # Objective-C++ syntax. They are specifically constructed to not push into - # sub-contexts, which ensures that Objective-C++ code isn't accidentally - # lexed as plain Objective-C. - # - # The "unique-*" contexts are additions that Objective-C makes over C, and - # thus can be directly reused in Objective-C++ along with contexts from C++ - # and C. - ############################################################################# - - properties: - - match: ((@)property)\s*(\() - captures: - 1: keyword.other.property.objc - 2: punctuation.definition.keyword.objc - 3: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.property-with-attributes.objc - - match: '\)' - scope: punctuation.section.scope.end.objc - pop: true - - match: \b(getter|setter|readonly|readwrite|assign|retain|copy|nonatomic|strong|weak|class|nonnull|nullable|null_unspecified|null_resettable)\b - scope: keyword.other.property.attribute.objc - - match: ',' - scope: punctuation.separator.objc - - match: ((@)property)\b - scope: meta.property.objc - captures: - 1: keyword.other.property.objc - 2: punctuation.definition.keyword.objc - - protocol_list: - - match: '<' + - meta_prepend: true + - include: interface + - include: implementation + + implementation: + - match: ^\s*(@implementation)\s*({{identifier}})\b + captures: + 1: meta.implementation.objc keyword.declaration.class.objc + 2: meta.implementation.objc entity.name.type.objc + push: [implementation.meta, interface.body] + implementation.meta: + - meta_scope: meta.implementation.objc meta.scope.implementation.objc + - include: pop-immediately + + interface: + - match: ^\s*(@interface|@protocol)\s*({{identifier}})\b + captures: + 1: meta.interface-or-protocol.objc keyword.declaration.class.objc + 2: meta.interface-or-protocol.objc entity.name.type.objc + push: [interface.meta, interface.body, interface.struct, interface.subclass, interface.category] + interface.meta: + - meta_scope: meta.interface-or-protocol.objc meta.scope.interface.objc + - include: pop-immediately + interface.category: + - clear_scopes: 1 + - match: \( + push: enclosure.parenthesis + - include: else-pop + interface.subclass: + - clear_scopes: 1 + - match: \< scope: punctuation.section.scope.begin.objc push: + - include: expression-identifiers - meta_scope: meta.protocol-list.objc - - match: '>' + - match: \> scope: punctuation.section.scope.end.objc - pop: true - - match: '{{common_protocols}}' - scope: support.other.protocol.objc - - protocol_type_qualifier: - - match: \b(in|out|inout|oneway|bycopy|byref)\b - scope: storage.modifier.protocol.objc - - ns-predicate: - - match: '(?=\])' - pop: true - - match: \bargument(?:Array|s)(:) - scope: support.function.any-method.name-of-parameter.objc + pop: 1 + - match: ':' + scope: punctuation.separator.objc + - include: expression-identifiers + - include: else-pop + interface.struct: + - match: \{ + scope: punctuation.section.block.begin.objc + push: enclosure.block + - include: else-pop + interface.body: + - match: ^\s*(@end) captures: - 1: punctuation.separator.arguments.objc - - match: \b\w+(:) - scope: invalid.illegal.unknown-method.objc + 1: keyword.declaration.interface.end.objc + pop: 1 + - match: ^\s*(@property) captures: - 1: punctuation.separator.arguments.objc - - match: '@"' - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.double.objc - - match: '"' - scope: punctuation.definition.string.end.objc - pop: true - - match: \b(?i:AND|OR|NOT|IN)\b - scope: keyword.operator.logical.predicate.cocoa.objc - - match: \b(?i:ALL|ANY|SOME|NONE)\b - scope: constant.language.predicate.cocoa.objc - - match: \b(?i:NULL|NIL|SELF|TRUE|YES|FALSE|NO|FIRST|LAST|SIZE)\b - scope: constant.language.predicate.cocoa.objc - - match: \b(?i:MATCHES|CONTAINS|BEGINSWITH|ENDSWITH|BETWEEN|LIKE)\b - scope: keyword.operator.comparison.predicate.cocoa.objc - - match: \b(?i:C(ASEINSENSITIVE|I))\b - scope: keyword.other.modifier.predicate.cocoa.objc - - match: \b(?i:ANYKEY|SUBQUERY|CAST|TRUEPREDICATE|FALSEPREDICATE)\b - scope: keyword.other.predicate.cocoa.objc - - match: '\\(\\|[abefnrtv''"?]|[0-3]\d{,2}|[4-7]\d?|x[a-zA-Z0-9]+)' - scope: constant.character.escape.objc - - match: \\. - scope: invalid.illegal.unknown-escape.objc + 1: keyword.other.objc + push: property + - match: ^\s*(@(?:synthesize|dynamic)) + captures: + 1: keyword.other.objc + push: statement - unique-strings: - - match: '@"' - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.double.objc - - match: '"' - scope: punctuation.definition.string.end.objc - pop: true - - include: scope:source.c#string_escaped_char - - match: '%@' - scope: constant.other.placeholder.objc - - include: scope:source.c#string_placeholder + - match: (?:\+|\-)\s*(?=\() + push: [selector, selector.return] + - include: expression - unique-keywords: - - match: (@)(dynamic|synthesize)\b - scope: keyword.other.property.directive.objc - captures: - 1: punctuation.definition.keyword.objc - - match: \b(NS_DURING|NS_HANDLER|NS_ENDHANDLER)\b - scope: keyword.control.macro.objc - - match: (@)(try|catch|finally|throw)\b - scope: keyword.control.exception.objc - captures: - 1: punctuation.definition.keyword.objc - - match: (@)(synchronized)\b - scope: keyword.control.synchronize.objc + property: + - match: \( + scope: punctuation.section.group.begin.objc + push: property.attrs + - match: (?=\S) + set: statement + property.attrs: + - match: \b([sg]etter)\s*(=)\s*({{identifier}})\b captures: - 1: punctuation.definition.keyword.objc - - match: (@)(defs|encode)\b - scope: keyword.other.objc + 1: storage.modifier.objc + 2: keyword.operator.assignment.objc + 3: entity.name.function.method.objc + - match: \b([sg]etter|readonly|readwrite|assign|retain|copy|atomic|nonatomic|strong|weak|class|nonnull|nullable|null_unspecified|null_resettable)\b + scope: storage.modifier.objc + - include: punctuation.comma + - include: operator + - match: \) + scope: punctuation.section.group.end.objc + pop: 1 + + selector.return: + - match: \( + scope: punctuation.section.group.begin + set: enclosure.parenthesis + selector: + - meta_scope: meta.function.objc + - match: '\b({{identifier}})\s*(\:)\s*(\()' + captures: + 1: entity.name.function.method.objc + 2: punctuation.separator.arguments.objc + 3: punctuation.section.group.begin.objc + push: [selector.param, enclosure.parenthesis] + - match: \b({{identifier}})\s*(?' - scope: punctuation.section.scope.end.objc - pop: true - - match: '<' - scope: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.protocol-list.objc - - match: '(?=>)' - pop: true - - match: '{{common_protocols}}' - scope: support.other.protocol.objc - - match: \bid\b(\s|\n)? - scope: storage.type.id.objc - - match: \b(IBOutlet|IBAction|BOOL|SEL|id|unichar|IMP|Class)\b - scope: storage.type.objc - - match: (@)(class|protocol)\b - scope: storage.type.objc + 1: entity.name.function.method.objc + 2: punctuation.separator.arguments.objc + + - include: expression + + - match: \] + scope: punctuation.section.brackets.end.objc + pop: 1 + message: + - meta_scope: meta.bracketed.objc + + - include: type + - include: keyword + - include: constant + - include: operator.accessor + - include: operator.pointer + - include: expression.call + - include: enclosure + + - match: (?<=[\)\]\}\w])\s*(?={{identifier}}\s*:) + set: message.func + + - match: (?<=[\)\]\}\w])\s*({{identifier}})\s*(\]) captures: - 1: punctuation.definition.storage.type.objc - - match: \bC(I(Sampler|Co(ntext|lor)|Image(Accumulator)?|PlugIn(Registration)?|Vector|Kernel|Filter(Generator|Shape)?)|A(Renderer|MediaTiming(Function)?|BasicAnimation|ScrollLayer|Constraint(LayoutManager)?|T(iledLayer|extLayer|rans(ition|action))|OpenGLLayer|PropertyAnimation|KeyframeAnimation|Layer|A(nimation(Group)?|ction)))\b - scope: support.class.quartz.objc - - match: \bC(G(Float|Point|Size|Rect)|IFormat|AConstraintAttribute)\b - scope: support.type.quartz.objc + 1: entity.name.function.method.objc + 2: punctuation.section.brackets.end.objc + pop: 1 + + - match: '\b({{identifier}})\b' + - match: (?=\S) + fail: message + enclosure: + - meta_prepend: true + - match: \[ + scope: punctuation.section.brackets.begin + branch_point: message + branch: [message, enclosure.brackets] + - match: '@\{' + scope: punctuation.section.mapping.begin + push: enclosure.mapping + enclosure.mapping: + - meta_scope: meta.mapping.objc + - match: \} + scope: punctuation.section.mapping.end + pop: 1 + - include: expression - # This context is separate since the regexes are huge and they affect - # compilation speed and caching performance ns-identifiers: - match: (\s*)\b(NS(Rect(ToCGRect|FromCGRect)|MakeCollectable|S(tringFromProtocol|ize(ToCGSize|FromCGSize))|Draw(NinePartImage|ThreePartImage)|P(oint(ToCGPoint|FromCGPoint)|rotocolFromString)|EventMaskFromType|Value))\b captures: @@ -228,1207 +308,14 @@ contexts: scope: support.constant.cocoa.objc - match: \bNS(RuleEditor|G(arbageCollector|radient)|MapTable|HashTable|Co(ndition|llectionView(Item)?)|T(oolbarItemGroup|extInputClient|r(eeNode|ackingArea))|InvocationOperation|Operation(Queue)?|D(ictionaryController|ockTile)|P(ointer(Functions|Array)|athC(o(ntrol(Delegate)?|mponentCell)|ell(Delegate)?)|r(intPanelAccessorizing|edicateEditor(RowTemplate)?))|ViewController|FastEnumeration|Animat(ionContext|ablePropertyContainer))\b scope: support.class.cocoa.leopard.objc - - match: \bNS(R(u(nLoop|ler(Marker|View))|e(sponder|cursiveLock|lativeSpecifier)|an(domSpecifier|geSpecifier))|G(etCommand|lyph(Generator|Storage|Info)|raphicsContext)|XML(Node|D(ocument|TD(Node)?)|Parser|Element)|M(iddleSpecifier|ov(ie(View)?|eCommand)|utable(S(tring|et)|C(haracterSet|opying)|IndexSet|D(ictionary|ata)|URLRequest|ParagraphStyle|A(ttributedString|rray))|e(ssagePort(NameServer)?|nu(Item(Cell)?|View)?|t(hodSignature|adata(Item|Query(ResultGroup|AttributeValueTuple)?)))|a(ch(BootstrapServer|Port)|trix))|B(itmapImageRep|ox|u(ndle|tton(Cell)?)|ezierPath|rowser(Cell)?)|S(hadow|c(anner|r(ipt(SuiteRegistry|C(o(ercionHandler|mmand(Description)?)|lassDescription)|ObjectSpecifier|ExecutionContext|WhoseTest)|oll(er|View)|een))|t(epper(Cell)?|atus(Bar|Item)|r(ing|eam))|imple(HorizontalTypesetter|CString)|o(cketPort(NameServer)?|und|rtDescriptor)|p(e(cifierTest|ech(Recognizer|Synthesizer)|ll(Server|Checker))|litView)|e(cureTextField(Cell)?|t(Command)?|archField(Cell)?|rializer|gmentedC(ontrol|ell))|lider(Cell)?|avePanel)|H(ost|TTP(Cookie(Storage)?|URLResponse)|elpManager)|N(ib(Con(nector|trolConnector)|OutletConnector)?|otification(Center|Queue)?|u(ll|mber(Formatter)?)|etService(Browser)?|ameSpecifier)|C(ha(ngeSpelling|racterSet)|o(n(stantString|nection|trol(ler)?|ditionLock)|d(ing|er)|unt(Command|edSet)|pying|lor(Space|P(ick(ing(Custom|Default)|er)|anel)|Well|List)?|m(p(oundPredicate|arisonPredicate)|boBox(Cell)?))|u(stomImageRep|rsor)|IImageRep|ell|l(ipView|o(seCommand|neCommand)|assDescription)|a(ched(ImageRep|URLResponse)|lendar(Date)?)|reateCommand)|T(hread|ypesetter|ime(Zone|r)|o(olbar(Item(Validations)?)?|kenField(Cell)?)|ext(Block|Storage|Container|Tab(le(Block)?)?|Input|View|Field(Cell)?|List|Attachment(Cell)?)?|a(sk|b(le(Header(Cell|View)|Column|View)|View(Item)?))|reeController)|I(n(dex(S(pecifier|et)|Path)|put(Manager|S(tream|erv(iceProvider|er(MouseTracker)?)))|vocation)|gnoreMisspelledWords|mage(Rep|Cell|View)?)|O(ut(putStream|lineView)|pen(GL(Context|Pixel(Buffer|Format)|View)|Panel)|bj(CTypeSerializationCallBack|ect(Controller)?))|D(i(st(antObject(Request)?|ributed(NotificationCenter|Lock))|ctionary|rectoryEnumerator)|ocument(Controller)?|e(serializer|cimalNumber(Behaviors|Handler)?|leteCommand)|at(e(Components|Picker(Cell)?|Formatter)?|a)|ra(wer|ggingInfo))|U(ser(InterfaceValidations|Defaults(Controller)?)|RL(Re(sponse|quest)|Handle(Client)?|C(onnection|ache|redential(Storage)?)|Download(Delegate)?|Prot(ocol(Client)?|ectionSpace)|AuthenticationChallenge(Sender)?)?|n(iqueIDSpecifier|doManager|archiver))|P(ipe|o(sitionalSpecifier|pUpButton(Cell)?|rt(Message|NameServer|Coder)?)|ICTImageRep|ersistentDocument|DFImageRep|a(steboard|nel|ragraphStyle|geLayout)|r(int(Info|er|Operation|Panel)|o(cessInfo|tocolChecker|perty(Specifier|ListSerialization)|gressIndicator|xy)|edicate))|E(numerator|vent|PSImageRep|rror|x(ception|istsCommand|pression))|V(iew(Animation)?|al(idated(ToolbarItem|UserInterfaceItem)|ue(Transformer)?))|Keyed(Unarchiver|Archiver)|Qui(ckDrawView|tCommand)|F(ile(Manager|Handle|Wrapper)|o(nt(Manager|Descriptor|Panel)?|rm(Cell|atter)))|W(hoseSpecifier|indow(Controller)?|orkspace)|L(o(c(k(ing)?|ale)|gicalTest)|evelIndicator(Cell)?|ayoutManager)|A(ssertionHandler|nimation|ctionCell|ttributedString|utoreleasePool|TSTypesetter|ppl(ication|e(Script|Event(Manager|Descriptor)))|ffineTransform|lert|r(chiver|ray(Controller)?)))\b + - match: \bNS(R(u(nLoop|ler(Marker|View))|e(sponder|cursiveLock|lativeSpecifier)|an(domSpecifier|geSpecifier))|G(etCommand|lyph(Generator|Storage|Info)|raphicsContext)|XML(Node|D(ocument|TD(Node)?)|Parser|Element)|M(iddleSpecifier|ov(ie(View)?|eCommand)|utable(S(tring|et)|C(haracterSet|opying)|IndexSet|D(ictionary|ata)|URLRequest|ParagraphStyle|A(ttributedString|rray))|e(ssagePort(NameServer)?|nu(Item(Cell)?|View)?|t(hodSignature|adata(Item|Query(ResultGroup|AttributeValueTuple)?)))|a(ch(BootstrapServer|Port)|trix))|B(itmapImageRep|ox|u(ndle|tton(Cell)?)|ezierPath|rowser(Cell)?)|S(hadow|c(anner|r(ipt(SuiteRegistry|C(o(ercionHandler|mmand(Description)?)|lassDescription)|ObjectSpecifier|ExecutionContext|WhoseTest)|oll(er|View)|een))|t(epper(Cell)?|atus(Bar|Item)|r(ing|eam))|imple(HorizontalTypesetter|CString)|o(cketPort(NameServer)?|und|rtDescriptor)|p(e(cifierTest|ech(Recognizer|Synthesizer)|ll(Server|Checker))|litView)|e(cureTextField(Cell)?|t(Command)?|archField(Cell)?|rializer|gmentedC(ontrol|ell))|lider(Cell)?|avePanel)|H(ost|TTP(Cookie(Storage)?|URLResponse)|elpManager)|N(ib(Con(nector|trolConnector)|OutletConnector)?|otification(Center|Queue)?|u(ll|mber(Formatter)?)|etService(Browser)?|ameSpecifier)|C(ha(ngeSpelling|racterSet)|o(n(stantString|nection|trol(ler)?|ditionLock)|d(ing|er)|unt(Command|edSet)|pying|lor(Space|P(ick(ing(Custom|Default)|er)|anel)|Well|List)?|m(p(oundPredicate|arisonPredicate)|boBox(Cell)?))|u(stomImageRep|rsor)|IImageRep|ell|l(ipView|o(seCommand|neCommand)|assDescription)|a(ched(ImageRep|URLResponse)|lendar(Date)?)|reateCommand)|T(hread|ypesetter|ime(Zone|r)|o(olbar(Item(Validations)?)?|kenField(Cell)?)|ext(Block|Storage|Container|Tab(le(Block)?)?|Input|View|Field(Cell)?|List|Attachment(Cell)?)?|a(sk|b(le(Header(Cell|View)|Column|View)|View(Item)?))|reeController)|I(n(dex(S(pecifier|et)|Path)|put(Manager|S(tream|erv(iceProvider|er(MouseTracker)?)))|vocation)|gnoreMisspelledWords|mage(Rep|Cell|View)?)|O(ut(putStream|lineView)|pen(GL(Context|Pixel(Buffer|Format)|View)|Panel)|bj(CTypeSerializationCallBack|ect(Controller)?))|D(i(st(antObject(Request)?|ributed(NotificationCenter|Lock))|ctionary|rectoryEnumerator)|ocument(Controller)?|e(serializer|cimalNumber(Behaviors|Handler)?|leteCommand)|at(e(Components|Picker(Cell)?|Formatter)?|a)|ra(wer|ggingInfo))|U(ser(InterfaceValidations|Defaults(Controller)?)|RL(Re(sponse|quest)|Handle(Client)?|C(onnection|ache|redential(Storage)?)|Download(Delegate)?|Prot(ocol(Client)?|ectionSpace)|AuthenticationChallenge(Sender)?)?|n(iqueIDSpecifier|doManager|archiver))|P(ipe|o(sitionalSpecifier|pUpButton(Cell)?|rt(Message|NameServer|Coder)?)|ICTImageRep|ersistentDocument|DFImageRep|a(steboard|nel|ragraphStyle|geLayout)|r(int(Info|er|Operation|Panel)|o(cessInfo|tocolChecker|perty(Specifier|ListSerialization)|gressIndicator|xy)|edicate))|E(numerator|vent|PSImageRep|rror|x(ception|istsCommand|pression))|V(iew(Animation)?|al(idated(ToobarItem|UserInterfaceItem)|ue(Transformer)?))|Keyed(Unarchiver|Archiver)|Qui(ckDrawView|tCommand)|F(ile(Manager|Handle|Wrapper)|o(nt(Manager|Descriptor|Panel)?|rm(Cell|atter)))|W(hoseSpecifier|indow(Controller)?|orkspace)|L(o(c(k(ing)?|ale)|gicalTest)|evelIndicator(Cell)?|ayoutManager)|A(ssertionHandler|nimation|ctionCell|ttributedString|utoreleasePool|TSTypesetter|ppl(ication|e(Script|Event(Manager|Descriptor)))|ffineTransform|lert|r(chiver|ray(Controller)?)))\b scope: support.class.cocoa.objc - match: \bNS(R(oundingMode|ule(Editor(RowType|NestingMode)|rOrientation)|e(questUserAttentionType|lativePosition))|G(lyphInscription|radientDrawingOptions)|XML(NodeKind|D(ocumentContentKind|TDNodeKind)|ParserError)|M(ultibyteGlyphPacking|apTableOptions)|B(itmapFormat|oxType|ezierPathElement|ackgroundStyle|rowserDropOperation)|S(tr(ing(CompareOptions|DrawingOptions|EncodingConversionOptions)|eam(Status|Event))|p(eechBoundary|litViewDividerStyle)|e(archPathD(irectory|omainMask)|gmentS(tyle|witchTracking))|liderType|aveOptions)|H(TTPCookieAcceptPolicy|ashTableOptions)|N(otification(SuspensionBehavior|Coalescing)|umberFormatter(RoundingMode|Behavior|Style|PadPosition)|etService(sError|Options))|C(haracterCollection|o(lor(RenderingIntent|SpaceModel|PanelMode)|mp(oundPredicateType|arisonPredicateModifier))|ellStateValue|al(culationError|endarUnit))|T(ypesetterControlCharacterAction|imeZoneNameStyle|e(stComparisonOperation|xt(Block(Dimension|V(erticalAlignment|alueType)|Layer)|TableLayoutAlgorithm|FieldBezelStyle))|ableView(SelectionHighlightStyle|ColumnAutoresizingStyle)|rackingAreaOptions)|I(n(sertionPosition|te(rfaceStyle|ger))|mage(RepLoadStatus|Scaling|CacheMode|FrameStyle|LoadStatus|Alignment))|Ope(nGLPixelFormatAttribute|rationQueuePriority)|Date(Picker(Mode|Style)|Formatter(Behavior|Style))|U(RL(RequestCachePolicy|HandleStatus|C(acheStoragePolicy|redentialPersistence))|Integer)|P(o(stingStyle|int(ingDeviceType|erFunctionsOptions)|pUpArrowPosition)|athStyle|r(int(ing(Orientation|PaginationMode)|erTableStatus|PanelOptions)|opertyList(MutabilityOptions|Format)|edicateOperatorType))|ExpressionType|KeyValue(SetMutationKind|Change)|QTMovieLoopMode|F(indPanel(SubstringMatchType|Action)|o(nt(RenderingMode|FamilyClass)|cusRingPlacement))|W(hoseSubelementIdentifier|ind(ingRule|ow(B(utton|ackingLocation)|SharingType|CollectionBehavior)))|L(ine(MovementDirection|SweepDirection|CapStyle|JoinStyle)|evelIndicatorStyle)|Animation(BlockingMode|Curve))\b scope: support.type.cocoa.leopard.objc - match: \bNS(R(ect(Edge)?|ange)|G(lyph(Relation|LayoutMode)?|radientType)|M(odalSession|a(trixMode|p(Table|Enumerator)))|B(itmapImageFileType|orderType|uttonType|ezelStyle|ackingStoreType|rowserColumnResizingType)|S(cr(oll(er(Part|Arrow)|ArrowPosition)|eenAuxiliaryOpaque)|tringEncoding|ize|ocketNativeHandle|election(Granularity|Direction|Affinity)|wapped(Double|Float)|aveOperationType)|Ha(sh(Table|Enumerator)|ndler(2)?)|C(o(ntrol(Size|Tint)|mp(ositingOperation|arisonResult))|ell(State|Type|ImagePosition|Attribute))|T(hreadPrivate|ypesetterGlyphInfo|i(ckMarkPosition|tlePosition|meInterval)|o(ol(TipTag|bar(SizeMode|DisplayMode))|kenStyle)|IFFCompression|ext(TabType|Alignment)|ab(State|leViewDropOperation|ViewType)|rackingRectTag)|ImageInterpolation|Zone|OpenGL(ContextAuxiliary|PixelFormatAuxiliary)|D(ocumentChangeType|atePickerElementFlags|ra(werState|gOperation))|UsableScrollerParts|P(oint|r(intingPageOrder|ogressIndicator(Style|Th(ickness|readInfo))))|EventType|KeyValueObservingOptions|Fo(nt(SymbolicTraits|TraitMask|Action)|cusRingType)|W(indow(OrderingMode|Depth)|orkspace(IconCreationOptions|LaunchOptions)|ritingDirection)|L(ineBreakMode|ayout(Status|Direction))|A(nimation(Progress|Effect)|ppl(ication(TerminateReply|DelegateReply|PrintReply)|eEventManagerSuspensionID)|ffineTransformStruct|lertStyle))\b scope: support.type.cocoa.objc # Catch-all - - match: \bNS\w+\b + - match: \bN\w+\b + pop: 1 - match: '' - pop: true - - - ############################################################################# - # The following are Objective-C-specific contexts that should not be reused. - # This is because they push into subcontexts and use variables that are - # Objective-C-specific. - ############################################################################# - - ## Common context layout - - global: - - include: objc-structures - - include: early-expressions - - match: '^\s*(?=\w+)' - push: global-modifier - - include: late-expressions - - statements: - - include: preprocessor-statements - - include: scope:source.c#label - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: typedef - - include: keywords-parens - - include: keywords - - include: numbers - - include: operators - - include: strings - - include: parens - - include: block - - include: variables - - include: constants - - include: access - - match: ',' - scope: punctuation.separator.objc - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.objc - - include: bracketed-content - - include: brackets - - late-expressions: - - include: modifiers-parens - - include: modifiers - - include: types - - include: function-call - - match: ';' - scope: punctuation.terminator.objc - - comments: - - include: scope:source.c#comments - - access: - - include: scope:source.c#access - - keywords: - - include: unique-keywords - - include: scope:source.c#keywords - - numbers: - - include: scope:source.c#numbers - - operators: - - include: scope:source.c#operators - - strings: - - include: unique-strings - - include: scope:source.c#strings - - variables: - - include: unique-variables - - include: scope:source.c#variables - - constants: - - include: unique-constants - - match: '(?=\bNS\w+\b)' - push: ns-identifiers - - include: scope:source.c#constants - - modifiers: - - include: unique-modifiers - - include: scope:source.c#modifiers - - types: - - include: unique-types - - match: '(?=\bNS\w+\b)' - push: ns-identifiers - - include: scope:source.c#types - - ## Objective-C-specific contexts - - bracketed-content: - - match: '(\[)\s*(?={{identifier}}\s+[^\s,])' - captures: - 1: punctuation.section.scope.begin.objc - push: - - meta_scope: meta.bracketed.objc - - match: '\]' - scope: punctuation.section.scope.end.objc - pop: true - - match: \s*(NSPredicate)\s+(predicateWithFormat(:)) - captures: - 1: support.class.cocoa - 2: support.function.any-method.objc - 3: punctuation.separator.arguments.objc - push: - - meta_scope: meta.function-call.predicate.objc - - include: ns-predicate - - include: expressions - - match: '\s+(\w+)(?=\s*\])' - captures: - 1: support.function.any-method.objc - - match: '\s+(\w+(:))' - captures: - 1: support.function.any-method.objc - 2: punctuation.separator.arguments.objc - push: - - meta_scope: meta.function-call.objc - - match: '(?=\])' - pop: true - - match: \b\w+(:) - scope: support.function.any-method.name-of-parameter.objc - captures: - 1: punctuation.separator.arguments.objc - - include: expressions - - include: expressions - - objc-structures: - - match: '((@)(interface|protocol))(?!.+;)\s+([[:alpha:]_][[:alnum:]_]*)\s*((:)(?:\s*)([[:alpha:]][[:alnum:]]*))?(\s|\n)?' - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - 4: entity.name.type.objc - 6: punctuation.definition.entity.other.inherited-class.objc - 7: entity.other.inherited-class.objc - 8: meta.divider.objc - 9: meta.inherited-class.objc - push: - - meta_scope: meta.interface-or-protocol.objc - - meta_content_scope: meta.scope.interface.objc - - match: ((@)end)\b - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - match: '((@)(implementation))\s+([[:alpha:]_][[:alnum:]_]*)\s*(?::\s*([[:alpha:]][[:alnum:]]*))?' - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - 4: entity.name.type.objc - 5: entity.other.inherited-class.objc - push: - - meta_scope: meta.implementation.objc - - meta_content_scope: meta.scope.implementation.objc - - match: ((@)end)\b - captures: - 1: storage.type.objc - 2: punctuation.definition.storage.type.objc - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - objc-structure-body: - - include: properties - - include: protocol_list - - include: method - - include: expressions - - method: - - match: ^(-|\+)\s* - push: - - meta_scope: meta.function.objc - - match: '\{' - scope: punctuation.section.block.begin.objc - set: - - meta_scope: meta.block.objc - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: (?=@end\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc - pop: true - - include: statements - - match: '(?=#|@end|;)' - pop: true - - match: '\(' - scope: meta.return-type.objc punctuation.definition.type.objc - push: - - meta_scope: meta.return-type.objc - - match: (\))\s*(\w+\b) - captures: - 1: punctuation.definition.type.objc - 2: entity.name.function.objc - pop: true - - include: protocol_list - - include: protocol_type_qualifier - - include: expressions - - match: \b\w+(?=:) - scope: entity.name.function.name-of-parameter.objc - - match: ((:))\s*(\() - captures: - 1: entity.name.function.name-of-parameter.objc - 2: punctuation.separator.arguments.objc - 3: punctuation.definition.type.objc - push: - - meta_scope: meta.argument-type.objc - - match: (\))\s*(\w+\b)? - captures: - 1: punctuation.definition.type.objc - 2: variable.parameter.function.objc - pop: true - - include: protocol_list - - include: protocol_type_qualifier - - include: expressions - - include: comments - - include: attribute - - match: '(,)\s+(\.\.\.)\s*' - captures: - 1: punctuation.separator.objc - 2: keyword.operator.variadic.objc - push: - - include: scope:source.c#function-call - - match: '(?=\S)' - pop: true - - ## Preprocessor for objc-structures - - preprocessor-objc-structures: - - include: preprocessor-rule-enabled-objc-structures - - include: preprocessor-rule-disabled-objc-structures - - preprocessor-rule-disabled-objc-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: objc-structure-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-objc-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: objc-structure-body - - ################################ - # Directly from C.sublime-syntax - ################################ - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \* - scope: keyword.operator.objc - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - {{identifier}} - (\s+{{identifier}}(?!\s*[{=;])|\s*\*+) - ) - ) - captures: - 1: keyword.declaration.objc - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/union - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{control_keywords}})\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_scope: meta.function-call.objc - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - match: (?={{identifier}}\s*\() - set: - - include: function-call - - match: '' - pop: true - - include: types - - match: '{{identifier}}' - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \* - scope: keyword.operator.objc - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Identifier that is not the function name - likely a macro - - match: '{{identifier}}(?!\s*(\(|$))' - # Real function definition - - match: '{{identifier}}(?=\s*(\(|$))' - scope: meta.function.objc entity.name.function.objc - set: function-definition-params - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.objc - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.objc meta.group.objc punctuation.section.group.begin.objc - set: - - meta_content_scope: meta.function.parameters.objc meta.group.objc - - match : \) - scope: punctuation.section.group.end.objc - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)))' - scope: variable.parameter.objc - - include: expressions - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.objc - - include: comments - - match: '(?=;)' - pop: true - - match: \b(const|final|noexcept|override)\b - scope: storage.modifier.objc - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-body: - - meta_content_scope: meta.function.objc - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.function.objc meta.block.objc - - match: '\}' - scope: meta.function.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - data-structures: - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{identifier}}\s+{{identifier}}\s*[=;\[])' - scope: keyword.declaration.objc - - match: '\bstruct\b' - scope: keyword.declaration.struct.objc - set: data-structures-struct-definition - - match: '\benum\b' - scope: keyword.declaration.enum.objc - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.objc - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - - data-structures-struct-definition: - - meta_scope: meta.struct.objc - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.struct.forward-decl.objc - - match: '{{identifier}}' - scope: entity.name.struct.objc - set: data-structures-struct-definition-after-name - - include: data-structures-struct-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-name: - - meta_scope: meta.struct.objc - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-struct-definition-block-start - - data-structures-struct-definition-block-start: - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.struct.objc meta.block.objc - - match: '\}' - scope: meta.struct.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.objc - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.enum.forward-decl.objc - - match: '{{identifier}}' - scope: entity.name.enum.objc - set: data-structures-enum-definition-after-name - - include: data-structures-enum-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-name: - - meta_scope: meta.enum.objc - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-enum-definition-block-start - - data-structures-enum-definition-block-start: - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.enum.objc meta.block.objc - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - include: data-structures-body-enum - - data-structures-union-definition: - - meta_scope: meta.union.objc - - include: data-structures-definition-common-begin - - include: data-structures-definition-common-macro - - match: '{{identifier}}(?=\s*;)' - scope: entity.name.union.forward-decl.objc - - match: '{{identifier}}' - scope: entity.name.union.objc - set: data-structures-union-definition-after-name - - include: data-structures-union-definition-block-start - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-name: - - meta_scope: meta.union.objc - - include: data-structures-definition-common-begin - - match: '(?=;)' - pop: true - - include: data-structures-union-definition-block-start - - data-structures-union-definition-block-start: - - match: '\{' - scope: meta.block.objc punctuation.section.block.begin.objc - set: - - meta_content_scope: meta.union.objc meta.block.objc - - match: '\}' - scope: meta.union.objc meta.block.objc punctuation.section.block.end.objc - pop: true - - include: data-structures-body - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: modifiers-parens - - include: modifiers - - data-structures-definition-common-macro: - # Handle macros so they aren't matched as the class name - - match: '\b[[:upper:][:digit:]_]+\b(?!\s*($|\{))' - - data-structures-definition-common-end: - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - include: expressions - - data-structures-body-enum: - - include: comments - - include: preprocessor-data-structures - - match: '(?={{before_tag}})' - push: data-structures - - match: '{{identifier}}' - scope: entity.name.constant.objc - push: constant-value - - match: ',' - scope: punctuation.separator.objc - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - block: - - match: '\{' - scope: punctuation.section.block.begin.objc - push: - - meta_scope: meta.block.objc - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc - pop: true - - include: statements - - parens: - - match: \( - scope: punctuation.section.group.begin.objc - push: - - meta_scope: meta.group.objc - - match: \) - scope: punctuation.section.group.end.objc - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.objc - push: - - meta_scope: meta.brackets.objc - - match: \] - scope: punctuation.section.brackets.end.objc - pop: true - - include: expressions - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.objc - push: - - match: ':' - scope: punctuation.separator.objc - pop: true - - include: expressions - - modifiers-parens: - - include: attribute - - match: \b(__declspec)(\() - captures: - 1: storage.modifier.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.objc - - match: ',' - scope: punctuation.separator.objc - - match: '=' - scope: keyword.operator.assignment.objc - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.objc - - attribute: - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push : - - meta_scope: meta.attribute.objc - - meta_content_scope: meta.group.objc - - include: parens - - include: strings - - match: \)\) - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - keywords-parens: - - match: '\b(sizeof)\b\s*(\()' - captures: - 1: keyword.operator.word.objc - 2: meta.group.objc punctuation.section.group.begin.objc - push: - - meta_content_scope: meta.group.objc - - match: '\)' - scope: meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.objc - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.objc - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions - - function-call: - - match: (?={{identifier}}\s*\() - push: - - meta_content_scope: meta.function-call.objc - - include: scope:source.c#c99 - - match: '{{identifier}}' - scope: variable.function.objc - - match: '\(' - scope: meta.group.objc punctuation.section.group.begin.objc - set: - - meta_content_scope: meta.function-call.objc meta.group.objc - - match : \) - scope: meta.function-call.objc meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc - push: - - meta_scope: meta.preprocessor.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.objc - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.objc - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - 3: meta.number.integer.decimal.objc constant.numeric.value.objc - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.else.objc - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc - push: - - meta_scope: meta.preprocessor.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.objc - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{identifier}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.objc - - include: scope:source.c#c99 - - match: '{{identifier}}' - scope: variable.function.objc - - match: '\(' - scope: meta.group.objc punctuation.section.group.begin.objc - set: preprocessor-if-branch-function-call-arguments - - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.objc meta.group.objc - - match : \) - scope: meta.function-call.objc meta.group.objc punctuation.section.group.end.objc - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.objc meta.group.objc - - match: \) - scope: meta.function-call.objc meta.group.objc punctuation.section.group.end.objc - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.objc - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.objc - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc keyword.control.import.objc - pop: true - - match: \} - scope: punctuation.section.block.end.objc - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.objc - push: - - match: '\{' - scope: punctuation.section.block.begin.objc - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.objc keyword.control.import.define.objc - push: - - meta_content_scope: meta.preprocessor.macro.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.objc - set: - - match: '\(' - scope: punctuation.section.group.begin.objc - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.objc - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.objc meta.group.objc - - match: '{{identifier}}' - scope: variable.parameter.objc - - match: \) - scope: punctuation.section.group.end.objc - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.objc - push: - - match: '{{identifier}}' - scope: variable.parameter.objc - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.objc - captures: - 1: punctuation.definition.comment.objc - 2: punctuation.definition.comment.objc - - match: '\S+' - scope: invalid.illegal.unexpected-character.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc - - match: (/\*).*(\*/) - scope: comment.block.objc - captures: - 1: punctuation.definition.comment.objc - 2: punctuation.definition.comment.objc - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.objc - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.objc - - match: '\}' - scope: punctuation.section.block.end.objc - - include: expressions - - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.objc - push: - - meta_scope: meta.preprocessor.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc - - match: ^\s*(#\s*(endif)\b) - captures: - 1: meta.preprocessor.objc - 2: keyword.control.import.objc - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.objc - push: - - meta_scope: meta.preprocessor.diagnostic.objc - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.objc - - match: ^\s*(#\s*(?:include|include_next|embed))\b - captures: - 1: keyword.control.import.include.objc - push: - - meta_scope: meta.preprocessor.include.objc - - include: preprocessor-other-include-common - - match: ^\s*(#\s*import)\b - captures: - 1: keyword.control.import.import.objc - push: - - meta_scope: meta.preprocessor.import.objc - - include: preprocessor-other-include-common - - include: scope:source.c#preprocessor-practical-workarounds - - preprocessor-other-include-common: - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.double.include.objc - - match: '"' - scope: punctuation.definition.string.end.objc - pop: true - - match: < - scope: punctuation.definition.string.begin.objc - push: - - meta_scope: string.quoted.other.lt-gt.include.objc - - match: ">" - scope: punctuation.definition.string.end.objc - pop: true + pop: 1 From 38438e00b49196b0d4df073f6e5f6c836349f547 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 23:34:08 -0600 Subject: [PATCH 17/66] Fix declspec being silly --- C++/C.sublime-syntax | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 933556cd44..b2381362cc 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -608,13 +608,14 @@ contexts: - match: \b(const|volatile|restrict|_Atomic|register|static|inline|extern|register|thread_local|_Thread_local|_Noreturn|noreturn|_Alignas)\b scope: storage.modifier.c + - match: \b(__declspec)(\()\b + captures: + 1: storage.modifier.c + 2: scope: punctuation.section.group.begin.c + push: declspec - match: \b__declspec\b scope: storage.modifier.c - push: - - match: \( - scope: punctuation.section.group.begin.c - push: declspec - # __attribute__ alone will already be storage.modifier.c from constant + - match: \b(__attribute__)\s*(\(\() captures: 1: storage.modifier.c @@ -670,7 +671,7 @@ contexts: - include: expression - match: \) scope: punctuation.section.group.end.c - pop: 2 + pop: 1 gnu-attribute: - meta_scope: meta.group.c meta.attribute.c From 568b42697f88f20ee58b65480ec4f27e0d92971f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 10 Feb 2025 23:36:31 -0600 Subject: [PATCH 18/66] huge mistake --- 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 b2381362cc..e90b5f95dd 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -611,7 +611,7 @@ contexts: - match: \b(__declspec)(\()\b captures: 1: storage.modifier.c - 2: scope: punctuation.section.group.begin.c + 2: punctuation.section.group.begin.c push: declspec - match: \b__declspec\b scope: storage.modifier.c From c69b396cb68104b7fe235c3bf415ff6ef38d1a07 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 11 Feb 2025 00:03:48 -0600 Subject: [PATCH 19/66] Add fallback for messed up parenthesis --- C++/C.sublime-syntax | 28 ++++++++++++++++++-------- Objective-C/Objective-C.sublime-syntax | 4 ++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index e90b5f95dd..1635599aa1 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -200,13 +200,16 @@ contexts: captures: 1: entity.name.function.c 2: punctuation.section.group.begin.c - push: function.params + push: [function.tail, function.params] - match: \b{{identifier}}\b function.params: - meta_content_scope: meta.function.parameters.c meta.group.c - match: \) scope: punctuation.section.group.end.c - set: function.tail + pop: 1 + - match: \}|\] # Fallback + scope: invalid.illegal.stray-bracket-end.c + pop: 2 - include: keyword - match: (? Date: Tue, 11 Feb 2025 00:07:53 -0600 Subject: [PATCH 20/66] Macros should only have parameters if there's no space between the name and parenthesis --- 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 1635599aa1..5e1a7ea61c 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -104,7 +104,7 @@ contexts: - include: eol-pop preprocessor.define: - include: eol-pop - - match: \s*({{identifier}})\s*(\() + - match: \s*({{identifier}})(\() captures: 1: entity.name.macro.c support.macro.c 2: punctuation.section.group.begin.c From f703731a34bb89828bcb893ceb87b9ad3b67541f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 11 Feb 2025 00:14:30 -0600 Subject: [PATCH 21/66] Add some more objc storage types --- Objective-C/Objective-C.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 543d426a3f..0b1951540b 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -191,7 +191,7 @@ contexts: keyword.storage: - meta_prepend: true - - match: (?:\b(?:__nonnull|nonnull|nullable|IBOutlet|IBInspectable)\b|@(?:private|public|protected|package|optional|required)) + - match: (?:\b(?:__nonnull|nonnull|nullable|IBOutlet|IBInspectable|__block|__weak|__strong|__autoreleasing)\b|@(?:private|public|protected|package|optional|required)) scope: storage.modifier.objc keyword: - meta_prepend: true From d4a595a6ec08f7c505743997c0fee39105e54933 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 11 Feb 2025 09:46:04 -0600 Subject: [PATCH 22/66] Add self access to ObjC, remove look-behinds from both syntaxes --- C++/C.sublime-syntax | 28 +++++++--- Objective-C/Objective-C.sublime-syntax | 75 ++++++++++++++++++-------- 2 files changed, 74 insertions(+), 29 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 5e1a7ea61c..5ad162c56b 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -210,19 +210,29 @@ contexts: - match: \}|\] # Fallback scope: invalid.illegal.stray-bracket-end.c pop: 2 - - include: keyword + - match: ; # Fallback + scope: invalid.illegal.unexpected-terminator.c + pop: 2 - - match: (? - scope: punctuation.section.scope.end.objc - pop: 1 + - include: protocol-list - match: ':' scope: punctuation.separator.objc - include: expression-identifiers @@ -114,9 +107,15 @@ contexts: 2: punctuation.separator.arguments.objc 3: punctuation.section.group.begin.objc push: [selector.param, enclosure.parenthesis] - - match: \b({{identifier}})\s*(?) + scope: punctuation.section.scope.begin.objc + push: + - include: expression-identifiers + - meta_scope: meta.protocol-list.objc + - match: \> + scope: punctuation.section.scope.end.objc + pop: 1 + gnu-attribute: - meta_append: true - match: \b(objc_direct)\b @@ -186,12 +195,16 @@ contexts: keyword.control: - meta_prepend: true - - match: \@(try|catch|finally|throw|autoreleasepool|import|synchronized)\b + - match: \@(autoreleasepool|import|synchronized)\b scope: keyword.control.objc + - match: \@(try|catch|finally|throw)\b + scope: keyword.control.exception.objc keyword.storage: - meta_prepend: true - - match: (?:\b(?:__nonnull|nonnull|nullable|IBOutlet|IBInspectable|__block|__weak|__strong|__autoreleasing)\b|@(?:private|public|protected|package|optional|required)) + - match: \b(nonnull|nullable|_Nullable|_Nonnull|IBOutlet|IBInspectable|__(unused|nonnull|block|weak|strong|autoreleasing|bridge))\b + scope: storage.modifier.objc + - match: \@(private|public|protected|package|optional|required)\b scope: storage.modifier.objc keyword: - meta_prepend: true @@ -207,7 +220,7 @@ contexts: type: - meta_prepend: true - - match: \(\s*(\^)({{identifier}})\s*\)\s*(\() + - match: \(\s*(\^)({{identifier}})?\s*\)\s*(\() captures: 1: keyword.operator.objc 2: entity.name.type.typedef.objc @@ -220,6 +233,22 @@ contexts: 1: keyword.declaration.class.objc 2: entity.name.type.class.objc + expression: + - meta_prepend: true + - match: (\^)\s*(?=\() + captures: + 1: keyword.operator.bitwise.objc + branch_point: block-fn + branch: [block-fn, pop-immediately] + - match: '(@catch)\s*(\()' + captures: + 1: keyword.control.exception.objc + 2: punctuation.section.group.begin.objc + push: function.params + - match: (?=\b(self)\s*(\.)) + push: self-access + - include: protocol-list + block-fn: - match: \( scope: punctuation.section.group.begin.objc @@ -229,13 +258,15 @@ contexts: set: enclosure.block - match: (?=\S) fail: block-fn - expression: - - meta_prepend: true - - match: (\^)\s*(?=\() + self-access: + - match: \b(self)\b captures: - 1: keyword.operator.bitwise.objc - branch_point: block-fn - branch: [block-fn, pop-immediately] + 1: variable.language.objc + - match: \s*(\.)\s*({{identifier}}) + captures: + 1: keyword.operator.accessor.objc + 2: variable.other.readwrite.member.objc + - include: pop-immediately message.func: - match: '\b({{identifier}})\s*(:)' @@ -251,6 +282,8 @@ contexts: message: - meta_scope: meta.bracketed.objc + - match: (?=\b(self)\s*(\.)) + push: self-access - include: type - include: keyword - include: constant @@ -259,10 +292,10 @@ contexts: - include: expression.call - include: enclosure - - match: (?<=[\)\]\}\w])\s*(?={{identifier}}\s*:) + - match: (?={{identifier}}\s*:) set: message.func - - match: (?<=[\)\]\}\w])\s*({{identifier}})\s*(\]) + - match: ({{identifier}})\s*(\]) captures: 1: entity.name.function.method.objc 2: punctuation.section.brackets.end.objc @@ -273,7 +306,7 @@ contexts: fail: message enclosure: - meta_prepend: true - - match: \[ + - match: \[(?!\s*{{identifier}}:) scope: punctuation.section.brackets.begin branch_point: message branch: [message, enclosure.brackets] From f00c31553d90a9dd23131565f2f02b5b366fc2f4 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:29:41 -0600 Subject: [PATCH 23/66] Don't include prototype for single and angle strings --- C++/C.sublime-syntax | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 5ad162c56b..e9ef88502c 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -218,7 +218,7 @@ contexts: push: - match: \s set: function.params.name - - include: expression-identifiers + - include: expression - include: expression function.params.name: - match: (?=[\]\}\);]) # Fallback @@ -441,12 +441,14 @@ contexts: - include: string.format string.single: - meta_scope: string.quoted.single.c + - meta_include_prototype: false - match: \' scope: punctuation.definition.string.end.c pop: 1 - include: string.escape string.angled: - meta_scope: string.quoted.other.c + - meta_include_prototype: false - match: \> scope: punctuation.definition.string.end.c pop: 1 From be03dd4f06d0ba6eb931be5a6f1260d571320fd1 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:31:08 -0600 Subject: [PATCH 24/66] Update Syntax Tests --- C++/syntax_test_c.c | 1777 ++++++++++---------- Objective-C/syntax_test_objc.m | 2769 ++++++++++++++++++-------------- 2 files changed, 2480 insertions(+), 2066 deletions(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 3155c7bcd8..e8d0339e61 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,483 +1,483 @@ -/* SYNTAX TEST "Packages/C++/C.sublime-syntax" */ +// SYNTAX TEST "Packages/C++/C.sublime-syntax" // Comment -/* ^^^^^^^^^^ comment.line.double-slash.c */ -/* ^^ punctuation.definition.comment.c */ +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c // My \ Comment -/*^^^^^^^^^ comment.line.double-slash.c */ +//^^^^^^^^^ comment.line.double-slash.c /* Foo Bar Baz*/ -/* ^^^^^^^^^^^^^^^^ comment.block.c */ -/* ^^ punctuation.definition.comment.c */ -/* ^^ punctuation.definition.comment.c */ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c */ -/* ^^ invalid.illegal.stray-comment-end.c */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// // Numbers ///////////////////////////////////////////// 1234567890 -/* ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c 1'234'567'890 -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c 0x123456789abcdef -/* ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^^^^^ constant.numeric.value.c */ +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c 0x123'456'789'abc'def -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c */ +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c 012345670 -/* ^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^^ constant.numeric.value.c */ +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c 012'345'670 -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c 0b100110 -/* ^^^^^^^^ meta.number.integer.binary.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^ constant.numeric.value.c */ +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c 0b100'110 -/* ^^^^^^^^^ meta.number.integer.binary.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c 314lUJ 314uLLj 314iLu 314llI 314F 314f -/* ^^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c 3.14f 314.l 3.14L -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c 314e15 3.14e-15 -/* ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c */ -/* ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c 0xdead.beefp+7f -/* ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c 012345670 0314llU -/* ^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^^ constant.numeric.value.c */ -/* ^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c 0b10 0b10iLu -/* ^^^^ meta.number.integer.binary.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^^^^^ meta.number.integer.binary.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c 0271828 0b10410 0xbag50 314a123 -/* ^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.binary.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c 314Ll 314lul 314iJ 314.ll 314.lf -/* ^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^ meta.number.integer.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ invalid.illegal.numeric.suffix.c */ +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c 0x314.1p5af 0b10e20 314e+30llu -/* ^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.binary.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^ invalid.illegal.numeric.suffix.c */ +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^^^^ meta.number.float.decimal.c +// ^^^^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// // Operators ///////////////////////////////////////////// 1 + 2 - 3 * 4 / 5 % 6 -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c 1 | 2 & 3 ^ 4 >> 5 << 6 -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.bitwise.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.bitwise.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.bitwise.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.bitwise.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.bitwise.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c 1 > 2 >= 3 == 4 != 5 <= 6 < 7 -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.comparison.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.comparison.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ keyword.operator.assignment.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.comparison.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.comparison.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c !1 ? -2 : ~3 -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.ternary.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.ternary.c */ -/* ^ keyword.operator.bitwise.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^^ keyword.operator.assignment.augmented.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^^ keyword.operator.assignment.augmented.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) -/* ^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end a,b = b.c; -/* ^ punctuation.separator.c */ -/* ^ keyword.operator.assignment.c */ -/* ^ punctuation.accessor.c */ -/* ^ punctuation.terminator.c */ +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// // Strings ///////////////////////////////////////////// "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' -/* ^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^^ string.quoted.double.c */ -/* ^ storage.type.string.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^^^ string.quoted.double.c */ -/* ^^ storage.type.string.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^^ string.quoted.double.c */ -/* ^ storage.type.string.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^^ string.quoted.double.c */ -/* ^ storage.type.string.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^ string.quoted.single.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^^ string.quoted.single.c */ -/* ^ storage.type.string.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c */ -/* ^ punctuation.definition.string.end.c */ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c '\u\w\x\y\z\/' -/* ^^^^^^^^^^^^^^ string.quoted.single.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c */ -/* ^ punctuation.definition.string.end.c */ +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c "%ms %as %*[, ]" -/* ^^^^^^^^^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^^^ constant.other.placeholder.c */ -/* ^^^ constant.other.placeholder.c */ -/* ^^^^^^ constant.other.placeholder.c */ -/* ^ punctuation.definition.string.end.c */ +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c "314 \ -/* ^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.separator.continuation.c */ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c 159" -/*^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.end.c */ +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c ///////////////////////////////////////////// // Constants ///////////////////////////////////////////// true TRUE false FALSE NULL __func__ -/* ^^^^ constant.language.boolean.true.c */ -/* ^^^^ constant.language.boolean.true.c */ -/* ^^^^^ constant.language.boolean.false.c */ -/* ^^^^^ constant.language.boolean.false.c */ -/* ^^^^ constant.language.null.c */ -/* ^^^^^^^^ constant.language.c */ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus -/* ^^^^^^^^ support.constant.c */ -/* ^^^^^^^^ support.constant.c */ -/* ^^^^^^^^ support.constant.c */ -/* ^^^^^^^^ support.constant.c */ -/* ^^^^^^^^ support.constant.c */ -/* ^^^^^^^^^^^^^^^^ support.constant.c */ -/* ^^^^^^^^ support.constant.c */ -/* ^^^^^^^^^ support.constant.c */ -/* ^^^^^^^^^^^ support.constant.c */ +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c True False Null __CplusPlus -/* ^^^^ invalid.illegal.malformed-constant-language.c */ -/* ^^^^^ invalid.illegal.malformed-constant-language.c */ -/* ^^^^ invalid.illegal.malformed-constant-language.c */ -/* ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c */ +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// // Enclosings ///////////////////////////////////////////// [a, b, c] -/* ^^^^^^^^^ meta.brackets.square.c */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.separator.c */ -/* ^ punctuation.separator.c */ -/* ^ punctuation.section.brackets.end */ +// ^^^^^^^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end {1, 2, 3} -/* ^^^^^^^^^ meta.block.c */ -/* ^ punctuation.section.block.begin */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.block.end */ +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end (6 - 7 == -1 && true) -/* ^^^^^^^^^^^^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.assignment.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^^ keyword.operator.logical.c */ -/* ^^^^ constant.language.boolean.true.c */ -/* ^ punctuation.section.group.end */ +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// // Default Types ///////////////////////////////////////////// auto void char short int long float double signed unsigned _Complex _Imaginary _Bool -/* ^^^^ storage.type.c */ -/* ^^^^ storage.type.c */ -/* ^^^^ storage.type.c */ -/* ^^^^^ storage.type.c */ -/* ^^^ storage.type.c */ -/* ^^^^ storage.type.c */ -/* ^^^^^ storage.type.c */ -/* ^^^^^^ storage.type.c */ -/* ^^^^^^ storage.type.c */ -/* ^^^^^^^^ storage.type.c */ -/* ^^^^^^^^ storage.type.c */ -/* ^^^^^^^^^^ storage.type.c */ -/* ^^^^^ storage.type.c */ +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t -/* ^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^ support.type.stdint.c */ +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t -/* ^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^ support.type.stdint.c */ -/* ^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^ support.type.stdint.c */ +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t -/* ^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^ support.type.stdint.c */ +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t -/* ^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^ support.type.stdint.c */ -/* ^^^^^^^^^^^^^ support.type.stdint.c */ +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) -/* ^^^^^^ keyword.declaration.type.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^ keyword.declaration.type.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^ keyword.declaration.type.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^^^ keyword.declaration.type.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// // Storage Keywords ///////////////////////////////////////////// register static inline extern register thread_local _Thread_local _Noreturn noreturn -/* ^^^^^^^^ storage.modifier.c */ -/* ^^^^^^ storage.modifier.c */ -/* ^^^^^^ storage.modifier.c */ -/* ^^^^^^ storage.modifier.c */ -/* ^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^ storage.modifier.c */ +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c const volatile restrict _Atomic _Alignas(4) -/* ^^^^^ storage.modifier.c */ -/* ^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^ storage.modifier.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// @@ -485,104 +485,107 @@ ///////////////////////////////////////////// test(5, 10, 15, 20); -/* ^^^^^^^^^^^^^^^^^^^ meta.group.c */ -/* ^^^^ variable.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c */ - h(f(5) - g(6)); -/* ^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ -/* ^^^^ meta.group.c */ -/* ^ variable.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.group.c */ -/* ^ variable.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ +// ^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^ meta.group.c +// ^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^^^^ meta.group.c +// ^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ keyword.operator.arithmetic.c +// ^^^^ meta.group.c +// ^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + int main(int argc, char const* argv[]) { -/* ^^^ storage.type.c */ -/* ^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ -/* ^^^ storage.type.c */ -/* ^^^^ variable.parameter.c */ -/* ^ punctuation.separator.c */ -/* ^^^^ storage.type.c */ -/* ^^^^^ storage.modifier.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ variable.parameter.c */ -/* ^^ meta.brackets.square.c */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -/* ^^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ -/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin int out = in("abcdefg"); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^^^^^^^^^^ meta.group.c */ -/* ^^ variable.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^ meta.group.c +// ^^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } -/*^^^ meta.function.c meta.block.c */ -/* ^ punctuation.section.block.end.c */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c int b = main(argc); -/* ^^^ storage.type.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^^^^^^^ meta.group.c */ -/* ^^^^ variable.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c */ +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ meta.group.c +// ^^^^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c static extern int* -/* ^^^^^^ storage.modifier.c */ -/* ^^^^^^ storage.modifier.c */ -/* ^^^ storage.type.c */ -/* ^ keyword.operator.arithmetic.c */ +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.arithmetic.c test( -/* ^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c const uint64_t a, -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ -/* ^^^^^ storage.modifier.c */ -/* ^^^^^^^^ support.type.stdint.c */ -/* ^ variable.parameter.c */ -/* ^ punctuation.separator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c +// ^ punctuation.separator.c typeof(b) b -/*^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ -/* ^^^^^^ keyword.declaration.type.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ variable.parameter.c */ +//^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^ variable.parameter.c ); -/*^^ meta.function.parameters.c meta.group.c */ -/* ^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ +//^^ meta.function.parameters.c meta.group.c +// ^^ meta.function.c +// ^ punctuation.section.group.end.c ///////////////////////////////////////////// // Control Flow @@ -590,532 +593,532 @@ void fun(int const a[]) { while (true) { -/*^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ -/* ^^^^^ keyword.control.c */ -/* ^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^^^^ constant.language.boolean.true.c */ -/* ^ punctuation.section.group.end */ -/* ^ meta.block.c punctuation.section.block.begin */ +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin do { -/*^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c */ -/* ^^ keyword.control.c */ -/* ^ meta.block.c punctuation.section.block.begin */ +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin for (int i = 0; i < 12; ++i) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c */ -/* ^^^ keyword.control.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type.c */ -/* ^ keyword.operator.assignment.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator.c */ -/* ^ keyword.operator.comparison.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator.c */ -/* ^^ keyword.operator.arithmetic.c */ -/* ^ punctuation.section.group.end */ -/* ^ meta.block.c punctuation.section.block.begin */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin switch (i) -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^^^ keyword.control.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end { -/*^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^ meta.block.c punctuation.section.block.begin */ +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin case 0: -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^ keyword.control.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.ternary.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c goto exit; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^ keyword.control.flow.goto.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c case 1: -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^ keyword.control.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.ternary.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c case 2 + 3: -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^ keyword.control.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ keyword.operator.ternary.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c if (a + b < i) {} -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^ keyword.control.c */ -/* ^^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ keyword.operator.comparison.c */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block.c */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end else if (b == -1) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^ keyword.control.c */ -/* ^^ keyword.control.c */ -/* ^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^^ keyword.operator.assignment.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ -/* ^ meta.block.c punctuation.section.block.begin */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin continue; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^^^^^ keyword.control.flow.continue.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c } -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^ punctuation.section.block.end */ +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end break; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^^ keyword.control.flow.break.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c default: -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^^^^ keyword.control.c */ -/* ^ keyword.operator.ternary.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.c +// ^ keyword.operator.ternary.c continue; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^^^^^^^^ keyword.control.flow.continue.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c } -/*^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^ punctuation.section.block.end */ +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end } -/*^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c */ -/* ^ punctuation.section.block.end */ +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end } while (a > b); -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c */ -/*^^^^^^^^^^^ meta.block.c */ -/* ^ punctuation.section.block.end */ -/* ^^^^^ keyword.control.c */ -/* ^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ keyword.operator.comparison.c */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } -/*^^^^^^^ meta.function.c meta.block.c meta.block.c */ -/* ^ punctuation.section.block.end */ +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end exit: -/*^^^^^^^ meta.function.c meta.block.c */ -/* ^^^^ entity.name.label.c */ -/* ^ punctuation.separator.c */ +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c +// ^ punctuation.separator.c return; -/*^^^^^^^^^^^^^ meta.function.c meta.block.c */ -/* ^^^^^^ keyword.control.flow.return.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c } -/*^^^ meta.function.c meta.block.c */ -/* ^ punctuation.section.block.end.c */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// // Data Structures ///////////////////////////////////////////// struct A; enum B; union C; -/* ^^^^^^^^ meta.struct.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^ entity.name.enum.forward-decl.c */ -/* ^ punctuation.terminator.c */ -/* ^^^^^^ meta.enum.c */ -/* ^^^^ keyword.declaration.enum.c */ -/* ^ entity.name.enum.forward-decl.c */ -/* ^ punctuation.terminator.c */ -/* ^^^^^^^ meta.union.c */ -/* ^^^^^ keyword.declaration.union.c */ -/* ^ entity.name.enum.forward-decl.c */ -/* ^ punctuation.terminator.c */ +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c enum B -/* ^^^^^^ meta.enum.c */ -/* ^^^^ keyword.declaration.enum.c */ -/* ^ entity.name.enum.c */ +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.c { -/* ^ meta.enum.c punctuation.section.block.begin.c */ +// ^ meta.enum.c punctuation.section.block.begin.c kTest1, -/*^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^^^ entity.name.constant.c */ -/* ^ punctuation.separator.c */ +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c kTest2 = kTest1 + 1, -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^^^ entity.name.constant.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^^^ constant.other.variable.mac-classic.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c kTest3, -/*^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^^^ entity.name.constant.c */ -/* ^ punctuation.separator.c */ +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c }myEnum; -/*^^ meta.block.c */ -/* ^ punctuation.section.block.end.c */ -/* ^ punctuation.terminator.c */ +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c const volatile struct A -/* ^^^^^ storage.modifier.c */ -/* ^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^ meta.struct.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^ entity.name.struct.c */ +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c { -/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c int a1; -/*^^^^^^^^^^^^^ meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c char a3[12]; -/*^^^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^ storage.type.c */ -/* ^^^^ meta.brackets.square.c */ -/* ^ punctuation.section.brackets.begin */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.brackets.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c void* h5; -/*^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^ storage.type.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c enum B out; }; -/*^^^^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^ keyword.declaration.enum.c */ -/* ^ punctuation.terminator.c */ -/* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ keyword.declaration.enum.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c union MACRO myUnion { -/* ^^^^^^^^^^^^^^^^^^^^ meta.union.c */ -/* ^^^^^ keyword.declaration.union.c */ -/* ^^^^^^^ entity.name.union.c */ -/* ^ meta.block.c meta.union.c punctuation.section.block.begin.c */ +// ^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c meta.union.c punctuation.section.block.begin.c struct A { -/*^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^^^^^^ meta.struct.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^ entity.name.struct.c */ -/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c int f; -/*^^^^^^^^^^^^^^^^ meta.block.c meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c } s1; -/*^^^^^^^^^^^ meta.block.c */ -/*^^^^^^^ meta.block.c */ -/* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c struct B { -/*^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^^^^^^ meta.struct.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^ entity.name.struct.c */ -/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c int f2; -/*^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c } s2; -/*^^^^^^^^^^^ meta.block.c */ -/*^^^^^^^ meta.block.c */ -/* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c void* ptr; -/*^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^^ storage.type.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c int a, *ptr2; -/*^^^^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.separator.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c }; -/*^^^ meta.block.c */ -/* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c */ +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c int test() { -/* ^^^ storage.type.c */ -/* ^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ -/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin union C myunion; -/*^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ -/* ^^^^^ keyword.declaration.union.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c myunion.s2.f = 20; -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c */ -/* ^ punctuation.accessor.c */ -/* ^ punctuation.accessor.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.c +// ^ punctuation.accessor.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } -/*^^^ meta.function.c meta.block.c */ -/* ^ punctuation.section.block.end.c */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c typedef struct { -/* ^^^^^^^ keyword.declaration.type.c */ -/* ^^^^^^^ meta.struct.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c myCustomType* a; -/*^^^^^^^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c } b; -/*^^^ meta.block.c */ -/* ^ punctuation.section.block.end */ -/* ^ entity.name.type.typedef.c */ -/* ^ punctuation.terminator.c */ +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c typedef void(*func)(int param, int, char param2); -/* ^^^^^^^ keyword.declaration.type.c */ -/* ^^^^ storage.type.c */ -/* ^ keyword.operator.c */ -/* ^^^^ entity.name.type.typedef.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ -/* ^^^ storage.type.c */ -/* ^^^^^ variable.parameter.c */ -/* ^ punctuation.separator.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.separator.c */ -/* ^^^^ storage.type.c */ -/* ^^^^^^ variable.parameter.c */ -/* ^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// // Attributes and Declspec ///////////////////////////////////////////// __declspec(align(5)) struct Test { -/* ^^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^ meta.group.c */ -/* ^^^^^ storage.modifier.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end.c */ -/* ^^^^^^^^^^^^ meta.struct.c */ -/* ^^^^^^ keyword.declaration.struct.c */ -/* ^^^^ entity.name.struct.c */ -/* ^ meta.block.c meta.struct.c punctuation.section.block.begin.c */ +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ meta.group.c +// ^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^^^^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c int a; -/*^^^^^^^^^^^^ meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c int b; -/*^^^^^^^^^^^^ meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c int c; -/*^^^^^^^^^^^^ meta.block.c */ -/* ^^^ storage.type.c */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c }; -/*^^^ meta.block.c */ -/* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c */ +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c void __declspec(dllimport) importedFn() const; -/* ^^^^ storage.type.c */ -/* ^^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^ constant.other.c */ -/* ^ punctuation.section.group.end.c */ -/* ^^^^^^^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ -/* ^^^^^ constant.other.c */ +// ^^^^ storage.type.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^^^^^ constant.other.c __declspec(property(get=10, put=10)) void runForever(); -/* ^^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^ storage.modifier.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^ variable.parameter.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.separator.c */ -/* ^^^ variable.parameter.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end.c */ -/* ^^^^ storage.type.c */ -/* ^^^^^^^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^ meta.function.c +// ^ punctuation.section.group.end.c void on_load() __attribute__((constructor, visibility("hidden"))) {} -/* ^^^^ storage.type.c */ -/* ^^^^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c */ -/* ^^^^^^^^^^^^^ storage.modifier.c */ -/* ^^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^^^ constant.other.c */ -/* ^ punctuation.separator.c */ -/* ^^^^^^^^^^^^^^^^^^^^ meta.group.c */ -/* ^^^^^^^^^^ storage.modifier.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^ punctuation.section.group.end */ -/* ^^ punctuation.section.group.end.c */ -/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ -/* ^ meta.block.c punctuation.section.block.end.c */ +// ^^^^ storage.type.c +// ^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c int a = -/* ^^^ storage.type.c */ -/* ^ keyword.operator.assignment.c */ +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c int main(int argc, char const* argv[]) { -/* ^^^ storage.type.c */ -/* ^^^^ entity.name.function.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c */ -/* ^^^ storage.type.c */ -/* ^^^^ variable.parameter.c */ -/* ^ punctuation.separator.c */ -/* ^^^^ storage.type.c */ -/* ^^^^^ storage.modifier.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ variable.parameter.c */ -/* ^^ meta.brackets.square.c */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -/* ^^^ meta.function.c */ -/* ^ punctuation.section.group.end.c */ -/* ^ meta.function.c meta.block.c punctuation.section.block.begin */ +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin } -/*^^^ meta.function.c meta.block.c */ -/* ^ punctuation.section.block.end.c */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// // Preprocessor ///////////////////////////////////////////// #include -/*^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^^^ keyword.control.import.c */ -/* ^^^^^^^^^^ string.quoted.other.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c #include_next "file.h" -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^^^^^^^^ keyword.control.import.c */ -/* ^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c #error Error Message -/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c */ -/*^^^^^^^^ keyword.control.import.error.c */ -/* ^^^^^^^^^^^^^^ string.unquoted.c */ +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c #error Error Message \ (this is an "error") -/*^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c */ +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c #warning Warning Message -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c */ -/*^^^^^^^^^^ keyword.control.import.warning.c */ -/* ^^^^^^^^^^^^^^^^ string.unquoted.c */ +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c #warning Warning Message \ (this is a "warning") #define FOO __declspec(dllimport) -/*^^^^^^^^^ keyword.control.import.c */ -/* ^^^ entity.name.macro.c support.macro.c */ -/* ^^^^^^^^^^ storage.modifier.c */ -/* ^^^^^^^^^^^ meta.group.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^^^^^^^^^ constant.other.c */ -/* ^ punctuation.section.group.end.c */ +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; -/*^^^^^^^^^ keyword.control.import.c */ -/* ^^^ entity.name.macro.c support.macro.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ variable.parameter.c */ -/* ^ punctuation.separator.c */ -/* ^ variable.parameter.c */ -/* ^ punctuation.separator.c */ -/* ^^^ keyword.operator.variadic.c */ -/* ^ punctuation.section.group.end.c */ -/* ^^^^ keyword.declaration.enum.c */ -/* ^^ keyword.operator.c */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^^^^^^^ constant.other.variable.mac-classic.c */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^^^^^^^ keyword.operator.word.c */ -/* ^^^ meta.group.c */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.separator.c */ -/* ^ punctuation.section.group.end */ -/* ^^^^^^^^^^^ constant.other.c */ -/* ^ punctuation.section.block.end */ -/* ^ punctuation.terminator.c */ +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.separator.c +// ^ punctuation.section.group.end +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c #if FOO -/*^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^ keyword.control.import.c */ +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c #ifndef FOO -/*^^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c #ifdef FOO -/*^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c #elif FOO -/*^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c #elifdef FOO -/*^^^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c #elifndef FOO -/*^^^^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c #else -/*^^^^^^^ keyword.control.import.c */ +//^^^^^^^ keyword.control.import.c #endif -/*^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^ keyword.control.import.c #undef FOO -/*^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c #pragma FOO -/*^^^^^^^^^^^^^ meta.preprocessor.c */ -/*^^^^^^^^^ keyword.control.import.c */ +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c #embed "file.txt" if_empty(0) -/*^^^^^^^^ keyword.control.import.c */ -/* ^^^^^^^^^^ string.quoted.double.c */ -/* ^ punctuation.definition.string.begin.c */ -/* ^ punctuation.definition.string.end.c */ -/* ^^^^^^^^ keyword.other.c */ -/* ^ punctuation.section.group.begin.c */ -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.section.group.end.c */ +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ keyword.other.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index b105d5fd49..382d17de1d 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -1,1233 +1,1644 @@ -/* SYNTAX TEST "Packages/Objective-C/Objective-C.sublime-syntax" */ - -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ +// SYNTAX TEST "Packages/Objective-C/Objective-C.sublime-syntax" - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number constant.numeric.value */ - /* ^^ keyword.operator.arithmetic */ -} - -enum Foo { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.enum */ -/* ^ entity.name.constant.objc */ -/* ^ entity.name.constant.objc */ -#define FOO Foo -enum FOO do_the_foo(void); -/* ^ entity.name.function */ -/* ^ storage.type */ - -#define APIC_CAPABILITY TheEnum -enum TheEnum { kFoo, kBar }; -static enum APIC_CAPABILITY apic_capabilities(void) { return kFoo; }; -/* ^ entity.name.function */ -/* ^ storage.type */ - -enum { kFoo, kBar }; -/* <- keyword.declaration */ -/* ^ entity.name.constant.objc */ -/* ^ entity.name.constant.objc */ - -enum { kFoo = FOO, kBar = BAR }; -/* <- keyword.declaration */ -/* ^^^^ entity.name.constant.objc */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ -/* ^ punctuation.separator.objc */ -/* ^^^^ entity.name.constant.objc */ -/* ^ keyword.operator.assignment.c */ -/* ^^^ - entity.name.constant */ - -typedef enum state { DEAD, ALIVE } State; -/* <- keyword.declaration -/* ^ entity.name.enum */ -/* ^ entity.name.constant.objc */ -/* ^ entity.name.constant.objc */ - -enum { - FOO, -/* ^^^ entity.name.constant.objc */ -/* ^ punctuation.separator.objc */ - BAR -/* ^^^ entity.name.constant.objc */ -}; - -struct __declspec(dllimport) X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct __declspec(dllimport) baz X {}; -/* ^ storage.modifier */ -/* ^ entity.name.struct */ - -struct foo { -/* ^ entity.name.struct */ - union { -/* ^ keyword.declaration */ - struct { -/* ^ keyword.declaration */ - int a; -/* ^ storage.type */ - int b; -/* ^ storage.type */ - } - } -} - -#define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS /* comment block */ * sizeof(struct ptp_extts_event)) // comment line -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group meta.group */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant.preprocessor */ -/* ^ comment.block */ -/* ^ keyword.operator.word */ -/* ^ keyword.declaration */ -/* ^ comment.line */ - -#pragma foo(bar, \ -"baz") -/*^^^^ meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#define PACKED __attribute__((aligned(1),packed)) -/* ^ entity.name.constant */ -/* ^ storage.modifier */ - -int i; -/* <- storage.type */ - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin */ -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function meta.block */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number constant.numeric.value */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -#define CONST0 16 // Comment -#define CONST1 8 -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#if defined(VARIABLE) | // comment_line \ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor */ \ - defined(VAR2) -/*^^^^^^^^^^^^^^^ meta.preprocessor */ -/* ^ keyword.control */ -# error This is a long error message that need to \ -/* <- keyword.control.import */ \ -/* ^ string.unquoted */ \ - be splitted into two lines to prevent large lines. // comment -#error "Explicitly quoted string wrapped, \ - ensuring that the string quoting stops at some point \ - " -#warning This is a short warning -/* <- keyword.control.import */ -#endif - /* <- keyword.control.import */ - -#define MACRO_WITH_CURLY_BRACE { -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -bool still_C_code_here = true; -/* <- storage.type */ -/* ^ constant.language */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c -#if 0 -#ifdef moo -/* <- - keyword.control */ -#endif -/* <- - keyword.control */ -#endif - -#if 0 -/* ^ meta.number constant.numeric.value */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 -/* ^ meta.number constant.numeric.value */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number constant.numeric.value */ - int b = 2; -/* ^ comment.block */ - #else - int c = 3; - #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - - -FOO -/* <- meta.assumed-macro */ -FOO; -/* <- - meta.assumed-macro */ -foo -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO(); -/* <- - meta.assumed-macro */ -foo() -/* <- - meta.assumed-macro */ -; // fix highlighting -/* <- punctuation.terminator */ - -struct X -{ - ENABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - int foo; - /* <- storage.type */ + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c - DISABLED("reason") - /* <- meta.assumed-macro variable.function.assumed-macro */ - float bar; - /* <- storage.type */ -}; + */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Preprocessor branches starting blocks +// Numbers ///////////////////////////////////////////// -#ifdef FOO -if (1) { -#elif BAR -if (2) { -# elif BAZ -if (3) { -# else -if (4) { -#endif - int bar = 1; -} -/* <- meta.block punctuation.section.block.end */ - /* <- - meta.block */ + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.14L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-15 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^ invalid.illegal.numeric.suffix.c + 0x314.1p5af 0b10e20 314e+30llu +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^^^^ meta.number.float.decimal.c +// ^^^^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Typedefs +// Operators ///////////////////////////////////////////// -typedef int myint; -/* <- keyword.declaration */ -/* ^ entity.name.type */ - -typedef struct mystruct { -/* <- keyword.declaration */ -/* ^ keyword.declaration.struct.objc */ -/* ^ entity.name.struct.objc */ -} mystruct; -/* ^ entity.name.type */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.objc */ -/* ^^^^^^ keyword.declaration.struct.objc */ -/* ^^^^^^^^^^^ entity.name.struct.objc */ -/* ^ punctuation.section.block.begin.objc */ -/* ^ punctuation.section.block.end.objc */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.objc */ + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 ? -2 : ~3 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Data structures and return values +// Strings ///////////////////////////////////////////// -struct point -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ -{ - int x; - int y; -} - -struct point2 { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - int x; - int y; -} - -int main(void) { -/* ^^^^ entity.name.function */ -/* ^^^^ storage.type */ -} - -struct point get_point() {} -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin -/* ^ punctuation.section.block.end -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^ entity.name.function */ - -struct point **alloc_points(); -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -struct point* alloc_point(); -/* ^ entity.name.function - variable.function */ - -struct point FOO_API *alloc_point3(); -/* ^ entity.name.function - variable.function */ - - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Constants ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[]) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -{ -/* <- meta.function meta.block */ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result == 0) { - return 0; -/* ^^^^^^ keyword.control.flow.return */ -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifdef BAR - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#elifndef BAZ - /* <- keyword.control.import */ - if (val == -3) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -4) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Matching various function definitions +// Enclosings ///////////////////////////////////////////// -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.function entity.name.function */ -(int * a) -/*^^^^^^^ meta.function.parameters meta.group */ -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} - -MACRO1 void * MACRO2 myfuncname () { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ meta.block punctuation.section.block.begin -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; -/* ^^^^^ keyword.control.flow.break */ - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ - } - - struct Args { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - }; - - struct Args args; -/* ^ keyword.declaration */ -/* ^ - entity */ - -} + [a, b, c] +// ^^^^^^^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end -static const uint32_t * const MACRO funcname(); -/* ^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() -{ - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -} +///////////////////////////////////////////// +// Default Types +///////////////////////////////////////////// -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Test function call in function parameters +// Storage Keywords ///////////////////////////////////////////// -static string foo(bar() + ';'); -/* ^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^ entity.name.function */ -/* ^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ string */ -/* ^ -string */ - -func_call(foo -/*^^^^^^^^^^^ meta.function-call */ -/* ^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -); -/* <- meta.function-call meta.group punctuation.section.group.end */ + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end + ///////////////////////////////////////////// -// Invalid +// Functions ///////////////////////////////////////////// -) -/* <- invalid.illegal.stray-bracket-end */ -} -/* <- invalid.illegal.stray-bracket-end */ + test(5, 10, 15, 20); +// ^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^ meta.group.c +// ^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^^^^ meta.group.c +// ^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ keyword.operator.arithmetic.c +// ^^^^ meta.group.c +// ^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^ meta.group.c +// ^^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ meta.group.c +// ^^^^ variable.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.arithmetic.c + test( +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^ variable.parameter.c + ); +//^^ meta.function.parameters.c meta.group.c +// ^^ meta.function.c +// ^ punctuation.section.group.end.c ///////////////////////////////////////////// -// Objective-C Interface +// Control Flow ///////////////////////////////////////////// -@interface Person : NSObject -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ -@property (readonly) NSString *firstName; -/* <- keyword.other punctuation.definition.keyword */ -/*^ keyword.other */ -@property (readonly, nullable, class) NSString *lastName; -/* <- keyword.other punctuation.definition.keyword */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute. */ -/* ^ punctuation.section.scope.end */ -- (NSString*)formatWithPattern:(NSString*)pattern __attribute__((swift_name("format(pattern:)"))); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.objc*/ -/* ^^^^^^^^^^^^^ storage.modifier.objc*/ -/* ^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/ -@end -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ - -NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@", -/*^ support.class */ -/* ^ keyword.operator */ -/* ^ meta.bracketed punctuation.section.scope.begin */ -/* ^ support.function.any-method */ -/* ^^ string.quoted.double punctuation.definition.string.begin */ - attributeName, attributeValue]; -/* ^ meta.bracketed punctuation.section.scope.end */ - -@implementation Person -- (void)debugOutput:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2) -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ variable.function */ -{} -@end - + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ punctuation.section.block.end + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.c +// ^ keyword.operator.ternary.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a > b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c +// ^ punctuation.separator.c + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Includes +// Data Structures ///////////////////////////////////////////// -#import -/* <- meta.preprocessor.import keyword.control.import.import */ - -#include -/* <- meta.preprocessor.include keyword.control.import.include */ - -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -static const unsigned char image_png[] = { -#embed -/* <- keyword.control.import.include */ -}; - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ + struct A; enum B; union C; +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c + { +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int a1; +//^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ keyword.declaration.enum.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c meta.union.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + void* ptr; +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.c +// ^ punctuation.accessor.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Numeric Constants +// Attributes and Declspec ///////////////////////////////////////////// -dec0 = 0; -/* ^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1234567890f; -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec3 = 1234567890L; -/* ^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec4 = 1234567890ul; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec5 = 1234567890Lu; -/* ^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec6 = 1234567890LLU; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec7 = 1234567890uLL; -/* ^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -dec8 = 1'234_567'890s0f; -/* ^^^^^^^^^^^^^^^^ meta.number.integer.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^^^ constant.numeric.value.c */ -/* ^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct1 = 01234567; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.terminator - constant */ - -oct2 = 01234567L; -/* ^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct3 = 01234567LL; -/* ^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct4 = 01234567ulL; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^^^^^^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -oct2 = 01284967Z0L; -/* ^^^^^^^^^^^ meta.number.integer.octal.c */ -/* ^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^^^^^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x0+0xFL+0xaull+0xallu+0xfu+0x'f'12_4uz; -/* ^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^^^ constant.numeric.suffix.c */ -/* ^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^^^^^ meta.number.integer.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^^^^ invalid.illegal.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic - constant.c */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c */ -/* ^^ constant.numeric.base.c */ -/* ^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c */ -/* ^ constant.numeric.value.c */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c */ -/* ^ punctuation.separator.decimal.c */ -/* ^^^^^ constant.numeric.value.c */ -/* ^ constant.numeric.suffix.c */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ invalid.illegal.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ meta.group.c +// ^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^^^^ entity.name.struct.c +// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c + int a; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^^^^^ constant.other.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^ meta.function.c +// ^ punctuation.section.group.end.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.c +// ^^^^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c +// ^^ meta.brackets.square.c +// ^ punctuation.section.brackets.begin +// ^ punctuation.section.brackets.end +// ^^^ meta.function.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Objective-C specific format specifiers +// Preprocessor ///////////////////////////////////////////// -print ("%@", @"String") -/* ^ - invalid */ - -NSLog (@"%@", @"String") -/* ^ constant.other.placeholder.objc */ + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.separator.c +// ^ punctuation.section.group.end +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c + #else +//^^^^^^^ keyword.control.import.c + #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + + #embed "file.txt" if_empty(0) +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^^^^^^^^ keyword.other.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c + + +#import +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +@import Foundation; +//^^^^^ keyword.control.objc +// ^ punctuation.terminator.c + +typedef SEL(^sample)(IMP _Nullable a, id _Nonnull b, Class nonnull c, BOOL nullable d); +//^^^^^ keyword.declaration.type.c +// ^^^ storage.type.objc +// ^ keyword.operator.objc +// ^^^^^^ entity.name.type.typedef.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^ storage.type.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^^ storage.type.objc +// ^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c +// ^ punctuation.section.group.end.c + +@class NSWindow; +//^^^^ keyword.declaration.class.objc +// ^^^^^^^^ entity.name.type.class.objc +// ^ punctuation.terminator.c + +@protocol MyProtocol +//^^^^^^^ meta.interface-or-protocol.objc keyword.declaration.class.objc +// ^^^^^^^^^^ meta.interface-or-protocol.objc entity.name.type.objc +@optional +//^^^^^^^ meta.interface-or-protocol.objc storage.modifier.objc ++(instancetype) selector; +//^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.function.objc +//^^^^^^^^^^^^^ meta.group.c +//^^^^^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.terminator.objc +@required +//^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc storage.modifier.objc +-(NSRect) someSelector:(__nonnull id)param withOther:(__unused)param2; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.function.objc +//^^^^^^^ meta.group.c +//^^^^^^ support.type.cocoa.objc +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end +// ^^^^^^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.interface-or-protocol.objc meta.scope.interface.objc keyword.declaration.interface.end.objc + +@interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NSObject +//^^^^^^^^ meta.interface-or-protocol.objc keyword.declaration.class.objc +// ^^^^^^^ meta.interface-or-protocol.objc entity.name.type.objc +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end +// ^^ punctuation.section.group.end.c +// ^ punctuation.separator.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^ meta.protocol-list.objc +// ^ punctuation.section.scope.begin.objc +// ^ punctuation.section.scope.end.objc +{ + @public int a; +//^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ punctuation.terminator.c + @protected NSDictionary* b; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +// ^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c + @private char* d; +//^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c + @package sample e; +//^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c +} -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ +@property(readwrite, nonatomic) IBOutlet NSButton* btn; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc +//^^^^^^^ keyword.other.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c +@property(readonly, getter=myGetE) IBInspectable sample e; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc +//^^^^^^^ keyword.other.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.objc +// ^ keyword.operator.assignment.objc +// ^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c + +-(void)someSelector:(void*)a; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.function.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +//^^^^ storage.type.c +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.group.begin.objc +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.interface-or-protocol.objc meta.scope.interface.objc keyword.declaration.interface.end.objc + +@implementation MyClass +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc +//^^^^^^^^^^^^^ meta.implementation.objc keyword.declaration.class.objc +// ^^^^^^^ meta.implementation.objc entity.name.type.objc +@synthesize e; +//^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc +//^^^^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c +@dynamic btn; +//^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc +//^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c + +-(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attribute__((objc_direct)) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.function.objc +//^^^^^^^^^ meta.group.c +//^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end +// ^^^^^^ variable.parameter.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.objc +// ^^ punctuation.section.group.end.c -"foo % baz" -/* ^ - invalid */ +{ + [super someSelector:param withOther:param2]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^ variable.language.objc +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __block int i = 1; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + __strong NSString* j = [NSString stringWithFormat:@"Hello, World! %@", @314, nil]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.objc +// ^^ punctuation.definition.string.begin.c +// ^^ constant.other.placeholder.objc +// ^ punctuation.definition.string.end.c +// ^ punctuation.separator.c +// ^ constant.numeric.objc +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ constant.language.null.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __weak NSNumber* k = @'3'; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^^^^ string.quoted.single.c +// ^^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.terminator.c + __autoreleasing NSView* a = [[NSView alloc] init]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^ support.class.cocoa.objc +// ^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + + NSArray* f = @[ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^ meta.protocol-list.objc +// ^ punctuation.section.scope.begin.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.scope.end.objc +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.brackets.square.c punctuation.section.brackets.begin + @314.5, +//^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ punctuation.separator.c + @0x314LL, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^ punctuation.separator.c + @0314e10, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + @0b1010u +//^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + ]; +//^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c + + NSDictionary* g = @{ +//^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^^ meta.mapping.objc punctuation.section.mapping.begin + (__bridge id)kValue1 : (__bridge NSViewController)kValue2, +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^^^^^ support.class.cocoa.leopard.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ punctuation.separator.c + (__bridge NSWindow)kValue3 : @YES +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^ constant.language.boolean.objc + }; +//^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^ meta.mapping.objc +// ^ punctuation.section.mapping.end +// ^ punctuation.terminator.c + + [g respondsToSelector:@selector(doSomething:withSomething:)]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.objc +// ^^^^^^^^^ keyword.operator.word.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.method-name.objc support.function.objc +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.brackets.end.objc + if (@available(iOS 10.4, macOS 11.3, *)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^^^ keyword.operator.word.objc +// ^ punctuation.section.group.begin.objc +// ^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^^^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + [[[g allValues] objectAtIndex: 1] +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.objc + perform: @encode(int) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ keyword.operator.word.objc +// ^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ punctuation.section.group.end + with: @NO +//^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^ constant.language.boolean.objc + ]; +//^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } +//^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +// ^ punctuation.section.block.end + + return [NSClassFromString([NSString stringWithUTF8String:self.j.UTF8String]) someSelector:^(__contravariant NSObject* a, __covariant int const* b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^ support.function.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^ variable.language.objc +// ^ keyword.operator.accessor.objc +// ^ variable.other.readwrite.member.objc +// ^ keyword.operator.accessor.objc +// ^^^^^^^^^^ variable.other.readwrite.member.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ keyword.operator.bitwise.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^^^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.objc + @try { +//^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +// ^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + [Nil message: (a + b) ? @true : @false]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^ constant.language.null.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ keyword.operator.ternary.c +// ^^^^^ constant.language.boolean.objc +// ^ keyword.operator.ternary.c +// ^^^^^^ constant.language.boolean.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } @catch(NSException* exc) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^^ keyword.control.exception.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^^^ variable.parameter.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin + return NO; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^ constant.language.boolean.objc +// ^ punctuation.terminator.c + } @finally { +//^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + return YES; +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^ constant.language.boolean.objc +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + }]; +//^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c +} +@end +//^^ meta.implementation.objc meta.scope.implementation.objc keyword.declaration.interface.end.objc +//^^ meta.implementation.objc meta.scope.implementation.objc keyword.declaration.interface.end.objc From a1e1478e309832642718f0f11b101de35f67f7ea Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:32:22 -0600 Subject: [PATCH 25/66] Add many to ObjC --- Objective-C/Objective-C.sublime-syntax | 211 ++++++++++++++----------- 1 file changed, 115 insertions(+), 96 deletions(-) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index a3fee296b3..582f3664dd 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -55,20 +55,17 @@ contexts: interface.struct: - match: \{ scope: punctuation.section.block.begin.objc - push: enclosure.block + set: enclosure.block - include: else-pop interface.body: - - match: ^\s*(@end) - captures: - 1: keyword.declaration.interface.end.objc + - match: \@end + scope: keyword.declaration.interface.end.objc pop: 1 - - match: ^\s*(@property) - captures: - 1: keyword.other.objc + - match: \@property + scope: keyword.other.objc push: [statement, property] - - match: ^\s*(@(?:synthesize|dynamic)) - captures: - 1: keyword.other.objc + - match: \@(?:synthesize|dynamic) + scope: keyword.other.objc push: statement - match: (?:\+|\-)\s*(?=\() @@ -130,24 +127,52 @@ contexts: pop: 1 protocol-list: - - match: \<(?=({{identifier}}|,|\s)*\>) + - match: \<(?=({{identifier}}|,|\s|\*)*\>) scope: punctuation.section.scope.begin.objc push: - include: expression-identifiers + - include: punctuation.comma + - include: operator.pointer - meta_scope: meta.protocol-list.objc - match: \> scope: punctuation.section.scope.end.objc pop: 1 - gnu-attribute: - - meta_append: true - - match: \b(objc_direct)\b - scope: constant.other.objc - - match: \b(swift_name)\s*(\() + expression: + - meta_prepend: true + - match: (\^)\s*(?=\() captures: - 1: storage.modifier.c - 2: punctuation.section.group.begin.c - push: enclosure.parenthesis + 1: keyword.operator.bitwise.objc + branch_point: block-fn + branch: [block-fn, pop-immediately] + - match: '(@catch)\s*(\()' + captures: + 1: keyword.control.exception.objc + 2: punctuation.section.group.begin.objc + push: function.params + - match: (?=\b(self)\s*(\.)) + push: self-access + - include: protocol-list + + block-fn: + - match: \( + scope: punctuation.section.group.begin.objc + push: function.params + - match: \{ + scope: punctuation.section.block.begin.objc + set: enclosure.block + - match: (?=\S) + fail: block-fn + + self-access: + - match: \b(self)\b + captures: + 1: variable.language.objc + - match: \s*(\.)\s*({{identifier}}) + captures: + 1: keyword.operator.accessor.objc + 2: variable.other.readwrite.member.objc + - include: pop-immediately preprocessor: - meta_prepend: true @@ -160,20 +185,25 @@ contexts: - match: \@\" scope: punctuation.definition.string.begin.c push: string.double-ns + - match: \@\' + scope: punctuation.definition.string.begin.c + push: string.single string.double-ns: - meta_scope: string.quoted.double.objc - include: string.double - match: '%@' scope: constant.other.placeholder.objc - keyword.type: - - meta_append: true - - match: \b(?:BOOL|Class|SEL|IMP|id|instancetype|IBAction)\b - scope: storage.type.objc - - match: \@(?:interface|class|implementation|protocol|end)\b - scope: keyword.declaration.objc - - match: '(?=\bNS\w+\b)' - push: ns-identifiers + available: + - match: \b(iOS|macOS|watchOS|tvOS|visionOS)\b + scope: support.constant.platform.objc + - match: \b(\d[\d\.]+)\b + captures: + 1: constant.numeric.version.objc + - include: expression + - match: \) + scope: punctuation.section.group.end.objc + pop: 1 selector-obj: - meta_scope: meta.selector.objc @@ -183,33 +213,55 @@ contexts: pop: 1 - match: . scope: support.function.objc - operator.word: - - meta_append: true - - match: '@(encode|available)' - scope: keyword.operator.word.objc - - match: '(@selector)\b(\()?' + + keyword: + - meta_prepend: true + - match: \b(self|super)\b + scope: variable.language.objc + - match: \@(property|synthesize|dynamic)\b + scope: keyword.other.objc + - match: '(@available)\b(\()' + captures: + 1: keyword.operator.word.objc + 2: punctuation.section.group.begin.objc + push: available + - match: '(@selector)\b(\()' captures: 1: keyword.operator.word.objc 2: punctuation.section.group.begin.objc push: selector-obj - + - match: '@(selector|encode|available)' + scope: keyword.operator.word.objc keyword.control: - meta_prepend: true - match: \@(autoreleasepool|import|synchronized)\b scope: keyword.control.objc - match: \@(try|catch|finally|throw)\b scope: keyword.control.exception.objc - keyword.storage: - meta_prepend: true - - match: \b(nonnull|nullable|_Nullable|_Nonnull|IBOutlet|IBInspectable|__(unused|nonnull|block|weak|strong|autoreleasing|bridge))\b + - match: \b(nonnull|nullable|_Nullable|_Nonnull|IBOutlet|IBInspectable|__(unused|nonnull|block|weak|strong|autoreleasing|bridge|covariant|contravariant))\b scope: storage.modifier.objc - match: \@(private|public|protected|package|optional|required)\b scope: storage.modifier.objc - keyword: - - meta_prepend: true - - match: \b(self|super)\b - scope: variable.language.objc + keyword.type: + - meta_append: true + - match: \b(?:BOOL|Class|SEL|IMP|id|instancetype|IBAction)\b + scope: storage.type.objc + - match: \@(?:interface|class|implementation|protocol|end)\b + scope: keyword.declaration.objc + - match: '(?=\bNS\w+\b)' + push: ns-identifiers + + gnu-attribute: + - meta_append: true + - match: \b(objc_(direct|designated_initializer|root_class|requires_super|subclassing_restricted|precise_lifetime|))\b + scope: constant.other.objc + - match: \b(swift_name|objc_runtime_name)\s*(\() + captures: + 1: storage.modifier.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis constant: - meta_append: true @@ -233,52 +285,22 @@ contexts: 1: keyword.declaration.class.objc 2: entity.name.type.class.objc - expression: + enclosure: - meta_prepend: true - - match: (\^)\s*(?=\() - captures: - 1: keyword.operator.bitwise.objc - branch_point: block-fn - branch: [block-fn, pop-immediately] - - match: '(@catch)\s*(\()' - captures: - 1: keyword.control.exception.objc - 2: punctuation.section.group.begin.objc - push: function.params - - match: (?=\b(self)\s*(\.)) - push: self-access - - include: protocol-list - - block-fn: - - match: \( - scope: punctuation.section.group.begin.objc - push: function.params - - match: \{ - scope: punctuation.section.block.begin.objc - set: enclosure.block - - match: (?=\S) - fail: block-fn - self-access: - - match: \b(self)\b - captures: - 1: variable.language.objc - - match: \s*(\.)\s*({{identifier}}) - captures: - 1: keyword.operator.accessor.objc - 2: variable.other.readwrite.member.objc - - include: pop-immediately - - message.func: - - match: '\b({{identifier}})\s*(:)' - captures: - 1: entity.name.function.method.objc - 2: punctuation.separator.arguments.objc - + - match: \[(?!\s*{{identifier}}\s*[:\]]) + scope: punctuation.section.brackets.begin + branch_point: message + branch: [message, enclosure.brackets] + - match: '@\{' + scope: punctuation.section.mapping.begin + push: enclosure.mapping + enclosure.mapping: + - meta_scope: meta.mapping.objc + - match: \} + scope: punctuation.section.mapping.end + pop: 1 - include: expression - - match: \] - scope: punctuation.section.brackets.end.objc - pop: 1 message: - meta_scope: meta.bracketed.objc @@ -304,22 +326,19 @@ contexts: - match: '\b({{identifier}})\b' - match: (?=\S) fail: message - enclosure: - - meta_prepend: true - - match: \[(?!\s*{{identifier}}:) - scope: punctuation.section.brackets.begin - branch_point: message - branch: [message, enclosure.brackets] - - match: '@\{' - scope: punctuation.section.mapping.begin - push: enclosure.mapping - enclosure.mapping: - - meta_scope: meta.mapping.objc - - match: \} - scope: punctuation.section.mapping.end - pop: 1 + message.func: + - meta_scope: meta.bracketed.objc + - match: '\b({{identifier}})\s*(:)' + captures: + 1: entity.name.function.method.objc + 2: punctuation.separator.arguments.objc + - include: expression + - match: \] + scope: punctuation.section.brackets.end.objc + pop: 1 + ns-identifiers: - match: (\s*)\b(NS(Rect(ToCGRect|FromCGRect)|MakeCollectable|S(tringFromProtocol|ize(ToCGSize|FromCGSize))|Draw(NinePartImage|ThreePartImage)|P(oint(ToCGPoint|FromCGPoint)|rotocolFromString)|EventMaskFromType|Value))\b captures: From d7ba999e886e538ec5d466ef2063945e0d888d88 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:47:02 -0600 Subject: [PATCH 26/66] Minor fixes --- C++/C.sublime-syntax | 12 +++++------ C++/syntax_test_c.c | 2 +- Objective-C/Objective-C.sublime-syntax | 28 +++++++++++++------------- Objective-C/syntax_test_objc.m | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index e9ef88502c..af09d82351 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -24,7 +24,7 @@ contexts: - include: comment - include: preprocessor - ###[PREPROCESSOR]### +###[ PREPROCESSOR ]############################################################ comment: - match: // @@ -157,7 +157,7 @@ contexts: - include: punctuation - include: string - ###[TOP LEVEL]### +###[ TOP LEVEL ]############################################################ statement: - match: ; @@ -257,7 +257,7 @@ contexts: - include: keyword - include: constant - ###[SIMPLE STRUCTURES]### +###[ SIMPLE STRUCTURES ]############################################################ type: - match: \btypedef\b @@ -417,7 +417,7 @@ contexts: 1: entity.name.label.c 2: punctuation.separator.c - ###[BASIC OBJECTS]### +###[ BASIC OBJECTS ]############################################################ string: - match: (L|u8?|U)?(\") @@ -514,7 +514,7 @@ contexts: scope: punctuation.accessor.c operator.pointer: - match: \&|\* - scope: keyword.operator.arithmetic.c + scope: keyword.operator.c punctuation: - include: punctuation.comma @@ -714,7 +714,7 @@ contexts: scope: punctuation.section.group.end.c pop: 1 - ###[HELPERS]### +###[ HELPERS ]############################################################ pop-immediately: - match: "" diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index e8d0339e61..b0697a632e 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -565,7 +565,7 @@ // ^^^^^^ storage.modifier.c // ^^^^^^ storage.modifier.c // ^^^ storage.type.c -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c test( // ^^^^ entity.name.function.c // ^ punctuation.section.group.begin.c diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 582f3664dd..d59b0ca830 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -76,9 +76,11 @@ contexts: - match: \( scope: punctuation.section.group.begin.objc push: property.attrs - - match: (?=\S) - pop: 1 + - include: else-pop property.attrs: + - match: \) + scope: punctuation.section.group.end.objc + pop: 1 - match: \b([sg]etter)\s*(=)\s*({{identifier}})\b captures: 1: storage.modifier.objc @@ -88,13 +90,10 @@ contexts: scope: storage.modifier.objc - include: punctuation.comma - include: operator - - match: \) - scope: punctuation.section.group.end.objc - pop: 1 selector.return: - match: \( - scope: punctuation.section.group.begin + scope: punctuation.section.group.begin.objc set: enclosure.parenthesis selector: - meta_scope: meta.function.objc @@ -183,10 +182,10 @@ contexts: string: - meta_prepend: true - match: \@\" - scope: punctuation.definition.string.begin.c + scope: punctuation.definition.string.begin.objc push: string.double-ns - match: \@\' - scope: punctuation.definition.string.begin.c + scope: punctuation.definition.string.begin.objc push: string.single string.double-ns: - meta_scope: string.quoted.double.objc @@ -259,16 +258,18 @@ contexts: scope: constant.other.objc - match: \b(swift_name|objc_runtime_name)\s*(\() captures: - 1: storage.modifier.c - 2: punctuation.section.group.begin.c + 1: storage.modifier.objc + 2: punctuation.section.group.begin.objc push: enclosure.parenthesis constant: - meta_append: true - match: \b(nil|Nil)\b scope: constant.language.null.objc - - match: (\b|\@)(YES|NO|true|false)\b - scope: constant.language.boolean.objc + - match: (\b|\@)(YES|true)\b + scope: constant.language.boolean.true.objc + - match: (\b|\@)(|NO|false)\b + scope: constant.language.boolean.false.objc type: - meta_prepend: true @@ -369,5 +370,4 @@ contexts: # Catch-all - match: \bN\w+\b pop: 1 - - match: '' - pop: 1 + - include: pop-immediately diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 382d17de1d..9384a75667 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -565,7 +565,7 @@ int main(int argc, char const* argv[]) { // ^^^^^^ storage.modifier.c // ^^^^^^ storage.modifier.c // ^^^ storage.type.c -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c test( // ^^^^ entity.name.function.c // ^ punctuation.section.group.begin.c @@ -1402,7 +1402,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^^^^^^^^^^ meta.protocol-list.objc // ^ punctuation.section.scope.begin.objc // ^^^^^^^^ support.class.cocoa.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ punctuation.section.scope.end.objc // ^ keyword.operator.arithmetic.c // ^ keyword.operator.assignment.c From acf156b5a3b433a575479f6649e8500d39a436b9 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:16:12 -0600 Subject: [PATCH 27/66] Avoid treating `return` and other control keywords as function return types --- C++/C.sublime-syntax | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index af09d82351..cd8f86d629 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -166,11 +166,14 @@ contexts: - include: expression expression: - # most likely function definition - - match: (?=^\s*{{identifier}}\s+{{identifier}}\s*\() - push: - - include: function - - include: else-pop + # priority issues with matching ^\s*{{identifier}} + - match: ^\s+ + branch_point: try-function + branch: [expression.try-function, pop-immediately] + - include: keyword.control-flow + - include: keyword.control + - match: (?=^{{identifier}}\s+{{identifier}}\s*\() + set: function - include: number - include: string - include: type @@ -181,6 +184,15 @@ contexts: - include: generic - include: expression.call - include: enclosure + expression.try-function: + - include: keyword.control + - include: keyword.control-flow + - match: (?={{identifier}}\s+{{identifier}}\s*\() + set: + - include: function + - include: else-pop + - match: (?=\S) + fail: try-function expression.call: - match: \b(?:({{std_funcs}}))\s*(\() captures: From b5b5bcdcd4a951e3ffc0c8c7043e57ac8b83411c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:59:46 -0600 Subject: [PATCH 28/66] Function calls can span a newline (#2815) --- C++/C.sublime-syntax | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index cd8f86d629..cb0580f02e 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -193,6 +193,18 @@ contexts: - include: else-pop - match: (?=\S) fail: try-function + expression.try-call: + - match: ({{std_funcs}})\s*$ + captures: + 1: variable.function.c support.function.std.c + - match: ({{identifier}})\s*$ + captures: + 1: variable.function.c + - match: \( + scope: punctuation.section.group.begin.c + set: enclosure.parenthesis + - match: (?=\S) + scope: invalid.illegal.bad expression.call: - match: \b(?:({{std_funcs}}))\s*(\() captures: @@ -204,6 +216,9 @@ contexts: 1: variable.function.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis + - match: \b(?={{identifier}}\s*$) + branch_point: try-call + branch: [expression.try-call, pop-immediately] function: - include: expression-identifiers From 5315b9d128ea9701aae7a9c8f5f02e2c0e7d913d Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:01:52 -0600 Subject: [PATCH 29/66] Update tests for previous commit --- C++/syntax_test_c.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index b0697a632e..26a809520e 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -548,6 +548,21 @@ // ^ punctuation.definition.string.end.c // ^ punctuation.section.group.end // ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c From 5b4e0aa2609dab460f120c932ae59780ca46b597 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:09:53 -0600 Subject: [PATCH 30/66] Improve multi-line function call --- C++/C.sublime-syntax | 45 ++++++++++++++------------ Objective-C/Objective-C.sublime-syntax | 2 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index cb0580f02e..8e27dd6acb 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -182,7 +182,7 @@ contexts: - include: operator - include: punctuation - include: generic - - include: expression.call + - include: call - include: enclosure expression.try-function: - include: keyword.control @@ -193,32 +193,35 @@ contexts: - include: else-pop - match: (?=\S) fail: try-function - expression.try-call: - - match: ({{std_funcs}})\s*$ - captures: - 1: variable.function.c support.function.std.c - - match: ({{identifier}})\s*$ - captures: - 1: variable.function.c - - match: \( - scope: punctuation.section.group.begin.c - set: enclosure.parenthesis - - match: (?=\S) - scope: invalid.illegal.bad - expression.call: - - match: \b(?:({{std_funcs}}))\s*(\() + + call: + - match: \b({{std_funcs}})\s*(\() captures: 1: variable.function.c support.function.std.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis - - match: \b(?:({{identifier}}))\s*(\() + - match: \b({{identifier}})\s*(\() captures: 1: variable.function.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis - match: \b(?={{identifier}}\s*$) - branch_point: try-call - branch: [expression.try-call, pop-immediately] + branch_point: not-call + branch: [call.not-call, call.multi-line] + call.not-call: + - include: expression-identifiers + - match: (?=\() + fail: not-call + + - match: '{{identifier}}\b' + - include: else-pop + call.multi-line: + - match: '{{std_funcs}}' + scope: variable.function.c support.function.std.c + push: enclosure + - match: '{{identifier}}' + scope: variable.function.c + push: enclosure function: - include: expression-identifiers @@ -319,7 +322,7 @@ contexts: - include: expression type.enum: - meta_scope: meta.enum.c - - include: expression.call + - include: call - match: ({{identifier}})\s*(?=;) captures: 1: entity.name.enum.forward-decl.c @@ -349,7 +352,7 @@ contexts: pop: 1 type.struct: - meta_scope: meta.struct.c - - include: expression.call + - include: call - match: ({{identifier}})\s*(?=;) captures: 1: entity.name.enum.forward-decl.c @@ -367,7 +370,7 @@ contexts: fail: struct type.union: - meta_scope: meta.union.c - - include: expression.call + - include: call - match: ({{identifier}})\s*(?=;) captures: 1: entity.name.enum.forward-decl.c diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index d59b0ca830..871bd8a21c 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -312,7 +312,7 @@ contexts: - include: constant - include: operator.accessor - include: operator.pointer - - include: expression.call + - include: call - include: enclosure - match: (?={{identifier}}\s*:) From 048a17d1c4c4ad9d7a71a41a0555763dcc9d752f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:24:58 -0600 Subject: [PATCH 31/66] Fix major multiline bug, move directive beginning into variable --- C++/C.sublime-syntax | 27 +++++++++++++------------- Objective-C/Objective-C.sublime-syntax | 5 ++++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 8e27dd6acb..b14fbfcb0a 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -47,39 +47,35 @@ contexts: preprocessor: - include: preprocessor.line-escape + - include: comment - match: ^\s*#\s*((?:el)?if(?:n?def)?|undef|pragma)\b scope: keyword.control.import.c push: - meta_scope: meta.preprocessor.c + - include: comment - include: eol-pop - - match: ^\s*#\s*(else|endif)\b + - match: '{{dir_start}}(else|endif)\b' scope: keyword.control.import.c - - match: ^\s*#\s*(include|include_next)\b + - match: '{{dir_start}}(include|include_next)\b' scope: keyword.control.import.c push: preprocessor.include - - match: ^\s*#\s*(embed)\b + - match: '{{dir_start}}(embed)\b' scope: keyword.control.import.c push: preprocessor.embed - - match: ^\s*#\s*(define)\b + - match: '{{dir_start}}(define)\b' scope: keyword.control.import.c push: preprocessor.define - - match: ^\s*#\s*(undef)\b - scope: keyword.control.import.c - push: - - meta_scope: meta.preprocessor.c - - include: eol-pop - - - match: ^\s*#\s*(error)\b + - match: '{{dir_start}}(error)\b' scope: keyword.control.import.error.c push: preprocessor.diagnostic - - match: ^\s*#\s*(warning)\b + - match: '{{dir_start}}(warning)\b' scope: keyword.control.import.warning.c push: preprocessor.diagnostic preprocessor.line-escape: @@ -218,10 +214,11 @@ contexts: call.multi-line: - match: '{{std_funcs}}' scope: variable.function.c support.function.std.c - push: enclosure - match: '{{identifier}}' scope: variable.function.c - push: enclosure + - match: \( + scope: punctuation.section.group.begin.c + set: enclosure.parenthesis function: - include: expression-identifiers @@ -776,3 +773,5 @@ variables: attribute_func: '(?:aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' std_funcs: '(?:assert|(?:exp(?:2|m1)|log(?:10|2|1p)|cbrt|hypot|erfc?|[lt]gamma|ceil|floor|trunc|l{0,2}round|f(?:absmod|max|min|dim)|c(?:abs|real|imag|arg|onj|proj|)|c?(?:exp|log|pow|sqrt|a?(?:sin|cos|tan)h?))[fl]?|abs|l{0,2}div|is(?:finite|inf|nan|normal|greater(?:equal)?|less(?:equal|greater)?|unordered|alnum|alpha|lower|upper|x?digit|cntrl|graph|space|blank|print|punct)(?:set|long)jmp|jmp_buf|signal|raise|va_(?:list|start|arg|copy|end)|std(?:in|out|err)|setv?buf|re(?:wind|move|name)|tmp(?:nam|file)(?:_s)?|f(?:(?:re)?open(?:_s)?|close|flush|wide|read|write|tell|getpos|seek|setpos|error)|gets_s|f?(?:get|put)?(?:c|s|char)|v?f?s?w?scanf(?:s|sn)?w?printf(?:_s)?|abort|(?:(?:at_)?quick_|at)?exit|_Exit|unreachable|system|getenv(?:_s)?|to(?:lower|upper)|ato(?:f|i|l|ll)|str(?:to(?:u?ll?|f|l?d)|from[dfl]|(?:n?cpy|cat|nlen|tok|error(?:len)?)(?:_s)?|xfrm|n?dup|n?cmp|coll|r?chr|c?spn|pbrk|str|len)|mem(?:chr|cmp|set(?:_explicit|_s)?|(?:move|cpy)(?:_s)?|ccpy)|thrd_(?:create|equal|current|sleep|yield|exit|detach|join|success|timedout|busy|nomem|error)|(?:diff|mk|strf)?time|clock|timespec_get(?:res)?|(?:as)?ctime(?:_s)?|(?:gm|local)time(?:_[rs])?)' + + dir_start: ^\s*#\s* \ No newline at end of file diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 871bd8a21c..3afb8c7477 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -175,7 +175,7 @@ contexts: preprocessor: - meta_prepend: true - - match: ^\s*#\s*(import)\b + - match: '{{dir_start}}(import)\b' scope: keyword.control.import.objc push: preprocessor.include @@ -318,6 +318,9 @@ contexts: - match: (?={{identifier}}\s*:) set: message.func + - match: \] + fail: message + - match: ({{identifier}})\s*(\]) captures: 1: entity.name.function.method.objc From 7d0a6a482a0c8e8f9517fba78cbe2c276966b125 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:31:29 -0600 Subject: [PATCH 32/66] Modify ObjC tests to match correct scope --- Objective-C/Objective-C.sublime-syntax | 6 +++--- Objective-C/syntax_test_objc.m | 23 +++++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 3afb8c7477..2c5dcc04dc 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -263,12 +263,12 @@ contexts: push: enclosure.parenthesis constant: - - meta_append: true + - meta_prepend: true - match: \b(nil|Nil)\b scope: constant.language.null.objc - - match: (\b|\@)(YES|true)\b + - match: ((@|\b)YES|@true)\b scope: constant.language.boolean.true.objc - - match: (\b|\@)(|NO|false)\b + - match: ((@|\b)NO|@false)\b scope: constant.language.boolean.false.objc type: diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 9384a75667..5689140a89 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -1211,8 +1211,8 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS // ^^^^^^^^^^^^^ storage.modifier.c // ^^ punctuation.section.group.begin.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^^^^^^^^^^^^^^^^^ storage.modifier.c -// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.begin.objc // ^^^^^^^^^^ string.quoted.double.c // ^ punctuation.definition.string.begin.c // ^ punctuation.definition.string.end.c @@ -1223,7 +1223,6 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS // ^^^^^^^^^^^^ meta.protocol-list.objc // ^ punctuation.section.scope.begin.objc // ^ punctuation.section.scope.end.objc - { @public int a; //^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c @@ -1353,13 +1352,13 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^^^^^^^ support.class.cocoa.objc // ^ keyword.operator.arithmetic.c // ^ keyword.operator.assignment.c -// ^^^^^^^^^^ meta.bracketed.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^^^^^^ support.class.cocoa.objc // ^^^^^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc // ^^^^^^^^^^^^^^^^^^^ string.quoted.double.objc -// ^^ punctuation.definition.string.begin.c +// ^^ punctuation.definition.string.begin.objc // ^^ constant.other.placeholder.objc // ^ punctuation.definition.string.end.c // ^ punctuation.separator.c @@ -1376,7 +1375,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ keyword.operator.arithmetic.c // ^ keyword.operator.assignment.c // ^^^^ string.quoted.single.c -// ^^ punctuation.definition.string.begin.c +// ^^ punctuation.definition.string.begin.objc // ^ punctuation.definition.string.end.c // ^ punctuation.terminator.c __autoreleasing NSView* a = [[NSView alloc] init]; @@ -1470,7 +1469,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.group.end // ^^^^^^^ constant.other.variable.mac-classic.c // ^ keyword.operator.ternary.c -// ^^^^ constant.language.boolean.objc +// ^^^^ constant.language.boolean.true.objc }; //^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c //^^^ meta.mapping.objc @@ -1533,7 +1532,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib //^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.bracketed.objc // ^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^^^ constant.language.boolean.objc +// ^^^ constant.language.boolean.false.objc ]; //^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c //^^^^^^^ meta.bracketed.objc @@ -1596,9 +1595,9 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ keyword.operator.arithmetic.c // ^ punctuation.section.group.end // ^ keyword.operator.ternary.c -// ^^^^^ constant.language.boolean.objc +// ^^^^^ constant.language.boolean.true.objc // ^ keyword.operator.ternary.c -// ^^^^^^ constant.language.boolean.objc +// ^^^^^^ constant.language.boolean.false.objc // ^ punctuation.section.brackets.end.objc // ^ punctuation.terminator.c } @catch(NSException* exc) { @@ -1616,7 +1615,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib return NO; //^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c // ^^^^^^ keyword.control.flow.return.c -// ^^ constant.language.boolean.objc +// ^^ constant.language.boolean.false.objc // ^ punctuation.terminator.c } @finally { //^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c @@ -1627,7 +1626,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib return YES; //^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c // ^^^^^^ keyword.control.flow.return.c -// ^^^ constant.language.boolean.objc +// ^^^ constant.language.boolean.true.objc // ^ punctuation.terminator.c } //^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c From c3d4f29c17805620ef0e12ead1f4fc7e532a677c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:19:40 -0600 Subject: [PATCH 33/66] common bug fixes --- C++/C.sublime-syntax | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index b14fbfcb0a..d1e14cca98 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -49,7 +49,7 @@ contexts: - include: preprocessor.line-escape - include: comment - - match: ^\s*#\s*((?:el)?if(?:n?def)?|undef|pragma)\b + - match: '{{dir_start}}((?:el)?if(?:n?def)?|undef|pragma)\b' scope: keyword.control.import.c push: - meta_scope: meta.preprocessor.c @@ -78,6 +78,9 @@ contexts: - match: '{{dir_start}}(warning)\b' scope: keyword.control.import.warning.c push: preprocessor.diagnostic + + - match: '{{dir_start}}(?!\s*{{identifier}})' + scope: keyword.control.c preprocessor.line-escape: - match: \\$\n scope: punctuation.separator.continuation.c @@ -212,9 +215,9 @@ contexts: - match: '{{identifier}}\b' - include: else-pop call.multi-line: - - match: '{{std_funcs}}' - scope: variable.function.c support.function.std.c - - match: '{{identifier}}' + - match: '\b{{std_funcs}}\b' + scope: support.function.std.c + - match: '\b{{identifier}}\b' scope: variable.function.c - match: \( scope: punctuation.section.group.begin.c @@ -752,6 +755,9 @@ contexts: eol-pop: - match: $\n? pop: 1 + pop-twice: + - match: "" + pop: 2 variables: identifier: \b[[:alpha:]_][[:alnum:]_]*\b From 1f595900d93ca5a76290c904c6e079af4ce4ed25 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:21:32 -0600 Subject: [PATCH 34/66] Start working on C++ --- C++/C++.sublime-syntax | 2531 ++++------------------------------------ 1 file changed, 201 insertions(+), 2330 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 81ed81d942..db5c99838b 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -3,6 +3,8 @@ # http://www.sublimetext.com/docs/3/syntax.html name: C++ scope: source.c++ +version: 2 +extends: Packages/C++/C.sublime-syntax file_extensions: - cpp @@ -26,2340 +28,209 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \b(c\+\+|cpp\b) .*? -\*- # editorconfig ) -variables: - # number digits - bin_digit: '[01'']' - oct_digit: '[0-7'']' - dec_digit: '[\d'']' - hex_digit: '[\h'']' - - dec_digits: '(?:\d(?:{{dec_digit}}*\d)?)' - - # number exponents - dec_exponent: '(?:[eE][-+]?{{dec_digit}}*)' - hex_exponent: '(?:[pP][-+]?{{dec_digit}}*)' - - # number suffixes - # note: nearly everything can be defined as suffix - # a) see user literals - # https://en.cppreference.com/w/cpp/language/user_literal - # b) see complex `operator` keyword - # https://en.cppreference.com/w/cpp/numeric/complex/operator%22%22i - bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' - oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' - dec_suffix: '[a-zA-Z_][[:alnum:]_]*' - hex_suffix: '[g-zG-Z_][[:alnum:]_]*' - float_suffix: '[fF]' - - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - path_lookahead: '(?:::\s*)?(?:{{identifier}}\s*::\s*)*(?:template\s+)?{{identifier}}' - operator_method_name: '\boperator\s*(?:[-+*/%^&|~!=<>]|[-+*/%^&|=!<>]=|<=>|<<=?|>>=?|&&|\|\||\+\+|--|,|->\*?|\(\)|\[\]|""\s*{{identifier}})' - casts: 'const_cast|dynamic_cast|reinterpret_cast|static_cast' - operator_keywords: 'and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq|noexcept' - coroutine_keywords: co_(?:await|return|yield) - control_keywords: 'break|case|catch|continue|default|do|else|for|goto|if|_Pragma|switch|throw|try|while|{{coroutine_keywords}}' - memory_operators: 'new|delete' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum\s+class|enum\s+struct|enum|class|concept' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|export|extern|friend|explicit|virtual|register|thread_local' - type_qualifier: 'const|mutable|typename|volatile' - constant_expression_specifiers: 'consteval|constexpr|constinit' - compiler_directive: 'inline|restrict|__restrict__|__restrict' - visibility_modifiers: 'private|protected|public' - other_keywords: 'typedef|nullptr|{{visibility_modifiers}}|static_assert|sizeof|using|typeid|alignof|alignas|namespace|template' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}|{{constant_expression_specifiers}}' - non_angle_brackets: '(?=<<|<=)' - module_identifier: '{{identifier}}(?:\.{{identifier}})*' - - regular: '[^(){}&;*^%=<>-]*' - regular_plus: '[^(){}&;*^%=<>-]+' - paren_open: (?:\( - paren_close: '\))?' - generic_open: (?:{{regular_plus}}(?:< - generic_close: '>)?)?' - balance_parentheses: '{{regular}}{{paren_open}}{{regular}}{{paren_close}}{{regular}}' - generic_lookahead: <{{generic_open}}{{generic_open}}{{regular}}{{generic_close}}\s*{{generic_close}}{{balance_parentheses}}> - - data_structures_forward_decl_lookahead: '(\s+{{macro_identifier}})*\s*(:\s*({{path_lookahead}}|{{visibility_modifiers}}|,|\s|<[^;]*>)+)?;' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__|typeid|alignof|alignas|static_assert' - contexts: - main: - - include: preprocessor-global - - include: global - - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the - # Objective-C++ syntax. They are specifically constructed to not push into - # sub-contexts, which ensures that Objective-C++ code isn't accidentally - # lexed as plain C++. - # - # The "unique-*" contexts are additions that C++ makes over C, and thus can - # be directly reused in Objective-C++ along with contexts from Objective-C - # and C. - ############################################################################# - - unique-late-expressions: - # This is highlighted after all of the other control keywords - # to allow operator overloading to be lexed properly - - match: \boperator\b - scope: keyword.control.c++ - - unique-modifiers: - - match: \b({{modifiers}})\b - scope: storage.modifier.c++ - - unique-variables: - - match: \bthis\b - scope: variable.language.c++ - # common C++ instance var naming idiom -- fMemberName - - match: '\b(f|m)[[:upper:]]\w*\b' - scope: variable.other.readwrite.member.c++ - # common C++ instance var naming idiom -- m_member_name - - match: '\bm_[[:alnum:]_]+\b' - scope: variable.other.readwrite.member.c++ - - unique-constants: - - match: \bnullptr\b - scope: constant.language.c++ - - unique-keywords: - - match: \busing\b - scope: keyword.control.c++ - - match: \bbreak\b - scope: keyword.control.flow.break.c++ - - match: \bcontinue\b - scope: keyword.control.flow.continue.c++ - - match: \bgoto\b - scope: keyword.control.flow.goto.c++ - - match: \breturn\b - scope: keyword.control.flow.return.c++ - - match: \bthrow\b - scope: keyword.control.flow.throw.c++ - - match: \b({{control_keywords}})\b - scope: keyword.control.c++ - - match: '\bdelete\b(\s*\[\])?|\bnew\b(?!])' - scope: keyword.control.c++ - - match: \b({{operator_keywords}})\b - scope: keyword.operator.word.c++ - - unique-types: - - match: \bclass\b - scope: keyword.declaration.class.c++ - - unique-strings: - - match: '((?:L|u8|u|U)?R)("([^\(\)\\ ]{0,16})\()' - captures: - 1: storage.type.string.c++ - 2: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.double.c++ - - match: '\)\3"' - scope: punctuation.definition.string.end.c++ - pop: true - - numbers: - # https://en.cppreference.com/w/cpp/language/floating_literal - - # decimal floats - - match: |- - (?x: - \b({{dec_digits}}) - (?: - ( (\.) - (?: - # 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L - {{dec_digit}}+ {{dec_exponent}}? - # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L - | {{dec_exponent}} - # 1., 1.f, 1.L # but not `..` - | (?!\.) - ) - # 1e1 1e1f 1e1L - | {{dec_exponent}} - ) ({{dec_suffix}})? - # 1f - | ({{float_suffix}}) - ) - # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L - | ( (\.) {{dec_digit}}+ {{dec_exponent}}? ) ({{dec_suffix}})? - ) - scope: meta.number.float.decimal.c++ - captures: - 1: constant.numeric.value.c++ - 2: constant.numeric.value.c++ - 3: punctuation.separator.decimal.c++ - 4: constant.numeric.suffix.c++ - 5: constant.numeric.suffix.c++ - 6: constant.numeric.value.c++ - 7: punctuation.separator.decimal.c++ - 8: constant.numeric.suffix.c++ - - # hexadecimal float - - match: \b(0[xX])({{hex_digit}}*(\.){{hex_digit}}*{{hex_exponent}})({{dec_suffix}})? - scope: meta.number.float.hexadecimal.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: punctuation.separator.decimal.c++ - 4: constant.numeric.suffix.c++ - - # https://en.cppreference.com/w/cpp/language/integer_literal - - # hexadecimal integer - - match: \b(0[xX])({{hex_digit}}*)({{hex_suffix}})? - scope: meta.number.integer.hexadecimal.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: constant.numeric.suffix.c++ - - # binary integer (C++14) - - match: \b(0[bB])({{bin_digit}}*)({{bin_suffix}})? - scope: meta.number.integer.binary.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: constant.numeric.suffix.c++ - - # octal integer - - match: \b(0)({{oct_digit}}+)({{oct_suffix}})? - scope: meta.number.integer.octal.c++ - captures: - 1: constant.numeric.base.c++ - 2: constant.numeric.value.c++ - 3: constant.numeric.suffix.c++ - - # decimal integer - - match: \b({{dec_digits}})({{dec_suffix}})? - scope: meta.number.integer.decimal.c++ - captures: - 1: constant.numeric.value.c++ - 2: constant.numeric.suffix.c++ - - identifiers: - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - match: '(?:(::)\s*)?{{identifier}}' - captures: - 1: punctuation.accessor.double-colon.c++ - - identifier-path-generic: - - include: angle-brackets - - match: '(?:(::)\s*)?{{identifier}}\s*(?=(<.*>)?\s*(::))\s*' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - function-specifiers: - - match: \b(const|final|noexcept|override)\b - scope: storage.modifier.c++ - - ############################################################################# - # The following are C++-specific contexts that should not be reused. This is - # because they push into subcontexts and use variables that are C++-specific. - ############################################################################# - - ## Common context layout - - global: - - match: '(?=\btemplate\b)' - push: + function: + - include: expression-identifiers + - include: operator.pointer + - match: ({{identifier}})\s*(\() + captures: + 1: entity.name.function.c + 2: punctuation.section.group.begin.c + push: [function.tail, function.params] + - match: (?={{identifier}}\s*<) + branch_point: try-template + branch: [function.try-template, function.consume-ident] + - match: \b{{identifier}}\b + function.consume-ident: + - match: \b{{identifier}}\b + - include: pop-immediately + function.try-template: + - match: ({{identifier}})(?=\s*<) + scope: entity.name.function.cpp + set: function.try-template.body + function.try-template.body: - include: template - - match: (?=\S) - set: global-modifier - - include: using-namespace - - include: namespace - - include: module - - include: keywords-angle-brackets - - match: '(?={{path_lookahead}}\s*<)' - push: global-modifier - - include: global-block-comments - - include: early-expressions - - match: ^\s*\b(extern)(?=\s+"C(\+\+)?") - scope: storage.modifier.c++ - push: - - include: comments - - include: strings - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_scope: meta.extern-c.c++ - - match: '^\s*(#\s*ifdef)\s*__cplusplus\s*' - scope: meta.preprocessor.c++ - captures: - 1: keyword.control.import.c++ - set: - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: preprocessor-global - - include: global - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: preprocessor-global - - include: global - - match: (?=\S) - set: global-modifier - - match: ^\s*(?=\w) - push: global-modifier - - include: late-expressions - - global-block-comments: - # NOTE: This context overrides `comments` context, which re-uses scopes - # from `source.c#comments`. So keep the trailing `c` for consistency reasons! - - match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n? - scope: comment.block.banner.c - captures: - 1: punctuation.definition.comment.begin.c - 2: meta.toc-list.banner.block.c - 3: punctuation.definition.comment.end.c - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.c punctuation.definition.comment.c - push: global-block-comment-after - # documentation block comments - - match: (?:/\*!|/\*{2,}) - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-documentation-body - # normal block comments - - match: /\* - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-body - - global-block-comment-after: - - match: \s*(?=\w) - set: global-modifier - - match: '' - pop: true - - statements: - - include: preprocessor-statements - - include: scope:source.c#label - - include: expressions - - statements-enum: - - include: comments - - include: preprocessor-statements - - include: scope:source.c#label - - match: '{{identifier}}' - scope: entity.name.constant.c++ - push: constant-value - - match: ',' - scope: punctuation.separator.c++ - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: early-expressions-before-generic-type - - include: generic-type - - include: early-expressions-after-generic-type - - early-expressions-before-generic-type: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: using-namespace - - include: typedef - - include: using-alias - - include: keywords-angle-brackets - - include: keywords-parens - - include: keywords - - include: numbers - # Prevent a '<' from getting scoped as the start of another template - # parameter list, if in reality a less-than-or-equals sign or - # three-way comparison operator is meant. - - match: '<=>?' - scope: keyword.operator.comparison.c - - early-expressions-after-generic-type: - - include: members-arrow - - include: operators - - include: members-dot - - include: strings - - include: parens - - include: brackets - - include: block - - include: variables - - include: constants - - match: ',' - scope: punctuation.separator.c++ - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.c++ - - expressions-minus-generic-type: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions - - expressions-minus-generic-type-function-call: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions-before-function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - late-expressions: - - include: late-expressions-before-function-call - - include: function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - late-expressions-before-function-call: - - include: unique-late-expressions - - include: modifiers-parens - - include: modifiers - - include: types - - expressions-minus-function-call: - - include: early-expressions - - include: late-expressions-before-function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - comments: - - include: scope:source.c#comments - - operators: - - include: scope:source.c#operators - - modifiers: - - include: unique-modifiers - - include: scope:source.c#modifiers - - variables: - - include: unique-variables - - include: scope:source.c#variables - - constants: - - include: unique-constants - - include: scope:source.c#constants - - keywords: - - include: unique-keywords - - include: scope:source.c#keywords - - types: - - include: unique-types - - include: types-parens - - include: scope:source.c#types - - strings: - - include: unique-strings - - include: scope:source.c#strings - - ## C++-specific contexts - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.c++ - push: - - match: (?=[);,]) - pop: true - - match: ':' - scope: punctuation.separator.c++ - pop: true - - include: expressions - - modifiers-parens: - - match: '\b(alignas)\b\s*(\()' - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push : - - meta_scope: meta.attribute.c++ - - meta_content_scope: meta.group.c++ - - include: parens - - include: strings - - match: \)\) - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - match: \b(__declspec)(\() - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.c++ - - match: ',' - scope: punctuation.separator.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.c++ - - types-parens: - - match: '\b(decltype)\b\s*(\()' - captures: - 1: keyword.declaration.type.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - keywords-angle-brackets: - - match: \b({{casts}})\b\s* - scope: keyword.operator.word.cast.c++ - push: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - match: '<' - scope: punctuation.definition.generic.begin.c++ - push: - - match: '(?=>)' - pop: true - - include: expressions-minus-generic-type-function-call - - keywords-parens: - - match: '\b(alignof|typeid|static_assert|sizeof)\b\s*(\()' - captures: - 1: keyword.operator.word.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - using-namespace: - - match: '\b(using)\s+(namespace)\b' - captures: - 1: keyword.control.c++ - 2: keyword.control.c++ - push: - - include: identifiers - - match: '' - pop: true - - namespace: - - match: '\b(namespace)\s+(?=({{path_lookahead}})?(?!\s*[;,]))' - scope: meta.namespace.c++ - captures: - 1: keyword.control.c++ - push: - - meta_content_scope: meta.namespace.c++ entity.name.namespace.c++ - - include: identifiers - - match: '' - set: - - meta_scope: meta.namespace.c++ - - include: comments - - match: '=' - scope: keyword.operator.alias.c++ - - match: '(?=;)' - pop: true - - match: '\}' - scope: meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - - include: expressions - - module-identifier: - # Special handling for trailing periods to prevent color changing while typing. - # Exit to catch invalid trailing period. - - match: '(?=\.\s*[\:;])' - pop: true - # Prevent color changing. - - match: \. - scope: entity.name.module.c++ - # Upcoming partition. - - match: (?=\s*\:) - pop: true - # Forgotten semmi-colon, fully abort out to handle upcoming syntax. - - match: (?=\s*\S) - pop: 2 - - match: '' #safety pop - pop: true - - module-error-handling: - # Stray periods in the name are invalid. - # Only mark the first period as invalid, even though trailing periods are also invalid. - - match: '\B\.' - scope: invalid.illegal.unexpected-character.c++ - # Stray period at end of module name. - - match: '(\.)(?=\s*\:)' - captures: - 1: invalid.illegal.unexpected-character.c++ - # Module partition - check for invalid partition names. - - match: (\:)\s*({{module_identifier}})(?:\s*(\:))? - captures: - 1: punctuation.accessor.c++ - 2: entity.name.partition.other - 3: invalid.illegal.unexpected-character.c++ - # End of line, but also check for stray period. - - match: '(\.\s*)?(;)' - captures: - 1: invalid.illegal.unexpected-character.c++ - 2: punctuation.terminator.c++ - pop: true - - match: (?=\S|$) # safety pop - pop: true - - module: - # The export keyword can go before most anything. - - match: '\b(export)\s+' - captures: - 1: keyword.control.c++ - push: - # export {...} block. - - match: '\}' - scope: meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - # If this is exporting a module declaration, pop so we can handle it. - - match: '(?=(module|import))' - pop: true - # Otherwise, set into a normal declaration. We are exporting a function or something. - - match: '' - set: global-type - - - match: '\b(import)\s+' - captures: - 1: keyword.control.c++ - push: - - meta_scope: meta.module.c++ - # Module name. - - match: '{{module_identifier}}' - scope: entity.name.module.c++ - push: module-identifier - # import "header"; - - match: '"' - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: meta.module.import.c++ string.quoted.double.import.c++ - - match: '"' - scope: punctuation.definition.string.end.c++ - pop: true - # import
; - - match: \< - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: meta.module.import.c++ string.quoted.other.lt-gt.import.c++ - - match: '>' - scope: punctuation.definition.string.end.c++ - pop: true - - include: module-error-handling - - - match: '\b(module)(\s+)?' - captures: - 1: keyword.control.c++ - push: - - meta_scope: meta.module.c++ - # Module name. - - match: '{{module_identifier}}' - scope: entity.name.module.c++ - push: module-identifier - # Module partition - check for invalid partition names. - - match: (\:)\s*(private)(?:\s*(\:))? - captures: - 1: punctuation.accessor.c++ - 2: entity.name.partition.private - 3: invalid.illegal.unexpected-character.c++ - - include: module-error-handling - - template-common: - # Exit the template scope if we hit some basic invalid characters. This - # helps when a user is in the middle of typing their template types and - # prevents re-highlighting the whole file until the next > is found. - - match: (?=[{};]) - pop: true - - include: expressions - - template: - - match: \btemplate\b - scope: keyword.declaration.template.c++ - push: - - meta_scope: meta.template.c++ - # Explicitly include comments here at the top, in order to NOT match the - # \S lookahead in the case of comments. - - include: comments - - match: < - scope: punctuation.definition.generic.begin.c++ - set: - - meta_content_scope: meta.template.c++ - - match: '>' - scope: meta.template.c++ punctuation.definition.generic.end.c++ - set: - - include: constraint-requires - - match: (?=\S) - pop: true - - match: \.{3} - scope: keyword.operator.variadic.c++ - - match: \b(typename|{{before_tag}})\b - scope: keyword.declaration.c++ - - include: template # include template here for nested templates - - include: template-common - - match: (?=\S) - set: - - meta_content_scope: meta.template.c++ - - match: \b({{before_tag}})\b - scope: keyword.declaration.c++ - - include: template-common - - requires: - - match: \brequires\b - scope: keyword.operator.word.c++ - push: function-definition-params - - constraint: - - match: (?=;) - pop: true - - include: requires - - include: expressions-minus-generic-type-function-call - - constraint-requires: - - match: '\brequires\b' - scope: storage.modifier.c++ - push: - - meta_scope: meta.constraint.c++ - - match: (?=\{|{{identifier}}\s*{{identifier}}\(|{{before_tag}}|:) - pop: true - - include: constraint - - generic-type: - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}}\s*(\(|\{))' - push: - - meta_scope: meta.function-call.c++ - - match: \btemplate\b - scope: keyword.declaration.template.c++ - - match: (?:(::)\s*)?({{identifier}})\s*(<) - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.definition.generic.begin.c++ - push: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - match: (?:(::)\s*)?({{identifier}})\s*(\() - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: (?:(::)\s*)?({{identifier}})\s*(\{) - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\}' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - include: identifiers - - include: angle-brackets - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\}' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}})' - push: - - include: identifiers - - match: '<' - scope: punctuation.definition.generic.begin.c++ - set: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - angle-brackets: - - match: '<(?!<)' - scope: punctuation.definition.generic.begin.c++ - push: - - match: '>' - scope: punctuation.definition.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - block: - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - function-call: - - match: (?={{path_lookahead}}\s*(\(|\{)) - push: - - meta_scope: meta.function-call.c++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.c++ - 2: variable.function.c++ - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\)' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\}' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - members-inside-function-call: - - meta_content_scope: meta.method-call.c++ meta.group.c++ - - match: \) - scope: meta.method-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - members-after-accessor-junction: - # After we've seen an accessor (dot or arrow), this context decides what - # kind of entity we're accessing. - - include: comments - - match: \btemplate\b - scope: meta.method-call.c++ keyword.declaration.template.c++ - # Guaranteed to be a template member function call after we match this - set: - - meta_content_scope: meta.method-call.c++ - - include: comments - - match: '{{identifier}}' - scope: variable.function.member.c++ - set: - - meta_content_scope: meta.method-call.c++ - - match: \( - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - - include: comments - - include: angle-brackets - - match: (?=\S) # safety pop - pop: true - - match: (?=\S) # safety pop - pop: true - # Operator overloading - - match: '({{operator_method_name}})\s*(\()' - captures: - 0: meta.method-call.c++ - 1: variable.function.member.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - # Non-templated member function call - - match: (~?{{identifier}})\s*(\() - captures: - 0: meta.method-call.c++ - 1: variable.function.member.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - # Templated member function call - - match: (~?{{identifier}})\s*(?={{generic_lookahead}}) - captures: - 1: variable.function.member.c++ - set: - - meta_scope: meta.method-call.c++ - - match: < - scope: punctuation.definition.generic.begin.c++ - set: - - meta_content_scope: meta.method-call.c++ - - match: '>' - scope: punctuation.definition.generic.end.c++ - set: - - meta_content_scope: meta.method-call.c++ - - include: comments - - match: \( - scope: punctuation.section.group.begin.c++ - set: members-inside-function-call - - match: (?=\S) # safety pop - pop: true - - include: expressions - # Explicit base-class access - - match: ({{identifier}})\s*(::) - captures: - 1: variable.other.base-class.c++ - 2: punctuation.accessor.double-colon.c++ - set: members-after-accessor-junction # reset - # Just a regular member variable - - match: '{{identifier}}' - scope: variable.other.readwrite.member.c++ - pop: true - - members-dot: - - include: scope:source.c#access-illegal - # No lookahead required because members-dot goes after operators in the - # early-expressions-after-generic-type context. This means triple dots - # (i.e. "..." or "variadic") is attempted first. - - match: \. - scope: punctuation.accessor.dot.c++ - push: members-after-accessor-junction - - members-arrow: - # This needs to be before operators in the - # early-expressions-after-generic-type context because otherwise the "->" - # from the C language will match. - - match: -> - scope: punctuation.accessor.arrow.c++ - push: members-after-accessor-junction - - using-alias: - # consume keyword if followed by typename - - match: '\b(using)\b(?=\s+typename\b)' - captures: - 1: keyword.control.c++ - - match: '\b(using)\b\s+({{identifier}})(?!\s*(<|::))' - captures: - 1: keyword.control.c++ - 2: entity.name.type.using.c++ - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.c++ - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.c++ - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions-minus-generic-type - - parens: - - match: \( - scope: punctuation.section.group.begin.c++ - push: - - meta_scope: meta.group.c++ - - match: \) - scope: punctuation.section.group.end.c++ - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.c++ - push: - - meta_scope: meta.brackets.c++ - - match: \] - scope: punctuation.section.brackets.end.c++ - pop: true - - include: expressions - - function-trailing-return-type: - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - - include: identifiers - - match: \*|& - scope: keyword.operator.c++ - - include: function-trailing-return-type-parens - - match: '(?=\S)' - pop: true - - function-trailing-return-type-parens: - - match: \( - scope: punctuation.section.group.begin.c++ - push: - - meta_scope: meta.group.c++ - - match: \) - scope: punctuation.section.group.end.c++ - pop: true - - include: function-trailing-return-type - - ## Detection of function and data structure definitions at the global level - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - # Constructors and destructors don't have a type - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*{{identifier}}\s*\()' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.constructor.c++ - - match: '(?=[^\w\s])' - set: function-definition-params - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*~{{identifier}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?(~{{identifier}})' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.destructor.c++ - - match: '(?=[^\w\s])' - set: function-definition-params - # If we see a path ending in :: before a newline, we don't know if it is - # a constructor or destructor, or a long return type, so we are just going - # to treat it like a regular function. Most likely it is a constructor, - # since it doesn't seem most developers would create such a long typename. - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*$)' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(::)\s*$' - captures: - 1: punctuation.accessor.double-colon.c++ - - match: '(?:(::)\s*)?(~?{{identifier}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - match: '(?=[^\w\s])' - set: function-definition-params - - include: unique-strings - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.c++ - set: - - include: identifiers - - match: '' - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '(?={{path_lookahead}}\s*\()' - set: - - include: function-call - - match: '' - pop: true - - include: variables - - include: constants - - include: identifiers - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.c++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Operator overloading - - match: '(?=({{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*)?{{operator_method_name}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?({{operator_method_name}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - match: '(?=\s*(\(|$))' - set: function-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\(|$)))' - push: - - include: identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*(\(|$))' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\(|$))' - set: [function-definition-params, global-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [function-definition-params, global-function-identifier] - - match: '(?=\S)' - pop: true - - global-function-identifier-generic: - - meta_content_scope: meta.toc-list.full-identifier.c++ - - include: identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})(?=\s*(<.*>)?\s*\()' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - match: '(?=\()' - pop: true - - global-function-identifier: - - meta_content_scope: meta.toc-list.full-identifier.c++ - - match: '(?:(::)\s*)?({{identifier}})(?!\s*(::))' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.c++ - - include: comments - - match: '(?=\()' - set: - match: \( - scope: meta.function.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function.parameters.c++ meta.group.c++ - - match : \) - scope: punctuation.section.group.end.c++ - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.c++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.c++ - set: function-definition-trailing-return - - include: function-specifiers - - include: constraint-requires - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '&' - scope: keyword.operator.c++ - - match: \b0\b - scope: meta.number.integer.decimal.c++ constant.numeric.value.c++ - - match: \b(default|delete)\b - scope: storage.modifier.c++ - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: function-definition-body - - include: function-specifiers - - include: constraint-requires - - include: function-trailing-return-type - - function-definition-body: - - meta_content_scope: meta.function.c++ meta.block.c++ - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.function.c++ meta.block.c++ - - match: '\}' - scope: meta.function.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Data structures including classes, structs, unions and enums - - data-structures: - - match: '\bclass\b' - scope: keyword.declaration.class.c++ - set: data-structures-class-definition - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{path_lookahead}}\s+{{path_lookahead}}\s*[=;\[])' - scope: keyword.declaration.c++ - - match: '\bstruct\b' - scope: keyword.declaration.struct.type.c++ - set: data-structures-struct-definition - - match: '\benum(\s+(class|struct))?\b' - scope: keyword.declaration.enum.type.c++ - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.type.c++ - set: data-structures-union-definition - - match: '\bconcept\b' - scope: meta.concept.c++ keyword.declaration.concept.c++ - set: data-structures-concept-definition - - match: '(?=\S)' - pop: true - - preprocessor-workaround-eat-macro-before-identifier: - # Handle macros so they aren't matched as the class name - - match: ({{macro_identifier}})(?=\s+~?{{identifier}}) - captures: - 1: meta.assumed-macro.c - - match: '({{macro_identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - data-structures-class-definition: - - meta_scope: meta.class.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.class.forward-decl.c++ - set: data-structures-class-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.class.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.class.c++ - set: data-structures-class-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-class-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-class-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-class-definition-after-identifier: - - meta_content_scope: meta.class.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.class.c++ meta.block.c++ - - match: '\}' - scope: meta.class.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - data-structures-struct-definition: - - meta_scope: meta.struct.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.struct.forward-decl.c++ - set: data-structures-struct-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.struct.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.struct.c++ - set: data-structures-struct-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-struct-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-struct-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-identifier: - - meta_content_scope: meta.struct.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.struct.c++ meta.block.c++ - - match: '\}' - scope: meta.struct.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.enum.forward-decl.c++ - set: data-structures-enum-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.enum.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.enum.c++ - set: data-structures-enum-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-enum-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-enum-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-identifier: - - meta_content_scope: meta.enum.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.enum.c++ meta.block.c++ - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: statements-enum - - data-structures-union-definition: - - meta_scope: meta.union.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.union.forward-decl.c++ - set: data-structures-union-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.union.c++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.union.c++ - set: data-structures-union-definition-after-identifier - - include: identifiers - - match: '(?=[^\w\s])' - set: data-structures-union-definition-after-identifier - - match: '(?=[{])' - set: data-structures-union-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-identifier: - - meta_content_scope: meta.union.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - # Unions don't support base classes - - include: angle-brackets - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.union.c++ meta.block.c++ - - match: '\}' - scope: meta.union.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - match: '(?=;)' - pop: true - - data-structures-concept-definition: - - meta_content_scope: meta.concept.c++ - - include: data-structures-definition-common-begin - - match: '({{identifier}})\s+(=)' - captures: - 1: entity.name.concept.c++ - 2: keyword.operator.assignment.c++ - set: - - meta_content_scope: meta.concept.c++ meta.constraint.c++ - - include: constraint - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - include: preprocessor-workaround-eat-macro-before-identifier - - data-structures-definition-common-end: - - include: angle-brackets - - match: \bfinal\b - scope: storage.modifier.c++ - - match: ':' - scope: punctuation.separator.c++ - push: - - include: comments - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - match: '\b(virtual|{{visibility_modifiers}})\b' - scope: storage.modifier.c++ - - match: (?={{path_lookahead}}) - push: - - meta_scope: entity.other.inherited-class.c++ - - include: identifiers - - match: '' - pop: true - - include: angle-brackets - - match: ',' - scope: punctuation.separator.c++ - - match: (?=\{|;) - pop: true - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?=\btemplate\b)' - push: - - include: template + scope: punctuation.section.group.begin.cpp + push: [pop-twice, function.tail, function.params] - match: (?=\S) - set: data-structures-modifier - - include: using-namespace - - include: typedef - - include: using-alias - - match: \b({{visibility_modifiers}})\s*(:)(?!:) - captures: - 1: storage.modifier.c++ - 2: punctuation.section.class.c++ - - match: '^\s*(?=(?:~?\w+|::))' - push: data-structures-modifier - - include: expressions-minus-generic-type - - data-structures-modifier-friend: - - match: (?=;) - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_scope: meta.block.c++ - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - include: expressions-minus-function-call - - data-structures-modifier: - - match: '\bfriend\b' - scope: storage.modifier.c++ - push: - - include: comments - - match: '\b({{before_tag}})\b' - scope: keyword.declaration.c++ - set: data-structures-modifier-friend - - match: '(?=\S)(?=[^;]+;)' - set: data-structures-modifier-friend - - match: '(?=\S)' - pop: true - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '\bstatic_assert(?=\s*\()' - scope: meta.static-assert.c++ keyword.operator.word.c++ - push: - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\)' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - # Destructor - - match: '(?:{{identifier}}\s*(::)\s*)?~{{identifier}}(?=\s*(\(|$))' - scope: meta.method.destructor.c++ entity.name.function.destructor.c++ - captures: - 1: punctuation.accessor.c++ - set: method-definition-params - # It's a macro, not a constructor if there is no type in the first param - - match: '({{identifier}})\s*(\()(?=\s*(?!void){{identifier}}\s*[),])' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - # Constructor - - include: preprocessor-workaround-eat-macro-before-identifier - - match: '((?!{{before_tag}}|template){{identifier}})(?=\s*\()' - scope: meta.method.constructor.c++ entity.name.function.constructor.c++ - set: method-definition-params - # Long form constructor - - match: '({{identifier}}\s*(::)\s*{{identifier}})(?=\s*\()' - captures: - 1: meta.method.constructor.c++ entity.name.function.constructor.c++ - 2: punctuation.accessor.c++ - push: method-definition-params - - match: '(?=\S)' - set: data-structures-type - - data-structures-type: - - include: comments - - match: \*|& - scope: keyword.operator.c++ - # Cast methods - - match: '(operator)\s+({{identifier}})(?=\s*(\(|$))' - captures: - 1: keyword.control.c++ - 2: meta.method.c++ entity.name.function.c++ - set: method-definition-params - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: data-structures-maybe-method - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.c++ - set: - - include: identifiers - - match: '' - set: data-structures-maybe-method - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: variables - - include: constants - - include: identifiers - - match: (?=[&*]) - set: data-structures-maybe-method - - match: (?=\W) - pop: true - - data-structures-maybe-method: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.c++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # Operator overloading - - match: '{{operator_method_name}}(?=\s*(\(|$))' - scope: meta.method.c++ entity.name.function.c++ - set: method-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\()))' - push: - - include: identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}})\s*(\())' - set: [method-definition-params, data-structures-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\())' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?=\S)' - pop: true - - data-structures-function-identifier-generic: - - include: angle-brackets - - match: '(?={{identifier}})' - push: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=<)' - pop: true - - match: '(?=\()' - pop: true - - data-structures-function-identifier: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - method-definition-params: - - meta_content_scope: meta.method.c++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.method.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.method.parameters.c++ meta.group.c++ - - match : \) - scope: punctuation.section.group.end.c++ - set: method-definition-continue - - match: '\bvoid\b' - scope: storage.type.c++ - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: expressions-minus-generic-type - - match: '(?=\S)' - pop: true - - method-definition-continue: - - meta_content_scope: meta.method.c++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.c++ - set: method-definition-trailing-return - - include: function-specifiers - - include: constraint-requires - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '&' - scope: keyword.operator.c++ - - match: \b0\b - scope: meta.number.integer.decimal.c++ constant.numeric.value.c++ - - match: \b(default|delete)\b - scope: storage.modifier.c++ - - match: '(?=:)' - set: - - match: ':' - scope: punctuation.separator.initializer-list.c++ - set: - - meta_scope: meta.method.constructor.initializer-list.c++ - - match: '{{identifier}}' - scope: variable.other.readwrite.member.c++ - push: - - match: \( - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.group.c++ - - match: \) - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: \{ - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.group.c++ - - match: \} - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - include: comments - - match: (?=\{|;) - set: method-definition-continue - - include: expressions - - match: '(?=\{)' - set: method-definition-body - - match: '(?=\S)' - pop: true - - method-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: method-definition-body - - include: function-specifiers - - include: function-trailing-return-type - - method-definition-body: - - meta_content_scope: meta.method.c++ meta.block.c++ - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.method.c++ meta.block.c++ - - match: '\}' - scope: meta.method.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - include: preprocessor-practical-workarounds - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.c++ - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.c++ - pop: true - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*(endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0+))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*[1-9]+[\d]*))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: meta.number.integer.decimal.c++ constant.numeric.value.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements + fail: try-template + + call: + - match: \b({{std_funcs}})\s*(\() + captures: + 1: variable.function.c support.function.std.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b({{identifier}})\s*(\() + captures: + 1: variable.function.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b(?={{identifier}}\s*($|<)) + branch_point: not-call + branch: [call.not-call, call.multi-line] + call.multi-line: + - meta_prepend: true + - include: template + + expression-identifiers: + - meta_append: true + - include: punctuation.qualifier + - include: template + + type: + - meta_append: true + - match: \bnamespace\b + scope: keyword.declaration.namesace.cpp + branch_point: namespace + branch: [type.namespace, pop-immediately] + - match: \b(using)\s+(namespace)\b + captures: + 1: keyword.declaration.cpp + 2: keyword.declaration.cpp + push: type.using-namespace + - match: \busing\b + scope: keyword.declaration.cpp + push: type.using + type.namespace: + - meta_scope: meta.namespace.cpp + - match: (?={{qualified}}) + push: + - meta_scope: entity.name.namespace.cpp + - include: qualified-ident + - include: else-pop - match: \{ - scope: punctuation.section.block.begin.c++ - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{path_lookahead}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.c++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - 2: punctuation.accessor.c++ - - match: '(?:(::)\s*)?{{identifier}}' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: preprocessor-if-branch-function-call-arguments - - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match : \) - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: \) - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.c++ - pop: true - - match: \} - scope: meta.block.c++ punctuation.section.block.end.c++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.c++ - push: - - match: '\{' - scope: punctuation.section.block.begin.c++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.c++ keyword.control.import.define.c++ - push: - - meta_content_scope: meta.preprocessor.macro.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.c++ - set: - - match: '\(' - scope: punctuation.section.group.begin.c++ - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.c++ - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.c++ meta.group.c++ + scope: punctuation.section.block.begin.cpp + push: [pop-twice, enclosure.block] + - match: (?=\S) + fail: namespace + type.using: + - meta_scope: meta.using.cpp + - meta_content_scope: entity.name.using.cpp + - match: (?={{qualified}}) + push: qualified-ident + - include: else-pop + type.using-namespace: + - meta_scope: meta.using.cpp + - meta_content_scope: entity.name.namespace.cpp + - match: (?={{qualified}}) + push: qualified-ident + - include: else-pop + + qualified-ident: + - match: (::) + scope: punctuation.separator.qualifier.cpp - match: '{{identifier}}' - scope: variable.parameter.c++ - - match: \) - scope: punctuation.section.group.end.c++ - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.c++ - push: - - match: '{{identifier}}' - scope: variable.parameter.c++ - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c++ - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.c++ - captures: - 1: punctuation.definition.comment.c++ - 2: punctuation.definition.comment.c++ - - match: '\S+' - scope: invalid.illegal.unexpected-character.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c++ - - match: (/\*).*(\*/) - scope: comment.block.c++ - captures: - 1: punctuation.definition.comment.c++ - 2: punctuation.definition.comment.c++ - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.c++ - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.c++ - - match: '\}' - scope: punctuation.section.block.end.c++ - # Captures the namespace macro idiom - - match: '\b(namespace)\s+(?={{path_lookahead}}\s*\{)' - scope: meta.namespace.c++ - captures: - 1: keyword.control.c++ - push: - - meta_content_scope: meta.namespace.c++ entity.name.namespace.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - include: expressions - - preprocessor-practical-workarounds: - - include: preprocessor-convention-ignore-uppercase-ident-lines - - include: scope:source.c#preprocessor-convention-ignore-uppercase-calls-without-semicolon - - preprocessor-convention-ignore-uppercase-ident-lines: - - match: ^(\s*{{macro_identifier}})+\s*$ - scope: meta.assumed-macro.c++ - push: - # It's possible that we are dealing with a function return type on its own line, and the - # name of the function is on the subsequent line. - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*\()' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*\()' - set: [function-definition-params, global-function-identifier] - - match: ^ - pop: true + push: qualified-ident.body + - include: else-pop + qualified-ident.body: + - match: (::) + scope: punctuation.separator.qualifier.cpp + pop: 1 + - include: template + - include: else-pop - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.c++ - push: - - meta_scope: meta.preprocessor.diagnostic.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.c++ - - match: ^\s*(#\s*(?:include|include_next|embed|import))\b - captures: - 1: keyword.control.import.include.c++ - push: - - meta_scope: meta.preprocessor.include.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.double.include.c++ - - match: '"' - scope: punctuation.definition.string.end.c++ - pop: true - - match: < - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.other.lt-gt.include.c++ - - match: '>' - scope: punctuation.definition.string.end.c++ - pop: true - - include: preprocessor-practical-workarounds + template: + - match: (?=<([^<]|$)) + branch_point: template + branch: [try-template, template.fail] + try-template: + - meta_scope: meta.template.cpp + - match: < + scope: punctuation.definition.generic.begin.cpp + set: try-template.body + try-template.body: + - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) + fail: template + - match: (?=\&\&\s*[^>]) + fail: template + - match: (>) + scope: punctuation.definition.generic.end.cpp + pop: true + - include: expression + template.fail: + - match: < + scope: keyword.operator.comparison.cpp + - include: pop-immediately + + label: + - match: '({{identifier}})\s*(:)(?!:)' + captures: + 1: entity.name.label.c + 2: punctuation.separator.c + + keyword: + - meta_append: true + - match: \b(export|friend|operator|noexcept)\b + scope: keyword.other.cpp + keyword.type: + - meta_prepend: true + - match: \b(w?char(8|16|32)_t)|wchar_t\b + scope: storage.type.cpp + - match: decltype + scope: keyword.declaration.type.cpp + keyword.storage: + - meta_prepend: true + - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual)\b + scope: storage.modifier.cpp + keyword.control: + - meta_prepend: true + - match: '\b(catch)\s*(\()' + captures: + 1: keyword.control.exception.cpp + 2: punctuation.section.group.begin.cpp + push: function.params + - match: \b(try|catch|finally|throw)\b + scope: keyword.control.exception.cpp + - match: \bco_(wait|yield|return)\b + scope: keyword.control.cpp + + constant: + - meta_prepend: true + - match: \bthis\b + scope: variable.language.cpp + + punctuation: + - meta_prepend: true + - include: punctuation.qualifier + punctuation.qualifier: + - match: (::) + scope: punctuation.separator.qualifier.cpp + + keyword.operator: # needs precedence over the < comparison + - meta_prepend: true + - include: template + operator.bitwise: + - meta_append: true + - match: \b(bit(and|or)|compl)\b + scope: keyword.operator.bitwise.cpp + - match: \bxor(_eq)\b + scope: keyword.operator.bitwise.cpp + operator.logical: + - meta_append: true + - match: \b(and|x?or|not)(_eq)?\b + scope: keyword.operator.logical.cpp + operator.word: + - meta_prepend: true + - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid)\b + scope: keyword.operator.word.cpp + + string: + - meta_prepend: true + - match: (R)(\")([^\s]*)(\() + captures: + 1: storage.type.string.cpp + 2: punctuation.definition.string.begin.cpp + 3: constant.other.placeholder.cpp + 4: constant.other.placeholder.cpp + push: string.raw + string.raw: + - meta_scope: string.quoted.raw.c + - match: (\)\3)(\") + captures: + 1: constant.other.placeholder.cpp + 2: punctuation.definition.string.end.cpp + pop: true +variables: + qualified: (?:::\s*)?(?:{{identifier}}(?:\s*:{0,2}\s*)?)+ From 0dd2e30def499b2af05dd2c2b640975529cbee7f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:45:38 -0600 Subject: [PATCH 35/66] Fix C stuff, update syntax tests --- C++/C.sublime-syntax | 5 ++--- C++/syntax_test_c.c | 5 +++-- Objective-C/syntax_test_objc.m | 20 ++++++++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index d1e14cca98..1cbd155e54 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -246,7 +246,7 @@ contexts: - match: (?={{identifier}}\s*(?![\[,\)]|$)) push: - - match: \s + - match: \b set: function.params.name - include: expression - include: expression @@ -268,7 +268,6 @@ contexts: - meta_scope: meta.function.c - match: ; pop: 1 - - include: gnu-attribute - match: \{ scope: punctuation.section.block.begin set: function.body @@ -761,7 +760,7 @@ contexts: variables: identifier: \b[[:alpha:]_][[:alnum:]_]*\b - likely_macro: \b[:upper:][[:upper:][:digit:]_]+\b + likely_macro: \b[[:upper:]][[:upper:][:digit:]_]+\b bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 26a809520e..06530dc0d6 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -965,7 +965,7 @@ // ^ punctuation.section.group.begin.c // ^^^^^^^^ meta.function.c // ^ punctuation.section.group.end.c -// ^^^^^ constant.other.c +// ^^^^^ storage.modifier.c __declspec(property(get=10, put=10)) void runForever(); // ^^^^^^^^^^ storage.modifier.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c @@ -1127,7 +1127,8 @@ #pragma FOO //^^^^^^^^^^^^^ meta.preprocessor.c //^^^^^^^^^ keyword.control.import.c - + # +// ^ keyword.control.c #embed "file.txt" if_empty(0) //^^^^^^^^ keyword.control.import.c // ^^^^^^^^^^ string.quoted.double.c diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 5689140a89..2b88b534c1 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -548,6 +548,21 @@ int main(int argc, char const* argv[]) { // ^ punctuation.definition.string.end.c // ^ punctuation.section.group.end // ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c @@ -950,7 +965,7 @@ int test() { // ^ punctuation.section.group.begin.c // ^^^^^^^^ meta.function.c // ^ punctuation.section.group.end.c -// ^^^^^ constant.other.c +// ^^^^^ storage.modifier.c __declspec(property(get=10, put=10)) void runForever(); // ^^^^^^^^^^ storage.modifier.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c @@ -1112,7 +1127,8 @@ int main(int argc, char const* argv[]) { #pragma FOO //^^^^^^^^^^^^^ meta.preprocessor.c //^^^^^^^^^ keyword.control.import.c - + # +// ^ keyword.control.c #embed "file.txt" if_empty(0) //^^^^^^^^ keyword.control.import.c // ^^^^^^^^^^ string.quoted.double.c From 57432b48d2dad8fae89b2a3dd5ca9dc9d4481903 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:46:12 -0600 Subject: [PATCH 36/66] Update C++ --- C++/C++.sublime-syntax | 108 +++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 15 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index db5c99838b..9b83587c53 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -57,19 +57,21 @@ contexts: fail: try-template call: - - match: \b({{std_funcs}})\s*(\() - captures: - 1: variable.function.c support.function.std.c - 2: punctuation.section.group.begin.c - push: enclosure.parenthesis - - match: \b({{identifier}})\s*(\() - captures: - 1: variable.function.c - 2: punctuation.section.group.begin.c - push: enclosure.parenthesis - - match: \b(?={{identifier}}\s*($|<)) - branch_point: not-call - branch: [call.not-call, call.multi-line] + - meta_prepend: true + - match: \b(?={{identifier}}\s*<) + branch_point: template-call + branch: [call.template-call, qualified-ident] + call.template-call: + - match: \b{{identifier}}\b + scope: entity.name.function.cpp + set: call.template-call.body + call.template-call.body: + - include: template + - match: \( + scope: punctuation.section.group.begin.cpp + set: enclosure.parenthesis + - match: (?=\S) + fail: template-call call.multi-line: - meta_prepend: true - include: template @@ -80,7 +82,7 @@ contexts: - include: template type: - - meta_append: true + - meta_prepend: true - match: \bnamespace\b scope: keyword.declaration.namesace.cpp branch_point: namespace @@ -93,6 +95,9 @@ contexts: - match: \busing\b scope: keyword.declaration.cpp push: type.using + - match: \bclass\b + scope: keyword.declaration.cpp + push: class type.namespace: - meta_scope: meta.namespace.cpp - match: (?={{qualified}}) @@ -118,6 +123,76 @@ contexts: push: qualified-ident - include: else-pop + class: + - match: ({{identifier}})(?=\s*;) + scope: entity.name.class.forward-declare.cpp + pop: 1 + - match: (?={{identifier}}) + set: [class.body-start, class.inherit, class.final, class.name, class.likely-macro] + class.likely-macro: + - match: '{{likely_macro}}' + - include: else-pop + class.name: + - match: ({{identifier}}) + scope: entity.name.class.cpp + set: + - include: qualified-ident + - include: else-pop + - include: else-pop + class.final: + - match: \bfinal(?!\s*;)\b + scope: storage.modifier.cpp + - include: else-pop + class.inherit: + - match: ':' + scope: punctuation.separator.inheritance.cpp + push: class.inherit.body + - include: else-pop + class.inherit.body: + - include: keyword.storage + - include: punctuation.comma + - match: (?={{qualified}}) + push: + - meta_scope: entity.other.inherited-class.cpp + - include: qualified-ident + - include: else-pop + class.body-start: + - match: \{ + scope: punctuation.section.block.begin.cpp + set: class.body + - include: else-pop + class.body: + - meta_scope: meta.block.cpp meta.class.cpp + - include: expression-identifiers + - match: ({{identifier}})\s*(\() + captures: + 1: entity.name.function.constructor.cpp + 2: punctuation.section.group.begin.c + push: [constructor.tail, function.params] + - match: (\~{{identifier}})\s*(\() + captures: + 1: entity.name.function.destructor.cpp + 2: punctuation.section.group.begin.c + push: [function.tail, function.params] + - include: function + - include: expression + #- include: enclosure.block + + constructor.tail: + - match: ':' + scope: punctuation.separator.initializer-list.begin.cpp + push: constructor.initializer-list + - include: function.tail + constructor.initializer-list: + - meta_scope: meta.method.constructor.initializer-list.cpp + - match: \b{{identifier}}\b + scope: variable.other.readwrite.member.cpp + - include: template + - match: \( + scope: punctuation.section.group.begin.c + set: enclosure.parenthesis + - include: else-pop + qualified-ident: - match: (::) scope: punctuation.separator.qualifier.cpp @@ -129,7 +204,8 @@ contexts: scope: punctuation.separator.qualifier.cpp pop: 1 - include: template - - include: else-pop + - match: (?=\S) + pop: 2 template: - match: (?=<([^<]|$)) @@ -172,6 +248,8 @@ contexts: scope: keyword.declaration.type.cpp keyword.storage: - meta_prepend: true + - match: '\b(private|protected|public):' + scope: storage.modifier.cpp - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual)\b scope: storage.modifier.cpp keyword.control: From e6e60398f7942ae0a3e052974981bc0c3653058f Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:13:38 -0600 Subject: [PATCH 37/66] Add template, default parameters, change scope to c++ instead of cpp --- C++/C++.sublime-syntax | 249 +++++++++++++++++++++++++++++------------ 1 file changed, 176 insertions(+), 73 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 9b83587c53..2a19124c5a 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -34,28 +34,58 @@ contexts: - include: operator.pointer - match: ({{identifier}})\s*(\() captures: - 1: entity.name.function.c - 2: punctuation.section.group.begin.c + 1: entity.name.function.c++ + 2: punctuation.section.group.begin.c++ push: [function.tail, function.params] - match: (?={{identifier}}\s*<) branch_point: try-template - branch: [function.try-template, function.consume-ident] + branch: [function.try-template, consume-ident] - match: \b{{identifier}}\b - function.consume-ident: - - match: \b{{identifier}}\b - - include: pop-immediately function.try-template: - match: ({{identifier}})(?=\s*<) - scope: entity.name.function.cpp + scope: entity.name.function.c++ set: function.try-template.body function.try-template.body: - include: template - match: \( - scope: punctuation.section.group.begin.cpp + scope: punctuation.section.group.begin.c++ push: [pop-twice, function.tail, function.params] - match: (?=\S) fail: try-template + function.params: # Add default parameters + - meta_content_scope: meta.function.parameters.c meta.group.c++ + - match: \) + scope: punctuation.section.group.end.c++ + pop: 1 + - match: \}|\] # Fallback + scope: invalid.illegal.stray-bracket-end.c++ + pop: 2 + - match: ; # Fallback + scope: invalid.illegal.unexpected-terminator.c++ + pop: 2 + + - match: (?={{identifier}}\s*(?!\s*[\[,\)=]|$)) + push: + - match: \b + set: function.params.name + - include: expression + - include: expression + function.params.name: + - match: (?=[\]\}\);]) # Fallback + pop: 1 + - include: expression-identifiers + - match: ({{identifier}})\s*(\[) + captures: + 1: variable.parameter.c++ + 2: punctuation.section.brackets.begin.c++ + set: enclosure.brackets + - match: ({{identifier}})\s*(?=[,\)=]|$) + captures: + 1: variable.parameter.c++ + pop: 1 + - include: expression + call: - meta_prepend: true - match: \b(?={{identifier}}\s*<) @@ -63,12 +93,12 @@ contexts: branch: [call.template-call, qualified-ident] call.template-call: - match: \b{{identifier}}\b - scope: entity.name.function.cpp + scope: entity.name.function.c++ set: call.template-call.body call.template-call.body: - include: template - match: \( - scope: punctuation.section.group.begin.cpp + scope: punctuation.section.group.begin.c++ set: enclosure.parenthesis - match: (?=\S) fail: template-call @@ -80,72 +110,131 @@ contexts: - meta_append: true - include: punctuation.qualifier - include: template + expression: + - meta_prepend: true + - include: template type: - meta_prepend: true - match: \bnamespace\b - scope: keyword.declaration.namesace.cpp + scope: keyword.declaration.namesace.c++ branch_point: namespace branch: [type.namespace, pop-immediately] - match: \b(using)\s+(namespace)\b captures: - 1: keyword.declaration.cpp - 2: keyword.declaration.cpp + 1: keyword.declaration.c++ + 2: keyword.declaration.c++ push: type.using-namespace - match: \busing\b - scope: keyword.declaration.cpp + scope: keyword.declaration.c++ push: type.using - match: \bclass\b - scope: keyword.declaration.cpp + scope: keyword.declaration.c++ push: class + - match: \btemplate\b + scope: keyword.declaration.c++ + push: type.template type.namespace: - - meta_scope: meta.namespace.cpp + - meta_scope: meta.namespace.c++ - match: (?={{qualified}}) push: - - meta_scope: entity.name.namespace.cpp + - meta_scope: entity.name.namespace.c++ - include: qualified-ident - include: else-pop - match: \{ - scope: punctuation.section.block.begin.cpp + scope: punctuation.section.block.begin.c++ push: [pop-twice, enclosure.block] - match: (?=\S) fail: namespace type.using: - - meta_scope: meta.using.cpp - - meta_content_scope: entity.name.using.cpp + - meta_scope: meta.using.c++ + - meta_content_scope: entity.name.using.c++ - match: (?={{qualified}}) push: qualified-ident - include: else-pop type.using-namespace: - - meta_scope: meta.using.cpp - - meta_content_scope: entity.name.namespace.cpp + - meta_scope: meta.using.c++ + - meta_content_scope: entity.name.namespace.c++ - match: (?={{qualified}}) push: qualified-ident - include: else-pop + type.template: + - meta_scope: meta.template.c++ + - match: \< + scope: punctuation.definition.generic.begin.c++ + push: type.template.body + - include: else-pop + type.template.body: + - match: \> + scope: punctuation.section.generic.end.c++ + pop: 1 + - match: \}|\]|\) # Fallback + scope: invalid.illegal.stray-bracket-end.c++ + pop: 2 + - match: ; # Fallback + scope: invalid.illegal.unexpected-terminator.c++ + pop: 2 + - match: (?={{identifier}}\s*(?!\s*[,\>=]|$)) + push: + - match: \b + set: type.template.name + - include: expression + - match: \b(typename|class)\b + scope: keyword.declaration.type.c++ + - include: expression + type.template.name: + - match: (?=[\]\}\);]) # Fallback + pop: 1 + - match: \b(typename|class)\b + scope: keyword.declaration.type.c++ + - include: expression-identifiers + - match: ({{identifier}})\s*(\[) + captures: + 1: variable.parameter.type.c++ + 2: punctuation.section.brackets.begin.c++ + set: enclosure.brackets + - match: ({{identifier}})\s*(?=[,\>=]|$) + captures: + 1: variable.parameter.type.c++ + pop: 1 + - include: expression class: - match: ({{identifier}})(?=\s*;) - scope: entity.name.class.forward-declare.cpp + scope: entity.name.class.forward-declare.c++ pop: 1 - - match: (?={{identifier}}) - set: [class.body-start, class.inherit, class.final, class.name, class.likely-macro] + - match: (?={{identifier}}|:|\{) + set: [class.body-start, class.inherit, class.final, class.likely-macro, class.name, class.likely-macro] class.likely-macro: - match: '{{likely_macro}}' + - match: '({{identifier}})\s*(\()' + captures: + 1: variable.function.c++ + 2: punctuation.section.group.begin.c++ + push: enclosure.parenthesis - include: else-pop class.name: + - include: punctuation.qualifier + - match: (?={{identifier}}) + branch_point: class-name + branch: [class.name.body, consume-ident] + - include: else-pop + class.name.body: - match: ({{identifier}}) - scope: entity.name.class.cpp - set: - - include: qualified-ident + scope: entity.name.class.c++ + push: + - include: template - include: else-pop + - match: (::) + fail: class-name - include: else-pop class.final: - match: \bfinal(?!\s*;)\b - scope: storage.modifier.cpp + scope: storage.modifier.c++ - include: else-pop class.inherit: - match: ':' - scope: punctuation.separator.inheritance.cpp + scope: punctuation.separator.inheritance.c++ push: class.inherit.body - include: else-pop class.inherit.body: @@ -153,55 +242,56 @@ contexts: - include: punctuation.comma - match: (?={{qualified}}) push: - - meta_scope: entity.other.inherited-class.cpp + - meta_scope: entity.other.inherited-class.c++ - include: qualified-ident - include: else-pop class.body-start: + - meta_scope: meta.class.c++ - match: \{ - scope: punctuation.section.block.begin.cpp + scope: punctuation.section.block.begin.c++ set: class.body - include: else-pop class.body: - - meta_scope: meta.block.cpp meta.class.cpp + - meta_scope: meta.block.c++ meta.class.c++ - include: expression-identifiers - match: ({{identifier}})\s*(\() captures: - 1: entity.name.function.constructor.cpp - 2: punctuation.section.group.begin.c + 1: entity.name.function.constructor.c++ + 2: punctuation.section.group.begin.c++ push: [constructor.tail, function.params] - match: (\~{{identifier}})\s*(\() captures: - 1: entity.name.function.destructor.cpp - 2: punctuation.section.group.begin.c + 1: entity.name.function.destructor.c++ + 2: punctuation.section.group.begin.c++ push: [function.tail, function.params] - include: function - include: expression - #- include: enclosure.block + - include: enclosure.block constructor.tail: - match: ':' - scope: punctuation.separator.initializer-list.begin.cpp + scope: punctuation.separator.initializer-list.begin.c++ push: constructor.initializer-list - include: function.tail constructor.initializer-list: - - meta_scope: meta.method.constructor.initializer-list.cpp + - meta_scope: meta.method.constructor.initializer-list.c++ - match: \b{{identifier}}\b - scope: variable.other.readwrite.member.cpp + scope: variable.other.readwrite.member.c++ - include: template - match: \( - scope: punctuation.section.group.begin.c + scope: punctuation.section.group.begin.c++ set: enclosure.parenthesis - include: else-pop qualified-ident: - match: (::) - scope: punctuation.separator.qualifier.cpp + scope: punctuation.separator.qualifier.c++ - match: '{{identifier}}' push: qualified-ident.body - include: else-pop qualified-ident.body: - match: (::) - scope: punctuation.separator.qualifier.cpp + scope: punctuation.separator.qualifier.c++ pop: 1 - include: template - match: (?=\S) @@ -212,9 +302,9 @@ contexts: branch_point: template branch: [try-template, template.fail] try-template: - - meta_scope: meta.template.cpp + - meta_scope: meta.template.c++ - match: < - scope: punctuation.definition.generic.begin.cpp + scope: punctuation.definition.generic.begin.c++ set: try-template.body try-template.body: - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) @@ -222,59 +312,63 @@ contexts: - match: (?=\&\&\s*[^>]) fail: template - match: (>) - scope: punctuation.definition.generic.end.cpp + scope: punctuation.definition.generic.end.c++ pop: true - include: expression template.fail: - match: < - scope: keyword.operator.comparison.cpp + scope: keyword.operator.comparison.c++ - include: pop-immediately label: - match: '({{identifier}})\s*(:)(?!:)' captures: - 1: entity.name.label.c - 2: punctuation.separator.c + 1: entity.name.label.c++ + 2: punctuation.separator.c++ keyword: - meta_append: true - match: \b(export|friend|operator|noexcept)\b - scope: keyword.other.cpp + scope: keyword.other.c++ keyword.type: - meta_prepend: true - match: \b(w?char(8|16|32)_t)|wchar_t\b - scope: storage.type.cpp + scope: storage.type.c++ - match: decltype - scope: keyword.declaration.type.cpp + scope: keyword.declaration.type.c++ keyword.storage: - meta_prepend: true - match: '\b(private|protected|public):' - scope: storage.modifier.cpp - - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual)\b - scope: storage.modifier.cpp + scope: storage.modifier.c++ + - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual|typename)\b + scope: storage.modifier.c++ keyword.control: - meta_prepend: true - match: '\b(catch)\s*(\()' captures: - 1: keyword.control.exception.cpp - 2: punctuation.section.group.begin.cpp + 1: keyword.control.exception.c++ + 2: punctuation.section.group.begin.c++ push: function.params - match: \b(try|catch|finally|throw)\b - scope: keyword.control.exception.cpp + scope: keyword.control.exception.c++ - match: \bco_(wait|yield|return)\b - scope: keyword.control.cpp + scope: keyword.control.c++ constant: - meta_prepend: true - match: \bthis\b - scope: variable.language.cpp + scope: variable.language.c++ + - match: \bm_[[:alpha:]_$][[:alnum:]_$]*\b + scope: variable.other.readwrite.member.c++ + - match: \bs_[[:alpha:]_$][[:alnum:]_$]*\b + scope: support.constant.c++ punctuation: - meta_prepend: true - include: punctuation.qualifier punctuation.qualifier: - match: (::) - scope: punctuation.separator.qualifier.cpp + scope: punctuation.separator.qualifier.c++ keyword.operator: # needs precedence over the < comparison - meta_prepend: true @@ -282,33 +376,42 @@ contexts: operator.bitwise: - meta_append: true - match: \b(bit(and|or)|compl)\b - scope: keyword.operator.bitwise.cpp + scope: keyword.operator.bitwise.c++ - match: \bxor(_eq)\b - scope: keyword.operator.bitwise.cpp + scope: keyword.operator.bitwise.c++ operator.logical: - meta_append: true - match: \b(and|x?or|not)(_eq)?\b - scope: keyword.operator.logical.cpp + scope: keyword.operator.logical.c++ operator.word: - meta_prepend: true - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid)\b - scope: keyword.operator.word.cpp + scope: keyword.operator.word.c++ + operator.variadic: + - meta_prepend: true + - match: '{{identifier}}\.\.\.' + scope: variable.other.member.c++ string: - meta_prepend: true - match: (R)(\")([^\s]*)(\() captures: - 1: storage.type.string.cpp - 2: punctuation.definition.string.begin.cpp - 3: constant.other.placeholder.cpp - 4: constant.other.placeholder.cpp + 1: storage.type.string.c++ + 2: punctuation.definition.string.begin.c++ + 3: constant.other.placeholder.c++ + 4: constant.other.placeholder.c++ push: string.raw string.raw: - - meta_scope: string.quoted.raw.c + - meta_scope: string.quoted.raw.c++ - match: (\)\3)(\") captures: - 1: constant.other.placeholder.cpp - 2: punctuation.definition.string.end.cpp + 1: constant.other.placeholder.c++ + 2: punctuation.definition.string.end.c++ pop: true + + consume-ident: + - match: \b{{identifier}}\b + - include: pop-immediately variables: + identifier: (\b|(?=\$))[[:alpha:]_$][[:alnum:]_$]*(\b|\$) qualified: (?:::\s*)?(?:{{identifier}}(?:\s*:{0,2}\s*)?)+ From 15a2619f3ffb8611800ad44c167bac32e9423c48 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:13:52 -0600 Subject: [PATCH 38/66] Add template <> to keymap --- C++/Default.sublime-keymap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C++/Default.sublime-keymap b/C++/Default.sublime-keymap index 7bf907a606..643310c47f 100644 --- a/C++/Default.sublime-keymap +++ b/C++/Default.sublime-keymap @@ -7,14 +7,14 @@ { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true }, { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, { "keys": ["<"], "command": "insert_snippet", "args": {"contents": "<${0:$SELECTION}>"}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, { "keys": [">"], "command": "move", "args": {"by": "characters", "forward": true}, "context": @@ -24,7 +24,7 @@ { "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true }, { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": @@ -35,7 +35,7 @@ { "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true }, { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true }, - { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & meta.preprocessor.include" } + { "key": "selector", "operator": "equal", "operand": "(source.c | source.c++) & (meta.preprocessor.include | meta.template)" } ] }, ] From 74e39c43f6fb4a2a07e5be960c413929491419a3 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:14:07 -0600 Subject: [PATCH 39/66] Update C and syntax tests --- C++/C.sublime-syntax | 6 +++--- C++/syntax_test_c.c | 4 ++-- Objective-C/syntax_test_objc.m | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 1cbd155e54..14fea3f5d5 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -88,7 +88,7 @@ contexts: - match: ^ pop: 1 preprocessor.include: - - meta_scope: meta.preprocessor.c + - meta_scope: meta.preprocessor.include.c - match: \" scope: punctuation.definition.string.begin.c push: string.double @@ -244,7 +244,7 @@ contexts: scope: invalid.illegal.unexpected-terminator.c pop: 2 - - match: (?={{identifier}}\s*(?![\[,\)]|$)) + - match: (?={{identifier}}\s*(?!\s*[\[,\)]|$)) push: - match: \b set: function.params.name @@ -257,7 +257,7 @@ contexts: - match: ({{identifier}})\s*(\[) captures: 1: variable.parameter.c - 2: punctuation.section.brackets.begin + 2: punctuation.section.brackets.begin.c set: enclosure.brackets - match: ({{identifier}})\s*(?=[,\)]|$) captures: diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 06530dc0d6..3e1b5602a2 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1040,13 +1040,13 @@ ///////////////////////////////////////////// #include -//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c //^^^^^^^^^^ keyword.control.import.c // ^^^^^^^^^^ string.quoted.other.c // ^ punctuation.definition.string.begin.c // ^ punctuation.definition.string.end.c #include_next "file.h" -//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c //^^^^^^^^^^^^^^^ keyword.control.import.c // ^^^^^^^^ string.quoted.double.c // ^ punctuation.definition.string.begin.c diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 2b88b534c1..3a4e89019e 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -1040,13 +1040,13 @@ int main(int argc, char const* argv[]) { ///////////////////////////////////////////// #include -//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c //^^^^^^^^^^ keyword.control.import.c // ^^^^^^^^^^ string.quoted.other.c // ^ punctuation.definition.string.begin.c // ^ punctuation.definition.string.end.c #include_next "file.h" -//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c //^^^^^^^^^^^^^^^ keyword.control.import.c // ^^^^^^^^ string.quoted.double.c // ^ punctuation.definition.string.begin.c @@ -1141,7 +1141,7 @@ int main(int argc, char const* argv[]) { #import -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c //^^^^^ keyword.control.import.objc // ^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.other.c // ^ punctuation.definition.string.begin.c From fbf17e5783ec7dfca088d43be54be14de29f81fe Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:16:03 -0600 Subject: [PATCH 40/66] Remove accessor test files (already managed in main test file) --- C++/syntax_test_accessor.c | 35 ------------------- C++/syntax_test_accessor.cpp | 68 ------------------------------------ 2 files changed, 103 deletions(-) delete mode 100644 C++/syntax_test_accessor.c delete mode 100644 C++/syntax_test_accessor.cpp diff --git a/C++/syntax_test_accessor.c b/C++/syntax_test_accessor.c deleted file mode 100644 index df99affa0b..0000000000 --- a/C++/syntax_test_accessor.c +++ /dev/null @@ -1,35 +0,0 @@ -// SYNTAX TEST "Packages/C++/C.sublime-syntax" - -typedef struct _X -{ - int a; - int b; -} X; - -int main() -{ - X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - X x; - x.. -// ^^ invalid.illegal - punctuation.accessor -} - -int main() -{ - X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - X* x = malloc(sizeof(X)); - x-> -// ^^ punctuation.accessor -} diff --git a/C++/syntax_test_accessor.cpp b/C++/syntax_test_accessor.cpp deleted file mode 100644 index e20a7bb04d..0000000000 --- a/C++/syntax_test_accessor.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// SYNTAX TEST "Packages/C++/C++.sublime-syntax" - -namespace N { - -class X -{ - public: - int a; - int b; -}; - -class Y : public X -{ - public: - int c; -} - -} // namespace N - -int main() -{ - N:: -// ^^ punctuation.accessor -} - -int main() -{ - N::X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - N::X x; - x.. -// ^^ - punctuation.accessor -} - -int main() -{ - N::X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - N::X* x = new X(); - x-> -// ^^ punctuation.accessor -} - -int main() -{ - N::Y y; - y.X:: -// ^ punctuation.accessor -// ^^ punctuation.accessor -} - -int main() -{ - N::Y* y = new Y(); - y->X:: -// ^^ punctuation.accessor -// ^^ punctuation.accessor -} From 51c67ae9e2e8cdff2ec63832aa3b1321c3bcb7e3 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:25:59 -0600 Subject: [PATCH 41/66] Fix #2334 --- C++/C.sublime-syntax | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 14fea3f5d5..a75a64865c 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -318,6 +318,8 @@ contexts: pop: 1 - match: ; # Fallback pop: 1 + - match: (?=\)) # Macro fallback + pop: 1 - include: expression type.enum: - meta_scope: meta.enum.c From ca0dd1909a748f17545198efe4061fdb98e3c72a Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 18 Feb 2025 16:30:35 -0600 Subject: [PATCH 42/66] add operator functions, remove some jank --- C++/C++.sublime-syntax | 101 +++++++++++++++++++++++++---------------- C++/C.sublime-syntax | 4 +- 2 files changed, 64 insertions(+), 41 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 2a19124c5a..2af577a462 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -30,9 +30,16 @@ first_line_match: |- contexts: function: + - match: \b(operator)\s*([<>=+\-*/%&|^!]=?|[+\-&|<>]{2}|<<=|>>=|<=>|~|->\*?|\(\)|\[\])\s*(\() + captures: + 1: keyword.operator.c++ + 2: entity.name.function.c++ + 3: punctuation.section.group.begin.c++ + push: [function.tail, function.params] + - include: expression-identifiers - include: operator.pointer - - match: ({{identifier}})\s*(\() + - match: (~?{{identifier}})\s*(\() captures: 1: entity.name.function.c++ 2: punctuation.section.group.begin.c++ @@ -86,11 +93,40 @@ contexts: pop: 1 - include: expression + function.tail: + - meta_prepend: true + - match: \b(override|final|noexcept)\b + scope: storage.modifier.c++ + - match: ':' + scope: punctuation.separator.initializer-list.begin.c++ + push: constructor.initializer-list + constructor.initializer-list: + - meta_scope: meta.method.constructor.initializer-list.c++ + - match: \b{{identifier}}\b + scope: variable.other.readwrite.member.c++ + push: constructor.initializer-list.body + - include: punctuation.comma + - include: else-pop + constructor.initializer-list.body: + - include: template + - match: \( + scope: punctuation.section.group.begin.c++ + set: enclosure.parenthesis + - match: \{ + scope: punctuation.section.block.begin.c++ + set: enclosure.block + - include: else-pop + call: - meta_prepend: true - match: \b(?={{identifier}}\s*<) branch_point: template-call branch: [call.template-call, qualified-ident] + - match: (~{{identifier}})\s*(\() + captures: + 1: variable.function.c + 2: punctuation.section.group.begin.c + push: enclosure.parenthesis call.template-call: - match: \b{{identifier}}\b scope: entity.name.function.c++ @@ -144,6 +180,9 @@ contexts: - match: \{ scope: punctuation.section.block.begin.c++ push: [pop-twice, enclosure.block] + - match: = + scope: keyword.operator.assignment.c++ + pop: 1 - match: (?=\S) fail: namespace type.using: @@ -222,9 +261,12 @@ contexts: class.name.body: - match: ({{identifier}}) scope: entity.name.class.c++ - push: + set: - include: template - - include: else-pop + - match: (::) + fail: class-name + - match: (?=\S) + pop: 2 - match: (::) fail: class-name - include: else-pop @@ -253,52 +295,28 @@ contexts: - include: else-pop class.body: - meta_scope: meta.block.c++ meta.class.c++ - - include: expression-identifiers - - match: ({{identifier}})\s*(\() - captures: - 1: entity.name.function.constructor.c++ - 2: punctuation.section.group.begin.c++ - push: [constructor.tail, function.params] - - match: (\~{{identifier}})\s*(\() - captures: - 1: entity.name.function.destructor.c++ - 2: punctuation.section.group.begin.c++ - push: [function.tail, function.params] - include: function - include: expression - include: enclosure.block - constructor.tail: - - match: ':' - scope: punctuation.separator.initializer-list.begin.c++ - push: constructor.initializer-list - - include: function.tail - constructor.initializer-list: - - meta_scope: meta.method.constructor.initializer-list.c++ - - match: \b{{identifier}}\b - scope: variable.other.readwrite.member.c++ - - include: template - - match: \( - scope: punctuation.section.group.begin.c++ - set: enclosure.parenthesis - - include: else-pop - qualified-ident: + - match: \btypename\b + scope: storage.modifier.c++ - match: (::) - scope: punctuation.separator.qualifier.c++ + scope: punctuation.accessor.double-colon.c++ - match: '{{identifier}}' push: qualified-ident.body - include: else-pop qualified-ident.body: - match: (::) - scope: punctuation.separator.qualifier.c++ + scope: punctuation.accessor.double-colon.c++ pop: 1 - include: template - match: (?=\S) pop: 2 template: - - match: (?=<([^<]|$)) + - match: (?=<([^<=]|$)) branch_point: template branch: [try-template, template.fail] try-template: @@ -328,7 +346,7 @@ contexts: keyword: - meta_append: true - - match: \b(export|friend|operator|noexcept)\b + - match: \b(export|friend|operator)\b scope: keyword.other.c++ keyword.type: - meta_prepend: true @@ -338,9 +356,9 @@ contexts: scope: keyword.declaration.type.c++ keyword.storage: - meta_prepend: true - - match: '\b(private|protected|public):' + - match: '\b(private|protected|public)\s*:' scope: storage.modifier.c++ - - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual|typename)\b + - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual|typename|alignas)\b scope: storage.modifier.c++ keyword.control: - meta_prepend: true @@ -360,21 +378,20 @@ contexts: scope: variable.language.c++ - match: \bm_[[:alpha:]_$][[:alnum:]_$]*\b scope: variable.other.readwrite.member.c++ - - match: \bs_[[:alpha:]_$][[:alnum:]_$]*\b - scope: support.constant.c++ punctuation: - meta_prepend: true - include: punctuation.qualifier punctuation.qualifier: - match: (::) - scope: punctuation.separator.qualifier.c++ + scope: punctuation.accessor.double-colon.c++ keyword.operator: # needs precedence over the < comparison - meta_prepend: true - include: template operator.bitwise: - - meta_append: true + - match: \&|\||\^|~(?!{{identifier}}\s*\()|<<|>> + scope: keyword.operator.bitwise.c - match: \b(bit(and|or)|compl)\b scope: keyword.operator.bitwise.c++ - match: \bxor(_eq)\b @@ -385,12 +402,16 @@ contexts: scope: keyword.operator.logical.c++ operator.word: - meta_prepend: true - - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid)\b + - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b scope: keyword.operator.word.c++ operator.variadic: - meta_prepend: true - match: '{{identifier}}\.\.\.' scope: variable.other.member.c++ + operator.comparison: + - meta_prepend: true + - match: <=> + scope: keyword.operator.comparison.c++ string: - meta_prepend: true diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index a75a64865c..5449492156 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -172,7 +172,9 @@ contexts: - include: keyword.control-flow - include: keyword.control - match: (?=^{{identifier}}\s+{{identifier}}\s*\() - set: function + push: + - include: function + - include: else-pop - include: number - include: string - include: type From 24a79e056cbbc920ad4cb3ae7f0d2eac3e21af31 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 21 Feb 2025 13:18:32 -0600 Subject: [PATCH 43/66] Module and lambda --- C++/C++.sublime-syntax | 70 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 2af577a462..d2af29c1d3 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -29,6 +29,10 @@ first_line_match: |- ) contexts: + main: + - meta_prepend: true + - include: module + function: - match: \b(operator)\s*([<>=+\-*/%&|^!]=?|[+\-&|<>]{2}|<<=|>>=|<=>|~|->\*?|\(\)|\[\])\s*(\() captures: @@ -149,7 +153,25 @@ contexts: expression: - meta_prepend: true - include: template + - include: module + - match: \+\s*(\[) + captures: + 1: punctuation.section.brackets.begin.c++ + push: lambda + module: + - match: \bmodule\b + scope: keyword.declaration.module.c++ + push: module.name + - match: \b(import)\s*(?=<) + scope: keyword.other.import.c++ + push: string.angled + module.name: + - meta_content_scope: entity.name.module.c++ + - match: '{{identifier}}' + - match: \. + scope: punctuation.accessor.dot.c++ + - include: else-pop type: - meta_prepend: true - match: \bnamespace\b @@ -238,6 +260,48 @@ contexts: pop: 1 - include: expression + enclosure: + - meta_prepend: true + - match: \[ + branch_point: lambda + scope: punctuation.section.brackets.begin.c++ + branch: [enclosure.brackets, lambda] + enclosure.brackets: + - meta_prepend: true + - match: (\])\s*(<) + fail: lambda + - match: (\])\s*(\() + captures: + 1: punctuation.section.brackets.end.c++ + 2: punctuation.section.group.begin.c++ + set: [lambda.try-not, enclosure.parenthesis] + + lambda.try-not: + - include: expression-identifiers + - match: \{ + fail: lambda + - include: else-pop + lambda: + - meta_scope: meta.lambda.c++ + - match: "" + set: [function.params, lambda.template, lambda.captures] + lambda.captures: + - match: '{{identifier}}' + scope: entity.other.lambda-capture.c++ variable.parameter.c++ + - match: \] + scope: punctuation.section.brackets.end.c++ + pop: 1 + - include: expression + lambda.template: + - match: (?=\<) + push: type.template + - match: \( + scope: punctuation.section.group.begin.c++ + pop: 1 + - include: expression-identifiers + - match: \{ + push: function.body + class: - match: ({{identifier}})(?=\s*;) scope: entity.name.class.forward-declare.c++ @@ -346,7 +410,7 @@ contexts: keyword: - meta_append: true - - match: \b(export|friend|operator)\b + - match: \b(export|friend|operator|import)\b scope: keyword.other.c++ keyword.type: - meta_prepend: true @@ -404,10 +468,6 @@ contexts: - meta_prepend: true - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b scope: keyword.operator.word.c++ - operator.variadic: - - meta_prepend: true - - match: '{{identifier}}\.\.\.' - scope: variable.other.member.c++ operator.comparison: - meta_prepend: true - match: <=> From 059faad6de5e8ab67e61218c3d20dbf0df64fe7e Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sat, 22 Feb 2025 21:45:07 -0600 Subject: [PATCH 44/66] Fix objc issues --- Objective-C/Objective-C.sublime-syntax | 50 +++++++++++++++----------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 2c5dcc04dc..d6b7dcc1fc 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -75,9 +75,10 @@ contexts: property: - match: \( scope: punctuation.section.group.begin.objc - push: property.attrs + set: property.attrs - include: else-pop property.attrs: + - meta_scope: meta.group.objc - match: \) scope: punctuation.section.group.end.objc pop: 1 @@ -128,14 +129,15 @@ contexts: protocol-list: - match: \<(?=({{identifier}}|,|\s|\*)*\>) scope: punctuation.section.scope.begin.objc - push: - - include: expression-identifiers - - include: punctuation.comma - - include: operator.pointer - - meta_scope: meta.protocol-list.objc - - match: \> - scope: punctuation.section.scope.end.objc - pop: 1 + push: protocol-list.body + protocol-list.body: + - meta_scope: meta.protocol-list.objc + - include: expression-identifiers + - include: punctuation.comma + - include: operator.pointer + - match: \> + scope: punctuation.section.scope.end.objc + pop: 1 expression: - meta_prepend: true @@ -154,9 +156,15 @@ contexts: - include: protocol-list block-fn: + - meta_scope: meta.function.block.objc + - match: '' + set: [block-fn.body, block-fn.params] + block-fn.params: - match: \( scope: punctuation.section.group.begin.objc - push: function.params + set: function.params + - include: else-pop + block-fn.body: - match: \{ scope: punctuation.section.block.begin.objc set: enclosure.block @@ -194,7 +202,7 @@ contexts: scope: constant.other.placeholder.objc available: - - match: \b(iOS|macOS|watchOS|tvOS|visionOS)\b + - match: \b(?:iOS|macOS|watchOS|tvOS|visionOS)\b scope: support.constant.platform.objc - match: \b(\d[\d\.]+)\b captures: @@ -210,36 +218,36 @@ contexts: - match: \) scope: punctuation.section.group.end.objc pop: 1 - - match: . + - match: '[^)]+' scope: support.function.objc keyword: - meta_prepend: true - - match: \b(self|super)\b + - match: \b(?:self|super)\b scope: variable.language.objc - - match: \@(property|synthesize|dynamic)\b + - match: \@(?:property|synthesize|dynamic)\b scope: keyword.other.objc - - match: '(@available)\b(\()' + - match: '(@available)\s*(\()' captures: 1: keyword.operator.word.objc 2: punctuation.section.group.begin.objc push: available - - match: '(@selector)\b(\()' + - match: '(@selector)\s*(\()' captures: 1: keyword.operator.word.objc 2: punctuation.section.group.begin.objc push: selector-obj - - match: '@(selector|encode|available)' + - match: '@(?:selector|encode|available)' scope: keyword.operator.word.objc keyword.control: - meta_prepend: true - - match: \@(autoreleasepool|import|synchronized)\b + - match: \@(?:autoreleasepool|import|synchronized)\b scope: keyword.control.objc - - match: \@(try|catch|finally|throw)\b + - match: \@(?:try|catch|finally|throw)\b scope: keyword.control.exception.objc keyword.storage: - meta_prepend: true - - match: \b(nonnull|nullable|_Nullable|_Nonnull|IBOutlet|IBInspectable|__(unused|nonnull|block|weak|strong|autoreleasing|bridge|covariant|contravariant))\b + - match: \b(?:nonnull|nullable|_Nullable|_Nonnull|IBOutlet|IBInspectable|__(?:unused|nonnull|block|weak|strong|autoreleasing|bridge|covariant|contravariant))\b scope: storage.modifier.objc - match: \@(private|public|protected|package|optional|required)\b scope: storage.modifier.objc @@ -249,7 +257,7 @@ contexts: scope: storage.type.objc - match: \@(?:interface|class|implementation|protocol|end)\b scope: keyword.declaration.objc - - match: '(?=\bNS\w+\b)' + - match: '(?=\bNS)' push: ns-identifiers gnu-attribute: From ffb8b9275020a340a35872fba34a6245fde94289 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sat, 22 Feb 2025 21:46:36 -0600 Subject: [PATCH 45/66] Don't consume ; in typedef fallback --- C++/C.sublime-syntax | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 5449492156..e215f8b0f6 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -318,9 +318,7 @@ contexts: captures: 1: entity.name.type.typedef.c pop: 1 - - match: ; # Fallback - pop: 1 - - match: (?=\)) # Macro fallback + - match: (?=\)|;) # Fallback pop: 1 - include: expression type.enum: From 4e0336438242b0622664a308aa6718da8e078a2c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 23 Feb 2025 03:17:53 -0600 Subject: [PATCH 46/66] Add member access highlight --- C++/C.sublime-syntax | 12 +++++++++ C++/syntax_test_c.c | 23 +++++++++------- Objective-C/Objective-C.sublime-syntax | 14 ---------- Objective-C/syntax_test_accessor.m | 35 ------------------------ Objective-C/syntax_test_objc.m | 37 ++++++++++++++------------ 5 files changed, 45 insertions(+), 76 deletions(-) delete mode 100644 Objective-C/syntax_test_accessor.m diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index e215f8b0f6..b74143e4dd 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -448,6 +448,14 @@ contexts: 1: entity.name.label.c 2: punctuation.separator.c + dot-access: + - match: '{{identifier}}' + scope: variable.other.readwrite.member.c + set: + - match: \( + fail: dot-access + - include: else-pop + ###[ BASIC OBJECTS ]############################################################ string: @@ -541,6 +549,10 @@ contexts: - match: \+\+|-- scope: keyword.operator.arithmetic.c operator.accessor: + - match: (\.|\-\>)(?=\s*{{identifier}}) + scope: punctuation.accessor.dot.c++ + branch_point: dot-access + branch: [dot-access, pop-immediately] - match: \.|\-\> scope: punctuation.accessor.c operator.pointer: diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 3e1b5602a2..733fbb33b8 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -260,10 +260,11 @@ // ^ punctuation.section.group.begin // ^ punctuation.section.group.end a,b = b.c; -// ^ punctuation.separator.c -// ^ keyword.operator.assignment.c -// ^ punctuation.accessor.c -// ^ punctuation.terminator.c +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c++ +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// // Strings @@ -877,12 +878,14 @@ // ^^^^^ keyword.declaration.union.c // ^ punctuation.terminator.c myunion.s2.f = 20; -//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c -// ^ punctuation.accessor.c -// ^ punctuation.accessor.c -// ^ keyword.operator.assignment.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c++ +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c++ +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index d6b7dcc1fc..d771a7b7ff 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -151,8 +151,6 @@ contexts: 1: keyword.control.exception.objc 2: punctuation.section.group.begin.objc push: function.params - - match: (?=\b(self)\s*(\.)) - push: self-access - include: protocol-list block-fn: @@ -171,16 +169,6 @@ contexts: - match: (?=\S) fail: block-fn - self-access: - - match: \b(self)\b - captures: - 1: variable.language.objc - - match: \s*(\.)\s*({{identifier}}) - captures: - 1: keyword.operator.accessor.objc - 2: variable.other.readwrite.member.objc - - include: pop-immediately - preprocessor: - meta_prepend: true - match: '{{dir_start}}(import)\b' @@ -313,8 +301,6 @@ contexts: message: - meta_scope: meta.bracketed.objc - - match: (?=\b(self)\s*(\.)) - push: self-access - include: type - include: keyword - include: constant diff --git a/Objective-C/syntax_test_accessor.m b/Objective-C/syntax_test_accessor.m deleted file mode 100644 index 4faa52c7bb..0000000000 --- a/Objective-C/syntax_test_accessor.m +++ /dev/null @@ -1,35 +0,0 @@ -// SYNTAX TEST "Packages/Objective-C/Objective-C.sublime-syntax" - -typedef struct _X -{ - int a; - int b; -} X; - -int main() -{ - X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - X x; - x.. -// ^^ invalid.illegal - punctuation.accessor -} - -int main() -{ - X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - X* x = malloc(sizeof(X)); - x-> -// ^^ punctuation.accessor -} diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 3a4e89019e..28cd86e421 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -260,10 +260,11 @@ // ^ punctuation.section.group.begin // ^ punctuation.section.group.end a,b = b.c; -// ^ punctuation.separator.c -// ^ keyword.operator.assignment.c -// ^ punctuation.accessor.c -// ^ punctuation.terminator.c +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c++ +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// // Strings @@ -877,12 +878,14 @@ int test() { // ^^^^^ keyword.declaration.union.c // ^ punctuation.terminator.c myunion.s2.f = 20; -//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c -// ^ punctuation.accessor.c -// ^ punctuation.accessor.c -// ^ keyword.operator.assignment.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c++ +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c++ +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c @@ -1561,26 +1564,26 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib return [NSClassFromString([NSString stringWithUTF8String:self.j.UTF8String]) someSelector:^(__contravariant NSObject* a, __covariant int const* b) { //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c // ^^^^^^ keyword.control.flow.return.c -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^^^^^^^^^^^^^^^ support.function.cocoa.objc // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c // ^ punctuation.section.group.begin -// ^^^^^^^^^^ meta.bracketed.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^^^^^^ support.class.cocoa.objc // ^^^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc // ^^^^ variable.language.objc -// ^ keyword.operator.accessor.objc -// ^ variable.other.readwrite.member.objc -// ^ keyword.operator.accessor.objc -// ^^^^^^^^^^ variable.other.readwrite.member.objc +// ^ punctuation.accessor.dot.c++ +// ^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c++ +// ^^^^^^^^^^ variable.other.readwrite.member.c // ^ punctuation.section.brackets.end.objc // ^ punctuation.section.group.end // ^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^ keyword.operator.bitwise.objc +// ^ meta.function.block.objc keyword.operator.bitwise.objc // ^ punctuation.section.group.begin.objc // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c // ^^^^^^^^^^^^^^^ storage.modifier.objc From 1187cc38bad10a090fc54e3633f543a03b9cf561 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 23 Feb 2025 04:06:24 -0600 Subject: [PATCH 47/66] Fixes --- C++/C++.sublime-syntax | 47 +++++++++++++++++++++++++++++++++++------- C++/C.sublime-syntax | 11 +++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index d2af29c1d3..d2f62ca0de 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -104,6 +104,14 @@ contexts: - match: ':' scope: punctuation.separator.initializer-list.begin.c++ push: constructor.initializer-list + - match: \-\> + scope: keyword.operator.arrow.c++ + push: function.tail.return + function.tail.return: + - meta_scope: meta.function.return-type.c++ + - match: (?={) + pop: 1 + - include: expression constructor.initializer-list: - meta_scope: meta.method.constructor.initializer-list.c++ - match: \b{{identifier}}\b @@ -154,6 +162,7 @@ contexts: - meta_prepend: true - include: template - include: module + - include: type - match: \+\s*(\[) captures: 1: punctuation.section.brackets.begin.c++ @@ -166,6 +175,9 @@ contexts: - match: \b(import)\s*(?=<) scope: keyword.other.import.c++ push: string.angled + - match: \bimport\b + scope: keyword.other.import.c++ + push: module.name module.name: - meta_content_scope: entity.name.module.c++ - match: '{{identifier}}' @@ -186,7 +198,7 @@ contexts: - match: \busing\b scope: keyword.declaration.c++ push: type.using - - match: \bclass\b + - match: \b(class|struct)\b scope: keyword.declaration.c++ push: class - match: \btemplate\b @@ -201,7 +213,7 @@ contexts: - include: else-pop - match: \{ scope: punctuation.section.block.begin.c++ - push: [pop-twice, enclosure.block] + push: [pop-twice, enclosure.outer-block] - match: = scope: keyword.operator.assignment.c++ pop: 1 @@ -275,22 +287,36 @@ contexts: 1: punctuation.section.brackets.end.c++ 2: punctuation.section.group.begin.c++ set: [lambda.try-not, enclosure.parenthesis] - + enclosure.outer-block: + - meta_scope: meta.block.c++ + - match: \} + scope: punctuation.section.block.end.c++ + pop: 1 + - include: main lambda.try-not: - include: expression-identifiers + - match: \-\> + fail: lambda - match: \{ fail: lambda - include: else-pop lambda: - meta_scope: meta.lambda.c++ - - match: "" - set: [function.params, lambda.template, lambda.captures] + - match: '[&=](?=\s*[,\]])' + scope: storage.modifier.capture.c++ + - match: (?=\S) + set: [function.tail, function.params, lambda.template, lambda.captures] lambda.captures: - match: '{{identifier}}' scope: entity.other.lambda-capture.c++ variable.parameter.c++ - match: \] scope: punctuation.section.brackets.end.c++ pop: 1 + - match: (?=\=) + push: + - match: (?=[,\]]) + pop: 1 + - include: expression - include: expression lambda.template: - match: (?=\<) @@ -359,9 +385,9 @@ contexts: - include: else-pop class.body: - meta_scope: meta.block.c++ meta.class.c++ - - include: function - - include: expression - - include: enclosure.block + #- include: function + #- include: expression + - include: enclosure.outer-block qualified-ident: - match: \btypename\b @@ -408,6 +434,11 @@ contexts: 1: entity.name.label.c++ 2: punctuation.separator.c++ + dot-access.body: + - meta_prepend: true + - match: \< + fail: dot-access + keyword: - meta_append: true - match: \b(export|friend|operator|import)\b diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index b74143e4dd..73617ff227 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -451,10 +451,11 @@ contexts: dot-access: - match: '{{identifier}}' scope: variable.other.readwrite.member.c - set: - - match: \( - fail: dot-access - - include: else-pop + set: dot-access.body + dot-access.body: + - match: \( + fail: dot-access + - include: else-pop ###[ BASIC OBJECTS ]############################################################ @@ -509,6 +510,7 @@ contexts: scope: constant.other.placeholder.c operator: + - include: operator.variadic - include: operator.accessor - include: operator.assignment - include: operator.arithmetic @@ -517,7 +519,6 @@ contexts: - include: operator.comparison - include: operator.word - include: operator.ternary - - include: operator.variadic - include: operator.increment-decrement operator.assignment: - match: = From 523e230459ba227a3ba8d2f3c20d562dcdf71d67 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 24 Feb 2025 14:22:45 -0600 Subject: [PATCH 48/66] Objective-C++ and bug fixes --- C++/C++.sublime-syntax | 14 +- Objective-C/Objective-C++.sublime-syntax | 2195 +--------------------- Objective-C/Objective-C.sublime-syntax | 16 +- 3 files changed, 36 insertions(+), 2189 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index d2f62ca0de..8130f0021e 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -274,10 +274,7 @@ contexts: enclosure: - meta_prepend: true - - match: \[ - branch_point: lambda - scope: punctuation.section.brackets.begin.c++ - branch: [enclosure.brackets, lambda] + - include: lambda-enclosure enclosure.brackets: - meta_prepend: true - match: (\])\s*(<) @@ -293,6 +290,13 @@ contexts: scope: punctuation.section.block.end.c++ pop: 1 - include: main + + lambda-enclosure: # for ObjC++ + - match: \[ + branch_point: lambda + scope: punctuation.section.brackets.begin.c++ + branch: [enclosure.brackets, lambda] + lambda.try-not: - include: expression-identifiers - match: \-\> @@ -525,5 +529,5 @@ contexts: - match: \b{{identifier}}\b - include: pop-immediately variables: - identifier: (\b|(?=\$))[[:alpha:]_$][[:alnum:]_$]*(\b|\$) + identifier: (?:\b|(?=\$))[[:alpha:]_$][[:alnum:]_$]*(?:\b|\$) qualified: (?:::\s*)?(?:{{identifier}}(?:\s*:{0,2}\s*)?)+ diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index a072f4eebc..4008ef1e96 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -3,6 +3,8 @@ # http://www.sublimetext.com/docs/3/syntax.html name: Objective-C++ scope: source.objc++ +version: 2 +extends: [Packages/Objective-C/Objective-C.sublime-syntax, Packages/C++/C++.sublime-syntax] file_extensions: - mm @@ -14,2186 +16,19 @@ first_line_match: |- ^ \s* // .*? -\*- .*? \bobj(ective-)?(c\+\+|cpp\b) .*? -\*- # editorconfig ) -variables: - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - path_lookahead: '(?:::\s*)?(?:{{identifier}}\s*::\s*)*(?:template\s+)?{{identifier}}' - operator_method_name: '\boperator\s*(?:[-+*/%ˆ&|~!=<>]|[-+*/%^&|=!<>]=|<=>|<<=?|>>=?|&&|\|\||\+\+|--|,|->\*?|\(\)|\[\]|""\s*{{identifier}})' - casts: 'const_cast|dynamic_cast|reinterpret_cast|static_cast' - operator_keywords: 'and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq|noexcept' - coroutine_keywords: co_(?:await|return|yield) - control_keywords: 'break|case|catch|continue|default|do|else|for|goto|if|_Pragma|return|switch|throw|try|while|{{coroutine_keywords}}' - memory_operators: 'new|delete' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum\s+class|enum\s+struct|enum|class' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|export|extern|friend|explicit|virtual|register|thread_local' - type_qualifier: 'const|mutable|typename|volatile' - constant_expression_specifiers: 'consteval|constexpr|constinit' - compiler_directive: 'inline|restrict|__restrict__|__restrict' - visibility_modifiers: 'private|protected|public' - other_keywords: 'typedef|nullptr|{{visibility_modifiers}}|static_assert|sizeof|using|typeid|alignof|alignas|namespace|template' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}|{{constant_expression_specifiers}}' - non_angle_brackets: '(?=<<|<=)' - - regular: '[^(){}&;*^%=<>-]*' - regular_plus: '[^(){}&;*^%=<>-]+' - paren_open: (?:\( - paren_close: '\))?' - generic_open: (?:{{regular_plus}}(?:< - generic_close: '>)?)?' - balance_parentheses: '{{regular}}{{paren_open}}{{regular}}{{paren_close}}{{regular}}' - generic_lookahead: <{{generic_open}}{{generic_open}}{{regular}}{{generic_close}}\s*{{generic_close}}{{balance_parentheses}}> - - data_structures_forward_decl_lookahead: '(\s+{{macro_identifier}})*\s*(:\s*({{path_lookahead}}|{{visibility_modifiers}}|,|\s|<[^;]*>)+)?;' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__|typeid|alignof|alignas|static_assert' - contexts: - main: - - include: preprocessor-global - - include: global - - ## Common context layout - - global: - - include: preprocessor-expressions - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: global-modifier - - include: using-namespace - - include: namespace - - include: keywords-angle-brackets - - match: '(?={{path_lookahead}}\s*<)' - push: global-modifier - - include: objc-structures - - include: global-block-comments - - include: early-expressions - - match: ^\s*\b(extern)(?=\s+"C(\+\+)?") - scope: storage.modifier.objc++ - push: - - include: comments - - include: strings - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_scope: meta.extern-c.objc++ - - match: '^\s*(#\s*ifdef)\s*__cplusplus\s*' - scope: meta.preprocessor.objc++ - captures: - 1: keyword.control.import.objc++ - set: - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: preprocessor-global - - include: global - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: preprocessor-global - - include: global - - match: (?=\S) - set: global-modifier - - match: ^\s*(?=\w) - push: global-modifier - - include: late-expressions - - global-block-comments: - # NOTE: This context overrides `comments` context, which re-uses scopes - # from `source.c#comments`. So keep the trailing `c` for consistency reasons! - - match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n? - scope: comment.block.banner.c - captures: - 1: punctuation.definition.comment.begin.c - 2: meta.toc-list.banner.block.c - 3: punctuation.definition.comment.end.c - # empty block comments - - match: /\*\*+/ - scope: comment.block.empty.c punctuation.definition.comment.c - push: global-block-comment-after - # documentation block comments - - match: (?:/\*!|/\*{2,}) - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-documentation-body - # normal block comments - - match: /\* - scope: punctuation.definition.comment.begin.c - push: - - global-block-comment-after - - scope:source.c#block-comment-body - - global-block-comment-after: - - match: \s*(?=\w) - set: global-modifier - - match: '' - pop: true - - statements: - - include: preprocessor-statements - - include: preprocessor-expressions - - include: scope:source.c#label - - include: expressions - - statements-enum: - - include: comments - - include: preprocessor-statements - - include: scope:source.c#label - - match: '{{identifier}}' - scope: entity.name.constant.objc++ - push: constant-value - - match: ',' - scope: punctuation.separator.objc++ - - constant-value: - - match: (?=[,;}]) - pop: true - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: early-expressions-before-generic-type - - include: generic-type - - include: early-expressions-after-generic-type - - early-expressions-before-generic-type: - - include: comments - - include: case-default - - include: using-namespace - - include: typedef - - include: using-alias - - include: keywords-angle-brackets - - include: keywords-parens - - include: keywords - - include: numbers - # Prevent a '<' from getting scoped as the start of another template - # parameter list, if in reality a less-than-or-equals sign or - # three-way comparison operator is meant. - - match: '<=>?' - scope: keyword.operator.comparison.c - - early-expressions-after-generic-type: - - include: members-arrow - - include: operators - - include: members-dot - - include: strings - - include: parens - - include: block - - include: variables - - include: constants - - match: ',' - scope: punctuation.separator.objc++ - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.objc++ - - include: bracketed-content - - include: brackets - - expressions-minus-generic-type: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions - - expressions-minus-generic-type-function-call: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions-before-function-call - - include: scope:source.c++#identifiers - - match: ';' - scope: punctuation.terminator.objc++ - - late-expressions: - - include: late-expressions-before-function-call - - include: function-call - - include: scope:source.c++#identifiers - - match: ';' - scope: punctuation.terminator.objc++ - - late-expressions-before-function-call: - - include: scope:source.c++#unique-late-expressions - - include: modifiers-parens - - include: modifiers - - include: types - - expressions-minus-function-call: - - include: early-expressions - - include: late-expressions-before-function-call - - include: scope:source.c++#identifiers - - match: ';' - scope: punctuation.terminator.objc++ - - comments: - - include: scope:source.c#comments - - operators: - - include: scope:source.c#operators - - modifiers: - - include: scope:source.objc#unique-modifiers - - include: scope:source.c++#unique-modifiers - - include: scope:source.c#modifiers - - variables: - - include: scope:source.objc#unique-variables - - include: scope:source.c++#unique-variables - - include: scope:source.c#variables - - constants: - - include: scope:source.objc#unique-constants - - match: '(?=\bNS\w+\b)' - push: scope:source.objc#ns-identifiers - - include: scope:source.c++#unique-constants - - include: scope:source.c#constants - - keywords: - - include: scope:source.objc#unique-keywords - - include: scope:source.c++#unique-keywords - - include: scope:source.c#keywords - - types: - - include: scope:source.objc#unique-types - - match: '(?=\bNS\w+\b)' - push: scope:source.objc#ns-identifiers - - include: scope:source.c++#unique-types - - include: types-parens - - include: scope:source.c#types - - strings: - - include: scope:source.objc#unique-strings - - include: scope:source.c++#unique-strings - - include: scope:source.c#strings - - numbers: - - include: scope:source.c++#numbers - - ########################################## - # Directly from Objective-C.sublime-syntax - ########################################## - - bracketed-content: - - match: '(\[)\s*(?={{identifier}}\s+[^\s,])' - captures: - 1: punctuation.section.scope.begin.objc++ - push: - - meta_scope: meta.bracketed.objc++ - - match: '\]' - scope: punctuation.section.scope.end.objc++ - pop: true - - match: \s*(NSPredicate)\s+(predicateWithFormat(:)) - captures: - 1: support.class.cocoa.objc++ - 2: support.function.any-method.objc++ - 3: punctuation.separator.arguments.objc++ - push: - - meta_scope: meta.function-call.predicate.objc++ - - include: scope:source.objc#ns-predicate - - include: expressions - - match: '\s+(\w+)(?=\s*\])' - captures: - 1: support.function.any-method.objc++ - - match: '\s+(\w+(:))' - captures: - 1: support.function.any-method.objc++ - 2: punctuation.separator.arguments.objc++ - push: - - meta_scope: meta.function-call.objc++ - - match: '(?=\])' - pop: true - - match: \b\w+(:) - scope: support.function.any-method.name-of-parameter.objc++ - captures: - 1: punctuation.separator.arguments.objc++ - - include: expressions - - include: expressions - - objc-structures: - - match: '((@)(interface|protocol))(?!.+;)\s+([[:alpha:]_][[:alnum:]_]*)\s*((:)(?:\s*)([[:alpha:]][[:alnum:]]*))?(\s|\n)?' - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - 4: entity.name.type.objc++ - 6: punctuation.definition.entity.other.inherited-class.objc++ - 7: entity.other.inherited-class.objc++ - 8: meta.divider.objc++ - 9: meta.inherited-class.objc++ - push: - - meta_scope: meta.interface-or-protocol.objc++ - - meta_content_scope: meta.scope.interface.objc++ - - match: ((@)end)\b - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - match: '((@)(implementation))\s+([[:alpha:]_][[:alnum:]_]*)\s*(?::\s*([[:alpha:]][[:alnum:]]*))?' - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - 4: entity.name.type.objc++ - 5: entity.other.inherited-class.objc++ - push: - - meta_scope: meta.implementation.objc++ - - meta_content_scope: meta.scope.implementation.objc++ - - match: ((@)end)\b - captures: - 1: storage.type.objc++ - 2: punctuation.definition.storage.type.objc++ - pop: true - - include: preprocessor-objc-structures - - include: objc-structure-body - - objc-structure-body: - - include: scope:source.objc#properties - - include: scope:source.objc#protocol_list - - include: method - - include: expressions - - method: - - match: ^(-|\+)\s* - push: - - meta_scope: meta.function.objc++ - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_scope: meta.block.objc++ - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: (?=@end\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - match: '(?=#|@end|;)' - pop: true - - match: '\(' - scope: meta.return-type.objc++ punctuation.definition.type.objc++ - push: - - meta_scope: meta.return-type.objc++ - - match: (\))\s*(\w+\b) - captures: - 1: punctuation.definition.type.objc++ - 2: entity.name.function.objc++ - pop: true - - include: scope:source.objc#protocol_list - - include: scope:source.objc#protocol_type_qualifier - - include: expressions - - match: \b\w+(?=:) - scope: entity.name.function.name-of-parameter.objc++ - - match: ((:))\s*(\() - captures: - 1: entity.name.function.name-of-parameter.objc++ - 2: punctuation.separator.arguments.objc++ - 3: punctuation.definition.type.objc++ - push: - - meta_scope: meta.argument-type.objc++ - - match: (\))\s*(\w+\b)? - captures: - 1: punctuation.definition.type.objc++ - 2: variable.parameter.function.objc++ - pop: true - - include: scope:source.objc#protocol_list - - include: scope:source.objc#protocol_type_qualifier - - include: expressions - - include: comments - - include: attribute - - match: '(,)\s+(\.\.\.)\s*' - captures: - 1: punctuation.separator.objc++ - 2: keyword.operator.variadic.objc++ - push: - - include: scope:source.c#function-call - - match: '(?=\S)' - pop: true - - ## Preprocessor for objc-structures - - preprocessor-objc-structures: - - include: preprocessor-rule-enabled-objc-structures - - include: preprocessor-rule-disabled-objc-structures - - preprocessor-rule-disabled-objc-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: objc-structure-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-objc-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: objc-structure-body - - ################################## - # Directly from C++.sublime-syntax - ################################## - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.objc++ - push: - - match: (?=[);,]) - pop: true - - match: ':' - scope: punctuation.separator.objc++ - pop: true - - include: expressions - - modifiers-parens: - - match: '\b(alignas)\b\s*(\()' - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - include: attribute - - match: \b(__declspec)(\() - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.objc++ - - match: ',' - scope: punctuation.separator.objc++ - - match: '=' - scope: keyword.operator.assignment.objc++ - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.objc++ - - attribute: - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push : - - meta_scope: meta.attribute.objc++ - - meta_content_scope: meta.group.objc++ - - include: parens - - include: strings - - match: \)\) - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - types-parens: - - match: '\b(decltype)\b\s*(\()' - captures: - 1: keyword.declaration.type.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - keywords-angle-brackets: - - match: \b({{casts}})\b\s* - scope: keyword.operator.word.cast.objc++ - push: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - match: '<' - scope: punctuation.definition.generic.begin.objc++ - push: - - match: '(?=>)' - pop: true - - include: expressions-minus-generic-type-function-call - - keywords-parens: - - match: '\b(alignof|typeid|static_assert|sizeof)\b\s*(\()' - captures: - 1: keyword.operator.word.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - using-namespace: - - match: '\b(using)\s+(namespace)\b' - captures: - 1: keyword.control.objc++ - 2: keyword.control.objc++ - push: - - include: scope:source.c++#identifiers - - match: '' - pop: true - - namespace: - - match: '\b(namespace)\s+(?=({{path_lookahead}})?(?!\s*[;,]))' - scope: meta.namespace.objc++ - captures: - 1: keyword.control.objc++ - push: - - meta_content_scope: meta.namespace.objc++ entity.name.namespace.objc++ - - include: scope:source.c++#identifiers - - match: '' - set: - - meta_scope: meta.namespace.objc++ - - include: comments - - match: '=' - scope: keyword.operator.alias.objc++ - - match: '(?=;)' - pop: true - - match: '\}' - scope: meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.objc++ - push: - - meta_scope: meta.block.objc++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - - include: expressions - - template-common: - # Exit the template scope if we hit some basic invalid characters. This - # helps when a user is in the middle of typing their template types and - # prevents re-highlighting the whole file until the next > is found. - - match: (?=[{};]) - pop: true - - include: expressions - - template: - - match: \btemplate\b - scope: keyword.declaration.template.objc++ - push: - - meta_scope: meta.template.objc++ - # Explicitly include comments here at the top, in order to NOT match the - # \S lookahead in the case of comments. - - include: comments - - match: < - scope: punctuation.definition.generic.begin.objc++ - set: - - meta_content_scope: meta.template.objc++ - - match: '>' - scope: meta.template.objc++ punctuation.definition.generic.end.objc++ - pop: true - - match: \.{3} - scope: keyword.operator.variadic.objc++ - - match: \b(typename|{{before_tag}})\b - scope: keyword.declaration.objc++ - - include: template # include template here for nested templates - - include: template-common - - match: (?=\S) - set: - - meta_content_scope: meta.template.objc++ - - match: \b({{before_tag}})\b - scope: keyword.declaration.objc++ - - include: template-common - - generic-type: - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}}\s*(\(|\{))' - push: - - meta_scope: meta.function-call.objc++ - - match: \btemplate\b - scope: keyword.declaration.template.objc++ - - match: (?:(::)\s*)?({{identifier}})\s*(<) - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - 3: punctuation.definition.generic.begin.objc++ - push: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - include: expressions-minus-generic-type-function-call - - match: (?:(::)\s*)?({{identifier}})\s*(\() - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - 3: punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: (?:(::)\s*)?({{identifier}})\s*(\{) - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - 3: punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\}' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - include: scope:source.c++#identifiers - - include: angle-brackets - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\}' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}})' - push: - - include: scope:source.c++#identifiers - - match: '<' - scope: punctuation.definition.generic.begin.objc++ - set: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - include: expressions-minus-generic-type-function-call - - angle-brackets: - - match: '<(?!<)' - scope: punctuation.definition.generic.begin.objc++ - push: - - match: '>' - scope: punctuation.definition.generic.end.objc++ - pop: true - - include: expressions-minus-generic-type-function-call - - block: - - match: '\{' - scope: punctuation.section.block.begin.objc++ - push: - - meta_scope: meta.block.objc++ - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - function-call: - - match: (?={{path_lookahead}}\s*(\(|\{)) - push: - - meta_scope: meta.function-call.objc++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: punctuation.accessor.double-colon.objc++ - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: variable.function.objc++ - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '\{' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match: '\}' - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - members-inside-function-call: - - meta_content_scope: meta.method-call.objc++ meta.group.objc++ - - match: \) - scope: meta.method-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - members-after-accessor-junction: - # After we've seen an accessor (dot or arrow), this context decides what - # kind of entity we're accessing. - - include: comments - - match: \btemplate\b - scope: meta.method-call.objc++ keyword.declaration.template.objc++ - # Guaranteed to be a template member function call after we match this - set: - - meta_content_scope: meta.method-call.objc++ - - include: comments - - match: '{{identifier}}' - scope: variable.function.member.objc++ - set: - - meta_content_scope: meta.method-call.objc++ - - match: \( - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: members-inside-function-call - - include: comments - - include: angle-brackets - - match: (?=\S) # safety pop - pop: true - - match: (?=\S) # safety pop - pop: true - # Non-templated member function call - - match: (~?{{identifier}})\s*(\() - captures: - 0: meta.method-call.objc++ - 1: variable.function.member.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - set: members-inside-function-call - # Templated member function call - - match: (~?{{identifier}})\s*(?={{generic_lookahead}}) - captures: - 1: variable.function.member.objc++ - set: - - meta_scope: meta.method-call.objc++ - - match: < - scope: punctuation.definition.generic.begin.objc++ - set: - - meta_content_scope: meta.method-call.objc++ - - match: '>' - scope: punctuation.definition.generic.end.objc++ - set: - - meta_content_scope: meta.method-call.objc++ - - include: comments - - match: \( - scope: punctuation.section.group.begin.objc++ - set: members-inside-function-call - - match: (?=\S) # safety pop - pop: true - - include: expressions - # Explicit base-class access - - match: ({{identifier}})\s*(::) - captures: - 1: variable.other.base-class.objc++ - 2: punctuation.accessor.double-colon.objc++ - set: members-after-accessor-junction # reset - # Just a regular member variable - - match: '{{identifier}}' - scope: variable.other.readwrite.member.objc++ - pop: true - - members-dot: - - include: scope:source.c#access-illegal - # No lookahead required because members-dot goes after operators in the - # early-expressions-after-generic-type context. This means triple dots - # (i.e. "..." or "variadic") is attempted first. - - match: \. - scope: punctuation.accessor.dot.objc++ - push: members-after-accessor-junction - - members-arrow: - # This needs to be before operators in the - # early-expressions-after-generic-type context because otherwise the "->" - # from the C language will match. - - match: -> - scope: punctuation.accessor.arrow.objc++ - push: members-after-accessor-junction - - using-alias: - # consume keyword if followed by typename - - match: '\b(using)\b(?=\s+typename\b)' - captures: - 1: keyword.control.objc++ - - match: '\b(using)\b\s+({{identifier}})(?!\s*(<|::))' - captures: - 1: keyword.control.objc++ - 2: entity.name.type.using.objc++ - - typedef: - - match: \btypedef\b - scope: keyword.declaration.type.objc++ - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.objc++ - pop: true - - match: '(?=\b({{before_tag}})\b)' - push: data-structures - - include: expressions-minus-generic-type - - parens: - - match: \( - scope: punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.group.objc++ - - match: \) - scope: punctuation.section.group.end.objc++ - pop: true - - include: expressions - - brackets: + message-enclosure: + - match: "" + enclosure: + - meta_prepend: true + - match: (?=\[(?!\s*{{identifier}}\s*[:\]])) + branch_point: message + branch: [pre-message, pre-lambda] + + pre-message: - match: \[ scope: punctuation.section.brackets.begin.objc++ - push: - - meta_scope: meta.brackets.objc++ - - match: \] - scope: punctuation.section.brackets.end.objc++ - pop: true - - include: expressions - - function-trailing-return-type: - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - - include: scope:source.c++#identifiers - - match: \*|& - scope: keyword.operator.objc++ - - include: function-trailing-return-type-parens - - match: '(?=\S)' - pop: true - - function-trailing-return-type-parens: - - match: \( - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.group.objc++ - - match: \) - scope: punctuation.section.group.end.objc++ - pop: true - - include: function-trailing-return-type - - ## Detection of function and data structure definitions at the global level - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - # Constructors and destructors don't have a type - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*{{identifier}}\s*\()' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.constructor.objc++ - - match: '(?=[^\w\s])' - set: function-definition-params - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?\s*::\s*~{{identifier}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?(~{{identifier}})' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.destructor.objc++ - - match: '(?=[^\w\s])' - set: function-definition-params - # If we see a path ending in :: before a newline, we don't know if it is - # a constructor or destructor, or a long return type, so we are just going - # to treat it like a regular function. Most likely it is a constructor, - # since it doesn't seem most developers would create such a long typename. - - match: '(?={{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*$)' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(::)\s*$' - captures: - 1: punctuation.accessor.double-colon.objc++ - - match: '(?:(::)\s*)?(~?{{identifier}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.objc++ - - match: '(?=[^\w\s])' - set: function-definition-params - - include: scope:source.c++#unique-strings - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \*|& - scope: keyword.operator.objc++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.objc++ - set: - - include: scope:source.c++#identifiers - - match: '' - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: '(?={{path_lookahead}}\s*\()' - set: - - include: function-call - - match: '' - pop: true - - include: variables - - include: constants - - include: scope:source.c++#identifiers - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.objc++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.objc++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Operator overloading - - match: '(?=({{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*)?{{operator_method_name}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.objc++ meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?({{operator_method_name}})(?=\s*\()' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.objc++ - - match: '(?=\s*(\(|$))' - set: function-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\(|$)))' - push: - - include: scope:source.c++#identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*(\(|$))' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\(|$))' - set: [function-definition-params, global-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [function-definition-params, global-function-identifier] - - match: '(?=\S)' - pop: true - - global-function-identifier-generic: - - meta_content_scope: meta.toc-list.full-identifier.objc++ - - include: scope:source.c++#identifier-path-generic - - match: '(?:(::)\s*)?({{identifier}})(?=\s*(<.*>)?\s*\()' - captures: - 1: punctuation.accessor.double-colon.objc++ - 2: entity.name.function.objc++ - - match: '(?=\()' - pop: true - - global-function-identifier: - - meta_content_scope: meta.toc-list.full-identifier.objc++ - - match: '(?:(::)\s*)?({{identifier}})(?!\s*(::))' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: entity.name.function.c++ - - include: scope:source.c++#identifiers - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.objc++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.objc++ meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.function.parameters.objc++ meta.group.objc++ - - match : \) - scope: punctuation.section.group.end.objc++ - set: function-definition-continue - - include: modifiers - - include: types - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.objc++ - - match: '=' - scope: keyword.operator.assignment.objc++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.objc++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.objc++ - set: function-definition-trailing-return - - include: scope:source.c++#function-specifiers - - match: '=' - scope: keyword.operator.assignment.objc++ - - match: '&' - scope: keyword.operator.objc++ - - match: \b0\b - scope: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - - match: \b(default|delete)\b - scope: storage.modifier.objc++ - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: function-definition-body - - include: scope:source.c++#function-specifiers - - include: function-trailing-return-type - - function-definition-body: - - meta_content_scope: meta.function.objc++ meta.block.objc++ - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.function.objc++ meta.block.objc++ - - match: '\}' - scope: meta.function.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Data structures including classes, structs, unions and enums - - data-structures: - - match: '\bclass\b' - scope: keyword.declaration.class.objc++ - set: data-structures-class-definition - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{path_lookahead}}\s+{{path_lookahead}}\s*[=;\[])' - scope: keyword.declaration.objc++ - - match: '\bstruct\b' - scope: keyword.declaration.struct.objc++ - set: data-structures-struct-definition - - match: '\benum(\s+(class|struct))?\b' - scope: keyword.declaration.enum.objc++ - set: data-structures-enum-definition - - match: '\bunion\b' - scope: keyword.declaration.union.objc++ - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - - preprocessor-workaround-eat-macro-before-identifier: - # Handle macros so they aren't matched as the class name - - match: ({{macro_identifier}})(?=\s+~?{{identifier}}) - captures: - 1: meta.assumed-macro.c - - data-structures-class-definition: - - meta_scope: meta.class.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.class.forward-decl.objc++ - set: data-structures-class-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.class.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.class.objc++ - set: data-structures-class-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-class-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-class-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-class-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-class-definition-after-identifier: - - meta_content_scope: meta.class.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.class.objc++ meta.block.objc++ - - match: '\}' - scope: meta.class.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: data-structures-body - - data-structures-struct-definition: - - meta_scope: meta.struct.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.struct.forward-decl.objc++ - set: data-structures-struct-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.struct.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.struct.objc++ - set: data-structures-struct-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-struct-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-struct-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-struct-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-identifier: - - meta_content_scope: meta.struct.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.struct.objc++ meta.block.objc++ - - match: '\}' - scope: meta.struct.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.enum.forward-decl.objc++ - set: data-structures-enum-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.enum.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.enum.objc++ - set: data-structures-enum-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-enum-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-enum-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-enum-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-identifier: - - meta_content_scope: meta.enum.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.enum.objc++ meta.block.objc++ - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: statements-enum - - data-structures-union-definition: - - meta_scope: meta.union.objc++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.union.forward-decl.objc++ - set: data-structures-union-definition-after-identifier - - match: '(?={{path_lookahead}})' - set: - - meta_scope: meta.union.objc++ - - match: '{{identifier}}(?!\s*::)' - scope: entity.name.union.objc++ - set: data-structures-union-definition-after-identifier - - include: scope:source.c++#identifiers - - match: data-structures-union-definition-after-identifier - - match: '(?=[^\w\s])' - set: data-structures-union-definition-after-identifier - - match: '(?=[{])' - set: data-structures-union-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-identifier: - - meta_content_scope: meta.union.objc++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - # Unions don't support base classes - - include: angle-brackets - - match: '\{' - scope: meta.block.objc++ punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.union.objc++ meta.block.objc++ - - match: '\}' - scope: meta.union.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - include: data-structures-body - - match: '(?=;)' - pop: true - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - include: scope:source.c++#preprocessor-workaround-eat-macro-before-identifier - - data-structures-definition-common-end: - - include: angle-brackets - - match: \bfinal\b - scope: storage.modifier.c++ - - match: ':' - scope: punctuation.separator.objc++ - push: - - include: comments - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - match: '\b(virtual|{{visibility_modifiers}})\b' - scope: storage.modifier.objc++ - - match: (?={{path_lookahead}}) - push: - - meta_scope: entity.other.inherited-class.objc++ - - include: scope:source.c++#identifiers - - match: '' - pop: true - - include: angle-brackets - - match: ',' - scope: punctuation.separator.objc++ - - match: (?=\{|;) - pop: true - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: data-structures-modifier - - include: typedef - - match: \b({{visibility_modifiers}})\s*(:)(?!:) - captures: - 1: storage.modifier.objc++ - 2: punctuation.section.class.objc++ - - match: '^\s*(?=(?:~?\w+|::))' - push: data-structures-modifier - - include: preprocessor-expressions - - include: expressions-minus-generic-type - - data-structures-modifier-friend: - - match: (?=;) - pop: true - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_scope: meta.block.objc++ - - match: '\}' - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - include: expressions-minus-function-call - - data-structures-modifier: - - match: '\bfriend\b' - scope: storage.modifier.objc++ - push: - - include: comments - - match: '\b({{before_tag}})\b' - scope: keyword.declaration.objc++ - set: data-structures-modifier-friend - - match: '(?=\S)(?=[^;]+;)' - set: data-structures-modifier-friend - - match: '(?=\S)' - pop: true - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '\bstatic_assert(?=\s*\()' - scope: meta.static-assert.objc++ keyword.operator.word.objc++ - push: - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match: '\)' - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - # Destructor - - match: '(?:{{identifier}}\s*(::)\s*)?~{{identifier}}(?=\s*(\(|$))' - scope: meta.method.destructor.objc++ entity.name.function.destructor.objc++ - captures: - 1: punctuation.accessor.objc++ - set: method-definition-params - # It's a macro, not a constructor if there is no type in the first param - - match: '({{identifier}})\s*(\()(?=\s*(?!void){{identifier}}\s*[),])' - captures: - 1: variable.function.objc++ - 2: meta.group.objc++ punctuation.section.group.begin.objc++ - push: - - meta_scope: meta.function-call.objc++ - - meta_content_scope: meta.group.objc++ - - match: '\)' - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - # Constructor - - include: scope:source.c++#preprocessor-workaround-eat-macro-before-identifier - - match: '((?!{{before_tag}}|template){{identifier}})(?=\s*\()' - scope: meta.method.constructor.objc++ entity.name.function.constructor.objc++ - set: method-definition-params - # Long form constructor - - match: '({{identifier}}\s*(::)\s*{{identifier}})(?=\s*\()' - captures: - 1: meta.method.constructor.objc++ entity.name.function.constructor.objc++ - 2: punctuation.accessor.objc++ - push: method-definition-params - - match: '(?=\S)' - set: data-structures-type - - data-structures-type: - - include: comments - - match: \*|& - scope: keyword.operator.objc++ - # Cast methods - - match: '(operator)\s+({{identifier}})(?=\s*(\(|$))' - captures: - 1: keyword.control.objc++ - 2: meta.method.objc++ entity.name.function.objc++ - set: method-definition-params - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: data-structures-maybe-method - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: keyword.declaration.objc++ - set: - - include: scope:source.c++#identifiers - - match: '' - set: data-structures-maybe-method - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: variables - - include: constants - - include: scope:source.c++#identifiers - - match: (?=[&*]) - set: data-structures-maybe-method - - match: (?=\W) - pop: true - - data-structures-maybe-method: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.objc++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.objc++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # Operator overloading - - match: '{{operator_method_name}}(?=\s*(\(|$))' - scope: meta.method.objc++ entity.name.function.objc++ - set: method-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\()))' - push: - - include: scope:source.c++#identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}})\s*(\())' - set: [method-definition-params, data-structures-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\())' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?=\S)' - pop: true - - data-structures-function-identifier-generic: - - include: angle-brackets - - match: '(?={{identifier}})' - push: - - meta_content_scope: entity.name.function.objc++ - - include: scope:source.c++#identifiers - - match: '(?=<)' - pop: true - - match: '(?=\()' - pop: true - - data-structures-function-identifier: - - meta_content_scope: entity.name.function.objc++ - - include: scope:source.c++#identifiers - - match: '(?=\S)' - pop: true - - method-definition-params: - - meta_content_scope: meta.method.objc++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.method.parameters.objc++ meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.method.parameters.objc++ meta.group.objc++ - - match : \) - scope: punctuation.section.group.end.objc++ - set: method-definition-continue - - match: '\bvoid\b' - scope: storage.type.objc++ - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.objc++ - - match: '=' - scope: keyword.operator.assignment.objc++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: expressions-minus-generic-type - - match: '(?=\S)' - pop: true - - method-definition-continue: - - meta_content_scope: meta.method.objc++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.objc++ - set: method-definition-trailing-return - - include: scope:source.c++#function-specifiers - - match: '=' - scope: keyword.operator.assignment.objc++ - - match: '&' - scope: keyword.operator.objc++ - - match: \b0\b - scope: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - - match: \b(default|delete)\b - scope: storage.modifier.objc++ - - match: '(?=:)' - set: - - match: ':' - scope: punctuation.separator.initializer-list.objc++ - set: - - meta_scope: meta.method.constructor.initializer-list.objc++ - - match: '{{identifier}}' - scope: variable.other.readwrite.member.objc++ - push: - - match: \( - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.group.objc++ - - match: \) - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - match: \{ - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: - - meta_content_scope: meta.group.objc++ - - match: \} - scope: meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - include: comments - - match: (?=\{|;) - set: method-definition-continue - - include: expressions - - match: '(?=\{)' - set: method-definition-body - - match: '(?=\S)' - pop: true - - method-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: method-definition-body - - include: scope:source.c++#function-specifiers - - include: function-trailing-return-type - - method-definition-body: - - meta_content_scope: meta.method.objc++ meta.block.objc++ - - match: '\{' - scope: punctuation.section.block.begin.objc++ - set: - - meta_content_scope: meta.method.objc++ meta.block.objc++ - - match: '\}' - scope: meta.method.objc++ meta.block.objc++ punctuation.section.block.end.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - include: scope:source.c++#preprocessor-practical-workarounds - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc++ - push: - - meta_scope: meta.preprocessor.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.objc++ - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.objc++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.objc++ - pop: true - - match: \} - scope: punctuation.section.block.end.objc++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*(endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.objc++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.objc++ - 2: keyword.control.import.objc++ - 3: meta.number.integer.decimal.objc++ constant.numeric.value.objc++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.else.objc++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.objc++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.objc++ - push: - - meta_scope: meta.preprocessor.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc++ - # Enter a new scope where all elif/elifdef/elifndef/else branches have - # their contexts popped by a subsequent elif/elifdef/elifndef/else/endif. - # This ensures that preprocessor branches don't push multiple meta.block - # scopes on the stack, thus messing up the "global" context's detection - # of functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.objc++ - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{path_lookahead}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.objc++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - scope: variable.function.objc++ - captures: - 1: punctuation.accessor.objc++ - 2: punctuation.accessor.objc++ - - match: '(?:(::)\s*)?{{identifier}}' - scope: variable.function.objc++ - captures: - 1: punctuation.accessor.objc++ - - match: '\(' - scope: meta.group.objc++ punctuation.section.group.begin.objc++ - set: preprocessor-if-branch-function-call-arguments - - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match : \) - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|elifdef|elifndef|else))\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.objc++ meta.group.objc++ - - match: \) - scope: meta.function-call.objc++ meta.group.objc++ punctuation.section.group.end.objc++ - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.objc++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.objc++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.objc++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.objc++ - pop: true - - match: \} - scope: meta.block.objc++ punctuation.section.block.end.objc++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.objc++ - push: - - match: '\{' - scope: punctuation.section.block.begin.objc++ - pop: true - - match: (?=^\s*#\s*(elif|elifdef|elifndef|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.objc++ keyword.control.import.define.objc++ - push: - - meta_content_scope: meta.preprocessor.macro.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.objc++ - set: - - match: '\(' - scope: punctuation.section.group.begin.objc++ - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.objc++ - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.objc++ meta.group.objc++ - - match: '{{identifier}}' - scope: variable.parameter.objc++ - - match: \) - scope: punctuation.section.group.end.objc++ - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.objc++ - push: - - match: '{{identifier}}' - scope: variable.parameter.objc++ - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc++ - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.objc++ - captures: - 1: punctuation.definition.comment.objc++ - 2: punctuation.definition.comment.objc++ - - match: '\S+' - scope: invalid.illegal.unexpected-character.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.objc++ - - match: (/\*).*(\*/) - scope: comment.block.objc++ - captures: - 1: punctuation.definition.comment.objc++ - 2: punctuation.definition.comment.objc++ - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.objc++ - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.objc++ - - match: '\}' - scope: punctuation.section.block.end.objc++ - # Captures the namespace macro idiom - - match: '\b(namespace)\s+(?={{path_lookahead}}\s*\{)' - scope: meta.namespace.objc++ - captures: - 1: keyword.control.objc++ - push: - - meta_content_scope: meta.namespace.objc++ entity.name.namespace.objc++ - - include: scope:source.c++#identifiers - - match: '(?=\S)' - pop: true - - include: expressions - - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|elifdef|elifndef|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.objc++ - push: - - meta_scope: meta.preprocessor.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.objc++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.objc++ keyword.control.import.objc++ - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.objc++ - push: - - meta_scope: meta.preprocessor.diagnostic.objc++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.objc++ - - match: ^\s*(#\s*(?:include|include_next|embed))\b - captures: - 1: keyword.control.import.include.objc++ - push: - - meta_scope: meta.preprocessor.include.objc++ - - include: preprocessor-other-include-common - - match: ^\s*(#\s*import)\b - captures: - 1: keyword.control.import.import.objc++ - push: - - meta_scope: meta.preprocessor.import.objc++ - - include: preprocessor-other-include-common - - include: scope:source.c++#preprocessor-practical-workarounds - - preprocessor-other-include-common: - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.objc++ - push: - - meta_scope: string.quoted.double.include.objc++ - - match: '"' - scope: punctuation.definition.string.end.objc++ - pop: true - - match: < - scope: punctuation.definition.string.begin.objc++ - push: - - meta_scope: string.quoted.other.lt-gt.include.objc++ - - match: ">" - scope: punctuation.definition.string.end.objc++ - pop: true + set: message + pre-lambda: + - include: lambda-enclosure + - include: pop-immediately \ No newline at end of file diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index d771a7b7ff..225f461c77 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -153,6 +153,11 @@ contexts: push: function.params - include: protocol-list + call.not-call: + - meta_prepend: true + - match: '(?={{identifier}}\s*:)' + pop: 1 + block-fn: - meta_scope: meta.function.block.objc - match: '' @@ -284,10 +289,7 @@ contexts: enclosure: - meta_prepend: true - - match: \[(?!\s*{{identifier}}\s*[:\]]) - scope: punctuation.section.brackets.begin - branch_point: message - branch: [message, enclosure.brackets] + - include: message-enclosure - match: '@\{' scope: punctuation.section.mapping.begin push: enclosure.mapping @@ -298,6 +300,12 @@ contexts: pop: 1 - include: expression + message-enclosure: # for ObjC++ + - match: \[(?!\s*{{identifier}}\s*[:\]]) + scope: punctuation.section.brackets.begin + branch_point: message + branch: [message, enclosure.brackets] + message: - meta_scope: meta.bracketed.objc From a540d2e45916a0504ff4b53a3f9ac721761d0ed1 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:30:41 -0600 Subject: [PATCH 49/66] Fix #1438 and simplify function pointer / block --- C++/C.sublime-syntax | 15 ++++++++++++- Objective-C/Objective-C.sublime-syntax | 11 ++++------ .../Symbol List - Methods.tmPreferences | 21 +++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 Objective-C/Symbol List - Methods.tmPreferences diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 73617ff227..0640cdfd6c 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -255,6 +255,12 @@ contexts: function.params.name: - match: (?=[\]\}\);]) # Fallback pop: 1 + - match: '{{fn_pointer}}' + captures: + 1: keyword.operator.c + 2: variable.parameter.c + 3: punctuation.section.group.begin.c + set: function.params - include: expression-identifiers - match: ({{identifier}})\s*(\[) captures: @@ -306,8 +312,14 @@ contexts: scope: keyword.declaration.union.c branch_point: union branch: [type.union, pop-immediately] + + - match: '{{fn_pointer}}' + captures: + 1: keyword.operator.c + 3: punctuation.section.group.begin.c + set: function.params type.typedef: - - match: \(\s*(\*)({{identifier}})\s*\)\s*(\() + - match: '{{fn_pointer}}' captures: 1: keyword.operator.c 2: entity.name.type.typedef.c @@ -776,6 +788,7 @@ contexts: variables: identifier: \b[[:alpha:]_][[:alnum:]_]*\b likely_macro: \b[[:upper:]][[:upper:][:digit:]_]+\b + fn_pointer: \(\s*(\*)({{identifier}})\s*\)\s*(\() bin_suffix: '[2-9a-zA-Z_][[:alnum:]_]*' oct_suffix: '[8-9g-zG-Z_][[:alnum:]_]*' diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 225f461c77..2152782cb9 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -97,7 +97,7 @@ contexts: scope: punctuation.section.group.begin.objc set: enclosure.parenthesis selector: - - meta_scope: meta.function.objc + - meta_scope: meta.function.selector.objc - match: '\b({{identifier}})\s*(\:)\s*(\()' captures: 1: entity.name.function.method.objc @@ -274,12 +274,6 @@ contexts: type: - meta_prepend: true - - match: \(\s*(\^)({{identifier}})?\s*\)\s*(\() - captures: - 1: keyword.operator.objc - 2: entity.name.type.typedef.objc - 3: punctuation.section.group.begin.objc - push: [function.params, pop-immediately] - match: \@(?=\d) scope: constant.numeric.objc - match: (\@class)\s*({{identifier}}) @@ -376,3 +370,6 @@ contexts: - match: \bN\w+\b pop: 1 - include: pop-immediately + +variables: + fn_pointer: \(\s*(\*|\^)({{identifier}})\s*\)\s*(\() diff --git a/Objective-C/Symbol List - Methods.tmPreferences b/Objective-C/Symbol List - Methods.tmPreferences new file mode 100644 index 0000000000..ce71c9a9bd --- /dev/null +++ b/Objective-C/Symbol List - Methods.tmPreferences @@ -0,0 +1,21 @@ + + + + scope + + settings + + showInSymbolList + 1 + showInIndexedSymbolList + 1 + + symbolTransformation + + s/([-+])\s*.+?(?=\w+\s*:)/$1/; + s/:[^:]+?\)\w+\s+(\w+)/:$1/g; + s/\:[^:]+\;/:/; + + + + From da8ed9701edbab32cb71684bab22f706337f751a Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:31:00 -0600 Subject: [PATCH 50/66] Fix meta issue with enclosures, lots of cleanup --- C++/C++.sublime-syntax | 38 ++- C++/C.sublime-syntax | 35 +-- C++/syntax_test_c.c | 141 +++++----- Objective-C/Objective-C.sublime-syntax | 85 +++--- Objective-C/syntax_test_objc.m | 343 +++++++++++++------------ 5 files changed, 334 insertions(+), 308 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 8130f0021e..bce7c0ea93 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -38,7 +38,7 @@ contexts: captures: 1: keyword.operator.c++ 2: entity.name.function.c++ - 3: punctuation.section.group.begin.c++ + 3: meta.group.c++ punctuation.section.group.begin.c++ push: [function.tail, function.params] - include: expression-identifiers @@ -46,7 +46,7 @@ contexts: - match: (~?{{identifier}})\s*(\() captures: 1: entity.name.function.c++ - 2: punctuation.section.group.begin.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ push: [function.tail, function.params] - match: (?={{identifier}}\s*<) branch_point: try-template @@ -59,7 +59,7 @@ contexts: function.try-template.body: - include: template - match: \( - scope: punctuation.section.group.begin.c++ + scope: meta.group.c++ punctuation.section.group.begin.c++ push: [pop-twice, function.tail, function.params] - match: (?=\S) fail: try-template @@ -89,7 +89,7 @@ contexts: - match: ({{identifier}})\s*(\[) captures: 1: variable.parameter.c++ - 2: punctuation.section.brackets.begin.c++ + 2: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ set: enclosure.brackets - match: ({{identifier}})\s*(?=[,\)=]|$) captures: @@ -122,10 +122,10 @@ contexts: constructor.initializer-list.body: - include: template - match: \( - scope: punctuation.section.group.begin.c++ + scope: meta.group.c++ punctuation.section.group.begin.c++ set: enclosure.parenthesis - match: \{ - scope: punctuation.section.block.begin.c++ + scope: meta.block.c++ punctuation.section.block.begin.c++ set: enclosure.block - include: else-pop @@ -146,7 +146,7 @@ contexts: call.template-call.body: - include: template - match: \( - scope: punctuation.section.group.begin.c++ + scope: meta.group.c++ punctuation.section.group.begin.c++ set: enclosure.parenthesis - match: (?=\S) fail: template-call @@ -165,7 +165,7 @@ contexts: - include: type - match: \+\s*(\[) captures: - 1: punctuation.section.brackets.begin.c++ + 1: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ push: lambda module: @@ -212,7 +212,7 @@ contexts: - include: qualified-ident - include: else-pop - match: \{ - scope: punctuation.section.block.begin.c++ + scope: meta.block.c++ punctuation.section.block.begin.c++ push: [pop-twice, enclosure.outer-block] - match: = scope: keyword.operator.assignment.c++ @@ -264,7 +264,7 @@ contexts: - match: ({{identifier}})\s*(\[) captures: 1: variable.parameter.type.c++ - 2: punctuation.section.brackets.begin.c++ + 2: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ set: enclosure.brackets - match: ({{identifier}})\s*(?=[,\>=]|$) captures: @@ -282,19 +282,19 @@ contexts: - match: (\])\s*(\() captures: 1: punctuation.section.brackets.end.c++ - 2: punctuation.section.group.begin.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ set: [lambda.try-not, enclosure.parenthesis] enclosure.outer-block: - - meta_scope: meta.block.c++ + - meta_content_scope: meta.block.c++ - match: \} - scope: punctuation.section.block.end.c++ + scope: meta.block.c++ punctuation.section.block.end.c++ pop: 1 - include: main lambda-enclosure: # for ObjC++ - match: \[ branch_point: lambda - scope: punctuation.section.brackets.begin.c++ + scope: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ branch: [enclosure.brackets, lambda] lambda.try-not: @@ -326,7 +326,7 @@ contexts: - match: (?=\<) push: type.template - match: \( - scope: punctuation.section.group.begin.c++ + scope: meta.group.c++ punctuation.section.group.begin.c++ pop: 1 - include: expression-identifiers - match: \{ @@ -343,7 +343,7 @@ contexts: - match: '({{identifier}})\s*(\()' captures: 1: variable.function.c++ - 2: punctuation.section.group.begin.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ push: enclosure.parenthesis - include: else-pop class.name: @@ -384,13 +384,11 @@ contexts: class.body-start: - meta_scope: meta.class.c++ - match: \{ - scope: punctuation.section.block.begin.c++ + scope: meta.block.c++ punctuation.section.block.begin.c++ set: class.body - include: else-pop class.body: - meta_scope: meta.block.c++ meta.class.c++ - #- include: function - #- include: expression - include: enclosure.outer-block qualified-ident: @@ -464,7 +462,7 @@ contexts: - match: '\b(catch)\s*(\()' captures: 1: keyword.control.exception.c++ - 2: punctuation.section.group.begin.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ push: function.params - match: \b(try|catch|finally|throw)\b scope: keyword.control.exception.c++ diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 0640cdfd6c..00becde8dc 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -199,12 +199,12 @@ contexts: - match: \b({{std_funcs}})\s*(\() captures: 1: variable.function.c support.function.std.c - 2: punctuation.section.group.begin.c + 2: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis - match: \b({{identifier}})\s*(\() captures: 1: variable.function.c - 2: punctuation.section.group.begin.c + 2: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis - match: \b(?={{identifier}}\s*$) branch_point: not-call @@ -222,7 +222,7 @@ contexts: - match: '\b{{identifier}}\b' scope: variable.function.c - match: \( - scope: punctuation.section.group.begin.c + scope: meta.group.c punctuation.section.group.begin.c set: enclosure.parenthesis function: @@ -265,7 +265,7 @@ contexts: - match: ({{identifier}})\s*(\[) captures: 1: variable.parameter.c - 2: punctuation.section.brackets.begin.c + 2: meta.brackets.square.c punctuation.section.brackets.begin.c set: enclosure.brackets - match: ({{identifier}})\s*(?=[,\)]|$) captures: @@ -375,7 +375,7 @@ contexts: 1: entity.name.struct.c set: - match: \{ - scope: meta.struct.c punctuation.section.block.begin.c + scope: meta.struct.c meta.block.c punctuation.section.block.begin.c set: enclosure.block - match: (?=\S) fail: struct @@ -393,7 +393,7 @@ contexts: 1: entity.name.union.c set: - match: \{ - scope: meta.union.c punctuation.section.block.begin.c + scope: meta.union.c meta.block.c punctuation.section.block.begin.c set: enclosure.block - match: (?=\S) fail: union @@ -402,37 +402,37 @@ contexts: enclosure: - match: \( - scope: punctuation.section.group.begin + scope: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis - match: \[ - scope: punctuation.section.brackets.begin + scope: meta.brackets.square.c punctuation.section.brackets.begin.c push: enclosure.brackets - match: \{ - scope: punctuation.section.block.begin + scope: meta.block.c punctuation.section.block.begin.c push: enclosure.block enclosure.parenthesis: - - meta_scope: meta.group.c + - meta_content_scope: meta.group.c - include: expression - match: \) - scope: punctuation.section.group.end + scope: meta.group.c punctuation.section.group.end.c pop: 1 - match: \}|\] # Fallback scope: invalid.illegal.stray-bracket-end.c pop: 1 enclosure.brackets: - - meta_scope: meta.brackets.square.c + - meta_content_scope: meta.brackets.square.c - include: expression - match: \] - scope: punctuation.section.brackets.end + scope: meta.brackets.square.c punctuation.section.brackets.end.c pop: 1 - match: \)|\} # Fallback scope: invalid.illegal.stray-bracket-end.c pop: 1 enclosure.block: - - meta_scope: meta.block.c + - meta_content_scope: meta.block.c - include: expression - match: \} - scope: punctuation.section.block.end + scope: meta.block.c punctuation.section.block.end.c pop: 1 - match: \)|\] # Fallback scope: invalid.illegal.stray-bracket-end.c @@ -738,7 +738,7 @@ contexts: - match: \b({{declspec_func}})\s*(\() captures: 1: storage.modifier.c - 2: punctuation.section.group.begin.c + 2: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis - match: \b(property)\s*(\() @@ -746,6 +746,7 @@ contexts: 1: storage.modifier.c 2: punctuation.section.group.begin.c push: + - meta_content_scope: meta.group.c - match: \b(get|put)\b scope: variable.parameter.c - include: enclosure.parenthesis @@ -764,7 +765,7 @@ contexts: - match: \b({{attribute_func}})\s*(\() captures: 1: storage.modifier.c - 2: punctuation.section.group.begin.c + 2: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis - match: \)\) scope: punctuation.section.group.end.c diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 733fbb33b8..74a7d5aa45 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -486,38 +486,37 @@ ///////////////////////////////////////////// test(5, 10, 15, 20); -// ^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^^^^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c int v = h(f(5) - g(6)); -// ^^^ storage.type.c -// ^ keyword.operator.assignment.c -// ^^^^^^^^^^^^^^ meta.group.c -// ^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^^^^ meta.group.c -// ^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ keyword.operator.arithmetic.c -// ^^^^ meta.group.c -// ^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c - +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c int main(int argc, char const* argv[]) { // ^^^ storage.type.c @@ -538,17 +537,17 @@ // ^ punctuation.section.group.end.c // ^ meta.function.c meta.block.c punctuation.section.block.begin int out = in("abcdefg"); -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c -// ^^^ storage.type.c -// ^ keyword.operator.assignment.c -// ^^^^^^^^^^^^^ meta.group.c -// ^^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^^ string.quoted.double.c -// ^ punctuation.definition.string.begin.c -// ^ punctuation.definition.string.end.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c printf //^^^^^^^^^^^^ meta.function.c meta.block.c @@ -569,13 +568,13 @@ // ^ punctuation.section.block.end.c int b = main(argc); -// ^^^ storage.type.c -// ^ keyword.operator.assignment.c -// ^^^^^^^^^^ meta.group.c -// ^^^^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c static extern int* // ^^^^^^ storage.modifier.c @@ -790,7 +789,7 @@ // ^^^^^^ keyword.declaration.struct.c // ^ entity.name.struct.c { -// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c +// ^ meta.struct.c meta.block.c punctuation.section.block.begin.c int a1; //^^^^^^^^^^^^^ meta.block.c // ^^^ storage.type.c @@ -816,10 +815,10 @@ // ^ punctuation.terminator.c union MACRO myUnion { -// ^^^^^^^^^^^^^^^^^^^^ meta.union.c -// ^^^^^ keyword.declaration.union.c -// ^^^^^^^ entity.name.union.c -// ^ meta.block.c meta.union.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c struct A { //^^^^^^^^^^^^^^^^ meta.block.c // ^^^^^^^^^ meta.struct.c @@ -891,10 +890,10 @@ // ^ punctuation.section.block.end.c typedef struct { -// ^^^^^^^ keyword.declaration.type.c -// ^^^^^^^ meta.struct.c -// ^^^^^^ keyword.declaration.struct.c -// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ meta.block.c punctuation.section.block.begin.c myCustomType* a; //^^^^^^^^^^^^^^^^^^^^^^ meta.block.c // ^ keyword.operator.arithmetic.c @@ -927,19 +926,19 @@ ///////////////////////////////////////////// __declspec(align(5)) struct Test { -// ^^^^^^^^^^ storage.modifier.c -// ^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ meta.group.c -// ^^^^^ storage.modifier.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.section.group.end.c -// ^^^^^^^^^^^^ meta.struct.c -// ^^^^^^ keyword.declaration.struct.c -// ^^^^ entity.name.struct.c -// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^^^^ entity.name.struct.c +// ^ meta.block.c punctuation.section.block.begin.c int a; //^^^^^^^^^^^^ meta.block.c // ^^^ storage.type.c diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 2152782cb9..3f49b54824 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -22,31 +22,52 @@ contexts: - include: implementation implementation: - - match: ^\s*(@implementation)\s*({{identifier}})\b + - match: ^\s*(@implementation)\b captures: - 1: meta.implementation.objc keyword.declaration.class.objc - 2: meta.implementation.objc entity.name.type.objc - push: [implementation.meta, interface.body] - implementation.meta: - - meta_scope: meta.implementation.objc meta.scope.implementation.objc - - include: pop-immediately + 1: keyword.declaration.class.objc + push: implementation.start + implementation.start: + - meta_scope: meta.implementation.objc + - match: '{{identifier}}' + scope: entity.name.type.objc + push: [pop-twice, interface.body] + - include: else-pop interface: - - match: ^\s*(@interface|@protocol)\s*({{identifier}})\b + - match: ^\s*(@interface)\b + captures: + 1: keyword.declaration.class.objc + push: + - meta_scope: meta.interface.objc + - include: interface.start + - match: ^\s*(@protocol)\b captures: - 1: meta.interface-or-protocol.objc keyword.declaration.class.objc - 2: meta.interface-or-protocol.objc entity.name.type.objc - push: [interface.meta, interface.body, interface.struct, interface.subclass, interface.category] + 1: keyword.declaration.class.objc + push: + - meta_scope: meta.protocol.objc + - include: interface.start + + interface.start: + - match: '{{identifier}}' + scope: entity.name.type.objc + push: + - pop-twice + - interface.body + - interface.struct + - interface.subclass + - interface.category + - include: else-pop interface.meta: - meta_scope: meta.interface-or-protocol.objc meta.scope.interface.objc - include: pop-immediately interface.category: - - clear_scopes: 1 - match: \( - push: enclosure.parenthesis + scope: meta.group.objc punctuation.section.group.begin.objc + set: + - meta_content_scope: meta.group.objc entity.name.type.category.objc + - include: enclosure.parenthesis - include: else-pop interface.subclass: - - clear_scopes: 1 - include: protocol-list - match: ':' scope: punctuation.separator.objc @@ -54,7 +75,7 @@ contexts: - include: else-pop interface.struct: - match: \{ - scope: punctuation.section.block.begin.objc + scope: meta.block.objc punctuation.section.block.begin.objc set: enclosure.block - include: else-pop interface.body: @@ -94,7 +115,7 @@ contexts: selector.return: - match: \( - scope: punctuation.section.group.begin.objc + scope: meta.group.objc punctuation.section.group.begin.objc set: enclosure.parenthesis selector: - meta_scope: meta.function.selector.objc @@ -102,7 +123,7 @@ contexts: captures: 1: entity.name.function.method.objc 2: punctuation.separator.arguments.objc - 3: punctuation.section.group.begin.objc + 3: meta.group.objc punctuation.section.group.begin.objc push: [selector.param, enclosure.parenthesis] - match: \b({{identifier}})\s*(\:) captures: @@ -117,7 +138,7 @@ contexts: scope: punctuation.terminator.objc pop: 1 - match: \{ - scope: punctuation.section.block.begin.objc + scope: meta.block.objc punctuation.section.block.begin.objc set: enclosure.block - include: operator.variadic - include: expression @@ -169,7 +190,7 @@ contexts: - include: else-pop block-fn.body: - match: \{ - scope: punctuation.section.block.begin.objc + scope: meta.block.objc punctuation.section.block.begin.objc set: enclosure.block - match: (?=\S) fail: block-fn @@ -194,22 +215,24 @@ contexts: - match: '%@' scope: constant.other.placeholder.objc - available: + available.body: + - meta_scope: meta.available.objc + - meta_content_scope: meta.group.objc + - match: \) + scope: meta.group.objc punctuation.section.group.end.objc + pop: 1 - match: \b(?:iOS|macOS|watchOS|tvOS|visionOS)\b scope: support.constant.platform.objc - match: \b(\d[\d\.]+)\b captures: 1: constant.numeric.version.objc - include: expression - - match: \) - scope: punctuation.section.group.end.objc - pop: 1 selector-obj: - meta_scope: meta.selector.objc - - meta_content_scope: meta.selector.method-name.objc + - meta_content_scope: meta.group.objc meta.selector.method-name.objc - match: \) - scope: punctuation.section.group.end.objc + scope: meta.group.objc punctuation.section.group.end.objc pop: 1 - match: '[^)]+' scope: support.function.objc @@ -223,14 +246,14 @@ contexts: - match: '(@available)\s*(\()' captures: 1: keyword.operator.word.objc - 2: punctuation.section.group.begin.objc - push: available + 2: meta.group.objc punctuation.section.group.begin.objc + push: available.body - match: '(@selector)\s*(\()' captures: 1: keyword.operator.word.objc - 2: punctuation.section.group.begin.objc + 2: meta.group.objc punctuation.section.group.begin.objc push: selector-obj - - match: '@(?:selector|encode|available)' + - match: '@(?:selector|encode|defs|available)' scope: keyword.operator.word.objc keyword.control: - meta_prepend: true @@ -260,7 +283,7 @@ contexts: - match: \b(swift_name|objc_runtime_name)\s*(\() captures: 1: storage.modifier.objc - 2: punctuation.section.group.begin.objc + 2: meta.group.objc punctuation.section.group.begin.objc push: enclosure.parenthesis constant: @@ -296,7 +319,7 @@ contexts: message-enclosure: # for ObjC++ - match: \[(?!\s*{{identifier}}\s*[:\]]) - scope: punctuation.section.brackets.begin + scope: meta.brackets.square.objc punctuation.section.brackets.begin branch_point: message branch: [message, enclosure.brackets] diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 28cd86e421..524a60c85d 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -355,11 +355,11 @@ ///////////////////////////////////////////// [a, b, c] -// ^^^^^^^^^ meta.brackets.square.c -// ^ punctuation.section.brackets.begin -// ^ punctuation.separator.c -// ^ punctuation.separator.c -// ^ punctuation.section.brackets.end +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^^^ meta.brackets.square.c +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end.c {1, 2, 3} // ^^^^^^^^^ meta.block.c // ^ punctuation.section.block.begin @@ -486,38 +486,37 @@ const volatile restrict _Atomic _Alignas(4) ///////////////////////////////////////////// test(5, 10, 15, 20); -// ^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^^^^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c int v = h(f(5) - g(6)); -// ^^^ storage.type.c -// ^ keyword.operator.assignment.c -// ^^^^^^^^^^^^^^ meta.group.c -// ^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^^^^ meta.group.c -// ^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ keyword.operator.arithmetic.c -// ^^^^ meta.group.c -// ^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c - +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c int main(int argc, char const* argv[]) { // ^^^ storage.type.c @@ -538,17 +537,17 @@ int main(int argc, char const* argv[]) { // ^ punctuation.section.group.end.c // ^ meta.function.c meta.block.c punctuation.section.block.begin int out = in("abcdefg"); -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c -// ^^^ storage.type.c -// ^ keyword.operator.assignment.c -// ^^^^^^^^^^^^^ meta.group.c -// ^^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^^ string.quoted.double.c -// ^ punctuation.definition.string.begin.c -// ^ punctuation.definition.string.end.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c printf //^^^^^^^^^^^^ meta.function.c meta.block.c @@ -569,13 +568,13 @@ int main(int argc, char const* argv[]) { // ^ punctuation.section.block.end.c int b = main(argc); -// ^^^ storage.type.c -// ^ keyword.operator.assignment.c -// ^^^^^^^^^^ meta.group.c -// ^^^^ variable.function.c -// ^ punctuation.section.group.begin.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c static extern int* // ^^^^^^ storage.modifier.c @@ -790,19 +789,19 @@ void fun(int const a[]) { // ^^^^^^ keyword.declaration.struct.c // ^ entity.name.struct.c { -// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c +// ^ meta.struct.c meta.block.c punctuation.section.block.begin.c int a1; //^^^^^^^^^^^^^ meta.block.c // ^^^ storage.type.c // ^ punctuation.terminator.c char a3[12]; -//^^^^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ storage.type.c -// ^^^^ meta.brackets.square.c -// ^ punctuation.section.brackets.begin -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.brackets.end -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^ meta.brackets.square.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.c +// ^ punctuation.terminator.c void* h5; //^^^^^^^^^^^^^^^ meta.block.c // ^^^^ storage.type.c @@ -816,10 +815,10 @@ void fun(int const a[]) { // ^ punctuation.terminator.c union MACRO myUnion { -// ^^^^^^^^^^^^^^^^^^^^ meta.union.c -// ^^^^^ keyword.declaration.union.c -// ^^^^^^^ entity.name.union.c -// ^ meta.block.c meta.union.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c struct A { //^^^^^^^^^^^^^^^^ meta.block.c // ^^^^^^^^^ meta.struct.c @@ -891,10 +890,10 @@ int test() { // ^ punctuation.section.block.end.c typedef struct { -// ^^^^^^^ keyword.declaration.type.c -// ^^^^^^^ meta.struct.c -// ^^^^^^ keyword.declaration.struct.c -// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^ meta.block.c punctuation.section.block.begin.c myCustomType* a; //^^^^^^^^^^^^^^^^^^^^^^ meta.block.c // ^ keyword.operator.arithmetic.c @@ -927,19 +926,19 @@ int test() { ///////////////////////////////////////////// __declspec(align(5)) struct Test { -// ^^^^^^^^^^ storage.modifier.c -// ^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ meta.group.c -// ^^^^^ storage.modifier.c -// ^ punctuation.section.group.begin.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.section.group.end.c -// ^^^^^^^^^^^^ meta.struct.c -// ^^^^^^ keyword.declaration.struct.c -// ^^^^ entity.name.struct.c -// ^ meta.block.c meta.struct.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ meta.struct.c +// ^^^^^^ keyword.declaration.struct.c +// ^^^^ entity.name.struct.c +// ^ meta.block.c punctuation.section.block.begin.c int a; //^^^^^^^^^^^^ meta.block.c // ^^^ storage.type.c @@ -1143,6 +1142,7 @@ int main(int argc, char const* argv[]) { // ^ punctuation.section.group.end.c + #import //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c //^^^^^ keyword.control.import.objc @@ -1156,9 +1156,9 @@ int main(int argc, char const* argv[]) { typedef SEL(^sample)(IMP _Nullable a, id _Nonnull b, Class nonnull c, BOOL nullable d); //^^^^^ keyword.declaration.type.c // ^^^ storage.type.objc -// ^ keyword.operator.objc -// ^^^^^^ entity.name.type.typedef.objc -// ^ punctuation.section.group.begin.objc +// ^ keyword.operator.c +// ^^^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c // ^^^ storage.type.objc // ^^^^^^^^^ storage.modifier.objc @@ -1176,6 +1176,7 @@ int main(int argc, char const* argv[]) { // ^^^^^^^^ storage.modifier.objc // ^ variable.parameter.c // ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c @class NSWindow; //^^^^ keyword.declaration.class.objc @@ -1183,59 +1184,61 @@ int main(int argc, char const* argv[]) { // ^ punctuation.terminator.c @protocol MyProtocol -//^^^^^^^ meta.interface-or-protocol.objc keyword.declaration.class.objc -// ^^^^^^^^^^ meta.interface-or-protocol.objc entity.name.type.objc +//^^^^^^^ meta.protocol.objc keyword.declaration.class.objc +// ^^^^^^^^^^ meta.protocol.objc entity.name.type.objc @optional -//^^^^^^^ meta.interface-or-protocol.objc storage.modifier.objc +//^^^^^^^ meta.protocol.objc storage.modifier.objc +(instancetype) selector; -//^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.function.objc +//^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc //^^^^^^^^^^^^^ meta.group.c //^^^^^^^^^^^^ storage.type.objc // ^ punctuation.section.group.end // ^^^^^^^^ entity.name.function.method.objc // ^ punctuation.terminator.objc @required -//^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc storage.modifier.objc +//^^^^^^^ meta.protocol.objc storage.modifier.objc -(NSRect) someSelector:(__nonnull id)param withOther:(__unused)param2; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.function.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc //^^^^^^^ meta.group.c //^^^^^^ support.type.cocoa.objc -// ^ punctuation.section.group.end -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.end.c // ^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^ punctuation.section.group.begin.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c // ^^^^^^^^^ storage.modifier.objc // ^^ storage.type.objc -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^^^^^ variable.parameter.objc -// ^^^^^^^^^^^^^^^^^^^^ meta.group.c // ^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^ punctuation.section.group.begin.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c // ^^^^^^^^ storage.modifier.objc -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^^^^^^ variable.parameter.objc // ^ punctuation.terminator.objc @end -//^^ meta.interface-or-protocol.objc meta.scope.interface.objc keyword.declaration.interface.end.objc +//^^ meta.protocol.objc keyword.declaration.interface.end.objc @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NSObject -//^^^^^^^^ meta.interface-or-protocol.objc keyword.declaration.class.objc -// ^^^^^^^ meta.interface-or-protocol.objc entity.name.type.objc -// ^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.end -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^^ keyword.declaration.class.objc +// ^^^^^^^ entity.name.type.objc +// ^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ entity.name.type.category.objc +// ^ meta.group.c punctuation.section.group.end.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c // ^^^^^^^^^^^^^ storage.modifier.c // ^^ punctuation.section.group.begin.c -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c // ^^^^^^^^^^^^^^^^^ storage.modifier.objc -// ^ punctuation.section.group.begin.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^ meta.group.c // ^^^^^^^^^^ string.quoted.double.c // ^ punctuation.definition.string.begin.c // ^ punctuation.definition.string.end.c -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^^ punctuation.section.group.end.c // ^ punctuation.separator.objc // ^^^^^^^^ support.class.cocoa.objc @@ -1244,30 +1247,30 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS // ^ punctuation.section.scope.end.objc { @public int a; -//^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +//^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c // ^^^^^^^ storage.modifier.objc // ^^^ storage.type.c // ^ punctuation.terminator.c @protected NSDictionary* b; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c // ^^^^^^^^^^ storage.modifier.objc // ^^^^^^^^^^^^ support.class.cocoa.objc // ^ keyword.operator.arithmetic.c // ^ punctuation.terminator.c @private char* d; -//^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c // ^^^^^^^^ storage.modifier.objc // ^^^^ storage.type.c // ^ keyword.operator.arithmetic.c // ^ punctuation.terminator.c @package sample e; -//^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c // ^^^^^^^^ storage.modifier.objc // ^ punctuation.terminator.c } @property(readwrite, nonatomic) IBOutlet NSButton* btn; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc //^^^^^^^ keyword.other.objc // ^ punctuation.section.group.begin.objc // ^^^^^^^^^ storage.modifier.objc @@ -1279,7 +1282,7 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS // ^ keyword.operator.arithmetic.c // ^ punctuation.terminator.c @property(readonly, getter=myGetE) IBInspectable sample e; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc //^^^^^^^ keyword.other.objc // ^ punctuation.section.group.begin.objc // ^^^^^^^^ storage.modifier.objc @@ -1292,63 +1295,63 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS // ^ punctuation.terminator.c -(void)someSelector:(void*)a; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface-or-protocol.objc meta.scope.interface.objc meta.function.objc -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.function.selector.objc +//^^^^^ meta.group.c //^^^^ storage.type.c -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^ punctuation.section.group.begin.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^ meta.group.c // ^^^^ storage.type.c // ^ keyword.operator.arithmetic.c -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^ variable.parameter.objc // ^ punctuation.terminator.objc @end -//^^ meta.interface-or-protocol.objc meta.scope.interface.objc keyword.declaration.interface.end.objc +//^^ meta.interface.objc keyword.declaration.interface.end.objc @implementation MyClass -//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc //^^^^^^^^^^^^^ meta.implementation.objc keyword.declaration.class.objc // ^^^^^^^ meta.implementation.objc entity.name.type.objc @synthesize e; -//^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc +//^^^^^^^^^^^^ meta.implementation.objc //^^^^^^^^^ keyword.other.objc // ^ punctuation.terminator.c @dynamic btn; -//^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc +//^^^^^^^^^^^ meta.implementation.objc //^^^^^^ keyword.other.objc // ^ punctuation.terminator.c -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attribute__((objc_direct)) -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.function.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.function.selector.objc //^^^^^^^^^ meta.group.c //^^^^^^^^ storage.type.objc -// ^ punctuation.section.group.end -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.end.c // ^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^ punctuation.section.group.begin.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c // ^^^^^^^^^ storage.modifier.objc // ^^ storage.type.objc -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^^^^^ variable.parameter.objc -// ^^^^^^^^^^^^^^^^^^^^ meta.group.c // ^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc -// ^ punctuation.section.group.begin.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c // ^^^^^^^^ storage.modifier.objc -// ^ punctuation.section.group.end +// ^ punctuation.section.group.end.c // ^^^^^^ variable.parameter.objc // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c // ^^^^^^^^^^^^^ storage.modifier.c // ^^ punctuation.section.group.begin.c // ^^^^^^^^^^^ constant.other.objc // ^^ punctuation.section.group.end.c - { [super someSelector:param withOther:param2]; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^^^ variable.language.objc @@ -1359,14 +1362,14 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.brackets.end.objc // ^ punctuation.terminator.c __block int i = 1; -//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^ storage.modifier.objc // ^^^ storage.type.c // ^ keyword.operator.assignment.c // ^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c __strong NSString* j = [NSString stringWithFormat:@"Hello, World! %@", @314, nil]; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^^ storage.modifier.objc // ^^^^^^^^ support.class.cocoa.objc // ^ keyword.operator.arithmetic.c @@ -1388,7 +1391,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.brackets.end.objc // ^ punctuation.terminator.c __weak NSNumber* k = @'3'; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^ storage.modifier.objc // ^^^^^^^^ support.class.cocoa.objc // ^ keyword.operator.arithmetic.c @@ -1398,7 +1401,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.definition.string.end.c // ^ punctuation.terminator.c __autoreleasing NSView* a = [[NSView alloc] init]; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^^^^^^^^^ storage.modifier.objc // ^^^^^^ support.class.cocoa.objc // ^ keyword.operator.arithmetic.c @@ -1415,7 +1418,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.terminator.c NSArray* f = @[ -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^ support.class.cocoa.objc // ^^^^^^^^^^^ meta.protocol-list.objc // ^ punctuation.section.scope.begin.objc @@ -1424,15 +1427,15 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.scope.end.objc // ^ keyword.operator.arithmetic.c // ^ keyword.operator.assignment.c -// ^ meta.brackets.square.c punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin @314.5, -//^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +//^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c // ^ constant.numeric.objc // ^^^^^ meta.number.float.decimal.c constant.numeric.value.c // ^ punctuation.separator.decimal.c // ^ punctuation.separator.c @0x314LL, -//^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c // ^ constant.numeric.objc // ^^^^^^^ meta.number.integer.hexadecimal.c // ^^ constant.numeric.base.c @@ -1440,31 +1443,31 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^ constant.numeric.suffix.c // ^ punctuation.separator.c @0314e10, -//^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c // ^ constant.numeric.objc // ^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c // ^ punctuation.separator.c @0b1010u -//^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.brackets.square.c +//^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c // ^ constant.numeric.objc // ^^^^^^^ meta.number.integer.binary.c // ^^ constant.numeric.base.c // ^^^^ constant.numeric.value.c // ^ constant.numeric.suffix.c ]; -//^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^ meta.implementation.objc meta.block.c //^^^ meta.brackets.square.c // ^ punctuation.section.brackets.end // ^ punctuation.terminator.c NSDictionary* g = @{ -//^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^^^^^^ support.class.cocoa.objc // ^ keyword.operator.arithmetic.c // ^ keyword.operator.assignment.c // ^^ meta.mapping.objc punctuation.section.mapping.begin (__bridge id)kValue1 : (__bridge NSViewController)kValue2, -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.mapping.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc // ^^^^^^^^^^^^^ meta.group.c // ^ punctuation.section.group.begin // ^^^^^^^^ storage.modifier.objc @@ -1480,7 +1483,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^^^^^^ constant.other.variable.mac-classic.c // ^ punctuation.separator.c (__bridge NSWindow)kValue3 : @YES -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.mapping.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc // ^^^^^^^^^^^^^^^^^^^ meta.group.c // ^ punctuation.section.group.begin // ^^^^^^^^ storage.modifier.objc @@ -1490,13 +1493,13 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ keyword.operator.ternary.c // ^^^^ constant.language.boolean.true.objc }; -//^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^ meta.implementation.objc meta.block.c //^^^ meta.mapping.objc // ^ punctuation.section.mapping.end // ^ punctuation.terminator.c [g respondsToSelector:@selector(doSomething:withSomething:)]; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc @@ -1508,11 +1511,13 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.group.end.objc // ^ punctuation.section.brackets.end.objc if (@available(iOS 10.4, macOS 11.3, *)) { -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^ keyword.control.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.available.objc // ^^^^^^^^^^ keyword.operator.word.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc // ^ punctuation.section.group.begin.objc // ^^^ support.constant.platform.objc // ^^^^ constant.numeric.version.objc @@ -1522,10 +1527,10 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.separator.c // ^ keyword.operator.arithmetic.c // ^ punctuation.section.group.end.objc -// ^ punctuation.section.group.end -// ^ meta.block.c punctuation.section.block.begin +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c [[[g allValues] objectAtIndex: 1] -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc @@ -1539,7 +1544,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.section.brackets.end.objc perform: @encode(int) -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc // ^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc // ^^^^^^^ keyword.operator.word.objc @@ -1548,21 +1553,21 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^^ storage.type.c // ^ punctuation.section.group.end with: @NO -//^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +//^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc // ^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc // ^^^ constant.language.boolean.false.objc ]; -//^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c //^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.end.objc // ^ punctuation.terminator.c } -//^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^ meta.implementation.objc meta.block.c meta.block.c // ^ punctuation.section.block.end return [NSClassFromString([NSString stringWithUTF8String:self.j.UTF8String]) someSelector:^(__contravariant NSObject* a, __covariant int const* b) { -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^ keyword.control.flow.return.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin @@ -1599,11 +1604,11 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.group.end.c // ^ meta.block.c punctuation.section.block.begin.objc @try { -//^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c // ^^^^ keyword.control.exception.objc // ^ meta.block.c punctuation.section.block.begin [Nil message: (a + b) ? @true : @false]; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c // ^^^^^ meta.bracketed.objc // ^ punctuation.section.brackets.begin // ^^^ constant.language.null.objc @@ -1620,7 +1625,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.brackets.end.objc // ^ punctuation.terminator.c } @catch(NSException* exc) { -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c //^^^^^^^ meta.block.c // ^ punctuation.section.block.end // ^^^^^^ keyword.control.exception.objc @@ -1632,31 +1637,31 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^ punctuation.section.group.end.c // ^ meta.block.c punctuation.section.block.begin return NO; -//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c // ^^^^^^ keyword.control.flow.return.c // ^^ constant.language.boolean.false.objc // ^ punctuation.terminator.c } @finally { -//^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c +//^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c //^^^^^^^ meta.block.c // ^ punctuation.section.block.end // ^^^^^^^^ keyword.control.exception.objc // ^ meta.block.c punctuation.section.block.begin return YES; -//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c // ^^^^^^ keyword.control.flow.return.c // ^^^ constant.language.boolean.true.objc // ^ punctuation.terminator.c } -//^^^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c meta.block.c meta.block.c +//^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c // ^ punctuation.section.block.end }]; -//^^^^^ meta.implementation.objc meta.scope.implementation.objc meta.block.c +//^^^^^ meta.implementation.objc meta.block.c //^^^ meta.block.c // ^ punctuation.section.block.end // ^ punctuation.section.brackets.end.objc // ^ punctuation.terminator.c } @end -//^^ meta.implementation.objc meta.scope.implementation.objc keyword.declaration.interface.end.objc -//^^ meta.implementation.objc meta.scope.implementation.objc keyword.declaration.interface.end.objc +//^^ meta.implementation.objc keyword.declaration.interface.end.objc +//^^ meta.implementation.objc keyword.declaration.interface.end.objc From a6a98c31cd978d6f40a5ebe0d8109316fe208ec5 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Mon, 24 Feb 2025 19:32:31 -0600 Subject: [PATCH 51/66] Add concepts and enum class --- C++/C++.sublime-syntax | 51 ++++++++++++++++++++++++++++++++++++++++-- C++/C.sublime-syntax | 10 +++++---- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index bce7c0ea93..728b5cc1f5 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -32,6 +32,7 @@ contexts: main: - meta_prepend: true - include: module + - include: requires-fn function: - match: \b(operator)\s*([<>=+\-*/%&|^!]=?|[+\-&|<>]{2}|<<=|>>=|<=>|~|->\*?|\(\)|\[\])\s*(\() @@ -104,11 +105,21 @@ contexts: - match: ':' scope: punctuation.separator.initializer-list.begin.c++ push: constructor.initializer-list + - match: \brequires\b + scope: storage.modifier.c++ + push: function.tail.requires - match: \-\> scope: keyword.operator.arrow.c++ push: function.tail.return function.tail.return: - meta_scope: meta.function.return-type.c++ + - match: (?=\brequires\b) + pop: 1 + - match: (?={) + pop: 1 + - include: expression + function.tail.requires: + - meta_scope: meta.function.requires.c++ - match: (?={) pop: 1 - include: expression @@ -163,6 +174,7 @@ contexts: - include: template - include: module - include: type + - include: requires-fn - match: \+\s*(\[) captures: 1: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ @@ -204,6 +216,9 @@ contexts: - match: \btemplate\b scope: keyword.declaration.c++ push: type.template + - match: \bconcept\b + scope: keyword.declaration.c++ + push: type.concept type.namespace: - meta_scope: meta.namespace.c++ - match: (?={{qualified}}) @@ -235,7 +250,7 @@ contexts: - meta_scope: meta.template.c++ - match: \< scope: punctuation.definition.generic.begin.c++ - push: type.template.body + push: [type.template.requires, type.template.body] - include: else-pop type.template.body: - match: \> @@ -255,6 +270,11 @@ contexts: - match: \b(typename|class)\b scope: keyword.declaration.type.c++ - include: expression + type.template.requires: + - match: \brequires\b + scope: storage.modifier.c++ + pop: 1 + - include: else-pop type.template.name: - match: (?=[\]\}\);]) # Fallback pop: 1 @@ -271,6 +291,33 @@ contexts: 1: variable.parameter.type.c++ pop: 1 - include: expression + type.concept: + - meta_scope: meta.concept.c++ + - match: '{{identifier}}' + scope: entity.name.concept.c++ + push: type.concept.body + - include: else-pop + type.concept.body: + - include: requires-fn + - include: expression + - match: (?=;|\)|\]|\}) + pop: 1 + + enum-def: + - match: \b(enum)(?:\s*(class))?\b + captures: + 1: keyword.declaration.enum.c + 2: keyword.declaration.class.c++ + branch_point: enum + branch: [type.enum, pop-immediately] + + + requires-fn: + - match: \b(requires)\s*(\()\b + captures: + 1: keyword.operator.word.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: function.params enclosure: - meta_prepend: true @@ -499,7 +546,7 @@ contexts: scope: keyword.operator.logical.c++ operator.word: - meta_prepend: true - - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b + - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept|requires)\b scope: keyword.operator.word.c++ operator.comparison: - meta_prepend: true diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 00becde8dc..e99abf4dd5 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -295,15 +295,17 @@ contexts: - include: constant ###[ SIMPLE STRUCTURES ]############################################################ + enum-def: # for C++ to override + - match: \benum\b + scope: keyword.declaration.enum.c + branch_point: enum + branch: [type.enum, pop-immediately] type: - match: \btypedef\b scope: keyword.declaration.type.c push: type.typedef - - match: \benum\b - scope: keyword.declaration.enum.c - branch_point: enum - branch: [type.enum, pop-immediately] + - include: enum-def - match: \bstruct\b scope: keyword.declaration.struct.c branch_point: struct From 2ade85e4758288b325af2418aa7c0e5f9a7b6c4c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 25 Feb 2025 09:11:24 -0600 Subject: [PATCH 52/66] Adhere closer to stylistic convention --- C++/C++.sublime-syntax | 179 +++++++++++++---------- C++/C.sublime-syntax | 98 +++++++------ Objective-C/Objective-C++.sublime-syntax | 3 +- Objective-C/Objective-C.sublime-syntax | 135 +++++++++-------- 4 files changed, 223 insertions(+), 192 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 728b5cc1f5..4ea0ea2532 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -40,7 +40,9 @@ contexts: 1: keyword.operator.c++ 2: entity.name.function.c++ 3: meta.group.c++ punctuation.section.group.begin.c++ - push: [function.tail, function.params] + push: + - function-tail + - function-params - include: expression-identifiers - include: operator.pointer @@ -48,24 +50,29 @@ contexts: captures: 1: entity.name.function.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ - push: [function.tail, function.params] + push: + - function-tail + - function-params - match: (?={{identifier}}\s*<) - branch_point: try-template - branch: [function.try-template, consume-ident] + branch_point: function-template + branch: [function-template, consume-ident] - match: \b{{identifier}}\b - function.try-template: + function-template: - match: ({{identifier}})(?=\s*<) scope: entity.name.function.c++ - set: function.try-template.body - function.try-template.body: + set: function-template-body + function-template-body: - include: template - match: \( scope: meta.group.c++ punctuation.section.group.begin.c++ - push: [pop-twice, function.tail, function.params] + push: + - pop-twice + - function-tail + - function-params - match: (?=\S) - fail: try-template + fail: function-template - function.params: # Add default parameters + function-params: # Add default parameters - meta_content_scope: meta.function.parameters.c meta.group.c++ - match: \) scope: punctuation.section.group.end.c++ @@ -80,10 +87,10 @@ contexts: - match: (?={{identifier}}\s*(?!\s*[\[,\)=]|$)) push: - match: \b - set: function.params.name + set: function-params-name - include: expression - include: expression - function.params.name: + function-params-name: - match: (?=[\]\}\);]) # Fallback pop: 1 - include: expression-identifiers @@ -98,39 +105,40 @@ contexts: pop: 1 - include: expression - function.tail: + function-tail: - meta_prepend: true - match: \b(override|final|noexcept)\b scope: storage.modifier.c++ - match: ':' scope: punctuation.separator.initializer-list.begin.c++ - push: constructor.initializer-list + push: initializer-list - match: \brequires\b scope: storage.modifier.c++ - push: function.tail.requires + push: function-tail-requires - match: \-\> scope: keyword.operator.arrow.c++ - push: function.tail.return - function.tail.return: + push: function-tail-return + function-tail-return: - meta_scope: meta.function.return-type.c++ - match: (?=\brequires\b) pop: 1 - match: (?={) pop: 1 - include: expression - function.tail.requires: + function-tail-requires: - meta_scope: meta.function.requires.c++ - match: (?={) pop: 1 - include: expression - constructor.initializer-list: - - meta_scope: meta.method.constructor.initializer-list.c++ + + initializer-list: + - meta_scope: meta.method.initializer-list.c++ - match: \b{{identifier}}\b scope: variable.other.readwrite.member.c++ - push: constructor.initializer-list.body + push: initializer-list-body - include: punctuation.comma - include: else-pop - constructor.initializer-list.body: + initializer-list-body: - include: template - match: \( scope: meta.group.c++ punctuation.section.group.begin.c++ @@ -144,24 +152,24 @@ contexts: - meta_prepend: true - match: \b(?={{identifier}}\s*<) branch_point: template-call - branch: [call.template-call, qualified-ident] + branch: [template-call, qualified-ident] - match: (~{{identifier}})\s*(\() captures: 1: variable.function.c 2: punctuation.section.group.begin.c push: enclosure.parenthesis - call.template-call: + template-call: - match: \b{{identifier}}\b scope: entity.name.function.c++ - set: call.template-call.body - call.template-call.body: + set: template-call-body + template-call-body: - include: template - match: \( scope: meta.group.c++ punctuation.section.group.begin.c++ set: enclosure.parenthesis - match: (?=\S) fail: template-call - call.multi-line: + call-multi-line: - meta_prepend: true - include: template @@ -183,19 +191,20 @@ contexts: module: - match: \bmodule\b scope: keyword.declaration.module.c++ - push: module.name + push: module-name - match: \b(import)\s*(?=<) scope: keyword.other.import.c++ push: string.angled - match: \bimport\b scope: keyword.other.import.c++ - push: module.name - module.name: + push: module-name + module-name: - meta_content_scope: entity.name.module.c++ - match: '{{identifier}}' - match: \. scope: punctuation.accessor.dot.c++ - include: else-pop + type: - meta_prepend: true - match: \bnamespace\b @@ -228,7 +237,9 @@ contexts: - include: else-pop - match: \{ scope: meta.block.c++ punctuation.section.block.begin.c++ - push: [pop-twice, enclosure.outer-block] + push: + - pop-twice + - enclosure.outer-block - match: = scope: keyword.operator.assignment.c++ pop: 1 @@ -246,13 +257,16 @@ contexts: - match: (?={{qualified}}) push: qualified-ident - include: else-pop + type.template: - meta_scope: meta.template.c++ - match: \< scope: punctuation.definition.generic.begin.c++ - push: [type.template.requires, type.template.body] + push: + - type.template-requires + - type.template-body - include: else-pop - type.template.body: + type.template-body: - match: \> scope: punctuation.section.generic.end.c++ pop: 1 @@ -265,17 +279,17 @@ contexts: - match: (?={{identifier}}\s*(?!\s*[,\>=]|$)) push: - match: \b - set: type.template.name + set: type.template-name - include: expression - match: \b(typename|class)\b scope: keyword.declaration.type.c++ - include: expression - type.template.requires: + type.template-requires: - match: \brequires\b scope: storage.modifier.c++ pop: 1 - include: else-pop - type.template.name: + type.template-name: - match: (?=[\]\}\);]) # Fallback pop: 1 - match: \b(typename|class)\b @@ -291,13 +305,14 @@ contexts: 1: variable.parameter.type.c++ pop: 1 - include: expression + type.concept: - meta_scope: meta.concept.c++ - match: '{{identifier}}' scope: entity.name.concept.c++ - push: type.concept.body + push: type.concept-body - include: else-pop - type.concept.body: + type.concept-body: - include: requires-fn - include: expression - match: (?=;|\)|\]|\}) @@ -311,14 +326,6 @@ contexts: branch_point: enum branch: [type.enum, pop-immediately] - - requires-fn: - - match: \b(requires)\s*(\()\b - captures: - 1: keyword.operator.word.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: function.params - enclosure: - meta_prepend: true - include: lambda-enclosure @@ -330,7 +337,7 @@ contexts: captures: 1: punctuation.section.brackets.end.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ - set: [lambda.try-not, enclosure.parenthesis] + set: [lambda-try-not, enclosure.parenthesis] enclosure.outer-block: - meta_content_scope: meta.block.c++ - match: \} @@ -344,7 +351,7 @@ contexts: scope: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ branch: [enclosure.brackets, lambda] - lambda.try-not: + lambda-try-not: - include: expression-identifiers - match: \-\> fail: lambda @@ -356,8 +363,12 @@ contexts: - match: '[&=](?=\s*[,\]])' scope: storage.modifier.capture.c++ - match: (?=\S) - set: [function.tail, function.params, lambda.template, lambda.captures] - lambda.captures: + set: + - function-tail + - function-params + - lambda-template + - lambda-captures + lambda-captures: - match: '{{identifier}}' scope: entity.other.lambda-capture.c++ variable.parameter.c++ - match: \] @@ -369,7 +380,7 @@ contexts: pop: 1 - include: expression - include: expression - lambda.template: + lambda-template: - match: (?=\<) push: type.template - match: \( @@ -377,29 +388,27 @@ contexts: pop: 1 - include: expression-identifiers - match: \{ - push: function.body + push: function-body class: - match: ({{identifier}})(?=\s*;) scope: entity.name.class.forward-declare.c++ pop: 1 - match: (?={{identifier}}|:|\{) - set: [class.body-start, class.inherit, class.final, class.likely-macro, class.name, class.likely-macro] - class.likely-macro: - - match: '{{likely_macro}}' - - match: '({{identifier}})\s*(\()' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: enclosure.parenthesis - - include: else-pop - class.name: + set: + - class-body-start + - class-inherit + - class-final + - likely-macro + - class-name + - likely-macro + class-name: - include: punctuation.qualifier - match: (?={{identifier}}) branch_point: class-name - branch: [class.name.body, consume-ident] + branch: [class-name-body, consume-ident] - include: else-pop - class.name.body: + class-name-body: - match: ({{identifier}}) scope: entity.name.class.c++ set: @@ -411,16 +420,16 @@ contexts: - match: (::) fail: class-name - include: else-pop - class.final: + class-final: - match: \bfinal(?!\s*;)\b scope: storage.modifier.c++ - include: else-pop - class.inherit: + class-inherit: - match: ':' scope: punctuation.separator.inheritance.c++ - push: class.inherit.body + push: class-inherit.body - include: else-pop - class.inherit.body: + class-inherit.body: - include: keyword.storage - include: punctuation.comma - match: (?={{qualified}}) @@ -428,13 +437,13 @@ contexts: - meta_scope: entity.other.inherited-class.c++ - include: qualified-ident - include: else-pop - class.body-start: + class-body-start: - meta_scope: meta.class.c++ - match: \{ scope: meta.block.c++ punctuation.section.block.begin.c++ - set: class.body + set: class-body - include: else-pop - class.body: + class-body: - meta_scope: meta.block.c++ meta.class.c++ - include: enclosure.outer-block @@ -444,9 +453,9 @@ contexts: - match: (::) scope: punctuation.accessor.double-colon.c++ - match: '{{identifier}}' - push: qualified-ident.body + push: qualified-ident-body - include: else-pop - qualified-ident.body: + qualified-ident-body: - match: (::) scope: punctuation.accessor.double-colon.c++ pop: 1 @@ -462,8 +471,8 @@ contexts: - meta_scope: meta.template.c++ - match: < scope: punctuation.definition.generic.begin.c++ - set: try-template.body - try-template.body: + set: try-template-body + try-template-body: - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) fail: template - match: (?=\&\&\s*[^>]) @@ -483,10 +492,19 @@ contexts: 1: entity.name.label.c++ 2: punctuation.separator.c++ - dot-access.body: + access-not-fn: - meta_prepend: true - match: \< - fail: dot-access + fail: access + + likely-macro: + - match: '{{likely_macro}}' + - match: '({{identifier}})\s*(\()' + captures: + 1: variable.function.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: enclosure.parenthesis + - include: else-pop keyword: - meta_append: true @@ -510,7 +528,7 @@ contexts: captures: 1: keyword.control.exception.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ - push: function.params + push: function-params - match: \b(try|catch|finally|throw)\b scope: keyword.control.exception.c++ - match: \bco_(wait|yield|return)\b @@ -546,6 +564,11 @@ contexts: scope: keyword.operator.logical.c++ operator.word: - meta_prepend: true + - match: \b(requires)\s*(\()\b + captures: + 1: keyword.operator.word.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: function-params - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept|requires)\b scope: keyword.operator.word.c++ operator.comparison: diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index e99abf4dd5..c281a82523 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -29,21 +29,22 @@ contexts: comment: - match: // scope: punctuation.definition.comment.c - push: - - meta_scope: comment.line.double-slash.c - - include: preprocessor.line-escape - - include: eol-pop - + push: comment.line - match: /\* scope: punctuation.definition.comment.c - push: - - meta_scope: comment.block.c - - include: preprocessor.line-escape - - match: \*/ - scope: punctuation.definition.comment.c - pop: 1 + push: comment.block - match: \*/ scope: invalid.illegal.stray-comment-end.c + comment.line: + - meta_scope: comment.line.double-slash.c + - include: preprocessor.line-escape + - include: eol-pop + comment.block: + - meta_scope: comment.block.c + - include: preprocessor.line-escape + - match: \*/ + scope: punctuation.definition.comment.c + pop: 1 preprocessor: - include: preprocessor.line-escape @@ -95,6 +96,7 @@ contexts: - match: \< scope: punctuation.definition.string.begin.c push: string.angled + - include: comment - include: eol-pop preprocessor.diagnostic: - meta_scope: meta.preprocessor.diagnostic.c @@ -148,6 +150,7 @@ contexts: push: preprocessor.embed-enclosure - include: eol-pop preprocessor.embed-enclosure: + - meta_scope: meta.group.c - match: \) scope: punctuation.section.group.end.c pop: 1 @@ -168,7 +171,7 @@ contexts: # priority issues with matching ^\s*{{identifier}} - match: ^\s+ branch_point: try-function - branch: [expression.try-function, pop-immediately] + branch: [try-function, pop-immediately] - include: keyword.control-flow - include: keyword.control - match: (?=^{{identifier}}\s+{{identifier}}\s*\() @@ -185,7 +188,8 @@ contexts: - include: generic - include: call - include: enclosure - expression.try-function: + + try-function: - include: keyword.control - include: keyword.control-flow - match: (?={{identifier}}\s+{{identifier}}\s*\() @@ -208,15 +212,14 @@ contexts: push: enclosure.parenthesis - match: \b(?={{identifier}}\s*$) branch_point: not-call - branch: [call.not-call, call.multi-line] - call.not-call: + branch: [call-try-not, call-multi-line] + call-try-not: - include: expression-identifiers - match: (?=\() fail: not-call - - match: '{{identifier}}\b' - include: else-pop - call.multi-line: + call-multi-line: - match: '\b{{std_funcs}}\b' scope: support.function.std.c - match: '\b{{identifier}}\b' @@ -232,9 +235,11 @@ contexts: captures: 1: entity.name.function.c 2: punctuation.section.group.begin.c - push: [function.tail, function.params] + push: + - function-tail + - function-params - match: \b{{identifier}}\b - function.params: + function-params: - meta_content_scope: meta.function.parameters.c meta.group.c - match: \) scope: punctuation.section.group.end.c @@ -249,10 +254,10 @@ contexts: - match: (?={{identifier}}\s*(?!\s*[\[,\)]|$)) push: - match: \b - set: function.params.name + set: function-params-name - include: expression - include: expression - function.params.name: + function-params-name: - match: (?=[\]\}\);]) # Fallback pop: 1 - match: '{{fn_pointer}}' @@ -260,7 +265,7 @@ contexts: 1: keyword.operator.c 2: variable.parameter.c 3: punctuation.section.group.begin.c - set: function.params + set: function-params - include: expression-identifiers - match: ({{identifier}})\s*(\[) captures: @@ -272,15 +277,15 @@ contexts: 1: variable.parameter.c pop: 1 - include: expression - function.tail: + function-tail: - meta_scope: meta.function.c - match: ; pop: 1 - match: \{ scope: punctuation.section.block.begin - set: function.body + set: function-body - include: expression - function.body: + function-body: - meta_scope: meta.function.c meta.block.c - match: \} scope: punctuation.section.block.end.c @@ -319,14 +324,14 @@ contexts: captures: 1: keyword.operator.c 3: punctuation.section.group.begin.c - set: function.params + set: function-params type.typedef: - match: '{{fn_pointer}}' captures: 1: keyword.operator.c 2: entity.name.type.typedef.c 3: punctuation.section.group.begin.c - set: function.params + set: function-params - match: ({{identifier}})\s*(?=;) captures: @@ -445,8 +450,8 @@ contexts: captures: 1: keyword.declaration.c 2: punctuation.section.group.begin.c - push: generic.body - generic.body: + push: generic-body + generic-body: - match: ':' scope: keyword.operator.c push: @@ -462,13 +467,13 @@ contexts: 1: entity.name.label.c 2: punctuation.separator.c - dot-access: + access: - match: '{{identifier}}' scope: variable.other.readwrite.member.c - set: dot-access.body - dot-access.body: + set: access-not-fn + access-not-fn: - match: \( - fail: dot-access + fail: access - include: else-pop ###[ BASIC OBJECTS ]############################################################ @@ -491,27 +496,27 @@ contexts: - match: \" scope: punctuation.definition.string.end.c pop: 1 - - include: string.escape - - include: string.format + - include: string-escape + - include: string-format string.single: - meta_scope: string.quoted.single.c - meta_include_prototype: false - match: \' scope: punctuation.definition.string.end.c pop: 1 - - include: string.escape + - include: string-escape string.angled: - meta_scope: string.quoted.other.c - meta_include_prototype: false - match: \> scope: punctuation.definition.string.end.c pop: 1 - string.escape: + string-escape: - match: \\([abfnrtv\\'\"?]|[eE]|[0-7]{1,3}|x\h+|u\h{4}|U\h{8}) scope: constant.character.escape.c - match: \\. scope: invalid.illegal.unknown-escape.c - string.format: + string-format: - match: |- (?x)% (\d+\$)? # field (argument #) @@ -566,8 +571,8 @@ contexts: operator.accessor: - match: (\.|\-\>)(?=\s*{{identifier}}) scope: punctuation.accessor.dot.c++ - branch_point: dot-access - branch: [dot-access, pop-immediately] + branch_point: access + branch: [access, pop-immediately] - match: \.|\-\> scope: punctuation.accessor.c operator.pointer: @@ -742,21 +747,20 @@ contexts: 1: storage.modifier.c 2: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis - - match: \b(property)\s*(\() captures: 1: storage.modifier.c 2: punctuation.section.group.begin.c - push: - - meta_content_scope: meta.group.c - - match: \b(get|put)\b - scope: variable.parameter.c - - include: enclosure.parenthesis - + push: declspec-proprty - include: expression - match: \) scope: punctuation.section.group.end.c pop: 1 + declspec-proprty: + - meta_content_scope: meta.group.c + - match: \b(get|put)\b + scope: variable.parameter.c + - include: enclosure.parenthesis gnu-attribute: - meta_scope: meta.group.c meta.attribute.c diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index 4008ef1e96..eb3c4f93e8 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -17,8 +17,7 @@ first_line_match: |- ) contexts: - message-enclosure: - - match: "" + message-enclosure: [] enclosure: - meta_prepend: true - match: (?=\[(?!\s*{{identifier}}\s*[:\]])) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 3f49b54824..ba5b8bb30b 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -25,12 +25,14 @@ contexts: - match: ^\s*(@implementation)\b captures: 1: keyword.declaration.class.objc - push: implementation.start - implementation.start: + push: implementation-start + implementation-start: - meta_scope: meta.implementation.objc - match: '{{identifier}}' scope: entity.name.type.objc - push: [pop-twice, interface.body] + push: + - pop-twice + - interface-body - include: else-pop interface: @@ -39,66 +41,67 @@ contexts: 1: keyword.declaration.class.objc push: - meta_scope: meta.interface.objc - - include: interface.start + - include: interface-start - match: ^\s*(@protocol)\b captures: 1: keyword.declaration.class.objc push: - meta_scope: meta.protocol.objc - - include: interface.start + - include: interface-start - interface.start: + interface-start: - match: '{{identifier}}' scope: entity.name.type.objc push: - pop-twice - - interface.body - - interface.struct - - interface.subclass - - interface.category + - interface-body + - interface-struct + - interface-subclass + - interface-category - include: else-pop - interface.meta: - - meta_scope: meta.interface-or-protocol.objc meta.scope.interface.objc - - include: pop-immediately - interface.category: + interface-category: - match: \( scope: meta.group.objc punctuation.section.group.begin.objc set: - meta_content_scope: meta.group.objc entity.name.type.category.objc - include: enclosure.parenthesis - include: else-pop - interface.subclass: + interface-subclass: - include: protocol-list - match: ':' scope: punctuation.separator.objc - include: expression-identifiers - include: else-pop - interface.struct: + interface-struct: - match: \{ scope: meta.block.objc punctuation.section.block.begin.objc set: enclosure.block - include: else-pop - interface.body: + interface-body: - match: \@end scope: keyword.declaration.interface.end.objc pop: 1 - match: \@property scope: keyword.other.objc - push: [statement, property] + push: + - statement + - property - match: \@(?:synthesize|dynamic) scope: keyword.other.objc push: statement - match: (?:\+|\-)\s*(?=\() - push: [selector, selector.return] + push: + - selector + - selector-return - include: expression property: - match: \( scope: punctuation.section.group.begin.objc - set: property.attrs + set: property-attrs - include: else-pop - property.attrs: + property-attrs: - meta_scope: meta.group.objc - match: \) scope: punctuation.section.group.end.objc @@ -113,10 +116,6 @@ contexts: - include: punctuation.comma - include: operator - selector.return: - - match: \( - scope: meta.group.objc punctuation.section.group.begin.objc - set: enclosure.parenthesis selector: - meta_scope: meta.function.selector.objc - match: '\b({{identifier}})\s*(\:)\s*(\()' @@ -124,7 +123,9 @@ contexts: 1: entity.name.function.method.objc 2: punctuation.separator.arguments.objc 3: meta.group.objc punctuation.section.group.begin.objc - push: [selector.param, enclosure.parenthesis] + push: + - selector-param + - enclosure.parenthesis - match: \b({{identifier}})\s*(\:) captures: 1: entity.name.function.method.objc @@ -142,7 +143,11 @@ contexts: set: enclosure.block - include: operator.variadic - include: expression - selector.param: + selector-return: + - match: \( + scope: meta.group.objc punctuation.section.group.begin.objc + set: enclosure.parenthesis + selector-param: - match: \b{{identifier}}\b scope: variable.parameter.objc pop: 1 @@ -150,8 +155,8 @@ contexts: protocol-list: - match: \<(?=({{identifier}}|,|\s|\*)*\>) scope: punctuation.section.scope.begin.objc - push: protocol-list.body - protocol-list.body: + push: protocol-list-body + protocol-list-body: - meta_scope: meta.protocol-list.objc - include: expression-identifiers - include: punctuation.comma @@ -165,35 +170,37 @@ contexts: - match: (\^)\s*(?=\() captures: 1: keyword.operator.bitwise.objc - branch_point: block-fn - branch: [block-fn, pop-immediately] + branch_point: block + branch: [block, pop-immediately] - match: '(@catch)\s*(\()' captures: 1: keyword.control.exception.objc 2: punctuation.section.group.begin.objc - push: function.params + push: function-params - include: protocol-list - call.not-call: + call-try-not: - meta_prepend: true - match: '(?={{identifier}}\s*:)' pop: 1 - block-fn: + block: - meta_scope: meta.function.block.objc - match: '' - set: [block-fn.body, block-fn.params] - block-fn.params: + set: + - block-body + - block-params + block-params: - match: \( scope: punctuation.section.group.begin.objc - set: function.params + set: function-params - include: else-pop - block-fn.body: + block-body: - match: \{ scope: meta.block.objc punctuation.section.block.begin.objc set: enclosure.block - match: (?=\S) - fail: block-fn + fail: block preprocessor: - meta_prepend: true @@ -215,28 +222,6 @@ contexts: - match: '%@' scope: constant.other.placeholder.objc - available.body: - - meta_scope: meta.available.objc - - meta_content_scope: meta.group.objc - - match: \) - scope: meta.group.objc punctuation.section.group.end.objc - pop: 1 - - match: \b(?:iOS|macOS|watchOS|tvOS|visionOS)\b - scope: support.constant.platform.objc - - match: \b(\d[\d\.]+)\b - captures: - 1: constant.numeric.version.objc - - include: expression - - selector-obj: - - meta_scope: meta.selector.objc - - meta_content_scope: meta.group.objc meta.selector.method-name.objc - - match: \) - scope: meta.group.objc punctuation.section.group.end.objc - pop: 1 - - match: '[^)]+' - scope: support.function.objc - keyword: - meta_prepend: true - match: \b(?:self|super)\b @@ -247,12 +232,12 @@ contexts: captures: 1: keyword.operator.word.objc 2: meta.group.objc punctuation.section.group.begin.objc - push: available.body + push: keyword.available - match: '(@selector)\s*(\()' captures: 1: keyword.operator.word.objc 2: meta.group.objc punctuation.section.group.begin.objc - push: selector-obj + push: keyword.selector - match: '@(?:selector|encode|defs|available)' scope: keyword.operator.word.objc keyword.control: @@ -275,6 +260,26 @@ contexts: scope: keyword.declaration.objc - match: '(?=\bNS)' push: ns-identifiers + keyword.available: + - meta_scope: meta.available.objc + - meta_content_scope: meta.group.objc + - match: \) + scope: meta.group.objc punctuation.section.group.end.objc + pop: 1 + - match: \b(?:iOS|macOS|watchOS|tvOS|visionOS)\b + scope: support.constant.platform.objc + - match: \b(\d[\d\.]+)\b + captures: + 1: constant.numeric.version.objc + - include: expression + keyword.selector: + - meta_scope: meta.selector.objc + - meta_content_scope: meta.group.objc meta.selector.method-name.objc + - match: \) + scope: meta.group.objc punctuation.section.group.end.objc + pop: 1 + - match: '[^)]+' + scope: support.function.objc gnu-attribute: - meta_append: true @@ -335,7 +340,7 @@ contexts: - include: enclosure - match: (?={{identifier}}\s*:) - set: message.func + set: message-func - match: \] fail: message @@ -349,7 +354,7 @@ contexts: - match: '\b({{identifier}})\b' - match: (?=\S) fail: message - message.func: + message-func: - meta_scope: meta.bracketed.objc - match: '\b({{identifier}})\s*(:)' captures: From c415e2131810b6f112c6883b5676e7285f464df9 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 25 Feb 2025 09:13:07 -0600 Subject: [PATCH 53/66] Change extends --- Objective-C/Objective-C++.sublime-syntax | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index eb3c4f93e8..cde3987790 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -4,7 +4,9 @@ name: Objective-C++ scope: source.objc++ version: 2 -extends: [Packages/Objective-C/Objective-C.sublime-syntax, Packages/C++/C++.sublime-syntax] +extends: + - Packages/Objective-C/Objective-C.sublime-syntax + - Packages/C++/C++.sublime-syntax file_extensions: - mm From fdcb4dd6a538e88016b7151b495665cbc6d20bb3 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:26:16 -0600 Subject: [PATCH 54/66] Add standard attributes --- C++/C++.sublime-syntax | 4 +++- C++/C.sublime-syntax | 29 +++++++++++++++++++----- Objective-C/Objective-C++.sublime-syntax | 7 +++--- Objective-C/Objective-C.sublime-syntax | 17 +++++++++++--- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 4ea0ea2532..c5584090bc 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -346,7 +346,7 @@ contexts: - include: main lambda-enclosure: # for ObjC++ - - match: \[ + - match: \[(?!\[) branch_point: lambda scope: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ branch: [enclosure.brackets, lambda] @@ -599,3 +599,5 @@ contexts: variables: identifier: (?:\b|(?=\$))[[:alpha:]_$][[:alnum:]_$]*(?:\b|\$) qualified: (?:::\s*)?(?:{{identifier}}(?:\s*:{0,2}\s*)?)+ + attribute_item: '(?:(?:gnu|clang)::{{gnu_attribute_item}}|deprecated|noreturn|likely|unlikely|no_unique_address|fallthrough|nodiscard|maybe_unused|noreturn|unsequenced|reproducible)' + attribute_func: '(?:(?:gnu|clang)::{{gnu_attribute_func}}|deprecated|nodiscard|assume)' diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index c281a82523..a6accb24af 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -300,6 +300,7 @@ contexts: - include: constant ###[ SIMPLE STRUCTURES ]############################################################ + enum-def: # for C++ to override - match: \benum\b scope: keyword.declaration.enum.c @@ -411,6 +412,9 @@ contexts: - match: \( scope: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis + - match: \[\[ + scope: meta.brackets.square.c punctuation.section.brackts.begin.c + push: enclosure.attribute - match: \[ scope: meta.brackets.square.c punctuation.section.brackets.begin.c push: enclosure.brackets @@ -444,6 +448,18 @@ contexts: - match: \)|\] # Fallback scope: invalid.illegal.stray-bracket-end.c pop: 1 + enclosure.attribute: + - meta_scope: meta.brackets.square.c meta.annotation.c + - match: \b({{attribute_func}})\s*(\() + captures: + 1: storage.modifier.c + 2: meta.group.c punctuation.section.group.begin.c + push: enclosure.parenthesis + - match: \b{{attribute_item}}\b + scope: constant.other.c + - match: \]\] + scope: punctuation.section.brackets.end.c + pop: 1 generic: - match: \b(_Generic)\s*(\() @@ -764,15 +780,14 @@ contexts: gnu-attribute: - meta_scope: meta.group.c meta.attribute.c - # too many attributes, these are the ones commonly used - include: punctuation.comma - - match: \b{{attribute_item}}\b - scope: constant.other.c - - match: \b({{attribute_func}})\s*(\() + - match: \b({{gnu_attribute_func}})\s*(\() captures: 1: storage.modifier.c 2: meta.group.c punctuation.section.group.begin.c push: enclosure.parenthesis + - match: \b{{gnu_attribute_item}}\b + scope: constant.other.c - match: \)\) scope: punctuation.section.group.end.c pop: 1 @@ -809,8 +824,10 @@ variables: declspec_item: '(?:allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' declspec_func: '(?:align|allocate|code_seg|spectre|uuid|deprecated)' - attribute_item: '(?:noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' - attribute_func: '(?:aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' + gnu_attribute_item: '(?:noreturn|pure|const|malloc|cold|hot|deprecated|always_inline|noinline|packed|unused|used|leaf|artificial|flatten|noclone|returns_twice|weak|no_reorder|minsize|externally_visible|constructor|destructor)' + gnu_attribute_func: '(?:aligned|format|nonnull|section|visibility|alias|ifunc|target|alloc_size|cleanup|warning|error|cold_hot_partitioning|no_sanitize|optimize)' + attribute_item: '(?:(?:gnu|clang)::{{gnu_attribute_item}}|deprecated|fallthrough|nodiscard|maybe_unused|noreturn|unsequenced|reproducible)' + attribute_func: '(?:(?:gnu|clang)::{{gnu_attribute_func}}|deprecated|nodiscard)' std_funcs: '(?:assert|(?:exp(?:2|m1)|log(?:10|2|1p)|cbrt|hypot|erfc?|[lt]gamma|ceil|floor|trunc|l{0,2}round|f(?:absmod|max|min|dim)|c(?:abs|real|imag|arg|onj|proj|)|c?(?:exp|log|pow|sqrt|a?(?:sin|cos|tan)h?))[fl]?|abs|l{0,2}div|is(?:finite|inf|nan|normal|greater(?:equal)?|less(?:equal|greater)?|unordered|alnum|alpha|lower|upper|x?digit|cntrl|graph|space|blank|print|punct)(?:set|long)jmp|jmp_buf|signal|raise|va_(?:list|start|arg|copy|end)|std(?:in|out|err)|setv?buf|re(?:wind|move|name)|tmp(?:nam|file)(?:_s)?|f(?:(?:re)?open(?:_s)?|close|flush|wide|read|write|tell|getpos|seek|setpos|error)|gets_s|f?(?:get|put)?(?:c|s|char)|v?f?s?w?scanf(?:s|sn)?w?printf(?:_s)?|abort|(?:(?:at_)?quick_|at)?exit|_Exit|unreachable|system|getenv(?:_s)?|to(?:lower|upper)|ato(?:f|i|l|ll)|str(?:to(?:u?ll?|f|l?d)|from[dfl]|(?:n?cpy|cat|nlen|tok|error(?:len)?)(?:_s)?|xfrm|n?dup|n?cmp|coll|r?chr|c?spn|pbrk|str|len)|mem(?:chr|cmp|set(?:_explicit|_s)?|(?:move|cpy)(?:_s)?|ccpy)|thrd_(?:create|equal|current|sleep|yield|exit|detach|join|success|timedout|busy|nomem|error)|(?:diff|mk|strf)?time|clock|timespec_get(?:res)?|(?:as)?ctime(?:_s)?|(?:gm|local)time(?:_[rs])?)' diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index cde3987790..c78ab848b9 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -26,10 +26,9 @@ contexts: branch_point: message branch: [pre-message, pre-lambda] - pre-message: - - match: \[ - scope: punctuation.section.brackets.begin.objc++ - set: message pre-lambda: + - match: \[\[ + scope: meta.brackts.square.objc++ punctuation.section.brackets.begin.objc++ + set: enclosure.attribute - include: lambda-enclosure - include: pop-immediately \ No newline at end of file diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index ba5b8bb30b..dc588831d9 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -323,11 +323,14 @@ contexts: - include: expression message-enclosure: # for ObjC++ - - match: \[(?!\s*{{identifier}}\s*[:\]]) - scope: meta.brackets.square.objc punctuation.section.brackets.begin + - match: (?=\[(?!\s*{{identifier}}\s*[:\]])) branch_point: message - branch: [message, enclosure.brackets] + branch: [pre-message, not-message] + pre-message: + - match: \[ + scope: meta.brackets.square.objc punctuation.section.brackets.begin + set: message message: - meta_scope: meta.bracketed.objc @@ -367,6 +370,14 @@ contexts: scope: punctuation.section.brackets.end.objc pop: 1 + not-message: + - match: \[\[ + scope: meta.brackets.square.objc punctuation.section.brackts.begin.objc + set: enclosure.attribute + - match: \[ + scope: meta.brackets.square.objc punctuation.section.brackets.begin.objc + set: enclosure.brackets + ns-identifiers: - match: (\s*)\b(NS(Rect(ToCGRect|FromCGRect)|MakeCollectable|S(tringFromProtocol|ize(ToCGSize|FromCGSize))|Draw(NinePartImage|ThreePartImage)|P(oint(ToCGPoint|FromCGPoint)|rotocolFromString)|EventMaskFromType|Value))\b captures: From c8d276de11ccb961337298e70ff2a00c221541b4 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:44:29 -0600 Subject: [PATCH 55/66] Remove c++ sublime settings --- C++/C++.sublime-settings | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 C++/C++.sublime-settings diff --git a/C++/C++.sublime-settings b/C++/C++.sublime-settings deleted file mode 100644 index 15f4f890ce..0000000000 --- a/C++/C++.sublime-settings +++ /dev/null @@ -1,4 +0,0 @@ -{ - // This overrides "file_extensions" in C.sublime-syntax - "extensions": ["h"] -} From 83367150662656e19f76462746aa3c61dff373bc Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:19:42 -0600 Subject: [PATCH 56/66] C++ Syntax Test --- C++/C++.sublime-syntax | 104 +- C++/C.sublime-syntax | 24 +- C++/syntax_test_c.c | 161 +- C++/syntax_test_cpp.cpp | 4979 +++++++++--------------- Objective-C/Objective-C.sublime-syntax | 16 +- Objective-C/syntax_test_objc.m | 245 +- 6 files changed, 2177 insertions(+), 3352 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index c5584090bc..94c3a17e0c 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -29,13 +29,8 @@ first_line_match: |- ) contexts: - main: - - meta_prepend: true - - include: module - - include: requires-fn - function: - - match: \b(operator)\s*([<>=+\-*/%&|^!]=?|[+\-&|<>]{2}|<<=|>>=|<=>|~|->\*?|\(\)|\[\])\s*(\() + - match: \b(operator)\s*([<>=+\-*/%&|^!]=?|[+\-&|<>]{2}|<<=|>>=|<=>|~|->\*?|\(\)|\[\]|\"\"\s*{{identifier}})\s*(\() captures: 1: keyword.operator.c++ 2: entity.name.function.c++ @@ -118,11 +113,13 @@ contexts: - match: \-\> scope: keyword.operator.arrow.c++ push: function-tail-return + - include: operator function-tail-return: - meta_scope: meta.function.return-type.c++ - match: (?=\brequires\b) pop: 1 - - match: (?={) + - include: expression-identifiers + - match: (?=(?:{{identifier}})?\s*{) pop: 1 - include: expression function-tail-requires: @@ -155,8 +152,8 @@ contexts: branch: [template-call, qualified-ident] - match: (~{{identifier}})\s*(\() captures: - 1: variable.function.c - 2: punctuation.section.group.begin.c + 1: variable.function.c++ + 2: punctuation.section.group.begin.c++ push: enclosure.parenthesis template-call: - match: \b{{identifier}}\b @@ -169,6 +166,9 @@ contexts: set: enclosure.parenthesis - match: (?=\S) fail: template-call + call-try-not-paren: + - meta_prepend: true + - include: template call-multi-line: - meta_prepend: true - include: template @@ -177,12 +177,12 @@ contexts: - meta_append: true - include: punctuation.qualifier - include: template + - include: module expression: - meta_prepend: true - include: template - include: module - include: type - - include: requires-fn - match: \+\s*(\[) captures: 1: meta.brackets.square.c++ punctuation.section.brackets.begin.c++ @@ -203,6 +203,8 @@ contexts: - match: '{{identifier}}' - match: \. scope: punctuation.accessor.dot.c++ + - match: ':' + scope: punctuation.separator.partition.c++ - include: else-pop type: @@ -313,7 +315,6 @@ contexts: push: type.concept-body - include: else-pop type.concept-body: - - include: requires-fn - include: expression - match: (?=;|\)|\]|\}) pop: 1 @@ -321,7 +322,7 @@ contexts: enum-def: - match: \b(enum)(?:\s*(class))?\b captures: - 1: keyword.declaration.enum.c + 1: keyword.declaration.enum.c++ 2: keyword.declaration.class.c++ branch_point: enum branch: [type.enum, pop-immediately] @@ -338,6 +339,9 @@ contexts: 1: punctuation.section.brackets.end.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ set: [lambda-try-not, enclosure.parenthesis] + + - match: (\])\s*(\{|\-\>|mutable\b) + fail: lambda enclosure.outer-block: - meta_content_scope: meta.block.c++ - match: \} @@ -386,9 +390,18 @@ contexts: - match: \( scope: meta.group.c++ punctuation.section.group.begin.c++ pop: 1 + - match: (?=->) + pop: 2 # skip params - include: expression-identifiers - - match: \{ - push: function-body + - match: (?=\{) + pop: 2 # skip params + + generic: # override, replace with {} constructor + - match: \b({{identifier}})\s*(\{) + captures: + 1: variable.function.c++ + 2: meta.block.c punctuation.section.block.begin.c++ + push: enclosure.block class: - match: ({{identifier}})(?=\s*;) @@ -508,13 +521,18 @@ contexts: keyword: - meta_append: true - - match: \b(export|friend|operator|import)\b + - match: \b(export|friend|operator)\b scope: keyword.other.c++ keyword.type: - meta_prepend: true - match: \b(w?char(8|16|32)_t)|wchar_t\b scope: storage.type.c++ - - match: decltype + - match: \b(decltype)\s*(\() + captures: + 1: keyword.declaration.type.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: enclosure.parenthesis + - match: \bdecltype\b scope: keyword.declaration.type.c++ keyword.storage: - meta_prepend: true @@ -531,8 +549,15 @@ contexts: push: function-params - match: \b(try|catch|finally|throw)\b scope: keyword.control.exception.c++ - - match: \bco_(wait|yield|return)\b + - match: \bco_(await|yield|return)\b scope: keyword.control.c++ + - match: \b(requires)\s*(\()\b + captures: + 1: keyword.operator.word.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: [function-tail, function-params] + - match: \b(requires)\b + scope: keyword.operator.word.c++ constant: - meta_prepend: true @@ -553,24 +578,17 @@ contexts: - include: template operator.bitwise: - match: \&|\||\^|~(?!{{identifier}}\s*\()|<<|>> - scope: keyword.operator.bitwise.c - - match: \b(bit(and|or)|compl)\b - scope: keyword.operator.bitwise.c++ - - match: \bxor(_eq)\b scope: keyword.operator.bitwise.c++ - operator.logical: - - meta_append: true - - match: \b(and|x?or|not)(_eq)?\b - scope: keyword.operator.logical.c++ operator.word: - meta_prepend: true - - match: \b(requires)\s*(\()\b - captures: - 1: keyword.operator.word.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: function-params - - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept|requires)\b + - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b scope: keyword.operator.word.c++ + - match: \b(and|x?or|not)(_eq)?\b + scope: keyword.operator.logical.c++ + - match: \b(bit(and|or)|compl)\b + scope: keyword.operator.bitwise.c++ + - match: \bxor(_eq)\b + scope: keyword.operator.bitwise.c++ operator.comparison: - meta_prepend: true - match: <=> @@ -585,18 +603,40 @@ contexts: 3: constant.other.placeholder.c++ 4: constant.other.placeholder.c++ push: string.raw + string.double: + - meta_prepend: true + - match: (\")({{literal_operator}})? + captures: + 1: punctuation.definition.string.end.c++ + 2: variable.function.c++ + pop: 1 + string.single: + - meta_prepend: true + - match: (\')({{literal_operator}})? + captures: + 1: punctuation.definition.string.end.c++ + 2: variable.function.c++ + pop: 1 string.raw: - meta_scope: string.quoted.raw.c++ - - match: (\)\3)(\") + - match: (\)\3)(\")({{literal_operator}})? captures: 1: constant.other.placeholder.c++ 2: punctuation.definition.string.end.c++ + 3: variable.function.c++ pop: true + string-format: + - meta_prepend: true + - match: '{}' + scope: constant.other.placeholder.c++ consume-ident: - match: \b{{identifier}}\b - include: pop-immediately variables: + literal_operator: '[[:alpha:]_$]+' + double_suffix: '(?![xb]|\w+\d){{literal_operator}}' + integer_suffix: '(?![xb]|\w+\d){{literal_operator}}' identifier: (?:\b|(?=\$))[[:alpha:]_$][[:alnum:]_$]*(?:\b|\$) qualified: (?:::\s*)?(?:{{identifier}}(?:\s*:{0,2}\s*)?)+ attribute_item: '(?:(?:gnu|clang)::{{gnu_attribute_item}}|deprecated|noreturn|likely|unlikely|no_unique_address|fallthrough|nodiscard|maybe_unused|noreturn|unsequenced|reproducible)' diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index a6accb24af..db8773bdf0 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -183,8 +183,8 @@ contexts: - include: type - include: keyword - include: constant - - include: operator - include: punctuation + - include: operator - include: generic - include: call - include: enclosure @@ -214,10 +214,11 @@ contexts: branch_point: not-call branch: [call-try-not, call-multi-line] call-try-not: - - include: expression-identifiers + - match: ({{identifier}}) + set: call-try-not-paren + call-try-not-paren: - match: (?=\() fail: not-call - - match: '{{identifier}}\b' - include: else-pop call-multi-line: - match: '\b{{std_funcs}}\b' @@ -279,12 +280,15 @@ contexts: - include: expression function-tail: - meta_scope: meta.function.c - - match: ; + - match: (?=;) pop: 1 - match: \{ - scope: punctuation.section.block.begin + scope: punctuation.section.block.begin.c set: function-body - - include: expression + - include: expression-identifiers + - match: \[\[ + scope: meta.brackets.square.c punctuation.section.brackts.begin.c + push: enclosure.attribute function-body: - meta_scope: meta.function.c meta.block.c - match: \} @@ -441,6 +445,7 @@ contexts: pop: 1 enclosure.block: - meta_content_scope: meta.block.c + - include: function - include: expression - match: \} scope: meta.block.c punctuation.section.block.end.c @@ -586,7 +591,7 @@ contexts: scope: keyword.operator.arithmetic.c operator.accessor: - match: (\.|\-\>)(?=\s*{{identifier}}) - scope: punctuation.accessor.dot.c++ + scope: punctuation.accessor.dot.c branch_point: access branch: [access, pop-immediately] - match: \.|\-\> @@ -751,6 +756,11 @@ contexts: scope: storage.type.c - match: \b(u?intptr|u?intmax|ptrdiff|nullptr|max_align|size|u?int(_fast|_least)?(8|16|32|64))_t\b scope: support.type.stdint.c + - match: \b(typeof_unqual|__typeof__|__typeof|typeof)\s*(\() + captures: + 1: keyword.declaration.type.c + 2: meta.group.c punctuation.section.group.begin.c + push: enclosure.parenthesis - match: \b(typeof_unqual|__typeof__|__typeof|typeof)\b scope: keyword.declaration.type.c diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 74a7d5aa45..0f39de6854 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -262,7 +262,7 @@ a,b = b.c; // ^ punctuation.separator.c // ^ keyword.operator.assignment.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^ variable.other.readwrite.member.c // ^ punctuation.terminator.c @@ -362,13 +362,13 @@ // ^ punctuation.section.brackets.end {1, 2, 3} // ^^^^^^^^^ meta.block.c -// ^ punctuation.section.block.begin +// ^ punctuation.section.block.begin.c // ^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.separator.c // ^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.separator.c // ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.block.end +// ^ punctuation.section.block.end.c (6 - 7 == -1 && true) // ^^^^^^^^^^^^^^^^^^^^^ meta.group.c // ^ punctuation.section.group.begin @@ -598,9 +598,10 @@ // ^ punctuation.section.group.end // ^ variable.parameter.c ); -//^^ meta.function.parameters.c meta.group.c -// ^^ meta.function.c -// ^ punctuation.section.group.end.c +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// // Control Flow @@ -803,10 +804,10 @@ // ^ punctuation.section.brackets.end // ^ punctuation.terminator.c void* h5; -//^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ storage.type.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c enum B out; }; //^^^^^^^^^^^^^^^^^^^ meta.block.c // ^^^^ keyword.declaration.enum.c @@ -850,16 +851,16 @@ // ^ punctuation.section.block.end // ^ punctuation.terminator.c void* ptr; -//^^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ storage.type.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c int a, *ptr2; -//^^^^^^^^^^^^^^^^^^^ meta.block.c -// ^^^ storage.type.c -// ^ punctuation.separator.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c }; //^^^ meta.block.c // ^ punctuation.section.block.end @@ -878,9 +879,9 @@ // ^ punctuation.terminator.c myunion.s2.f = 20; //^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^^ variable.other.readwrite.member.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^ variable.other.readwrite.member.c // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c @@ -895,9 +896,9 @@ // ^^^^^^ keyword.declaration.struct.c // ^ meta.block.c punctuation.section.block.begin.c myCustomType* a; -//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c } b; //^^^ meta.block.c // ^ punctuation.section.block.end @@ -957,37 +958,40 @@ // ^ punctuation.terminator.c void __declspec(dllimport) importedFn() const; -// ^^^^ storage.type.c -// ^^^^^^^^^^ storage.modifier.c -// ^^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^^ constant.other.c -// ^ punctuation.section.group.end.c -// ^^^^^^^^^^ entity.name.function.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ meta.function.c -// ^ punctuation.section.group.end.c -// ^^^^^ storage.modifier.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c __declspec(property(get=10, put=10)) void runForever(); -// ^^^^^^^^^^ storage.modifier.c -// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ storage.modifier.c -// ^ punctuation.section.group.begin.c -// ^^^ variable.parameter.c -// ^ keyword.operator.assignment.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^^ variable.parameter.c -// ^ keyword.operator.assignment.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.section.group.end.c -// ^^^^ storage.type.c -// ^^^^^^^^^^ entity.name.function.c -// ^ punctuation.section.group.begin.c -// ^^ meta.function.c -// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c void on_load() __attribute__((constructor, visibility("hidden"))) {} // ^^^^ storage.type.c @@ -1011,6 +1015,55 @@ // ^ meta.function.c meta.block.c punctuation.section.block.begin // ^ meta.block.c punctuation.section.block.end.c + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + int a = // ^^^ storage.type.c // ^ keyword.operator.assignment.c diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 8a6ee23d42..9f941861fd 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -1,3223 +1,1886 @@ -/* SYNTAX TEST "Packages/C++/C++.sublime-syntax" */ - -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ +// SYNTAX TEST "Packages/C++/C++.sublime-syntax" - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ - -Task natural_numbers() -{ - int n = 0; - while (true) { - co_yield n; - /* ^ keyword.control */ - n++; - } -} -Task foo() -{ - co_return 42; - /* ^ keyword.control */ - /* ^ meta.number */ -} -Task bar() -{ - co_await natural_numbers(); - /* ^ keyword.control */ - /* ^ variable.function */ -} - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number */ - /* ^^ keyword.operator.arithmetic */ -} - -///////////////////////////////////////////// -// Preprocessor -///////////////////////////////////////////// + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c -#ifndef IGUARD_ - /* <- keyword.control.import */ -#define IGUARD_ - /* <- keyword.control.import.define */ -struct foo* alloc_foo(); -/* <- keyword.declaration */ - /* <- - entity.name.type */ - /* <- entity.name.function */ -#endif - /* <- keyword.control.import */ - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -int g(int x = 5 \ - /* ^ punctuation.separator.continuation */ - , int y); - -#define MACRO_WITH_CURLY_BRACE { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ - - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} - -// This is a method/function with the return type on a separate line and so should not be a -// constructor. -FOOLIB_RESULT -some_namespace::some_function(int a_parameter, double another_parameter) { - /* <- meta.function meta.toc-list.full-identifier */ - /* ^ entity.name.function - entity.name.function.constructor */ - return FOOLIB_SUCCESS; -} - -#pragma foo(bar, \ -"baz", \ -1) -/* <- meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#if 0 -#ifdef moo -/* <- - keyword.control */ -#endif -/* <- - keyword.control */ -#endif - -#if 0000000 -/* ^^^^^^^ meta.number constant.numeric.value -*/ -#endif - -#if 0090 -/* ^^^^ meta.number constant.numeric.value -*/ -#endif - -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO -/* <- meta.assumed-macro */ - -struct FOO1 FOO2 FOO3 Test { - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - Test(); - Test() noexcept; - Test() final; - Test() noexcept final; - ~Test(); - ~Test() noexcept; - ~Test() override noexcept; - virtual ~Test(); - virtual ~Test() noexcept; - virtual ~Test() override noexcept; - DLL_API Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - DLL_API Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() noexcept final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API ~Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - DLL_API ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API virtual ~Test(); - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - DLL_API virtual ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API virtual ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -} - -struct X { - X(); - /* <- meta.group */ - /*^ meta.group - meta.group meta.group */ -}; - -#define DEPRECATED(msg) [[deprecated(msg)]] - -struct Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -}; - -namespace Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -} - -struct Test { -DEPRECATED("bla") -/* <- meta.assumed-macro variable.function.assumed-macro */ -bool foo (bool run=true) {} -/* ^ entity.name.function */ -}; + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c -///////////////////////////////////////////// -// Strings -///////////////////////////////////////////// + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c -char str1[] = "abc"; -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char8_t str2[] = u8"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char16_t str3[] = u"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char32_t str4[] = U"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -wchar_t str5[] = L"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char str6[] = "\a|\b|\e|\f|\n|\r|\t|\v|\'|\"|\?"; -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ - -char str7[] = "\0|\012"; -/* ^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ - -char str8[] = "\x0a|\x41|\xA|\x000065"; -/* ^^^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ -/* ^^^ constant.character.escape */ -/* ^^^^^^^^ constant.character.escape */ - -char8_t str9[] = u8"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char16_t str10[] = u"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char32_t str11[] = U"\U00000063"; -/* ^^^^^^^^^^ constant.character.escape */ - -char str12[] = "\q"; -/* ^^ invalid.illegal.unknown-escape */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ - -char rawStr1[] = R"("This is a raw string")"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char rawStr2[] = R"A*!34( )" )A*!34"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.definition.string.end */ - -const char IncludeRegexPattern[] = - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^^ - invalid */ -/* ^^ - invalid */ -/* ^ punctuation.definition.string.end */ - -foo.f<5> /* foo */ (); + */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Storage Types +// Numbers ///////////////////////////////////////////// -void* ptr; -/* <- storage.type */ - -bool b; -/* <- storage.type */ - -char ch; -/* <- storage.type */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -unsigned int ui; -/* <- storage.type */ -/* ^ storage.type */ - -signed long l; -/* <- storage.type */ -/* ^ storage.type */ - -short s; -/* <- storage.type */ - -auto a = 2; -/* <- storage.type */ - -decltype(s) dt; -/* <- keyword.declaration.type */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -float f; -/* <- storage.type */ - -double d; -/* <- storage.type */ - -typedef int my_int; -/* <- keyword.declaration.type */ -/* ^ entity.name.type */ - -typedef struct Books { -/* ^^^^^^ keyword.declaration.struct */ -/* ^ - entity.name.type */ - char title[50]; - int book_id; -} Book; -/*^ entity.name.type */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.c++ */ -/* ^^^^^^ keyword.declaration.struct.type.c++ */ -/* ^^^^^^^^^^^ entity.name.struct.c++ */ -/* ^ punctuation.section.block.begin.c++ */ -/* ^ punctuation.section.block.end.c++ */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.c++ */ - -using Alias = Foo; -/* <- keyword.control */ -/* ^^^^^ entity.name.type.using */ - -using Alias - = NewLineFoo; -/*^ - entity.name */ - -template -using TemplateAlias = Foo; -/* ^^^^^^^^^^^^^ entity.name.type.using */ - -using std::cout; -/* <- keyword.control */ -/* ^ - entity.name */ - -using std:: - cout; -/*^ - entity.name */ - -class MyClass : public SuperClass -{ - using This = MyClass; -/* ^ keyword.control */ -/* ^^^^ entity.name.type.using */ - - using MyInt -/* ^ keyword.control */ - = int32_t; - - using SuperClass::SuperClass; -/* ^ keyword.control */ -/* ^ - entity.name */ -}; - -class MyClass : public CrtpClass -{ - using typename CrtpClass::PointerType; -/* ^ keyword.control */ -/* ^ storage.modifier */ - using CrtpClass< -/* ^ keyword.control */ - MyClass>::method; -}; - -typedef struct Books Book; -/* ^ - entity.name.type.struct */ -/* ^ entity.name.type.typedef */ - -template class MyStack; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic */ -/* ^ storage.type */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic */ - -template class tupleTmpl; -/* <- keyword.declaration.template */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^^^^^ keyword.declaration.c++ */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -template, typename... Rest> class tupleVariadic; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^^^^^^^^ keyword.declaration */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ punctuation.definition.generic.end */ - -template void SomeClass::function(); -/* ^^^ keyword.operator.variadic */ -/* ^^^^^^^^ entity.name.function */ - -template inline struct Foo* baz() -/* ^^^^^^ storage.modifier */ -/* ^ - entity.name */ -/* ^^^ meta.function entity.name.function */ -{} - -template -void classname::methodName() { -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^^^^ entity.name.function */ -} - -template -void funcName() { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -} -bool A::operator<(const A& a) { return false; } -/* ^ storage.type */ -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters punctuation.section.group.begin */ -template bool A::operator<(const A& a) { return false; } -/* ^ keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters meta.group punctuation.section.group.begin */ -template -SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -template SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.constructor */ - -template A::~A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.destructor */ - -template -bool A::operator > (const A& other) { return false; } -/* ^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^^^^ entity.name.function */ -template -bool A::operator == (const A& other) { return false; } -/* ^^^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^^^^^^ entity.name.function */ -template -bool A::operator <=> (const A& other) { return false; } -/* ^^^^^^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^^^^^^ entity.name.function */ - -typedef std :: vector > Table; -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.end */ - -template - /* ^ meta.template keyword.operator */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template meta.number */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template constant.language */ -struct Foo -{ - -/* <- meta.struct - meta.template */ - - void bar(int a = 3, bool b = true) {} - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template meta.number */ - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template constant.language */ -}; - -/* <- - meta.block - meta.struct - meta.template */ - -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template meta.number */ -class fixed_array : private std::array {}; - -constexpr std::size_t f() { return 128; } -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -/* ^ meta.template punctuation */ -class fixed_array : private std::array {}; - -template class A { /* ... */ }; -template class B { /* ... */ }; -/* ^ meta.template keyword.operator */ -/* ^ meta.template */ -/* ^ meta.template punctuation */ -/* ^ - meta.template */ -template class C { /* ... */ }; - -// templates inside templates... it's templates all the way down -template class P> class X { /* ... */ }; -/* ^ meta.template punctuation */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template meta.template keyword.declaration */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template keyword.declaration */ -/* ^ meta.template punctuation */ - -X xa; // OK -X xb; // OK in C++14 after CWG 150 - // Error earlier: not an exact match -X xc; // OK in C++14 after CWG 150 - -// template declarations spanning multiple lines -template -/* <- meta.template keyword.declaration.template */ -< -/* <- meta.template punctuation.definition.generic.begin */ - class T, - class U = T -> -class B -{ - /* ... */ -}; - -// template declarations spanning multiple lines -template -< -/* <- meta.template punctuation.definition.generic.begin */ - std::size_t Count = f() -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -> -/* <- meta.template punctuation.definition.generic.end */ -class fixed_array : private std::array {}; - -template -static bool decode(const Node& node, T& sequence) { - if (!node.IsSequence()) - return false; - sequence.clear(); - for (const auto& item : node) { - sequence.push_back(item.template as()); - /* ^ punctuation.accessor */ - /* ^ keyword.declaration.template - variable.other */ - /* ^ variable.function */ - /* ^ punctuation */ - /* ^^ punctuation.accessor */ - /* ^ punctuation */ - } - return true; -} - -#include -template struct A {}; -template struct B {}; -struct C {}; -A> f(std::function>()> g) { - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ variable.parameter */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - return g(); -} -int main() { - std::function foo1; - /* ^ - variable.function */ - std::function()> foo2; - /* ^ - variable.function */ - auto f = [](std::function>()> g) { return g(); }; - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - /* ^ punctuation.section.block.end */ - return 0; -} -/* <- - invalid.illegal */ - -// Example from section 14.2/4 of -// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf -struct X -{ - template - X* alloc(); - - template - static X* adjust(); -}; -template -void f(T* p) -{ - // Be optimistic: scope it as a template member function call anyway. - T* p1 = p->alloc<200>(); // ill-formed: < means less than - - T* p2 = p->template alloc<200>(); // OK: < starts template argument list - /* ^ punctuation.accessor */ - /* ^ keyword.declaration.template - variable.other */ - /* ^ variable.function */ - - // Be optimistic: scope it as a template member function call anyway. - T::adjust<100>(); // ill-formed: < means less than - - T::template adjust<100>(); // OK: < starts template argument list - /* <- - variable.function */ - /*^ punctuation.accessor */ - /* ^ keyword.declaration.template - variable.other */ - /* ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ - /* ^ variable.function */ -} - -struct X -{ - void template(); // <-- not allowed to be a function! - /* ^ - entity.name.function */ -}; - -void f() -{ - X x; - x.template(); // <-- should not be scoped as variable.function! - /* ^ - variable.function */ - - x /**/ . /**/ foo <5> /**/ () /**/ ; - /*^^^^ comment.block */ - /* ^ punctuation.accessor */ - /* ^^^ meta.method-call variable.function */ - /* ^ meta.method-call - variable.function */ - /* ^ meta.method-call punctuation.definition.generic.begin */ - /* ^ meta.method-call punctuation.definition.generic.end */ - /* ^ meta.method-call - punctuation - comment.block */ - /* ^^^^ meta.method-call comment.block */ - /* ^ meta.method-call - comment.block - punctuation */ - /* ^^ meta.method-call punctuation - comment.block */ - /* ^ - meta.method-call */ -}; - -template C f(T t) -{ - return C { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -template C> f(T t) -{ - return C> { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -struct A { int foo; }; -int main() { - A a, b; - a.foo = a.foo < 0 ? 1 : 2; - /* ^ - punctuation.definition.generic */ - a.operator<(b); - /*^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator>(b); - /*^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator<=(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator>=(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator==(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator!=(b); - /*^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator<=>(b); - /*^^^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^^ variable.function.member */ - /* ^^^ meta.group */ - a.operator->(); - /*^^^^^^^^^^^^ meta.method-call */ - /*^^^^^^^^^^ variable.function.member */ - /* ^^ meta.group */ -} -/* <- - invalid.illegal */ - -template -struct A::value && !is_std_char_type::value>> { - using x = conditional_t; - /* ^^ keyword.operator.comparison */ - - template - struct Y { - constexpr int operator<=>(const Y&) { return 0; } - }; - Y{} <=> Y<0>{}> y; - /* ^^^ keyword.operator.comparison */ -}; -/* <- - invalid.illegal */ - + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.14L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-15 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c + 0x314.1p5af 0b10e20 +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Storage Modifiers +// Operators ///////////////////////////////////////////// -alignas(16) char array[256]; -/* <- storage.modifier */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -const int XYZ = 2; -/* <- storage.modifier */ - -constexpr int ABC = 3 + 5; -/* <- storage.modifier */ - -consteval int f() { return 42; } -/* <- storage.modifier */ - -constinit const int i = f(); -/* <- storage.modifier */ - -thread_local int x; -/* <- storage.modifier */ - + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 && 2 || 3 ? -4 : ~5 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ keyword.operator.word.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Control Keywords +// Strings ///////////////////////////////////////////// -static_assert(x >= 0); -/* <- keyword.operator */ - -noexcept(f()); -/* ^^^ meta.function-call */ -/* <- keyword.operator */ - -if (x < 5) -/* <- keyword.control */ -{} -else -/* <- keyword.control */ -{} - -switch (x) -/* <- keyword.control */ -{ -case 1: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -default: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -} - -do -/* <- keyword.control */ -{ - if (y == 3) - continue; - /* <- keyword.control.flow.continue */ -} while (y < x); -/*^ keyword.control */ - -switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ -} - -goto label; -/* <- keyword.control.flow.goto */ - -try -/* <- keyword.control */ -{ - throw std :: string("xyz"); - /* <- keyword.control.flow.throw */ - /* ^^^^^^ variable.function */ - /* ^^ punctuation.accessor */ -} -catch (...) -/* <- keyword.control */ -{ -} - -int* ptr = new int(2); -/* ^ keyword.control */ - -delete ptr; -/* <- keyword.control */ - -return 123; -/* <- keyword.control.flow.return */ - + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c++ + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c++ + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c++ + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c++ ///////////////////////////////////////////// -// Operator Keywords +// Constants ///////////////////////////////////////////// -int x = alignof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -int x = sizeof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Cast Keywords +// Enclosings ///////////////////////////////////////////// -const_cast(2.0); -/* <- keyword.operator.word.cast */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -dynamic_cast(2.0); -/* <- keyword.operator.word.cast */ - -reinterpret_cast(2.0); -/* <- keyword.operator.word.cast */ - -static_cast(2.0); -/* <- keyword.operator.word.cast */ - -auto var = *reinterpret_cast>*>(v); -/* ^ keyword.operator.word.cast */ -/* ^ - variable.function */ + [a, b, c] +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^^^^^^ meta.brackets.square.c +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end.c + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Language Constants +// Default Types ///////////////////////////////////////////// -bool t = true; -/* ^ constant.language */ - -bool f = false; -/* ^ constant.language */ - -int* p = nullptr; -/* ^ constant.language */ - -char ch[] = __func__; -/* ^ constant.language */ - + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Support Constants +// Storage Keywords ///////////////////////////////////////////// -std::cout << __FILE__ << '\n'; -/* ^ support.constant */ -/* ^^ punctuation.accessor */ - -std :: cout << __FUNCTION__ << '\n'; -/* ^^ punctuation.accessor */ -/* ^ support.constant */ - -std::cout << __LINE__ << '\n'; -/* ^ support.constant */ + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Numeric Constants +// Functions ///////////////////////////////////////////// -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1'924'013; -/* ^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec3 = 124ul; -/* ^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec4 = 9'204lu; -/* ^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec5 = 2'354'202'076LL; -/* ^^^^^^^^^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct1 = 0123_567; -/* ^^^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct2 = 014'70; -/* ^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0X1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex3 = 0x1234567890abcdef; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex4 = 0xA7'45'8C'38; -/* ^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex5 = 0x0+0xFL+0xaull+0xallu+0xfu+0xf'12_4_uz; -/* ^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic - constant.c++ */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -bin1 = 0b010110; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin2 = 0B010010; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin3 = 0b1001'1101'0010'1100; -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1'843'290.245'123; -/* ^^^^^^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 2'837e1'000; -/* ^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 23e-1'000; -/* ^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ constant.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ + test(5, 10, 15, 20); +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.c + test( +// ^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.c++ + ); +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Functions +// Control Flow ///////////////////////////////////////////// -// function prototype -void abcdWXYZ1234(); -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -// function definition -void abcdWXYZ1234() -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -struct foo **alloc_foo(); -/* ^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -long func -/* ^^^^ meta.function entity.name.function */ -(int x, void *MYMACRO(y) ) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ -entity.name.function */ -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^ meta.group meta.function-call meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end */ - // Ensure < and > aren't parsed as a generic - if (foo < bar && baz > bar ) { -/* ^ keyword.operator.comparison */ -/* ^ keyword.operator.comparison */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - } - if (version.major == 10 && version.minor < 11) -/* ^ keyword.operator.comparison */ - { - - } -} -/* <- meta.function meta.block punctuation.section.block.end */ - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} - -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - struct Args { -/* ^^^^^^ keyword.declaration.struct.type */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - Args() -/* ^ entity.name.function.constructor */ - : hellp(nullptr), -/* ^ punctuation.separator.initializer-list */ - foobar(nullptr) - { + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c++ +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c++ +// ^ punctuation.section.group.end.c +// ^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^ punctuation.section.block.end.c + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.c +// ^ keyword.operator.ternary.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a > b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } - }; - - struct Args args2; -/* ^^^^^^ keyword.declaration */ -/* ^ - entity */ - - class LocalFoo MYMACRO -/* ^^^^^ keyword.declaration.class */ -/* ^ entity.name.class */ -/* ^ - entity */ - { - LocalFoo() {} -/* ^ entity.name.function.constructor */ +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c++ +// ^ punctuation.separator.c++ + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c } - - class LocalFoo test; -/* ^^^^^ keyword.declaration.class */ -/* ^ - entity */ - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -/* A comment. */ void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -// prevent leading comment from function recognition -/**/ HRESULT A::b() -/* ^ meta.function */ -/* ^ entity.name.function */ -{ - return S_OK; -} -FooBar::FooBar(int a) -/*^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ punctuation.section.group.end */ -{ -} - -FooBar :: FooBar(int a) & = -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.operator */ -/* ^ keyword.operator.assignment */ -default; -/*^^^^^ meta.function storage.modifier */ - -FooBar::~FooBar -/*^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ -() { } -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ - /* <- meta.function.parameters meta.group punctuation.section.group.end */ -/*^^^^ meta.function */ - -ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath:: - ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath() -/* <- meta.function meta.toc-list.full-identifier */ - : var_name(nullptr) { -} - -bool FooBar::operator==() {} -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^^^^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - -myns::FooBar::~FooBar() { } -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ - - extern "C" void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if 0 -void test_in_extern_c_block() -/* ^ comment.block */ -{ -} -#else - -/* temporary C++ preprocessor block */ -#ifdef __cplusplus -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -# ifndef _Bool -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ -/* ^ keyword.declaration */ -/* ^ entity.name.type.typedef */ -# endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -#endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - -void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ -#endif - -#ifdef __cplusplus -} -#endif -/* ^ - meta.extern-c */ - -gener func_returning_generic(int a); -/* ^ entity.name.function */ - -std::vector func_returning_path_generic(int a); -/* ^ punctuation.definition.generic */ -/* ^ entity.name.function */ - -void f() -{ - static_assert(false, "oops"); - /* ^ keyword.operator.word */ -} - -long double operator "" _km (long double x); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^^^^^^^^^^^^^ entity.name.function */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Namespace +// Data Structures ///////////////////////////////////////////// -namespace myNameSpace {} -/* <- keyword.control */ -/* ^ entity.name.namespace */ - -namespace new_name = current_name; -/* <- keyword.control */ - -using namespace NAME __attribute__((visibility ("hidden"))); -/* <- keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ - -void func() { - using namespace NAME __attribute__((visibility ("hidden"))); -/* ^ keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ -} - -using namespace -/* <- keyword.control */ -/* ^ keyword.control */ - -using namespace myNameSpace; -/* <- keyword.control */ -/* ^ keyword.control */ - -namespace ns :: abc /* Neither this comment... */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace */ -/* ^^^^^^^^^ entity.name.namespace */ -/* ^^ punctuation.accessor */ -/* ^ comment.block */ -// ...nor this comment is highlighted -/* <- comment.line */ -{ -/* <- meta.namespace meta.block punctuation.section.block.begin */ - void nsfunc() { - /* ^ entity.name.function */ - } -} -/* <- meta.namespace meta.block punctuation.section.block.end */ - -namespace tl { -/*^^^^^^^^^^^^ meta.namespace */ -/* ^ keyword.control */ - namespace { -/* ^ keyword.control */ -/* ^^^^^^^^^^^ meta.namespace meta.namespace */ -/* ^ meta.block meta.block punctuation.section.block.begin */ - void nested_func(){} -/* ^ entity.name.function */ + struct A; enum B; union C; +// ^^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ entity.name.class.c++ + { +//^^^ meta.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a1; +//^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^ meta.brackets.square.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.c +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ keyword.declaration.enum.c++ +// ^ punctuation.terminator.c +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + void* ptr; +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } -} - -MACRONAME namespace ns3 {} -/* ^ keyword.control */ - -extern "C++" -// ^ storage.modifier -// ^^^^^ string.quoted.double -{ -namespace std _GLIBCXX_VISIBILITY(default) -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace -// ^ keyword.control -// ^ entity.name.namespace -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call -// ^^^^^^^^^ meta.group -// ^ keyword.control -{} -} - -#define MY_NAMESPACE_BEGIN namespace greatapp { -#define MY_NAMESPACE_END } -MY_NAMESPACE_BEGIN -class X { -private: -/* <- storage.modifier */ - int a; -protected: -/* <- storage.modifier */ - int b; -public: -/* <- storage.modifier */ - int c; -}; -MY_NAMESPACE_END - -MY_NAMESPACE_BEGIN int foo(); MY_NAMESPACE_END -/* ^ storage.type */ -/* ^ meta.function entity.name.function */ -/* ^^^ punctuation */ - -// Uncomment this some day -// MY_NAMESPACE_BEGIN class X : public std::true_type {}; MY_NAMESPACE_END +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^ keyword.operator.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Classes, structs, unions and enums +// Attributes and Declspec ///////////////////////////////////////////// -class BaseClass; -/*^^^^^^^^^^^^^ meta.class */ -/* ^ - meta.class meta.class */ -/* ^^^^^^^^^ entity.name.class.forward-decl */ - -class BaseClass // comment -/* <- keyword.declaration */ -/* ^ entity.name.class */ -{ -public : -/* <- storage.modifier */ - tupleTmpl max(tupleGen a, tupleGen b); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -protected: -/* <- storage.modifier */ -private: -/* <- storage.modifier */ - - static int a = 1 << 4; - /* <- storage.modifier */ - /* ^^ keyword.operator.arithmetic */ - - static int x; - /* <- storage.modifier */ - - virtual void doSomething() const = 0; - /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /* ^ - meta.method meta.method */ - /* ^^ meta.method.parameters meta.group */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* <- storage.modifier */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ meta.number */ - - template - void func(){} -/* ^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/* ^^^^ entity.name.function */ - - template - void func(){} -/* ^^^^^^^^^^^ meta.method */ -/* ^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - template - BaseClass(){} -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ meta.method.constructor */ -/* ^^^^^^^^^ entity.name.function */ - - ~BaseClass() {} -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^ meta.method.destructor */ -/* ^^^^^^^^^^ entity.name.function */ - - BaseClass operator [] () -/* ^^^^^^^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^^^^^^^^^^ entity.name.function */ - {} - - BaseClass operator= -/* ^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ entity.name.function */ - () {} -/* ^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^ meta.block */ -}; - -class DerivedClass : public ::BaseClass // Comment -/* ^ entity.other.inherited-class */ -/* ^ comment.line */ -{ - ~DerivedClass() override; - /* <- meta.method.destructor */ - /*^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /*^^^^^^^^^^^ meta.method.destructor */ - /* ^ storage.modifier */ - virtual void doSomething() const override final; - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - protected: -/*^^^^^^^^ storage.modifier */ - DerivedClass() override -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/*^^^^^^^^^^^^ meta.method.constructor */ -/* ^ storage.modifier */ - : a(a), -/* ^^^^^^^ meta.method.constructor.initializer-list */ - base_id_(BaseClass::None().ToInt()), -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ -/* ^ variable.other.readwrite.member */ -/* ^ punctuation.accessor */ -/* ^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^ variable.function */ -/* ^ punctuation - meta.method-call */ -/* ^^^^^^^ meta.method-call */ -/* ^^^^^ variable.function */ -/* ^ punctuation.separator */ - bounds_(NULL), -/* ^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - bit_field_(0) { -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - char * a = "sprintf"; - char * b = sprintf("Testing %s", a); -/* ^^^^^^^^^ meta.function-call */ -/* ^^^^^^^ support.function.C99 */ - - base_id_->foobar(1, "foo"); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^ variable.function */ - - base_id_->~BaseClass(); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^^^^^ variable.function */ - } -/* ^ meta.method meta.block punctuation.section.block.end */ - -/* <- - meta.class.constructor.initializer-list */ - - typedef std::vector qux; -/* ^^^ entity.name.type.typedef */ -}; - - -template -class class1 : class2 -/* ^^^^^^ entity.name.class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -/* ^^^^^^ entity.other.inherited-class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -{} - -class FooBar { -/* ^ meta.class meta.block punctuation.section.block.begin */ - explicit FooBar(int a); -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^ storage.modifier */ -/* ^^^^^^ entity.name.function */ - FooBar() =default; -/* ^^^^^^ entity.name.function */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - FooBar(void) =default; -/* ^^^^^^ entity.name.function */ -/* ^^^^ storage.type */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - - // If a constructor name is on a line without the opening (, it is not - // highlighted as a method/constructor. This prevents a bunch of false - // positives, including data types as they are being typed into a struct. - FooBar -/* ^ - entity.name.function */ - (); - - virtual ~FooBar(); -/* ^^^^^^^ entity.name.function */ - -#ifndef DEBUG - ~FooBar(); -/* ^^^^^^^ entity.name.function */ -#endif - - void insert () {} -/* ^^^^^^ entity.name.function */ - - explicit operator bool -/* ^^^^ entity.name.function */ - () {} - - FooBar::~FooBar(); -/* ^^^^^^^^^^^^^^^ entity.name.function */ - - void FooBar:: - Baz() { - /* <- entity.name.function */ - } - - auto f(int a) -> decltype(a.begin()) override final; -/* ^^ punctuation.separator */ -/* ^ punctuation.accessor */ -/* ^^^^^ variable.function */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - - auto g() -> std::vector override final { -/* ^^ punctuation.separator */ -/* ^^ punctuation.accessor */ -/* ^ storage.type */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - this->g(1); -/* ^ variable.language */ - } - -private: -/*^^^^^ storage.modifier */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - myns::subns::MyDataType -/* ^ - entity.name.function */ - and_now_method_name(); -/* ^ entity.name.function */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - std::shared_future> -/* ^ - entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ - and_now_method_name2(); -/* ^ entity.name.function */ - - enum { - FOO, - /* ^^^ entity.name.constant.c++ */ - /* ^ punctuation.separator.c++ */ - BAR - /* ^^^ entity.name.constant.c++ */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c }; - - enum -/* ^^^^ meta.enum keyword.declaration */ - { -/* ^ meta.enum punctuation.section.block.begin */ - A = 1, -/* ^ entity.name.constant.c++ */ -/* ^ punctuation.separator.c++ */ - B = 20 / 5, -/* ^ entity.name.constant.c++ */ -/* ^ punctuation.separator.c++ */ - C = FOO -/* ^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^ - entity.name */ - } -/* ^ meta.enum punctuation.section.block.end */ -/* ^ - meta.enum */ - - friend int func(int a, int b); -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ - entity.name.function */ -/* ^ - meta.function-call */ - - friend int func(int a, int b) { -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ entity.name.function */ -/* ^ - meta.function-call */ -/* ^ meta.class meta.block meta.method meta.block punctuation.section.block.begin */ - int a = 1; - } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ - - friend class ::FooBar; -/* ^ storage.modifier */ -/* ^ keyword.declaration -/* ^^ punctuation.accessor */ -/* ^ - entity */ - - friend bool operator != (const X& lhs, const X& rhs) { - /* ^^^^^^^^^^^ entity.name.function */ - int a = 1; - } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ - - #if 0 - /* ^ meta.number */ - int disabled_func() { - /* ^ comment.block */ +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } - #endif +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin - #if 1 - /* ^ meta.number */ - int enabled_func() {} - /* ^ entity.name.function */ - #else - int disabled_func() { - /* ^ comment.block */ } - #endif - - MACRO_NOT_CONSTRUCTOR(FooBar); -/* ^ meta.function-call variable.function - entity.name.function */ - - MACRO_NOT_CONSTRUCTOR2(FooBar, -/* ^ meta.function-call variable.function - entity.name.function */ - FriendClass); -} -/* <- meta.class meta.block punctuation.section.block.end */ - /* <- - meta.class meta.block */ - -struct X { - Y f() override noexcept final; - /*^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class X { - public: - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -union Y { - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class Child : public Parent { - ::anotherClass Func() override; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ -} - -class Adapter2 : public Abstraction, private Scenario { -/* ^ punctuation.separator */ -} - -class Adapter : public Abstraction - #if defined ASPECTO_MACRO -/* ^^^ keyword.control.import */ - , public Scenario -/* ^ punctuation.separator */ -/* ^ storage.modifier */ -/* ^ entity.other.inherited-class */ - #endif -/* ^^^^^^ keyword.control.import */ -{ - -} - -struct Base {}; -class Derived final : Base {}; -/* ^ storage.modifier */ -struct Derived final : Base {}; -/* ^ storage.modifier */ - -/* C++11 "uniform initialization" in initializer lists */ -class Foo { -public: - Foo() : var1(1), var(2), var3{3}, var4(4) {} - /* ^ meta.method.constructor.initializer-list */ - /* ^ - meta.function-call - variable.function */ -private: - int var1, var2, var3, var4; -}; - -class X { - int a, b, i, j; -public: - const int& r; - X(int i) - : r(a) // initializes X::r to refer to X::a - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , b{i} // initializes X::b to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , i(i) // initializes X::i to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j(this->i) // initializes X::j to the value of X::i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j - /*^ variable */ - (this->i) - /* <- meta.method.constructor.initializer-list punctuation */ - { } -/* ^ punctuation - meta.method.constructor.initializer-list */ -/* ^ punctuation - meta.method.constructor.initializer-list */ -}; - -struct A { - static_assert(0 < 1, ""); - /* ^ keyword.operator.word */ - /* ^ meta.function-call */ - /* ^ keyword.operator.comparison */ - - A(); -/*^ meta.method.constructor entity.name.function.constructor */ - - void f(); - /* ^ storage.type */ - /* ^ meta.method entity.name.function */ - /* ^ punctuation.terminator */ -}; -/* <- punctuation.section.block.end - invalid.illegal */ - -struct bar { -/*^^^^^^^^^^ meta.struct */ -/*^^^^ keyword.declaration */ -/* ^^^ entity.name.struct */ -/* ^ meta.block punctuation.section.block.begin */ - bar() -/* ^^^^^ meta.method */ -/* ^^^ entity.name.function */ - {} -} -/* <- meta.struct meta.block punctuation.section.block.end */ - /* <- - meta.struct meta.block */ - -enum baz { -/*^^^^^^^^ meta.enum */ -/* <- meta.enum keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ meta.block punctuation.section.block.begin */ - FOO = 1, -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAR = 2, - BAZ = 3, -#if 0 -/* ^ meta.number */ - QUX = 4, -/* ^ comment.block */ -#endif -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; - -enum class qux : std::uint8_t -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/*^^^^^^^^ keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ punctuation.separator */ -/* ^^^^^^^^^^^^ entity.other.inherited-class */ -{ -/* <- meta.block punctuation.section.block.begin */ - FOO = 1, - BAR = 2, -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAZ = 3 -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -typedef enum class funky -/*^^^^^ keyword.declaration */ -/* ^^^^^ entity.name.enum */ -{ - BAZ = 3 -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Funky; - -typedef enum -/*^^^^^ keyword.declaration */ -{ - FOO = 1, - BAR = 2, - BAZ = 3 -/* ^^^ entity.name.constant.c++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Fun; - -enum LineEnding : uint32_t; -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/* ^^^^^^^^^^ entity.name.enum.forward-decl */ -/* ^ punctuation.separator */ -/* ^^^^^^^^ entity.other.inherited-class */ -/* ^ - meta.enum */ - -union foobaz { -/* <- meta.union keyword.declaration */ -/* ^^^^^^ entity.name.union */ -/* ^ meta.block punctuation.section.block.begin */ -} -/* <- meta.union meta.block punctuation.section.block.end */ - /* <- - meta.union meta.block */ - -// Class name that looks like a possible macro -class SP {} -/* ^^ entity.name.class */ - -class MyClass MACRO MACRO2 -/* ^ keyword.declaration */ -/* ^ entity.name.class */ -/* ^ - entity */ -/* ^ - entity */ -{} - -// Class using macro to handle __declspec() on Windows -class SK_API SkBitmap {} -/* ^ entity.name.class */ -class __declspec(property(get=foo)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ variable.parameter */ -/* ^ entity.name.class */ -class __declspec(align(8)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ meta.number */ -/* ^ entity.name.class */ -class __declspec(dllimport) SkBitmap {} -/* ^ constant.other */ -/* ^ entity.name.class */ - -// Make sure not to match macros that have "too few characters". -template class Sample { - public: - // The T here should not be consumed as a macro. - T operator() (const foo x) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - int operator == (const int x) { - /*^^^^^^^^^^^ entity.name.function */ - return 0; - } - // The T here should not be consumed as a macro. - T operator()(int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - // The T here should not be consumed as a macro. - T operator[](int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } -}; - -class Namespace::MyClass MACRO1 MACRO2 : public SuperClass -/* ^^^^^^^ entity.name.class */ -/* ^^ punctuation.accessor */ -/* ^ - entity.name */ -{ -}; - -struct Namespace::MyStruct -/* ^^^^^^^^ entity.name.struct */ -/* ^^ punctuation.accessor */ -{ -}; - -union Namespace::MyUnion -/* ^^^^^^^ entity.name.union */ -/* ^^ punctuation.accessor */ -{ -}; - -enum class Namespace::MyEnum -/* ^^^^^^ entity.name.enum */ -/* ^^ punctuation.accessor */ -{ - BAR = 1, -/* ^^^ entity.name.constant.c++ */ -}; - -class Namespace:: -MyClass MACRO1 -/* <- entity.name.class */ -/* ^ - entity.name */ -{ -}; - -struct Namespace:: -MyStruct MACRO1 -/* <- entity.name.struct */ -/* ^ - entity.name */ -{ -}; - -union Namespace:: -MyUnion MACRO1 -/* <- entity.name.union */ -/* ^ - entity.name */ -{ -}; - -enum class Namespace:: -MyEnum MACRO1 -/* <- entity.name.enum */ -/* ^ - entity.name */ -{ -}; - +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Preprocessor ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[], bool val3 = false) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -/* ^ punctuation.separator */ -/* ^^^^ storage.type */ -/* ^^^^ variable.parameter */ -/* ^ keyword.operator.assignment */ -/* ^^^^^ constant.language */ -{ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result == 0) { - return 0; -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifndef DEBUG - if (check_debug()) { - val /= 2; -#endif - val += 1; -#ifndef DEBUG - } -/* ^ meta.function meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ -#endif - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -#if 0 -/* ^ meta.number */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 -/* ^ meta.number */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number */ - int b = 2; -/* ^ comment.block */ + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c++ +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.separator.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c #else - int c = 3; - #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ - -///////////////////////////////////////////// -// Matching various function definitions -///////////////////////////////////////////// - -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ entity.name.function */ -(int * a) -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ punctuation.section.group.end */ -{ - -} - -void MyClass3:: -foo() { -/* <- entity.name.function */ -} - -MyClass3:: -~MyClass3() { -/* <- entity.name.function */ -} - -struct A -{ - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ +//^^^^^^^ keyword.control.import.c #endif - - void f() - { - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ - #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + # +// ^ keyword.control.c + #embed "file.txt" if_empty(0) +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ keyword.other.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c + + + "Hello {}!"_literal +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + 'h'_literal +// ^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + R"RAW( +// ^^^^^^ string.quoted.raw.c++ +// ^ storage.type.string.c++ +// ^ punctuation.definition.string.begin.c++ +// ^^^^ constant.other.placeholder.c++ + raw string )STR" +//^^^^^^^^^^^^^^^^^^ string.quoted.raw.c++ + )RAW"_literal +//^^^^^^^^^^^^^^^ string.quoted.raw.c++ +// ^^^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + + using std::cout; +// ^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^ entity.name.using.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.terminator.c + using namespace std; +// ^^^^^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.namespace.c++ +// ^ punctuation.terminator.c + + and and_eq or or_eq not not_eq xor xor_eq bitand bitor compl +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^ keyword.operator.logical.c++ +// ^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ + delete new typeid noexcept <=> +// ^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.word.c++ +// ^^^^^^ keyword.operator.word.c++ +// ^^^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.comparison.c++ + + constexpr consteval constinit +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ + wchar_t wchar8_t wchar16_t wchar32_t +// ^^^^^^^ storage.type.c++ +// ^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ + + enum class Test { +// ^^^^^^^^^^^^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^^^^^ keyword.declaration.class.c++ +// ^^^^ entity.name.enum.c +// ^ punctuation.section.block.begin.c + A = 314, +//^^^^^^^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + B, +//^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ punctuation.separator.c + }; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + namespace std::mynamespace { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ +// ^^^^^^^^^ keyword.declaration.namesace.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.namespace.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.block.c++ punctuation.section.block.begin.c++ + std::vector const& func(std::string const& a, std::function b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + template auto func(char param1, int param2 = f(20) - g(20)) const -> decltype(T::func(param)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ variable.function.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + try { +//^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + throw ns::func(param2); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^ keyword.control.exception.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^^^^ meta.function.c +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } catch (std::exception const& e) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^ keyword.control.exception.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_await func +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ + (e); +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + } finally { +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_yield func(param1); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ +// ^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end.c + + co_return 7; +//^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^^^^^^^ keyword.control.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c } - - void f() - { - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ +//^^^ meta.namespace.c++ meta.block.c++ +// ^ punctuation.section.block.end.c++ + + class Type; +// ^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + + template class V, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.separator.c + typename ...Args> requires std::same_as, std::string> +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^^^ keyword.operator.variadic.c +// ^^^^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ + struct MACRO Type> MACRO final : D> { +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^^^^^ entity.other.inherited-class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + private: +//^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ + alignas(20) std::string m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + protected: +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^ storage.modifier.c++ + int m_value2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + friend class V; +//^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + friend void someFunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + public: +//^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ + Type() && : m_value1("a"), m_value2(10); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.initializer-list.c++ +// ^ punctuation.separator.initializer-list.begin.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^ meta.group.c +// ^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.separator.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.group.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + ~Type() = default; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^^ keyword.control.c +// ^ punctuation.terminator.c + explicit Type(int) = delete; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ storage.type.c +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^ keyword.operator.word.c++ +// ^ punctuation.terminator.c + + template <> +//^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^ punctuation.section.generic.end.c++ + std::string const& doThing() const requires requires(std::tuple a) { a.get<0>().runThing(); } { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +//^^^^^^ meta.template.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.requires.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ keyword.operator.variadic.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.definition.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return this->m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^ variable.language.c++ +// ^^ punctuation.accessor.dot.c +// ^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + }; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + export { +// ^^^^^^ keyword.other.c++ +// ^ meta.block.c punctuation.section.block.begin.c + class A : protected A, private B, public C { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.c++ +// ^^ entity.other.inherited-class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + virtual void vfunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ storage.type.c +// ^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + bool operator ==(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + int operator<=>(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + unsigned long long operator ""_label(unsigned long long a) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c } -}; - -void f() -{ - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ -} - -void f() -{ - #ifdef X - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ - #endif -} - -Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/); -/* ^^^^^^^^^ comment */ - -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + void A::vfunc() { +// ^^^^ storage.type.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + auto lambda = [=] mutable -> std::string { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return "test"; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + ([&, this, lambda](int a, char b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.separator.c +// ^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^^^^^^ meta.template.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + + })(5, 10); +//^^^^^^^^^^^^^^^^ meta.block.c +//^^^^^^^^^^^^^^^ meta.group.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + auto somestruct = { +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.block.c punctuation.section.block.begin.c + .thing = 5, "200", .other = lambda +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.separator.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c } - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() -{ - -} - -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -int& return_type_ref_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ - -///////////////////////////////////////////// -// Paths/identifiers -///////////////////////////////////////////// - -void sayHi() -{ - std::cout << "Hi!\n"; -/* ^ punctuation.accessor */ - Print(3); -/* ^ variable.function */ - func_call(foo -/* ^ meta.function-call */ - ); - - if (::std::foo()) {} -/* ^^^ variable.function */ -/* ^^ punctuation.accessor */ -/* ^^ punctuation.accessor */ - - foobaz(); -/* ^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<>(); -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<0>(); -/* ^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - ::myns::foo(); -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ storage.type */ - - myns::FooClass{42}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ - - ::myns::BarClass{}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ -/* ^^^ storage.type */ - - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ - - std::cout << ">> Hi!\n"; -/* ^^ keyword.operator.arithmetic.c */ -} - -///////////////////////////////////////////// -// Includes -///////////////////////////////////////////// - -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -/** - * -/* ^ comment.block.documentation.c punctuation.definition.comment.c */ - -///////////////////////////////////////////// -// Modules -///////////////////////////////////////////// - -export module AA; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export module A.B; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ - -export module A.BB.C.D; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^^^^^^ entity.name.module.c++ */ - -export module ABC:DE; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^ entity.name.partition.other */ - -module ABC; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -module :private; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^^^ entity.name.partition.private */ - -import A; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ entity.name.module.c++ */ - -import :B; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^ entity.name.partition.other */ - -import "ABC"; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^ meta.module.import.c++ string.quoted.double.import.c++ */ -/* ^ punctuation.definition.string.begin.c++ */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.terminator.c++ */ - -import ; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^ meta.module.import.c++ string.quoted.other.lt-gt.import.c++ */ -/* ^ punctuation.definition.string.begin */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.terminator.c++ */ - -import "ABC/BCD.h"; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^^^^^^ meta.module.import.c++ string.quoted.double.import.c++ */ -/* ^ punctuation.definition.string.begin.c++ */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.terminator.c++ */ - -// Doesn't break grammar when missing semi-colon. -export module ABC:d -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^ entity.name.partition.other */ - -// Doesn't break grammar when missing semi-colon. -export import ABC:d -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^ entity.name.partition.other */ - -module .test.module; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^^^^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -import .test.module; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^^^^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -module test : part1:part2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -module abc.def.:part1:part2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^^^^ entity.name.module.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -module test. -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^^ entity.name.module.c++ */ -/* ^ - invalid.illegal.unexpected-character.c++ */ - -module test. ; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^^^^ entity.name.module.c++ */ -/* ^^ invalid.illegal.unexpected-character.c++ */ -/* ^ punctuation.terminator.c++ */ - -import :part1:part2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -module :private:test2; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^^^ entity.name.partition.private */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ - -import .test.module; import ABD; -/* <- meta.module.c++ keyword.control.c++ */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^^^^^^ source.c++ */ -/* ^ punctuation.terminator.c++ */ -/* ^^^^^^ meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export module ABC:test1:test2; import DEF; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^^ - entity.name.partition.other */ -/* ^ punctuation.terminator.c++ */ -/* ^^^^^^ meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export module ABC:test1:test2 import DEF; -/* <- keyword.control.c++ */ -/* ^^^^^^ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.accessor.c++ */ -/* ^^^^^ entity.name.partition.other */ -/* ^ invalid.illegal.unexpected-character.c++ */ -/* ^^^^^ - entity.name.partition.other */ -/* ^^^^^^ meta.module.c++ keyword.control.c++ */ -/* ^^^ entity.name.module.c++ */ -/* ^ punctuation.terminator.c++ */ - -export { -/* <- keyword.control.c++ */ -/* ^ meta.block.c++ punctuation.section.block.begin.c++ */ - void test(); -/* ^^^^ meta.block.c++ storage.type.c */ -/* ^^^^ meta.block.c++ meta.function.c++ entity.name.function.c++ */ - void test2(); -/* ^^^^ meta.block.c++ storage.type.c */ -/* ^^^^^ meta.block.c++ meta.function.c++ entity.name.function.c++ */ -} -/* <- meta.block.c++ punctuation.section.block.end.c++ */ - -export void test3(); -/* <- keyword.control.c++ */ -/* ^^^^ storage.type.c */ -/* ^^^^^ meta.function.c++ entity.name.function.c++ */ - -export -/* <- keyword.control.c++ */ -template -/* <- meta.template.c++ keyword.declaration.template.c++ */ -void test4() -{ - return; -} - -///////////////////////////////////////////// -// Concepts -///////////////////////////////////////////// - -template -/* <- meta.template.c++ keyword.declaration.template.c++ */ -concept has_foo = requires(T t) { -/* <- meta.concept.c++ keyword.declaration.concept.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ */ -/* ^^^^^^^ meta.concept.c++ entity.name.concept.c++ */ -/* ^^^^^^^^^^^^^^^ meta.concept.c++ meta.constraint.c++ */ -/* ^^^^^ meta.function.parameters.c++ */ -/* ^ meta.function.c++ meta.block.c++ */ - t.foo(); -/* ^^^^^^^^ meta.concept.c++ meta.constraint.c++ meta.function.c++ meta.block.c++ */ -} && std::move_constructible; -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ meta.constraint.c++ */ - -template -/* <- meta.template.c++ keyword.declaration.template.c++ */ -void foo() requires std::same_as -/* <- storage.type.c */ -/* ^^^ meta.function.c++ entity.name.function.c++ */ -/* ^^^^^^^^ meta.function.c++ meta.constraint.c++ storage.modifier.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.function.c++ meta.constraint.c++ */ -{ - return; -} - -template requires std::same_as -/* <- meta.template.c++ keyword.declaration.template.c++ */ -/* ^^^^^^^^ meta.constraint.c++ storage.modifier.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.constraint.c++ */ -void bar() -/* <- storage.type.c */ -/* ^^^ meta.function.c++ entity.name.function.c++ */ -{ - return; -} - -#define GTY0 -/* ^^^^ meta.preprocessor.macro.c++ */ -#define GTY1(A) -/* ^^^^ entity.name.function.preprocessor */ -/* ^^^ meta.preprocessor.macro.parameters */ -#define GTY2(A, B) -/* ^^^^ entity.name.function.preprocessor */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ - -struct GTY0 foo { -/*<- keyword.declaration.struct.type.c++ */ -/* ^^^^ meta.assumed-macro */ -/* ^^^ entity.name.struct.c++ */ -}; - -struct GTY1(42) bar { -/*<- keyword.declaration.struct.type.c++ */ -/* ^^^^ meta.function-call.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^^^ entity.name.struct.c++ */ -}; - -enum GTY1("struct") baz { -/*<- keyword.declaration.enum.type.c++ */ -/* ^^^^ meta.function-call.c++ */ -/* ^^^^^^^^ string */ -/* ^^^ entity.name.enum.c++ */ -}; - -union GTY2("union struct", 42) bazz { -/*<- keyword.declaration.union.type.c++ */ -/* ^^^^ meta.function-call.c++ */ -/* ^^^^^^^^^^^^^^ string */ -/* ^^ constant.numeric.value.c++ */ -/* ^^^^ entity.name.union.c++ */ -}; - -class GTY2("struct class", 42) bazzz { -/*<- keyword.declaration.class.c++ */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ entity.name.class.c++ */ -}; +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + A::~A() { +// ^^ punctuation.accessor.double-colon.c++ +// ^^ variable.function.c++ +// ^ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + delete this; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.operator.word.c++ +// ^^^^ variable.language.c++ +// ^ punctuation.terminator.c + } +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + template +// ^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ + concept MyConcept = std::same_as || requires(T a) { something(a) == 0; }; +//^^ meta.template.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ entity.name.concept.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^ keyword.operator.assignment.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + export module test.module:part; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + module test.module:part; +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + import test.module:part; +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^ keyword.other.import.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index dc588831d9..10c7b1c0bd 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -172,11 +172,6 @@ contexts: 1: keyword.operator.bitwise.objc branch_point: block branch: [block, pop-immediately] - - match: '(@catch)\s*(\()' - captures: - 1: keyword.control.exception.objc - 2: punctuation.section.group.begin.objc - push: function-params - include: protocol-list call-try-not: @@ -244,6 +239,11 @@ contexts: - meta_prepend: true - match: \@(?:autoreleasepool|import|synchronized)\b scope: keyword.control.objc + - match: '(@catch)\s*(\()' + captures: + 1: keyword.control.exception.objc + 2: meta.group.objc punctuation.section.group.begin.objc + push: function-params - match: \@(?:try|catch|finally|throw)\b scope: keyword.control.exception.objc keyword.storage: @@ -313,12 +313,12 @@ contexts: - meta_prepend: true - include: message-enclosure - match: '@\{' - scope: punctuation.section.mapping.begin + scope: punctuation.section.mapping.begin.objc push: enclosure.mapping enclosure.mapping: - meta_scope: meta.mapping.objc - match: \} - scope: punctuation.section.mapping.end + scope: punctuation.section.mapping.end.objc pop: 1 - include: expression @@ -329,7 +329,7 @@ contexts: pre-message: - match: \[ - scope: meta.brackets.square.objc punctuation.section.brackets.begin + scope: meta.brackets.square.objc punctuation.section.brackets.begin.objc set: message message: - meta_scope: meta.bracketed.objc diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 524a60c85d..55a70df815 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -262,7 +262,7 @@ a,b = b.c; // ^ punctuation.separator.c // ^ keyword.operator.assignment.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^ variable.other.readwrite.member.c // ^ punctuation.terminator.c @@ -355,7 +355,7 @@ ///////////////////////////////////////////// [a, b, c] -// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc // ^^^^^^^^ meta.brackets.square.c // ^ punctuation.separator.c // ^ punctuation.separator.c @@ -598,9 +598,10 @@ int main(int argc, char const* argv[]) { // ^ punctuation.section.group.end // ^ variable.parameter.c ); -//^^ meta.function.parameters.c meta.group.c -// ^^ meta.function.c -// ^ punctuation.section.group.end.c +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c ///////////////////////////////////////////// // Control Flow @@ -797,22 +798,22 @@ void fun(int const a[]) { char a3[12]; //^^^^^^^^^^^^^^^^^^ meta.block.c // ^^^^ storage.type.c -// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc // ^^^ meta.brackets.square.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.section.brackets.end.c // ^ punctuation.terminator.c void* h5; -//^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ storage.type.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c enum B out; }; -//^^^^^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ keyword.declaration.enum.c -// ^ punctuation.terminator.c -// ^ punctuation.section.block.end -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ keyword.declaration.enum.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c union MACRO myUnion { // ^^^^^^^^^^^^^^^^^^^^^ meta.union.c @@ -850,16 +851,16 @@ void fun(int const a[]) { // ^ punctuation.section.block.end // ^ punctuation.terminator.c void* ptr; -//^^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ storage.type.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c int a, *ptr2; -//^^^^^^^^^^^^^^^^^^^ meta.block.c -// ^^^ storage.type.c -// ^ punctuation.separator.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c }; //^^^ meta.block.c // ^ punctuation.section.block.end @@ -878,9 +879,9 @@ int test() { // ^ punctuation.terminator.c myunion.s2.f = 20; //^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^^ variable.other.readwrite.member.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^ variable.other.readwrite.member.c // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c @@ -895,9 +896,9 @@ int test() { // ^^^^^^ keyword.declaration.struct.c // ^ meta.block.c punctuation.section.block.begin.c myCustomType* a; -//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c -// ^ keyword.operator.arithmetic.c -// ^ punctuation.terminator.c +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c } b; //^^^ meta.block.c // ^ punctuation.section.block.end @@ -957,59 +958,111 @@ int test() { // ^ punctuation.terminator.c void __declspec(dllimport) importedFn() const; -// ^^^^ storage.type.c -// ^^^^^^^^^^ storage.modifier.c -// ^^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^^ constant.other.c -// ^ punctuation.section.group.end.c -// ^^^^^^^^^^ entity.name.function.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ meta.function.c -// ^ punctuation.section.group.end.c -// ^^^^^ storage.modifier.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c __declspec(property(get=10, put=10)) void runForever(); -// ^^^^^^^^^^ storage.modifier.c -// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ storage.modifier.c -// ^ punctuation.section.group.begin.c -// ^^^ variable.parameter.c -// ^ keyword.operator.assignment.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.separator.c -// ^^^ variable.parameter.c -// ^ keyword.operator.assignment.c -// ^^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ punctuation.section.group.end -// ^ punctuation.section.group.end.c -// ^^^^ storage.type.c -// ^^^^^^^^^^ entity.name.function.c -// ^ punctuation.section.group.begin.c -// ^^ meta.function.c -// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c void on_load() __attribute__((constructor, visibility("hidden"))) {} -// ^^^^ storage.type.c -// ^^^^^^^ entity.name.function.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c -// ^ punctuation.section.group.end.c -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c -// ^^^^^^^^^^^^^ storage.modifier.c -// ^^ punctuation.section.group.begin.c -// ^^^^^^^^^^^ constant.other.c -// ^ punctuation.separator.c -// ^^^^^^^^^^^^^^^^^^^^ meta.group.c -// ^^^^^^^^^^ storage.modifier.c -// ^ punctuation.section.group.begin.c -// ^^^^^^^^ string.quoted.double.c -// ^ punctuation.definition.string.begin.c -// ^ punctuation.definition.string.end.c -// ^ punctuation.section.group.end -// ^^ punctuation.section.group.end.c -// ^ meta.function.c meta.block.c punctuation.section.block.begin -// ^ meta.block.c punctuation.section.block.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.objc punctuation.section.brackts.begin.objc +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c int a = // ^^^ storage.type.c @@ -1141,6 +1194,10 @@ int main(int argc, char const* argv[]) { // ^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.section.group.end.c +///////////////////////////////////////////// +// Objective-C +///////////////////////////////////////////// + #import @@ -1255,13 +1312,13 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c // ^^^^^^^^^^ storage.modifier.objc // ^^^^^^^^^^^^ support.class.cocoa.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ punctuation.terminator.c @private char* d; //^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c // ^^^^^^^^ storage.modifier.objc // ^^^^ storage.type.c -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ punctuation.terminator.c @package sample e; //^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c @@ -1272,6 +1329,7 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS @property(readwrite, nonatomic) IBOutlet NSButton* btn; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc //^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc // ^ punctuation.section.group.begin.objc // ^^^^^^^^^ storage.modifier.objc // ^ punctuation.separator.c @@ -1284,6 +1342,7 @@ @interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NS @property(readonly, getter=myGetE) IBInspectable sample e; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc //^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc // ^ punctuation.section.group.begin.objc // ^^^^^^^^ storage.modifier.objc // ^ punctuation.separator.c @@ -1372,10 +1431,10 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^^ storage.modifier.objc // ^^^^^^^^ support.class.cocoa.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ keyword.operator.assignment.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc -// ^ punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin // ^^^^^^^^ support.class.cocoa.objc // ^^^^^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc @@ -1394,7 +1453,7 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib //^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^ storage.modifier.objc // ^^^^^^^^ support.class.cocoa.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ keyword.operator.assignment.c // ^^^^ string.quoted.single.c // ^^ punctuation.definition.string.begin.objc @@ -1404,12 +1463,12 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^^^^^^^^^ storage.modifier.objc // ^^^^^^ support.class.cocoa.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ keyword.operator.assignment.c // ^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc -// ^ punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin // ^^^^^^^^^^^^^^ meta.bracketed.objc -// ^ punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin // ^^^^^^ support.class.cocoa.objc // ^^^^^ entity.name.function.method.objc // ^ punctuation.section.brackets.end.objc @@ -1425,9 +1484,9 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^^^^^^^ support.class.cocoa.objc // ^ keyword.operator.c // ^ punctuation.section.scope.end.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ keyword.operator.assignment.c -// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc @314.5, //^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c // ^ constant.numeric.objc @@ -1463,9 +1522,9 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib NSDictionary* g = @{ //^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c // ^^^^^^^^^^^^ support.class.cocoa.objc -// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.c // ^ keyword.operator.assignment.c -// ^^ meta.mapping.objc punctuation.section.mapping.begin +// ^^ meta.mapping.objc punctuation.section.mapping.begin.objc (__bridge id)kValue1 : (__bridge NSViewController)kValue2, //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc // ^^^^^^^^^^^^^ meta.group.c @@ -1580,9 +1639,9 @@ -(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attrib // ^^^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc // ^ punctuation.separator.arguments.objc // ^^^^ variable.language.objc -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^ variable.other.readwrite.member.c -// ^ punctuation.accessor.dot.c++ +// ^ punctuation.accessor.dot.c // ^^^^^^^^^^ variable.other.readwrite.member.c // ^ punctuation.section.brackets.end.objc // ^ punctuation.section.group.end From 84c04bc07d820a3d3bc6a809dc50d90847d006e9 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:35:44 -0600 Subject: [PATCH 57/66] Objective-C++ syntax tests --- C++/C++.sublime-syntax | 2 +- Objective-C/Objective-C++.sublime-syntax | 2 + Objective-C/syntax_test_objc++.mm | 5204 ++++++++++------------ 3 files changed, 2339 insertions(+), 2869 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 94c3a17e0c..3801ad6f0e 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -315,9 +315,9 @@ contexts: push: type.concept-body - include: else-pop type.concept-body: - - include: expression - match: (?=;|\)|\]|\}) pop: 1 + - include: expression enum-def: - match: \b(enum)(?:\s*(class))?\b diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index c78ab848b9..923f107d40 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -19,6 +19,8 @@ first_line_match: |- ) contexts: + protocol-list: + - include: template message-enclosure: [] enclosure: - meta_prepend: true diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index cecf257de1..a1c03afdab 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -1,2938 +1,2406 @@ /* SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" */ + // Comment +// ^^^^^^^^^^ comment.line.double-slash.c +// ^^ punctuation.definition.comment.c -// =Banner= -/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */ - -// = Banner = -/* ^^^^^^^^^^^ comment.line.banner.c */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.line.c */ -/* ^^^ - meta.toc-list */ - -// Comment // -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^ comment.line.double-slash.c punctuation.definition.comment.c */ - -//! Comment -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - -/// Comment /// -/* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /* <- comment.line.documentation.c punctuation.definition.comment.c */ - /*^^^^^^^^^ comment.line.documentation.c - punctuation */ - /* ^^^ comment.line.documentation.c punctuation.definition.comment.c */ - -//// Comment //// -/* <- comment.line.double-slash.c punctuation.definition.comment.c */ - /* <- comment.line.double-slash.c punctuation.definition.comment.c */ -/*^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */ - /* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */ -/* ^^ comment.line.double-slash.c - punctuation */ - -/* =Banner= */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^ comment.block.banner.c - punctuation */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - -/* = Banner = */ -/* <- comment.block.banner.c punctuation.definition.comment.begin.c */ -/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */ -/*^^^ - meta.toc-list */ -/* ^^^^^^ meta.toc-list.banner.block.c */ -/* ^^^^^ - meta.toc-list */ -/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */ - - /*****/ -/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */ - - /** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*** -/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*! -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ - - /*!**** -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c - punctuation */ - - /*!****/ -/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */ -/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */ - - /*! - * docstring - **/ -/* ^^^ comment.block.documentation.c */ + // My \ + Comment +//^^^^^^^^^ comment.line.double-slash.c - */ -/* ^^ invalid.illegal.stray-comment-end.c */ - - **/ -/* ^^^ invalid.illegal.stray-comment-end.c */ + /* Foo Bar Baz*/ +// ^^^^^^^^^^^^^^^^ comment.block.c +// ^^ punctuation.definition.comment.c +// ^^ punctuation.definition.comment.c -Task natural_numbers() -{ - int n = 0; - while (true) { - co_yield n; - /* ^ keyword.control */ - n++; - } -} -Task foo() -{ - co_return 42; - /* ^ keyword.control */ - /* ^ meta.number */ -} -Task bar() -{ - co_await natural_numbers(); - /* ^ keyword.control */ - /* ^ variable.function */ -} - -int main(){ - int a=5,b=0; - while(a-->0)++b; - /* ^^ keyword.operator.arithmetic */ - /* ^ keyword.operator.comparison */ - /* ^ meta.number */ - /* ^^ keyword.operator.arithmetic */ -} + */ +// ^^ invalid.illegal.stray-comment-end.c ///////////////////////////////////////////// -// Preprocessor +// Numbers ///////////////////////////////////////////// -#ifndef IGUARD_ - /* <- keyword.control.import */ -#define IGUARD_ - /* <- keyword.control.import.define */ -struct foo* alloc_foo(); -/* <- keyword.declaration */ - /* <- - entity.name.type */ - /* <- entity.name.function */ -#endif - /* <- keyword.control.import */ - -// The following example ensures that comments at the end of preprocessor -// directives don't mess with context transitions -int func() { -/* ^ entity.name.function */ - #if( EXTAL == 40000 ) /* 40 MHz */ -/* ^ keyword.control.import */ - #define PLL_RFD_PHI1 10 // PLL0_PH1 = 40MHz -/* ^ keyword.control.import */ -/* ^^ meta.number */ -/* ^ comment.line */ - #endif -/* ^ keyword.control.import */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - /* <- - meta.function meta.block */ - -int f(int x, \ - /* ^ punctuation.separator.continuation */ - int y); - -int g(int x = 5 \ - /* ^ punctuation.separator.continuation */ - , int y); - -#define MACRO_WITH_CURLY_BRACE { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -#define MACRO_WITH_CURLY_BRACE_2 } -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* <- keyword.control.import.define */ -/* ^ entity.name.constant */ - -FOOBAR -hello() { - /* <- meta.function entity.name.function */ - return 0; -} - -EFIAPI -UserStructCompare ( - /* <- meta.function entity.name.function */ - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - const USER_STRUCT *CmpStruct1; - /* <- meta.block storage.modifier */ - - CmpStruct1 = UserStruct1; - return KeyCompare (&CmpStruct1->Key, UserStruct2); - /* <- meta.block keyword.control */ - /* ^ meta.block meta.function-call variable.function */ -} - -LIB_RESULT -foo() -/* <- meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -LIB_RESULT bar() -/* ^ meta.function entity.name.function */ -{ - return LIB_SUCCESS; -} - -THIS_IS_REALLY_JUST_A_MACRO_AND_NOT_A_RETURN_TYPE -/* <- meta.assumed-macro */ - -int main() { -/* <- storage.type */ - /* ^ meta.function entity.name.function */ - return 0; -} - -// This is a method/function with the return type on a separate line and so should not be a -// constructor. -FOOLIB_RESULT -some_namespace::some_function(int a_parameter, double another_parameter) { - /* <- meta.function meta.toc-list.full-identifier */ - /* ^ entity.name.function - entity.name.function.constructor */ - return FOOLIB_SUCCESS; -} - -#pragma foo(bar, \ -"baz", \ -1) -/* <- meta.preprocessor */ - -#define MY_MACRO(a, b) -/*^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ -/* ^^^^^^ meta.preprocessor.macro.parameters */ -/* ^^^^^^^^ entity.name.function.preprocessor */ -/* ^ punctuation.section.group.end */ - -#define max(a, b, \ -/*^^^^^^^^^^^^^^^^^ meta.preprocessor.macro */ \ -/* ^^^^^^^^ meta.preprocessor.macro.parameters */ \ -/* <- keyword.control.import.define */ \ -/* ^ entity.name.function.preprocessor */ \ -/* ^ punctuation.section.group.begin */ \ -/* ^ variable.parameter */ \ -/* ^ punctuation.separator */ \ -/* */ \ -/* <- comment.block */ \ - c) ((a>b) ? (a>c?a:c) : (b>c?b:c)) - /* <- meta.preprocessor.macro meta.group variable.parameter */ - /* <- meta.preprocessor.macro meta.group punctuation.section.group.end */ - /* ^ keyword.operator.ternary */ - /* ^ keyword.operator.ternary */ - -#if 0 -#ifdef moo -/* <- - keyword.control */ -#endif -/* <- - keyword.control */ -#endif - -FOO() -/* <- meta.assumed-macro variable.function.assumed-macro */ -FOO -/* <- meta.assumed-macro */ - -struct FOO1 FOO2 FOO3 Test { - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - /* ^ meta.struct meta.assumed-macro */ - Test(); - Test() noexcept; - Test() final; - Test() noexcept final; - ~Test(); - ~Test() noexcept; - ~Test() override noexcept; - virtual ~Test(); - virtual ~Test() noexcept; - virtual ~Test() override noexcept; - DLL_API Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - DLL_API Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - DLL_API Test() noexcept final; - /* <- meta.assumed-macro */ - /* ^ meta.method.constructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API ~Test(); - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - DLL_API ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - DLL_API virtual ~Test(); - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - DLL_API virtual ~Test() noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - DLL_API virtual ~Test() override noexcept; - /* <- meta.assumed-macro */ - /* ^ storage.modifier */ - /* ^ meta.method.destructor */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -} - -struct X { - X(); - /* <- meta.group */ - /*^ meta.group - meta.group meta.group */ -}; - -#define DEPRECATED(msg) [[deprecated(msg)]] - -struct Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -}; - -namespace Test { - DEPRECATED("bla") - /* <- meta.assumed-macro variable.function.assumed-macro */ - bool foo (bool run=true) {} - /* ^ entity.name.function */ -} - -struct Test { -DEPRECATED("bla") -/* <- meta.assumed-macro variable.function.assumed-macro */ -bool foo (bool run=true) {} -/* ^ entity.name.function */ -}; + 1234567890 +// ^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + 1'234'567'890 +// ^^^^^^^^^^^^^ meta.number.integer.decimal.c constant.numeric.value.c + + 0x123456789abcdef +// ^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^ constant.numeric.value.c + 0x123'456'789'abc'def +// ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^^^^^^^^ constant.numeric.value.c + 012345670 +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c + 012'345'670 +// ^^^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^^^ constant.numeric.value.c + 0b100110 +// ^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^ constant.numeric.value.c + 0b100'110 +// ^^^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c + + 314lUJ 314uLLj 314iLu 314llI 314F 314f +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c +// ^^^^ meta.number.float.decimal.c +// ^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + 3.14f 314.l 3.14L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-15 +// ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c + 0xdead.beefp+7f +// ^^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 012345670 0314llU +// ^^^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^^^^^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + 0b10 0b10iLu +// ^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c + + 0271828 0b10410 0xbag50 314a123 +// ^^^^^^^ meta.number.integer.octal.c +// ^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^^ invalid.illegal.numeric.suffix.c + 314Ll 314lul 314iJ 314.ll 314.lf +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^^ constant.numeric.suffix.c +// ^^^^^ meta.number.integer.decimal.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ constant.numeric.suffix.c + 0x314.1p5af 0b10e20 +// ^^^^^^^^^^^ meta.number.float.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^^ invalid.illegal.numeric.suffix.c +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^ constant.numeric.value.c +// ^^^ invalid.illegal.numeric.suffix.c ///////////////////////////////////////////// -// Strings +// Operators ///////////////////////////////////////////// -char str1[] = "abc"; -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char8_t str2[] = u8"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char16_t str3[] = u"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char32_t str4[] = U"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -wchar_t str5[] = L"abc"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ - -char str6[] = "\a|\b|\e|\f|\n|\r|\t|\v|\'|\"|\?"; -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ -/* ^^ constant.character.escape */ - -char str7[] = "\0|\012"; -/* ^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ - -char str8[] = "\x0a|\x41|\xA|\x000065"; -/* ^^^^ constant.character.escape */ -/* ^^^^ constant.character.escape */ -/* ^^^ constant.character.escape */ -/* ^^^^^^^^ constant.character.escape */ - -char8_t str9[] = u8"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char16_t str10[] = u"\u0063"; -/* ^^^^^^ constant.character.escape */ - -char32_t str11[] = U"\U00000063"; -/* ^^^^^^^^^^ constant.character.escape */ - -char str12[] = "\q"; -/* ^^ invalid.illegal.unknown-escape */ - -scanf("%ms %as %*[, ]", &buf); -/* ^^^ constant.other.placeholder */ -/* ^^^ constant.other.placeholder */ -/* ^^^^^^ constant.other.placeholder */ - -"foo % baz" -/* ^ - invalid */ - -char rawStr1[] = R"("This is a raw string")"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ - -char rawStr2[] = R"A*!34( )" )A*!34"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^ punctuation.definition.string.begin */ -/* ^ string.quoted.double */ -/* ^ punctuation.definition.string.end */ -/* ^ punctuation.definition.string.end */ - -const char IncludeRegexPattern[] = - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; -/* ^ storage.type.string */ -/* ^ punctuation.definition.string.begin */ -/* ^^ - invalid */ -/* ^^ - invalid */ -/* ^ punctuation.definition.string.end */ + 1 + 2 - 3 * 4 / 5 % 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 | 2 & 3 ^ 4 >> 5 << 6 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 1 > 2 >= 3 == 4 != 5 <= 6 < 7 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.comparison.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.comparison.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + !1 && 2 || 3 ? -4 : ~5 +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c +// ^ keyword.operator.bitwise.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c + 0 += 1 -= 2 *= 3 /= 4 %= 5 |= 6 &= 7 ^= 8 >>= 9 <<= 10 +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^^ keyword.operator.assignment.augmented.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c + sizeof(a) alignof(b) _Alignof(c) offsetof(c) static_assert(d) _Static_assert(d) +// ^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^ keyword.operator.word.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c + a,b = b.c; +// ^ punctuation.separator.c +// ^ keyword.operator.assignment.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c - -///////////////////////////////////////////// -// Storage Types ///////////////////////////////////////////// - -void* ptr; -/* <- storage.type */ - -bool b; -/* <- storage.type */ - -char ch; -/* <- storage.type */ - -size_t size_t_var; -/* <- support.type.stddef */ - -ptrdiff_t ptrdiff_t_var; -/* <- support.type.stddef */ - -max_align_t max_align_t_var; -/* <- support.type.stddef */ - -nullptr_t nullptr_t_var; -/* <- support.type.stddef */ - -wchar_t wchar_t_var; -/* <- support.type.wchar */ - -wint_t wint_t_var; -/* <- support.type.wchar */ - -wctrans_t wctrans_t_var; -/* <- support.type.wchar */ - -wctype_t wctype_t_var; -/* <- support.type.wchar */ - -mbstate_t mbstate_t_var; -/* <- support.type.uchar */ - -char8_t char8_t_var; -/* <- support.type.uchar */ - -char16_t char16_t_var; -/* <- support.type.uchar */ - -char32_t char32_t_var; -/* <- support.type.uchar */ - -unsigned int ui; -/* <- storage.type */ -/* ^ storage.type */ - -signed long l; -/* <- storage.type */ -/* ^ storage.type */ - -short s; -/* <- storage.type */ - -auto a = 2; -/* <- storage.type */ - -decltype(s) dt; -/* <- keyword.declaration */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -float f; -/* <- storage.type */ - -double d; -/* <- storage.type */ - -typedef int my_int; -/* <- keyword.declaration */ -/* ^ entity.name.type */ - -typedef struct Books { -/* ^ keyword.declaration */ -/* ^ - entity.name.type */ - char title[50]; - int book_id; -} Book; -/*^ entity.name.type */ - -typedef struct MyStructure {} MyStructure_t; -/* <- keyword.declaration.type.objc++ */ -/* ^^^^^^ keyword.declaration.struct.objc++ */ -/* ^^^^^^^^^^^ entity.name.struct.objc++ */ -/* ^ punctuation.section.block.begin.objc++ */ -/* ^ punctuation.section.block.end.objc++ */ -/* ^^^^^^^^^^^^^ entity.name.type.typedef.objc++ */ - -typedef struct Books Book; -/* ^ - entity.name.type.struct */ -/* ^ entity.name.type.typedef */ - -using Alias = Foo; -/* <- keyword.control */ -/* ^^^^^ entity.name.type.using */ - -using Alias - = NewLineFoo; -/*^ - entity.name */ - -template -using TemplateAlias = Foo; -/* ^^^^^^^^^^^^^ entity.name.type.using */ - -using std::cout; -/* <- keyword.control */ -/* ^ - entity.name */ - -using std:: - cout; -/*^ - entity.name */ - -class MyClass : public SuperClass -{ - using This = MyClass; -/* ^ keyword.control */ -/* ^^^^ entity.name.type.using */ - - using MyInt -/* ^ keyword.control */ - = int32_t; - - using SuperClass::SuperClass; -/* ^ keyword.control */ -/* ^ - entity.name */ -}; - -class MyClass : public CrtpClass -{ - using typename CrtpClass::PointerType; -/* ^ keyword.control */ -/* ^ storage.modifier */ - using CrtpClass< -/* ^ keyword.control */ - MyClass>::method; -}; - -template class MyStack; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic */ -/* ^ storage.type */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic */ - -template class tupleTmpl; -/* <- keyword.declaration.template */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ keyword.declaration */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -template, typename... Rest> class tupleVariadic; -/* <- keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ keyword.declaration */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ punctuation.definition.generic.end */ - -template void SomeClass::function(); -/* ^^^ keyword.operator.variadic */ -/* ^^^^^^^^ entity.name.function */ - -template inline struct Foo* baz() -/* ^^^^^^ storage.modifier */ -/* ^ - entity.name */ -/* ^^^ meta.function entity.name.function */ -{} - -template -void classname::methodName() { -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^^^^ entity.name.function */ -} - -template -void funcName() { -/* ^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -} -bool A::operator<(const A& a) { return false; } -/* ^ storage.type */ -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters punctuation.section.group.begin */ -template bool A::operator<(const A& a) { return false; } -/* ^ keyword.declaration.template */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^^^ entity.name.function */ -/* ^ meta.function.parameters meta.group punctuation.section.group.begin */ -template -SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ - -template SomeType A::foobar(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function */ - -template A::A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.constructor */ - -template A::~A(YetAnotherType&& asRValue) {} -/* ^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^ entity.name.function.destructor */ - -template -bool A::operator > (const A& other) { return false; } -/* ^^^^^^^^^^^^ meta.function entity.name.function */ -template -bool A::operator == (const A& other) { return false; } -/* ^^^^^^^^^^^^^^ meta.function entity.name.function */ -template -bool A::operator <=> (const A& other) { return false; } -/* ^^^^^^^^^^^^^^ meta.function entity.name.function */ -typedef std :: vector > Table; -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.end */ - -template - /* ^ meta.template keyword.operator */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template meta.number */ - /* ^ meta.template keyword.operator */ - /* ^ meta.template constant.language */ -struct Foo -{ - -/* <- meta.struct - meta.template */ - - void bar(int a = 3, bool b = true) {} - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template meta.number */ - /* ^ - meta.template keyword.operator */ - /* ^ - meta.template constant.language */ -}; - -/* <- - meta.block - meta.struct - meta.template */ - -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template meta.number */ -class fixed_array : private std::array {}; - -constexpr std::size_t f() { return 128; } -template -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -/* ^ meta.template punctuation */ -class fixed_array : private std::array {}; - -template class A { /* ... */ }; -template class B { /* ... */ }; -/* ^ meta.template keyword.operator */ -/* ^ meta.template */ -/* ^ meta.template punctuation */ -/* ^ - meta.template */ -template class C { /* ... */ }; - -// templates inside templates... it's templates all the way down -template class P> class X { /* ... */ }; -/* ^ meta.template punctuation */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template meta.template keyword.declaration */ -/* ^ meta.template meta.template punctuation */ -/* ^^^^^ meta.template keyword.declaration */ -/* ^ meta.template punctuation */ - -X xa; // OK -X xb; // OK in C++14 after CWG 150 - // Error earlier: not an exact match -X xc; // OK in C++14 after CWG 150 - -// template declarations spanning multiple lines -template -/* <- meta.template keyword.declaration */ -< -/* <- meta.template punctuation.definition.generic.begin */ - class T, - class U = T -> -class B -{ - /* ... */ -}; - -// template declarations spanning multiple lines -template -< -/* <- meta.template punctuation.definition.generic.begin */ - std::size_t Count = f() -/* ^^ meta.template punctuation.accessor */ -/* ^ meta.template keyword.operator */ -/* ^ meta.template variable.function */ -/* ^^ meta.template meta.function-call punctuation */ -> -/* <- meta.template punctuation.definition.generic.end */ -class fixed_array : private std::array {}; - -template -static bool decode(const Node& node, T& sequence) { - if (!node.IsSequence()) - return false; - sequence.clear(); - for (const auto& item : node) { - sequence.push_back(item.template as()); - /* ^ punctuation.accessor */ - /* ^ keyword.declaration - variable.other */ - /* ^ variable.function */ - /* ^ punctuation */ - /* ^^ punctuation.accessor */ - /* ^ punctuation */ - } - return true; -} - -#include -template struct A {}; -template struct B {}; -struct C {}; -A> f(std::function>()> g) { - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ variable.parameter */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - return g(); -} -int main() { - std::function foo1; - /* ^ - variable.function */ - std::function()> foo2; - /* ^ - variable.function */ - auto f = [](std::function>()> g) { return g(); }; - /* ^ punctuation.section.group.begin */ - /* ^^ punctuation.accessor */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^ punctuation.definition.generic.begin */ - /* ^^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.definition.generic.end */ - /* ^ punctuation.section.group.end */ - /* ^ punctuation.section.block.begin */ - /* ^ punctuation.section.block.end */ - return 0; -} -/* <- - invalid.illegal */ - -// Example from section 14.2/4 of -// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf -struct X -{ - template - X* alloc(); - - template - static X* adjust(); -}; -template -void f(T* p) -{ - // Be optimistic: scope it as a template member function call anyway. - T* p1 = p->alloc<200>(); // ill-formed: < means less than - - T* p2 = p->template alloc<200>(); // OK: < starts template argument list - /* ^ punctuation.accessor */ - /* ^ keyword.declaration - variable.other */ - /* ^ variable.function */ - - // Be optimistic: scope it as a template member function call anyway. - T::adjust<100>(); // ill-formed: < means less than - - T::template adjust<100>(); // OK: < starts template argument list - /* <- - variable.function */ - /*^ punctuation.accessor */ - /* ^ keyword.declaration - variable.other */ - /* ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ - /* ^ variable.function */ -} - -struct X -{ - void template(); // <-- not allowed to be a function! - /* ^ - entity.name.function */ -}; - -void f() -{ - X x; - x.template(); // <-- should not be scoped as variable.function! - /* ^ - variable.function */ - - x /**/ . /**/ foo <5> /**/ () /**/ ; - /*^^^^ comment.block */ - /* ^ punctuation.accessor */ - /* ^^^ meta.method-call variable.function */ - /* ^ meta.method-call - variable.function */ - /* ^ meta.method-call punctuation.definition.generic.begin */ - /* ^ meta.method-call punctuation.definition.generic.end */ - /* ^ meta.method-call - punctuation - comment.block */ - /* ^^^^ meta.method-call comment.block */ - /* ^ meta.method-call - comment.block - punctuation */ - /* ^^ meta.method-call punctuation - comment.block */ - /* ^ - meta.method-call */ -}; - -template C f(T t) -{ - return C { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -template C> f(T t) -{ - return C> { g>(t) }; - /* ^ variable.function */ - /* ^ punctuation.section.group.begin */ -} - -struct A { int foo; }; -int main() { - A a; - a.foo = a.foo < 0 ? 1 : 2; - /* ^ - punctuation.definition.generic */ -} -/* <- - invalid.illegal */ - -template -struct A::value && !is_std_char_type::value>> { - using x = conditional_t; - /* ^^ keyword.operator.comparison */ - - template - struct Y { - constexpr int operator<=>(const Y&) { return 0; } - }; - Y{} <=> Y<0>> y; - /* ^^^ keyword.operator.comparison */ -}; -/* <- - invalid.illegal */ - - -///////////////////////////////////////////// -// Storage Modifiers +// Strings ///////////////////////////////////////////// -alignas(16) char array[256]; -/* <- storage.modifier */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -const int XYZ = 2; -/* <- storage.modifier */ - -constexpr int ABC = 3 + 5; -/* <- storage.modifier */ - -consteval int f() { return 42; } -/* <- storage.modifier */ - -constinit const int i = f(); -/* <- storage.modifier */ - -thread_local int x; -/* <- storage.modifier */ - + "abc123" L"abc123" u8"abc123" u"abc123" U"abc123" 'abc123' L'abc123' +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^^ string.quoted.double.c +// ^^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.double.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^^ string.quoted.single.c +// ^ storage.type.string.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + "\a\b\f\n\r\t\v\e\E\314\xabc\u3141\U15926535\\\"\'\?\0\7" +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.c +// ^ punctuation.definition.string.end.c++ + '\u\w\x\y\z\/' +// ^^^^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^^^^^^^^^^^^ invalid.illegal.unknown-escape.c +// ^ punctuation.definition.string.end.c++ + "%ms %as %*[, ]" +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^^ constant.other.placeholder.c +// ^^^ constant.other.placeholder.c +// ^^^^^^ constant.other.placeholder.c +// ^ punctuation.definition.string.end.c++ + "314 \ +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.separator.continuation.c + 159" +//^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.end.c++ ///////////////////////////////////////////// -// Control Keywords +// Constants ///////////////////////////////////////////// -static_assert(x >= 0); -/* <- keyword.operator */ - -noexcept(f()); -/* ^^^ meta.function-call */ -/* <- keyword.operator */ - -if (x < 5) -/* <- keyword.control */ -{} -else -/* <- keyword.control */ -{} - -switch (x) -/* <- keyword.control */ -{ -case 1: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -default: -/* <- keyword.control */ - break; - /* <- keyword.control.flow.break */ -} - -do -/* <- keyword.control */ -{ - if (y == 3) - continue; - /* <- keyword.control.flow.continue */ -} while (y < x); -/*^ keyword.control */ - -switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ -} - -goto label; -/* <- keyword.control.flow.goto */ - -try -/* <- keyword.control */ -{ - throw std :: string("xyz"); - /* <- keyword.control.flow.throw */ - /* ^^^^^^ variable.function */ - /* ^^ punctuation.accessor */ -} -catch (...) -/* <- keyword.control */ -{ -} - -int* ptr = new int(2); -/* ^ keyword.control */ - -delete ptr; -/* <- keyword.control */ - -return 123; -/* <- keyword.control.flow.return */ - + true TRUE false FALSE NULL __func__ +// ^^^^ constant.language.boolean.true.c +// ^^^^ constant.language.boolean.true.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^^ constant.language.boolean.false.c +// ^^^^ constant.language.null.c +// ^^^^^^^^ constant.language.c + __FILE__ __LINE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __GNUC__ __clang__ __cplusplus +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^^^^^^^^ support.constant.c +// ^^^^^^^^ support.constant.c +// ^^^^^^^^^ support.constant.c +// ^^^^^^^^^^^ support.constant.c + + True False Null __CplusPlus +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^ invalid.illegal.malformed-constant-language.c +// ^^^^^^^^^^^ invalid.illegal.malformed-constant-language.c ///////////////////////////////////////////// -// Operator Keywords +// Enclosings ///////////////////////////////////////////// -int x = alignof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -int x = sizeof(char); -/* ^ keyword.operator.word */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - + [a, b, c] +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^^^^^^ meta.brackets.square.c +// ^ punctuation.separator.c +// ^ punctuation.separator.c +// ^ punctuation.section.brackets.end.c + {1, 2, 3} +// ^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.block.end + (6 - 7 == -1 && true) +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^^ keyword.operator.logical.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Cast Keywords +// Default Types ///////////////////////////////////////////// -const_cast(2.0); -/* <- keyword.operator.word.cast */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ - -dynamic_cast(2.0); -/* <- keyword.operator.word.cast */ - -reinterpret_cast(2.0); -/* <- keyword.operator.word.cast */ - -static_cast(2.0); -/* <- keyword.operator.word.cast */ - -auto var = *reinterpret_cast>*>(v); -/* ^ keyword.operator.word.cast */ -/* ^ - variable.function */ + auto void char short int long float double signed unsigned _Complex _Imaginary _Bool +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^ storage.type.c +// ^^^^^^^^^^ storage.type.c +// ^^^^^ storage.type.c + size_t ptrdiff_t nullptr_t max_align_t intmax_t uintmax_t intptr_t uintptr_t +// ^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^ support.type.stdint.c + uint8_t uint16_t uint32_t uint64_t int8_t int16_t int32_t int64_t +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^^^ support.type.stdint.c +// ^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c +// ^^^^^^^ support.type.stdint.c + uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t int_fast8_t int_fast16_t int_fast32_t int_fast64_t +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c + uint_least8_t uint_least16_t uint_least32_t uint_least64_t int_least8_t int_least16_t int_least32_t int_least64_t +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c +// ^^^^^^^^^^^^^ support.type.stdint.c + + typeof(a) __typeof__(b) __typeof(c) typeof_unqual(d) +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end +// ^^^^^^^^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end ///////////////////////////////////////////// -// Language Constants +// Storage Keywords ///////////////////////////////////////////// -bool t = true; -/* ^ constant.language */ - -bool f = false; -/* ^ constant.language */ - -int* p = nullptr; -/* ^ constant.language */ - -char ch[] = __func__; -/* ^ constant.language */ - - -///////////////////////////////////////////// -// Support Constants -///////////////////////////////////////////// - -std::cout << __FILE__ << '\n'; -/* ^ support.constant */ -/* ^^ punctuation.accessor */ - -std :: cout << __FUNCTION__ << '\n'; -/* ^^ punctuation.accessor */ -/* ^ support.constant */ - -std::cout << __LINE__ << '\n'; -/* ^ support.constant */ - - -///////////////////////////////////////////// -// Numeric Constants -///////////////////////////////////////////// + register static inline extern register thread_local _Thread_local _Noreturn noreturn +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c + const volatile restrict _Atomic _Alignas(4) +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end -dec1 = 1234567890; -/* ^^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec2 = 1'924'013; -/* ^^^^^^^^^ meta.number.integer.decimal constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -dec3 = 124ul; -/* ^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec4 = 9'204lu; -/* ^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -dec5 = 2'354'202'076LL; -/* ^^^^^^^^^^^^^^^ meta.number.integer.decimal.c++ */ -/* ^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct1 = 0123_567; -/* ^^^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -oct2 = 014'70; -/* ^^^^^^ meta.number.integer.octal.c++ */ -/* ^ constant.numeric.base.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex1 = 0x1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0X1234567890ABCDEF; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex3 = 0x1234567890abcdef; -/* ^^^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex4 = 0xA7'45'8C'38; -/* ^^^^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.terminator - constant */ - -hex5 = 0x0+0xFL+0xaull+0xallu+0xfu+0xf'12_4_uz; -/* ^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^^ constant.numeric.suffix.c++ */ -/* ^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^^^^^^^^ meta.number.integer.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^^^^^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -hex2 = 0xc1.01AbFp-1+0x1.45c778p+7f; -/* ^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic - constant.c++ */ -/* ^^^^^^^^^^^^^^ meta.number.float.hexadecimal.c++ */ -/* ^^ constant.numeric.base.c++ */ -/* ^^^^^^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -bin1 = 0b010110; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin2 = 0B010010; -/* ^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -bin3 = 0b1001'1101'0010'1100; -/* ^^^^^^^^^^^^^^^^^^^^^ meta.number.integer.binary */ -/* ^^ constant.numeric.base */ -/* ^^^^^^^^^^^^^^^^^^^ constant.numeric.value */ -/* ^ punctuation.terminator - constant */ - -f = 1.1+1.1e1+1.1e-1+1.1f+1.1e1f+1.1e-1f+1.1L+1.1e1L+1.1e-1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.e1+1.e-1+1.e1f+1.e-1f+1.e1L+1.e-1L; -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1.+1.f+1.L+1..; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^ meta.number.integer.decimal.c++ */ -/* ^ constant.numeric.value.c++ */ -/* ^^ invalid.illegal.syntax.c */ -/* ^ punctuation.terminator - constant */ - -f = 1e1+1e1f+1e1L; -/* ^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = .1+.1e1+.1e-1+.1f+.1e1f+.1e-1f+.1L+.1e1L+.1e-1L; -/* ^^ meta.number.float.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ keyword.operator.arithmetic.c */ -/* ^^^^^^ meta.number.float.decimal.c++ */ -/* ^ punctuation.separator.decimal.c++ */ -/* ^^^^^ constant.numeric.value.c++ */ -/* ^ constant.numeric.suffix.c++ */ -/* ^ punctuation.terminator - constant */ - -f = 1'843'290.245'123; -/* ^^^^^^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 2'837e1'000; -/* ^^^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -f = 23e-1'000; -/* ^^^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.terminator - constant */ - -units0 = 1.0suff+1.suff*.0suff/{1suff} -/* ^^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator */ -/* ^^^^^^ meta.number.float.decimal */ -/* ^^^^ constant.numeric.suffix */ -/* ^ keyword.operator.arithmetic */ -/* ^ punctuation.section.block.begin */ -/* ^^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.value */ -/* ^^^^ constant.numeric.suffix */ -/* ^ punctuation.section.block.end */ - -units1 = 134h + 123.45h; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units2 = 147min + 147.min; -/* ^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units3 = 357s + 34.7s; -/* ^^^^ meta.number.integer.decimal */ -/* ^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^ meta.number.float.decimal */ -/* ^ punctuation.separator.decimal */ -/* ^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ - -units4 = 234_custom + 10e-1_custom; -/* ^^^^^^^^^^ meta.number.integer.decimal */ -/* ^^^ constant.numeric.value */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^^^ - constant */ -/* ^^^^^^^^^^^^ meta.number.float.decimal */ -/* ^^^^^^^ constant.numeric.suffix */ -/* ^ punctuation.terminator - constant */ ///////////////////////////////////////////// // Functions ///////////////////////////////////////////// -// function prototype -void abcdWXYZ1234(); -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ - -// function definition -void abcdWXYZ1234() -/* ^^^^^^^^^^^^^^ meta.function */ -/* ^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -struct foo **alloc_foo(); -/* ^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.declaration */ -/* ^ - entity.name.struct */ -/* ^^ keyword.operator */ -/* ^ entity.name.function */ - -long func -/* ^^^^ meta.function entity.name.function */ -(int x, void *MYMACRO(y) ) { -/*^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ -entity.name.function */ -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^ meta.group meta.function-call meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.section.group.end */ - // Ensure < and > aren't parsed as a generic - if (foo < bar && baz > bar ) { -/* ^ keyword.operator.comparison */ -/* ^ keyword.operator.comparison */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - + test(5, 10, 15, 20); +// ^^^^ variable.function.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + int v = h(f(5) - g(6)); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + int out = in("abcdefg"); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ variable.function.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + printf +//^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ variable.function.c + (1, 2, 3); +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int b = main(argc); +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^^^ variable.function.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + static extern int* +// ^^^^^^ storage.modifier.c +// ^^^^^^ storage.modifier.c +// ^^^ storage.type.c +// ^ keyword.operator.c + test( +// ^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ + const uint64_t a, +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^ support.type.stdint.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c + typeof(b) b +//^^^^^^^^^^^^^^^^^ meta.function.c meta.function.parameters.c meta.group.c++ +// ^^^^^^ keyword.declaration.type.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.c++ + ); +//^^^ meta.function.c +//^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c - if (version.major == 10 && version.minor < 11) -/* ^ keyword.operator.comparison */ - { - - } -} -/* <- meta.function meta.block punctuation.section.block.end */ - -MACRO1 -RETURN_TYPE -/* <- - entity.name.function */ -func_name() { -/* < entity.name.function */ -} +///////////////////////////////////////////// +// Control Flow +///////////////////////////////////////////// -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - struct Args { -/* ^ keyword.declaration */ -/* ^ entity.name.struct */ - void* hello; - void* foobar; - Args() -/* ^ entity.name.function.constructor */ - : hellp(nullptr), -/* ^ punctuation.separator.initializer-list */ - foobar(nullptr) - { + void fun(int const a[]) { + while (true) { +//^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.control.c +// ^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + do { +//^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^ meta.block.c punctuation.section.block.begin + for (int i = 0; i < 12; ++i) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c +// ^^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ keyword.operator.comparison.c++ +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + switch (i) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ punctuation.section.group.end + { +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ meta.block.c punctuation.section.block.begin + case 0: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + goto exit; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.flow.goto.c +// ^ punctuation.terminator.c + case 1: +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + case 2 + 3: +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.ternary.c + if (a + b < i) {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c++ +// ^ punctuation.section.group.end.c +// ^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^ punctuation.section.block.end.c + else if (b == -1) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.c +// ^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^ keyword.operator.assignment.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end +// ^ meta.block.c punctuation.section.block.begin + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + break; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^ keyword.control.flow.break.c +// ^ punctuation.terminator.c + default: +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.c +// ^ keyword.operator.ternary.c + continue; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.flow.continue.c +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } +//^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + } while (a > b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^ keyword.control.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end +// ^ punctuation.terminator.c } - }; - - struct Args args2; -/* ^ keyword.declaration */ -/* ^ - entity */ - - class LocalFoo MYMACRO -/* ^ keyword.declaration */ -/* ^ entity.name.class */ -/* ^ - entity */ - { - LocalFoo() {} -/* ^ entity.name.function.constructor */ +//^^^^^^^ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + + exit: +//^^^^^^^ meta.function.c meta.block.c +// ^^^^ entity.name.label.c++ +// ^ punctuation.separator.c++ + return; +//^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^ punctuation.terminator.c } - - class LocalFoo test; -/* ^ keyword.declaration */ -/* ^ - entity */ - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -/* A comment. */ void FooBar :: baz(int a) -/* ^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^ entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -{ -} -// prevent leading comment from function recognition -/**/ HRESULT A::b() -/* ^ meta.function */ -/* ^ entity.name.function */ -{ - return S_OK; -} -FooBar::FooBar(int a) -/*^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ punctuation.section.group.end */ -{ -} - -FooBar :: FooBar(int a) & = -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/*^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^ entity.name.function */ -/* ^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^^^ storage.type */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ keyword.operator */ -/* ^ keyword.operator.assignment */ -default; -/*^^^^^ meta.function storage.modifier */ - -FooBar::~FooBar -/*^^^^^^^^^^^^^ meta.function meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ -() { } -/* <- meta.function.parameters meta.group punctuation.section.group.begin */ - /* <- meta.function.parameters meta.group punctuation.section.group.end */ -/*^^^^ meta.function */ - -ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath:: - ThisIsAReallyReallyLongClassNameThatRequiresWrappingCodeInTheMiddleOfAPath() -/* <- meta.function meta.toc-list.full-identifier */ - : var_name(nullptr) { -} - -bool FooBar::operator==() {} -/* ^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^^^^ entity.name.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - -myns::FooBar::~FooBar() { } -/*^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/*^^^^^^^^^^^^^^^^^^^ meta.toc-list.full-identifier */ -/* ^^^^^^^ entity.name.function */ - - extern "C" void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if 0 -void test_in_extern_c_block() -/* ^ comment.block */ -{ -} -#else - -/* temporary C++ preprocessor block */ -#ifdef __cplusplus -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -# ifndef _Bool -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */ -/* ^ keyword.declaration */ -/* ^ entity.name.type.typedef */ -# endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ -#endif -/* <- meta.preprocessor */ -/* <- keyword.control.import */ - -void test_in_extern_c_block() -/* ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ -{ -/* <- meta.function meta.block punctuation.section.block.begin */ -} -/* <- meta.function meta.block punctuation.section.block.end */ -#endif - -#ifdef __cplusplus -} -#endif -/* ^ - meta.extern-c */ - -gener func_returning_generic(int a); -/* ^ entity.name.function */ - -std::vector func_returning_path_generic(int a); -/* ^ punctuation.definition.generic */ -/* ^ entity.name.function */ - -void f() -{ - static_assert(false, "oops"); - /* ^ keyword.operator.word */ -} - -long double operator "" _km (long double x); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^ meta.function.parameters */ -/* ^^^^^^^^^^^^^^^ entity.name.function */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Namespace +// Data Structures ///////////////////////////////////////////// -namespace myNameSpace {} -/* <- keyword.control */ -/* ^ entity.name.namespace */ - -namespace new_name = current_name; -/* <- keyword.control */ - -using namespace NAME __attribute__((visibility ("hidden"))); -/* <- keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ - -using namespace -/* <- keyword.control */ -/* ^ keyword.control */ - -using namespace myNameSpace; -/* <- keyword.control */ -/* ^ keyword.control */ - -void func() { - using namespace NAME __attribute__((visibility ("hidden"))); -/* ^ keyword.control */ -/* ^ keyword.control */ -/* ^ storage.modifier */ -/* ^ string */ -} - -namespace ns :: abc /* Neither this comment... */ -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace */ -/* ^^^^^^^^^ entity.name.namespace */ -/* ^^ punctuation.accessor */ -/* ^ comment.block */ -// ...nor this comment is highlighted -/* <- comment.line */ -{ -/* <- meta.namespace meta.block punctuation.section.block.begin */ - void nsfunc() { - /* ^ entity.name.function */ - } -} -/* <- meta.namespace meta.block punctuation.section.block.end */ - -namespace tl { -/*^^^^^^^^^^^^ meta.namespace */ -/* ^ keyword.control */ - namespace { -/* ^ keyword.control */ -/* ^^^^^^^^^^^ meta.namespace meta.namespace */ -/* ^ meta.block meta.block punctuation.section.block.begin */ - void nested_func(){} -/* ^ entity.name.function */ + struct A; enum B; union C; +// ^^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c +// ^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^ entity.name.enum.forward-decl.c +// ^ punctuation.terminator.c + + enum B +// ^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^ entity.name.enum.c + { +// ^ meta.enum.c punctuation.section.block.begin.c + kTest1, +//^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + kTest2 = kTest1 + 1, +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + kTest3, +//^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ entity.name.constant.c +// ^ punctuation.separator.c + }myEnum; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + const volatile struct A +// ^^^^^ storage.modifier.c +// ^^^^^^^^ storage.modifier.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ entity.name.class.c++ + { +//^^^ meta.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a1; +//^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + char a3[12]; +//^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^^^ meta.brackets.square.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.c +// ^ punctuation.terminator.c + void* h5; +//^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + enum B out; }; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^ keyword.declaration.enum.c++ +// ^ punctuation.terminator.c +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + union MACRO myUnion { +// ^^^^^^^^^^^^^^^^^^^^^ meta.union.c +// ^^^^^ keyword.declaration.union.c +// ^^^^^^^ entity.name.union.c +// ^ meta.block.c punctuation.section.block.begin.c + struct A { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f; +//^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s1; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + struct B { +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.c++ +// ^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int f2; +//^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + } s2; +//^^^^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + void* ptr; +//^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + int a, *ptr2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + }; +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.terminator.c + + int test() { +// ^^^ storage.type.c +// ^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + union C myunion; +//^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^ keyword.declaration.union.c +// ^ punctuation.terminator.c + myunion.s2.f = 20; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } -} - -MACRONAME namespace ns3 {} -/* ^ keyword.control */ - -extern "C++" -// ^ storage.modifier -// ^^^^^ string.quoted.double -{ -namespace std _GLIBCXX_VISIBILITY(default) -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace -// ^ keyword.control -// ^ entity.name.namespace -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call -// ^^^^^^^^^ meta.group -// ^ keyword.control -{} -} - -#define MY_NAMESPACE_BEGIN namespace greatapp { -#define MY_NAMESPACE_END } -MY_NAMESPACE_BEGIN -class X { -private: -/* <- storage.modifier */ - int a; -protected: -/* <- storage.modifier */ - int b; -public: -/* <- storage.modifier */ - int c; -}; -MY_NAMESPACE_END - -MY_NAMESPACE_BEGIN int foo(); MY_NAMESPACE_END -/* ^ storage.type */ -/* ^ meta.function entity.name.function */ -/* ^^^ punctuation */ - -// Uncomment this some day -// MY_NAMESPACE_BEGIN class X : public std::true_type {}; MY_NAMESPACE_END +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + typedef struct { +// ^^^^^^^ keyword.declaration.type.c +// ^^^^^^ keyword.declaration.c++ +// ^ meta.class.c++ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + myCustomType* a; +//^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^ keyword.operator.c +// ^ punctuation.terminator.c + } b; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ entity.name.type.typedef.c +// ^ punctuation.terminator.c + + typedef void(*func)(int param, int, char param2); +// ^^^^^^^ keyword.declaration.type.c +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c ///////////////////////////////////////////// -// Classes, structs, unions and enums +// Attributes and Declspec ///////////////////////////////////////////// -class BaseClass; -/*^^^^^^^^^^^^^ meta.class */ -/* ^ - meta.class meta.class */ -/* ^^^^^^^^^ entity.name.class.forward-decl */ - -class BaseClass // comment -/* <- keyword.declaration */ -/* ^ entity.name.class */ -{ -public : -/* <- storage.modifier */ - tupleTmpl max(tupleGen a, tupleGen b); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^ variable.parameter */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -/* ^ punctuation.definition.generic.begin */ -/* ^ storage.type */ -/* ^ punctuation.definition.generic.end */ -protected: -/* <- storage.modifier */ -private: -/* <- storage.modifier */ - - static int a = 1 << 4; - /* <- storage.modifier */ - /* ^^ keyword.operator.arithmetic */ - - static int x; - /* <- storage.modifier */ - - virtual void doSomething() const = 0; - /* ^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /* ^ - meta.method meta.method */ - /* ^^ meta.method.parameters meta.group */ - /* ^ punctuation.section.group.begin */ - /* ^ punctuation.section.group.end */ - /* <- storage.modifier */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ meta.number */ - - template - void func(){} -/* ^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ -/* ^^^^ entity.name.function */ - - template - void func(){} -/* ^^^^^^^^^^^ meta.method */ -/* ^^^^ entity.name.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.method.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^ meta.block */ -/* ^ punctuation.section.block.begin */ -/* ^ punctuation.section.block.end */ - - template - BaseClass(){} -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ meta.method.constructor */ -/* ^^^^^^^^^ entity.name.function */ - - ~BaseClass() {} -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^ meta.method.destructor */ -/* ^^^^^^^^^^ entity.name.function */ - - BaseClass operator [] () -/* ^^^^^^^^^^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^^^^^^^^^^ entity.name.function */ - {} - - BaseClass operator= -/* ^^^^^^^^^ meta.method */ -/* ^^^^^^^^^ entity.name.function */ - () {} -/* ^^^^^ meta.method */ -/* ^^ meta.method.parameters */ -/* ^^ meta.block */ -}; - -class DerivedClass : public ::BaseClass // Comment -/* ^ entity.other.inherited-class */ -/* ^ comment.line */ -{ - ~DerivedClass() override; - /* <- meta.method.destructor */ - /*^^^^^^^^^^^^^^^^^^^^^^ meta.method */ - /*^^^^^^^^^^^ meta.method.destructor */ - /* ^ storage.modifier */ - virtual void doSomething() const override final; - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - protected: -/*^^^^^^^^ storage.modifier */ - DerivedClass() override -/*^^^^^^^^^^^^^^^^^^^^^^^ meta.method */ -/*^^^^^^^^^^^^ meta.method.constructor */ -/* ^ storage.modifier */ - : a(a), -/* ^^^^^^^ meta.method.constructor.initializer-list */ - base_id_(BaseClass::None().ToInt()), -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ -/* ^ variable.other.readwrite.member */ -/* ^ punctuation.accessor */ -/* ^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^ variable.function */ -/* ^ punctuation - meta.method-call */ -/* ^^^^^^^ meta.method-call */ -/* ^^^^^ variable.function */ -/* ^ punctuation.separator */ - bounds_(NULL), -/* ^^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - bit_field_(0) { -/* ^^^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^^^^^^ meta.method.constructor.initializer-list */ - char * a = "sprintf"; - char * b = sprintf("Testing %s", a); -/* ^^^^^^^^^ meta.function-call */ -/* ^^^^^^^ support.function.C99 */ - - base_id_->foobar(1, "foo"); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^ variable.function */ - - base_id_->~BaseClass(); -/* ^^ punctuation.accessor - meta.method-call */ -/* ^^^^^^^^^^^^ meta.method-call */ -/* ^^^^^^^^^^ variable.function */ - } -/* ^ meta.method meta.block punctuation.section.block.end */ - -/* <- - meta.class.constructor.initializer-list */ - - typedef std::vector qux; -/* ^^^ entity.name.type.typedef */ -}; - - -template -class class1 : class2 -/* ^^^^^^ entity.name.class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -/* ^^^^^^ entity.other.inherited-class */ -/* ^ punctuation.definition.generic */ -/* ^ punctuation.definition.generic */ -{} - -class FooBar { -/* ^ meta.class meta.block punctuation.section.block.begin */ - explicit FooBar(int a); -/* ^^^^^^^^^^^^^ meta.method */ -/* ^^^^^^^^ storage.modifier */ -/* ^^^^^^ entity.name.function */ - FooBar() =default; -/* ^^^^^^ entity.name.function */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - FooBar(void) =default; -/* ^^^^^^ entity.name.function */ -/* ^^^^ storage.type */ -/* ^ keyword.operator.assignment */ -/* ^^^^^^^ storage.modifier */ - - // If a constructor name is on a line without the opening (, it is not - // highlighted as a method/constructor. This prevents a bunch of false - // positives, including data types as they are being typed into a struct. - FooBar -/* ^ - entity.name.function */ - (); - - virtual ~FooBar(); -/* ^^^^^^^ entity.name.function */ - -#ifndef DEBUG - ~FooBar(); -/* ^^^^^^^ entity.name.function */ -#endif - - void insert () {} -/* ^^^^^^ entity.name.function */ - - explicit operator bool -/* ^^^^ entity.name.function */ - () {} - - FooBar::~FooBar(); -/* ^^^^^^^^^^^^^^^ entity.name.function */ - - void FooBar:: - Baz() { - /* <- entity.name.function */ - } - - auto f(int a) -> decltype(a.begin()) override final; -/* ^^ punctuation.separator */ -/* ^ punctuation.accessor */ -/* ^^^^^ variable.function */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - - auto g() -> std::vector override final { -/* ^^ punctuation.separator */ -/* ^^ punctuation.accessor */ -/* ^ storage.type */ -/* ^ storage.modifier */ -/* ^ storage.modifier */ - this->g(1); -/* ^ variable.language */ - } - -private: -/*^^^^^ storage.modifier */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - myns::subns::MyDataType -/* ^ - entity.name.function */ - and_now_method_name(); -/* ^ entity.name.function */ - - VISIBILITY_MACRO -/* ^ - entity.name.function */ - std::shared_future> -/* ^ - entity.name.function */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ -/* ^ punctuation.definition.generic.begin */ -/* ^^ punctuation.accessor */ - and_now_method_name2(); -/* ^ entity.name.function */ - - enum { - FOO, - /* ^^^ entity.name.constant.objc++ */ - /* ^ punctuation.separator.objc++ */ - BAR - /* ^^^ entity.name.constant.objc++ */ + __declspec(align(5)) struct Test { +// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^ storage.modifier.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + int a; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int b; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c + int c; +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^ punctuation.terminator.c }; - - enum -/* ^^^^ meta.enum keyword.declaration */ - { -/* ^ meta.enum punctuation.section.block.begin */ - A = 1, -/* ^ entity.name.constant.objc++ */ -/* ^ punctuation.separator.objc++ */ - B = 20 / 5, -/* ^ entity.name.constant.objc++ */ -/* ^ punctuation.separator.objc++ */ - C = FOO -/* ^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment.c */ -/* ^^^^ - entity.name */ - } -/* ^ meta.enum punctuation.section.block.end */ -/* ^ - meta.enum */ - - friend int func(int a, int b); -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ - entity.name.function */ -/* ^ - meta.function-call */ - - friend int func(int a, int b) { -/* ^ storage.modifier */ -/* ^ storage.type */ -/* ^ entity.name.function */ -/* ^ - meta.function-call */ -/* ^ meta.class meta.block meta.method meta.block punctuation.section.block.begin */ - int a = 1; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + void __declspec(dllimport) importedFn() const; +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + __declspec(property(get=10, put=10)) void runForever(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ variable.parameter.c +// ^ keyword.operator.assignment.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + void on_load() __attribute__((constructor, visibility("hidden"))) {} +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.separator.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin +// ^ meta.block.c punctuation.section.block.end.c + + int old_func() [[deprecated]] [[gnu::pure]] [[nodiscard("Do not discard")]] { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackets.square.c punctuation.section.brackts.begin.c +// ^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.brackets.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin + if ([[clang::hot]] true) return 5; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^ meta.brackets.square.c meta.annotation.c +// ^^ meta.brackts.square.objc++ punctuation.section.brackets.begin.objc++ +// ^^^^^^^^^^ constant.other.c +// ^^ punctuation.section.brackets.end.c +// ^^^^ constant.language.boolean.true.c +// ^ punctuation.section.group.end.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + else return 6; +//^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^ keyword.control.c +// ^^^^^^ keyword.control.flow.return.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ - - friend class ::FooBar; -/* ^ storage.modifier */ -/* ^ keyword.declaration -/* ^^ punctuation.accessor */ -/* ^ - entity */ - - friend bool operator != (const X& lhs, const X& rhs) { - /* ^^^^^^^^^^^ entity.name.function */ - int a = 1; - } -/* ^ meta.class meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.class meta.block meta.block */ +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + + int a = +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c + int main(int argc, char const* argv[]) { +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.c +// ^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^^^^ variable.parameter.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ meta.brackets.square.c punctuation.section.brackets.end.c +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin - #if 0 - /* ^ meta.number */ - int disabled_func() { - /* ^ comment.block */ } - #endif - - #if 1 - /* ^ meta.number */ - int enabled_func() {} - /* ^ entity.name.function */ - #else - int disabled_func() { - /* ^ comment.block */ - } - #endif - - MACRO_NOT_CONSTRUCTOR(FooBar); -/* ^ meta.function-call variable.function - entity.name.function */ - - MACRO_NOT_CONSTRUCTOR2(FooBar, -/* ^ meta.function-call variable.function - entity.name.function */ - FriendClass); -} -/* <- meta.class meta.block punctuation.section.block.end */ - /* <- - meta.class meta.block */ - -struct X { - Y f() override noexcept final; - /*^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class X { - public: - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -union Y { - ::Y g() override noexcept final; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ - /* ^ storage.modifier */ -}; - -class Child : public Parent { - ::anotherClass Func() override; - /* <- punctuation.accessor */ - /* ^ entity.name.function */ - /* ^ storage.modifier */ -} - -class Adapter2 : public Abstraction, private Scenario { -/* ^ punctuation.separator */ -} - -class Adapter : public Abstraction - #if defined ASPECTO_MACRO -/* ^^^ keyword.control.import */ - , public Scenario -/* ^ punctuation.separator */ -/* ^ storage.modifier */ -/* ^ entity.other.inherited-class */ - #endif -/* ^^^^^^ keyword.control.import */ -{ - -} - -struct Base {}; -class Derived final : Base {}; -/* ^ storage.modifier */ -struct Derived final : Base {}; -/* ^ storage.modifier */ - -/* C++11 "uniform initialization" in initializer lists */ -class Foo { -public: - Foo() : var1(1), var(2), var3{3}, var4(4) {} - /* ^ meta.method.constructor.initializer-list */ - /* ^ - meta.function-call - variable.function */ -private: - int var1, var2, var3, var4; -}; - -class X { - int a, b, i, j; -public: - const int& r; - X(int i) - : r(a) // initializes X::r to refer to X::a - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , b{i} // initializes X::b to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , i(i) // initializes X::i to the value of the parameter i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j(this->i) // initializes X::j to the value of X::i - /* ^ meta.method.constructor.initializer-list punctuation */ - /* ^ meta.method.constructor.initializer-list punctuation */ - , j - /*^ variable */ - (this->i) - /* <- meta.method.constructor.initializer-list punctuation */ - { } -/* ^ punctuation - meta.method.constructor.initializer-list */ -/* ^ punctuation - meta.method.constructor.initializer-list */ -}; - -struct A { - static_assert(0 < 1, ""); - /* ^ keyword.operator.word */ - /* ^ meta.function-call */ - /* ^ keyword.operator.comparison */ - - A(); -/*^ meta.method.constructor entity.name.function.constructor */ - - void f(); - /* ^ storage.type */ - /* ^ meta.method entity.name.function */ - /* ^ punctuation.terminator */ -}; -/* <- punctuation.section.block.end - invalid.illegal */ - -struct bar { -/*^^^^^^^^^^ meta.struct */ -/*^^^^ keyword.declaration */ -/* ^^^ entity.name.struct */ -/* ^ meta.block punctuation.section.block.begin */ - bar() -/* ^^^^^ meta.method */ -/* ^^^ entity.name.function */ - {} -} -/* <- meta.struct meta.block punctuation.section.block.end */ - /* <- - meta.struct meta.block */ - -enum baz { -/*^^^^^^^^ meta.enum */ -/* <- meta.enum keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ meta.block punctuation.section.block.begin */ - FOO = 1, -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAR = 2, - BAZ = 3, -#if 0 -/* ^ meta.number */ - QUX = 4, -/* ^ comment.block */ -#endif -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -int main(void) -{ - struct UI_BoundingBox decorativeBox = {10, titleHeight-3, width-20, height-10}; -/* ^ - entity.name */ -/* ^ - entity.name */ -} - -struct foo MACRO { -/* ^ entity.name.struct */ -/* ^ - entity.name */ -} - -// Partially-typed -struct foo -/* ^ entity.name */ - -struct UI_MenuBoxData -/* <- keyword.declaration */ -/* ^ entity.name.struct */ -{ - struct UI_BoundingBox position; -/* ^ - entity.name */ -/* ^ - entity.name */ - enum UI_BoxCharType borderType; -/* ^ - entity.name */ -/* ^ - entity.name */ - unsigned int paddingX; - unsigned int paddingY; - struct UI_ScrollBoxText boxContents[]; -/* ^ - entity.name */ -/* ^ - entity.name */ -}; - -enum class qux : std::uint8_t -/*^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/*^^^^^^^^ keyword.declaration */ -/* ^^^ entity.name.enum */ -/* ^ punctuation.separator */ -/* ^^^^^^^^^^^^ entity.other.inherited-class */ -{ -/* <- meta.block punctuation.section.block.begin */ - FOO = 1, - BAR = 2, -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ - BAZ = 3 -} -/* <- meta.enum meta.block punctuation.section.block.end */ - /* <- - meta.enum meta.block */ - -typedef enum class funky -/*^^^^^ keyword.declaration */ -/* ^^^^^ entity.name.enum */ -{ - BAZ = 3 -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Funky; - -typedef enum -/*^^^^^ keyword.declaration */ -{ - FOO = 1, - BAR = 2, - BAZ = 3 -/* ^^^ entity.name.constant.objc++ */ -/* ^ keyword.operator.assignment */ -/* ^ meta.number */ -} Fun; - -enum LineEnding : uint32_t; -/*^^^^^^^^^^^^^^^^^^^^^^^^ meta.enum */ -/* ^^^^^^^^^^ entity.name.enum.forward-decl */ -/* ^ punctuation.separator */ -/* ^^^^^^^^ entity.other.inherited-class */ -/* ^ - meta.enum */ - -union foobaz { -/* <- meta.union keyword.declaration */ -/* ^^^^^^ entity.name.union */ -/* ^ meta.block punctuation.section.block.begin */ -} -/* <- meta.union meta.block punctuation.section.block.end */ - /* <- - meta.union meta.block */ - -// Class name that looks like a possible macro -class SP {} -/* ^^ entity.name.class */ - -class MyClass MACRO MACRO2 -/* ^ keyword.declaration */ -/* ^ entity.name.class */ -/* ^ - entity */ -/* ^ - entity */ -{} - -// Class using macro to handle __declspec() on Windows -class SK_API SkBitmap {} -/* ^ entity.name.class */ -class __declspec(property(get=foo)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ variable.parameter */ -/* ^ entity.name.class */ -class __declspec(align(8)) SkBitmap {} -/* ^ storage.modifier */ -/* ^ meta.number */ -/* ^ entity.name.class */ -class __declspec(dllimport) SkBitmap {} -/* ^ constant.other */ -/* ^ entity.name.class */ - -// Make sure not to match macros that have "too few characters". -template class Sample { - public: - // The T here should not be consumed as a macro. - T operator() (const foo x) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - int operator == (const int x) { - /*^^^^^^^^^^^ entity.name.function */ - return 0; - } - // The T here should not be consumed as a macro. - T operator()(int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } - // The T here should not be consumed as a macro. - T operator[](int a) { - /* <- entity.name.function */ - /*^^^^^^^^ entity.name.function */ - return T; - } -}; - -class Namespace::MyClass MACRO1 MACRO2 : public SuperClass -/* ^^^^^^^ entity.name.class */ -/* ^^ punctuation.accessor */ -/* ^ - entity.name */ -{ -}; - -struct Namespace::MyStruct -/* ^^^^^^^^ entity.name.struct */ -/* ^^ punctuation.accessor */ -{ -}; - -union Namespace::MyUnion -/* ^^^^^^^ entity.name.union */ -/* ^^ punctuation.accessor */ -{ -}; - -enum class Namespace::MyEnum -/* ^^^^^^ entity.name.enum */ -/* ^^ punctuation.accessor */ -{ -}; - -class Namespace:: -MyClass MACRO1 -/* <- entity.name.class */ -/* ^ - entity.name */ -{ -}; - -struct Namespace:: -MyStruct MACRO1 -/* <- entity.name.struct */ -/* ^ - entity.name */ -{ -}; - -union Namespace:: -MyUnion MACRO1 -/* <- entity.name.union */ -/* ^ - entity.name */ -{ -}; - -enum class Namespace:: -MyEnum MACRO1 -/* <- entity.name.enum */ -/* ^ - entity.name */ -{ - BAR = 1, -/* ^^^ entity.name.constant.objc++ */ -}; +//^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c ///////////////////////////////////////////// -// Test preprocessor branching and C blocks +// Preprocessor ///////////////////////////////////////////// -int bar(int, int const *, int const * const); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ punctuation.terminator */ -/* ^^^ storage.type */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^ punctuation.separator */ -/* ^^^ storage.type */ -/* ^^^^^ storage.modifier */ -/* ^ keyword.operator */ -/* ^^^^^ storage.modifier */ - -int foo(int val, float val2[], bool val3 = false) -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function */ -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^^^ variable.parameter */ -/* ^ punctuation.separator */ -/* ^^^^ variable.parameter */ -/* ^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ -/* ^ punctuation.separator */ -/* ^^^^ storage.type */ -/* ^^^^ variable.parameter */ -/* ^ keyword.operator.assignment */ -/* ^^^^^ constant.language */ -{ - myClass *result; - result->kk = func(val); -/* ^^ punctuation.accessor */ - if (result == 0) { - return 0; -#if CROSS_SCOPE_MACRO - /* <- keyword.control.import */ - } else if (result > 0) { - return 1; -#endif - /* <- keyword.control.import */ - } -/* ^ meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - -#ifndef DEBUG - if (check_debug()) { - val /= 2; -#endif - val += 1; -#ifndef DEBUG - } -/* ^ meta.function meta.block meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ -#endif - -#ifdef FOO - /* <- keyword.control.import */ - int foobar -/* ^^^^^^ - entity.name.function */ - ; - - if (val == -1) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#else - /* <- keyword.control.import */ - if (val == -2) { -/* ^ meta.block meta.block punctuation.section.block.begin */ -#endif - /* <- keyword.control.import */ - val += 1; - } -/* ^ meta.block punctuation.section.block.end */ -/* ^ - meta.block meta.block */ - - return -1; -} -/* <- meta.function punctuation.section.block.end */ - /* <- - meta.function */ - -#if 0 -/* ^ meta.number */ -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 -/* ^ meta.number */ -int enabled_func() {} -/* ^ entity.name.function */ -#else -int disabled_func() { -/* ^ comment.block */ -} -#endif - -#if 1 - int a = 1; - #if 0 -/* ^ meta.number */ - int b = 2; -/* ^ comment.block */ + #include +//^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c + #include_next "file.h" +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^^^^^^^^^^^ keyword.control.import.c +// ^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ + #error Error Message +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^ keyword.control.import.error.c +// ^^^^^^^^^^^^^^ string.unquoted.c + #error Error Message \ + (this is an "error") +//^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c + #warning Warning Message +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c +//^^^^^^^^^^ keyword.control.import.warning.c +// ^^^^^^^^^^^^^^^^ string.unquoted.c + #warning Warning Message \ + (this is a "warning") + + #define FOO __declspec(dllimport) +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^^^^^^^^^^ storage.modifier.c +// ^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^ constant.other.c +// ^ punctuation.section.group.end.c + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^ keyword.control.import.c +// ^^^ entity.name.macro.c support.macro.c +// ^ punctuation.section.group.begin.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^ variable.parameter.c +// ^ punctuation.separator.c +// ^^^ keyword.operator.variadic.c +// ^ punctuation.section.group.end.c +// ^^^^ keyword.declaration.enum.c++ +// ^^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.begin.c +// ^^^^^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^ keyword.operator.word.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.separator.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^ constant.other.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + #if FOO +//^^^^^^^^^ meta.preprocessor.c +//^^^^^ keyword.control.import.c + #ifndef FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + #ifdef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #elif FOO +//^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^ keyword.control.import.c + #elifdef FOO +//^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^ keyword.control.import.c + #elifndef FOO +//^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^^^ keyword.control.import.c #else - int c = 3; +//^^^^^^^ keyword.control.import.c #endif -#else - int d = 4; -/* ^ comment.block */ -#endif - -BOOL -GetTextMetrics( - HDC hdc, - LPTEXTMETRIC lptm - ) -{ -#ifdef UNICODE -/* <- keyword.control.import */ - return GetTextMetricsW( -/* ^ variable.function */ -#else -/* <- keyword.control.import */ - return GetTextMetricsA( -/* ^ variable.function */ -#endif -/* <- keyword.control.import */ - hdc, - lptm - ); -/* ^ meta.function-call */ -/* ^ - meta.function-call */ -} - /* <- - meta.function */ - /* <- - meta.block */ - -///////////////////////////////////////////// -// Matching various function definitions -///////////////////////////////////////////// - -const int foo = 1; -/* ^ - entity.name.function */ -int a; -/* ^ - entity.name.function */ - -int /* comment */ * myfunc -/* <- storage.type */ -/* ^ comment.block */ -/* ^ keyword.operator */ -/* ^^^^^^ entity.name.function */ -(int * a) -/* <- punctuation.section.group.begin */ -/* ^ keyword.operator */ -/* ^ punctuation.section.group.end */ -{ - -} - -void MyClass3:: -foo() { -/* <- entity.name.function */ -} - -MyClass3:: -~MyClass3() { -/* <- entity.name.function */ -} - -struct A -{ - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ - #endif - - void f() - { - #ifdef X - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ - #endif +//^^^^^^^^ keyword.control.import.c + + #undef FOO +//^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^ keyword.control.import.c + #pragma FOO +//^^^^^^^^^^^^^ meta.preprocessor.c +//^^^^^^^^^ keyword.control.import.c + # +// ^ keyword.control.c + #embed "file.txt" if_empty(0) +//^^^^^^^^ keyword.control.import.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ keyword.other.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c + + + "Hello {}!"_literal +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + 'h'_literal +// ^^^^^^^^^^^ string.quoted.single.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + R"RAW( +// ^^^^^^ string.quoted.raw.c++ +// ^ storage.type.string.c++ +// ^ punctuation.definition.string.begin.c++ +// ^^^^ constant.other.placeholder.c++ + raw string )STR" +//^^^^^^^^^^^^^^^^^^ string.quoted.raw.c++ + )RAW"_literal +//^^^^^^^^^^^^^^^ string.quoted.raw.c++ +// ^^^^ constant.other.placeholder.c++ +// ^ punctuation.definition.string.end.c++ +// ^^^^^^^^ variable.function.c++ + + using std::cout; +// ^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^ entity.name.using.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.terminator.c + using namespace std; +// ^^^^^^^^^^^^^^^^^^^ meta.using.c++ +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.namespace.c++ +// ^ punctuation.terminator.c + + and and_eq or or_eq not not_eq xor xor_eq bitand bitor compl +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^ keyword.operator.logical.c++ +// ^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.logical.c++ +// ^^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ +// ^^^^^ keyword.operator.bitwise.c++ + delete new typeid noexcept <=> +// ^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.word.c++ +// ^^^^^^ keyword.operator.word.c++ +// ^^^^^^^^ keyword.operator.word.c++ +// ^^^ keyword.operator.comparison.c++ + + constexpr consteval constinit +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^ storage.modifier.c++ + wchar_t wchar8_t wchar16_t wchar32_t +// ^^^^^^^ storage.type.c++ +// ^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ +// ^^^^^^^^^ storage.type.c++ + + enum class Test { +// ^^^^^^^^^^^^^^^^^ meta.enum.c +// ^^^^ keyword.declaration.enum.c++ +// ^^^^^ keyword.declaration.class.c++ +// ^^^^ entity.name.enum.c +// ^ punctuation.section.block.begin.c + A = 314, +//^^^^^^^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ keyword.operator.assignment.c +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + B, +//^^^^^^^^ meta.block.c +// ^ entity.name.constant.c +// ^ punctuation.separator.c + }; +//^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + namespace std::mynamespace { +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ +// ^^^^^^^^^ keyword.declaration.namesace.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.namespace.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.block.c++ punctuation.section.block.begin.c++ + std::vector const& func(std::string const& a, std::function b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^ storage.type.c +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + + template auto func(char param1, int param2 = f(20) - g(20)) const -> decltype(T::func(param)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ +// ^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^ storage.type.c +// ^^^^^^ variable.parameter.c++ +// ^ keyword.operator.assignment.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ keyword.operator.arithmetic.c +// ^ variable.function.c +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^ meta.group.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ variable.function.c +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + try { +//^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + throw ns::func(param2); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^ keyword.control.exception.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^^^^^^ meta.function.c +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } catch (std::exception const& e) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^ keyword.control.exception.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_await func +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ + (e); +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + } finally { +//^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^^^ keyword.control.exception.c++ +// ^ meta.block.c punctuation.section.block.begin.c + co_yield func(param1); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^^^^^^^^ keyword.control.c++ +// ^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + } +//^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c meta.block.c +// ^ punctuation.section.block.end.c + + co_return 7; +//^^^^^^^^^^^^^^^^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^^^^^^^^^ keyword.control.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.namespace.c++ meta.block.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c } - - void f() - { - static_assert(false, "asdf"); - /* ^ keyword.operator.word */ +//^^^ meta.namespace.c++ meta.block.c++ +// ^ punctuation.section.block.end.c++ + + class Type; +// ^^^^^ keyword.declaration.c++ +// ^^^^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + + template class V, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.separator.c + typename ...Args> requires std::same_as, std::string> +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^^^ keyword.operator.variadic.c +// ^^^^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^ punctuation.separator.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ punctuation.definition.generic.end.c++ + struct MACRO Type> MACRO final : D> { +// ^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^^^^ entity.name.class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^^^^^ storage.modifier.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^^^^^ entity.other.inherited-class.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ storage.type.c +// ^^ punctuation.definition.generic.end.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + private: +//^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ + alignas(20) std::string m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + protected: +//^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^ storage.modifier.c++ + int m_value2; +//^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ punctuation.terminator.c + friend class V; +//^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^^ keyword.declaration.c++ +// ^ entity.name.class.forward-declare.c++ +// ^ punctuation.terminator.c + friend void someFunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^ keyword.other.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^ meta.function.c +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + public: +//^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ + Type() && : m_value1("a"), m_value2(10); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.method.initializer-list.c++ +// ^ punctuation.separator.initializer-list.begin.c++ +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^ meta.group.c +// ^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^ punctuation.separator.c +// ^^^^^^^^ variable.other.readwrite.member.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.group.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + ~Type() = default; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^^ keyword.control.c +// ^ punctuation.terminator.c + explicit Type(int) = delete; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ storage.type.c +// ^ punctuation.section.group.end.c++ +// ^ keyword.operator.assignment.c +// ^^^^^^ keyword.operator.word.c++ +// ^ punctuation.terminator.c + + template <> +//^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +// ^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^ punctuation.section.generic.end.c++ + std::string const& doThing() const requires requires(std::tuple a) { a.get<0>().runThing(); } { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ +//^^^^^^ meta.template.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.requires.c++ +// ^^^^^^^^ storage.modifier.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^ keyword.operator.variadic.c +// ^ punctuation.definition.generic.end.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^ entity.name.function.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.definition.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return this->m_value1; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^ variable.language.c++ +// ^^ punctuation.accessor.dot.c +// ^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c + }; +//^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + + export { +// ^^^^^^ keyword.other.c++ +// ^ meta.block.c punctuation.section.block.begin.c + class A : protected A, private B, public C { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^ keyword.declaration.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.c++ +// ^ entity.name.class.c++ +// ^ punctuation.separator.inheritance.c++ +// ^^^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^^ storage.modifier.c++ +// ^ entity.other.inherited-class.c++ +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.c++ +// ^^ entity.other.inherited-class.c++ +// ^ meta.block.c++ meta.class.c++ meta.block.c++ punctuation.section.block.begin.c++ + virtual void vfunc(); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^ storage.type.c +// ^^^^^^^ meta.function.c +// ^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + bool operator ==(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + int operator<=>(A const&) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c++ meta.class.c++ +// ^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^ storage.modifier.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c++ meta.class.c++ +// ^ meta.block.c++ punctuation.section.block.end.c++ +// ^ punctuation.terminator.c + unsigned long long operator ""_label(unsigned long long a) const; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.c++ +// ^^^^^^^^ entity.name.function.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^ storage.type.c +// ^^^^ storage.type.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^^^^^ storage.modifier.c +// ^ punctuation.terminator.c } -}; - -void f() -{ - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ -} - -void f() -{ - #ifdef X - static_assert(false, "asdf"); -/* ^ meta.function meta.block */ -/* ^ keyword.operator.word */ - #endif -} - -Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/); -/* ^^^^^^^^^ comment */ - -MACRO1 void * MACRO2 myfuncname () { -/* ^ storage.type */ -/* ^ keyword.operator */ -/* ^ entity.name.function */ - - label: -/* ^ entity.name.label */ -/* ^ punctuation.separator */ - do { - break; - } while(true); - - switch (a) { - case 1: break; -/* ^ punctuation.separator */ - case 100 - 10: break; -/* ^ punctuation.separator */ - default: break; -/* ^ punctuation.separator */ +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + void A::vfunc() { +// ^^^^ storage.type.c +// ^^ punctuation.accessor.double-colon.c++ +// ^^^^^ variable.function.c +// ^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + auto lambda = [=] mutable -> std::string { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^ storage.modifier.c++ +// ^^^^^^^^ meta.function.return-type.c++ +// ^^ keyword.operator.arrow.c++ +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + return "test"; +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.function.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.terminator.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + ([&, this, lambda](int a, char b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ meta.lambda.c++ +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ +// ^ storage.modifier.capture.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^ punctuation.separator.c +// ^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^^ entity.other.lambda-capture.c++ variable.parameter.c++ +// ^ punctuation.section.brackets.end.c++ +// ^^^^^^^^^^^^ meta.template.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c + + })(5, 10); +//^^^^^^^^^^^^^^^^ meta.block.c +//^^^^^^^^^^^^^^^ meta.group.c +//^^^^^^^ meta.function.c meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.section.group.end.c +// ^ punctuation.section.group.begin.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c + + auto somestruct = { +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.block.c punctuation.section.block.begin.c + .thing = 5, "200", .other = lambda +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c meta.block.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.separator.c +// ^ punctuation.accessor.dot.c +// ^^^^^ variable.other.readwrite.member.c +// ^ keyword.operator.assignment.c + }; +//^^^^^^^^ meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c } - -} - -static const uint32_t * const MACRO funcname(); -/* ^ storage.modifier */ -/* ^ storage.modifier */ -/* ^ support.type */ -/* ^ keyword.operator */ -/* ^ storage.modifier */ -/* ^ entity.name.function */ - -MACRO int -/* ^ storage.type */ -funcname2 -/* ^ entity.name.function */ -() +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + A::~A() { +// ^^ punctuation.accessor.double-colon.c++ +// ^^ variable.function.c++ +// ^ punctuation.section.group.begin.c++ +// ^ meta.group.c punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + delete this; +//^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.operator.word.c++ +// ^^^^ variable.language.c++ +// ^ punctuation.terminator.c + } +//^^^ meta.block.c +// ^ punctuation.section.block.end.c + + template +// ^^^^^^^^^^^^^^^^^^^^^ meta.template.c++ +// ^^^^^^^^ keyword.declaration.c++ +// ^ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ keyword.declaration.type.c++ +// ^ variable.parameter.type.c++ +// ^ punctuation.section.generic.end.c++ + concept MyConcept = std::same_as || requires(T a) { something(a) == 0; }; +//^^ meta.template.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^^ keyword.declaration.c++ +// ^^^^^^^^^ entity.name.concept.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ +// ^ keyword.operator.assignment.c +// ^^ punctuation.accessor.double-colon.c++ +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.c +// ^ punctuation.definition.generic.end.c++ +// ^^ keyword.operator.logical.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c +// ^^^^^^^^ keyword.operator.word.c++ +// ^ meta.group.c++ punctuation.section.group.begin.c++ +// ^^^ meta.function.parameters.c meta.group.c++ +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.function.c meta.block.c punctuation.section.block.begin.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^^^^ variable.function.c +// ^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ punctuation.section.group.end.c +// ^^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c +// ^ punctuation.section.block.end.c +// ^ punctuation.terminator.c + + export module test.module:part; +// ^^^^^^ keyword.other.c++ +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + module test.module:part; +// ^^^^^^ keyword.declaration.module.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + import test.module:part; +// ^^^^^^ keyword.other.import.c++ +// ^^^^^^^^^^^^^^^^^ entity.name.module.c++ +// ^ punctuation.accessor.dot.c++ +// ^ punctuation.separator.partition.c++ +// ^ punctuation.terminator.c + +#import +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c +//^^^^^ keyword.control.import.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.other.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c +@import Foundation; +//^^^^^ keyword.control.objc +// ^ punctuation.terminator.c + +typedef SEL(^sample)(IMP _Nullable a, id _Nonnull b, Class nonnull c, BOOL nullable d); +//^^^^^ keyword.declaration.type.c +// ^^^ storage.type.objc +// ^ keyword.operator.c +// ^^^^^^ entity.name.type.typedef.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^ storage.type.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^ storage.type.objc +// ^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^ storage.type.objc +// ^^^^^^^^ storage.modifier.objc +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ punctuation.terminator.c + +@class NSWindow; +//^^^^ keyword.declaration.class.objc +// ^^^^^^^^ entity.name.type.class.objc +// ^ punctuation.terminator.c + +@protocol MyProtocol +//^^^^^^^ meta.protocol.objc keyword.declaration.class.objc +// ^^^^^^^^^^ meta.protocol.objc entity.name.type.objc +@optional +//^^^^^^^ meta.protocol.objc storage.modifier.objc ++(instancetype) selector; +//^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc +//^^^^^^^^^^^^^ meta.group.c +//^^^^^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end +// ^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.terminator.objc +@required +//^^^^^^^ meta.protocol.objc storage.modifier.objc +-(NSRect) someSelector:(__nonnull id)param withOther:(__unused)param2; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.protocol.objc meta.function.selector.objc +//^^^^^^^ meta.group.c +//^^^^^^ support.type.cocoa.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.c +// ^^^^^^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.protocol.objc keyword.declaration.interface.end.objc + +@interface MyClass(Category) __attribute__((objc_runtime_name("My_Class"))) : NSObject +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^^ keyword.declaration.class.objc +// ^^^^^^^ entity.name.type.objc +// ^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ entity.name.type.category.objc +// ^ meta.group.c punctuation.section.group.end.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^ storage.modifier.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^ string.quoted.double.c +// ^ punctuation.definition.string.begin.c +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.section.group.end.c +// ^ punctuation.separator.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^ punctuation.definition.generic.end.c++ { - -} - -MACRO_CALL(int) macro_prefixed_func(){} -/*^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^ meta.group */ -/* ^ punctuation.section.group.begin */ -/* ^ punctuation.section.group.end */ -/* ^ entity.name.function */ - -int* return_type_pointer_no_space(){} -/* ^ entity.name.function */ - -int& return_type_ref_no_space(){} -/* ^ entity.name.function */ - -// Make sure there isn't an incorrect match here since this is not a valid -// function definition -int32 -/* <- - entity.name.function */ -() {} - -_declspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ -__declspec(deprecated("bla")) void func2(int) {} -/* <- storage.modifier - variable.function */ -/* ^ storage.modifier - variable.function */ -/* ^ string.quoted.double punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double - punctuation */ -/* ^ string.quoted.double punctuation */ -/* ^^ punctuation - invalid */ -/* ^ entity.name.function */ -__notdeclspec(deprecated("bla")) void func2(int) {} -/* <- meta.function-call variable.function */ -/* ^ entity.name.function */ - -///////////////////////////////////////////// -// Paths/identifiers -///////////////////////////////////////////// - -void sayHi() + @public int a; +//^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ punctuation.terminator.c + @protected NSDictionary* b; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ punctuation.terminator.c + @private char* d; +//^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^ storage.type.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c + @package sample e; +//^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c +} + +@property(readwrite, nonatomic) IBOutlet NSButton* btn; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.terminator.c +@property(readonly, getter=myGetE) IBInspectable sample e; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc +//^^^^^^^ keyword.other.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.separator.c +// ^^^^^^ storage.modifier.objc +// ^ keyword.operator.assignment.objc +// ^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.group.end.objc +// ^^^^^^^^^^^^^ storage.modifier.objc +// ^ punctuation.terminator.c + +-(void)someSelector:(void*)a; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interface.objc meta.function.selector.objc +//^^^^^ meta.group.c +//^^^^ storage.type.c +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^ meta.group.c +// ^^^^ storage.type.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.c +// ^ variable.parameter.objc +// ^ punctuation.terminator.objc +@end +//^^ meta.interface.objc keyword.declaration.interface.end.objc + +@implementation MyClass +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc +//^^^^^^^^^^^^^ meta.implementation.objc keyword.declaration.class.objc +// ^^^^^^^ meta.implementation.objc entity.name.type.objc +@synthesize e; +//^^^^^^^^^^^^ meta.implementation.objc +//^^^^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c +@dynamic btn; +//^^^^^^^^^^^ meta.implementation.objc +//^^^^^^ keyword.other.objc +// ^ punctuation.terminator.c + +-(IBAction) someSelector:(__nonnull id)param withOther:(__unused)param2 __attribute__((objc_direct)) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.function.selector.objc +//^^^^^^^^^ meta.group.c +//^^^^^^^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^ variable.parameter.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^ meta.group.c +// ^^^^^^^^ storage.modifier.objc +// ^ punctuation.section.group.end.c +// ^^^^^^ variable.parameter.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c meta.attribute.c +// ^^^^^^^^^^^^^ storage.modifier.c +// ^^ punctuation.section.group.begin.c +// ^^^^^^^^^^^ constant.other.objc +// ^^ punctuation.section.group.end.c { - std::cout << "Hi!\n"; -/* ^ punctuation.accessor */ - Print(3); -/* ^ variable.function */ - func_call(foo -/* ^ meta.function-call */ - ); - - if (::std::foo()) {} -/* ^^^ variable.function */ -/* ^^ punctuation.accessor */ -/* ^^ punctuation.accessor */ - - foobaz(); -/* ^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<>(); -/* ^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - foobaz<0>(); -/* ^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^ variable.function */ -/* ^ punctuation.definition.generic.begin */ -/* ^ meta.number */ -/* ^ punctuation.definition.generic.end */ -/* ^^ meta.group */ - - ::myns::foo(); -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^ variable.function */ -/* ^^^ storage.type */ - - myns::FooClass{42}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ - - ::myns::BarClass{}; -/* ^^ punctuation.accessor.double-colon */ -/* ^^ punctuation.accessor.double-colon */ -/* ^^^^^^^^^^^^^^^^^^^^^ meta.function-call */ -/* ^^^^^^^^ variable.function */ -/* ^^^ storage.type */ - - int a[5]; -/* ^^^ meta.brackets */ -/* ^ punctuation.section.brackets.begin */ -/* ^ punctuation.section.brackets.end */ - - std::cout << ">> Hi!\n"; -/* ^^ keyword.operator.arithmetic.c */ + [super someSelector:param withOther:param2]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^ variable.language.objc +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __block int i = 1; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^ keyword.operator.assignment.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.terminator.c + __strong NSString* j = [NSString stringWithFormat:@"Hello, World! %@", @314, nil]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^ string.quoted.double.objc +// ^^ punctuation.definition.string.begin.objc +// ^^ constant.other.placeholder.objc +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.separator.c +// ^ constant.numeric.objc +// ^^^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c +// ^^^ constant.language.null.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + __weak NSNumber* k = @'3'; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^ string.quoted.single.c +// ^^ punctuation.definition.string.begin.objc +// ^ punctuation.definition.string.end.c++ +// ^ punctuation.terminator.c + __autoreleasing NSView* a = [[NSView alloc] init]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin +// ^^^^^^ support.class.cocoa.objc +// ^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + + NSArray* f = @[ +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^ support.class.cocoa.objc +// ^ meta.template.c++ punctuation.definition.generic.begin.c++ +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ punctuation.definition.generic.end.c++ +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ + @314.5, +//^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ punctuation.separator.c + @0x314LL, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.hexadecimal.c +// ^^ constant.numeric.base.c +// ^^^ constant.numeric.value.c +// ^^ constant.numeric.suffix.c +// ^ punctuation.separator.c + @0314e10, +//^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c + @0b1010u +//^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.brackets.square.c +// ^ constant.numeric.objc +// ^^^^^^^ meta.number.integer.binary.c +// ^^ constant.numeric.base.c +// ^^^^ constant.numeric.value.c +// ^ constant.numeric.suffix.c + ]; +//^^^^ meta.implementation.objc meta.block.c +//^^^ meta.brackets.square.c +// ^ punctuation.section.brackets.end +// ^ punctuation.terminator.c + + NSDictionary* g = @{ +//^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.c +// ^ keyword.operator.assignment.c +// ^^ meta.mapping.objc punctuation.section.mapping.begin.objc + (__bridge id)kValue1 : (__bridge NSViewController)kValue2, +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.objc +// ^^ storage.type.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^^^^^^^^^ support.class.cocoa.leopard.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ punctuation.separator.c + (__bridge NSWindow)kValue3 : @YES +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.mapping.objc +// ^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ punctuation.section.group.end +// ^^^^^^^ constant.other.variable.mac-classic.c +// ^ keyword.operator.ternary.c +// ^^^^ constant.language.boolean.true.objc + }; +//^^^^ meta.implementation.objc meta.block.c +//^^^ meta.mapping.objc +// ^ punctuation.section.mapping.end +// ^ punctuation.terminator.c + + [g respondsToSelector:@selector(doSomething:withSomething:)]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.objc +// ^^^^^^^^^ keyword.operator.word.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.selector.method-name.objc support.function.objc +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.brackets.end.objc + if (@available(iOS 10.4, macOS 11.3, *)) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^ keyword.control.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.available.objc +// ^^^^^^^^^^ keyword.operator.word.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.objc +// ^ punctuation.section.group.begin.objc +// ^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^^^^^ support.constant.platform.objc +// ^^^^ constant.numeric.version.objc +// ^ punctuation.separator.c +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end.objc +// ^ punctuation.section.group.end.c +// ^ meta.block.c punctuation.section.block.begin.c + [[[g allValues] objectAtIndex: 1] +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.section.brackets.end.objc +// ^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.section.brackets.end.objc + perform: @encode(int) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ keyword.operator.word.objc +// ^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^^^ storage.type.c +// ^ punctuation.section.group.end + with: @NO +//^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.bracketed.objc +// ^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^ constant.language.boolean.false.objc + ]; +//^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } +//^^^ meta.implementation.objc meta.block.c meta.block.c +// ^ punctuation.section.block.end + + return [NSClassFromString([NSString stringWithUTF8String:self.j.UTF8String]) someSelector:^(__contravariant NSObject* a, __covariant int const* b) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^^^^^^^^^^ support.function.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.bracketed.objc +// ^ meta.brackets.square.objc punctuation.section.brackets.begin.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^^^^^^^^^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^ variable.language.objc +// ^ punctuation.accessor.dot.c +// ^ variable.other.readwrite.member.c +// ^ punctuation.accessor.dot.c +// ^^^^^^^^^^ variable.other.readwrite.member.c +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.section.group.end.c +// ^^^^^^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^ meta.function.block.objc keyword.operator.bitwise.objc +// ^ punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^^^^^^^^ storage.modifier.objc +// ^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c++ +// ^ punctuation.separator.c +// ^^^^^^^^^^^ storage.modifier.objc +// ^^^ storage.type.c +// ^^^^^ storage.modifier.c +// ^ keyword.operator.arithmetic.c +// ^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.objc punctuation.section.block.begin.objc + @try { +//^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +// ^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + [Nil message: (a + b) ? @true : @false]; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^ meta.bracketed.objc +// ^ punctuation.section.brackets.begin +// ^^^ constant.language.null.objc +// ^^^^^^^ entity.name.function.method.objc +// ^ punctuation.separator.arguments.objc +// ^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin +// ^ keyword.operator.arithmetic.c +// ^ punctuation.section.group.end +// ^ keyword.operator.ternary.c +// ^^^^^ constant.language.boolean.true.objc +// ^ keyword.operator.ternary.c +// ^^^^^^ constant.language.boolean.false.objc +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c + } @catch(NSException* exc) { +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.bracketed.objc meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^^ keyword.control.exception.objc +// ^ meta.group.objc punctuation.section.group.begin.objc +// ^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c++ +// ^^^^^^^^^^^ support.class.cocoa.objc +// ^ keyword.operator.arithmetic.c +// ^^^ variable.parameter.c++ +// ^ punctuation.section.group.end.c++ +// ^ meta.block.c punctuation.section.block.begin.c + return NO; +//^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^ constant.language.boolean.false.objc +// ^ punctuation.terminator.c + } @finally { +//^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c +//^^^^^^^ meta.block.c +// ^ punctuation.section.block.end +// ^^^^^^^^ keyword.control.exception.objc +// ^ meta.block.c punctuation.section.block.begin + return YES; +//^^^^^^^^^^^^^^^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^^^^^^ keyword.control.flow.return.c +// ^^^ constant.language.boolean.true.objc +// ^ punctuation.terminator.c + } +//^^^^^^^ meta.implementation.objc meta.block.c meta.block.c meta.block.c +// ^ punctuation.section.block.end + }]; +//^^^^^ meta.implementation.objc meta.block.c +//^^^ meta.block.c +// ^ punctuation.section.block.end +// ^ punctuation.section.brackets.end.objc +// ^ punctuation.terminator.c } - -///////////////////////////////////////////// -// Objective-C Interface -///////////////////////////////////////////// - -@interface Person : NSObject -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ -@property (readonly) NSString *firstName; -/* <- keyword.other punctuation.definition.keyword */ -/*^ keyword.other */ -@property (readonly, nullable, class) NSString *lastName; -/* <- keyword.other punctuation.definition.keyword */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute */ -/* ^ punctuation.separator.objc */ -/* ^ keyword.other.property.attribute. */ -/* ^ punctuation.section.scope.end */ -- (NSString*)formatWithPattern:(NSString*)pattern __attribute__((swift_name("format(pattern:)"))); -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.objc++*/ -/* ^^^^^^^^^^^^^ storage.modifier.objc++*/ -/* ^^^^^^^^^^^^^^^^^^ string.quoted.double.c*/ @end -/* <- storage.type punctuation.definition.storage.type */ -/*^ storage.type */ - -NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@", -/*^ support.class */ -/* ^ keyword.operator */ -/* ^ meta.bracketed punctuation.section.scope.begin */ -/* ^ support.function.any-method */ -/* ^^ string.quoted.double punctuation.definition.string.begin */ - attributeName, attributeValue]; -/* ^ meta.bracketed punctuation.section.scope.end */ - -@implementation Person -- (void)debugOutput:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2) -/* ^ punctuation.separator */ -/* ^^^ keyword.operator.variadic */ -/* ^ variable.function */ -{} -@end - -///////////////////////////////////////////// -// Includes -///////////////////////////////////////////// - -#import -/* <- meta.preprocessor.import keyword.control.import.import */ - -#include -/* <- meta.preprocessor.include keyword.control.import.include */ - -#include "foobar.h" -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.double.include */ -/* ^ punctuation.definition.string.end */ - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ - -#ifdef _GLIBCXX_INCLUDE_NEXT_C_HEADERS -#include_next -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ -#endif - -#include -/* <- keyword.control.import.include */ -/* ^ punctuation.definition.string.begin */ -/* ^^^^^^^^ string.quoted.other.lt-gt.include */ -/* ^ punctuation.definition.string.end */ +//^^ meta.implementation.objc keyword.declaration.interface.end.objc +//^^ meta.implementation.objc keyword.declaration.interface.end.objc From 1055d64978f404ec0c787e22bde81612f775626c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:43:17 -0600 Subject: [PATCH 58/66] Small accessor fixes --- C++/C.sublime-syntax | 2 + C++/syntax_test_c.c | 4 ++ C++/syntax_test_cpp.cpp | 9 ++-- Objective-C/syntax_test_accessor.mm | 68 ----------------------------- Objective-C/syntax_test_objc++.mm | 6 ++- Objective-C/syntax_test_objc.m | 4 ++ 6 files changed, 20 insertions(+), 73 deletions(-) delete mode 100644 Objective-C/syntax_test_accessor.mm diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index db8773bdf0..5a72e729fd 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -590,6 +590,8 @@ contexts: - match: \+\+|-- scope: keyword.operator.arithmetic.c operator.accessor: + - match: \.\. + scope: invalid.illegal.syntax.c - match: (\.|\-\>)(?=\s*{{identifier}}) scope: punctuation.accessor.dot.c branch_point: access diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 0f39de6854..53b934119c 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -886,6 +886,10 @@ // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 9f941861fd..3eb8431503 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -883,6 +883,10 @@ // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c @@ -1832,7 +1836,7 @@ // ^ punctuation.section.generic.end.c++ concept MyConcept = std::same_as || requires(T a) { something(a) == 0; }; //^^ meta.template.c++ -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ // ^^^^^^^ keyword.declaration.c++ // ^^^^^^^^^ entity.name.concept.c++ // ^ meta.template.c++ punctuation.definition.generic.begin.c++ @@ -1863,7 +1867,6 @@ // ^ punctuation.terminator.c export module test.module:part; -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ // ^^^^^^ keyword.other.c++ // ^^^^^^ keyword.declaration.module.c++ // ^^^^^^^^^^^^^^^^^ entity.name.module.c++ @@ -1871,14 +1874,12 @@ // ^ punctuation.separator.partition.c++ // ^ punctuation.terminator.c module test.module:part; -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ // ^^^^^^ keyword.declaration.module.c++ // ^^^^^^^^^^^^^^^^^ entity.name.module.c++ // ^ punctuation.accessor.dot.c++ // ^ punctuation.separator.partition.c++ // ^ punctuation.terminator.c import test.module:part; -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.concept.c++ // ^^^^^^ keyword.other.import.c++ // ^^^^^^^^^^^^^^^^^ entity.name.module.c++ // ^ punctuation.accessor.dot.c++ diff --git a/Objective-C/syntax_test_accessor.mm b/Objective-C/syntax_test_accessor.mm deleted file mode 100644 index 2c28b49af3..0000000000 --- a/Objective-C/syntax_test_accessor.mm +++ /dev/null @@ -1,68 +0,0 @@ -// SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" - -namespace N { - -class X -{ - public: - int a; - int b; -}; - -class Y : public X -{ - public: - int c; -} - -} // namespace N - -int main() -{ - N:: -// ^^ punctuation.accessor -} - -int main() -{ - N::X x; - x. -// ^ punctuation.accessor -} - -int main() -{ - N::X x; - x.. -// ^^ - punctuation.accessor -} - -int main() -{ - N::X x; - x... -// ^^^ keyword - punctuation.accessor -} - -int main() -{ - N::X* x = new X(); - x-> -// ^^ punctuation.accessor -} - -int main() -{ - N::Y y; - y.X:: -// ^ punctuation.accessor -// ^^ punctuation.accessor -} - -int main() -{ - N::Y* y = new Y(); - y->X:: -// ^^ punctuation.accessor -// ^^ punctuation.accessor -} diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index a1c03afdab..83841a81c6 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -1,4 +1,4 @@ -/* SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" */ +// SYNTAX TEST "Packages/Objective-C/Objective-C++.sublime-syntax" // Comment // ^^^^^^^^^^ comment.line.double-slash.c @@ -883,6 +883,10 @@ int test() { // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 55a70df815..86fceaf22b 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -886,6 +886,10 @@ int test() { // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + myunion..s2; +//^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^ invalid.illegal.syntax.c +// ^ punctuation.terminator.c } //^^^ meta.function.c meta.block.c // ^ punctuation.section.block.end.c From 89f92e9dd772e220fb84db8663101425746b1a79 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 4 Mar 2025 19:30:16 -0600 Subject: [PATCH 59/66] Case and arrow pointer fix --- C++/C.sublime-syntax | 24 ++++++++++++++--- C++/syntax_test_c.c | 43 +++++++++++++++++------------ C++/syntax_test_cpp.cpp | 45 ++++++++++++++++++------------- Objective-C/syntax_test_objc++.mm | 45 ++++++++++++++++++------------- Objective-C/syntax_test_objc.m | 43 +++++++++++++++++------------ 5 files changed, 127 insertions(+), 73 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 5a72e729fd..cb148c82ef 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -488,6 +488,17 @@ contexts: 1: entity.name.label.c 2: punctuation.separator.c + case: + - match: \bcase\b + scope: keyword.control.case.c + push: case-body + case-body: + - match: ':' + scope: punctuation.separator.c + pop: 1 + - include: expression + - include: eof-pop + access: - match: '{{identifier}}' scope: variable.other.readwrite.member.c @@ -592,8 +603,10 @@ contexts: operator.accessor: - match: \.\. scope: invalid.illegal.syntax.c - - match: (\.|\-\>)(?=\s*{{identifier}}) - scope: punctuation.accessor.dot.c + - match: (?:(\.)|(\-\>))(?=\s*{{identifier}}) + captures: + 1: punctuation.accessor.dot.c + 2: punctuation.accessor.arrow.c branch_point: access branch: [access, pop-immediately] - match: \.|\-\> @@ -748,7 +761,12 @@ contexts: - match: \bgoto\b scope: keyword.control.flow.goto.c keyword.control: - - match: \b(?:if|else|for|while|do|switch|case|default)\b + - include: case + - match: \b(default)\s*(:) + captures: + 1: keyword.control.case.c + 2: punctuation.separator.c + - match: \b(?:if|else|for|while|do|switch|default)\b scope: keyword.control.c keyword.asm: - match: \b(asm|__asm|__asm__)\b diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 53b934119c..7e9906837f 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -645,26 +645,26 @@ //^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c // ^ meta.block.c punctuation.section.block.begin case 0: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c goto exit; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^ keyword.control.flow.goto.c // ^ punctuation.terminator.c case 1: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c case 2 + 3: -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.arithmetic.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c if (a + b < i) {} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^ keyword.control.c @@ -699,9 +699,9 @@ // ^^^^^ keyword.control.flow.break.c // ^ punctuation.terminator.c default: -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^^^^ keyword.control.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c continue; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^^^^^ keyword.control.flow.continue.c @@ -886,6 +886,15 @@ // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c myunion..s2; //^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c // ^^ invalid.illegal.syntax.c diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 3eb8431503..5e3b2e5208 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -643,26 +643,26 @@ //^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c // ^ meta.block.c punctuation.section.block.begin case 0: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c goto exit; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^ keyword.control.flow.goto.c // ^ punctuation.terminator.c case 1: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c case 2 + 3: -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.arithmetic.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c if (a + b < i) {} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^ keyword.control.c @@ -697,9 +697,9 @@ // ^^^^^ keyword.control.flow.break.c // ^ punctuation.terminator.c default: -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^^^^ keyword.control.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c continue; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^^^^^ keyword.control.flow.continue.c @@ -883,6 +883,15 @@ // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c myunion..s2; //^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c // ^^ invalid.illegal.syntax.c @@ -1617,7 +1626,7 @@ //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c // ^^^^^^ keyword.control.flow.return.c // ^^^^ variable.language.c++ -// ^^ punctuation.accessor.dot.c +// ^^ punctuation.accessor.arrow.c // ^^^^^^^^ variable.other.readwrite.member.c // ^ punctuation.terminator.c } diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index 83841a81c6..2e6bf606ca 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -643,26 +643,26 @@ void fun(int const a[]) { //^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c // ^ meta.block.c punctuation.section.block.begin case 0: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c goto exit; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^ keyword.control.flow.goto.c // ^ punctuation.terminator.c case 1: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c case 2 + 3: -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.arithmetic.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c if (a + b < i) {} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^ keyword.control.c @@ -697,9 +697,9 @@ void fun(int const a[]) { // ^^^^^ keyword.control.flow.break.c // ^ punctuation.terminator.c default: -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^^^^ keyword.control.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c continue; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^^^^^ keyword.control.flow.continue.c @@ -883,6 +883,15 @@ int test() { // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c++ +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c myunion..s2; //^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c // ^^ invalid.illegal.syntax.c @@ -1617,7 +1626,7 @@ int main(int argc, char const* argv[]) { //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c++ meta.class.c++ meta.function.c meta.block.c // ^^^^^^ keyword.control.flow.return.c // ^^^^ variable.language.c++ -// ^^ punctuation.accessor.dot.c +// ^^ punctuation.accessor.arrow.c // ^^^^^^^^ variable.other.readwrite.member.c // ^ punctuation.terminator.c } diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 86fceaf22b..6c0513c6c7 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -645,26 +645,26 @@ void fun(int const a[]) { //^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c // ^ meta.block.c punctuation.section.block.begin case 0: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c goto exit; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^ keyword.control.flow.goto.c // ^ punctuation.terminator.c case 1: -//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c case 2 + 3: -//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^ keyword.control.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.arithmetic.c -// ^ meta.number.integer.decimal.c constant.numeric.value.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^ keyword.control.case.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ keyword.operator.arithmetic.c +// ^ meta.number.integer.decimal.c constant.numeric.value.c +// ^ punctuation.separator.c if (a + b < i) {} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^ keyword.control.c @@ -699,9 +699,9 @@ void fun(int const a[]) { // ^^^^^ keyword.control.flow.break.c // ^ punctuation.terminator.c default: -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c -// ^^^^^^^ keyword.control.c -// ^ keyword.operator.ternary.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c +// ^^^^^^^ keyword.control.case.c +// ^ punctuation.separator.c continue; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c meta.block.c meta.block.c meta.block.c // ^^^^^^^^ keyword.control.flow.continue.c @@ -886,6 +886,15 @@ int test() { // ^ keyword.operator.assignment.c // ^^ meta.number.integer.decimal.c constant.numeric.value.c // ^ punctuation.terminator.c + (&myunion)->s2; +//^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c +// ^^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^ keyword.operator.bitwise.c +// ^ punctuation.section.group.end.c +// ^^ punctuation.accessor.arrow.c +// ^^ variable.other.readwrite.member.c +// ^ punctuation.terminator.c myunion..s2; //^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c // ^^ invalid.illegal.syntax.c From 29a3f2b67c6032e183470391512b36580ef9cbbf Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:01:23 -0600 Subject: [PATCH 60/66] Minor Fixes --- C++/C++.sublime-syntax | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 3801ad6f0e..4a7d630003 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -340,7 +340,7 @@ contexts: 2: meta.group.c++ punctuation.section.group.begin.c++ set: [lambda-try-not, enclosure.parenthesis] - - match: (\])\s*(\{|\-\>|mutable\b) + - match: \]\s*(?:\{|\-\>|mutable\b) fail: lambda enclosure.outer-block: - meta_content_scope: meta.block.c++ @@ -551,12 +551,12 @@ contexts: scope: keyword.control.exception.c++ - match: \bco_(await|yield|return)\b scope: keyword.control.c++ - - match: \b(requires)\s*(\()\b + - match: \b(requires)\s*(\() captures: 1: keyword.operator.word.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ push: [function-tail, function-params] - - match: \b(requires)\b + - match: \brequires\b scope: keyword.operator.word.c++ constant: @@ -583,11 +583,9 @@ contexts: - meta_prepend: true - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b scope: keyword.operator.word.c++ - - match: \b(and|x?or|not)(_eq)?\b + - match: \b(?:and|xor|or|not)(?:_eq)?\b scope: keyword.operator.logical.c++ - - match: \b(bit(and|or)|compl)\b - scope: keyword.operator.bitwise.c++ - - match: \bxor(_eq)\b + - match: \b(?:bit(?:and|or)|compl)\b scope: keyword.operator.bitwise.c++ operator.comparison: - meta_prepend: true From 6b14a5fa3f867433f30eaaf35aae48181f54b63d Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:22:04 -0600 Subject: [PATCH 61/66] Minor Fixes --- C++/C++.sublime-syntax | 40 +++++++++--------- C++/C.sublime-syntax | 58 +++++++++++++------------- Objective-C/Objective-C.sublime-syntax | 16 +++---- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 4a7d630003..4aa4409632 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -51,9 +51,9 @@ contexts: - match: (?={{identifier}}\s*<) branch_point: function-template branch: [function-template, consume-ident] - - match: \b{{identifier}}\b + - match: '{{identifier}}' function-template: - - match: ({{identifier}})(?=\s*<) + - match: '{{identifier}}(?=\s*<)' scope: entity.name.function.c++ set: function-template-body function-template-body: @@ -102,7 +102,7 @@ contexts: function-tail: - meta_prepend: true - - match: \b(override|final|noexcept)\b + - match: \b(?:override|final|noexcept)\b scope: storage.modifier.c++ - match: ':' scope: punctuation.separator.initializer-list.begin.c++ @@ -130,7 +130,7 @@ contexts: initializer-list: - meta_scope: meta.method.initializer-list.c++ - - match: \b{{identifier}}\b + - match: '{{identifier}}' scope: variable.other.readwrite.member.c++ push: initializer-list-body - include: punctuation.comma @@ -156,7 +156,7 @@ contexts: 2: punctuation.section.group.begin.c++ push: enclosure.parenthesis template-call: - - match: \b{{identifier}}\b + - match: '{{identifier}}' scope: entity.name.function.c++ set: template-call-body template-call-body: @@ -221,7 +221,7 @@ contexts: - match: \busing\b scope: keyword.declaration.c++ push: type.using - - match: \b(class|struct)\b + - match: \b(?:class|struct)\b scope: keyword.declaration.c++ push: class - match: \btemplate\b @@ -283,7 +283,7 @@ contexts: - match: \b set: type.template-name - include: expression - - match: \b(typename|class)\b + - match: \b(?:typename|class)\b scope: keyword.declaration.type.c++ - include: expression type.template-requires: @@ -294,7 +294,7 @@ contexts: type.template-name: - match: (?=[\]\}\);]) # Fallback pop: 1 - - match: \b(typename|class)\b + - match: \b(?:typename|class)\b scope: keyword.declaration.type.c++ - include: expression-identifiers - match: ({{identifier}})\s*(\[) @@ -397,7 +397,7 @@ contexts: pop: 2 # skip params generic: # override, replace with {} constructor - - match: \b({{identifier}})\s*(\{) + - match: ({{identifier}})\s*(\{) captures: 1: variable.function.c++ 2: meta.block.c punctuation.section.block.begin.c++ @@ -426,7 +426,7 @@ contexts: scope: entity.name.class.c++ set: - include: template - - match: (::) + - match: '::' fail: class-name - match: (?=\S) pop: 2 @@ -463,13 +463,13 @@ contexts: qualified-ident: - match: \btypename\b scope: storage.modifier.c++ - - match: (::) + - match: '::' scope: punctuation.accessor.double-colon.c++ - match: '{{identifier}}' push: qualified-ident-body - include: else-pop qualified-ident-body: - - match: (::) + - match: '::' scope: punctuation.accessor.double-colon.c++ pop: 1 - include: template @@ -490,7 +490,7 @@ contexts: fail: template - match: (?=\&\&\s*[^>]) fail: template - - match: (>) + - match: '>' scope: punctuation.definition.generic.end.c++ pop: true - include: expression @@ -521,11 +521,11 @@ contexts: keyword: - meta_append: true - - match: \b(export|friend|operator)\b + - match: \b(?:export|friend|operator)\b scope: keyword.other.c++ keyword.type: - meta_prepend: true - - match: \b(w?char(8|16|32)_t)|wchar_t\b + - match: \b(?:w?char(?:8|16|32)_t)|wchar_t\b scope: storage.type.c++ - match: \b(decltype)\s*(\() captures: @@ -536,9 +536,9 @@ contexts: scope: keyword.declaration.type.c++ keyword.storage: - meta_prepend: true - - match: '\b(private|protected|public)\s*:' + - match: '\b(?:private|protected|public)\s*:' scope: storage.modifier.c++ - - match: \b(const(expr|eval|init)|explicit|mutable|private|protected|public|virtual|typename|alignas)\b + - match: \b(?:const(?:expr|eval|init)|explicit|mutable|private|protected|public|virtual|typename|alignas)\b scope: storage.modifier.c++ keyword.control: - meta_prepend: true @@ -547,9 +547,9 @@ contexts: 1: keyword.control.exception.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ push: function-params - - match: \b(try|catch|finally|throw)\b + - match: \b(?:try|catch|finally|throw)\b scope: keyword.control.exception.c++ - - match: \bco_(await|yield|return)\b + - match: \bco_(?:await|yield|return)\b scope: keyword.control.c++ - match: \b(requires)\s*(\() captures: @@ -581,7 +581,7 @@ contexts: scope: keyword.operator.bitwise.c++ operator.word: - meta_prepend: true - - match: \b((const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b + - match: \b(?:(?:const|static|reinterpret|dynamic)_cast|static_assert|delete|new|typeid|noexcept)\b scope: keyword.operator.word.c++ - match: \b(?:and|xor|or|not)(?:_eq)?\b scope: keyword.operator.logical.c++ diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index cb148c82ef..ef2f2131f0 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -57,26 +57,26 @@ contexts: - include: comment - include: eol-pop - - match: '{{dir_start}}(else|endif)\b' + - match: '{{dir_start}}(?:else|endif)\b' scope: keyword.control.import.c - - match: '{{dir_start}}(include|include_next)\b' + - match: '{{dir_start}}(?:include|include_next)\b' scope: keyword.control.import.c push: preprocessor.include - - match: '{{dir_start}}(embed)\b' + - match: '{{dir_start}}embed\b' scope: keyword.control.import.c push: preprocessor.embed - - match: '{{dir_start}}(define)\b' + - match: '{{dir_start}}define\b' scope: keyword.control.import.c push: preprocessor.define - - match: '{{dir_start}}(error)\b' + - match: '{{dir_start}}error\b' scope: keyword.control.import.error.c push: preprocessor.diagnostic - - match: '{{dir_start}}(warning)\b' + - match: '{{dir_start}}warning\b' scope: keyword.control.import.warning.c push: preprocessor.diagnostic @@ -110,13 +110,13 @@ contexts: 1: entity.name.macro.c support.macro.c 2: punctuation.section.group.begin.c set: preprocessor.define-params - - match: \b{{identifier}}\b + - match: '{{identifier}}' scope: entity.name.macro.c support.macro.c embed: preprocessor.define-body escape: (? Date: Thu, 6 Mar 2025 23:45:00 -0600 Subject: [PATCH 62/66] More fixes --- C++/C.sublime-syntax | 24 ++++++++++++++++++------ C++/syntax_test_c.c | 23 +++++++++++++---------- C++/syntax_test_cpp.cpp | 12 +++++++----- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index ef2f2131f0..19db83c38d 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -23,6 +23,9 @@ contexts: prototype: - include: comment - include: preprocessor + - match: ^\s*({{likely_macro}})\s*$ + captures: + 1: meta.assumed-macro.c ###[ PREPROCESSOR ]############################################################ @@ -54,6 +57,7 @@ contexts: scope: keyword.control.import.c push: - meta_scope: meta.preprocessor.c + - include: preprocessor.line-escape - include: comment - include: eol-pop @@ -104,24 +108,28 @@ contexts: - include: preprocessor.line-escape - include: eol-pop preprocessor.define: + - meta_scope: meta.preprocessor.macro.c - include: eol-pop - match: \s*({{identifier}})(\() captures: 1: entity.name.macro.c support.macro.c - 2: punctuation.section.group.begin.c + 2: meta.group.c punctuation.section.group.begin.c meta.preprocessor.macro.parameters.c set: preprocessor.define-params - match: '{{identifier}}' scope: entity.name.macro.c support.macro.c embed: preprocessor.define-body escape: (? b); -//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c -//^^^^^^^^^^^ meta.block.c -// ^ punctuation.section.block.end -// ^^^^^ keyword.control.c -// ^^^^^^^ meta.group.c -// ^ punctuation.section.group.begin -// ^ keyword.operator.comparison.c -// ^ punctuation.section.group.end -// ^ punctuation.terminator.c + } while (a --> b); +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c meta.block.c meta.block.c +//^^^^^^^^^^^ meta.block.c +// ^ punctuation.section.block.end.c +// ^^^^^ keyword.control.c +// ^^^^^^^^^ meta.group.c +// ^ punctuation.section.group.begin.c +// ^^ keyword.operator.arithmetic.c +// ^ keyword.operator.comparison.c +// ^ punctuation.section.group.end.c +// ^ punctuation.terminator.c } //^^^^^^^ meta.function.c meta.block.c meta.block.c // ^ punctuation.section.block.end @@ -1106,6 +1107,8 @@ ///////////////////////////////////////////// // Preprocessor ///////////////////////////////////////////// + ASSUME_MACRO +// ^^^^^^^^^^^^ meta.assumed-macro.c #include //^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.include.c diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 5e3b2e5208..8266e3e531 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -1216,14 +1216,17 @@ // ^ punctuation.definition.string.end.c++ // ^^^^^^^^ variable.function.c++ R"RAW( -// ^^^^^^ string.quoted.raw.c++ +// ^^^^^^ string.quoted.double.raw.c++ +// ^ storage.type.string.c++ +// ^ punctuation.definition.string.begin.c++ +// ^^^^ constant.other.placeholder.c++ // ^ storage.type.string.c++ // ^ punctuation.definition.string.begin.c++ // ^^^^ constant.other.placeholder.c++ raw string )STR" -//^^^^^^^^^^^^^^^^^^ string.quoted.raw.c++ +//^^^^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ )RAW"_literal -//^^^^^^^^^^^^^^^ string.quoted.raw.c++ +//^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ // ^^^^ constant.other.placeholder.c++ // ^ punctuation.definition.string.end.c++ // ^^^^^^^^ variable.function.c++ @@ -1756,7 +1759,7 @@ //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.c // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.c // ^ punctuation.section.group.begin.c -// ^^ meta.lambda.c++ +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.lambda.c++ // ^ meta.brackets.square.c++ punctuation.section.brackets.begin.c++ // ^ storage.modifier.capture.c++ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.c @@ -1779,7 +1782,6 @@ // ^ variable.parameter.c++ // ^ punctuation.section.group.end.c++ // ^ meta.function.c meta.block.c punctuation.section.block.begin.c - })(5, 10); //^^^^^^^^^^^^^^^^ meta.block.c //^^^^^^^^^^^^^^^ meta.group.c From dcbfd872c153830ee39648865e8809262f9d0f6c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:49:57 -0600 Subject: [PATCH 63/66] Forgot to commit this file --- C++/C++.sublime-syntax | 43 ++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 4aa4409632..ede8a96df9 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -193,7 +193,8 @@ contexts: scope: keyword.declaration.module.c++ push: module-name - match: \b(import)\s*(?=<) - scope: keyword.other.import.c++ + captures: + 1: keyword.other.import.c++ push: string.angled - match: \bimport\b scope: keyword.other.import.c++ @@ -201,6 +202,8 @@ contexts: module-name: - meta_content_scope: entity.name.module.c++ - match: '{{identifier}}' + - match: \.(?=\W) + scope: invalid.illegal.unexpected-character.c++ - match: \. scope: punctuation.accessor.dot.c++ - match: ':' @@ -221,7 +224,7 @@ contexts: - match: \busing\b scope: keyword.declaration.c++ push: type.using - - match: \b(?:class|struct)\b + - match: \b(?:struct|class)\b scope: keyword.declaration.c++ push: class - match: \btemplate\b @@ -333,7 +336,10 @@ contexts: enclosure.brackets: - meta_prepend: true - match: (\])\s*(<) - fail: lambda + captures: + 1: punctuation.section.brackets.end.c++ + 2: keyword.control.comparison.c++ + set: lambda-try-not-template - match: (\])\s*(\() captures: 1: punctuation.section.brackets.end.c++ @@ -347,6 +353,13 @@ contexts: - match: \} scope: meta.block.c++ punctuation.section.block.end.c++ pop: 1 + - match: '({{likely_macro}})\s*(\()' + captures: + 1: variable.function.assumed-macro.c++ + 2: meta.group.c++ punctuation.section.group.begin.c++ + push: call-body + - match: '{{likely_macro}}' + scope: meta.assumed-macro.c++ - include: main lambda-enclosure: # for ObjC++ @@ -362,12 +375,21 @@ contexts: - match: \{ fail: lambda - include: else-pop + lambda-try-not-template: + - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) + pop: 1 + - match: (?=\&\&\s*[^>,]) + pop: 1 + - match: '>' + fail: lambda + - include: expression lambda: - meta_scope: meta.lambda.c++ - match: '[&=](?=\s*[,\]])' scope: storage.modifier.capture.c++ - match: (?=\S) - set: + push: + - pop-twice - function-tail - function-params - lambda-template @@ -488,7 +510,7 @@ contexts: try-template-body: - match: (?=\)|\}|\]|\|\||;|\band\b|\bor\b) fail: template - - match: (?=\&\&\s*[^>]) + - match: (?=\&\&\s*[^>,]) fail: template - match: '>' scope: punctuation.definition.generic.end.c++ @@ -511,12 +533,13 @@ contexts: fail: access likely-macro: - - match: '{{likely_macro}}' - - match: '({{identifier}})\s*(\()' + - match: '({{likely_macro}})\s*(\()' captures: - 1: variable.function.c++ + 1: variable.function.assumed-macro.c++ 2: meta.group.c++ punctuation.section.group.begin.c++ - push: enclosure.parenthesis + push: call-body + - match: '{{likely_macro}}' + scope: meta.assumed-macro.c++ - include: else-pop keyword: @@ -616,7 +639,7 @@ contexts: 2: variable.function.c++ pop: 1 string.raw: - - meta_scope: string.quoted.raw.c++ + - meta_scope: string.quoted.double.raw.c++ - match: (\)\3)(\")({{literal_operator}})? captures: 1: constant.other.placeholder.c++ From ef1450c12c700742f6a97406d190c1ae63c055da Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 7 Mar 2025 09:21:19 -0600 Subject: [PATCH 64/66] Typo fix --- C++/C.sublime-syntax | 2 +- Objective-C/syntax_test_objc++.mm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 19db83c38d..867ac990c8 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -509,7 +509,7 @@ contexts: scope: punctuation.separator.c pop: 1 - include: expression - - include: eof-pop + - include: eol-pop access: - match: '{{identifier}}' diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index 2e6bf606ca..ca5dbc5c48 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -1216,14 +1216,14 @@ int main(int argc, char const* argv[]) { // ^ punctuation.definition.string.end.c++ // ^^^^^^^^ variable.function.c++ R"RAW( -// ^^^^^^ string.quoted.raw.c++ +// ^^^^^^ string.quoted.double.raw.c++ // ^ storage.type.string.c++ // ^ punctuation.definition.string.begin.c++ // ^^^^ constant.other.placeholder.c++ raw string )STR" -//^^^^^^^^^^^^^^^^^^ string.quoted.raw.c++ +//^^^^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ )RAW"_literal -//^^^^^^^^^^^^^^^ string.quoted.raw.c++ +//^^^^^^^^^^^^^^^ string.quoted.double.raw.c++ // ^^^^ constant.other.placeholder.c++ // ^ punctuation.definition.string.end.c++ // ^^^^^^^^ variable.function.c++ From 6b2206ec8956e0f0d30ea13ff7a6cd3a31db8123 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 7 Mar 2025 10:30:54 -0600 Subject: [PATCH 65/66] Fix struct, union, enum and more --- C++/C++.sublime-syntax | 16 +--- C++/C.sublime-syntax | 120 +++++++++++++++++++----------- C++/syntax_test_c.c | 45 +++++------ C++/syntax_test_cpp.cpp | 4 +- Objective-C/syntax_test_objc++.mm | 4 +- Objective-C/syntax_test_objc.m | 6 +- 6 files changed, 109 insertions(+), 86 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index ede8a96df9..f778682856 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -260,8 +260,10 @@ contexts: - meta_scope: meta.using.c++ - meta_content_scope: entity.name.namespace.c++ - match: (?={{qualified}}) - push: qualified-ident - - include: else-pop + push: + - pop-twice + - qualified-ident + - include: eol-pop type.template: - meta_scope: meta.template.c++ @@ -532,16 +534,6 @@ contexts: - match: \< fail: access - likely-macro: - - match: '({{likely_macro}})\s*(\()' - captures: - 1: variable.function.assumed-macro.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: call-body - - match: '{{likely_macro}}' - scope: meta.assumed-macro.c++ - - include: else-pop - keyword: - meta_append: true - match: \b(?:export|friend|operator)\b diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 867ac990c8..df9b3de597 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -247,7 +247,7 @@ contexts: - match: ({{identifier}})\s*(\() captures: 1: entity.name.function.c - 2: punctuation.section.group.begin.c + 2: meta.group.c punctuation.section.group.begin.c push: - function-tail - function-params @@ -255,7 +255,7 @@ contexts: function-params: - meta_content_scope: meta.function.parameters.c meta.group.c - match: \) - scope: punctuation.section.group.end.c + scope: meta.group.c punctuation.section.group.end.c pop: 1 - match: \}|\] # Fallback scope: invalid.illegal.stray-bracket-end.c @@ -359,20 +359,26 @@ contexts: - include: expression type.enum: - meta_scope: meta.enum.c - - include: call - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.enum.forward-decl.c + - match: '' + push: + - pop-twice + - type.enum-body + - type.enum-body-start + - likely-macro + - type.enum-name + - likely-macro + type.enum-name: + - match: '{{identifier}}\s*(?=;)' + scope: entity.name.enum.forward-declare.c + pop: 4 + - match: '{{identifier}}' + scope: entity.name.enum.c + pop: 1 + - include: else-pop + type.enum-body-start: + - match: \{ + scope: meta.block.c punctuation.section.block.begin.c pop: 1 - - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) - captures: - 1: entity.name.enum.c - set: - - match: \{ - scope: meta.enum.c punctuation.section.block.begin.c - set: type.enum-body - - match: (?=\S) - fail: enum - match: (?=\S) fail: enum type.enum-body: @@ -387,40 +393,54 @@ contexts: - match: \} scope: punctuation.section.block.end.c pop: 1 + type.struct: - meta_scope: meta.struct.c - - include: call - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.enum.forward-decl.c + - match: '' + push: + - pop-twice + - enclosure.block + - type.struct-body + - likely-macro + - type.struct-name + - likely-macro + type.struct-name: + - match: '{{identifier}}\s*(?=;)' + scope: entity.name.struct.forward-declare.c + pop: 4 + - match: '{{identifier}}' + scope: entity.name.struct.c + pop: 1 + - include: else-pop + type.struct-body: + - match: \{ + scope: meta.block.c punctuation.section.block.begin.c pop: 1 - - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) - captures: - 1: entity.name.struct.c - set: - - match: \{ - scope: meta.struct.c meta.block.c punctuation.section.block.begin.c - set: enclosure.block - - match: (?=\S) - fail: struct - match: (?=\S) fail: struct + type.union: - meta_scope: meta.union.c - - include: call - - match: ({{identifier}})\s*(?=;) - captures: - 1: entity.name.enum.forward-decl.c + - match: '' + push: + - pop-twice + - enclosure.block + - type.union-body + - likely-macro + - type.union-name + - likely-macro + type.union-name: + - match: '{{identifier}}\s*(?=;)' + scope: entity.name.union.forward-declare.c + pop: 4 + - match: '{{identifier}}' + scope: entity.name.union.c + pop: 1 + - include: else-pop + type.union-body: + - match: \{ + scope: meta.block.c punctuation.section.block.begin.c pop: 1 - - match: (?:{{identifier}}\s*)*?({{identifier}})?\s*(?:{{likely_macro}}\s*)*(?=\{|$) - captures: - 1: entity.name.union.c - set: - - match: \{ - scope: meta.union.c meta.block.c punctuation.section.block.begin.c - set: enclosure.block - - match: (?=\S) - fail: union - match: (?=\S) fail: union @@ -520,6 +540,16 @@ contexts: fail: access - include: else-pop + likely-macro: + - match: '({{likely_macro}})\s*(\()' + captures: + 1: variable.function.assumed-macro.c + 2: meta.group.c++ punctuation.section.group.begin.c + push: call-body + - match: '{{likely_macro}}' + scope: meta.assumed-macro.c + - include: else-pop + ###[ BASIC OBJECTS ]############################################################ string: @@ -646,7 +676,7 @@ contexts: ( (\.) (?: # 1.1, 1.1e1, 1.1e-1, 1.1f, 1.1e1f, 1.1e-1f, 1.1L, 1.1e1L, 1.1e-1L - \d+ {{dec_exponent}}? + \d[\d']* {{dec_exponent}}? # 1.e1, 1.e-1, 1.e1f, 1.e-1f, 1.e1L, 1.e-1L | {{dec_exponent}} # 1., 1.f, 1.L # but not `..` @@ -659,7 +689,7 @@ contexts: | ({{float_suffix}}) ) ({{dec_suffix}})? # .1, .1e1, .1e-1, .1f, .1e1f, .1e-1f, .1L, .1e1L, .1e-1L - | ( (\.) \d+ {{dec_exponent}}? ) (?: ({{double_suffix}}) | ({{dec_suffix}}) )? + | ( (\.) \d[\d']* {{dec_exponent}}? ) (?: ({{double_suffix}}) | ({{dec_suffix}}) )? ) scope: meta.number.float.decimal.c captures: @@ -861,8 +891,8 @@ variables: double_suffix: '[fFlL]' float_suffix: '[fF]' integer_suffix: '(?:(?:ll|LL)(?!\s*[lL])|(?i)(?:u(?!\w*u)|l(?!\w*l)|i(?!\w*[ij])|j(?!\w*[ij])))+\b' - dec_exponent: '(?:[eE][-+]?\d*)' - hex_exponent: '(?:[pP][-+]?\d*)' + dec_exponent: (?:[eE][-+]?[\d']*) + hex_exponent: (?:[pP][-+]?[\d']*) declspec_item: '(?:allocator|appdomain|deprecated|dllimport|dllexport|empty_bases|hybrid_patchable|jitintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|no_sanitize_address|process|restrict|safebuffers|selectany|thread)' declspec_func: '(?:align|allocate|code_seg|spectre|uuid|deprecated)' diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 809d418ef3..8bdd96220e 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -1,4 +1,5 @@ // SYNTAX TEST "Packages/C++/C.sublime-syntax" +// <- source.c // Comment // ^^^^^^^^^^ comment.line.double-slash.c @@ -69,20 +70,20 @@ // ^^^^ meta.number.float.decimal.c // ^^^ constant.numeric.value.c // ^ constant.numeric.suffix.c - 3.14f 314.l 3.14L -// ^^^^^ meta.number.float.decimal.c -// ^^^^ constant.numeric.value.c -// ^ punctuation.separator.decimal.c -// ^ constant.numeric.suffix.c -// ^^^^^ meta.number.float.decimal.c -// ^^^^ constant.numeric.value.c -// ^ punctuation.separator.decimal.c -// ^ constant.numeric.suffix.c -// ^^^^^ meta.number.float.decimal.c -// ^^^^ constant.numeric.value.c -// ^ punctuation.separator.decimal.c -// ^ constant.numeric.suffix.c - 314e15 3.14e-15 + 3.14f 314.l 3.1'4L +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^ meta.number.float.decimal.c +// ^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c +// ^^^^^^ meta.number.float.decimal.c +// ^^^^^ constant.numeric.value.c +// ^ punctuation.separator.decimal.c +// ^ constant.numeric.suffix.c + 314e15 3.14e-1'5 // ^^^^^^ meta.number.float.decimal.c constant.numeric.value.c // ^^^^^^^^ meta.number.float.decimal.c constant.numeric.value.c // ^ punctuation.separator.decimal.c @@ -746,15 +747,15 @@ struct A; enum B; union C; // ^^^^^^^^ meta.struct.c // ^^^^^^ keyword.declaration.struct.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.struct.forward-declare.c // ^ punctuation.terminator.c // ^^^^^^ meta.enum.c // ^^^^ keyword.declaration.enum.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.enum.forward-declare.c // ^ punctuation.terminator.c // ^^^^^^^ meta.union.c // ^^^^^ keyword.declaration.union.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.union.forward-declare.c // ^ punctuation.terminator.c enum B @@ -851,11 +852,11 @@ //^^^^^^^ meta.block.c // ^ punctuation.section.block.end // ^ punctuation.terminator.c - void* ptr; -//^^^^^^^^^^^^^^^^ meta.block.c -// ^^^^ storage.type.c -// ^ keyword.operator.c -// ^ punctuation.terminator.c + struct C* ptr; +//^^^^^^^^^^^^^^^^^^^^ meta.block.c +// ^^^^^^ keyword.declaration.struct.c +// ^ keyword.operator.c +// ^ punctuation.terminator.c int a, *ptr2; //^^^^^^^^^^^^^^^^^^^ meta.block.c // ^^^ storage.type.c diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index 8266e3e531..43c3e79684 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -746,11 +746,11 @@ // ^ punctuation.terminator.c // ^^^^^^ meta.enum.c // ^^^^ keyword.declaration.enum.c++ -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.enum.forward-declare.c // ^ punctuation.terminator.c // ^^^^^^^ meta.union.c // ^^^^^ keyword.declaration.union.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.union.forward-declare.c // ^ punctuation.terminator.c enum B diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index ca5dbc5c48..fb86dd6421 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -746,11 +746,11 @@ void fun(int const a[]) { // ^ punctuation.terminator.c // ^^^^^^ meta.enum.c // ^^^^ keyword.declaration.enum.c++ -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.enum.forward-declare.c // ^ punctuation.terminator.c // ^^^^^^^ meta.union.c // ^^^^^ keyword.declaration.union.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.union.forward-declare.c // ^ punctuation.terminator.c enum B diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index 6c0513c6c7..0ba2c1f011 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -745,15 +745,15 @@ void fun(int const a[]) { struct A; enum B; union C; // ^^^^^^^^ meta.struct.c // ^^^^^^ keyword.declaration.struct.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.struct.forward-declare.c // ^ punctuation.terminator.c // ^^^^^^ meta.enum.c // ^^^^ keyword.declaration.enum.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.enum.forward-declare.c // ^ punctuation.terminator.c // ^^^^^^^ meta.union.c // ^^^^^ keyword.declaration.union.c -// ^ entity.name.enum.forward-decl.c +// ^ entity.name.union.forward-declare.c // ^ punctuation.terminator.c enum B From db4b3b71a2096d7c5a76556108d71c828f898175 Mon Sep 17 00:00:00 2001 From: camila <47485054+camila314@users.noreply.github.com> Date: Sat, 8 Mar 2025 13:03:28 -0600 Subject: [PATCH 66/66] Apply suggestions from code review Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com> --- C++/syntax_test_c.c | 50 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 8bdd96220e..a19e3fb070 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -578,11 +578,14 @@ // ^ punctuation.terminator.c static extern int* +// ^^^^^^^^^^^^^^^^^^^ meta.function.return-type.c // ^^^^^^ storage.modifier.c // ^^^^^^ storage.modifier.c // ^^^ storage.type.c // ^ keyword.operator.c test( +//^^^^^^ meta.function.identifier.c +// ^^ meta.function.parameters.c meta.group.c // ^^^^ entity.name.function.c // ^ punctuation.section.group.begin.c const uint64_t a, @@ -942,7 +945,13 @@ ///////////////////////////////////////////// __declspec(align(5)) struct Test { -// ^^^^^^^^^^^^^^^^^^^^ meta.group.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.struct.c - meta.struct meta.struct +// ^^^^^^^^^^ - meta.group +// ^^^^^^ meta.group.c - meta.group meta.group +// ^^^ meta.group.c meta.group.c +// ^ meta.group.c - meta.group meta.group +// ^^^^^^^^^^^^^ - meta.group - meta.block +// ^^ meta.block.c - meta.block meta.block // ^^^^^^^^^^ storage.modifier.c // ^ punctuation.section.group.begin.c // ^^^^^ storage.modifier.c @@ -1083,6 +1092,11 @@ // ^^^ storage.type.c // ^ keyword.operator.assignment.c int main(int argc, char const* argv[]) { +// ^^^^ meta.function.return-type.c +// ^^^^ meta.function.identifier.c +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.c meta.group.c +// ^ meta.function.c - meta.block - meta.group +// ^^ meta.function.c meta.block.c // ^^^ storage.type.c // ^^^^ entity.name.function.c // ^ punctuation.section.group.begin.c @@ -1126,7 +1140,9 @@ #error Error Message //^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c //^^^^^^^^ keyword.control.import.error.c -// ^^^^^^^^^^^^^^ string.unquoted.c +// ^ - keyword - string +// ^^^^^^^^^^^^^ meta.string.c string.unquoted.c +// ^ - string #error Error Message \ (this is an "error") //^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.diagnostic.c string.unquoted.c @@ -1138,6 +1154,11 @@ (this is a "warning") #define FOO __declspec(dllimport) +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c - meta.macro meta.macro +// ^^^^^^^^ meta.macro.c +// ^^^ meta.macro.identifier.c - meta.group +// ^^^^^^^^^^^ meta.macro.body.c - meta.group +// ^^^^^^^^^^^ meta.macro.body.c meta.group.c //^^^^^^^^^ keyword.control.import.c // ^^^ entity.name.macro.c support.macro.c // ^^^^^^^^^^ storage.modifier.c @@ -1146,6 +1167,15 @@ // ^^^^^^^^^ constant.other.c // ^ punctuation.section.group.end.c #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; + #define BAR(x, y, ...) enum MyEnum ## x { kEnumValue1 = y __VA_OPT__(,) __VA_ARGS__ }; +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c - meta.macro meta.macro +// ^^^^^^^^ meta.macro.c +// ^^^ meta.macro.identifier.c - meta.group +// ^^^^^^^^^^^ meta.macro.parameters.c meta.group.c +// ^^^^^^^^^^^^^^^^^^ meta.macro.body.c - meta.group - meta.block +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.macro.body.c meta.block.c - meta.group +// ^^^ meta.macro.body.c meta.block.c meta.group.c - meta.group meta.group +// ^^^^^^^^^^^^^^ meta.macro.body.c meta.block.c - meta.group //^^^^^^^^^ keyword.control.import.c // ^^^ entity.name.macro.c support.macro.c // ^ punctuation.section.group.begin.c @@ -1172,7 +1202,9 @@ #if FOO //^^^^^^^^^ meta.preprocessor.c -//^^^^^ keyword.control.import.c +//^^ - keyword.control.import.c +// ^^^ keyword.control.import.c +// ^ - keyword.control.import.c #ifndef FOO //^^^^^^^^^^^^^ meta.preprocessor.c //^^^^^^^^^ keyword.control.import.c @@ -1189,7 +1221,10 @@ //^^^^^^^^^^^^^^^ meta.preprocessor.c //^^^^^^^^^^^ keyword.control.import.c #else -//^^^^^^^ keyword.control.import.c +//^^^^^^^ meta.preprocessor.c +//^^ - keyword.control.import.c +// ^^^^^ keyword.control.import.c +// ^ - keyword.control.import.c #endif //^^^^^^^^ keyword.control.import.c @@ -1202,8 +1237,11 @@ # // ^ keyword.control.c #embed "file.txt" if_empty(0) -//^^^^^^^^ keyword.control.import.c -// ^^^^^^^^^^ string.quoted.double.c +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.c +//^^ - keyword +// ^^^^^^ keyword.control.import.c +// ^ - keyword - string +// ^^^^^^^^^^ meta.string.c string.quoted.double.c // ^ punctuation.definition.string.begin.c // ^ punctuation.definition.string.end.c // ^^^^^^^^ keyword.other.c