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