plasma 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1 @@
1
+ PLASMA
@@ -0,0 +1,28 @@
1
+ dir = File.dirname(__FILE__)
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ Gem::manage_gems
6
+ require 'rake/gempackagetask'
7
+
8
+ gemspec = Gem::Specification.new do |s|
9
+ s.name = "plasma"
10
+ s.version = "0.0.1"
11
+ s.author = "Ryan Spangler"
12
+ s.email = "patch_work8848@yahoo.com"
13
+ s.homepage = "http://kaleidomedallion.com/plasma/"
14
+ s.platform = Gem::Platform::RUBY
15
+ s.summary = "plasma --- a lightweight interpreted templating language in ruby"
16
+ s.files = FileList['README', 'Rakefile', "{test,lib,bin,doc,examples}/**/*"].to_a
17
+ s.bindir = 'bin'
18
+ s.executables = ['plasma']
19
+ s.require_path = 'lib'
20
+ s.rubyforge_project = 'plasma'
21
+ s.add_dependency "treetop"
22
+ end
23
+
24
+ Rake::GemPackageTask.new(gemspec) do |pkg|
25
+ pkg.need_tar = true
26
+ end
27
+
28
+
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ gem 'plasma'
4
+
5
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
6
+ require 'plasma'
7
+
8
+ interpreter = Plasma::Interpreter::PlasmaInterpreter.new
9
+
10
+ if ARGV.empty?
11
+ interpreter.repl
12
+ else
13
+ puts interpreter.merge(ARGV[0])
14
+ end
15
+
16
+
17
+
18
+
@@ -0,0 +1,18 @@
1
+ class PlasmaView
2
+ def initialize(action_view)
3
+ @action_view = action_view
4
+ end
5
+
6
+ def render(template, local_assigns)
7
+ @action_view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
8
+ assigns = @action_view.assigns.dup
9
+
10
+ if content_for_layout = @action_view.instance_variable_get("@content_for_layout")
11
+ assigns['content_for_layout'] = content_for_layout
12
+ end
13
+ assigns.merge!(local_assigns)
14
+
15
+ plasma = Plasma::Template::PlasmaTemplate.parse(template)
16
+ plasma.render(assigns)
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+
3
+ dir = File.dirname(__FILE__)
4
+
5
+ PLASMA_ROOT = File.join(dir, 'plasma')
6
+ PLASMA_PACKAGE_ROOT = File.expand_path(dir + '/..')
7
+
8
+ require File.join(PLASMA_ROOT, 'interpreter')
9
+ require File.join(PLASMA_ROOT, 'template')
10
+
11
+ $LOAD_PATH.unshift(dir)
@@ -0,0 +1,3 @@
1
+ |
2
+ (def yyyyy 55555) |
3
+ (def zwzwz 98989) |
@@ -0,0 +1,27 @@
1
+ module Plasma
2
+ module Interpreter
3
+ class PlasmaCore
4
+ def self.plasma(interp)
5
+ {
6
+ :import => RubyClosure.new('import', interp) do |plasma|
7
+ interp.merge(plasma)
8
+ end,
9
+
10
+ :print => RubyClosure.new('print', interp) do |string|
11
+ puts string.to_plasma
12
+ end,
13
+
14
+ :eval => RubyClosure.new('eval', interp) do |quote|
15
+ if quote.is_a?(String)
16
+ interp.interpret(quote)
17
+ else
18
+ interp.evaluate(quote)
19
+ end
20
+ end
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+
@@ -0,0 +1,9 @@
1
+ dir = File.join(File.dirname(__FILE__), 'interpreter')
2
+
3
+ require 'treetop'
4
+ require File.join(dir, 'class_mods')
5
+ require File.join(dir, 'plasma_grammar')
6
+ require File.join(dir, 'plasma_grammarnode')
7
+ require File.join(dir, 'plasma_interpreter')
8
+
9
+
@@ -0,0 +1,43 @@
1
+ class Object
2
+ def to_plasma
3
+ self
4
+ end
5
+ end
6
+
7
+ class String
8
+ def classify
9
+ self.split('_').map{|s| s.capitalize}.join
10
+ end
11
+
12
+ def to_plasma
13
+ self.inspect
14
+ end
15
+ end
16
+
17
+ class Array
18
+ def to_hash
19
+ hash = {}
20
+ self.each {|key, value| hash[key] = value}
21
+
22
+ return hash
23
+ end
24
+
25
+ def to_plasma
26
+ plasma = self.map do |p|
27
+ p.to_plasma
28
+ end.join ' '
29
+
30
+ return "[#{plasma}]"
31
+ end
32
+ end
33
+
34
+ class Hash
35
+ def to_plasma
36
+ plasma = self.map do |key, value|
37
+ "#{key.to_s}:#{value.to_plasma}"
38
+ end.join ' '
39
+
40
+ return "{#{plasma}}"
41
+ end
42
+ end
43
+
@@ -0,0 +1,1996 @@
1
+ module Plasma
2
+ module Interpreter
3
+ module PlasmaGrammar
4
+ include Treetop::Runtime
5
+
6
+ def root
7
+ @root || :plasma
8
+ end
9
+
10
+ def _nt_plasma
11
+ start_index = index
12
+ if node_cache[:plasma].has_key?(index)
13
+ cached = node_cache[:plasma][index]
14
+ @index = cached.interval.end if cached
15
+ return cached
16
+ end
17
+
18
+ i0 = index
19
+ r1 = _nt_decl
20
+ if r1
21
+ r0 = r1
22
+ else
23
+ r2 = _nt_seq
24
+ if r2
25
+ r0 = r2
26
+ else
27
+ r3 = _nt_quote
28
+ if r3
29
+ r0 = r3
30
+ else
31
+ r4 = _nt_defun
32
+ if r4
33
+ r0 = r4
34
+ else
35
+ r5 = _nt_def
36
+ if r5
37
+ r0 = r5
38
+ else
39
+ r6 = _nt_fun
40
+ if r6
41
+ r0 = r6
42
+ else
43
+ r7 = _nt_if
44
+ if r7
45
+ r0 = r7
46
+ else
47
+ r8 = _nt_apply
48
+ if r8
49
+ r0 = r8
50
+ else
51
+ r9 = _nt_bool
52
+ if r9
53
+ r0 = r9
54
+ else
55
+ r10 = _nt_sym
56
+ if r10
57
+ r0 = r10
58
+ else
59
+ r11 = _nt_hash
60
+ if r11
61
+ r0 = r11
62
+ else
63
+ r12 = _nt_list
64
+ if r12
65
+ r0 = r12
66
+ else
67
+ r13 = _nt_date
68
+ if r13
69
+ r0 = r13
70
+ else
71
+ r14 = _nt_time
72
+ if r14
73
+ r0 = r14
74
+ else
75
+ r15 = _nt_str
76
+ if r15
77
+ r0 = r15
78
+ else
79
+ r16 = _nt_num
80
+ if r16
81
+ r0 = r16
82
+ else
83
+ self.index = i0
84
+ r0 = nil
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ node_cache[:plasma][start_index] = r0
103
+
104
+ return r0
105
+ end
106
+
107
+ module Decl0
108
+ def s
109
+ elements[0]
110
+ end
111
+
112
+ def s
113
+ elements[2]
114
+ end
115
+
116
+ def plasma
117
+ elements[3]
118
+ end
119
+ end
120
+
121
+ module Decl1
122
+ def x
123
+ elements[1]
124
+ end
125
+
126
+ def first
127
+ elements[2]
128
+ end
129
+
130
+ def rest
131
+ elements[3]
132
+ end
133
+
134
+ def x
135
+ elements[4]
136
+ end
137
+
138
+ end
139
+
140
+ def _nt_decl
141
+ start_index = index
142
+ if node_cache[:decl].has_key?(index)
143
+ cached = node_cache[:decl][index]
144
+ @index = cached.interval.end if cached
145
+ return cached
146
+ end
147
+
148
+ i0, s0 = index, []
149
+ if input.index('|', index) == index
150
+ r1 = (SyntaxNode).new(input, index...(index + 1))
151
+ @index += 1
152
+ else
153
+ terminal_parse_failure('|')
154
+ r1 = nil
155
+ end
156
+ s0 << r1
157
+ if r1
158
+ r2 = _nt_x
159
+ s0 << r2
160
+ if r2
161
+ r4 = _nt_plasma
162
+ if r4
163
+ r3 = r4
164
+ else
165
+ r3 = SyntaxNode.new(input, index...index)
166
+ end
167
+ s0 << r3
168
+ if r3
169
+ s5, i5 = [], index
170
+ loop do
171
+ i6, s6 = index, []
172
+ r7 = _nt_s
173
+ s6 << r7
174
+ if r7
175
+ if input.index('|', index) == index
176
+ r8 = (SyntaxNode).new(input, index...(index + 1))
177
+ @index += 1
178
+ else
179
+ terminal_parse_failure('|')
180
+ r8 = nil
181
+ end
182
+ s6 << r8
183
+ if r8
184
+ r9 = _nt_s
185
+ s6 << r9
186
+ if r9
187
+ r10 = _nt_plasma
188
+ s6 << r10
189
+ end
190
+ end
191
+ end
192
+ if s6.last
193
+ r6 = (SyntaxNode).new(input, i6...index, s6)
194
+ r6.extend(Decl0)
195
+ else
196
+ self.index = i6
197
+ r6 = nil
198
+ end
199
+ if r6
200
+ s5 << r6
201
+ else
202
+ break
203
+ end
204
+ end
205
+ r5 = SyntaxNode.new(input, i5...index, s5)
206
+ s0 << r5
207
+ if r5
208
+ r11 = _nt_x
209
+ s0 << r11
210
+ if r11
211
+ if input.index('|', index) == index
212
+ r12 = (SyntaxNode).new(input, index...(index + 1))
213
+ @index += 1
214
+ else
215
+ terminal_parse_failure('|')
216
+ r12 = nil
217
+ end
218
+ s0 << r12
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
224
+ if s0.last
225
+ r0 = (DeclNode).new(input, i0...index, s0)
226
+ r0.extend(Decl1)
227
+ else
228
+ self.index = i0
229
+ r0 = nil
230
+ end
231
+
232
+ node_cache[:decl][start_index] = r0
233
+
234
+ return r0
235
+ end
236
+
237
+ module Seq0
238
+ def s
239
+ elements[0]
240
+ end
241
+
242
+ def s
243
+ elements[2]
244
+ end
245
+
246
+ def plasma
247
+ elements[3]
248
+ end
249
+ end
250
+
251
+ module Seq1
252
+ def x
253
+ elements[1]
254
+ end
255
+
256
+ def first
257
+ elements[2]
258
+ end
259
+
260
+ def rest
261
+ elements[3]
262
+ end
263
+
264
+ def x
265
+ elements[4]
266
+ end
267
+
268
+ end
269
+
270
+ def _nt_seq
271
+ start_index = index
272
+ if node_cache[:seq].has_key?(index)
273
+ cached = node_cache[:seq][index]
274
+ @index = cached.interval.end if cached
275
+ return cached
276
+ end
277
+
278
+ i0, s0 = index, []
279
+ if input.index('(', index) == index
280
+ r1 = (SyntaxNode).new(input, index...(index + 1))
281
+ @index += 1
282
+ else
283
+ terminal_parse_failure('(')
284
+ r1 = nil
285
+ end
286
+ s0 << r1
287
+ if r1
288
+ r2 = _nt_x
289
+ s0 << r2
290
+ if r2
291
+ r4 = _nt_plasma
292
+ if r4
293
+ r3 = r4
294
+ else
295
+ r3 = SyntaxNode.new(input, index...index)
296
+ end
297
+ s0 << r3
298
+ if r3
299
+ s5, i5 = [], index
300
+ loop do
301
+ i6, s6 = index, []
302
+ r7 = _nt_s
303
+ s6 << r7
304
+ if r7
305
+ if input.index('|', index) == index
306
+ r8 = (SyntaxNode).new(input, index...(index + 1))
307
+ @index += 1
308
+ else
309
+ terminal_parse_failure('|')
310
+ r8 = nil
311
+ end
312
+ s6 << r8
313
+ if r8
314
+ r9 = _nt_s
315
+ s6 << r9
316
+ if r9
317
+ r10 = _nt_plasma
318
+ s6 << r10
319
+ end
320
+ end
321
+ end
322
+ if s6.last
323
+ r6 = (SyntaxNode).new(input, i6...index, s6)
324
+ r6.extend(Seq0)
325
+ else
326
+ self.index = i6
327
+ r6 = nil
328
+ end
329
+ if r6
330
+ s5 << r6
331
+ else
332
+ break
333
+ end
334
+ end
335
+ r5 = SyntaxNode.new(input, i5...index, s5)
336
+ s0 << r5
337
+ if r5
338
+ r11 = _nt_x
339
+ s0 << r11
340
+ if r11
341
+ if input.index(')', index) == index
342
+ r12 = (SyntaxNode).new(input, index...(index + 1))
343
+ @index += 1
344
+ else
345
+ terminal_parse_failure(')')
346
+ r12 = nil
347
+ end
348
+ s0 << r12
349
+ end
350
+ end
351
+ end
352
+ end
353
+ end
354
+ if s0.last
355
+ r0 = (SeqNode).new(input, i0...index, s0)
356
+ r0.extend(Seq1)
357
+ else
358
+ self.index = i0
359
+ r0 = nil
360
+ end
361
+
362
+ node_cache[:seq][start_index] = r0
363
+
364
+ return r0
365
+ end
366
+
367
+ module Quote0
368
+ def plasma
369
+ elements[1]
370
+ end
371
+ end
372
+
373
+ def _nt_quote
374
+ start_index = index
375
+ if node_cache[:quote].has_key?(index)
376
+ cached = node_cache[:quote][index]
377
+ @index = cached.interval.end if cached
378
+ return cached
379
+ end
380
+
381
+ i0, s0 = index, []
382
+ if input.index("'", index) == index
383
+ r1 = (SyntaxNode).new(input, index...(index + 1))
384
+ @index += 1
385
+ else
386
+ terminal_parse_failure("'")
387
+ r1 = nil
388
+ end
389
+ s0 << r1
390
+ if r1
391
+ r2 = _nt_plasma
392
+ s0 << r2
393
+ end
394
+ if s0.last
395
+ r0 = (QuoteNode).new(input, i0...index, s0)
396
+ r0.extend(Quote0)
397
+ else
398
+ self.index = i0
399
+ r0 = nil
400
+ end
401
+
402
+ node_cache[:quote][start_index] = r0
403
+
404
+ return r0
405
+ end
406
+
407
+ module Defun0
408
+ def x
409
+ elements[1]
410
+ end
411
+
412
+ def s
413
+ elements[3]
414
+ end
415
+
416
+ def params
417
+ elements[4]
418
+ end
419
+
420
+ def s
421
+ elements[5]
422
+ end
423
+
424
+ def plasma
425
+ elements[6]
426
+ end
427
+
428
+ def x
429
+ elements[7]
430
+ end
431
+
432
+ end
433
+
434
+ def _nt_defun
435
+ start_index = index
436
+ if node_cache[:defun].has_key?(index)
437
+ cached = node_cache[:defun][index]
438
+ @index = cached.interval.end if cached
439
+ return cached
440
+ end
441
+
442
+ i0, s0 = index, []
443
+ if input.index('(', index) == index
444
+ r1 = (SyntaxNode).new(input, index...(index + 1))
445
+ @index += 1
446
+ else
447
+ terminal_parse_failure('(')
448
+ r1 = nil
449
+ end
450
+ s0 << r1
451
+ if r1
452
+ r2 = _nt_x
453
+ s0 << r2
454
+ if r2
455
+ if input.index('defun', index) == index
456
+ r3 = (SyntaxNode).new(input, index...(index + 5))
457
+ @index += 5
458
+ else
459
+ terminal_parse_failure('defun')
460
+ r3 = nil
461
+ end
462
+ s0 << r3
463
+ if r3
464
+ r4 = _nt_s
465
+ s0 << r4
466
+ if r4
467
+ r5 = _nt_params
468
+ s0 << r5
469
+ if r5
470
+ r6 = _nt_s
471
+ s0 << r6
472
+ if r6
473
+ r7 = _nt_plasma
474
+ s0 << r7
475
+ if r7
476
+ r8 = _nt_x
477
+ s0 << r8
478
+ if r8
479
+ if input.index(')', index) == index
480
+ r9 = (SyntaxNode).new(input, index...(index + 1))
481
+ @index += 1
482
+ else
483
+ terminal_parse_failure(')')
484
+ r9 = nil
485
+ end
486
+ s0 << r9
487
+ end
488
+ end
489
+ end
490
+ end
491
+ end
492
+ end
493
+ end
494
+ end
495
+ if s0.last
496
+ r0 = (DefunNode).new(input, i0...index, s0)
497
+ r0.extend(Defun0)
498
+ else
499
+ self.index = i0
500
+ r0 = nil
501
+ end
502
+
503
+ node_cache[:defun][start_index] = r0
504
+
505
+ return r0
506
+ end
507
+
508
+ module Def0
509
+ def x
510
+ elements[1]
511
+ end
512
+
513
+ def s
514
+ elements[3]
515
+ end
516
+
517
+ def sym
518
+ elements[4]
519
+ end
520
+
521
+ def s
522
+ elements[5]
523
+ end
524
+
525
+ def plasma
526
+ elements[6]
527
+ end
528
+
529
+ def x
530
+ elements[7]
531
+ end
532
+
533
+ end
534
+
535
+ def _nt_def
536
+ start_index = index
537
+ if node_cache[:def].has_key?(index)
538
+ cached = node_cache[:def][index]
539
+ @index = cached.interval.end if cached
540
+ return cached
541
+ end
542
+
543
+ i0, s0 = index, []
544
+ if input.index('(', index) == index
545
+ r1 = (SyntaxNode).new(input, index...(index + 1))
546
+ @index += 1
547
+ else
548
+ terminal_parse_failure('(')
549
+ r1 = nil
550
+ end
551
+ s0 << r1
552
+ if r1
553
+ r2 = _nt_x
554
+ s0 << r2
555
+ if r2
556
+ if input.index('def', index) == index
557
+ r3 = (SyntaxNode).new(input, index...(index + 3))
558
+ @index += 3
559
+ else
560
+ terminal_parse_failure('def')
561
+ r3 = nil
562
+ end
563
+ s0 << r3
564
+ if r3
565
+ r4 = _nt_s
566
+ s0 << r4
567
+ if r4
568
+ r5 = _nt_sym
569
+ s0 << r5
570
+ if r5
571
+ r6 = _nt_s
572
+ s0 << r6
573
+ if r6
574
+ r7 = _nt_plasma
575
+ s0 << r7
576
+ if r7
577
+ r8 = _nt_x
578
+ s0 << r8
579
+ if r8
580
+ if input.index(')', index) == index
581
+ r9 = (SyntaxNode).new(input, index...(index + 1))
582
+ @index += 1
583
+ else
584
+ terminal_parse_failure(')')
585
+ r9 = nil
586
+ end
587
+ s0 << r9
588
+ end
589
+ end
590
+ end
591
+ end
592
+ end
593
+ end
594
+ end
595
+ end
596
+ if s0.last
597
+ r0 = (DefNode).new(input, i0...index, s0)
598
+ r0.extend(Def0)
599
+ else
600
+ self.index = i0
601
+ r0 = nil
602
+ end
603
+
604
+ node_cache[:def][start_index] = r0
605
+
606
+ return r0
607
+ end
608
+
609
+ module Fun0
610
+ def x
611
+ elements[1]
612
+ end
613
+
614
+ def s
615
+ elements[3]
616
+ end
617
+
618
+ def params
619
+ elements[4]
620
+ end
621
+
622
+ def s
623
+ elements[5]
624
+ end
625
+
626
+ def plasma
627
+ elements[6]
628
+ end
629
+
630
+ def x
631
+ elements[7]
632
+ end
633
+
634
+ end
635
+
636
+ def _nt_fun
637
+ start_index = index
638
+ if node_cache[:fun].has_key?(index)
639
+ cached = node_cache[:fun][index]
640
+ @index = cached.interval.end if cached
641
+ return cached
642
+ end
643
+
644
+ i0, s0 = index, []
645
+ if input.index('(', index) == index
646
+ r1 = (SyntaxNode).new(input, index...(index + 1))
647
+ @index += 1
648
+ else
649
+ terminal_parse_failure('(')
650
+ r1 = nil
651
+ end
652
+ s0 << r1
653
+ if r1
654
+ r2 = _nt_x
655
+ s0 << r2
656
+ if r2
657
+ if input.index('fun', index) == index
658
+ r3 = (SyntaxNode).new(input, index...(index + 3))
659
+ @index += 3
660
+ else
661
+ terminal_parse_failure('fun')
662
+ r3 = nil
663
+ end
664
+ s0 << r3
665
+ if r3
666
+ r4 = _nt_s
667
+ s0 << r4
668
+ if r4
669
+ r5 = _nt_params
670
+ s0 << r5
671
+ if r5
672
+ r6 = _nt_s
673
+ s0 << r6
674
+ if r6
675
+ r7 = _nt_plasma
676
+ s0 << r7
677
+ if r7
678
+ r8 = _nt_x
679
+ s0 << r8
680
+ if r8
681
+ if input.index(')', index) == index
682
+ r9 = (SyntaxNode).new(input, index...(index + 1))
683
+ @index += 1
684
+ else
685
+ terminal_parse_failure(')')
686
+ r9 = nil
687
+ end
688
+ s0 << r9
689
+ end
690
+ end
691
+ end
692
+ end
693
+ end
694
+ end
695
+ end
696
+ end
697
+ if s0.last
698
+ r0 = (FunNode).new(input, i0...index, s0)
699
+ r0.extend(Fun0)
700
+ else
701
+ self.index = i0
702
+ r0 = nil
703
+ end
704
+
705
+ node_cache[:fun][start_index] = r0
706
+
707
+ return r0
708
+ end
709
+
710
+ module Params0
711
+ def s
712
+ elements[0]
713
+ end
714
+
715
+ def sym
716
+ elements[1]
717
+ end
718
+ end
719
+
720
+ module Params1
721
+ def x
722
+ elements[1]
723
+ end
724
+
725
+ def first
726
+ elements[2]
727
+ end
728
+
729
+ def rest
730
+ elements[3]
731
+ end
732
+
733
+ def x
734
+ elements[4]
735
+ end
736
+
737
+ end
738
+
739
+ def _nt_params
740
+ start_index = index
741
+ if node_cache[:params].has_key?(index)
742
+ cached = node_cache[:params][index]
743
+ @index = cached.interval.end if cached
744
+ return cached
745
+ end
746
+
747
+ i0, s0 = index, []
748
+ if input.index('(', index) == index
749
+ r1 = (SyntaxNode).new(input, index...(index + 1))
750
+ @index += 1
751
+ else
752
+ terminal_parse_failure('(')
753
+ r1 = nil
754
+ end
755
+ s0 << r1
756
+ if r1
757
+ r2 = _nt_x
758
+ s0 << r2
759
+ if r2
760
+ r3 = _nt_sym
761
+ s0 << r3
762
+ if r3
763
+ s4, i4 = [], index
764
+ loop do
765
+ i5, s5 = index, []
766
+ r6 = _nt_s
767
+ s5 << r6
768
+ if r6
769
+ r7 = _nt_sym
770
+ s5 << r7
771
+ end
772
+ if s5.last
773
+ r5 = (SyntaxNode).new(input, i5...index, s5)
774
+ r5.extend(Params0)
775
+ else
776
+ self.index = i5
777
+ r5 = nil
778
+ end
779
+ if r5
780
+ s4 << r5
781
+ else
782
+ break
783
+ end
784
+ end
785
+ r4 = SyntaxNode.new(input, i4...index, s4)
786
+ s0 << r4
787
+ if r4
788
+ r8 = _nt_x
789
+ s0 << r8
790
+ if r8
791
+ if input.index(')', index) == index
792
+ r9 = (SyntaxNode).new(input, index...(index + 1))
793
+ @index += 1
794
+ else
795
+ terminal_parse_failure(')')
796
+ r9 = nil
797
+ end
798
+ s0 << r9
799
+ end
800
+ end
801
+ end
802
+ end
803
+ end
804
+ if s0.last
805
+ r0 = (ParamsNode).new(input, i0...index, s0)
806
+ r0.extend(Params1)
807
+ else
808
+ self.index = i0
809
+ r0 = nil
810
+ end
811
+
812
+ node_cache[:params][start_index] = r0
813
+
814
+ return r0
815
+ end
816
+
817
+ module If0
818
+ def s
819
+ elements[0]
820
+ end
821
+
822
+ def s
823
+ elements[2]
824
+ end
825
+
826
+ def other
827
+ elements[3]
828
+ end
829
+ end
830
+
831
+ module If1
832
+ def x
833
+ elements[1]
834
+ end
835
+
836
+ def s
837
+ elements[3]
838
+ end
839
+
840
+ def pred
841
+ elements[4]
842
+ end
843
+
844
+ def s
845
+ elements[5]
846
+ end
847
+
848
+ def s
849
+ elements[7]
850
+ end
851
+
852
+ def body
853
+ elements[8]
854
+ end
855
+
856
+ def maybe
857
+ elements[9]
858
+ end
859
+
860
+ def x
861
+ elements[10]
862
+ end
863
+
864
+ end
865
+
866
+ def _nt_if
867
+ start_index = index
868
+ if node_cache[:if].has_key?(index)
869
+ cached = node_cache[:if][index]
870
+ @index = cached.interval.end if cached
871
+ return cached
872
+ end
873
+
874
+ i0, s0 = index, []
875
+ if input.index('(', index) == index
876
+ r1 = (SyntaxNode).new(input, index...(index + 1))
877
+ @index += 1
878
+ else
879
+ terminal_parse_failure('(')
880
+ r1 = nil
881
+ end
882
+ s0 << r1
883
+ if r1
884
+ r2 = _nt_x
885
+ s0 << r2
886
+ if r2
887
+ if input.index('if', index) == index
888
+ r3 = (SyntaxNode).new(input, index...(index + 2))
889
+ @index += 2
890
+ else
891
+ terminal_parse_failure('if')
892
+ r3 = nil
893
+ end
894
+ s0 << r3
895
+ if r3
896
+ r4 = _nt_s
897
+ s0 << r4
898
+ if r4
899
+ r5 = _nt_plasma
900
+ s0 << r5
901
+ if r5
902
+ r6 = _nt_s
903
+ s0 << r6
904
+ if r6
905
+ if input.index('then', index) == index
906
+ r7 = (SyntaxNode).new(input, index...(index + 4))
907
+ @index += 4
908
+ else
909
+ terminal_parse_failure('then')
910
+ r7 = nil
911
+ end
912
+ s0 << r7
913
+ if r7
914
+ r8 = _nt_s
915
+ s0 << r8
916
+ if r8
917
+ r9 = _nt_plasma
918
+ s0 << r9
919
+ if r9
920
+ i11, s11 = index, []
921
+ r12 = _nt_s
922
+ s11 << r12
923
+ if r12
924
+ if input.index('else', index) == index
925
+ r13 = (SyntaxNode).new(input, index...(index + 4))
926
+ @index += 4
927
+ else
928
+ terminal_parse_failure('else')
929
+ r13 = nil
930
+ end
931
+ s11 << r13
932
+ if r13
933
+ r14 = _nt_s
934
+ s11 << r14
935
+ if r14
936
+ r15 = _nt_plasma
937
+ s11 << r15
938
+ end
939
+ end
940
+ end
941
+ if s11.last
942
+ r11 = (SyntaxNode).new(input, i11...index, s11)
943
+ r11.extend(If0)
944
+ else
945
+ self.index = i11
946
+ r11 = nil
947
+ end
948
+ if r11
949
+ r10 = r11
950
+ else
951
+ r10 = SyntaxNode.new(input, index...index)
952
+ end
953
+ s0 << r10
954
+ if r10
955
+ r16 = _nt_x
956
+ s0 << r16
957
+ if r16
958
+ if input.index(')', index) == index
959
+ r17 = (SyntaxNode).new(input, index...(index + 1))
960
+ @index += 1
961
+ else
962
+ terminal_parse_failure(')')
963
+ r17 = nil
964
+ end
965
+ s0 << r17
966
+ end
967
+ end
968
+ end
969
+ end
970
+ end
971
+ end
972
+ end
973
+ end
974
+ end
975
+ end
976
+ end
977
+ if s0.last
978
+ r0 = (IfNode).new(input, i0...index, s0)
979
+ r0.extend(If1)
980
+ else
981
+ self.index = i0
982
+ r0 = nil
983
+ end
984
+
985
+ node_cache[:if][start_index] = r0
986
+
987
+ return r0
988
+ end
989
+
990
+ module Apply0
991
+ def s
992
+ elements[0]
993
+ end
994
+
995
+ def plasma
996
+ elements[1]
997
+ end
998
+ end
999
+
1000
+ module Apply1
1001
+ def x
1002
+ elements[1]
1003
+ end
1004
+
1005
+ def applied
1006
+ elements[2]
1007
+ end
1008
+
1009
+ def s
1010
+ elements[3]
1011
+ end
1012
+
1013
+ def first
1014
+ elements[4]
1015
+ end
1016
+
1017
+ def rest
1018
+ elements[5]
1019
+ end
1020
+
1021
+ def x
1022
+ elements[6]
1023
+ end
1024
+
1025
+ end
1026
+
1027
+ def _nt_apply
1028
+ start_index = index
1029
+ if node_cache[:apply].has_key?(index)
1030
+ cached = node_cache[:apply][index]
1031
+ @index = cached.interval.end if cached
1032
+ return cached
1033
+ end
1034
+
1035
+ i0, s0 = index, []
1036
+ if input.index('(', index) == index
1037
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1038
+ @index += 1
1039
+ else
1040
+ terminal_parse_failure('(')
1041
+ r1 = nil
1042
+ end
1043
+ s0 << r1
1044
+ if r1
1045
+ r2 = _nt_x
1046
+ s0 << r2
1047
+ if r2
1048
+ i3 = index
1049
+ r4 = _nt_fun
1050
+ if r4
1051
+ r3 = r4
1052
+ else
1053
+ r5 = _nt_sym
1054
+ if r5
1055
+ r3 = r5
1056
+ else
1057
+ self.index = i3
1058
+ r3 = nil
1059
+ end
1060
+ end
1061
+ s0 << r3
1062
+ if r3
1063
+ r6 = _nt_s
1064
+ s0 << r6
1065
+ if r6
1066
+ r7 = _nt_plasma
1067
+ s0 << r7
1068
+ if r7
1069
+ s8, i8 = [], index
1070
+ loop do
1071
+ i9, s9 = index, []
1072
+ r10 = _nt_s
1073
+ s9 << r10
1074
+ if r10
1075
+ r11 = _nt_plasma
1076
+ s9 << r11
1077
+ end
1078
+ if s9.last
1079
+ r9 = (SyntaxNode).new(input, i9...index, s9)
1080
+ r9.extend(Apply0)
1081
+ else
1082
+ self.index = i9
1083
+ r9 = nil
1084
+ end
1085
+ if r9
1086
+ s8 << r9
1087
+ else
1088
+ break
1089
+ end
1090
+ end
1091
+ r8 = SyntaxNode.new(input, i8...index, s8)
1092
+ s0 << r8
1093
+ if r8
1094
+ r12 = _nt_x
1095
+ s0 << r12
1096
+ if r12
1097
+ if input.index(')', index) == index
1098
+ r13 = (SyntaxNode).new(input, index...(index + 1))
1099
+ @index += 1
1100
+ else
1101
+ terminal_parse_failure(')')
1102
+ r13 = nil
1103
+ end
1104
+ s0 << r13
1105
+ end
1106
+ end
1107
+ end
1108
+ end
1109
+ end
1110
+ end
1111
+ end
1112
+ if s0.last
1113
+ r0 = (ApplyNode).new(input, i0...index, s0)
1114
+ r0.extend(Apply1)
1115
+ else
1116
+ self.index = i0
1117
+ r0 = nil
1118
+ end
1119
+
1120
+ node_cache[:apply][start_index] = r0
1121
+
1122
+ return r0
1123
+ end
1124
+
1125
+ def _nt_bool
1126
+ start_index = index
1127
+ if node_cache[:bool].has_key?(index)
1128
+ cached = node_cache[:bool][index]
1129
+ @index = cached.interval.end if cached
1130
+ return cached
1131
+ end
1132
+
1133
+ i0 = index
1134
+ if input.index('true', index) == index
1135
+ r1 = (TrueNode).new(input, index...(index + 4))
1136
+ @index += 4
1137
+ else
1138
+ terminal_parse_failure('true')
1139
+ r1 = nil
1140
+ end
1141
+ if r1
1142
+ r0 = r1
1143
+ else
1144
+ if input.index('false', index) == index
1145
+ r2 = (FalseNode).new(input, index...(index + 5))
1146
+ @index += 5
1147
+ else
1148
+ terminal_parse_failure('false')
1149
+ r2 = nil
1150
+ end
1151
+ if r2
1152
+ r0 = r2
1153
+ else
1154
+ self.index = i0
1155
+ r0 = nil
1156
+ end
1157
+ end
1158
+
1159
+ node_cache[:bool][start_index] = r0
1160
+
1161
+ return r0
1162
+ end
1163
+
1164
+ def _nt_sym
1165
+ start_index = index
1166
+ if node_cache[:sym].has_key?(index)
1167
+ cached = node_cache[:sym][index]
1168
+ @index = cached.interval.end if cached
1169
+ return cached
1170
+ end
1171
+
1172
+ s0, i0 = [], index
1173
+ loop do
1174
+ if input.index(Regexp.new('[a-z+!/\\^&@?*%<>=_-]'), index) == index
1175
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1176
+ @index += 1
1177
+ else
1178
+ r1 = nil
1179
+ end
1180
+ if r1
1181
+ s0 << r1
1182
+ else
1183
+ break
1184
+ end
1185
+ end
1186
+ if s0.empty?
1187
+ self.index = i0
1188
+ r0 = nil
1189
+ else
1190
+ r0 = SymNode.new(input, i0...index, s0)
1191
+ end
1192
+
1193
+ node_cache[:sym][start_index] = r0
1194
+
1195
+ return r0
1196
+ end
1197
+
1198
+ module Hash0
1199
+ def s
1200
+ elements[0]
1201
+ end
1202
+
1203
+ def relation
1204
+ elements[1]
1205
+ end
1206
+ end
1207
+
1208
+ module Hash1
1209
+ def x
1210
+ elements[1]
1211
+ end
1212
+
1213
+ def first
1214
+ elements[2]
1215
+ end
1216
+
1217
+ def rest
1218
+ elements[3]
1219
+ end
1220
+
1221
+ def x
1222
+ elements[4]
1223
+ end
1224
+
1225
+ end
1226
+
1227
+ def _nt_hash
1228
+ start_index = index
1229
+ if node_cache[:hash].has_key?(index)
1230
+ cached = node_cache[:hash][index]
1231
+ @index = cached.interval.end if cached
1232
+ return cached
1233
+ end
1234
+
1235
+ i0, s0 = index, []
1236
+ if input.index('{', index) == index
1237
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1238
+ @index += 1
1239
+ else
1240
+ terminal_parse_failure('{')
1241
+ r1 = nil
1242
+ end
1243
+ s0 << r1
1244
+ if r1
1245
+ r2 = _nt_x
1246
+ s0 << r2
1247
+ if r2
1248
+ r4 = _nt_relation
1249
+ if r4
1250
+ r3 = r4
1251
+ else
1252
+ r3 = SyntaxNode.new(input, index...index)
1253
+ end
1254
+ s0 << r3
1255
+ if r3
1256
+ s5, i5 = [], index
1257
+ loop do
1258
+ i6, s6 = index, []
1259
+ r7 = _nt_s
1260
+ s6 << r7
1261
+ if r7
1262
+ r8 = _nt_relation
1263
+ s6 << r8
1264
+ end
1265
+ if s6.last
1266
+ r6 = (SyntaxNode).new(input, i6...index, s6)
1267
+ r6.extend(Hash0)
1268
+ else
1269
+ self.index = i6
1270
+ r6 = nil
1271
+ end
1272
+ if r6
1273
+ s5 << r6
1274
+ else
1275
+ break
1276
+ end
1277
+ end
1278
+ r5 = SyntaxNode.new(input, i5...index, s5)
1279
+ s0 << r5
1280
+ if r5
1281
+ r9 = _nt_x
1282
+ s0 << r9
1283
+ if r9
1284
+ if input.index('}', index) == index
1285
+ r10 = (SyntaxNode).new(input, index...(index + 1))
1286
+ @index += 1
1287
+ else
1288
+ terminal_parse_failure('}')
1289
+ r10 = nil
1290
+ end
1291
+ s0 << r10
1292
+ end
1293
+ end
1294
+ end
1295
+ end
1296
+ end
1297
+ if s0.last
1298
+ r0 = (HashNode).new(input, i0...index, s0)
1299
+ r0.extend(Hash1)
1300
+ else
1301
+ self.index = i0
1302
+ r0 = nil
1303
+ end
1304
+
1305
+ node_cache[:hash][start_index] = r0
1306
+
1307
+ return r0
1308
+ end
1309
+
1310
+ module Relation0
1311
+ def sym
1312
+ elements[0]
1313
+ end
1314
+
1315
+ def x
1316
+ elements[1]
1317
+ end
1318
+
1319
+ def x
1320
+ elements[3]
1321
+ end
1322
+
1323
+ def plasma
1324
+ elements[4]
1325
+ end
1326
+ end
1327
+
1328
+ def _nt_relation
1329
+ start_index = index
1330
+ if node_cache[:relation].has_key?(index)
1331
+ cached = node_cache[:relation][index]
1332
+ @index = cached.interval.end if cached
1333
+ return cached
1334
+ end
1335
+
1336
+ i0, s0 = index, []
1337
+ r1 = _nt_sym
1338
+ s0 << r1
1339
+ if r1
1340
+ r2 = _nt_x
1341
+ s0 << r2
1342
+ if r2
1343
+ if input.index(':', index) == index
1344
+ r3 = (SyntaxNode).new(input, index...(index + 1))
1345
+ @index += 1
1346
+ else
1347
+ terminal_parse_failure(':')
1348
+ r3 = nil
1349
+ end
1350
+ s0 << r3
1351
+ if r3
1352
+ r4 = _nt_x
1353
+ s0 << r4
1354
+ if r4
1355
+ r5 = _nt_plasma
1356
+ s0 << r5
1357
+ end
1358
+ end
1359
+ end
1360
+ end
1361
+ if s0.last
1362
+ r0 = (RelationNode).new(input, i0...index, s0)
1363
+ r0.extend(Relation0)
1364
+ else
1365
+ self.index = i0
1366
+ r0 = nil
1367
+ end
1368
+
1369
+ node_cache[:relation][start_index] = r0
1370
+
1371
+ return r0
1372
+ end
1373
+
1374
+ module List0
1375
+ def s
1376
+ elements[0]
1377
+ end
1378
+
1379
+ def plasma
1380
+ elements[1]
1381
+ end
1382
+ end
1383
+
1384
+ module List1
1385
+ def x
1386
+ elements[1]
1387
+ end
1388
+
1389
+ def first
1390
+ elements[2]
1391
+ end
1392
+
1393
+ def rest
1394
+ elements[3]
1395
+ end
1396
+
1397
+ def x
1398
+ elements[4]
1399
+ end
1400
+
1401
+ end
1402
+
1403
+ def _nt_list
1404
+ start_index = index
1405
+ if node_cache[:list].has_key?(index)
1406
+ cached = node_cache[:list][index]
1407
+ @index = cached.interval.end if cached
1408
+ return cached
1409
+ end
1410
+
1411
+ i0, s0 = index, []
1412
+ if input.index('[', index) == index
1413
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1414
+ @index += 1
1415
+ else
1416
+ terminal_parse_failure('[')
1417
+ r1 = nil
1418
+ end
1419
+ s0 << r1
1420
+ if r1
1421
+ r2 = _nt_x
1422
+ s0 << r2
1423
+ if r2
1424
+ r4 = _nt_plasma
1425
+ if r4
1426
+ r3 = r4
1427
+ else
1428
+ r3 = SyntaxNode.new(input, index...index)
1429
+ end
1430
+ s0 << r3
1431
+ if r3
1432
+ s5, i5 = [], index
1433
+ loop do
1434
+ i6, s6 = index, []
1435
+ r7 = _nt_s
1436
+ s6 << r7
1437
+ if r7
1438
+ r8 = _nt_plasma
1439
+ s6 << r8
1440
+ end
1441
+ if s6.last
1442
+ r6 = (SyntaxNode).new(input, i6...index, s6)
1443
+ r6.extend(List0)
1444
+ else
1445
+ self.index = i6
1446
+ r6 = nil
1447
+ end
1448
+ if r6
1449
+ s5 << r6
1450
+ else
1451
+ break
1452
+ end
1453
+ end
1454
+ r5 = SyntaxNode.new(input, i5...index, s5)
1455
+ s0 << r5
1456
+ if r5
1457
+ r9 = _nt_x
1458
+ s0 << r9
1459
+ if r9
1460
+ if input.index(']', index) == index
1461
+ r10 = (SyntaxNode).new(input, index...(index + 1))
1462
+ @index += 1
1463
+ else
1464
+ terminal_parse_failure(']')
1465
+ r10 = nil
1466
+ end
1467
+ s0 << r10
1468
+ end
1469
+ end
1470
+ end
1471
+ end
1472
+ end
1473
+ if s0.last
1474
+ r0 = (ListNode).new(input, i0...index, s0)
1475
+ r0.extend(List1)
1476
+ else
1477
+ self.index = i0
1478
+ r0 = nil
1479
+ end
1480
+
1481
+ node_cache[:list][start_index] = r0
1482
+
1483
+ return r0
1484
+ end
1485
+
1486
+ module Date0
1487
+ def s
1488
+ elements[0]
1489
+ end
1490
+
1491
+ def time
1492
+ elements[1]
1493
+ end
1494
+ end
1495
+
1496
+ module Date1
1497
+ def year
1498
+ elements[0]
1499
+ end
1500
+
1501
+ def month
1502
+ elements[2]
1503
+ end
1504
+
1505
+ def day
1506
+ elements[4]
1507
+ end
1508
+
1509
+ end
1510
+
1511
+ def _nt_date
1512
+ start_index = index
1513
+ if node_cache[:date].has_key?(index)
1514
+ cached = node_cache[:date][index]
1515
+ @index = cached.interval.end if cached
1516
+ return cached
1517
+ end
1518
+
1519
+ i0, s0 = index, []
1520
+ r1 = _nt_year
1521
+ s0 << r1
1522
+ if r1
1523
+ if input.index(Regexp.new('[-]'), index) == index
1524
+ r2 = (SyntaxNode).new(input, index...(index + 1))
1525
+ @index += 1
1526
+ else
1527
+ r2 = nil
1528
+ end
1529
+ s0 << r2
1530
+ if r2
1531
+ r3 = _nt_dual
1532
+ s0 << r3
1533
+ if r3
1534
+ if input.index(Regexp.new('[-]'), index) == index
1535
+ r4 = (SyntaxNode).new(input, index...(index + 1))
1536
+ @index += 1
1537
+ else
1538
+ r4 = nil
1539
+ end
1540
+ s0 << r4
1541
+ if r4
1542
+ r5 = _nt_dual
1543
+ s0 << r5
1544
+ if r5
1545
+ i7, s7 = index, []
1546
+ r8 = _nt_s
1547
+ s7 << r8
1548
+ if r8
1549
+ r9 = _nt_time
1550
+ s7 << r9
1551
+ end
1552
+ if s7.last
1553
+ r7 = (SyntaxNode).new(input, i7...index, s7)
1554
+ r7.extend(Date0)
1555
+ else
1556
+ self.index = i7
1557
+ r7 = nil
1558
+ end
1559
+ if r7
1560
+ r6 = r7
1561
+ else
1562
+ r6 = SyntaxNode.new(input, index...index)
1563
+ end
1564
+ s0 << r6
1565
+ end
1566
+ end
1567
+ end
1568
+ end
1569
+ end
1570
+ if s0.last
1571
+ r0 = (DateNode).new(input, i0...index, s0)
1572
+ r0.extend(Date1)
1573
+ else
1574
+ self.index = i0
1575
+ r0 = nil
1576
+ end
1577
+
1578
+ node_cache[:date][start_index] = r0
1579
+
1580
+ return r0
1581
+ end
1582
+
1583
+ module Year0
1584
+ end
1585
+
1586
+ def _nt_year
1587
+ start_index = index
1588
+ if node_cache[:year].has_key?(index)
1589
+ cached = node_cache[:year][index]
1590
+ @index = cached.interval.end if cached
1591
+ return cached
1592
+ end
1593
+
1594
+ i0, s0 = index, []
1595
+ if input.index(Regexp.new('[0-9]'), index) == index
1596
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1597
+ @index += 1
1598
+ else
1599
+ r1 = nil
1600
+ end
1601
+ s0 << r1
1602
+ if r1
1603
+ if input.index(Regexp.new('[0-9]'), index) == index
1604
+ r2 = (SyntaxNode).new(input, index...(index + 1))
1605
+ @index += 1
1606
+ else
1607
+ r2 = nil
1608
+ end
1609
+ s0 << r2
1610
+ if r2
1611
+ if input.index(Regexp.new('[0-9]'), index) == index
1612
+ r3 = (SyntaxNode).new(input, index...(index + 1))
1613
+ @index += 1
1614
+ else
1615
+ r3 = nil
1616
+ end
1617
+ s0 << r3
1618
+ if r3
1619
+ if input.index(Regexp.new('[0-9]'), index) == index
1620
+ r4 = (SyntaxNode).new(input, index...(index + 1))
1621
+ @index += 1
1622
+ else
1623
+ r4 = nil
1624
+ end
1625
+ s0 << r4
1626
+ end
1627
+ end
1628
+ end
1629
+ if s0.last
1630
+ r0 = (SyntaxNode).new(input, i0...index, s0)
1631
+ r0.extend(Year0)
1632
+ else
1633
+ self.index = i0
1634
+ r0 = nil
1635
+ end
1636
+
1637
+ node_cache[:year][start_index] = r0
1638
+
1639
+ return r0
1640
+ end
1641
+
1642
+ module Dual0
1643
+ end
1644
+
1645
+ def _nt_dual
1646
+ start_index = index
1647
+ if node_cache[:dual].has_key?(index)
1648
+ cached = node_cache[:dual][index]
1649
+ @index = cached.interval.end if cached
1650
+ return cached
1651
+ end
1652
+
1653
+ i0, s0 = index, []
1654
+ if input.index(Regexp.new('[0-9]'), index) == index
1655
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1656
+ @index += 1
1657
+ else
1658
+ r1 = nil
1659
+ end
1660
+ s0 << r1
1661
+ if r1
1662
+ if input.index(Regexp.new('[0-9]'), index) == index
1663
+ r2 = (SyntaxNode).new(input, index...(index + 1))
1664
+ @index += 1
1665
+ else
1666
+ r2 = nil
1667
+ end
1668
+ s0 << r2
1669
+ end
1670
+ if s0.last
1671
+ r0 = (SyntaxNode).new(input, i0...index, s0)
1672
+ r0.extend(Dual0)
1673
+ else
1674
+ self.index = i0
1675
+ r0 = nil
1676
+ end
1677
+
1678
+ node_cache[:dual][start_index] = r0
1679
+
1680
+ return r0
1681
+ end
1682
+
1683
+ module Time0
1684
+ def hours
1685
+ elements[0]
1686
+ end
1687
+
1688
+ def minutes
1689
+ elements[2]
1690
+ end
1691
+
1692
+ def seconds
1693
+ elements[4]
1694
+ end
1695
+ end
1696
+
1697
+ def _nt_time
1698
+ start_index = index
1699
+ if node_cache[:time].has_key?(index)
1700
+ cached = node_cache[:time][index]
1701
+ @index = cached.interval.end if cached
1702
+ return cached
1703
+ end
1704
+
1705
+ i0, s0 = index, []
1706
+ r1 = _nt_dual
1707
+ s0 << r1
1708
+ if r1
1709
+ if input.index(':', index) == index
1710
+ r2 = (SyntaxNode).new(input, index...(index + 1))
1711
+ @index += 1
1712
+ else
1713
+ terminal_parse_failure(':')
1714
+ r2 = nil
1715
+ end
1716
+ s0 << r2
1717
+ if r2
1718
+ r3 = _nt_dual
1719
+ s0 << r3
1720
+ if r3
1721
+ if input.index(':', index) == index
1722
+ r4 = (SyntaxNode).new(input, index...(index + 1))
1723
+ @index += 1
1724
+ else
1725
+ terminal_parse_failure(':')
1726
+ r4 = nil
1727
+ end
1728
+ s0 << r4
1729
+ if r4
1730
+ r5 = _nt_dual
1731
+ s0 << r5
1732
+ end
1733
+ end
1734
+ end
1735
+ end
1736
+ if s0.last
1737
+ r0 = (TimeNode).new(input, i0...index, s0)
1738
+ r0.extend(Time0)
1739
+ else
1740
+ self.index = i0
1741
+ r0 = nil
1742
+ end
1743
+
1744
+ node_cache[:time][start_index] = r0
1745
+
1746
+ return r0
1747
+ end
1748
+
1749
+ module Str0
1750
+ def first
1751
+ elements[1]
1752
+ end
1753
+
1754
+ def rest
1755
+ elements[2]
1756
+ end
1757
+
1758
+ end
1759
+
1760
+ def _nt_str
1761
+ start_index = index
1762
+ if node_cache[:str].has_key?(index)
1763
+ cached = node_cache[:str][index]
1764
+ @index = cached.interval.end if cached
1765
+ return cached
1766
+ end
1767
+
1768
+ i0, s0 = index, []
1769
+ if input.index('"', index) == index
1770
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1771
+ @index += 1
1772
+ else
1773
+ terminal_parse_failure('"')
1774
+ r1 = nil
1775
+ end
1776
+ s0 << r1
1777
+ if r1
1778
+ if input.index(Regexp.new('[^"]'), index) == index
1779
+ r3 = (SyntaxNode).new(input, index...(index + 1))
1780
+ @index += 1
1781
+ else
1782
+ r3 = nil
1783
+ end
1784
+ if r3
1785
+ r2 = r3
1786
+ else
1787
+ r2 = SyntaxNode.new(input, index...index)
1788
+ end
1789
+ s0 << r2
1790
+ if r2
1791
+ s4, i4 = [], index
1792
+ loop do
1793
+ if input.index(Regexp.new('[^"]'), index) == index
1794
+ r5 = (SyntaxNode).new(input, index...(index + 1))
1795
+ @index += 1
1796
+ else
1797
+ r5 = nil
1798
+ end
1799
+ if r5
1800
+ s4 << r5
1801
+ else
1802
+ break
1803
+ end
1804
+ end
1805
+ r4 = SyntaxNode.new(input, i4...index, s4)
1806
+ s0 << r4
1807
+ if r4
1808
+ if input.index('"', index) == index
1809
+ r6 = (SyntaxNode).new(input, index...(index + 1))
1810
+ @index += 1
1811
+ else
1812
+ terminal_parse_failure('"')
1813
+ r6 = nil
1814
+ end
1815
+ s0 << r6
1816
+ end
1817
+ end
1818
+ end
1819
+ if s0.last
1820
+ r0 = (StrNode).new(input, i0...index, s0)
1821
+ r0.extend(Str0)
1822
+ else
1823
+ self.index = i0
1824
+ r0 = nil
1825
+ end
1826
+
1827
+ node_cache[:str][start_index] = r0
1828
+
1829
+ return r0
1830
+ end
1831
+
1832
+ module Num0
1833
+ end
1834
+
1835
+ module Num1
1836
+ def whole
1837
+ elements[0]
1838
+ end
1839
+
1840
+ def expansion
1841
+ elements[1]
1842
+ end
1843
+ end
1844
+
1845
+ def _nt_num
1846
+ start_index = index
1847
+ if node_cache[:num].has_key?(index)
1848
+ cached = node_cache[:num][index]
1849
+ @index = cached.interval.end if cached
1850
+ return cached
1851
+ end
1852
+
1853
+ i0, s0 = index, []
1854
+ s1, i1 = [], index
1855
+ loop do
1856
+ if input.index(Regexp.new('[0-9]'), index) == index
1857
+ r2 = (SyntaxNode).new(input, index...(index + 1))
1858
+ @index += 1
1859
+ else
1860
+ r2 = nil
1861
+ end
1862
+ if r2
1863
+ s1 << r2
1864
+ else
1865
+ break
1866
+ end
1867
+ end
1868
+ if s1.empty?
1869
+ self.index = i1
1870
+ r1 = nil
1871
+ else
1872
+ r1 = SyntaxNode.new(input, i1...index, s1)
1873
+ end
1874
+ s0 << r1
1875
+ if r1
1876
+ i4, s4 = index, []
1877
+ if input.index('.', index) == index
1878
+ r5 = (SyntaxNode).new(input, index...(index + 1))
1879
+ @index += 1
1880
+ else
1881
+ terminal_parse_failure('.')
1882
+ r5 = nil
1883
+ end
1884
+ s4 << r5
1885
+ if r5
1886
+ s6, i6 = [], index
1887
+ loop do
1888
+ if input.index(Regexp.new('[0-9]'), index) == index
1889
+ r7 = (SyntaxNode).new(input, index...(index + 1))
1890
+ @index += 1
1891
+ else
1892
+ r7 = nil
1893
+ end
1894
+ if r7
1895
+ s6 << r7
1896
+ else
1897
+ break
1898
+ end
1899
+ end
1900
+ if s6.empty?
1901
+ self.index = i6
1902
+ r6 = nil
1903
+ else
1904
+ r6 = SyntaxNode.new(input, i6...index, s6)
1905
+ end
1906
+ s4 << r6
1907
+ end
1908
+ if s4.last
1909
+ r4 = (SyntaxNode).new(input, i4...index, s4)
1910
+ r4.extend(Num0)
1911
+ else
1912
+ self.index = i4
1913
+ r4 = nil
1914
+ end
1915
+ if r4
1916
+ r3 = r4
1917
+ else
1918
+ r3 = SyntaxNode.new(input, index...index)
1919
+ end
1920
+ s0 << r3
1921
+ end
1922
+ if s0.last
1923
+ r0 = (NumNode).new(input, i0...index, s0)
1924
+ r0.extend(Num1)
1925
+ else
1926
+ self.index = i0
1927
+ r0 = nil
1928
+ end
1929
+
1930
+ node_cache[:num][start_index] = r0
1931
+
1932
+ return r0
1933
+ end
1934
+
1935
+ def _nt_x
1936
+ start_index = index
1937
+ if node_cache[:x].has_key?(index)
1938
+ cached = node_cache[:x][index]
1939
+ @index = cached.interval.end if cached
1940
+ return cached
1941
+ end
1942
+
1943
+ r1 = _nt_s
1944
+ if r1
1945
+ r0 = r1
1946
+ else
1947
+ r0 = SyntaxNode.new(input, index...index)
1948
+ end
1949
+
1950
+ node_cache[:x][start_index] = r0
1951
+
1952
+ return r0
1953
+ end
1954
+
1955
+ def _nt_s
1956
+ start_index = index
1957
+ if node_cache[:s].has_key?(index)
1958
+ cached = node_cache[:s][index]
1959
+ @index = cached.interval.end if cached
1960
+ return cached
1961
+ end
1962
+
1963
+ s0, i0 = [], index
1964
+ loop do
1965
+ if input.index(Regexp.new('[ \\n]'), index) == index
1966
+ r1 = (SyntaxNode).new(input, index...(index + 1))
1967
+ @index += 1
1968
+ else
1969
+ r1 = nil
1970
+ end
1971
+ if r1
1972
+ s0 << r1
1973
+ else
1974
+ break
1975
+ end
1976
+ end
1977
+ if s0.empty?
1978
+ self.index = i0
1979
+ r0 = nil
1980
+ else
1981
+ r0 = SyntaxNode.new(input, i0...index, s0)
1982
+ end
1983
+
1984
+ node_cache[:s][start_index] = r0
1985
+
1986
+ return r0
1987
+ end
1988
+
1989
+ end
1990
+
1991
+ class PlasmaGrammarParser < Treetop::Runtime::CompiledParser
1992
+ include PlasmaGrammar
1993
+ end
1994
+
1995
+ end
1996
+ end