-
Notifications
You must be signed in to change notification settings - Fork 2
/
exoscript.iro
349 lines (278 loc) · 8.43 KB
/
exoscript.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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
name = sample
file_extensions [] = sample;
styles [] {
.comments : style {
color = "light_green";
textmate_scope = "comment.line";
// pygments_scope = "Comment";
}
.keywords : style {
color = "light_blue";
textmate_scope = "keyword.control";
}
.conditionals :style {
color = "pink";
textmate_scope = "keyword punctuation";
}
.literals : style {
color = "orange";
italic = "true";
textmate_scope = "constant";
}
.story_ids : style {
color = "pink";
textmate_scope = "entity.name.class";
}
.user_variables : style {
color = "yellow";
textmate_scope = "variable.parameter";
}
.game_variables : style {
color = "gold";
textmate_scope = "variable.language";
}
.operators : style {
color = "red";
textmate_scope = "keyword.operator";
}
.real_text : style {
color = "#BBBBAA";
textmate_scope = "text source";
}
}
contexts[] {
interpolatingVariables : context {
: inline_push {
uid = uid_interpolating_vars_in_text_open
regex \= ((\[\=|\[)((?![A-Za-zÀ-ÖØ-öø-ÿ])))
styles [] = .conditionals;
: pop {
uid = uid_interpolating_vars_in_text_close
regex \= (\])
styles [] = .conditionals;
}
: pattern {
uid = uid_interpolating_vars_in_text
regex \= ([a-zA-Z_$]([a-zA-Z_$0-9])+)
styles [] = .game_variables;
}
: pattern {
uid = uid_interpolated_var_pipes_for_gender_thruples
regex \= (\|)
styles [] = .conditionals;
}
}
}
realTextHighlighting : context {
: include "interpolatingVariables" ;
}
randoVariable : context {
: pattern {
uid = uid_rando_variable
regex \= ((?<![A-Za-zÀ-ÖØ-öø-ÿ])([A-Za-zÀ-ÿ_$]([A-Za-zÀ-ÿ_$0-9])+)(?![A-Za-zÀ-ÖØ-öø-ÿ]))
styles [] = .game_variables;
}
}
opsAndLiterals : context {
// number and boolean literals {
: pattern {
uid = uid_story_id
regex \= ((?<![A-Za-zÀ-ÖØ-öø-ÿ])(true|false|none|null)(?![A-Za-zÀ-ÖØ-öø-ÿ]))
styles [] = .literals;
}
// operators
: pattern {
regex \= (&&|\+\+|\+|--|-|>!|!=|=|<|>|<=|>=|%|&|\?|:|\|\|)
styles [] = .operators;
}
: pattern {
regex \= (\!)
styles [] = .operators;
}
: pattern {
regex \= (?<![A-Za-zÀ-ÖØ-öø-ÿ])([0-9]+)(?![A-Za-zÀ-ÖØ-öø-ÿ])
styles [] = .literals;
}
}
vars : context {
: pattern {
uid = uid_scene_temporary_variables
regex \= (var_(.*?)(?=\]|\s))
styles[] = .user_variables;
}
: pattern {
uid = uid_single_game_variables
regex \= (mem_(.*?)(?=\]|\s))
styles[] = .user_variables;
}
: pattern {
uid = uid_all_game_groundhogs_day_variables
regex \= (hog_(.*?)(?=\]|\s))
styles[] = .user_variables;
}
}
tildeProcessing : context {
// The "~" check
: inline_push {
regex \= (~)
styles [] = .conditionals;
: eol_pop {}
// imperatives with a preceding ~
: pattern {
regex \= (ifd|if|setif|set|call)
styles [] = .keywords;
}
: include "main" ;
: include "vars" ;
: include "opsAndLiterals";
: include "randoVariable";
}
}
atSignProcessing : context {
// The "@" check for exoloader markup
: inline_push {
regex \= (@)
styles [] = .conditionals;
: eol_pop {}
// imperatives with a preceding @
: pattern {
regex \= (insert|replace)
styles [] = .keywords;
}
//exolodder syntax includes | as indicators
: pattern {
regex \= (\|)
styles [] = .conditionals;
}
//exolodder syntax includes > as indicators
: pattern {
regex \= (\>)
styles [] = .game_variables;
}
: include "main" ;
: include "vars" ;
: include "opsAndLiterals";
: include "randoVariable";
}
}
bracketProcessing : context {
// the [if random : hunting feral dogs|trying to find some clean drinking water|looking for a working sparkplug]
// construct. I'm going to assume it can be infinitely long!
: inline_push {
regex \= (\[if(\s*?)random(\s*?):)
styles [] = .conditionals;
: pop {
regex \= (\])
styles [] = .conditionals;
}
: pattern {
regex \= (\|)
styles [] = .conditionals;
}
: pattern {
regex \= (^[\|])
styles [] = .real_text;
}
}
// conditionals (The "[...]" check)
// Todo: the [They|He\She] check
// Todo:
: inline_push {
regex \= (\[)
styles [] = .conditionals;
: pop {
regex \= (\])
styles [] = .conditionals;
}
: include "main" ;
: include "vars" ;
: include "opsAndLiterals";
: include "randoVariable";
: pattern {
regex \= (and|call|else|end|elseif|if|ifd|or|random|set|setif)
styles [] = .keywords;
}
// number and boolean literals {
: pattern {
regex \= ([^(A-Za-zÀ-ÿ)]\\d+|true|false|none|null|((\\+|-)\\d+))
styles [] = .literals;
}
}
}
jumpProcessing : context {
: inline_push {
regex \= (^(\s*?)(>+))
styles [] = .operators;
default_style = ".real_text";
: pop {
regex \= (.*?$)
styles [] = .user_variables;
}
}
//choiceid identifier - just = followed by a word
: inline_push {
uid = uid_choiceid_identifier
regex \= (^\s*=(?!=))
styles [] = .conditionals;
default_style = ".real_text";
: pop {
regex \= (.*?$)
styles [] = .user_variables;
}
}
//subchoice flow - any number of *'s
: inline_push {
uid = uid_subchoice_flow
regex \= (\s\*+\s)
styles [] = .conditionals;
default_style = ".real_text";
: pop {
regex \= (.*?$)
styles [] = .user_variables;
}
}
// Any number of *'s... and a =
: inline_push {
uid = uid_subchoice_flow_break
regex \= (\s\*+=\s)
styles [] = .conditionals;
default_style = ".real_text";
: pop {
regex \= (.*?$)
styles [] = .user_variables;
}
}
}
storyIdProcessing : context {
: inline_push {
regex \= (^===\s)
styles [] = .conditionals;
default_style = ".real_text";
: pop {
regex \= ((?<![A-Za-zÀ-ÖØ-öø-ÿ])([a-zA-Z_$]([A-Za-zÀ-ÿ_$0-9])+)(?![A-Za-zÀ-ÖØ-öø-ÿ]))
styles [] = .story_ids;
}
}
}
main : context {
default_style = ".real_text";
: include "storyIdProcessing";
// for any number of whitespaces, a single -, any number of whitespaces, and a newline
: pattern {
uid = uid_hard_break
regex \= ((\s*?)-(\s*?)$)
styles [] = .conditionals;
}
// comments
: pattern {
uid = uid_single_line_comment
regex \= (====(=+))|(/\*(.*?)$|//(.*?)$)$
styles[] = .comments;
}
: include "jumpProcessing";
: include "tildeProcessing";
: include "bracketProcessing";
: include "atSignProcessing";
: include "realTextHighlighting";
}
}