]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/cpp.yaml
Merge branch 'python-highlight-zero' of https://github.com/a11ce/micro into a11ce...
[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(concept|requires)\\b"
14     - statement: "\\b(import|export|module)\\b"
15     - statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
16     - statement: "\\b(try|throw|catch|operator|new|delete|static_assert)\\b"
17     - statement: "\\b(goto|continue|break|return)\\b"
18     - preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma"
19
20       # Conditionally-supported/extension keywords
21     - statement: "\\b(asm|fortran)\\b"
22
23       # GCC builtins
24     - statement: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)"
25
26       # Operator Color
27     - symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(sizeof|alignof|typeid|(and|or|xor|not)(_eq)?|bitor|compl|bitand|(const|dynamic|reinterpret|static)_cast)\\b"
28       # Parenthetical Color
29     - symbol.brackets: "[(){}]|\\[|\\]"
30       # Integer Literals
31     - 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)"
32       # Decimal Floating-point Literals
33     - constant.number: "(\\b(([0-9']*[.][0-9']+|[0-9']+[.][0-9']*)([Ee][+-]?[0-9']+)?|[0-9']+[Ee][+-]?[0-9']+)[FfLl]?\\b)"
34       # Hexadecimal Floating-point Literals
35     - 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)"
36     - constant.bool: "(\\b(true|false|NULL|nullptr)\\b)"
37
38     - constant.string:
39         start: "\""
40         end: "\""
41         skip: "\\\\."
42         rules:
43             - 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})"
44
45     - constant.string:
46         start: "'"
47         end: "'"
48         skip: "\\\\."
49         rules:
50             - error: "..+"
51             - 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})"
52
53     - comment:
54         start: "//"
55         end: "$"
56         rules:
57             - todo: "(TODO|XXX|FIXME):?"
58
59     - comment:
60         start: "/\\*"
61         end: "\\*/"
62         rules:
63             - todo: "(TODO|XXX|FIXME):?"
64