Soroban 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ require 'treetop'
2
+
3
+ require 'soroban/parser/rewrite'
4
+ require 'soroban/parser/nodes'
5
+ require 'soroban/parser/grammar'
6
+
7
+ module Soroban
8
+
9
+ # A Treetop parser for Excel formulas that can generate valid Ruby expression
10
+ # via a rewrite operation, and which can build an array of referenced labels.
11
+ def self.parser
12
+ @@parser ||= SorobanParser.new
13
+ end
14
+
15
+ end
@@ -0,0 +1,1814 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Soroban
5
+ include Treetop::Runtime
6
+
7
+ def root
8
+ @root ||= :formula
9
+ end
10
+
11
+ module Formula0
12
+ def logical
13
+ elements[2]
14
+ end
15
+ end
16
+
17
+ def _nt_formula
18
+ start_index = index
19
+ if node_cache[:formula].has_key?(index)
20
+ cached = node_cache[:formula][index]
21
+ if cached
22
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
23
+ @index = cached.interval.end
24
+ end
25
+ return cached
26
+ end
27
+
28
+ i0 = index
29
+ i1, s1 = index, []
30
+ if has_terminal?('=', false, index)
31
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
32
+ @index += 1
33
+ else
34
+ terminal_parse_failure('=')
35
+ r2 = nil
36
+ end
37
+ s1 << r2
38
+ if r2
39
+ r4 = _nt_space
40
+ if r4
41
+ r3 = r4
42
+ else
43
+ r3 = instantiate_node(SyntaxNode,input, index...index)
44
+ end
45
+ s1 << r3
46
+ if r3
47
+ r5 = _nt_logical
48
+ s1 << r5
49
+ end
50
+ end
51
+ if s1.last
52
+ r1 = instantiate_node(Formula,input, i1...index, s1)
53
+ r1.extend(Formula0)
54
+ else
55
+ @index = i1
56
+ r1 = nil
57
+ end
58
+ if r1
59
+ r0 = r1
60
+ else
61
+ r6 = _nt_string
62
+ if r6
63
+ r0 = r6
64
+ else
65
+ r7 = _nt_number
66
+ if r7
67
+ r0 = r7
68
+ else
69
+ r8 = _nt_boolean
70
+ if r8
71
+ r0 = r8
72
+ else
73
+ @index = i0
74
+ r0 = nil
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ node_cache[:formula][start_index] = r0
81
+
82
+ r0
83
+ end
84
+
85
+ module Logical0
86
+ def and
87
+ elements[3]
88
+ end
89
+ end
90
+
91
+ module Logical1
92
+ def and
93
+ elements[0]
94
+ end
95
+
96
+ end
97
+
98
+ def _nt_logical
99
+ start_index = index
100
+ if node_cache[:logical].has_key?(index)
101
+ cached = node_cache[:logical][index]
102
+ if cached
103
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
104
+ @index = cached.interval.end
105
+ end
106
+ return cached
107
+ end
108
+
109
+ i0, s0 = index, []
110
+ r1 = _nt_and
111
+ s0 << r1
112
+ if r1
113
+ s2, i2 = [], index
114
+ loop do
115
+ i3, s3 = index, []
116
+ r5 = _nt_space
117
+ if r5
118
+ r4 = r5
119
+ else
120
+ r4 = instantiate_node(SyntaxNode,input, index...index)
121
+ end
122
+ s3 << r4
123
+ if r4
124
+ if has_terminal?('or', false, index)
125
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 2))
126
+ @index += 2
127
+ else
128
+ terminal_parse_failure('or')
129
+ r6 = nil
130
+ end
131
+ s3 << r6
132
+ if r6
133
+ r8 = _nt_space
134
+ if r8
135
+ r7 = r8
136
+ else
137
+ r7 = instantiate_node(SyntaxNode,input, index...index)
138
+ end
139
+ s3 << r7
140
+ if r7
141
+ r9 = _nt_and
142
+ s3 << r9
143
+ end
144
+ end
145
+ end
146
+ if s3.last
147
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
148
+ r3.extend(Logical0)
149
+ else
150
+ @index = i3
151
+ r3 = nil
152
+ end
153
+ if r3
154
+ s2 << r3
155
+ else
156
+ break
157
+ end
158
+ end
159
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
160
+ s0 << r2
161
+ end
162
+ if s0.last
163
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
164
+ r0.extend(Logical1)
165
+ else
166
+ @index = i0
167
+ r0 = nil
168
+ end
169
+
170
+ node_cache[:logical][start_index] = r0
171
+
172
+ r0
173
+ end
174
+
175
+ module And0
176
+ def truthval
177
+ elements[3]
178
+ end
179
+ end
180
+
181
+ module And1
182
+ def truthval
183
+ elements[0]
184
+ end
185
+
186
+ end
187
+
188
+ def _nt_and
189
+ start_index = index
190
+ if node_cache[:and].has_key?(index)
191
+ cached = node_cache[:and][index]
192
+ if cached
193
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
194
+ @index = cached.interval.end
195
+ end
196
+ return cached
197
+ end
198
+
199
+ i0, s0 = index, []
200
+ r1 = _nt_truthval
201
+ s0 << r1
202
+ if r1
203
+ s2, i2 = [], index
204
+ loop do
205
+ i3, s3 = index, []
206
+ r5 = _nt_space
207
+ if r5
208
+ r4 = r5
209
+ else
210
+ r4 = instantiate_node(SyntaxNode,input, index...index)
211
+ end
212
+ s3 << r4
213
+ if r4
214
+ if has_terminal?('and', false, index)
215
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 3))
216
+ @index += 3
217
+ else
218
+ terminal_parse_failure('and')
219
+ r6 = nil
220
+ end
221
+ s3 << r6
222
+ if r6
223
+ r8 = _nt_space
224
+ if r8
225
+ r7 = r8
226
+ else
227
+ r7 = instantiate_node(SyntaxNode,input, index...index)
228
+ end
229
+ s3 << r7
230
+ if r7
231
+ r9 = _nt_truthval
232
+ s3 << r9
233
+ end
234
+ end
235
+ end
236
+ if s3.last
237
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
238
+ r3.extend(And0)
239
+ else
240
+ @index = i3
241
+ r3 = nil
242
+ end
243
+ if r3
244
+ s2 << r3
245
+ else
246
+ break
247
+ end
248
+ end
249
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
250
+ s0 << r2
251
+ end
252
+ if s0.last
253
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
254
+ r0.extend(And1)
255
+ else
256
+ @index = i0
257
+ r0 = nil
258
+ end
259
+
260
+ node_cache[:and][start_index] = r0
261
+
262
+ r0
263
+ end
264
+
265
+ module Truthval0
266
+ def logical
267
+ elements[2]
268
+ end
269
+
270
+ end
271
+
272
+ def _nt_truthval
273
+ start_index = index
274
+ if node_cache[:truthval].has_key?(index)
275
+ cached = node_cache[:truthval][index]
276
+ if cached
277
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
278
+ @index = cached.interval.end
279
+ end
280
+ return cached
281
+ end
282
+
283
+ i0 = index
284
+ r1 = _nt_comparison
285
+ if r1
286
+ r0 = r1
287
+ else
288
+ i2, s2 = index, []
289
+ if has_terminal?('(', false, index)
290
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
291
+ @index += 1
292
+ else
293
+ terminal_parse_failure('(')
294
+ r3 = nil
295
+ end
296
+ s2 << r3
297
+ if r3
298
+ r5 = _nt_space
299
+ if r5
300
+ r4 = r5
301
+ else
302
+ r4 = instantiate_node(SyntaxNode,input, index...index)
303
+ end
304
+ s2 << r4
305
+ if r4
306
+ r6 = _nt_logical
307
+ s2 << r6
308
+ if r6
309
+ r8 = _nt_space
310
+ if r8
311
+ r7 = r8
312
+ else
313
+ r7 = instantiate_node(SyntaxNode,input, index...index)
314
+ end
315
+ s2 << r7
316
+ if r7
317
+ if has_terminal?(')', false, index)
318
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
319
+ @index += 1
320
+ else
321
+ terminal_parse_failure(')')
322
+ r9 = nil
323
+ end
324
+ s2 << r9
325
+ end
326
+ end
327
+ end
328
+ end
329
+ if s2.last
330
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
331
+ r2.extend(Truthval0)
332
+ else
333
+ @index = i2
334
+ r2 = nil
335
+ end
336
+ if r2
337
+ r0 = r2
338
+ else
339
+ r10 = _nt_boolean
340
+ if r10
341
+ r0 = r10
342
+ else
343
+ @index = i0
344
+ r0 = nil
345
+ end
346
+ end
347
+ end
348
+
349
+ node_cache[:truthval][start_index] = r0
350
+
351
+ r0
352
+ end
353
+
354
+ def _nt_boolean
355
+ start_index = index
356
+ if node_cache[:boolean].has_key?(index)
357
+ cached = node_cache[:boolean][index]
358
+ if cached
359
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
360
+ @index = cached.interval.end
361
+ end
362
+ return cached
363
+ end
364
+
365
+ i0 = index
366
+ if has_terminal?('true', false, index)
367
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 4))
368
+ @index += 4
369
+ else
370
+ terminal_parse_failure('true')
371
+ r1 = nil
372
+ end
373
+ if r1
374
+ r0 = r1
375
+ else
376
+ if has_terminal?('false', false, index)
377
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 5))
378
+ @index += 5
379
+ else
380
+ terminal_parse_failure('false')
381
+ r2 = nil
382
+ end
383
+ if r2
384
+ r0 = r2
385
+ else
386
+ if has_terminal?('TRUE', false, index)
387
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 4))
388
+ @index += 4
389
+ else
390
+ terminal_parse_failure('TRUE')
391
+ r3 = nil
392
+ end
393
+ if r3
394
+ r0 = r3
395
+ else
396
+ if has_terminal?('FALSE', false, index)
397
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 5))
398
+ @index += 5
399
+ else
400
+ terminal_parse_failure('FALSE')
401
+ r4 = nil
402
+ end
403
+ if r4
404
+ r0 = r4
405
+ else
406
+ @index = i0
407
+ r0 = nil
408
+ end
409
+ end
410
+ end
411
+ end
412
+
413
+ node_cache[:boolean][start_index] = r0
414
+
415
+ r0
416
+ end
417
+
418
+ module Comparison0
419
+ def comparator
420
+ elements[1]
421
+ end
422
+
423
+ def expression
424
+ elements[3]
425
+ end
426
+ end
427
+
428
+ module Comparison1
429
+ def expression
430
+ elements[0]
431
+ end
432
+
433
+ end
434
+
435
+ def _nt_comparison
436
+ start_index = index
437
+ if node_cache[:comparison].has_key?(index)
438
+ cached = node_cache[:comparison][index]
439
+ if cached
440
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
441
+ @index = cached.interval.end
442
+ end
443
+ return cached
444
+ end
445
+
446
+ i0, s0 = index, []
447
+ r1 = _nt_expression
448
+ s0 << r1
449
+ if r1
450
+ s2, i2 = [], index
451
+ loop do
452
+ i3, s3 = index, []
453
+ r5 = _nt_space
454
+ if r5
455
+ r4 = r5
456
+ else
457
+ r4 = instantiate_node(SyntaxNode,input, index...index)
458
+ end
459
+ s3 << r4
460
+ if r4
461
+ r6 = _nt_comparator
462
+ s3 << r6
463
+ if r6
464
+ r8 = _nt_space
465
+ if r8
466
+ r7 = r8
467
+ else
468
+ r7 = instantiate_node(SyntaxNode,input, index...index)
469
+ end
470
+ s3 << r7
471
+ if r7
472
+ r9 = _nt_expression
473
+ s3 << r9
474
+ end
475
+ end
476
+ end
477
+ if s3.last
478
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
479
+ r3.extend(Comparison0)
480
+ else
481
+ @index = i3
482
+ r3 = nil
483
+ end
484
+ if r3
485
+ s2 << r3
486
+ else
487
+ break
488
+ end
489
+ end
490
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
491
+ s0 << r2
492
+ end
493
+ if s0.last
494
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
495
+ r0.extend(Comparison1)
496
+ else
497
+ @index = i0
498
+ r0 = nil
499
+ end
500
+
501
+ node_cache[:comparison][start_index] = r0
502
+
503
+ r0
504
+ end
505
+
506
+ def _nt_comparator
507
+ start_index = index
508
+ if node_cache[:comparator].has_key?(index)
509
+ cached = node_cache[:comparator][index]
510
+ if cached
511
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
512
+ @index = cached.interval.end
513
+ end
514
+ return cached
515
+ end
516
+
517
+ i0 = index
518
+ if has_terminal?('=', false, index)
519
+ r1 = instantiate_node(Equal,input, index...(index + 1))
520
+ @index += 1
521
+ else
522
+ terminal_parse_failure('=')
523
+ r1 = nil
524
+ end
525
+ if r1
526
+ r0 = r1
527
+ else
528
+ if has_terminal?('<>', false, index)
529
+ r2 = instantiate_node(NotEqual,input, index...(index + 2))
530
+ @index += 2
531
+ else
532
+ terminal_parse_failure('<>')
533
+ r2 = nil
534
+ end
535
+ if r2
536
+ r0 = r2
537
+ else
538
+ if has_terminal?('>=', false, index)
539
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
540
+ @index += 2
541
+ else
542
+ terminal_parse_failure('>=')
543
+ r3 = nil
544
+ end
545
+ if r3
546
+ r0 = r3
547
+ else
548
+ if has_terminal?('<=', false, index)
549
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
550
+ @index += 2
551
+ else
552
+ terminal_parse_failure('<=')
553
+ r4 = nil
554
+ end
555
+ if r4
556
+ r0 = r4
557
+ else
558
+ if has_terminal?('>', false, index)
559
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
560
+ @index += 1
561
+ else
562
+ terminal_parse_failure('>')
563
+ r5 = nil
564
+ end
565
+ if r5
566
+ r0 = r5
567
+ else
568
+ if has_terminal?('<', false, index)
569
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
570
+ @index += 1
571
+ else
572
+ terminal_parse_failure('<')
573
+ r6 = nil
574
+ end
575
+ if r6
576
+ r0 = r6
577
+ else
578
+ @index = i0
579
+ r0 = nil
580
+ end
581
+ end
582
+ end
583
+ end
584
+ end
585
+ end
586
+
587
+ node_cache[:comparator][start_index] = r0
588
+
589
+ r0
590
+ end
591
+
592
+ module Expression0
593
+ def additive_operator
594
+ elements[1]
595
+ end
596
+
597
+ def multiplicative
598
+ elements[3]
599
+ end
600
+ end
601
+
602
+ module Expression1
603
+ def multiplicative
604
+ elements[0]
605
+ end
606
+
607
+ end
608
+
609
+ def _nt_expression
610
+ start_index = index
611
+ if node_cache[:expression].has_key?(index)
612
+ cached = node_cache[:expression][index]
613
+ if cached
614
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
615
+ @index = cached.interval.end
616
+ end
617
+ return cached
618
+ end
619
+
620
+ i0, s0 = index, []
621
+ r1 = _nt_multiplicative
622
+ s0 << r1
623
+ if r1
624
+ s2, i2 = [], index
625
+ loop do
626
+ i3, s3 = index, []
627
+ r5 = _nt_space
628
+ if r5
629
+ r4 = r5
630
+ else
631
+ r4 = instantiate_node(SyntaxNode,input, index...index)
632
+ end
633
+ s3 << r4
634
+ if r4
635
+ r6 = _nt_additive_operator
636
+ s3 << r6
637
+ if r6
638
+ r8 = _nt_space
639
+ if r8
640
+ r7 = r8
641
+ else
642
+ r7 = instantiate_node(SyntaxNode,input, index...index)
643
+ end
644
+ s3 << r7
645
+ if r7
646
+ r9 = _nt_multiplicative
647
+ s3 << r9
648
+ end
649
+ end
650
+ end
651
+ if s3.last
652
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
653
+ r3.extend(Expression0)
654
+ else
655
+ @index = i3
656
+ r3 = nil
657
+ end
658
+ if r3
659
+ s2 << r3
660
+ else
661
+ break
662
+ end
663
+ end
664
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
665
+ s0 << r2
666
+ end
667
+ if s0.last
668
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
669
+ r0.extend(Expression1)
670
+ else
671
+ @index = i0
672
+ r0 = nil
673
+ end
674
+
675
+ node_cache[:expression][start_index] = r0
676
+
677
+ r0
678
+ end
679
+
680
+ def _nt_additive_operator
681
+ start_index = index
682
+ if node_cache[:additive_operator].has_key?(index)
683
+ cached = node_cache[:additive_operator][index]
684
+ if cached
685
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
686
+ @index = cached.interval.end
687
+ end
688
+ return cached
689
+ end
690
+
691
+ i0 = index
692
+ if has_terminal?('+', false, index)
693
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
694
+ @index += 1
695
+ else
696
+ terminal_parse_failure('+')
697
+ r1 = nil
698
+ end
699
+ if r1
700
+ r0 = r1
701
+ else
702
+ if has_terminal?('-', false, index)
703
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
704
+ @index += 1
705
+ else
706
+ terminal_parse_failure('-')
707
+ r2 = nil
708
+ end
709
+ if r2
710
+ r0 = r2
711
+ else
712
+ @index = i0
713
+ r0 = nil
714
+ end
715
+ end
716
+
717
+ node_cache[:additive_operator][start_index] = r0
718
+
719
+ r0
720
+ end
721
+
722
+ module Multiplicative0
723
+ def multiplicative_operator
724
+ elements[1]
725
+ end
726
+
727
+ def value
728
+ elements[3]
729
+ end
730
+ end
731
+
732
+ module Multiplicative1
733
+ def value
734
+ elements[0]
735
+ end
736
+
737
+ end
738
+
739
+ def _nt_multiplicative
740
+ start_index = index
741
+ if node_cache[:multiplicative].has_key?(index)
742
+ cached = node_cache[:multiplicative][index]
743
+ if cached
744
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
745
+ @index = cached.interval.end
746
+ end
747
+ return cached
748
+ end
749
+
750
+ i0, s0 = index, []
751
+ r1 = _nt_value
752
+ s0 << r1
753
+ if r1
754
+ s2, i2 = [], index
755
+ loop do
756
+ i3, s3 = index, []
757
+ r5 = _nt_space
758
+ if r5
759
+ r4 = r5
760
+ else
761
+ r4 = instantiate_node(SyntaxNode,input, index...index)
762
+ end
763
+ s3 << r4
764
+ if r4
765
+ r6 = _nt_multiplicative_operator
766
+ s3 << r6
767
+ if r6
768
+ r8 = _nt_space
769
+ if r8
770
+ r7 = r8
771
+ else
772
+ r7 = instantiate_node(SyntaxNode,input, index...index)
773
+ end
774
+ s3 << r7
775
+ if r7
776
+ r9 = _nt_value
777
+ s3 << r9
778
+ end
779
+ end
780
+ end
781
+ if s3.last
782
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
783
+ r3.extend(Multiplicative0)
784
+ else
785
+ @index = i3
786
+ r3 = nil
787
+ end
788
+ if r3
789
+ s2 << r3
790
+ else
791
+ break
792
+ end
793
+ end
794
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
795
+ s0 << r2
796
+ end
797
+ if s0.last
798
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
799
+ r0.extend(Multiplicative1)
800
+ else
801
+ @index = i0
802
+ r0 = nil
803
+ end
804
+
805
+ node_cache[:multiplicative][start_index] = r0
806
+
807
+ r0
808
+ end
809
+
810
+ def _nt_multiplicative_operator
811
+ start_index = index
812
+ if node_cache[:multiplicative_operator].has_key?(index)
813
+ cached = node_cache[:multiplicative_operator][index]
814
+ if cached
815
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
816
+ @index = cached.interval.end
817
+ end
818
+ return cached
819
+ end
820
+
821
+ i0 = index
822
+ if has_terminal?('^', false, index)
823
+ r1 = instantiate_node(Pow,input, index...(index + 1))
824
+ @index += 1
825
+ else
826
+ terminal_parse_failure('^')
827
+ r1 = nil
828
+ end
829
+ if r1
830
+ r0 = r1
831
+ else
832
+ if has_terminal?('*', false, index)
833
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
834
+ @index += 1
835
+ else
836
+ terminal_parse_failure('*')
837
+ r2 = nil
838
+ end
839
+ if r2
840
+ r0 = r2
841
+ else
842
+ if has_terminal?('/', false, index)
843
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
844
+ @index += 1
845
+ else
846
+ terminal_parse_failure('/')
847
+ r3 = nil
848
+ end
849
+ if r3
850
+ r0 = r3
851
+ else
852
+ @index = i0
853
+ r0 = nil
854
+ end
855
+ end
856
+ end
857
+
858
+ node_cache[:multiplicative_operator][start_index] = r0
859
+
860
+ r0
861
+ end
862
+
863
+ module Value0
864
+ def expression
865
+ elements[2]
866
+ end
867
+
868
+ end
869
+
870
+ module Value1
871
+ def value
872
+ elements[1]
873
+ end
874
+ end
875
+
876
+ def _nt_value
877
+ start_index = index
878
+ if node_cache[:value].has_key?(index)
879
+ cached = node_cache[:value][index]
880
+ if cached
881
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
882
+ @index = cached.interval.end
883
+ end
884
+ return cached
885
+ end
886
+
887
+ i0 = index
888
+ r1 = _nt_function
889
+ if r1
890
+ r0 = r1
891
+ else
892
+ i2, s2 = index, []
893
+ if has_terminal?('(', false, index)
894
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
895
+ @index += 1
896
+ else
897
+ terminal_parse_failure('(')
898
+ r3 = nil
899
+ end
900
+ s2 << r3
901
+ if r3
902
+ r5 = _nt_space
903
+ if r5
904
+ r4 = r5
905
+ else
906
+ r4 = instantiate_node(SyntaxNode,input, index...index)
907
+ end
908
+ s2 << r4
909
+ if r4
910
+ r6 = _nt_expression
911
+ s2 << r6
912
+ if r6
913
+ r8 = _nt_space
914
+ if r8
915
+ r7 = r8
916
+ else
917
+ r7 = instantiate_node(SyntaxNode,input, index...index)
918
+ end
919
+ s2 << r7
920
+ if r7
921
+ if has_terminal?(')', false, index)
922
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
923
+ @index += 1
924
+ else
925
+ terminal_parse_failure(')')
926
+ r9 = nil
927
+ end
928
+ s2 << r9
929
+ end
930
+ end
931
+ end
932
+ end
933
+ if s2.last
934
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
935
+ r2.extend(Value0)
936
+ else
937
+ @index = i2
938
+ r2 = nil
939
+ end
940
+ if r2
941
+ r0 = r2
942
+ else
943
+ r10 = _nt_range
944
+ if r10
945
+ r0 = r10
946
+ else
947
+ r11 = _nt_number
948
+ if r11
949
+ r0 = r11
950
+ else
951
+ r12 = _nt_boolean
952
+ if r12
953
+ r0 = r12
954
+ else
955
+ r13 = _nt_identifier
956
+ if r13
957
+ r0 = r13
958
+ else
959
+ r14 = _nt_string
960
+ if r14
961
+ r0 = r14
962
+ else
963
+ i15, s15 = index, []
964
+ if has_terminal?('-', false, index)
965
+ r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
966
+ @index += 1
967
+ else
968
+ terminal_parse_failure('-')
969
+ r16 = nil
970
+ end
971
+ s15 << r16
972
+ if r16
973
+ r17 = _nt_value
974
+ s15 << r17
975
+ end
976
+ if s15.last
977
+ r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
978
+ r15.extend(Value1)
979
+ else
980
+ @index = i15
981
+ r15 = nil
982
+ end
983
+ if r15
984
+ r0 = r15
985
+ else
986
+ @index = i0
987
+ r0 = nil
988
+ end
989
+ end
990
+ end
991
+ end
992
+ end
993
+ end
994
+ end
995
+ end
996
+
997
+ node_cache[:value][start_index] = r0
998
+
999
+ r0
1000
+ end
1001
+
1002
+ module Function0
1003
+ end
1004
+
1005
+ def _nt_function
1006
+ start_index = index
1007
+ if node_cache[:function].has_key?(index)
1008
+ cached = node_cache[:function][index]
1009
+ if cached
1010
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1011
+ @index = cached.interval.end
1012
+ end
1013
+ return cached
1014
+ end
1015
+
1016
+ i0, s0 = index, []
1017
+ s1, i1 = [], index
1018
+ loop do
1019
+ if has_terminal?('\G[a-zA-Z]', true, index)
1020
+ r2 = true
1021
+ @index += 1
1022
+ else
1023
+ r2 = nil
1024
+ end
1025
+ if r2
1026
+ s1 << r2
1027
+ else
1028
+ break
1029
+ end
1030
+ end
1031
+ if s1.empty?
1032
+ @index = i1
1033
+ r1 = nil
1034
+ else
1035
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1036
+ end
1037
+ s0 << r1
1038
+ if r1
1039
+ if has_terminal?('(', false, index)
1040
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
1041
+ @index += 1
1042
+ else
1043
+ terminal_parse_failure('(')
1044
+ r3 = nil
1045
+ end
1046
+ s0 << r3
1047
+ if r3
1048
+ r5 = _nt_space
1049
+ if r5
1050
+ r4 = r5
1051
+ else
1052
+ r4 = instantiate_node(SyntaxNode,input, index...index)
1053
+ end
1054
+ s0 << r4
1055
+ if r4
1056
+ r7 = _nt_arguments
1057
+ if r7
1058
+ r6 = r7
1059
+ else
1060
+ r6 = instantiate_node(SyntaxNode,input, index...index)
1061
+ end
1062
+ s0 << r6
1063
+ if r6
1064
+ r9 = _nt_space
1065
+ if r9
1066
+ r8 = r9
1067
+ else
1068
+ r8 = instantiate_node(SyntaxNode,input, index...index)
1069
+ end
1070
+ s0 << r8
1071
+ if r8
1072
+ if has_terminal?(')', false, index)
1073
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
1074
+ @index += 1
1075
+ else
1076
+ terminal_parse_failure(')')
1077
+ r10 = nil
1078
+ end
1079
+ s0 << r10
1080
+ end
1081
+ end
1082
+ end
1083
+ end
1084
+ end
1085
+ if s0.last
1086
+ r0 = instantiate_node(Function,input, i0...index, s0)
1087
+ r0.extend(Function0)
1088
+ else
1089
+ @index = i0
1090
+ r0 = nil
1091
+ end
1092
+
1093
+ node_cache[:function][start_index] = r0
1094
+
1095
+ r0
1096
+ end
1097
+
1098
+ module Arguments0
1099
+ def logical
1100
+ elements[3]
1101
+ end
1102
+ end
1103
+
1104
+ module Arguments1
1105
+ def logical
1106
+ elements[0]
1107
+ end
1108
+
1109
+ end
1110
+
1111
+ def _nt_arguments
1112
+ start_index = index
1113
+ if node_cache[:arguments].has_key?(index)
1114
+ cached = node_cache[:arguments][index]
1115
+ if cached
1116
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1117
+ @index = cached.interval.end
1118
+ end
1119
+ return cached
1120
+ end
1121
+
1122
+ i0, s0 = index, []
1123
+ r1 = _nt_logical
1124
+ s0 << r1
1125
+ if r1
1126
+ s2, i2 = [], index
1127
+ loop do
1128
+ i3, s3 = index, []
1129
+ r5 = _nt_space
1130
+ if r5
1131
+ r4 = r5
1132
+ else
1133
+ r4 = instantiate_node(SyntaxNode,input, index...index)
1134
+ end
1135
+ s3 << r4
1136
+ if r4
1137
+ if has_terminal?(',', false, index)
1138
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
1139
+ @index += 1
1140
+ else
1141
+ terminal_parse_failure(',')
1142
+ r6 = nil
1143
+ end
1144
+ s3 << r6
1145
+ if r6
1146
+ r8 = _nt_space
1147
+ if r8
1148
+ r7 = r8
1149
+ else
1150
+ r7 = instantiate_node(SyntaxNode,input, index...index)
1151
+ end
1152
+ s3 << r7
1153
+ if r7
1154
+ r9 = _nt_logical
1155
+ s3 << r9
1156
+ end
1157
+ end
1158
+ end
1159
+ if s3.last
1160
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
1161
+ r3.extend(Arguments0)
1162
+ else
1163
+ @index = i3
1164
+ r3 = nil
1165
+ end
1166
+ if r3
1167
+ s2 << r3
1168
+ else
1169
+ break
1170
+ end
1171
+ end
1172
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1173
+ s0 << r2
1174
+ end
1175
+ if s0.last
1176
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1177
+ r0.extend(Arguments1)
1178
+ else
1179
+ @index = i0
1180
+ r0 = nil
1181
+ end
1182
+
1183
+ node_cache[:arguments][start_index] = r0
1184
+
1185
+ r0
1186
+ end
1187
+
1188
+ def _nt_number
1189
+ start_index = index
1190
+ if node_cache[:number].has_key?(index)
1191
+ cached = node_cache[:number][index]
1192
+ if cached
1193
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1194
+ @index = cached.interval.end
1195
+ end
1196
+ return cached
1197
+ end
1198
+
1199
+ i0 = index
1200
+ r1 = _nt_float
1201
+ if r1
1202
+ r0 = r1
1203
+ else
1204
+ r2 = _nt_integer
1205
+ if r2
1206
+ r0 = r2
1207
+ else
1208
+ @index = i0
1209
+ r0 = nil
1210
+ end
1211
+ end
1212
+
1213
+ node_cache[:number][start_index] = r0
1214
+
1215
+ r0
1216
+ end
1217
+
1218
+ module Float0
1219
+ end
1220
+
1221
+ def _nt_float
1222
+ start_index = index
1223
+ if node_cache[:float].has_key?(index)
1224
+ cached = node_cache[:float][index]
1225
+ if cached
1226
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1227
+ @index = cached.interval.end
1228
+ end
1229
+ return cached
1230
+ end
1231
+
1232
+ i0, s0 = index, []
1233
+ s1, i1 = [], index
1234
+ loop do
1235
+ if has_terminal?('\G[0-9]', true, index)
1236
+ r2 = true
1237
+ @index += 1
1238
+ else
1239
+ r2 = nil
1240
+ end
1241
+ if r2
1242
+ s1 << r2
1243
+ else
1244
+ break
1245
+ end
1246
+ end
1247
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1248
+ s0 << r1
1249
+ if r1
1250
+ if has_terminal?('.', false, index)
1251
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
1252
+ @index += 1
1253
+ else
1254
+ terminal_parse_failure('.')
1255
+ r3 = nil
1256
+ end
1257
+ s0 << r3
1258
+ if r3
1259
+ s4, i4 = [], index
1260
+ loop do
1261
+ if has_terminal?('\G[0-9]', true, index)
1262
+ r5 = true
1263
+ @index += 1
1264
+ else
1265
+ r5 = nil
1266
+ end
1267
+ if r5
1268
+ s4 << r5
1269
+ else
1270
+ break
1271
+ end
1272
+ end
1273
+ if s4.empty?
1274
+ @index = i4
1275
+ r4 = nil
1276
+ else
1277
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1278
+ end
1279
+ s0 << r4
1280
+ end
1281
+ end
1282
+ if s0.last
1283
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1284
+ r0.extend(Float0)
1285
+ else
1286
+ @index = i0
1287
+ r0 = nil
1288
+ end
1289
+
1290
+ node_cache[:float][start_index] = r0
1291
+
1292
+ r0
1293
+ end
1294
+
1295
+ def _nt_integer
1296
+ start_index = index
1297
+ if node_cache[:integer].has_key?(index)
1298
+ cached = node_cache[:integer][index]
1299
+ if cached
1300
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1301
+ @index = cached.interval.end
1302
+ end
1303
+ return cached
1304
+ end
1305
+
1306
+ s0, i0 = [], index
1307
+ loop do
1308
+ if has_terminal?('\G[0-9]', true, index)
1309
+ r1 = true
1310
+ @index += 1
1311
+ else
1312
+ r1 = nil
1313
+ end
1314
+ if r1
1315
+ s0 << r1
1316
+ else
1317
+ break
1318
+ end
1319
+ end
1320
+ if s0.empty?
1321
+ @index = i0
1322
+ r0 = nil
1323
+ else
1324
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1325
+ end
1326
+
1327
+ node_cache[:integer][start_index] = r0
1328
+
1329
+ r0
1330
+ end
1331
+
1332
+ module Identifier0
1333
+ end
1334
+
1335
+ def _nt_identifier
1336
+ start_index = index
1337
+ if node_cache[:identifier].has_key?(index)
1338
+ cached = node_cache[:identifier][index]
1339
+ if cached
1340
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1341
+ @index = cached.interval.end
1342
+ end
1343
+ return cached
1344
+ end
1345
+
1346
+ i0, s0 = index, []
1347
+ if has_terminal?('\G[a-zA-Z]', true, index)
1348
+ r1 = true
1349
+ @index += 1
1350
+ else
1351
+ r1 = nil
1352
+ end
1353
+ s0 << r1
1354
+ if r1
1355
+ s2, i2 = [], index
1356
+ loop do
1357
+ if has_terminal?('\G[a-zA-Z0-9]', true, index)
1358
+ r3 = true
1359
+ @index += 1
1360
+ else
1361
+ r3 = nil
1362
+ end
1363
+ if r3
1364
+ s2 << r3
1365
+ else
1366
+ break
1367
+ end
1368
+ end
1369
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1370
+ s0 << r2
1371
+ end
1372
+ if s0.last
1373
+ r0 = instantiate_node(Identifier,input, i0...index, s0)
1374
+ r0.extend(Identifier0)
1375
+ else
1376
+ @index = i0
1377
+ r0 = nil
1378
+ end
1379
+
1380
+ node_cache[:identifier][start_index] = r0
1381
+
1382
+ r0
1383
+ end
1384
+
1385
+ module Label0
1386
+ end
1387
+
1388
+ module Label1
1389
+ end
1390
+
1391
+ def _nt_label
1392
+ start_index = index
1393
+ if node_cache[:label].has_key?(index)
1394
+ cached = node_cache[:label][index]
1395
+ if cached
1396
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1397
+ @index = cached.interval.end
1398
+ end
1399
+ return cached
1400
+ end
1401
+
1402
+ i0 = index
1403
+ i1, s1 = index, []
1404
+ s2, i2 = [], index
1405
+ loop do
1406
+ if has_terminal?('\G[A-Za-z]', true, index)
1407
+ r3 = true
1408
+ @index += 1
1409
+ else
1410
+ r3 = nil
1411
+ end
1412
+ if r3
1413
+ s2 << r3
1414
+ else
1415
+ break
1416
+ end
1417
+ end
1418
+ if s2.empty?
1419
+ @index = i2
1420
+ r2 = nil
1421
+ else
1422
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1423
+ end
1424
+ s1 << r2
1425
+ if r2
1426
+ if has_terminal?('\G[1-9]', true, index)
1427
+ r4 = true
1428
+ @index += 1
1429
+ else
1430
+ r4 = nil
1431
+ end
1432
+ s1 << r4
1433
+ if r4
1434
+ s5, i5 = [], index
1435
+ loop do
1436
+ if has_terminal?('\G[0-9]', true, index)
1437
+ r6 = true
1438
+ @index += 1
1439
+ else
1440
+ r6 = nil
1441
+ end
1442
+ if r6
1443
+ s5 << r6
1444
+ else
1445
+ break
1446
+ end
1447
+ end
1448
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1449
+ s1 << r5
1450
+ end
1451
+ end
1452
+ if s1.last
1453
+ r1 = instantiate_node(Label,input, i1...index, s1)
1454
+ r1.extend(Label0)
1455
+ else
1456
+ @index = i1
1457
+ r1 = nil
1458
+ end
1459
+ if r1
1460
+ r0 = r1
1461
+ else
1462
+ i7, s7 = index, []
1463
+ if has_terminal?('$', false, index)
1464
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
1465
+ @index += 1
1466
+ else
1467
+ terminal_parse_failure('$')
1468
+ r8 = nil
1469
+ end
1470
+ s7 << r8
1471
+ if r8
1472
+ s9, i9 = [], index
1473
+ loop do
1474
+ if has_terminal?('\G[A-Za-z]', true, index)
1475
+ r10 = true
1476
+ @index += 1
1477
+ else
1478
+ r10 = nil
1479
+ end
1480
+ if r10
1481
+ s9 << r10
1482
+ else
1483
+ break
1484
+ end
1485
+ end
1486
+ if s9.empty?
1487
+ @index = i9
1488
+ r9 = nil
1489
+ else
1490
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1491
+ end
1492
+ s7 << r9
1493
+ if r9
1494
+ if has_terminal?('$', false, index)
1495
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
1496
+ @index += 1
1497
+ else
1498
+ terminal_parse_failure('$')
1499
+ r11 = nil
1500
+ end
1501
+ s7 << r11
1502
+ if r11
1503
+ if has_terminal?('\G[1-9]', true, index)
1504
+ r12 = true
1505
+ @index += 1
1506
+ else
1507
+ r12 = nil
1508
+ end
1509
+ s7 << r12
1510
+ if r12
1511
+ s13, i13 = [], index
1512
+ loop do
1513
+ if has_terminal?('\G[0-9]', true, index)
1514
+ r14 = true
1515
+ @index += 1
1516
+ else
1517
+ r14 = nil
1518
+ end
1519
+ if r14
1520
+ s13 << r14
1521
+ else
1522
+ break
1523
+ end
1524
+ end
1525
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1526
+ s7 << r13
1527
+ end
1528
+ end
1529
+ end
1530
+ end
1531
+ if s7.last
1532
+ r7 = instantiate_node(Label,input, i7...index, s7)
1533
+ r7.extend(Label1)
1534
+ else
1535
+ @index = i7
1536
+ r7 = nil
1537
+ end
1538
+ if r7
1539
+ r0 = r7
1540
+ else
1541
+ @index = i0
1542
+ r0 = nil
1543
+ end
1544
+ end
1545
+
1546
+ node_cache[:label][start_index] = r0
1547
+
1548
+ r0
1549
+ end
1550
+
1551
+ module String0
1552
+ end
1553
+
1554
+ module String1
1555
+ end
1556
+
1557
+ module String2
1558
+ end
1559
+
1560
+ def _nt_string
1561
+ start_index = index
1562
+ if node_cache[:string].has_key?(index)
1563
+ cached = node_cache[:string][index]
1564
+ if cached
1565
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1566
+ @index = cached.interval.end
1567
+ end
1568
+ return cached
1569
+ end
1570
+
1571
+ i0 = index
1572
+ i1, s1 = index, []
1573
+ if has_terminal?('"', false, index)
1574
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
1575
+ @index += 1
1576
+ else
1577
+ terminal_parse_failure('"')
1578
+ r2 = nil
1579
+ end
1580
+ s1 << r2
1581
+ if r2
1582
+ s3, i3 = [], index
1583
+ loop do
1584
+ i4 = index
1585
+ if has_terminal?('\"', false, index)
1586
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
1587
+ @index += 2
1588
+ else
1589
+ terminal_parse_failure('\"')
1590
+ r5 = nil
1591
+ end
1592
+ if r5
1593
+ r4 = r5
1594
+ else
1595
+ i6, s6 = index, []
1596
+ i7 = index
1597
+ if has_terminal?('"', false, index)
1598
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
1599
+ @index += 1
1600
+ else
1601
+ terminal_parse_failure('"')
1602
+ r8 = nil
1603
+ end
1604
+ if r8
1605
+ r7 = nil
1606
+ else
1607
+ @index = i7
1608
+ r7 = instantiate_node(SyntaxNode,input, index...index)
1609
+ end
1610
+ s6 << r7
1611
+ if r7
1612
+ if index < input_length
1613
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
1614
+ @index += 1
1615
+ else
1616
+ terminal_parse_failure("any character")
1617
+ r9 = nil
1618
+ end
1619
+ s6 << r9
1620
+ end
1621
+ if s6.last
1622
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
1623
+ r6.extend(String0)
1624
+ else
1625
+ @index = i6
1626
+ r6 = nil
1627
+ end
1628
+ if r6
1629
+ r4 = r6
1630
+ else
1631
+ @index = i4
1632
+ r4 = nil
1633
+ end
1634
+ end
1635
+ if r4
1636
+ s3 << r4
1637
+ else
1638
+ break
1639
+ end
1640
+ end
1641
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
1642
+ s1 << r3
1643
+ if r3
1644
+ if has_terminal?('"', false, index)
1645
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
1646
+ @index += 1
1647
+ else
1648
+ terminal_parse_failure('"')
1649
+ r10 = nil
1650
+ end
1651
+ s1 << r10
1652
+ end
1653
+ end
1654
+ if s1.last
1655
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1656
+ r1.extend(String1)
1657
+ else
1658
+ @index = i1
1659
+ r1 = nil
1660
+ end
1661
+ if r1
1662
+ r0 = r1
1663
+ else
1664
+ i11, s11 = index, []
1665
+ if has_terminal?("'", false, index)
1666
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
1667
+ @index += 1
1668
+ else
1669
+ terminal_parse_failure("'")
1670
+ r12 = nil
1671
+ end
1672
+ s11 << r12
1673
+ if r12
1674
+ s13, i13 = [], index
1675
+ loop do
1676
+ if has_terminal?('\G[^\']', true, index)
1677
+ r14 = true
1678
+ @index += 1
1679
+ else
1680
+ r14 = nil
1681
+ end
1682
+ if r14
1683
+ s13 << r14
1684
+ else
1685
+ break
1686
+ end
1687
+ end
1688
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1689
+ s11 << r13
1690
+ if r13
1691
+ if has_terminal?("'", false, index)
1692
+ r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
1693
+ @index += 1
1694
+ else
1695
+ terminal_parse_failure("'")
1696
+ r15 = nil
1697
+ end
1698
+ s11 << r15
1699
+ end
1700
+ end
1701
+ if s11.last
1702
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
1703
+ r11.extend(String2)
1704
+ else
1705
+ @index = i11
1706
+ r11 = nil
1707
+ end
1708
+ if r11
1709
+ r0 = r11
1710
+ else
1711
+ @index = i0
1712
+ r0 = nil
1713
+ end
1714
+ end
1715
+
1716
+ node_cache[:string][start_index] = r0
1717
+
1718
+ r0
1719
+ end
1720
+
1721
+ module Range0
1722
+ def label1
1723
+ elements[0]
1724
+ end
1725
+
1726
+ def label2
1727
+ elements[2]
1728
+ end
1729
+ end
1730
+
1731
+ def _nt_range
1732
+ start_index = index
1733
+ if node_cache[:range].has_key?(index)
1734
+ cached = node_cache[:range][index]
1735
+ if cached
1736
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1737
+ @index = cached.interval.end
1738
+ end
1739
+ return cached
1740
+ end
1741
+
1742
+ i0, s0 = index, []
1743
+ r1 = _nt_label
1744
+ s0 << r1
1745
+ if r1
1746
+ if has_terminal?(':', false, index)
1747
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
1748
+ @index += 1
1749
+ else
1750
+ terminal_parse_failure(':')
1751
+ r2 = nil
1752
+ end
1753
+ s0 << r2
1754
+ if r2
1755
+ r3 = _nt_label
1756
+ s0 << r3
1757
+ end
1758
+ end
1759
+ if s0.last
1760
+ r0 = instantiate_node(Range,input, i0...index, s0)
1761
+ r0.extend(Range0)
1762
+ else
1763
+ @index = i0
1764
+ r0 = nil
1765
+ end
1766
+
1767
+ node_cache[:range][start_index] = r0
1768
+
1769
+ r0
1770
+ end
1771
+
1772
+ def _nt_space
1773
+ start_index = index
1774
+ if node_cache[:space].has_key?(index)
1775
+ cached = node_cache[:space][index]
1776
+ if cached
1777
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1778
+ @index = cached.interval.end
1779
+ end
1780
+ return cached
1781
+ end
1782
+
1783
+ s0, i0 = [], index
1784
+ loop do
1785
+ if has_terminal?('\G[\\s]', true, index)
1786
+ r1 = true
1787
+ @index += 1
1788
+ else
1789
+ r1 = nil
1790
+ end
1791
+ if r1
1792
+ s0 << r1
1793
+ else
1794
+ break
1795
+ end
1796
+ end
1797
+ if s0.empty?
1798
+ @index = i0
1799
+ r0 = nil
1800
+ else
1801
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1802
+ end
1803
+
1804
+ node_cache[:space][start_index] = r0
1805
+
1806
+ r0
1807
+ end
1808
+
1809
+ end
1810
+
1811
+ class SorobanParser < Treetop::Runtime::CompiledParser
1812
+ include Soroban
1813
+ end
1814
+