]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/v.yaml
9790f74c4370f2261cba8b188a4a956afd82e606
[micro.git] / runtime / syntax / v.yaml
1 filetype: v
2
3 detect:
4
5 rules:
6     # Conditionals and control flow
7     - keywords: "\\b(import|go|defer)\\b"
8     - special: "\\b(or|break|continue|match|case|goto|return|none)\\b"
9     - function: "\\b(fn)\\b"
10     - main_function: "\\b(fn main\\(\\))"
11     - optionals: "\\b(none|error\\()"
12     - statement: "\\b(if|else|for|match)\\b"
13     - assert: "\\b(assert)\\b"
14     - symbol.operator: "\\b([-+/*=<>!~%&|^])\\b"
15     - symbol.operator: "\\b(:=)\\b"
16     - symbol.operator: "\\b(\\|\\|)\b"
17     - symbol.operator: "\\b(\\&\\&)\\b"
18
19     - compile_if: "\\b(\\$if|\\$else)\\b"
20     - oses: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|js|android|solaris|haiku)\\b"
21
22       # Types
23     - symbol: "(,|\\.)"
24     - btype: "\\b(bool)\\b"
25     - ztype: "\\b(char|byte)\\b"
26     - itype: "\\b(int|i(8|16|64)|u(8|16|32|64))\\b"
27     - ftype: "\\b(f(32|64))\\b"
28     - ptype: "\\b(uintptr|charptr|byteptr|voidptr)\\b"
29     - atype: "\\b(array)\\b"
30     - stype: "\\b(string|ustring)\\b"
31     - mtype: "\\b(map)\\b"
32     - type.keyword: "\\b(pub|mut|struct|enum|interface|module|type|const)\\b"
33     - constant.bool: "\\b(true|false)\\b"
34
35       # Brackets
36     - symbol.brackets: "(\\{|\\})"
37     - symbol.brackets: "(\\(|\\))"
38     - symbol.brackets: "(\\[|\\])"
39
40       # Numbers and strings
41     - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'"
42
43     - constant.string:
44         start: "\""
45         end: "\""
46         skip: "\\\\."
47         rules:
48             - constant.specialChar: "%."
49             - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
50             - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
51
52     - constant.string:
53         start: "'"
54         end: "'"
55         skip: "\\\\."
56         rules:
57             - error: "..+"
58             - constant.specialChar: "%."
59             - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
60             - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
61
62     - constant.string:
63         start: "`"
64         end: "`"
65         rules: []
66
67     - comment:
68         start: "//"
69         end: "$"
70         rules:
71             - todo: "(TODO|XXX|FIXME):?"
72
73     - comment:
74         start: "/\\*"
75         end: "\\*/"
76         rules:
77             - todo: "(TODO|XXX|FIXME):?"
78
79     - function.attribute:
80         start: "^\\["
81         end: "\\]$"
82         rules:
83             - known: "\\b(deprecated|inline|typedef|if)\\b"
84