]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/c.yaml
Merge branch 'master' into view-refactor
[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(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.extended: "\\b(bool)\\b"
11     - statement: "\\b(typename|mutable|volatile|register|explicit)\\b"
12     - statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
13     - statement: "\\b(try|throw|catch|operator|new|delete)\\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     - constant: "'([^'\\\\]|(\\\\[\"'abfnrtv\\\\]))'"
17     - constant: "'\\\\(([0-3]?[0-7]{1,2}))'"
18     - constant: "'\\\\x[0-9A-Fa-f]{1,2}'"
19       # GCC builtins
20     - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)"
21     - statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
22       # Operator Color
23     - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" 
24     - symbol.brackets: "[(){}]|\\[|\\]"
25     - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)"
26     - constant.number: "NULL"
27
28     - constant.string:
29         start: "\""
30         end: "(?<!\\\\)\""
31         rules:
32             - constant.specialChar: "\\\\."
33
34     - constant.string:
35         start: "'"
36         end: "(?<!\\\\)'"
37         rules:
38             - preproc: "..+"
39             - constant.specialChar: "\\\\."
40
41     - comment:
42         start: "//"
43         end: "$"
44         rules:
45             - todo: "(TODO|XXX|FIXME):?"
46
47     - comment:
48         start: "/\\*"
49         end: "\\*/"
50         rules:
51             - todo: "(TODO|XXX|FIXME):?"
52