-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJai.sublime-syntax
203 lines (188 loc) · 6.24 KB
/
Jai.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
202
203
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Jai
file_extensions:
- jai
first_line_match: "-[*]-( Mode:)? Jai -[*]-"
scope: source.jai
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: custom_styling
- include: strings
- include: string-escaped-char
- include: variables
custom_styling:
- match: \b({{screaming_identifier}})\b
captures:
1: storage.constant.jai
- match: \b([A-Z][a-z0-9]+)([_A-Z][a-z0-9]*)*\b
scope: storage.type.jai
block-comment:
- match: /\*
scope: punctuation.definition.comment.jai
push:
- meta_scope: comment.block.jai
- match: \*/
scope: punctuation.definition.comment.jai
pop: true
- include: block-comment
comments:
- include: block-comment
- match: //
scope: punctuation.definition.comment.jai
push:
- meta_scope: comment.line.double-slash.jai
- match: \n
pop: true
- match: "#!"
scope: punctuation.definition.comment.jai
push:
- meta_scope: comment.line.double-slash.jai
- match: \n
pop: true
keywords:
- match: \b(#?if|then|else|defer|return)\b
scope: keyword.control.jai
- match: \b(while|for|break|continue|remove|case)\b
scope: keyword.control.jai
- match: \b(using|inline|no_inline)\b
scope: keyword.control.jai
- match: \b(context|it|it_index)\b
scope: keyword.control.jai
- match: \b(null|true|false)\b
scope: constant.language.jai
- match: '\b((0b(0|1|_)+)|(0o([0-7_])+)|(0d([0-9_])+)|(0[xXhH]([0-9a-fA-F_])+))\b'
scope: constant.numeric.jai
- match: '(?<!\w)(-|\+)?(\.\d(\d|_)*|(\d(\d|_)*)\.?)((e|E)(\+|-)?\d+)?[ijk]?'
scope: constant.numeric.jai
- match: '(\d*)*(\.\.)(\d*)*'
captures:
"1": constant.numeric.jai
"2": keyword.operator.jai
"3": constant.numeric.jai
- match: '---'
scope: constant.language.jai
- match: \b(struct|enum|enum_flags|union|operator|push_context)\b
scope: storage.type.jai
- match: \b(cast|acast|xx)\b
scope: keyword.function.jai
- match: '@({{identifier}})'
scope: support.type.jai
- match: '#(import|load|no_abc|assert|must|complete|run|run_and_insert|through|char|filepath|line|caller_location|location|foreign_library|foreign|modify|placeholder|c_call|expand|program_export|program_import|align)'
scope: keyword.other.directive.jai
- match: ->
scope: keyword.operator.jai
- match: \!=?
scope: keyword.operator.jai
- match: \>\>\>?
scope: keyword.operator.jai
- match: \<\<\<?
scope: keyword.operator.jai
- match: :=?
scope: keyword.operator.assignment.jai
# - match: ({{identifier}})(?:(,)\s*({{identifier}}))*\s*(:=)
# captures:
# "1": support.type.jai
# "2": source.jai
# "3": support.type
# "4": keyword.operator.jai
- match: (\||&|=|\+$![0-9]|-$![0-9]|\*|/|\<|>)=?
scope: keyword.operator.jai
functions-and-declarations:
- match: '\b({{identifier}})\s*([:]\s*[:])\s*\('
captures:
1: meta.function.jai entity.name.function.jai
2: keyword.operator.jai
- match: '\b({{identifier}})\s*([:]\s*[:])\s*(inline|no_inline)\s+\('
captures:
1: meta.function.jai entity.name.function.jai
2: keyword.operator.jai
3: keyword.control.jai
- match: '\b({{identifier}})\s*\('
captures:
1: meta.function-call.jai variable.function.jai
- match: \b(size_of|type_of|type_info)\b\s*\(
captures:
1: keyword.function.jai
- match: ({{identifier}})\s*[!]?\s*[\(]
captures:
1: entity.function.jai
- match: '\b({{identifier}})\s*[:]\s*[:]\s*(struct|union|enum)'
captures:
1: meta.type.jai entity.name.type.jai
2: storage.type.jai
- match: '\b({{identifier}})\s*[:]\s*[:]\s*([#]\s*type)'
captures:
1: meta.type.jai entity.name.type.jai
2: keyword.tag.jai
- match: '\b({{identifier}})\s*([:]\s*[:])\s*'
captures:
1: meta.constant.jai entity.name.type.jai
2: keyword.operator.jai
types:
- match: '\b(struct|enum|union)\b(?:(\{)(\}))?'
captures:
1: storage.type.jai
2: meta.block.jai punctuation.definition.block.begin.jai
3: meta.block.jai punctuation.definition.block.end.jai
- match: (\[)(\d*)(\])(?=[[:alpha:]_])
scope: meta.brackets.jai
captures:
1: punctuation.definition.brackets.begin.jai
2: constant.numeric.jai
3: punctuation.definition.brackets.end.jai
- include: basic-types
- match: '\$\$?\s*({{identifier}})'
scope: storage.type.jai
basic-types:
- match: '\b(s8|s16|s32|s64|s128|int)\b'
scope: storage.type.jai
- match: '\b(u8|u16|u32|u64|u128|uint)\b'
scope: storage.type.jai
- match: '\b(float|float32|float64)\b'
scope: storage.type.jai
- match: '\b(bool|string|Any|void)\b'
scope: storage.type.jai
strings:
- match: '"'
scope: punctuation.definition.string.begin.jai
push:
- meta_scope: string.quoted.double.jai
- match: '"'
scope: punctuation.definition.string.end.jai
pop: true
- include: string-escaped-char
- match: "`"
scope: punctuation.definition.string.begin.jai
push:
- meta_scope: string.quoted.raw.jai
- match: "`"
scope: punctuation.definition.string.end.jai
pop: true
- match: "'"
scope: punctuation.definition.string.begin.jai
push:
- meta_scope: string.quoted.raw.jai
- match: "'"
scope: punctuation.definition.string.end.jai
pop: true
- include: string-escaped-char
string-escaped-char:
- match: '\\(\\|[0nrt"]|x\h{2}|u\h{4}|U\h{8}|[0-7]{3})'
scope: constant.character.escape.jai
- match: \\.
scope: invalid.illegal.unknown-escape.jai
variables:
- match: \b__(temporary_allocator)\b
scope: support.type.jai