| 1 |
filetype: c++ |
| 2 |
|
| 3 |
detect: |
| 4 |
filename: "(\\.c(c|pp|xx)$|\\.h(h|pp|xx)?$|\\.ii?$|\\.(def)$)" |
| 5 |
signature: "\\b(namespace|class|public|protected|private|template|constexpr|noexcept|nullptr|throw)\\b" |
| 6 |
|
| 7 |
rules: |
| 8 |
- identifier: "\\b[A-Z_][0-9A-Z_]*\\b" |
| 9 |
- type: "\\b(auto|float|double|bool|char|int|short|long|enum|void|struct|union|typedef|(un)?signed|inline)\\b" |
| 10 |
- type: "\\b(((s?size)|((u_?)?int(8|16|32|64|ptr))|char(8|16|32))_t|wchar_t)\\b" |
| 11 |
- type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b" |
| 12 |
- type: "\\b(final|override)\\b" |
| 13 |
- statement: "\\b(volatile|const(expr|eval|init)?|mutable|register|thread_local|static|extern|decltype|explicit|virtual)\\b" |
| 14 |
- statement: "\\b(class|namespace|template|typename|this|friend|using|public|protected|private|noexcept)\\b" |
| 15 |
- statement: "\\b(concept|requires)\\b" |
| 16 |
- statement: "\\b(import|export|module)\\b" |
| 17 |
- statement: "\\b(for|if|while|do|else|case|default|switch)\\b" |
| 18 |
- statement: "\\b(try|throw|catch|operator|new|delete|static_assert)\\b" |
| 19 |
- statement: "\\b(goto|continue|break|return)\\b" |
| 20 |
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma" |
| 21 |
|
| 22 |
# Conditionally-supported/extension keywords |
| 23 |
- statement: "\\b(asm|fortran)\\b" |
| 24 |
|
| 25 |
# GCC builtins |
| 26 |
- statement: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)" |
| 27 |
|
| 28 |
# Operator Color |
| 29 |
- symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(sizeof|alignof|typeid|(and|or|xor|not)(_eq)?|bitor|compl|bitand|(const|dynamic|reinterpret|static)_cast)\\b" |
| 30 |
# Parenthetical Color |
| 31 |
- symbol.brackets: "[(){}]|\\[|\\]" |
| 32 |
|
| 33 |
# Integer Literals |
| 34 |
- constant.number: "(\\b([0-9]|0[0-7]|0[Xx][0-9A-Fa-f]|0[Bb][01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Base case (Without ' separtor) |
| 35 |
- constant.number: "(\\b([1-9][0-9']*[0-9])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Decimal |
| 36 |
- constant.number: "(\\b(0[0-7][0-7']*[0-7])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Oct |
| 37 |
- constant.number: "(\\b(0[Xx][0-9A-Fa-f][0-9A-Fa-f']*[0-9A-Fa-f])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Hex |
| 38 |
- constant.number: "(\\b(0[Bb][01][01']*[01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Binary |
| 39 |
|
| 40 |
# Decimal Floating-point Literals |
| 41 |
- constant.number: "(([0-9]?[.]?\\b[0-9]+)([Ee][+-]?[0-9]+)?[FfLl]?\\b)" # Base case optional interger part with exponent base case |
| 42 |
- constant.number: "(\\b([0-9]+[.][0-9]?)([Ee][+-]?[0-9]+)?[FfLl]?)" # Base case optional fractional part with exponent base case |
| 43 |
- constant.number: "(([0-9]?[.]?\\b[0-9]+)([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Base case optional interger part with exponent |
| 44 |
- constant.number: "(\\b([0-9]+[.][0-9]?)([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Base case optional fractional part with exponent |
| 45 |
|
| 46 |
- constant.number: "(([0-9][0-9']*[0-9])?[.]?\\b([0-9][0-9']*[0-9])+([Ee][+-]?[0-9]+)?[FfLl]?\\b)" # Optional interger part with exponent base case |
| 47 |
- constant.number: "(\\b([0-9][0-9']*[0-9])+[.]([0-9][0-9']*[0-9])?([Ee][+-]?[0-9]+)?[FfLl]?)" # Optional fractional part with exponent base case |
| 48 |
- constant.number: "(([0-9][0-9']*[0-9])?[.]?\\b([0-9][0-9']*[0-9])+([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Optional interger part with exponent |
| 49 |
- constant.number: "(\\b([0-9][0-9']*[0-9])+[.]([0-9][0-9']*[0-9])?([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Optional fractional part with exponent |
| 50 |
|
| 51 |
# Hexadecimal Floating-point Literals |
| 52 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]?[.]?[0-9a-zA-Z]+)([Pp][+-]?[0-9]+)?[FfLl]?\\b)" # Base case optional interger part with exponent base case |
| 53 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]+[.][0-9a-zA-Z]?)([Pp][+-]?[0-9]+)?[FfLl]?)" # Base case optional fractional part with exponent base case |
| 54 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]?[.]?[0-9a-zA-Z]+)([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Base case optional interger part with exponent |
| 55 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]+[.][0-9a-zA-Z]?)([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Base case optional fractional part with exponent |
| 56 |
|
| 57 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?[.]?([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+([Pp][+-]?[0-9]+)?[FfLl]?\\b)" # Optional interger part with exponent base case |
| 58 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+[.]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?([Pp][+-]?[0-9]+)?[FfLl]?)" # Optional fractional part with exponent base case |
| 59 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?[.]?([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Optional interger part with exponent |
| 60 |
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+[.]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Optional fractional part with exponent |
| 61 |
|
| 62 |
- constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)" |
| 63 |
|
| 64 |
- constant.string: |
| 65 |
start: "\"" |
| 66 |
end: "\"" |
| 67 |
skip: "\\\\." |
| 68 |
rules: |
| 69 |
- 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})" |
| 70 |
|
| 71 |
- constant.string: |
| 72 |
start: "'" |
| 73 |
end: "'" |
| 74 |
skip: "(\\\\.)|\\b([1-9][0-9']+[0-9]|0[0-7']+[0-7]|0[Xx][0-9A-Fa-f][0-9A-Fa-f']+[0-9A-Fa-f]|0[Bb][01][01']*[01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b" |
| 75 |
rules: |
| 76 |
# TODO: Revert back to - error: "..+" once #3127 is merged |
| 77 |
- error: "[[:graph:]]{2,}'" |
| 78 |
- 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})" |
| 79 |
|
| 80 |
- comment: |
| 81 |
start: "//" |
| 82 |
end: "$" |
| 83 |
rules: |
| 84 |
- todo: "(TODO|XXX|FIXME):?" |
| 85 |
|
| 86 |
- comment: |
| 87 |
start: "/\\*" |
| 88 |
end: "\\*/" |
| 89 |
rules: |
| 90 |
- todo: "(TODO|XXX|FIXME):?" |
| 91 |
|