]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/cpp.yaml
groovy highlight (#1866)
[micro.git] / runtime / syntax / cpp.yaml
1 filetype: c++
2
3 detect:
4     filename: "(\\.c(c|pp|xx)$|\\.h(h|pp|xx)$|\\.ii?$|\\.(def)$)"
5
6 rules:
7     - identifier: "\\b[A-Z_][0-9A-Z_]*\\b"
8     - type: "\\b(float|double|bool|char|int|short|long|enum|void|struct|union|typedef|(un)?signed|inline)\\b"
9     - type: "\\b(((s?size)|((u_?)?int(8|16|32|64|ptr))|char(8|16|32))_t|wchar_t)\\b"
10     - type: "\\b(final|override)\\b"
11     - type.keyword: "\\b(auto|volatile|const(expr|eval|init)?|mutable|register|thread_local|static|extern|decltype|explicit|virtual)\\b"
12     - statement: "\\b(class|namespace|template|typename|this|friend|using|public|protected|private|noexcept)\\b"
13     - statement: "\\b((const|dynamic|reinterpret|static)_cast)\\b"
14     - statement: "\\b(concept|requires)\\b"
15     - statement: "\\b(import|export|module)\\b"
16     - statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
17     - statement: "\\b(try|throw|catch|operator|new|delete|static_assert)\\b"
18     - statement: "\\b(goto|continue|break|return)\\b"
19     - preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma"
20
21       # Conditionally-supported/extension keywords
22     - statement: "\\b(asm|fortran)\\b"
23
24       # GCC builtins
25     - statement: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)"
26
27       # Operator Color
28     - symbol.operator: "([.:;,+*~|=!?\\%]|<|>|/|-|&|\\b(sizeof|alignof|typeid|(and|or|xor|not)(_eq)?|bitor|compl|bitand)\\b)"
29       # Parenthetical Color
30     - symbol.brackets: "[(){}]|\\[|\\]"
31       # Integer Literals
32     - 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)"
33       # Decimal Floating-point Literals
34     - constant.number: "(\\b([0-9']*[.][0-9']*([Ee][+-]?[0-9']+)?|[0-9']+[Ee][+-]?[0-9']+)[FfLl]?\\b)"
35       # Hexadecimal Floating-point Literals
36     - 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)"
37     - constant.bool: "(\\b(true|false|NULL|nullptr)\\b)"
38
39     - constant.string:
40         start: "\""
41         end: "\""
42         skip: "\\\\."
43         rules:
44             - 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})"
45
46     - constant.string:
47         start: "'"
48         end: "'"
49         skip: "\\\\."
50         rules:
51             - error: "..+"
52             - 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})"
53
54     - comment:
55         start: "//"
56         end: "$"
57         rules:
58             - todo: "(TODO|XXX|FIXME):?"
59
60     - comment:
61         start: "/\\*"
62         end: "\\*/"
63         rules:
64             - todo: "(TODO|XXX|FIXME):?"
65