]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/c.yaml
Add autoretab
[micro.git] / runtime / syntax / c.yaml
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(auto|float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\b"
9     - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b"
10     - type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b"
11     - type.extended: "\\b(bool)\\b"
12     - statement: "\\b(volatile|register)\\b"
13     - statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
14     - statement: "\\b(goto|continue|break|return)\\b"
15     - preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
16       # GCC builtins
17     - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)"
18     - statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
19       # Operator Color
20     - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)"
21     - symbol.brackets: "[(){}]|\\[|\\]"
22       # Integer Constants
23     - 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)"
24       # Decimal Floating Constants
25     - constant.number: "(\\b(([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)[FfLl]?\\b)"
26       # Hexadecimal Floating Constants
27     - 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)"
28     - constant.number: "NULL"
29
30     - constant.string:
31         start: "\""
32         end: "\""
33         skip: "\\\\."
34         rules:
35             - 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})"
36
37     - constant.string:
38         start: "'"
39         end: "'"
40         skip: "\\\\."
41         rules:
42             - error: "..+"
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     - comment:
46         start: "//"
47         end: "$"
48         rules:
49             - todo: "(TODO|XXX|FIXME):?"
50
51     - comment:
52         start: "/\\*"
53         end: "\\*/"
54         rules:
55             - todo: "(TODO|XXX|FIXME):?"