ql 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/q/parser.rb ADDED
@@ -0,0 +1,2795 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ require 'q/scope'
5
+ require 'q/syntax'
6
+
7
+ module Q
8
+ include Treetop::Runtime
9
+
10
+ def root
11
+ @root ||= :statements
12
+ end
13
+
14
+ module Statements0
15
+ def statement
16
+ elements[1]
17
+ end
18
+
19
+ end
20
+
21
+ module Statements1
22
+ def statements
23
+ elements[0]
24
+ end
25
+
26
+ end
27
+
28
+ module Statements2
29
+ def eval scope
30
+ statements.elements.each do |statement|
31
+ statement.statement.eval scope
32
+ end
33
+
34
+ scope['_']
35
+ end
36
+ end
37
+
38
+ def _nt_statements
39
+ start_index = index
40
+ if node_cache[:statements].has_key?(index)
41
+ cached = node_cache[:statements][index]
42
+ if cached
43
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
44
+ @index = cached.interval.end
45
+ end
46
+ return cached
47
+ end
48
+
49
+ i0, s0 = index, []
50
+ s1, i1 = [], index
51
+ loop do
52
+ i2, s2 = index, []
53
+ s3, i3 = [], index
54
+ loop do
55
+ r4 = _nt_ws
56
+ if r4
57
+ s3 << r4
58
+ else
59
+ break
60
+ end
61
+ end
62
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
63
+ s2 << r3
64
+ if r3
65
+ i5 = index
66
+ r6 = _nt_comment
67
+ if r6
68
+ r5 = r6
69
+ else
70
+ r7 = _nt_statement
71
+ if r7
72
+ r5 = r7
73
+ else
74
+ @index = i5
75
+ r5 = nil
76
+ end
77
+ end
78
+ s2 << r5
79
+ if r5
80
+ s8, i8 = [], index
81
+ loop do
82
+ r9 = _nt_ws
83
+ if r9
84
+ s8 << r9
85
+ else
86
+ break
87
+ end
88
+ end
89
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
90
+ s2 << r8
91
+ end
92
+ end
93
+ if s2.last
94
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
95
+ r2.extend(Statements0)
96
+ else
97
+ @index = i2
98
+ r2 = nil
99
+ end
100
+ if r2
101
+ s1 << r2
102
+ else
103
+ break
104
+ end
105
+ end
106
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
107
+ s0 << r1
108
+ if r1
109
+ s10, i10 = [], index
110
+ loop do
111
+ r11 = _nt_ws
112
+ if r11
113
+ s10 << r11
114
+ else
115
+ break
116
+ end
117
+ end
118
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
119
+ s0 << r10
120
+ end
121
+ if s0.last
122
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
123
+ r0.extend(Statements1)
124
+ r0.extend(Statements2)
125
+ else
126
+ @index = i0
127
+ r0 = nil
128
+ end
129
+
130
+ node_cache[:statements][start_index] = r0
131
+
132
+ r0
133
+ end
134
+
135
+ module Statement0
136
+ def expression
137
+ elements[0]
138
+ end
139
+
140
+ end
141
+
142
+ module Statement1
143
+ def eval scope
144
+ scope['_'] = expression.eval scope
145
+ end
146
+ end
147
+
148
+ def _nt_statement
149
+ start_index = index
150
+ if node_cache[:statement].has_key?(index)
151
+ cached = node_cache[:statement][index]
152
+ if cached
153
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
154
+ @index = cached.interval.end
155
+ end
156
+ return cached
157
+ end
158
+
159
+ i0, s0 = index, []
160
+ r1 = _nt_expression
161
+ s0 << r1
162
+ if r1
163
+ s2, i2 = [], index
164
+ loop do
165
+ r3 = _nt_ws
166
+ if r3
167
+ s2 << r3
168
+ else
169
+ break
170
+ end
171
+ end
172
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
173
+ s0 << r2
174
+ if r2
175
+ if has_terminal?(';', false, index)
176
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
177
+ @index += 1
178
+ else
179
+ terminal_parse_failure(';')
180
+ r4 = nil
181
+ end
182
+ s0 << r4
183
+ end
184
+ end
185
+ if s0.last
186
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
187
+ r0.extend(Statement0)
188
+ r0.extend(Statement1)
189
+ else
190
+ @index = i0
191
+ r0 = nil
192
+ end
193
+
194
+ node_cache[:statement][start_index] = r0
195
+
196
+ r0
197
+ end
198
+
199
+ def _nt_expression
200
+ start_index = index
201
+ if node_cache[:expression].has_key?(index)
202
+ cached = node_cache[:expression][index]
203
+ if cached
204
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
205
+ @index = cached.interval.end
206
+ end
207
+ return cached
208
+ end
209
+
210
+ i0 = index
211
+ r1 = _nt_call
212
+ if r1
213
+ r0 = r1
214
+ else
215
+ r2 = _nt_assignment
216
+ if r2
217
+ r0 = r2
218
+ else
219
+ r3 = _nt_conditional
220
+ if r3
221
+ r0 = r3
222
+ else
223
+ r4 = _nt_binomial
224
+ if r4
225
+ r0 = r4
226
+ else
227
+ @index = i0
228
+ r0 = nil
229
+ end
230
+ end
231
+ end
232
+ end
233
+
234
+ node_cache[:expression][start_index] = r0
235
+
236
+ r0
237
+ end
238
+
239
+ module Function0
240
+ def identifier
241
+ elements[1]
242
+ end
243
+
244
+ end
245
+
246
+ module Function1
247
+ def arguments
248
+ elements[1]
249
+ end
250
+
251
+ def statements
252
+ elements[4]
253
+ end
254
+
255
+ end
256
+
257
+ def _nt_function
258
+ start_index = index
259
+ if node_cache[:function].has_key?(index)
260
+ cached = node_cache[:function][index]
261
+ if cached
262
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
263
+ @index = cached.interval.end
264
+ end
265
+ return cached
266
+ end
267
+
268
+ i0, s0 = index, []
269
+ if has_terminal?('(', false, index)
270
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
271
+ @index += 1
272
+ else
273
+ terminal_parse_failure('(')
274
+ r1 = nil
275
+ end
276
+ s0 << r1
277
+ if r1
278
+ s2, i2 = [], index
279
+ loop do
280
+ i3, s3 = index, []
281
+ s4, i4 = [], index
282
+ loop do
283
+ r5 = _nt_ws
284
+ if r5
285
+ s4 << r5
286
+ else
287
+ break
288
+ end
289
+ end
290
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
291
+ s3 << r4
292
+ if r4
293
+ r6 = _nt_identifier
294
+ s3 << r6
295
+ if r6
296
+ s7, i7 = [], index
297
+ loop do
298
+ r8 = _nt_ws
299
+ if r8
300
+ s7 << r8
301
+ else
302
+ break
303
+ end
304
+ end
305
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
306
+ s3 << r7
307
+ end
308
+ end
309
+ if s3.last
310
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
311
+ r3.extend(Function0)
312
+ else
313
+ @index = i3
314
+ r3 = nil
315
+ end
316
+ if r3
317
+ s2 << r3
318
+ else
319
+ break
320
+ end
321
+ end
322
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
323
+ s0 << r2
324
+ if r2
325
+ if has_terminal?(')', false, index)
326
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
327
+ @index += 1
328
+ else
329
+ terminal_parse_failure(')')
330
+ r9 = nil
331
+ end
332
+ s0 << r9
333
+ if r9
334
+ if has_terminal?('{', false, index)
335
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
336
+ @index += 1
337
+ else
338
+ terminal_parse_failure('{')
339
+ r10 = nil
340
+ end
341
+ s0 << r10
342
+ if r10
343
+ r11 = _nt_statements
344
+ s0 << r11
345
+ if r11
346
+ if has_terminal?('}', false, index)
347
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
348
+ @index += 1
349
+ else
350
+ terminal_parse_failure('}')
351
+ r12 = nil
352
+ end
353
+ s0 << r12
354
+ end
355
+ end
356
+ end
357
+ end
358
+ end
359
+ if s0.last
360
+ r0 = instantiate_node(Q::Syntax::Function,input, i0...index, s0)
361
+ r0.extend(Function1)
362
+ else
363
+ @index = i0
364
+ r0 = nil
365
+ end
366
+
367
+ node_cache[:function][start_index] = r0
368
+
369
+ r0
370
+ end
371
+
372
+ module Assignment0
373
+ def destination
374
+ elements[0]
375
+ end
376
+
377
+ def expression
378
+ elements[4]
379
+ end
380
+ end
381
+
382
+ module Assignment1
383
+ def eval scope
384
+ scope['_'] = scope[destination.text_value] = expression.eval scope
385
+ end
386
+ end
387
+
388
+ def _nt_assignment
389
+ start_index = index
390
+ if node_cache[:assignment].has_key?(index)
391
+ cached = node_cache[:assignment][index]
392
+ if cached
393
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
394
+ @index = cached.interval.end
395
+ end
396
+ return cached
397
+ end
398
+
399
+ i0, s0 = index, []
400
+ i1 = index
401
+ r2 = _nt_self
402
+ if r2
403
+ r1 = r2
404
+ else
405
+ r3 = _nt_identifier
406
+ if r3
407
+ r1 = r3
408
+ else
409
+ @index = i1
410
+ r1 = nil
411
+ end
412
+ end
413
+ s0 << r1
414
+ if r1
415
+ s4, i4 = [], index
416
+ loop do
417
+ r5 = _nt_ws
418
+ if r5
419
+ s4 << r5
420
+ else
421
+ break
422
+ end
423
+ end
424
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
425
+ s0 << r4
426
+ if r4
427
+ if has_terminal?('<:', false, index)
428
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 2))
429
+ @index += 2
430
+ else
431
+ terminal_parse_failure('<:')
432
+ r6 = nil
433
+ end
434
+ s0 << r6
435
+ if r6
436
+ s7, i7 = [], index
437
+ loop do
438
+ r8 = _nt_ws
439
+ if r8
440
+ s7 << r8
441
+ else
442
+ break
443
+ end
444
+ end
445
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
446
+ s0 << r7
447
+ if r7
448
+ r9 = _nt_expression
449
+ s0 << r9
450
+ end
451
+ end
452
+ end
453
+ end
454
+ if s0.last
455
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
456
+ r0.extend(Assignment0)
457
+ r0.extend(Assignment1)
458
+ else
459
+ @index = i0
460
+ r0 = nil
461
+ end
462
+
463
+ node_cache[:assignment][start_index] = r0
464
+
465
+ r0
466
+ end
467
+
468
+ module Call0
469
+ def argument
470
+ elements[1]
471
+ end
472
+
473
+ end
474
+
475
+ module Call1
476
+ def name
477
+ elements[0]
478
+ end
479
+
480
+ def arguments
481
+ elements[3]
482
+ end
483
+
484
+ end
485
+
486
+ module Call2
487
+ def eval scope
488
+ scope['_'] = name.eval(scope).call(callscope(scope))
489
+ end
490
+
491
+ def callscope scope
492
+ cscope = Q::Scope.new scope
493
+
494
+ cscope.args = arguments.elements.map.each do |argument|
495
+ argument.argument.eval(scope)
496
+ end
497
+
498
+ cscope
499
+ end
500
+ end
501
+
502
+ def _nt_call
503
+ start_index = index
504
+ if node_cache[:call].has_key?(index)
505
+ cached = node_cache[:call][index]
506
+ if cached
507
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
508
+ @index = cached.interval.end
509
+ end
510
+ return cached
511
+ end
512
+
513
+ i0, s0 = index, []
514
+ i1 = index
515
+ r2 = _nt_function
516
+ if r2
517
+ r1 = r2
518
+ else
519
+ r3 = _nt_self
520
+ if r3
521
+ r1 = r3
522
+ else
523
+ r4 = _nt_identifier
524
+ if r4
525
+ r1 = r4
526
+ else
527
+ @index = i1
528
+ r1 = nil
529
+ end
530
+ end
531
+ end
532
+ s0 << r1
533
+ if r1
534
+ s5, i5 = [], index
535
+ loop do
536
+ r6 = _nt_ws
537
+ if r6
538
+ s5 << r6
539
+ else
540
+ break
541
+ end
542
+ end
543
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
544
+ s0 << r5
545
+ if r5
546
+ if has_terminal?('(', false, index)
547
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
548
+ @index += 1
549
+ else
550
+ terminal_parse_failure('(')
551
+ r7 = nil
552
+ end
553
+ s0 << r7
554
+ if r7
555
+ s8, i8 = [], index
556
+ loop do
557
+ i9, s9 = index, []
558
+ s10, i10 = [], index
559
+ loop do
560
+ r11 = _nt_ws
561
+ if r11
562
+ s10 << r11
563
+ else
564
+ break
565
+ end
566
+ end
567
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
568
+ s9 << r10
569
+ if r10
570
+ r12 = _nt_expression
571
+ s9 << r12
572
+ if r12
573
+ s13, i13 = [], index
574
+ loop do
575
+ r14 = _nt_ws
576
+ if r14
577
+ s13 << r14
578
+ else
579
+ break
580
+ end
581
+ end
582
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
583
+ s9 << r13
584
+ end
585
+ end
586
+ if s9.last
587
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
588
+ r9.extend(Call0)
589
+ else
590
+ @index = i9
591
+ r9 = nil
592
+ end
593
+ if r9
594
+ s8 << r9
595
+ else
596
+ break
597
+ end
598
+ end
599
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
600
+ s0 << r8
601
+ if r8
602
+ if has_terminal?(')', false, index)
603
+ r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
604
+ @index += 1
605
+ else
606
+ terminal_parse_failure(')')
607
+ r15 = nil
608
+ end
609
+ s0 << r15
610
+ end
611
+ end
612
+ end
613
+ end
614
+ if s0.last
615
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
616
+ r0.extend(Call1)
617
+ r0.extend(Call2)
618
+ else
619
+ @index = i0
620
+ r0 = nil
621
+ end
622
+
623
+ node_cache[:call][start_index] = r0
624
+
625
+ r0
626
+ end
627
+
628
+ module Binomial0
629
+ def operator
630
+ elements[1]
631
+ end
632
+
633
+ def feet
634
+ elements[3]
635
+ end
636
+ end
637
+
638
+ module Binomial1
639
+ def head
640
+ elements[0]
641
+ end
642
+
643
+ def tail
644
+ elements[2]
645
+ end
646
+ end
647
+
648
+ module Binomial2
649
+ def eval scope
650
+ if has_feet?
651
+ return operator.apply(scope, head, feet)
652
+ end
653
+
654
+ scope['_'] = head.eval(scope)
655
+ end
656
+
657
+ def has_feet?
658
+ not tail.nil? and not tail.elements.first.nil? and not tail.elements.first.feet.nil?
659
+ end
660
+
661
+ def feet
662
+ return nil if not has_feet?
663
+
664
+ tail.elements.first.feet
665
+ end
666
+
667
+ def operator
668
+ return nil if not has_feet?
669
+
670
+ tail.elements.first.operator
671
+ end
672
+ end
673
+
674
+ def _nt_binomial
675
+ start_index = index
676
+ if node_cache[:binomial].has_key?(index)
677
+ cached = node_cache[:binomial][index]
678
+ if cached
679
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
680
+ @index = cached.interval.end
681
+ end
682
+ return cached
683
+ end
684
+
685
+ i0, s0 = index, []
686
+ r1 = _nt_monomial
687
+ s0 << r1
688
+ if r1
689
+ s2, i2 = [], index
690
+ loop do
691
+ r3 = _nt_ws
692
+ if r3
693
+ s2 << r3
694
+ else
695
+ break
696
+ end
697
+ end
698
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
699
+ s0 << r2
700
+ if r2
701
+ s4, i4 = [], index
702
+ loop do
703
+ i5, s5 = index, []
704
+ s6, i6 = [], index
705
+ loop do
706
+ r7 = _nt_ws
707
+ if r7
708
+ s6 << r7
709
+ else
710
+ break
711
+ end
712
+ end
713
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
714
+ s5 << r6
715
+ if r6
716
+ r8 = _nt_binomial_operator
717
+ s5 << r8
718
+ if r8
719
+ s9, i9 = [], index
720
+ loop do
721
+ r10 = _nt_ws
722
+ if r10
723
+ s9 << r10
724
+ else
725
+ break
726
+ end
727
+ end
728
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
729
+ s5 << r9
730
+ if r9
731
+ r11 = _nt_monomial
732
+ s5 << r11
733
+ end
734
+ end
735
+ end
736
+ if s5.last
737
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
738
+ r5.extend(Binomial0)
739
+ else
740
+ @index = i5
741
+ r5 = nil
742
+ end
743
+ if r5
744
+ s4 << r5
745
+ else
746
+ break
747
+ end
748
+ end
749
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
750
+ s0 << r4
751
+ end
752
+ end
753
+ if s0.last
754
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
755
+ r0.extend(Binomial1)
756
+ r0.extend(Binomial2)
757
+ else
758
+ @index = i0
759
+ r0 = nil
760
+ end
761
+
762
+ node_cache[:binomial][start_index] = r0
763
+
764
+ r0
765
+ end
766
+
767
+ module Monomial0
768
+ def operator
769
+ elements[1]
770
+ end
771
+
772
+ def feet
773
+ elements[3]
774
+ end
775
+ end
776
+
777
+ module Monomial1
778
+ def head
779
+ elements[0]
780
+ end
781
+
782
+ def tail
783
+ elements[2]
784
+ end
785
+ end
786
+
787
+ module Monomial2
788
+ def eval scope
789
+ if has_feet?
790
+ feet = tail.elements.first.feet
791
+ return operator.apply(scope, head, feet)
792
+ end
793
+
794
+ scope['_'] = head.eval(scope)
795
+ end
796
+
797
+ def has_feet?
798
+ not tail.nil? and not tail.elements.first.nil? and not tail.elements.first.feet.nil?
799
+ end
800
+
801
+ def operator
802
+ return nil if not has_feet?
803
+
804
+ tail.elements.first.operator
805
+ end
806
+ end
807
+
808
+ def _nt_monomial
809
+ start_index = index
810
+ if node_cache[:monomial].has_key?(index)
811
+ cached = node_cache[:monomial][index]
812
+ if cached
813
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
814
+ @index = cached.interval.end
815
+ end
816
+ return cached
817
+ end
818
+
819
+ i0, s0 = index, []
820
+ r1 = _nt_primary
821
+ s0 << r1
822
+ if r1
823
+ s2, i2 = [], index
824
+ loop do
825
+ r3 = _nt_ws
826
+ if r3
827
+ s2 << r3
828
+ else
829
+ break
830
+ end
831
+ end
832
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
833
+ s0 << r2
834
+ if r2
835
+ s4, i4 = [], index
836
+ loop do
837
+ i5, s5 = index, []
838
+ s6, i6 = [], index
839
+ loop do
840
+ r7 = _nt_ws
841
+ if r7
842
+ s6 << r7
843
+ else
844
+ break
845
+ end
846
+ end
847
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
848
+ s5 << r6
849
+ if r6
850
+ r8 = _nt_monomial_operator
851
+ s5 << r8
852
+ if r8
853
+ s9, i9 = [], index
854
+ loop do
855
+ r10 = _nt_ws
856
+ if r10
857
+ s9 << r10
858
+ else
859
+ break
860
+ end
861
+ end
862
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
863
+ s5 << r9
864
+ if r9
865
+ r11 = _nt_monomial
866
+ s5 << r11
867
+ end
868
+ end
869
+ end
870
+ if s5.last
871
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
872
+ r5.extend(Monomial0)
873
+ else
874
+ @index = i5
875
+ r5 = nil
876
+ end
877
+ if r5
878
+ s4 << r5
879
+ else
880
+ break
881
+ end
882
+ end
883
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
884
+ s0 << r4
885
+ end
886
+ end
887
+ if s0.last
888
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
889
+ r0.extend(Monomial1)
890
+ r0.extend(Monomial2)
891
+ else
892
+ @index = i0
893
+ r0 = nil
894
+ end
895
+
896
+ node_cache[:monomial][start_index] = r0
897
+
898
+ r0
899
+ end
900
+
901
+ module Conditional0
902
+ def consequence
903
+ elements[4]
904
+ end
905
+
906
+ end
907
+
908
+ module Conditional1
909
+ def condition
910
+ elements[3]
911
+ end
912
+
913
+ def consequence
914
+ elements[9]
915
+ end
916
+
917
+ def otherwise
918
+ elements[11]
919
+ end
920
+ end
921
+
922
+ def _nt_conditional
923
+ start_index = index
924
+ if node_cache[:conditional].has_key?(index)
925
+ cached = node_cache[:conditional][index]
926
+ if cached
927
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
928
+ @index = cached.interval.end
929
+ end
930
+ return cached
931
+ end
932
+
933
+ i0, s0 = index, []
934
+ if has_terminal?('if', false, index)
935
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
936
+ @index += 2
937
+ else
938
+ terminal_parse_failure('if')
939
+ r1 = nil
940
+ end
941
+ s0 << r1
942
+ if r1
943
+ s2, i2 = [], index
944
+ loop do
945
+ r3 = _nt_ws
946
+ if r3
947
+ s2 << r3
948
+ else
949
+ break
950
+ end
951
+ end
952
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
953
+ s0 << r2
954
+ if r2
955
+ if has_terminal?('[', false, index)
956
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
957
+ @index += 1
958
+ else
959
+ terminal_parse_failure('[')
960
+ r4 = nil
961
+ end
962
+ s0 << r4
963
+ if r4
964
+ i5 = index
965
+ r6 = _nt_conditional_expression
966
+ if r6
967
+ r5 = r6
968
+ else
969
+ r7 = _nt_statements
970
+ if r7
971
+ r5 = r7
972
+ else
973
+ @index = i5
974
+ r5 = nil
975
+ end
976
+ end
977
+ s0 << r5
978
+ if r5
979
+ if has_terminal?(']', false, index)
980
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
981
+ @index += 1
982
+ else
983
+ terminal_parse_failure(']')
984
+ r8 = nil
985
+ end
986
+ s0 << r8
987
+ if r8
988
+ s9, i9 = [], index
989
+ loop do
990
+ r10 = _nt_ws
991
+ if r10
992
+ s9 << r10
993
+ else
994
+ break
995
+ end
996
+ end
997
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
998
+ s0 << r9
999
+ if r9
1000
+ if has_terminal?('then', false, index)
1001
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 4))
1002
+ @index += 4
1003
+ else
1004
+ terminal_parse_failure('then')
1005
+ r11 = nil
1006
+ end
1007
+ s0 << r11
1008
+ if r11
1009
+ s12, i12 = [], index
1010
+ loop do
1011
+ r13 = _nt_ws
1012
+ if r13
1013
+ s12 << r13
1014
+ else
1015
+ break
1016
+ end
1017
+ end
1018
+ r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1019
+ s0 << r12
1020
+ if r12
1021
+ if has_terminal?('[', false, index)
1022
+ r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
1023
+ @index += 1
1024
+ else
1025
+ terminal_parse_failure('[')
1026
+ r14 = nil
1027
+ end
1028
+ s0 << r14
1029
+ if r14
1030
+ i15 = index
1031
+ r16 = _nt_conditional_expression
1032
+ if r16
1033
+ r15 = r16
1034
+ else
1035
+ r17 = _nt_statements
1036
+ if r17
1037
+ r15 = r17
1038
+ else
1039
+ @index = i15
1040
+ r15 = nil
1041
+ end
1042
+ end
1043
+ s0 << r15
1044
+ if r15
1045
+ if has_terminal?(']', false, index)
1046
+ r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
1047
+ @index += 1
1048
+ else
1049
+ terminal_parse_failure(']')
1050
+ r18 = nil
1051
+ end
1052
+ s0 << r18
1053
+ if r18
1054
+ i20, s20 = index, []
1055
+ s21, i21 = [], index
1056
+ loop do
1057
+ r22 = _nt_ws
1058
+ if r22
1059
+ s21 << r22
1060
+ else
1061
+ break
1062
+ end
1063
+ end
1064
+ r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
1065
+ s20 << r21
1066
+ if r21
1067
+ if has_terminal?('else', false, index)
1068
+ r23 = instantiate_node(SyntaxNode,input, index...(index + 4))
1069
+ @index += 4
1070
+ else
1071
+ terminal_parse_failure('else')
1072
+ r23 = nil
1073
+ end
1074
+ s20 << r23
1075
+ if r23
1076
+ s24, i24 = [], index
1077
+ loop do
1078
+ r25 = _nt_ws
1079
+ if r25
1080
+ s24 << r25
1081
+ else
1082
+ break
1083
+ end
1084
+ end
1085
+ r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
1086
+ s20 << r24
1087
+ if r24
1088
+ if has_terminal?('[', false, index)
1089
+ r26 = instantiate_node(SyntaxNode,input, index...(index + 1))
1090
+ @index += 1
1091
+ else
1092
+ terminal_parse_failure('[')
1093
+ r26 = nil
1094
+ end
1095
+ s20 << r26
1096
+ if r26
1097
+ i27 = index
1098
+ r28 = _nt_conditional_expression
1099
+ if r28
1100
+ r27 = r28
1101
+ else
1102
+ r29 = _nt_statements
1103
+ if r29
1104
+ r27 = r29
1105
+ else
1106
+ @index = i27
1107
+ r27 = nil
1108
+ end
1109
+ end
1110
+ s20 << r27
1111
+ if r27
1112
+ if has_terminal?(']', false, index)
1113
+ r30 = instantiate_node(SyntaxNode,input, index...(index + 1))
1114
+ @index += 1
1115
+ else
1116
+ terminal_parse_failure(']')
1117
+ r30 = nil
1118
+ end
1119
+ s20 << r30
1120
+ end
1121
+ end
1122
+ end
1123
+ end
1124
+ end
1125
+ if s20.last
1126
+ r20 = instantiate_node(SyntaxNode,input, i20...index, s20)
1127
+ r20.extend(Conditional0)
1128
+ else
1129
+ @index = i20
1130
+ r20 = nil
1131
+ end
1132
+ if r20
1133
+ r19 = r20
1134
+ else
1135
+ r19 = instantiate_node(SyntaxNode,input, index...index)
1136
+ end
1137
+ s0 << r19
1138
+ end
1139
+ end
1140
+ end
1141
+ end
1142
+ end
1143
+ end
1144
+ end
1145
+ end
1146
+ end
1147
+ end
1148
+ end
1149
+ if s0.last
1150
+ r0 = instantiate_node(Q::Syntax::Conditional,input, i0...index, s0)
1151
+ r0.extend(Conditional1)
1152
+ else
1153
+ @index = i0
1154
+ r0 = nil
1155
+ end
1156
+
1157
+ node_cache[:conditional][start_index] = r0
1158
+
1159
+ r0
1160
+ end
1161
+
1162
+ module ConditionalExpression0
1163
+ def expression
1164
+ elements[1]
1165
+ end
1166
+
1167
+ end
1168
+
1169
+ module ConditionalExpression1
1170
+ def eval scope
1171
+ expression.eval scope
1172
+ end
1173
+ end
1174
+
1175
+ def _nt_conditional_expression
1176
+ start_index = index
1177
+ if node_cache[:conditional_expression].has_key?(index)
1178
+ cached = node_cache[:conditional_expression][index]
1179
+ if cached
1180
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1181
+ @index = cached.interval.end
1182
+ end
1183
+ return cached
1184
+ end
1185
+
1186
+ i0, s0 = index, []
1187
+ s1, i1 = [], index
1188
+ loop do
1189
+ r2 = _nt_ws
1190
+ if r2
1191
+ s1 << r2
1192
+ else
1193
+ break
1194
+ end
1195
+ end
1196
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1197
+ s0 << r1
1198
+ if r1
1199
+ r3 = _nt_expression
1200
+ s0 << r3
1201
+ if r3
1202
+ s4, i4 = [], index
1203
+ loop do
1204
+ r5 = _nt_ws
1205
+ if r5
1206
+ s4 << r5
1207
+ else
1208
+ break
1209
+ end
1210
+ end
1211
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1212
+ s0 << r4
1213
+ if r4
1214
+ i6 = index
1215
+ if has_terminal?(']', false, index)
1216
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
1217
+ @index += 1
1218
+ else
1219
+ terminal_parse_failure(']')
1220
+ r7 = nil
1221
+ end
1222
+ if r7
1223
+ @index = i6
1224
+ r6 = instantiate_node(SyntaxNode,input, index...index)
1225
+ else
1226
+ r6 = nil
1227
+ end
1228
+ s0 << r6
1229
+ end
1230
+ end
1231
+ end
1232
+ if s0.last
1233
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1234
+ r0.extend(ConditionalExpression0)
1235
+ r0.extend(ConditionalExpression1)
1236
+ else
1237
+ @index = i0
1238
+ r0 = nil
1239
+ end
1240
+
1241
+ node_cache[:conditional_expression][start_index] = r0
1242
+
1243
+ r0
1244
+ end
1245
+
1246
+ module Primary0
1247
+ def expression
1248
+ elements[2]
1249
+ end
1250
+
1251
+ end
1252
+
1253
+ module Primary1
1254
+ def eval scope
1255
+ scope['_'] = expression.eval(scope)
1256
+ end
1257
+ end
1258
+
1259
+ def _nt_primary
1260
+ start_index = index
1261
+ if node_cache[:primary].has_key?(index)
1262
+ cached = node_cache[:primary][index]
1263
+ if cached
1264
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1265
+ @index = cached.interval.end
1266
+ end
1267
+ return cached
1268
+ end
1269
+
1270
+ i0 = index
1271
+ r1 = _nt_call
1272
+ if r1
1273
+ r0 = r1
1274
+ else
1275
+ r2 = _nt_function
1276
+ if r2
1277
+ r0 = r2
1278
+ else
1279
+ r3 = _nt_self
1280
+ if r3
1281
+ r0 = r3
1282
+ else
1283
+ r4 = _nt_unary
1284
+ if r4
1285
+ r0 = r4
1286
+ else
1287
+ r5 = _nt_value
1288
+ if r5
1289
+ r0 = r5
1290
+ else
1291
+ r6 = _nt_identifier
1292
+ if r6
1293
+ r0 = r6
1294
+ else
1295
+ i7, s7 = index, []
1296
+ if has_terminal?('(', false, index)
1297
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
1298
+ @index += 1
1299
+ else
1300
+ terminal_parse_failure('(')
1301
+ r8 = nil
1302
+ end
1303
+ s7 << r8
1304
+ if r8
1305
+ s9, i9 = [], index
1306
+ loop do
1307
+ r10 = _nt_ws
1308
+ if r10
1309
+ s9 << r10
1310
+ else
1311
+ break
1312
+ end
1313
+ end
1314
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1315
+ s7 << r9
1316
+ if r9
1317
+ r11 = _nt_expression
1318
+ s7 << r11
1319
+ if r11
1320
+ s12, i12 = [], index
1321
+ loop do
1322
+ r13 = _nt_ws
1323
+ if r13
1324
+ s12 << r13
1325
+ else
1326
+ break
1327
+ end
1328
+ end
1329
+ r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1330
+ s7 << r12
1331
+ if r12
1332
+ if has_terminal?(')', false, index)
1333
+ r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
1334
+ @index += 1
1335
+ else
1336
+ terminal_parse_failure(')')
1337
+ r14 = nil
1338
+ end
1339
+ s7 << r14
1340
+ end
1341
+ end
1342
+ end
1343
+ end
1344
+ if s7.last
1345
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1346
+ r7.extend(Primary0)
1347
+ r7.extend(Primary1)
1348
+ else
1349
+ @index = i7
1350
+ r7 = nil
1351
+ end
1352
+ if r7
1353
+ r0 = r7
1354
+ else
1355
+ @index = i0
1356
+ r0 = nil
1357
+ end
1358
+ end
1359
+ end
1360
+ end
1361
+ end
1362
+ end
1363
+ end
1364
+
1365
+ node_cache[:primary][start_index] = r0
1366
+
1367
+ r0
1368
+ end
1369
+
1370
+ def _nt_binomial_operator
1371
+ start_index = index
1372
+ if node_cache[:binomial_operator].has_key?(index)
1373
+ cached = node_cache[:binomial_operator][index]
1374
+ if cached
1375
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1376
+ @index = cached.interval.end
1377
+ end
1378
+ return cached
1379
+ end
1380
+
1381
+ i0 = index
1382
+ r1 = _nt_minus
1383
+ if r1
1384
+ r0 = r1
1385
+ else
1386
+ r2 = _nt_plus
1387
+ if r2
1388
+ r0 = r2
1389
+ else
1390
+ r3 = _nt_comparison_operators
1391
+ if r3
1392
+ r0 = r3
1393
+ else
1394
+ @index = i0
1395
+ r0 = nil
1396
+ end
1397
+ end
1398
+ end
1399
+
1400
+ node_cache[:binomial_operator][start_index] = r0
1401
+
1402
+ r0
1403
+ end
1404
+
1405
+ def _nt_monomial_operator
1406
+ start_index = index
1407
+ if node_cache[:monomial_operator].has_key?(index)
1408
+ cached = node_cache[:monomial_operator][index]
1409
+ if cached
1410
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1411
+ @index = cached.interval.end
1412
+ end
1413
+ return cached
1414
+ end
1415
+
1416
+ i0 = index
1417
+ r1 = _nt_slash
1418
+ if r1
1419
+ r0 = r1
1420
+ else
1421
+ r2 = _nt_star
1422
+ if r2
1423
+ r0 = r2
1424
+ else
1425
+ @index = i0
1426
+ r0 = nil
1427
+ end
1428
+ end
1429
+
1430
+ node_cache[:monomial_operator][start_index] = r0
1431
+
1432
+ r0
1433
+ end
1434
+
1435
+ def _nt_unary
1436
+ start_index = index
1437
+ if node_cache[:unary].has_key?(index)
1438
+ cached = node_cache[:unary][index]
1439
+ if cached
1440
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1441
+ @index = cached.interval.end
1442
+ end
1443
+ return cached
1444
+ end
1445
+
1446
+ i0 = index
1447
+ r1 = _nt_negative
1448
+ if r1
1449
+ r0 = r1
1450
+ else
1451
+ r2 = _nt_negation
1452
+ if r2
1453
+ r0 = r2
1454
+ else
1455
+ @index = i0
1456
+ r0 = nil
1457
+ end
1458
+ end
1459
+
1460
+ node_cache[:unary][start_index] = r0
1461
+
1462
+ r0
1463
+ end
1464
+
1465
+ module Negation0
1466
+ def primary
1467
+ elements[2]
1468
+ end
1469
+ end
1470
+
1471
+ module Negation1
1472
+ def eval scope
1473
+ not primary.eval(scope)
1474
+ end
1475
+ end
1476
+
1477
+ def _nt_negation
1478
+ start_index = index
1479
+ if node_cache[:negation].has_key?(index)
1480
+ cached = node_cache[:negation][index]
1481
+ if cached
1482
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1483
+ @index = cached.interval.end
1484
+ end
1485
+ return cached
1486
+ end
1487
+
1488
+ i0, s0 = index, []
1489
+ if has_terminal?('!', false, index)
1490
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1491
+ @index += 1
1492
+ else
1493
+ terminal_parse_failure('!')
1494
+ r1 = nil
1495
+ end
1496
+ s0 << r1
1497
+ if r1
1498
+ s2, i2 = [], index
1499
+ loop do
1500
+ r3 = _nt_ws
1501
+ if r3
1502
+ s2 << r3
1503
+ else
1504
+ break
1505
+ end
1506
+ end
1507
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1508
+ s0 << r2
1509
+ if r2
1510
+ r4 = _nt_primary
1511
+ s0 << r4
1512
+ end
1513
+ end
1514
+ if s0.last
1515
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1516
+ r0.extend(Negation0)
1517
+ r0.extend(Negation1)
1518
+ else
1519
+ @index = i0
1520
+ r0 = nil
1521
+ end
1522
+
1523
+ node_cache[:negation][start_index] = r0
1524
+
1525
+ r0
1526
+ end
1527
+
1528
+ module Negative0
1529
+ def primary
1530
+ elements[2]
1531
+ end
1532
+ end
1533
+
1534
+ module Negative1
1535
+ def eval scope
1536
+ - primary.eval(scope)
1537
+ end
1538
+ end
1539
+
1540
+ def _nt_negative
1541
+ start_index = index
1542
+ if node_cache[:negative].has_key?(index)
1543
+ cached = node_cache[:negative][index]
1544
+ if cached
1545
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1546
+ @index = cached.interval.end
1547
+ end
1548
+ return cached
1549
+ end
1550
+
1551
+ i0, s0 = index, []
1552
+ if has_terminal?('-', false, index)
1553
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1554
+ @index += 1
1555
+ else
1556
+ terminal_parse_failure('-')
1557
+ r1 = nil
1558
+ end
1559
+ s0 << r1
1560
+ if r1
1561
+ s2, i2 = [], index
1562
+ loop do
1563
+ r3 = _nt_ws
1564
+ if r3
1565
+ s2 << r3
1566
+ else
1567
+ break
1568
+ end
1569
+ end
1570
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1571
+ s0 << r2
1572
+ if r2
1573
+ r4 = _nt_primary
1574
+ s0 << r4
1575
+ end
1576
+ end
1577
+ if s0.last
1578
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1579
+ r0.extend(Negative0)
1580
+ r0.extend(Negative1)
1581
+ else
1582
+ @index = i0
1583
+ r0 = nil
1584
+ end
1585
+
1586
+ node_cache[:negative][start_index] = r0
1587
+
1588
+ r0
1589
+ end
1590
+
1591
+ def _nt_comparison_operators
1592
+ start_index = index
1593
+ if node_cache[:comparison_operators].has_key?(index)
1594
+ cached = node_cache[:comparison_operators][index]
1595
+ if cached
1596
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1597
+ @index = cached.interval.end
1598
+ end
1599
+ return cached
1600
+ end
1601
+
1602
+ i0 = index
1603
+ r1 = _nt_lt
1604
+ if r1
1605
+ r0 = r1
1606
+ else
1607
+ r2 = _nt_lte
1608
+ if r2
1609
+ r0 = r2
1610
+ else
1611
+ r3 = _nt_gt
1612
+ if r3
1613
+ r0 = r3
1614
+ else
1615
+ r4 = _nt_gte
1616
+ if r4
1617
+ r0 = r4
1618
+ else
1619
+ r5 = _nt_neq
1620
+ if r5
1621
+ r0 = r5
1622
+ else
1623
+ r6 = _nt_eq
1624
+ if r6
1625
+ r0 = r6
1626
+ else
1627
+ @index = i0
1628
+ r0 = nil
1629
+ end
1630
+ end
1631
+ end
1632
+ end
1633
+ end
1634
+ end
1635
+
1636
+ node_cache[:comparison_operators][start_index] = r0
1637
+
1638
+ r0
1639
+ end
1640
+
1641
+ module Lt0
1642
+ def apply scope, a, b
1643
+ a.eval(scope) < b.eval(scope)
1644
+ end
1645
+ end
1646
+
1647
+ def _nt_lt
1648
+ start_index = index
1649
+ if node_cache[:lt].has_key?(index)
1650
+ cached = node_cache[:lt][index]
1651
+ if cached
1652
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1653
+ @index = cached.interval.end
1654
+ end
1655
+ return cached
1656
+ end
1657
+
1658
+ if has_terminal?('<', false, index)
1659
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1660
+ r0.extend(Lt0)
1661
+ @index += 1
1662
+ else
1663
+ terminal_parse_failure('<')
1664
+ r0 = nil
1665
+ end
1666
+
1667
+ node_cache[:lt][start_index] = r0
1668
+
1669
+ r0
1670
+ end
1671
+
1672
+ module Gt0
1673
+ def apply scope, a, b
1674
+ a.eval(scope) < b.eval(scope)
1675
+ end
1676
+ end
1677
+
1678
+ def _nt_gt
1679
+ start_index = index
1680
+ if node_cache[:gt].has_key?(index)
1681
+ cached = node_cache[:gt][index]
1682
+ if cached
1683
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1684
+ @index = cached.interval.end
1685
+ end
1686
+ return cached
1687
+ end
1688
+
1689
+ if has_terminal?('>', false, index)
1690
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1691
+ r0.extend(Gt0)
1692
+ @index += 1
1693
+ else
1694
+ terminal_parse_failure('>')
1695
+ r0 = nil
1696
+ end
1697
+
1698
+ node_cache[:gt][start_index] = r0
1699
+
1700
+ r0
1701
+ end
1702
+
1703
+ module Lte0
1704
+ def apply scope, a, b
1705
+ a.eval(scope) <= b.eval(scope)
1706
+ end
1707
+ end
1708
+
1709
+ def _nt_lte
1710
+ start_index = index
1711
+ if node_cache[:lte].has_key?(index)
1712
+ cached = node_cache[:lte][index]
1713
+ if cached
1714
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1715
+ @index = cached.interval.end
1716
+ end
1717
+ return cached
1718
+ end
1719
+
1720
+ if has_terminal?('<=', false, index)
1721
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
1722
+ r0.extend(Lte0)
1723
+ @index += 2
1724
+ else
1725
+ terminal_parse_failure('<=')
1726
+ r0 = nil
1727
+ end
1728
+
1729
+ node_cache[:lte][start_index] = r0
1730
+
1731
+ r0
1732
+ end
1733
+
1734
+ module Gte0
1735
+ def apply scope, a, b
1736
+ a.eval(scope) >= b.eval(scope)
1737
+ end
1738
+ end
1739
+
1740
+ def _nt_gte
1741
+ start_index = index
1742
+ if node_cache[:gte].has_key?(index)
1743
+ cached = node_cache[:gte][index]
1744
+ if cached
1745
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1746
+ @index = cached.interval.end
1747
+ end
1748
+ return cached
1749
+ end
1750
+
1751
+ if has_terminal?('>=', false, index)
1752
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
1753
+ r0.extend(Gte0)
1754
+ @index += 2
1755
+ else
1756
+ terminal_parse_failure('>=')
1757
+ r0 = nil
1758
+ end
1759
+
1760
+ node_cache[:gte][start_index] = r0
1761
+
1762
+ r0
1763
+ end
1764
+
1765
+ module Eq0
1766
+ def apply scope, a, b
1767
+ a.eval(scope) == b.eval(scope)
1768
+ end
1769
+ end
1770
+
1771
+ def _nt_eq
1772
+ start_index = index
1773
+ if node_cache[:eq].has_key?(index)
1774
+ cached = node_cache[:eq][index]
1775
+ if cached
1776
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1777
+ @index = cached.interval.end
1778
+ end
1779
+ return cached
1780
+ end
1781
+
1782
+ if has_terminal?('=', false, index)
1783
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1784
+ r0.extend(Eq0)
1785
+ @index += 1
1786
+ else
1787
+ terminal_parse_failure('=')
1788
+ r0 = nil
1789
+ end
1790
+
1791
+ node_cache[:eq][start_index] = r0
1792
+
1793
+ r0
1794
+ end
1795
+
1796
+ module Neq0
1797
+ def apply scope, a, b
1798
+ a.eval(scope) != b.eval(scope)
1799
+ end
1800
+ end
1801
+
1802
+ def _nt_neq
1803
+ start_index = index
1804
+ if node_cache[:neq].has_key?(index)
1805
+ cached = node_cache[:neq][index]
1806
+ if cached
1807
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1808
+ @index = cached.interval.end
1809
+ end
1810
+ return cached
1811
+ end
1812
+
1813
+ if has_terminal?('!=', false, index)
1814
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
1815
+ r0.extend(Neq0)
1816
+ @index += 2
1817
+ else
1818
+ terminal_parse_failure('!=')
1819
+ r0 = nil
1820
+ end
1821
+
1822
+ node_cache[:neq][start_index] = r0
1823
+
1824
+ r0
1825
+ end
1826
+
1827
+ module Plus0
1828
+ def apply scope, a, b
1829
+ scope['_'] = a.eval(scope) + b.eval(scope)
1830
+ end
1831
+ end
1832
+
1833
+ def _nt_plus
1834
+ start_index = index
1835
+ if node_cache[:plus].has_key?(index)
1836
+ cached = node_cache[:plus][index]
1837
+ if cached
1838
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1839
+ @index = cached.interval.end
1840
+ end
1841
+ return cached
1842
+ end
1843
+
1844
+ if has_terminal?('+', false, index)
1845
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1846
+ r0.extend(Plus0)
1847
+ @index += 1
1848
+ else
1849
+ terminal_parse_failure('+')
1850
+ r0 = nil
1851
+ end
1852
+
1853
+ node_cache[:plus][start_index] = r0
1854
+
1855
+ r0
1856
+ end
1857
+
1858
+ module Minus0
1859
+ def apply scope, a, b
1860
+ scope['_'] = a.eval(scope) - b.eval(scope)
1861
+ end
1862
+ end
1863
+
1864
+ def _nt_minus
1865
+ start_index = index
1866
+ if node_cache[:minus].has_key?(index)
1867
+ cached = node_cache[:minus][index]
1868
+ if cached
1869
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1870
+ @index = cached.interval.end
1871
+ end
1872
+ return cached
1873
+ end
1874
+
1875
+ if has_terminal?('-', false, index)
1876
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1877
+ r0.extend(Minus0)
1878
+ @index += 1
1879
+ else
1880
+ terminal_parse_failure('-')
1881
+ r0 = nil
1882
+ end
1883
+
1884
+ node_cache[:minus][start_index] = r0
1885
+
1886
+ r0
1887
+ end
1888
+
1889
+ module Star0
1890
+ def apply scope, a, b
1891
+ scope['_'] = a.eval(scope) * b.eval(scope)
1892
+ end
1893
+ end
1894
+
1895
+ def _nt_star
1896
+ start_index = index
1897
+ if node_cache[:star].has_key?(index)
1898
+ cached = node_cache[:star][index]
1899
+ if cached
1900
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1901
+ @index = cached.interval.end
1902
+ end
1903
+ return cached
1904
+ end
1905
+
1906
+ if has_terminal?('*', false, index)
1907
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1908
+ r0.extend(Star0)
1909
+ @index += 1
1910
+ else
1911
+ terminal_parse_failure('*')
1912
+ r0 = nil
1913
+ end
1914
+
1915
+ node_cache[:star][start_index] = r0
1916
+
1917
+ r0
1918
+ end
1919
+
1920
+ module Slash0
1921
+ def apply scope, a, b
1922
+ scope['_'] = a.eval(scope) / b.eval(scope)
1923
+ end
1924
+ end
1925
+
1926
+ def _nt_slash
1927
+ start_index = index
1928
+ if node_cache[:slash].has_key?(index)
1929
+ cached = node_cache[:slash][index]
1930
+ if cached
1931
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1932
+ @index = cached.interval.end
1933
+ end
1934
+ return cached
1935
+ end
1936
+
1937
+ if has_terminal?('/', false, index)
1938
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1939
+ r0.extend(Slash0)
1940
+ @index += 1
1941
+ else
1942
+ terminal_parse_failure('/')
1943
+ r0 = nil
1944
+ end
1945
+
1946
+ node_cache[:slash][start_index] = r0
1947
+
1948
+ r0
1949
+ end
1950
+
1951
+ def _nt_value
1952
+ start_index = index
1953
+ if node_cache[:value].has_key?(index)
1954
+ cached = node_cache[:value][index]
1955
+ if cached
1956
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1957
+ @index = cached.interval.end
1958
+ end
1959
+ return cached
1960
+ end
1961
+
1962
+ i0 = index
1963
+ r1 = _nt_number
1964
+ if r1
1965
+ r0 = r1
1966
+ else
1967
+ r2 = _nt_string
1968
+ if r2
1969
+ r0 = r2
1970
+ else
1971
+ r3 = _nt_truth
1972
+ if r3
1973
+ r0 = r3
1974
+ else
1975
+ r4 = _nt_lie
1976
+ if r4
1977
+ r0 = r4
1978
+ else
1979
+ r5 = _nt_nil
1980
+ if r5
1981
+ r0 = r5
1982
+ else
1983
+ @index = i0
1984
+ r0 = nil
1985
+ end
1986
+ end
1987
+ end
1988
+ end
1989
+ end
1990
+
1991
+ node_cache[:value][start_index] = r0
1992
+
1993
+ r0
1994
+ end
1995
+
1996
+ module Truth0
1997
+ def eval scope
1998
+ return true
1999
+ end
2000
+ end
2001
+
2002
+ def _nt_truth
2003
+ start_index = index
2004
+ if node_cache[:truth].has_key?(index)
2005
+ cached = node_cache[:truth][index]
2006
+ if cached
2007
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2008
+ @index = cached.interval.end
2009
+ end
2010
+ return cached
2011
+ end
2012
+
2013
+ if has_terminal?('true', false, index)
2014
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 4))
2015
+ r0.extend(Truth0)
2016
+ @index += 4
2017
+ else
2018
+ terminal_parse_failure('true')
2019
+ r0 = nil
2020
+ end
2021
+
2022
+ node_cache[:truth][start_index] = r0
2023
+
2024
+ r0
2025
+ end
2026
+
2027
+ module Lie0
2028
+ def eval scope
2029
+ return false
2030
+ end
2031
+ end
2032
+
2033
+ def _nt_lie
2034
+ start_index = index
2035
+ if node_cache[:lie].has_key?(index)
2036
+ cached = node_cache[:lie][index]
2037
+ if cached
2038
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2039
+ @index = cached.interval.end
2040
+ end
2041
+ return cached
2042
+ end
2043
+
2044
+ if has_terminal?('false', false, index)
2045
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 5))
2046
+ r0.extend(Lie0)
2047
+ @index += 5
2048
+ else
2049
+ terminal_parse_failure('false')
2050
+ r0 = nil
2051
+ end
2052
+
2053
+ node_cache[:lie][start_index] = r0
2054
+
2055
+ r0
2056
+ end
2057
+
2058
+ module Nil0
2059
+ def eval scope
2060
+ return nil
2061
+ end
2062
+ end
2063
+
2064
+ def _nt_nil
2065
+ start_index = index
2066
+ if node_cache[:nil].has_key?(index)
2067
+ cached = node_cache[:nil][index]
2068
+ if cached
2069
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2070
+ @index = cached.interval.end
2071
+ end
2072
+ return cached
2073
+ end
2074
+
2075
+ if has_terminal?('nil', false, index)
2076
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 3))
2077
+ r0.extend(Nil0)
2078
+ @index += 3
2079
+ else
2080
+ terminal_parse_failure('nil')
2081
+ r0 = nil
2082
+ end
2083
+
2084
+ node_cache[:nil][start_index] = r0
2085
+
2086
+ r0
2087
+ end
2088
+
2089
+ def _nt_string
2090
+ start_index = index
2091
+ if node_cache[:string].has_key?(index)
2092
+ cached = node_cache[:string][index]
2093
+ if cached
2094
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2095
+ @index = cached.interval.end
2096
+ end
2097
+ return cached
2098
+ end
2099
+
2100
+ i0 = index
2101
+ r1 = _nt_single_quote_string
2102
+ if r1
2103
+ r0 = r1
2104
+ else
2105
+ r2 = _nt_double_quote_string
2106
+ if r2
2107
+ r0 = r2
2108
+ else
2109
+ @index = i0
2110
+ r0 = nil
2111
+ end
2112
+ end
2113
+
2114
+ node_cache[:string][start_index] = r0
2115
+
2116
+ r0
2117
+ end
2118
+
2119
+ module SingleQuoteString0
2120
+ end
2121
+
2122
+ module SingleQuoteString1
2123
+ def content
2124
+ elements[1]
2125
+ end
2126
+
2127
+ end
2128
+
2129
+ module SingleQuoteString2
2130
+ def eval scope
2131
+ content.text_value.gsub '\\\'', "'"
2132
+ end
2133
+ end
2134
+
2135
+ def _nt_single_quote_string
2136
+ start_index = index
2137
+ if node_cache[:single_quote_string].has_key?(index)
2138
+ cached = node_cache[:single_quote_string][index]
2139
+ if cached
2140
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2141
+ @index = cached.interval.end
2142
+ end
2143
+ return cached
2144
+ end
2145
+
2146
+ i0, s0 = index, []
2147
+ if has_terminal?("'", false, index)
2148
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2149
+ @index += 1
2150
+ else
2151
+ terminal_parse_failure("'")
2152
+ r1 = nil
2153
+ end
2154
+ s0 << r1
2155
+ if r1
2156
+ s2, i2 = [], index
2157
+ loop do
2158
+ i3 = index
2159
+ if has_terminal?("\\'", false, index)
2160
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
2161
+ @index += 2
2162
+ else
2163
+ terminal_parse_failure("\\'")
2164
+ r4 = nil
2165
+ end
2166
+ if r4
2167
+ r3 = r4
2168
+ else
2169
+ i5, s5 = index, []
2170
+ i6 = index
2171
+ if has_terminal?("'", false, index)
2172
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2173
+ @index += 1
2174
+ else
2175
+ terminal_parse_failure("'")
2176
+ r7 = nil
2177
+ end
2178
+ if r7
2179
+ r6 = nil
2180
+ else
2181
+ @index = i6
2182
+ r6 = instantiate_node(SyntaxNode,input, index...index)
2183
+ end
2184
+ s5 << r6
2185
+ if r6
2186
+ if index < input_length
2187
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2188
+ @index += 1
2189
+ else
2190
+ terminal_parse_failure("any character")
2191
+ r8 = nil
2192
+ end
2193
+ s5 << r8
2194
+ end
2195
+ if s5.last
2196
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2197
+ r5.extend(SingleQuoteString0)
2198
+ else
2199
+ @index = i5
2200
+ r5 = nil
2201
+ end
2202
+ if r5
2203
+ r3 = r5
2204
+ else
2205
+ @index = i3
2206
+ r3 = nil
2207
+ end
2208
+ end
2209
+ if r3
2210
+ s2 << r3
2211
+ else
2212
+ break
2213
+ end
2214
+ end
2215
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2216
+ s0 << r2
2217
+ if r2
2218
+ if has_terminal?("'", false, index)
2219
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2220
+ @index += 1
2221
+ else
2222
+ terminal_parse_failure("'")
2223
+ r9 = nil
2224
+ end
2225
+ s0 << r9
2226
+ end
2227
+ end
2228
+ if s0.last
2229
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2230
+ r0.extend(SingleQuoteString1)
2231
+ r0.extend(SingleQuoteString2)
2232
+ else
2233
+ @index = i0
2234
+ r0 = nil
2235
+ end
2236
+
2237
+ node_cache[:single_quote_string][start_index] = r0
2238
+
2239
+ r0
2240
+ end
2241
+
2242
+ module DoubleQuoteString0
2243
+ end
2244
+
2245
+ module DoubleQuoteString1
2246
+ def content
2247
+ elements[1]
2248
+ end
2249
+
2250
+ end
2251
+
2252
+ module DoubleQuoteString2
2253
+ def eval scope
2254
+ content.text_value.gsub '\"', '"'
2255
+ end
2256
+ end
2257
+
2258
+ def _nt_double_quote_string
2259
+ start_index = index
2260
+ if node_cache[:double_quote_string].has_key?(index)
2261
+ cached = node_cache[:double_quote_string][index]
2262
+ if cached
2263
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2264
+ @index = cached.interval.end
2265
+ end
2266
+ return cached
2267
+ end
2268
+
2269
+ i0, s0 = index, []
2270
+ if has_terminal?('"', false, index)
2271
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2272
+ @index += 1
2273
+ else
2274
+ terminal_parse_failure('"')
2275
+ r1 = nil
2276
+ end
2277
+ s0 << r1
2278
+ if r1
2279
+ s2, i2 = [], index
2280
+ loop do
2281
+ i3 = index
2282
+ if has_terminal?('\"', false, index)
2283
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
2284
+ @index += 2
2285
+ else
2286
+ terminal_parse_failure('\"')
2287
+ r4 = nil
2288
+ end
2289
+ if r4
2290
+ r3 = r4
2291
+ else
2292
+ i5, s5 = index, []
2293
+ i6 = index
2294
+ if has_terminal?('"', false, index)
2295
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2296
+ @index += 1
2297
+ else
2298
+ terminal_parse_failure('"')
2299
+ r7 = nil
2300
+ end
2301
+ if r7
2302
+ r6 = nil
2303
+ else
2304
+ @index = i6
2305
+ r6 = instantiate_node(SyntaxNode,input, index...index)
2306
+ end
2307
+ s5 << r6
2308
+ if r6
2309
+ if index < input_length
2310
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2311
+ @index += 1
2312
+ else
2313
+ terminal_parse_failure("any character")
2314
+ r8 = nil
2315
+ end
2316
+ s5 << r8
2317
+ end
2318
+ if s5.last
2319
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2320
+ r5.extend(DoubleQuoteString0)
2321
+ else
2322
+ @index = i5
2323
+ r5 = nil
2324
+ end
2325
+ if r5
2326
+ r3 = r5
2327
+ else
2328
+ @index = i3
2329
+ r3 = nil
2330
+ end
2331
+ end
2332
+ if r3
2333
+ s2 << r3
2334
+ else
2335
+ break
2336
+ end
2337
+ end
2338
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2339
+ s0 << r2
2340
+ if r2
2341
+ if has_terminal?('"', false, index)
2342
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2343
+ @index += 1
2344
+ else
2345
+ terminal_parse_failure('"')
2346
+ r9 = nil
2347
+ end
2348
+ s0 << r9
2349
+ end
2350
+ end
2351
+ if s0.last
2352
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2353
+ r0.extend(DoubleQuoteString1)
2354
+ r0.extend(DoubleQuoteString2)
2355
+ else
2356
+ @index = i0
2357
+ r0 = nil
2358
+ end
2359
+
2360
+ node_cache[:double_quote_string][start_index] = r0
2361
+
2362
+ r0
2363
+ end
2364
+
2365
+ module Number0
2366
+ def point
2367
+ elements[1]
2368
+ end
2369
+
2370
+ end
2371
+
2372
+ module Number1
2373
+ def eval scope
2374
+ if point.empty?
2375
+ return scope['_'] = text_value.to_i
2376
+ end
2377
+
2378
+ scope['_'] = text_value.to_f
2379
+ end
2380
+ end
2381
+
2382
+ def _nt_number
2383
+ start_index = index
2384
+ if node_cache[:number].has_key?(index)
2385
+ cached = node_cache[:number][index]
2386
+ if cached
2387
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2388
+ @index = cached.interval.end
2389
+ end
2390
+ return cached
2391
+ end
2392
+
2393
+ i0, s0 = index, []
2394
+ s1, i1 = [], index
2395
+ loop do
2396
+ if has_terminal?('\G[0-9]', true, index)
2397
+ r2 = true
2398
+ @index += 1
2399
+ else
2400
+ r2 = nil
2401
+ end
2402
+ if r2
2403
+ s1 << r2
2404
+ else
2405
+ break
2406
+ end
2407
+ end
2408
+ if s1.empty?
2409
+ @index = i1
2410
+ r1 = nil
2411
+ else
2412
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2413
+ end
2414
+ s0 << r1
2415
+ if r1
2416
+ if has_terminal?('.', false, index)
2417
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2418
+ @index += 1
2419
+ else
2420
+ terminal_parse_failure('.')
2421
+ r4 = nil
2422
+ end
2423
+ if r4
2424
+ r3 = r4
2425
+ else
2426
+ r3 = instantiate_node(SyntaxNode,input, index...index)
2427
+ end
2428
+ s0 << r3
2429
+ if r3
2430
+ s5, i5 = [], index
2431
+ loop do
2432
+ if has_terminal?('\G[0-9]', true, index)
2433
+ r6 = true
2434
+ @index += 1
2435
+ else
2436
+ r6 = nil
2437
+ end
2438
+ if r6
2439
+ s5 << r6
2440
+ else
2441
+ break
2442
+ end
2443
+ end
2444
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2445
+ s0 << r5
2446
+ end
2447
+ end
2448
+ if s0.last
2449
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2450
+ r0.extend(Number0)
2451
+ r0.extend(Number1)
2452
+ else
2453
+ @index = i0
2454
+ r0 = nil
2455
+ end
2456
+
2457
+ node_cache[:number][start_index] = r0
2458
+
2459
+ r0
2460
+ end
2461
+
2462
+ module Identifier0
2463
+ end
2464
+
2465
+ module Identifier1
2466
+ def eval scope
2467
+ scope['_'] = scope[text_value]
2468
+ end
2469
+ end
2470
+
2471
+ def _nt_identifier
2472
+ start_index = index
2473
+ if node_cache[:identifier].has_key?(index)
2474
+ cached = node_cache[:identifier][index]
2475
+ if cached
2476
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2477
+ @index = cached.interval.end
2478
+ end
2479
+ return cached
2480
+ end
2481
+
2482
+ i0, s0 = index, []
2483
+ if has_terminal?('\G[a-zA-Z_]', true, index)
2484
+ r1 = true
2485
+ @index += 1
2486
+ else
2487
+ r1 = nil
2488
+ end
2489
+ s0 << r1
2490
+ if r1
2491
+ s2, i2 = [], index
2492
+ loop do
2493
+ if has_terminal?('\G[a-zA-Z0-9_]', true, index)
2494
+ r3 = true
2495
+ @index += 1
2496
+ else
2497
+ r3 = nil
2498
+ end
2499
+ if r3
2500
+ s2 << r3
2501
+ else
2502
+ break
2503
+ end
2504
+ end
2505
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2506
+ s0 << r2
2507
+ if r2
2508
+ i5 = index
2509
+ if has_terminal?('?', false, index)
2510
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
2511
+ @index += 1
2512
+ else
2513
+ terminal_parse_failure('?')
2514
+ r6 = nil
2515
+ end
2516
+ if r6
2517
+ r5 = r6
2518
+ else
2519
+ if has_terminal?('!', false, index)
2520
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2521
+ @index += 1
2522
+ else
2523
+ terminal_parse_failure('!')
2524
+ r7 = nil
2525
+ end
2526
+ if r7
2527
+ r5 = r7
2528
+ else
2529
+ @index = i5
2530
+ r5 = nil
2531
+ end
2532
+ end
2533
+ if r5
2534
+ r4 = r5
2535
+ else
2536
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2537
+ end
2538
+ s0 << r4
2539
+ end
2540
+ end
2541
+ if s0.last
2542
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2543
+ r0.extend(Identifier0)
2544
+ r0.extend(Identifier1)
2545
+ else
2546
+ @index = i0
2547
+ r0 = nil
2548
+ end
2549
+
2550
+ node_cache[:identifier][start_index] = r0
2551
+
2552
+ r0
2553
+ end
2554
+
2555
+ module Self0
2556
+ def eval scope
2557
+ scope.this
2558
+ end
2559
+ end
2560
+
2561
+ def _nt_self
2562
+ start_index = index
2563
+ if node_cache[:self].has_key?(index)
2564
+ cached = node_cache[:self][index]
2565
+ if cached
2566
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2567
+ @index = cached.interval.end
2568
+ end
2569
+ return cached
2570
+ end
2571
+
2572
+ if has_terminal?('@', false, index)
2573
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
2574
+ r0.extend(Self0)
2575
+ @index += 1
2576
+ else
2577
+ terminal_parse_failure('@')
2578
+ r0 = nil
2579
+ end
2580
+
2581
+ node_cache[:self][start_index] = r0
2582
+
2583
+ r0
2584
+ end
2585
+
2586
+ module Comment0
2587
+ end
2588
+
2589
+ module Comment1
2590
+ end
2591
+
2592
+ module Comment2
2593
+ def eval scope
2594
+ # NO-OP, this is a comment for crying out loud! (:
2595
+ end
2596
+ end
2597
+
2598
+ def _nt_comment
2599
+ start_index = index
2600
+ if node_cache[:comment].has_key?(index)
2601
+ cached = node_cache[:comment][index]
2602
+ if cached
2603
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2604
+ @index = cached.interval.end
2605
+ end
2606
+ return cached
2607
+ end
2608
+
2609
+ i0, s0 = index, []
2610
+ if has_terminal?('#', false, index)
2611
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2612
+ @index += 1
2613
+ else
2614
+ terminal_parse_failure('#')
2615
+ r1 = nil
2616
+ end
2617
+ s0 << r1
2618
+ if r1
2619
+ s2, i2 = [], index
2620
+ loop do
2621
+ i3, s3 = index, []
2622
+ i4 = index
2623
+ i5 = index
2624
+ if has_terminal?("\n", false, index)
2625
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
2626
+ @index += 1
2627
+ else
2628
+ terminal_parse_failure("\n")
2629
+ r6 = nil
2630
+ end
2631
+ if r6
2632
+ r5 = r6
2633
+ else
2634
+ if has_terminal?("\r", false, index)
2635
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2636
+ @index += 1
2637
+ else
2638
+ terminal_parse_failure("\r")
2639
+ r7 = nil
2640
+ end
2641
+ if r7
2642
+ r5 = r7
2643
+ else
2644
+ @index = i5
2645
+ r5 = nil
2646
+ end
2647
+ end
2648
+ if r5
2649
+ r4 = nil
2650
+ else
2651
+ @index = i4
2652
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2653
+ end
2654
+ s3 << r4
2655
+ if r4
2656
+ if index < input_length
2657
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2658
+ @index += 1
2659
+ else
2660
+ terminal_parse_failure("any character")
2661
+ r8 = nil
2662
+ end
2663
+ s3 << r8
2664
+ end
2665
+ if s3.last
2666
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2667
+ r3.extend(Comment0)
2668
+ else
2669
+ @index = i3
2670
+ r3 = nil
2671
+ end
2672
+ if r3
2673
+ s2 << r3
2674
+ else
2675
+ break
2676
+ end
2677
+ end
2678
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2679
+ s0 << r2
2680
+ if r2
2681
+ s9, i9 = [], index
2682
+ loop do
2683
+ i10 = index
2684
+ if has_terminal?("\n", false, index)
2685
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
2686
+ @index += 1
2687
+ else
2688
+ terminal_parse_failure("\n")
2689
+ r11 = nil
2690
+ end
2691
+ if r11
2692
+ r10 = r11
2693
+ else
2694
+ if has_terminal?("\r", false, index)
2695
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
2696
+ @index += 1
2697
+ else
2698
+ terminal_parse_failure("\r")
2699
+ r12 = nil
2700
+ end
2701
+ if r12
2702
+ r10 = r12
2703
+ else
2704
+ @index = i10
2705
+ r10 = nil
2706
+ end
2707
+ end
2708
+ if r10
2709
+ s9 << r10
2710
+ else
2711
+ break
2712
+ end
2713
+ end
2714
+ if s9.empty?
2715
+ @index = i9
2716
+ r9 = nil
2717
+ else
2718
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
2719
+ end
2720
+ s0 << r9
2721
+ end
2722
+ end
2723
+ if s0.last
2724
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
2725
+ r0.extend(Comment1)
2726
+ r0.extend(Comment2)
2727
+ else
2728
+ @index = i0
2729
+ r0 = nil
2730
+ end
2731
+
2732
+ node_cache[:comment][start_index] = r0
2733
+
2734
+ r0
2735
+ end
2736
+
2737
+ def _nt_ws
2738
+ start_index = index
2739
+ if node_cache[:ws].has_key?(index)
2740
+ cached = node_cache[:ws][index]
2741
+ if cached
2742
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2743
+ @index = cached.interval.end
2744
+ end
2745
+ return cached
2746
+ end
2747
+
2748
+ i0 = index
2749
+ if has_terminal?(' ', false, index)
2750
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2751
+ @index += 1
2752
+ else
2753
+ terminal_parse_failure(' ')
2754
+ r1 = nil
2755
+ end
2756
+ if r1
2757
+ r0 = r1
2758
+ else
2759
+ if has_terminal?("\n", false, index)
2760
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
2761
+ @index += 1
2762
+ else
2763
+ terminal_parse_failure("\n")
2764
+ r2 = nil
2765
+ end
2766
+ if r2
2767
+ r0 = r2
2768
+ else
2769
+ if has_terminal?("\r", false, index)
2770
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
2771
+ @index += 1
2772
+ else
2773
+ terminal_parse_failure("\r")
2774
+ r3 = nil
2775
+ end
2776
+ if r3
2777
+ r0 = r3
2778
+ else
2779
+ @index = i0
2780
+ r0 = nil
2781
+ end
2782
+ end
2783
+ end
2784
+
2785
+ node_cache[:ws][start_index] = r0
2786
+
2787
+ r0
2788
+ end
2789
+
2790
+ end
2791
+
2792
+ class QParser < Treetop::Runtime::CompiledParser
2793
+ include Q
2794
+ end
2795
+