-
Notifications
You must be signed in to change notification settings - Fork 14
/
Odin.sublime-syntax
201 lines (190 loc) · 6.42 KB
/
Odin.sublime-syntax
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Odin
file_extensions:
- odin
first_line_match: "-[*]-( Mode:)? Odin -[*]-"
scope: source.odin
variables:
identifier: '\b[[:alpha:]_][[:alnum:]_]*\b'
type_chars: '[[:alnum:]\s,._^<>\[\]-]'
screaming_identifier: '\b[A-Z_](?![a-z])[A-Z_0-9]+\b'
contexts:
main:
- include: global
global:
- include: comments
- include: types
- include: keywords
- include: functions-and-declarations
- include: strings
- include: string-escaped-char
block-comment:
- match: /\*
scope: punctuation.definition.comment.odin
push:
- meta_scope: comment.block.odin
- match: \*/
scope: punctuation.definition.comment.odin
pop: true
- include: block-comment
comments:
- include: block-comment
- match: //
scope: punctuation.definition.comment.odin
push:
- meta_scope: comment.line.double-slash.odin
- match: \n
pop: true
- match: "#!"
scope: punctuation.definition.comment.odin
push:
- meta_scope: comment.line.double-slash.odin
- match: \n
pop: true
keywords:
- match: \b(import|foreign|package)\b
scope: keyword.control.odin
- match: \b(if|else|when|for|in|not_in|defer|switch|return|const|do|where)\b
scope: keyword.control.odin
- match: \b(fallthrough|break|continue|case)\b
scope: keyword.control.odin
- match: \b(using|([#]force_inline)|([#]force_no_inline))\b
scope: keyword.control.odin
- match: \b(asm|or_else|or_return|or_break|or_continue)\b
scope: keyword.control.odin
- match: \b(distinct)\b
scope: keyword.operator.odin
- match: \b(context)\b
scope: keyword.operator.odin
- match: \b(nil|true|false)\b
scope: constant.language.odin
- match: '\b(\d(\d|_)*(.\d(\d|_)*)?)((e|E)(\+|-)?\d+)?[ijk]?\b'
scope: constant.numeric.odin
- match: '\b((0b(0|1|_)+)|(0o(\d|_)+)|(0d(\d|_)+)|(0[xXh](\h|_)+))[ijk]?\b'
scope: constant.numeric.odin
- match: '---'
scope: constant.numeric.odin
- match: \b(struct|enum|union|map|bit_set|bit_field|dynamic|matrix)\b
scope: storage.type.odin
- match: \b(cast|transmute|auto_cast)\b
scope: keyword.function.odin
- match: '([#]\s*{{identifier}})'
scope: keyword.tag.odin
- match: '(#[+]\s*[[:alpha:]-][[:alnum:]-]*)'
scope: keyword.tag.odin
- match: '(\x40\s*{{identifier}})'
scope: keyword.tag.odin
- match: '(\x40\s*[(]\s*{{identifier}})\s*[)]'
scope: keyword.tag.odin
- match: '@'
scope: keyword.operator.odin
functions-and-declarations:
- match: '\b({{identifier}})\s*[:]\s*[:]\s*(proc)'
captures:
1: meta.function.odin entity.name.function.odin
2: storage.type.odin
- match: '\b({{identifier}})\s*[:]\s*[:]\s*([#]force_inline|[#]force_no_inline)\s+(proc)'
captures:
1: meta.function.odin entity.name.function.odin
2: keyword.control.odin
3: storage.type.odin
- match: \b(size_of|align_of|offset_of|type_of)\b\s*\(
captures:
1: keyword.function.odin
- match: \b(type_info_of|typeid_of)\b\s*\(
captures:
1: keyword.function.odin
- match: (proc)\s*[\(]
captures:
1: storage.type.odin
- match: ({{identifier}})\s*[!]?\s*[\(]
captures:
1: support.function.odin
- match: '\b({{identifier}})\s*[:]\s*[:]\s*(struct|union|enum|bit_set)'
captures:
1: meta.type.odin entity.name.type.odin
2: storage.type.odin
- match: '\b({{identifier}})\s*[:]\s*[:]\s*([#]\s*type)'
captures:
1: meta.type.odin entity.name.type.odin
2: keyword.tag.odin
- match: '\b({{identifier}})\s*[:]\s*[:]\s*'
captures:
1: meta.constant.odin entity.name.type.odin
types:
- match: '\b(struct|enum|union|bit_set)\b(?:(\{)(\}))?'
captures:
1: storage.type.odin
2: meta.block.odin punctuation.definition.block.begin.odin
3: meta.block.odin punctuation.definition.block.end.odin
- match: '\b(proc)\b'
scope: storage.type.odin
- match: (\[)(\d*)(\])(?=[[:alpha:]_])
scope: meta.brackets.odin
captures:
1: punctuation.definition.brackets.begin.odin
2: constant.numeric.odin
3: punctuation.definition.brackets.end.odin
- include: basic-types
- match: '\$\s*({{identifier}})'
scope: storage.type.odin
basic-types:
- match: '\b(i8|i16|i32|i64|i128|int)\b'
scope: storage.type.odin
- match: '\b(u8|u16|u32|u64|u128|uint|uintptr)\b'
scope: storage.type.odin
- match: '\b(f16|f32|f64)\b'
scope: storage.type.odin
- match: '\b(f16le|f32le|f64le)\b'
scope: storage.type.odin
- match: '\b(f16be|f32be|f64be)\b'
scope: storage.type.odin
- match: '\b(complex32|complex64|complex128)\b'
scope: storage.type.odin
- match: '\b(quaternion64|quaternion128|quaternion256)\b'
scope: storage.type.odin
- match: '\b(bool|b8|b16|b32|b64)\b'
scope: storage.type.odin
- match: '\b(string|cstring|rune)\b'
scope: storage.type.odin
- match: '\b(rawptr)\b'
scope: storage.type.odin
- match: '\b(any|typeid)\b'
scope: storage.type.odin
- match: '\b(byte)\b'
scope: storage.type.odin
- match: '\b(u16le|u32le|u64le|u128le|i16le|i32le|i64le|i128le)\b'
scope: storage.type.odin
- match: '\b(i16be|i32be|i64be|i128be|u16be|u32be|u64be|u128be)\b'
scope: storage.type.odin
strings:
- match: '"'
scope: punctuation.definition.string.begin.odin
push:
- meta_scope: string.quoted.double.odin
- match: '"'
scope: punctuation.definition.string.end.odin
pop: true
- include: string-escaped-char
- match: "`"
scope: punctuation.definition.string.begin.odin
push:
- meta_scope: string.quoted.raw.odin
- match: "`"
scope: punctuation.definition.string.end.odin
pop: true
- match: "'"
scope: punctuation.definition.string.begin.odin
push:
- meta_scope: string.quoted.raw.odin
- match: "'"
scope: punctuation.definition.string.end.odin
pop: true
- include: string-escaped-char
string-escaped-char:
- match: '\\(\\|[abefnrutv''"]|x\h{2}|u\h{4}|U\h{8}|[0-7]{3})'
scope: constant.character.escape.odin
- match: \\.
scope: invalid.illegal.unknown-escape.odin