ceml 0.7.13 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile +1 -1
- data/VERSION +1 -1
- data/ceml.gemspec +62 -50
- data/guide/guide.html +69 -14
- data/guide/guide.md +74 -15
- data/guide/guide.pdf +0 -0
- data/lib/ceml/driver.rb +0 -181
- data/lib/ceml/lang/basic_instruction.rb +49 -0
- data/lib/ceml/{casting_statement.rb → lang/casting_statement.rb} +19 -9
- data/lib/ceml/{instruction_statements.rb → lang/instruction_statements.rb} +5 -16
- data/lib/ceml/{script.rb → lang/script.rb} +53 -43
- data/lib/ceml/lang/tt/casting.rb +432 -0
- data/lib/ceml/lang/tt/casting.treetop +29 -0
- data/lib/ceml/lang/tt/instructions.rb +1130 -0
- data/lib/ceml/lang/tt/instructions.treetop +86 -0
- data/lib/ceml/lang/tt/lexer.rb +1804 -0
- data/lib/ceml/{tt → lang/tt}/lexer.treetop +70 -7
- data/lib/ceml/lang/tt/scripts.rb +647 -0
- data/lib/ceml/{tt → lang/tt}/scripts.treetop +2 -2
- data/lib/ceml/lang.rb +10 -0
- data/lib/ceml/models/audition.rb +65 -0
- data/lib/ceml/models/bundle.rb +64 -0
- data/lib/ceml/models/cast.rb +108 -0
- data/lib/ceml/models/castable.rb +81 -0
- data/lib/ceml/{incident.rb → models/incident.rb} +63 -15
- data/lib/ceml/models/incident_model.rb +100 -0
- data/lib/ceml/models/incident_role_slot.rb +16 -0
- data/lib/ceml/models/player.rb +80 -0
- data/lib/ceml/models/queue.rb +12 -0
- data/lib/ceml/models/waiting_room.rb +40 -0
- data/lib/ceml/models.rb +16 -0
- data/lib/ceml/processor.rb +162 -0
- data/lib/ceml.rb +7 -14
- data/test/askchain.ceml +6 -0
- data/test/compliment.ceml +4 -0
- data/test/dialogues/accept.ceml +24 -0
- data/test/dialogues/basic_seed.ceml +26 -0
- data/test/dialogues/jordan.ceml +121 -0
- data/test/helper.rb +44 -39
- data/test/jane.ceml +48 -0
- data/test/{test_casting.rb → lang/test_casting.rb} +5 -0
- data/test/lang/test_instructions.rb +42 -0
- data/test/{test_scripts.rb → lang/test_scripts.rb} +3 -2
- data/test/sync.ceml +6 -0
- data/test/test_castable.rb +20 -0
- data/test/test_dialogues.rb +58 -0
- data/test/test_incident.rb +64 -127
- metadata +54 -30
- data/.gitignore +0 -23
- data/lib/ceml/confluence.rb +0 -63
- data/lib/ceml/role.rb +0 -61
- data/lib/ceml/tt/casting.treetop +0 -65
- data/lib/ceml/tt/instructions.treetop +0 -91
- data/test/test_instructions.rb +0 -27
- data/test/test_release.rb +0 -78
@@ -0,0 +1,647 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
module CEML
|
5
|
+
module Scripts
|
6
|
+
include Treetop::Runtime
|
7
|
+
|
8
|
+
def root
|
9
|
+
@root ||= :scripts
|
10
|
+
end
|
11
|
+
|
12
|
+
include Lexer
|
13
|
+
|
14
|
+
include Casting
|
15
|
+
|
16
|
+
include Instructions
|
17
|
+
|
18
|
+
module Scripts0
|
19
|
+
def nl
|
20
|
+
elements[0]
|
21
|
+
end
|
22
|
+
|
23
|
+
def script
|
24
|
+
elements[1]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Scripts1
|
29
|
+
def script
|
30
|
+
elements[0]
|
31
|
+
end
|
32
|
+
|
33
|
+
def more
|
34
|
+
elements[1]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Scripts2
|
39
|
+
def list
|
40
|
+
[script] + more.elements.map(&:script)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def _nt_scripts
|
45
|
+
start_index = index
|
46
|
+
if node_cache[:scripts].has_key?(index)
|
47
|
+
cached = node_cache[:scripts][index]
|
48
|
+
if cached
|
49
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
50
|
+
@index = cached.interval.end
|
51
|
+
end
|
52
|
+
return cached
|
53
|
+
end
|
54
|
+
|
55
|
+
i0, s0 = index, []
|
56
|
+
r1 = _nt_script
|
57
|
+
s0 << r1
|
58
|
+
if r1
|
59
|
+
s2, i2 = [], index
|
60
|
+
loop do
|
61
|
+
i3, s3 = index, []
|
62
|
+
r4 = _nt_nl
|
63
|
+
s3 << r4
|
64
|
+
if r4
|
65
|
+
r5 = _nt_script
|
66
|
+
s3 << r5
|
67
|
+
end
|
68
|
+
if s3.last
|
69
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
70
|
+
r3.extend(Scripts0)
|
71
|
+
else
|
72
|
+
@index = i3
|
73
|
+
r3 = nil
|
74
|
+
end
|
75
|
+
if r3
|
76
|
+
s2 << r3
|
77
|
+
else
|
78
|
+
break
|
79
|
+
end
|
80
|
+
end
|
81
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
82
|
+
s0 << r2
|
83
|
+
end
|
84
|
+
if s0.last
|
85
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
86
|
+
r0.extend(Scripts1)
|
87
|
+
r0.extend(Scripts2)
|
88
|
+
else
|
89
|
+
@index = i0
|
90
|
+
r0 = nil
|
91
|
+
end
|
92
|
+
|
93
|
+
node_cache[:scripts][start_index] = r0
|
94
|
+
|
95
|
+
r0
|
96
|
+
end
|
97
|
+
|
98
|
+
module FreeScripts0
|
99
|
+
def scripts
|
100
|
+
elements[1]
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
def _nt_free_scripts
|
106
|
+
start_index = index
|
107
|
+
if node_cache[:free_scripts].has_key?(index)
|
108
|
+
cached = node_cache[:free_scripts][index]
|
109
|
+
if cached
|
110
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
111
|
+
@index = cached.interval.end
|
112
|
+
end
|
113
|
+
return cached
|
114
|
+
end
|
115
|
+
|
116
|
+
i0, s0 = index, []
|
117
|
+
r2 = _nt_nl
|
118
|
+
if r2
|
119
|
+
r1 = r2
|
120
|
+
else
|
121
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
122
|
+
end
|
123
|
+
s0 << r1
|
124
|
+
if r1
|
125
|
+
r3 = _nt_scripts
|
126
|
+
s0 << r3
|
127
|
+
if r3
|
128
|
+
r5 = _nt_nl
|
129
|
+
if r5
|
130
|
+
r4 = r5
|
131
|
+
else
|
132
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
133
|
+
end
|
134
|
+
s0 << r4
|
135
|
+
end
|
136
|
+
end
|
137
|
+
if s0.last
|
138
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
139
|
+
r0.extend(FreeScripts0)
|
140
|
+
else
|
141
|
+
@index = i0
|
142
|
+
r0 = nil
|
143
|
+
end
|
144
|
+
|
145
|
+
node_cache[:free_scripts][start_index] = r0
|
146
|
+
|
147
|
+
r0
|
148
|
+
end
|
149
|
+
|
150
|
+
module FreeScript0
|
151
|
+
def script
|
152
|
+
elements[1]
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
def _nt_free_script
|
158
|
+
start_index = index
|
159
|
+
if node_cache[:free_script].has_key?(index)
|
160
|
+
cached = node_cache[:free_script][index]
|
161
|
+
if cached
|
162
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
163
|
+
@index = cached.interval.end
|
164
|
+
end
|
165
|
+
return cached
|
166
|
+
end
|
167
|
+
|
168
|
+
i0, s0 = index, []
|
169
|
+
r2 = _nt_nl
|
170
|
+
if r2
|
171
|
+
r1 = r2
|
172
|
+
else
|
173
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
174
|
+
end
|
175
|
+
s0 << r1
|
176
|
+
if r1
|
177
|
+
r3 = _nt_script
|
178
|
+
s0 << r3
|
179
|
+
if r3
|
180
|
+
r5 = _nt_nl
|
181
|
+
if r5
|
182
|
+
r4 = r5
|
183
|
+
else
|
184
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
185
|
+
end
|
186
|
+
s0 << r4
|
187
|
+
end
|
188
|
+
end
|
189
|
+
if s0.last
|
190
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
191
|
+
r0.extend(FreeScript0)
|
192
|
+
else
|
193
|
+
@index = i0
|
194
|
+
r0 = nil
|
195
|
+
end
|
196
|
+
|
197
|
+
node_cache[:free_script][start_index] = r0
|
198
|
+
|
199
|
+
r0
|
200
|
+
end
|
201
|
+
|
202
|
+
module Script0
|
203
|
+
def title
|
204
|
+
elements[0]
|
205
|
+
end
|
206
|
+
|
207
|
+
def nl1
|
208
|
+
elements[1]
|
209
|
+
end
|
210
|
+
|
211
|
+
def casting_statement
|
212
|
+
elements[2]
|
213
|
+
end
|
214
|
+
|
215
|
+
def nl2
|
216
|
+
elements[3]
|
217
|
+
end
|
218
|
+
|
219
|
+
def instructions
|
220
|
+
elements[4]
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
module Script1
|
225
|
+
def title
|
226
|
+
elements[0]
|
227
|
+
end
|
228
|
+
|
229
|
+
def nl
|
230
|
+
elements[1]
|
231
|
+
end
|
232
|
+
|
233
|
+
def instructions
|
234
|
+
elements[2]
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
module Script2
|
239
|
+
def casting_statement
|
240
|
+
elements[0]
|
241
|
+
end
|
242
|
+
|
243
|
+
def nl
|
244
|
+
elements[1]
|
245
|
+
end
|
246
|
+
|
247
|
+
def instructions
|
248
|
+
elements[2]
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
module Script3
|
253
|
+
def title
|
254
|
+
elements[0]
|
255
|
+
end
|
256
|
+
|
257
|
+
def nl
|
258
|
+
elements[1]
|
259
|
+
end
|
260
|
+
|
261
|
+
def casting_statement
|
262
|
+
elements[2]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
module Script4
|
267
|
+
def title
|
268
|
+
elements[0]
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
module Script5
|
274
|
+
end
|
275
|
+
|
276
|
+
def _nt_script
|
277
|
+
start_index = index
|
278
|
+
if node_cache[:script].has_key?(index)
|
279
|
+
cached = node_cache[:script][index]
|
280
|
+
if cached
|
281
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
282
|
+
@index = cached.interval.end
|
283
|
+
end
|
284
|
+
return cached
|
285
|
+
end
|
286
|
+
|
287
|
+
i0, s0 = index, []
|
288
|
+
i1 = index
|
289
|
+
i2, s2 = index, []
|
290
|
+
r3 = _nt_title
|
291
|
+
s2 << r3
|
292
|
+
if r3
|
293
|
+
r4 = _nt_nl
|
294
|
+
s2 << r4
|
295
|
+
if r4
|
296
|
+
r5 = _nt_casting_statement
|
297
|
+
s2 << r5
|
298
|
+
if r5
|
299
|
+
r6 = _nt_nl
|
300
|
+
s2 << r6
|
301
|
+
if r6
|
302
|
+
r7 = _nt_instructions
|
303
|
+
s2 << r7
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
if s2.last
|
309
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
310
|
+
r2.extend(Script0)
|
311
|
+
else
|
312
|
+
@index = i2
|
313
|
+
r2 = nil
|
314
|
+
end
|
315
|
+
if r2
|
316
|
+
r1 = r2
|
317
|
+
else
|
318
|
+
i8, s8 = index, []
|
319
|
+
r9 = _nt_title
|
320
|
+
s8 << r9
|
321
|
+
if r9
|
322
|
+
r10 = _nt_nl
|
323
|
+
s8 << r10
|
324
|
+
if r10
|
325
|
+
r11 = _nt_instructions
|
326
|
+
s8 << r11
|
327
|
+
end
|
328
|
+
end
|
329
|
+
if s8.last
|
330
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
331
|
+
r8.extend(Script1)
|
332
|
+
else
|
333
|
+
@index = i8
|
334
|
+
r8 = nil
|
335
|
+
end
|
336
|
+
if r8
|
337
|
+
r1 = r8
|
338
|
+
else
|
339
|
+
i12, s12 = index, []
|
340
|
+
r13 = _nt_casting_statement
|
341
|
+
s12 << r13
|
342
|
+
if r13
|
343
|
+
r14 = _nt_nl
|
344
|
+
s12 << r14
|
345
|
+
if r14
|
346
|
+
r15 = _nt_instructions
|
347
|
+
s12 << r15
|
348
|
+
end
|
349
|
+
end
|
350
|
+
if s12.last
|
351
|
+
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
352
|
+
r12.extend(Script2)
|
353
|
+
else
|
354
|
+
@index = i12
|
355
|
+
r12 = nil
|
356
|
+
end
|
357
|
+
if r12
|
358
|
+
r1 = r12
|
359
|
+
else
|
360
|
+
i16, s16 = index, []
|
361
|
+
r17 = _nt_title
|
362
|
+
s16 << r17
|
363
|
+
if r17
|
364
|
+
r18 = _nt_nl
|
365
|
+
s16 << r18
|
366
|
+
if r18
|
367
|
+
r19 = _nt_casting_statement
|
368
|
+
s16 << r19
|
369
|
+
end
|
370
|
+
end
|
371
|
+
if s16.last
|
372
|
+
r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
|
373
|
+
r16.extend(Script3)
|
374
|
+
else
|
375
|
+
@index = i16
|
376
|
+
r16 = nil
|
377
|
+
end
|
378
|
+
if r16
|
379
|
+
r1 = r16
|
380
|
+
else
|
381
|
+
r20 = _nt_instructions
|
382
|
+
if r20
|
383
|
+
r1 = r20
|
384
|
+
else
|
385
|
+
i21, s21 = index, []
|
386
|
+
r22 = _nt_title
|
387
|
+
s21 << r22
|
388
|
+
if r22
|
389
|
+
if has_terminal?('', false, index)
|
390
|
+
r23 = instantiate_node(SyntaxNode,input, index...(index + 0))
|
391
|
+
@index += 0
|
392
|
+
else
|
393
|
+
terminal_parse_failure('')
|
394
|
+
r23 = nil
|
395
|
+
end
|
396
|
+
s21 << r23
|
397
|
+
end
|
398
|
+
if s21.last
|
399
|
+
r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
|
400
|
+
r21.extend(Script4)
|
401
|
+
else
|
402
|
+
@index = i21
|
403
|
+
r21 = nil
|
404
|
+
end
|
405
|
+
if r21
|
406
|
+
r1 = r21
|
407
|
+
else
|
408
|
+
@index = i1
|
409
|
+
r1 = nil
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
s0 << r1
|
417
|
+
if r1
|
418
|
+
if has_terminal?('', false, index)
|
419
|
+
r24 = instantiate_node(SyntaxNode,input, index...(index + 0))
|
420
|
+
@index += 0
|
421
|
+
else
|
422
|
+
terminal_parse_failure('')
|
423
|
+
r24 = nil
|
424
|
+
end
|
425
|
+
s0 << r24
|
426
|
+
end
|
427
|
+
if s0.last
|
428
|
+
r0 = instantiate_node(Script,input, i0...index, s0)
|
429
|
+
r0.extend(Script5)
|
430
|
+
else
|
431
|
+
@index = i0
|
432
|
+
r0 = nil
|
433
|
+
end
|
434
|
+
|
435
|
+
node_cache[:script][start_index] = r0
|
436
|
+
|
437
|
+
r0
|
438
|
+
end
|
439
|
+
|
440
|
+
module Title0
|
441
|
+
end
|
442
|
+
|
443
|
+
module Title1
|
444
|
+
def value
|
445
|
+
elements[1]
|
446
|
+
end
|
447
|
+
|
448
|
+
end
|
449
|
+
|
450
|
+
module Title2
|
451
|
+
def title_value
|
452
|
+
value.text_value.gsub(/\\"/, '"')
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
def _nt_title
|
457
|
+
start_index = index
|
458
|
+
if node_cache[:title].has_key?(index)
|
459
|
+
cached = node_cache[:title][index]
|
460
|
+
if cached
|
461
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
462
|
+
@index = cached.interval.end
|
463
|
+
end
|
464
|
+
return cached
|
465
|
+
end
|
466
|
+
|
467
|
+
i0, s0 = index, []
|
468
|
+
if has_terminal?('"', false, index)
|
469
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
470
|
+
@index += 1
|
471
|
+
else
|
472
|
+
terminal_parse_failure('"')
|
473
|
+
r1 = nil
|
474
|
+
end
|
475
|
+
s0 << r1
|
476
|
+
if r1
|
477
|
+
s2, i2 = [], index
|
478
|
+
loop do
|
479
|
+
i3 = index
|
480
|
+
if has_terminal?('\\"', false, index)
|
481
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
482
|
+
@index += 2
|
483
|
+
else
|
484
|
+
terminal_parse_failure('\\"')
|
485
|
+
r4 = nil
|
486
|
+
end
|
487
|
+
if r4
|
488
|
+
r3 = r4
|
489
|
+
else
|
490
|
+
i5, s5 = index, []
|
491
|
+
i6 = index
|
492
|
+
if has_terminal?('"', false, index)
|
493
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
494
|
+
@index += 1
|
495
|
+
else
|
496
|
+
terminal_parse_failure('"')
|
497
|
+
r7 = nil
|
498
|
+
end
|
499
|
+
if r7
|
500
|
+
r6 = nil
|
501
|
+
else
|
502
|
+
@index = i6
|
503
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
504
|
+
end
|
505
|
+
s5 << r6
|
506
|
+
if r6
|
507
|
+
if index < input_length
|
508
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
509
|
+
@index += 1
|
510
|
+
else
|
511
|
+
terminal_parse_failure("any character")
|
512
|
+
r8 = nil
|
513
|
+
end
|
514
|
+
s5 << r8
|
515
|
+
end
|
516
|
+
if s5.last
|
517
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
518
|
+
r5.extend(Title0)
|
519
|
+
else
|
520
|
+
@index = i5
|
521
|
+
r5 = nil
|
522
|
+
end
|
523
|
+
if r5
|
524
|
+
r3 = r5
|
525
|
+
else
|
526
|
+
@index = i3
|
527
|
+
r3 = nil
|
528
|
+
end
|
529
|
+
end
|
530
|
+
if r3
|
531
|
+
s2 << r3
|
532
|
+
else
|
533
|
+
break
|
534
|
+
end
|
535
|
+
end
|
536
|
+
if s2.empty?
|
537
|
+
@index = i2
|
538
|
+
r2 = nil
|
539
|
+
else
|
540
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
541
|
+
end
|
542
|
+
s0 << r2
|
543
|
+
if r2
|
544
|
+
if has_terminal?('"', false, index)
|
545
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
546
|
+
@index += 1
|
547
|
+
else
|
548
|
+
terminal_parse_failure('"')
|
549
|
+
r9 = nil
|
550
|
+
end
|
551
|
+
s0 << r9
|
552
|
+
end
|
553
|
+
end
|
554
|
+
if s0.last
|
555
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
556
|
+
r0.extend(Title1)
|
557
|
+
r0.extend(Title2)
|
558
|
+
else
|
559
|
+
@index = i0
|
560
|
+
r0 = nil
|
561
|
+
end
|
562
|
+
|
563
|
+
node_cache[:title][start_index] = r0
|
564
|
+
|
565
|
+
r0
|
566
|
+
end
|
567
|
+
|
568
|
+
module Instructions0
|
569
|
+
def nl
|
570
|
+
elements[0]
|
571
|
+
end
|
572
|
+
|
573
|
+
def instruction_stmt
|
574
|
+
elements[1]
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
module Instructions1
|
579
|
+
def instruction_stmt
|
580
|
+
elements[0]
|
581
|
+
end
|
582
|
+
|
583
|
+
def more
|
584
|
+
elements[1]
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
def _nt_instructions
|
589
|
+
start_index = index
|
590
|
+
if node_cache[:instructions].has_key?(index)
|
591
|
+
cached = node_cache[:instructions][index]
|
592
|
+
if cached
|
593
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
594
|
+
@index = cached.interval.end
|
595
|
+
end
|
596
|
+
return cached
|
597
|
+
end
|
598
|
+
|
599
|
+
i0, s0 = index, []
|
600
|
+
r1 = _nt_instruction_stmt
|
601
|
+
s0 << r1
|
602
|
+
if r1
|
603
|
+
s2, i2 = [], index
|
604
|
+
loop do
|
605
|
+
i3, s3 = index, []
|
606
|
+
r4 = _nt_nl
|
607
|
+
s3 << r4
|
608
|
+
if r4
|
609
|
+
r5 = _nt_instruction_stmt
|
610
|
+
s3 << r5
|
611
|
+
end
|
612
|
+
if s3.last
|
613
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
614
|
+
r3.extend(Instructions0)
|
615
|
+
else
|
616
|
+
@index = i3
|
617
|
+
r3 = nil
|
618
|
+
end
|
619
|
+
if r3
|
620
|
+
s2 << r3
|
621
|
+
else
|
622
|
+
break
|
623
|
+
end
|
624
|
+
end
|
625
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
626
|
+
s0 << r2
|
627
|
+
end
|
628
|
+
if s0.last
|
629
|
+
r0 = instantiate_node(InstructionStatements,input, i0...index, s0)
|
630
|
+
r0.extend(Instructions1)
|
631
|
+
else
|
632
|
+
@index = i0
|
633
|
+
r0 = nil
|
634
|
+
end
|
635
|
+
|
636
|
+
node_cache[:instructions][start_index] = r0
|
637
|
+
|
638
|
+
r0
|
639
|
+
end
|
640
|
+
|
641
|
+
end
|
642
|
+
|
643
|
+
class ScriptsParser < Treetop::Runtime::CompiledParser
|
644
|
+
include Scripts
|
645
|
+
end
|
646
|
+
|
647
|
+
end
|
data/lib/ceml/lang.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'treetop'
|
2
|
+
|
3
|
+
require 'ceml/lang/script'
|
4
|
+
require 'ceml/lang/casting_statement'
|
5
|
+
require 'ceml/lang/basic_instruction'
|
6
|
+
require 'ceml/lang/instruction_statements'
|
7
|
+
require 'ceml/lang/tt/lexer'
|
8
|
+
require 'ceml/lang/tt/casting'
|
9
|
+
require 'ceml/lang/tt/instructions'
|
10
|
+
require 'ceml/lang/tt/scripts'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module CEML
|
2
|
+
|
3
|
+
class Audition < Struct.new(:id) # "#{code}:#{player_id}"
|
4
|
+
include Redis::Objects
|
5
|
+
set :rooms
|
6
|
+
|
7
|
+
def list_in_rooms(da_rooms)
|
8
|
+
# p "Listing in rooms #{da_rooms.map(&:id)}"
|
9
|
+
da_rooms.each{ |room| self.rooms << room.id; room.add(id) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def clear_from_all_rooms(*extra_rooms)
|
13
|
+
rooms_to_clear = rooms.members + extra_rooms
|
14
|
+
redis.multi do
|
15
|
+
rooms_to_clear.each do |r|
|
16
|
+
WaitingRoom.new(r).waiting_auditions.delete(id)
|
17
|
+
end
|
18
|
+
redis.del rooms.key
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.consume(ids, extra_rooms = [])
|
23
|
+
roomsets = ids.map{ |id| Audition.new(id).rooms }
|
24
|
+
rooms = (roomsets.map(&:members) + extra_rooms).flatten.uniq
|
25
|
+
# puts "Consuming ids #{ids.inspect} from rooms #{rooms.inspect}"
|
26
|
+
# TODO: install new redis and re-enable watchlist
|
27
|
+
# redis.watch(*roomsets.map(&:key))
|
28
|
+
# redis.multi do
|
29
|
+
# rooms = roomsets.first.union(roomsets[1,-1]) || []
|
30
|
+
rooms.each do |r|
|
31
|
+
# puts "PROCESSING ROOM #{r.key}"
|
32
|
+
ids.each do |id|
|
33
|
+
# puts "DELETING #{id} from room #{r}"
|
34
|
+
WaitingRoom.new(r).waiting_auditions.delete(id)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
roomsets.map(&:clear)
|
38
|
+
# end
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.from_rooms(room_ids)
|
43
|
+
players = {}
|
44
|
+
rooms = room_ids.map{ |r| WaitingRoom.new(r) }
|
45
|
+
auditions = rooms.map{ |r| r.waiting_auditions.members }.flatten
|
46
|
+
|
47
|
+
# clear old style
|
48
|
+
auditions.each do |a|
|
49
|
+
next unless a =~ /:/
|
50
|
+
Audition.new(a).rooms.clear
|
51
|
+
rooms.each{ |r| r.waiting_auditions.delete(a) }
|
52
|
+
end
|
53
|
+
|
54
|
+
puts "Auditions found: #{auditions.inspect}"
|
55
|
+
auditions.each do |audition|
|
56
|
+
# next if audition =~ /:/
|
57
|
+
# code, player_id = audition.split(':')
|
58
|
+
player_id = audition
|
59
|
+
players[player_id] ||= audition
|
60
|
+
end
|
61
|
+
players
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|