-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.iro
299 lines (248 loc) · 7.25 KB
/
syntax.iro
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#################################################################
## Iro
################################################################
##
## * Press Ctrl + '+'/'-' To Zoom in
## * Press Ctrl + S to save and recalculate...
## * Documents are saved to web storage.
## * Only one save slot supported.
## * Matches cannot span lines.
## * Unicode chars must be defined in \u0000 to \uffff format.
## * All matches must be contained by a single group ( ... )
## * Look behinds not permitted, (?<= or (?<!
## * Look forwards are permitted (?= or (?!
## * Constants are defined as __my_const = (......)
## * The \= format allows unescaped regular expressions
## * Constants referenced by match \= $${__my_const}
## * Constants can reference other constants
## * You are free to delete all the default scopes.
## * Twitter : ainslec , Web: http://eeyo.io/iro
##
################################################################
name = prog8
file_extensions [] = p8, prog8;
################################################################
## Constants
################################################################
__MY_CONSTANT \= (\b[a-z][a-z0-9]*)
################################################################
## Styles
################################################################
styles [] {
.comment.line : style {
color = light_green
italic = true
ace_scope = comment
textmate_scope = comment.line
pygments_scope = Comment
}
.keyword.control : style {
color = cyan
ace_scope = keyword
textmate_scope = keyword.control
pygments_scope = Keyword
}
.keyword.operator : style {
color = cyan
ace_scope = keyword
textmate_scope = keyword.operator
pygments_scope = Keyword
}
.constant.language : style {
color = purple
ace_scope = keyword
textmate_scope = constant.language
pygments_scope = Keyword
}
.storage.type : style {
color = brown
ace_scope = keyword
textmate_scope = storage.type
pygments_scope = Keyword
}
.storage.modifier : style {
color = brown
ace_scope = keyword
textmate_scope = storage.modifier
pygments_scope = Keyword
}
.entity.name.section : style {
color = grey
ace_scope = text
textmate_scope = entity.name.section
pygments_scope = String
}
.entity.name.function : style {
color = green
ace_scope = text
textmate_scope = entity.name.function
pygments_scope = String
}
.numeric : style {
color = gold
ace_scope = constant.numeric
textmate_scope = constant.numeric
pygments_scope = Number
}
.punctuation : style {
color = red_2
ace_scope = punctuation
textmate_scope = punctuation
pygments_scope = Punctuation
}
.text : style {
color = brown
ace_scope = text
textmate_scope = text
pygments_scope = String
}
.directive : style {
color = pink
ace_scope = text
textmate_scope = meta
pygments_scope = String
}
.illegal : style {
color = white
background_color = red
ace_scope = invalid
textmate_scope = invalid
pygments_scope = Generic.Error
}
.support.function : style {
color = yellow
ace_scope = invalid
textmate_scope = .support.function
pygments_scope = Generic.Error
}
}
#################################################
## Parse contexts
#################################################
contexts [] {
##############################################
## Main Context - Entry point context
##############################################
main : context {
: include "numeric" ;
: inline_push {
regex \= (\{)
styles [] = .punctuation;
: pop {
regex \= (\})
styles [] = .punctuation;
}
: include "main" ;
}
: inline_push {
regex \= (\")
styles [] = .punctuation;
default_style = .text
: pop {
regex \= (\")
styles [] = .punctuation;
}
}
: inline_push {
regex \= (\()
styles [] = .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "numeric" ;
: include "keywords";
: include "storage";
: pattern {
regex \= (,)
styles [] = .punctuation;
}
}
: pattern {
regex \= (\;.+)
styles [] = .comment.line;
}
: inline_push {
regex \= (\bif\b)
styles [] = .keyword.control;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "numeric" ;
: include "storage";
: include "constant";
}
: include "keywords";
: include "storage";
: include "constant";
: include "support";
: pattern {
regex \= (^\s*%\w+)
styles [] = .directive;
}
: inline_push {
regex \= (\w+)\s*(\()
styles [] = .entity.name.function, .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "numeric" ;
: include "storage";
: include "constant";
}
: pattern {
regex \= (\b\w+\.)
styles [] = .entity.name.section;
}
: pattern {
regex \= (\b\w+\s*)(\{)
styles [] = .entity.name.section, .punctuation;
}
}
#################################################
## End of Contexts
#################################################
keywords : context {
: pattern {
regex \= (\b(sub|for|in|to|do|while|until|repeat|else|when|return)\b)
styles [] = .keyword.control;
}
: pattern {
regex \= (\b(and|or)\b)
styles [] = .keyword.operator;
}
}
storage : context {
: pattern {
regex \= (\b(void|ubyte|byte|word|uword|float|str)\b)
styles [] = .storage.type;
}
: pattern {
regex \= (\b(const)\b)
styles [] = .storage.modifier;
}
}
constant : context {
: pattern {
regex \= (true|false)
styles [] = .constant.language;
}
}
support : context {
: pattern {
regex \= (\b(abs|atan|ceil|cos|cos8u|cos8|cos16u|cos16|deg|floor|ln|log2|rad|round|sin|sgn|sin8u|sin8|sin16u|sin16|sqrt16|sqrt|tan|any|all|len|max|min|reverse|sum|sort|memcopy|memset|memsetw|leftstr|rightstr|strlen|strcmp|substr|exit|lsb|msb|mkword|rnd|rndw|rndf|rol|rol2|ror|ror2|rsave|rrestore|read_flags|sizeof|set_carry|clear_carry|set_irqd|clear_irqd|swap)\b)
styles [] = .support.function;
}
}
###########################################
## Numeric Context
###########################################
numeric : context {
: pattern {
regex \= (\b\d+)
styles [] = .numeric;
}
}
}