]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/odin.yaml
runtime/syntax: add rudimentary Odin support (#2296)
[micro.git] / runtime / syntax / odin.yaml
1 filetype: odin
2
3 detect:
4     filename: "\\.odin$"
5
6 rules:
7     # Conditionals and control flow
8     - special: "\\b(asm|auto_cast|break|case|cast|context|continue|do|dynamic|fallthrough|return|transmute|using|where)\\b"
9     - statement: "\\b(else|for|if|switch|in|not_in|or_else|or_return|when)\\b"
10     - preproc: "\\b(assert|package|foreign|import|proc|defer|make|new|free|delete|copy|len|cap|append|raw_data)\\b"
11     - preproc: "\\b((size|align|offset|type|type_info|typeid)_of|offset_of_by_string)\\b"
12     - preproc: "\\b(swizzle|complex|quaternion|real|imag|jmag|kmag|conj|expand_to_tuple|min|max|abs|clamp|soa_zip|soa_unzip|transpose|outer_product|hadamard_product|matrix_flatten)\\b"
13     - symbol.operator: "[-+/*=<>!~%&|^@]|:\\s*=|:\\s*:|\\?"
14
15       # Types
16     - symbol: "(,|\\.)"
17     - type: "\\b(b(8|16|32|64)|(i|u)(8|(16|32|64|128)(le|be)?)|f(16|32|64)(le|be)?|complex(32|64|128)|quaternion(64|128|256))\\b"
18     - type: "\\b(any|bool|byte|rune|u?int|uintptr|rawptr|c?string|map|matrix|typeid)\\b"
19     - type.keyword: "\\b(distinct|struct|enum|union|bit_set)\\b"
20     - constant.bool: "\\b(true|false|nil)\\b"
21
22       # Brackets
23     - symbol.brackets: "(\\{|\\})"
24     - symbol.brackets: "(\\(|\\))"
25     - symbol.brackets: "(\\[|\\])"
26
27       # Numbers and strings
28     - constant.number: "\\b(0b[01]*|0o[0-7]*|0x[0-9a-fA-F]*|[0-9_]+|0d[0-9]*|0z[0-9abAB]*)\\b|'.'"
29
30     - constant.string:
31         start: "\""
32         end: "\""
33         skip: "\\\\."
34         rules:
35             - constant.specialChar: "%."
36             - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
37             - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"
38
39     - constant.string:
40         start: "'"
41         end: "'"
42         skip: "\\\\."
43         rules:
44             - error: "..+"
45             - constant.specialChar: "%."
46             - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
47             - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"
48
49     - constant.string:
50         start: "`"
51         end: "`"
52         rules: []
53
54     - comment:
55         start: "//"
56         end: "$"
57         rules:
58             - todo: "TODO:?|NOTE(\\(.*\\))?:?"
59
60     - comment:
61         start: "/\\*"
62         end: "\\*/"
63         rules:
64             - todo: "TODO:?|NOTE(\\(.*\\))?:?"