| 1 |
filetype: c |
| 2 |
|
| 3 |
detect: |
| 4 |
filename: "(\\.(c|C)$|\\.(h|H)$|\\.ii?$|\\.(def)$)" |
| 5 |
|
| 6 |
rules: |
| 7 |
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b" |
| 8 |
- type: "\\b(_Atomic|_BitInt|float|double|_Decimal32|_Decimal64|_Decimal128|_Complex|complex|_Imaginary|imaginary|_Bool|bool|char|int|short|long|enum|void|struct|union|typedef|typeof|typeof_unqual|(un)?signed|inline|_Noreturn)\\b" |
| 9 |
- type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr))|char(8|16|32)|wchar)_t\\b" |
| 10 |
# GCC float/decimal/fixed types |
| 11 |
- type: "\\b(_Float16|__fp16|_Float32|_Float32x|_Float64|_Float64x|__float80|_Float128|_Float128x|__float128|__ibm128|__int128|_Fract|_Sat|_Accum)\\b" |
| 12 |
- type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b" |
| 13 |
- statement: "\\b(auto|volatile|register|restrict|_Alignas|alignas|_Alignof|alignof|static|const|constexpr|extern|_Thread_local|thread_local)\\b" |
| 14 |
- statement: "\\b(for|if|while|do|else|case|default|switch|_Generic|_Static_assert|static_assert)\\b" |
| 15 |
- statement: "\\b(goto|continue|break|return)\\b" |
| 16 |
- statement: "\\b(asm|fortran)\\b" |
| 17 |
- preproc: "^[[:space:]]*#[[:space:]]*(define|embed|pragma|include|(un|ifn?)def|endif|el(if|ifdef|ifndef|se)|if|line|warning|error|__has_include|__has_embed|__has_c_attribute)" |
| 18 |
- preproc: "^[[:space:]]*_Pragma\\b" |
| 19 |
# GCC builtins |
| 20 |
- statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)" |
| 21 |
- statement: "__(aligned|asm|builtin|extension|hidden|inline|packed|restrict|section|typeof|weak)__" |
| 22 |
# Operator Color |
| 23 |
- symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(offsetof|sizeof)\\b" |
| 24 |
- symbol.brackets: "[(){}]|\\[|\\]" |
| 25 |
# Integer Constants |
| 26 |
- constant.number: "(\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+|0[Bb][01]+)([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" |
| 27 |
# Decimal Floating Constants |
| 28 |
- constant.number: "(\\b(([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)[FfLl]?\\b)" |
| 29 |
# Hexadecimal Floating Constants |
| 30 |
- constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)" |
| 31 |
- constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)" |
| 32 |
|
| 33 |
- constant.string: |
| 34 |
start: "\"" |
| 35 |
end: "\"" |
| 36 |
skip: "\\\\." |
| 37 |
rules: |
| 38 |
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})" |
| 39 |
|
| 40 |
- constant.string: |
| 41 |
start: "'" |
| 42 |
end: "'" |
| 43 |
skip: "\\\\." |
| 44 |
rules: |
| 45 |
# TODO: Revert back to - error: "..+" once #3127 is merged |
| 46 |
- error: "[[:graph:]]{2,}'" |
| 47 |
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})" |
| 48 |
|
| 49 |
- comment: |
| 50 |
start: "//" |
| 51 |
end: "$" |
| 52 |
rules: |
| 53 |
- todo: "(TODO|XXX|FIXME):?" |
| 54 |
|
| 55 |
- comment: |
| 56 |
start: "/\\*" |
| 57 |
end: "\\*/" |
| 58 |
rules: |
| 59 |
- todo: "(TODO|XXX|FIXME):?" |
| 60 |
|