]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/c.yaml
Merge pull request #1148 from Calinou/improve-gdscript-syntax
[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(volatile|register)\\b"
12     - statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
13     - statement: "\\b(goto|continue|break|return)\\b"
14     - preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
15     - constant: "'([^'\\\\]|(\\\\[\"'abfnrtv\\\\]))'"
16     - constant: "'\\\\(([0-3]?[0-7]{1,2}))'"
17     - constant: "'\\\\x[0-9A-Fa-f]{1,2}'"
18       # GCC builtins
19     - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)"
20     - statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
21       # Operator Color
22     - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)"
23     - symbol.brackets: "[(){}]|\\[|\\]"
24     - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)"
25     - constant.number: "NULL"
26
27     - constant.string:
28         start: "\""
29         end: "\""
30         skip: "\\\\."
31         rules:
32             - constant.specialChar: "\\\\."
33
34     - constant.string:
35         start: "'"
36         end: "'"
37         skip: "\\\\."
38         rules:
39             - preproc: "..+"
40             - constant.specialChar: "\\\\."
41
42     - comment:
43         start: "//"
44         end: "$"
45         rules:
46             - todo: "(TODO|XXX|FIXME):?"
47
48     - comment:
49         start: "/\\*"
50         end: "\\*/"
51         rules:
52             - todo: "(TODO|XXX|FIXME):?"