aboutsummaryrefslogtreecommitdiff
path: root/language_odin.lua
blob: 6f393c81db812cb25d4815ab5971d4515f733ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
local syntax = require "core.syntax"

syntax.add {
  files = "%.odin$",
  comment = "//",
  patterns = {
    { pattern = "//.-\n",               type = "comment"  },
    { pattern = { "/%*", "%*/" },       type = "comment"  },
    { pattern = { '"', '"', '\\' },     type = "string"   },
    { pattern = { "'", "'", '\\' },     type = "string"   },
    { pattern = { "`", "`", '\\' },     type = "string"   },
    { pattern = "0b[0-1]+",             type = "number"   },
    { pattern = "0o[0-7]+",             type = "number"   },
    { pattern = "0d[%d]+",              type = "number"   },
    { pattern = "0z[%d]+",              type = "number"   },
    { pattern = "0x[%da-fA-F]+",        type = "number"   },
    { pattern = "-?%d+[%d%.]*",         type = "number"   },
    { pattern = "-?%.?%d+?",            type = "number"   },
    { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
    { pattern = "[<>~=+-*/]=",          type = "operator" },
    { pattern = "[::][:=]",             type = "operator" },
    { pattern = "[:]",                  type = "operator" },
    { pattern = "$[TE]",                type = "operator" },
    { pattern = "[%a_][%w_]*%f[(]",     type = "function" },
    { pattern = "[#@]?[%a_][%w_]*",     type = "symbol"   },
  },
  symbols = {
    -- Keywords
    ["package"]     = "keyword",
    ["import"]      = "keyword",
    ["foreign"]     = "keyword",
    ["when"]        = "keyword",
    ["if"]          = "keyword",
    ["else"]        = "keyword",
    ["for"]         = "keyword",
    ["defer"]       = "keyword",
    ["return"]      = "keyword",
    ["switch"]      = "keyword",
    ["case"]        = "keyword",
    ["in"]          = "keyword",
    ["notin"]       = "keyword",
    ["do"]          = "keyword",
    ["break"]       = "keyword",
    ["continue"]    = "keyword",
    ["fallthrough"] = "keyword",
    ["proc"]        = "keyword",
    ["struct"]      = "keyword",
    ["union"]       = "keyword",
    ["enum"]        = "keyword",
    ["bit_set"]     = "keyword",
    ["map"]         = "keyword",
    ["dynamic"]     = "keyword",
    ["using"]       = "keyword",
    ["inline"]      = "keyword",
    ["no_inline"]   = "keyword",
    ["context"]     = "keyword",
    ["distinct"]    = "keyword",
    ["opaque"]      = "keyword",
    ["macro"]       = "keyword", -- Reserved, not yet used
    ["const"]       = "keyword", -- Reserved, not yet used
    -- Builtin procedures and directives
    ["cast"]        = "keyword2",
    ["auto_cast"]   = "keyword2",
    ["transmute"]   = "keyword2",
    ["len"]         = "keyword2",
    ["cap"]         = "keyword2",
    ["size_of"]     = "keyword2",
    ["align_of"]    = "keyword2",
    ["offset_of"]   = "keyword2",
    ["typeid_of"]   = "keyword2",
    ["type_of"]     = "keyword2",
    ["type_info_of"]   = "keyword2",
    ["type_info_base"] = "keyword2",
    ["swizzle"]     = "keyword2",
    ["complex"]     = "keyword2",
    ["real"]        = "keyword2",
    ["imag"]        = "keyword2",
    ["conj"]        = "keyword2",
    ["min"]         = "keyword2",
    ["max"]         = "keyword2",
    ["abs"]         = "keyword2",
    ["clamp"]       = "keyword2",
    ["assert"]      = "keyword2",
    ["#assert"]     = "keyword2",
    ["#location"]   = "keyword2",
    ["#caller_location"] = "keyword2",
    ["#packed"]     = "keyword2",
    ["#raw_union"]  = "keyword2",
    ["#align"]      = "keyword2",
    ["#no_nil"]     = "keyword2",
    ["#complete"]   = "keyword2",
    ["#no_alias"]   = "keyword2",
    ["#align"]      = "keyword2",
    ["#load"]       = "keyword2",
    ["#location"]   = "keyword2",
    ["#file"]       = "keyword2",
    ["#line"]       = "keyword2",
    ["#procedure"]  = "keyword2",
    ["#defined"]    = "keyword2",
    ["#no_bounds_check"]  = "keyword2",
    ["#bounds_check"]     = "keyword2",
    ["#type"]       = "keyword2",
    ["@private"]    = "keyword2",
    -- Types
    ["rawptr"]      = "keyword2",
    ["typeid"]      = "keyword2",
    ["any"]         = "keyword2",
    ["string"]      = "keyword2",
    ["cstring"]     = "keyword2",
    ["int"]         = "keyword2",
    ["uint"]        = "keyword2",
    ["uintptr"]     = "keyword2",
    ["rune"]        = "keyword2",
    ["byte"]        = "keyword2",
    ["u8"]          = "keyword2",
    ["u16"]         = "keyword2",
    ["u32"]         = "keyword2",
    ["u64"]         = "keyword2",
    ["u128"]        = "keyword2",
    ["i8"]          = "keyword2",
    ["i16"]         = "keyword2",
    ["i32"]         = "keyword2",
    ["i64"]         = "keyword2",
    ["i128"]        = "keyword2",
    ["f16"]         = "keyword2",
    ["f32"]         = "keyword2",
    ["f64"]         = "keyword2",
    ["u16le"]       = "keyword2",
    ["u32le"]       = "keyword2",
    ["u64le"]       = "keyword2",
    ["u128le"]      = "keyword2",
    ["i16le"]       = "keyword2",
    ["i32le"]       = "keyword2",
    ["i64le"]       = "keyword2",
    ["i128le"]      = "keyword2",
    ["u16be"]       = "keyword2",
    ["u32be"]       = "keyword2",
    ["u64be"]       = "keyword2",
    ["u128be"]      = "keyword2",
    ["i16be"]       = "keyword2",
    ["i32be"]       = "keyword2",
    ["i64be"]       = "keyword2",
    ["i128be"]      = "keyword2",
    ["complex32"]   = "keyword2",
    ["complex64"]   = "keyword2",
    ["complex128"]  = "keyword2",
    ["quaternion128"]  = "keyword2",
    ["quaternion256"]  = "keyword2",
    ["bool"]        = "keyword2",
    ["b8"]          = "keyword2",
    ["b32"]         = "keyword2",
    ["b64"]         = "keyword2",
    ["b128"]        = "keyword2",
    -- Literals
    ["true"]        = "literal",
    ["false"]       = "literal",
    ["nil"]         = "literal",
  }
}