mongo-ejson 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/src/ejson.rb ADDED
@@ -0,0 +1,4022 @@
1
+ # This file was generated from src/ejson.peg
2
+ # See http://canopy.jcoglan.com/ for documentation.
3
+
4
+ module ExtendedJSON
5
+ class TreeNode
6
+ include Enumerable
7
+ attr_reader :text, :offset, :elements
8
+
9
+ def initialize(text, offset, elements = [])
10
+ @text = text
11
+ @offset = offset
12
+ @elements = elements
13
+ end
14
+
15
+ def each(&block)
16
+ @elements.each(&block)
17
+ end
18
+ end
19
+
20
+ class TreeNode1 < TreeNode
21
+ attr_reader :string, :value
22
+
23
+ def initialize(text, offset, elements)
24
+ super
25
+ @string = elements[0]
26
+ @value = elements[1]
27
+ end
28
+ end
29
+
30
+ class TreeNode2 < TreeNode
31
+ attr_reader :pair
32
+
33
+ def initialize(text, offset, elements)
34
+ super
35
+ @pair = elements[0]
36
+ end
37
+ end
38
+
39
+ class TreeNode3 < TreeNode
40
+ attr_reader :pair
41
+
42
+ def initialize(text, offset, elements)
43
+ super
44
+ @pair = elements[0]
45
+ end
46
+ end
47
+
48
+ class TreeNode4 < TreeNode
49
+ attr_reader :value
50
+
51
+ def initialize(text, offset, elements)
52
+ super
53
+ @value = elements[0]
54
+ end
55
+ end
56
+
57
+ class TreeNode5 < TreeNode
58
+ attr_reader :value
59
+
60
+ def initialize(text, offset, elements)
61
+ super
62
+ @value = elements[0]
63
+ end
64
+ end
65
+
66
+ class TreeNode6 < TreeNode
67
+ attr_reader :hex_value
68
+
69
+ def initialize(text, offset, elements)
70
+ super
71
+ @hex_value = elements[0]
72
+ end
73
+ end
74
+
75
+ class TreeNode7 < TreeNode
76
+ attr_reader :hex_value
77
+
78
+ def initialize(text, offset, elements)
79
+ super
80
+ @hex_value = elements[0]
81
+ end
82
+ end
83
+
84
+ class TreeNode8 < TreeNode
85
+ attr_reader :integer_number
86
+
87
+ def initialize(text, offset, elements)
88
+ super
89
+ @integer_number = elements[0]
90
+ end
91
+ end
92
+
93
+ class TreeNode9 < TreeNode
94
+ attr_reader :integer_number
95
+
96
+ def initialize(text, offset, elements)
97
+ super
98
+ @integer_number = elements[0]
99
+ end
100
+ end
101
+
102
+ class TreeNode10 < TreeNode
103
+ attr_reader :number
104
+
105
+ def initialize(text, offset, elements)
106
+ super
107
+ @number = elements[0]
108
+ end
109
+ end
110
+
111
+ class TreeNode11 < TreeNode
112
+ attr_reader :number
113
+
114
+ def initialize(text, offset, elements)
115
+ super
116
+ @number = elements[0]
117
+ end
118
+ end
119
+
120
+ class TreeNode12 < TreeNode
121
+ attr_reader :base64_value
122
+
123
+ def initialize(text, offset, elements)
124
+ super
125
+ @base64_value = elements[0]
126
+ end
127
+ end
128
+
129
+ class TreeNode13 < TreeNode
130
+ attr_reader :base64_value
131
+
132
+ def initialize(text, offset, elements)
133
+ super
134
+ @base64_value = elements[0]
135
+ end
136
+ end
137
+
138
+ class TreeNode14 < TreeNode
139
+ attr_reader :integer
140
+
141
+ def initialize(text, offset, elements)
142
+ super
143
+ @integer = elements[1]
144
+ end
145
+ end
146
+
147
+ class TreeNode15 < TreeNode
148
+ attr_reader :integer
149
+
150
+ def initialize(text, offset, elements)
151
+ super
152
+ @integer = elements[1]
153
+ end
154
+ end
155
+
156
+ class TreeNode16 < TreeNode
157
+ attr_reader :integer
158
+
159
+ def initialize(text, offset, elements)
160
+ super
161
+ @integer = elements[0]
162
+ end
163
+ end
164
+
165
+ class TreeNode17 < TreeNode
166
+ attr_reader :hex_string
167
+
168
+ def initialize(text, offset, elements)
169
+ super
170
+ @hex_string = elements[0]
171
+ end
172
+ end
173
+
174
+ class TreeNode18 < TreeNode
175
+ attr_reader :bin_data_type, :base64_string
176
+
177
+ def initialize(text, offset, elements)
178
+ super
179
+ @bin_data_type = elements[0]
180
+ @base64_string = elements[1]
181
+ end
182
+ end
183
+
184
+ class TreeNode19 < TreeNode
185
+ attr_reader :integer_number
186
+
187
+ def initialize(text, offset, elements)
188
+ super
189
+ @integer_number = elements[1]
190
+ end
191
+ end
192
+
193
+ class TreeNode20 < TreeNode
194
+ attr_reader :number_long_value
195
+
196
+ def initialize(text, offset, elements)
197
+ super
198
+ @number_long_value = elements[0]
199
+ end
200
+ end
201
+
202
+ class TreeNode21 < TreeNode
203
+ attr_reader :number_decimal_value
204
+
205
+ def initialize(text, offset, elements)
206
+ super
207
+ @number_decimal_value = elements[0]
208
+ end
209
+ end
210
+
211
+ class TreeNode22 < TreeNode
212
+ attr_reader :date_value
213
+
214
+ def initialize(text, offset, elements)
215
+ super
216
+ @date_value = elements[0]
217
+ end
218
+ end
219
+
220
+ class TreeNode23 < TreeNode
221
+ attr_reader :string
222
+
223
+ def initialize(text, offset, elements)
224
+ super
225
+ @string = elements[1]
226
+ end
227
+ end
228
+
229
+ class TreeNode24 < TreeNode
230
+ attr_reader :comma
231
+
232
+ def initialize(text, offset, elements)
233
+ super
234
+ @comma = elements[0]
235
+ end
236
+ end
237
+
238
+ ParseError = Class.new(StandardError)
239
+
240
+ FAILURE = Object.new
241
+
242
+ module Grammar
243
+ def _read_root
244
+ address0, index0 = FAILURE, @offset
245
+ cached = @cache[:root][index0]
246
+ if cached
247
+ @offset = cached[1]
248
+ return cached[0]
249
+ end
250
+ index1, elements0 = @offset, []
251
+ address1 = FAILURE
252
+ address1 = _read___
253
+ unless address1 == FAILURE
254
+ address2 = FAILURE
255
+ index2 = @offset
256
+ address2 = _read_object
257
+ if address2 == FAILURE
258
+ @offset = index2
259
+ address2 = _read_array
260
+ if address2 == FAILURE
261
+ @offset = index2
262
+ end
263
+ end
264
+ unless address2 == FAILURE
265
+ elements0 << address2
266
+ address3 = FAILURE
267
+ address3 = _read___
268
+ unless address3 == FAILURE
269
+ else
270
+ elements0 = nil
271
+ @offset = index1
272
+ end
273
+ else
274
+ elements0 = nil
275
+ @offset = index1
276
+ end
277
+ else
278
+ elements0 = nil
279
+ @offset = index1
280
+ end
281
+ if elements0.nil?
282
+ address0 = FAILURE
283
+ else
284
+ address0 = @actions.make_root(@input, index1, @offset, elements0)
285
+ @offset = @offset
286
+ end
287
+ @cache[:root][index0] = [address0, @offset]
288
+ return address0
289
+ end
290
+
291
+ def _read_object
292
+ address0, index0 = FAILURE, @offset
293
+ cached = @cache[:object][index0]
294
+ if cached
295
+ @offset = cached[1]
296
+ return cached[0]
297
+ end
298
+ index1 = @offset
299
+ address0 = _read_non_empty_object
300
+ if address0 == FAILURE
301
+ @offset = index1
302
+ address0 = _read_empty_object
303
+ if address0 == FAILURE
304
+ @offset = index1
305
+ end
306
+ end
307
+ @cache[:object][index0] = [address0, @offset]
308
+ return address0
309
+ end
310
+
311
+ def _read_pair
312
+ address0, index0 = FAILURE, @offset
313
+ cached = @cache[:pair][index0]
314
+ if cached
315
+ @offset = cached[1]
316
+ return cached[0]
317
+ end
318
+ index1, elements0 = @offset, []
319
+ address1 = FAILURE
320
+ address1 = _read___
321
+ unless address1 == FAILURE
322
+ address2 = FAILURE
323
+ address2 = _read_string
324
+ unless address2 == FAILURE
325
+ elements0 << address2
326
+ address3 = FAILURE
327
+ address3 = _read_assignment
328
+ unless address3 == FAILURE
329
+ address4 = FAILURE
330
+ address4 = _read_value
331
+ unless address4 == FAILURE
332
+ elements0 << address4
333
+ else
334
+ elements0 = nil
335
+ @offset = index1
336
+ end
337
+ else
338
+ elements0 = nil
339
+ @offset = index1
340
+ end
341
+ else
342
+ elements0 = nil
343
+ @offset = index1
344
+ end
345
+ else
346
+ elements0 = nil
347
+ @offset = index1
348
+ end
349
+ if elements0.nil?
350
+ address0 = FAILURE
351
+ else
352
+ address0 = @actions.make_pair(@input, index1, @offset, elements0)
353
+ @offset = @offset
354
+ end
355
+ @cache[:pair][index0] = [address0, @offset]
356
+ return address0
357
+ end
358
+
359
+ def _read_non_empty_object
360
+ address0, index0 = FAILURE, @offset
361
+ cached = @cache[:non_empty_object][index0]
362
+ if cached
363
+ @offset = cached[1]
364
+ return cached[0]
365
+ end
366
+ index1, elements0 = @offset, []
367
+ address1 = FAILURE
368
+ address1 = _read_object_open
369
+ unless address1 == FAILURE
370
+ address2 = FAILURE
371
+ address2 = _read_pair
372
+ unless address2 == FAILURE
373
+ elements0 << address2
374
+ address3 = FAILURE
375
+ remaining0, index2, elements1, address4 = 0, @offset, [], true
376
+ until address4 == FAILURE
377
+ index3, elements2 = @offset, []
378
+ address5 = FAILURE
379
+ address5 = _read_delimiter
380
+ unless address5 == FAILURE
381
+ address6 = FAILURE
382
+ address6 = _read_pair
383
+ unless address6 == FAILURE
384
+ elements2 << address6
385
+ else
386
+ elements2 = nil
387
+ @offset = index3
388
+ end
389
+ else
390
+ elements2 = nil
391
+ @offset = index3
392
+ end
393
+ if elements2.nil?
394
+ address4 = FAILURE
395
+ else
396
+ address4 = TreeNode3.new(@input[index3...@offset], index3, elements2)
397
+ @offset = @offset
398
+ end
399
+ unless address4 == FAILURE
400
+ elements1 << address4
401
+ remaining0 -= 1
402
+ end
403
+ end
404
+ if remaining0 <= 0
405
+ address3 = TreeNode.new(@input[index2...@offset], index2, elements1)
406
+ @offset = @offset
407
+ else
408
+ address3 = FAILURE
409
+ end
410
+ unless address3 == FAILURE
411
+ elements0 << address3
412
+ address7 = FAILURE
413
+ address7 = _read_object_close
414
+ unless address7 == FAILURE
415
+ else
416
+ elements0 = nil
417
+ @offset = index1
418
+ end
419
+ else
420
+ elements0 = nil
421
+ @offset = index1
422
+ end
423
+ else
424
+ elements0 = nil
425
+ @offset = index1
426
+ end
427
+ else
428
+ elements0 = nil
429
+ @offset = index1
430
+ end
431
+ if elements0.nil?
432
+ address0 = FAILURE
433
+ else
434
+ address0 = @actions.make_object(@input, index1, @offset, elements0)
435
+ @offset = @offset
436
+ end
437
+ @cache[:non_empty_object][index0] = [address0, @offset]
438
+ return address0
439
+ end
440
+
441
+ def _read_empty_object
442
+ address0, index0 = FAILURE, @offset
443
+ cached = @cache[:empty_object][index0]
444
+ if cached
445
+ @offset = cached[1]
446
+ return cached[0]
447
+ end
448
+ index1, elements0 = @offset, []
449
+ address1 = FAILURE
450
+ address1 = _read_object_open
451
+ unless address1 == FAILURE
452
+ address2 = FAILURE
453
+ address2 = _read_object_close
454
+ unless address2 == FAILURE
455
+ else
456
+ elements0 = nil
457
+ @offset = index1
458
+ end
459
+ else
460
+ elements0 = nil
461
+ @offset = index1
462
+ end
463
+ if elements0.nil?
464
+ address0 = FAILURE
465
+ else
466
+ address0 = @actions.make_empty_object(@input, index1, @offset, elements0)
467
+ @offset = @offset
468
+ end
469
+ @cache[:empty_object][index0] = [address0, @offset]
470
+ return address0
471
+ end
472
+
473
+ def _read_array
474
+ address0, index0 = FAILURE, @offset
475
+ cached = @cache[:array][index0]
476
+ if cached
477
+ @offset = cached[1]
478
+ return cached[0]
479
+ end
480
+ index1 = @offset
481
+ address0 = _read_non_empty_array
482
+ if address0 == FAILURE
483
+ @offset = index1
484
+ address0 = _read_empty_array
485
+ if address0 == FAILURE
486
+ @offset = index1
487
+ end
488
+ end
489
+ @cache[:array][index0] = [address0, @offset]
490
+ return address0
491
+ end
492
+
493
+ def _read_non_empty_array
494
+ address0, index0 = FAILURE, @offset
495
+ cached = @cache[:non_empty_array][index0]
496
+ if cached
497
+ @offset = cached[1]
498
+ return cached[0]
499
+ end
500
+ index1, elements0 = @offset, []
501
+ address1 = FAILURE
502
+ address1 = _read_array_open
503
+ unless address1 == FAILURE
504
+ address2 = FAILURE
505
+ address2 = _read_value
506
+ unless address2 == FAILURE
507
+ elements0 << address2
508
+ address3 = FAILURE
509
+ remaining0, index2, elements1, address4 = 0, @offset, [], true
510
+ until address4 == FAILURE
511
+ index3, elements2 = @offset, []
512
+ address5 = FAILURE
513
+ address5 = _read_delimiter
514
+ unless address5 == FAILURE
515
+ address6 = FAILURE
516
+ address6 = _read_value
517
+ unless address6 == FAILURE
518
+ elements2 << address6
519
+ else
520
+ elements2 = nil
521
+ @offset = index3
522
+ end
523
+ else
524
+ elements2 = nil
525
+ @offset = index3
526
+ end
527
+ if elements2.nil?
528
+ address4 = FAILURE
529
+ else
530
+ address4 = TreeNode5.new(@input[index3...@offset], index3, elements2)
531
+ @offset = @offset
532
+ end
533
+ unless address4 == FAILURE
534
+ elements1 << address4
535
+ remaining0 -= 1
536
+ end
537
+ end
538
+ if remaining0 <= 0
539
+ address3 = TreeNode.new(@input[index2...@offset], index2, elements1)
540
+ @offset = @offset
541
+ else
542
+ address3 = FAILURE
543
+ end
544
+ unless address3 == FAILURE
545
+ elements0 << address3
546
+ address7 = FAILURE
547
+ address7 = _read_array_close
548
+ unless address7 == FAILURE
549
+ else
550
+ elements0 = nil
551
+ @offset = index1
552
+ end
553
+ else
554
+ elements0 = nil
555
+ @offset = index1
556
+ end
557
+ else
558
+ elements0 = nil
559
+ @offset = index1
560
+ end
561
+ else
562
+ elements0 = nil
563
+ @offset = index1
564
+ end
565
+ if elements0.nil?
566
+ address0 = FAILURE
567
+ else
568
+ address0 = @actions.make_array(@input, index1, @offset, elements0)
569
+ @offset = @offset
570
+ end
571
+ @cache[:non_empty_array][index0] = [address0, @offset]
572
+ return address0
573
+ end
574
+
575
+ def _read_empty_array
576
+ address0, index0 = FAILURE, @offset
577
+ cached = @cache[:empty_array][index0]
578
+ if cached
579
+ @offset = cached[1]
580
+ return cached[0]
581
+ end
582
+ index1, elements0 = @offset, []
583
+ address1 = FAILURE
584
+ address1 = _read_array_open
585
+ unless address1 == FAILURE
586
+ address2 = FAILURE
587
+ address2 = _read_array_close
588
+ unless address2 == FAILURE
589
+ else
590
+ elements0 = nil
591
+ @offset = index1
592
+ end
593
+ else
594
+ elements0 = nil
595
+ @offset = index1
596
+ end
597
+ if elements0.nil?
598
+ address0 = FAILURE
599
+ else
600
+ address0 = @actions.make_empty_array(@input, index1, @offset, elements0)
601
+ @offset = @offset
602
+ end
603
+ @cache[:empty_array][index0] = [address0, @offset]
604
+ return address0
605
+ end
606
+
607
+ def _read_value
608
+ address0, index0 = FAILURE, @offset
609
+ cached = @cache[:value][index0]
610
+ if cached
611
+ @offset = cached[1]
612
+ return cached[0]
613
+ end
614
+ index1 = @offset
615
+ address0 = _read_json_values
616
+ if address0 == FAILURE
617
+ @offset = index1
618
+ address0 = _read_mongo_literals
619
+ if address0 == FAILURE
620
+ @offset = index1
621
+ address0 = _read_mongo_types
622
+ if address0 == FAILURE
623
+ @offset = index1
624
+ end
625
+ end
626
+ end
627
+ @cache[:value][index0] = [address0, @offset]
628
+ return address0
629
+ end
630
+
631
+ def _read_json_values
632
+ address0, index0 = FAILURE, @offset
633
+ cached = @cache[:json_values][index0]
634
+ if cached
635
+ @offset = cached[1]
636
+ return cached[0]
637
+ end
638
+ index1 = @offset
639
+ address0 = _read_object
640
+ if address0 == FAILURE
641
+ @offset = index1
642
+ address0 = _read_array
643
+ if address0 == FAILURE
644
+ @offset = index1
645
+ address0 = _read_number
646
+ if address0 == FAILURE
647
+ @offset = index1
648
+ address0 = _read_string
649
+ if address0 == FAILURE
650
+ @offset = index1
651
+ address0 = _read_boolean
652
+ if address0 == FAILURE
653
+ @offset = index1
654
+ address0 = _read_null
655
+ if address0 == FAILURE
656
+ @offset = index1
657
+ end
658
+ end
659
+ end
660
+ end
661
+ end
662
+ end
663
+ @cache[:json_values][index0] = [address0, @offset]
664
+ return address0
665
+ end
666
+
667
+ def _read_mongo_literals
668
+ address0, index0 = FAILURE, @offset
669
+ cached = @cache[:mongo_literals][index0]
670
+ if cached
671
+ @offset = cached[1]
672
+ return cached[0]
673
+ end
674
+ index1 = @offset
675
+ address0 = _read_min_key
676
+ if address0 == FAILURE
677
+ @offset = index1
678
+ address0 = _read_max_key
679
+ if address0 == FAILURE
680
+ @offset = index1
681
+ address0 = _read_undefined
682
+ if address0 == FAILURE
683
+ @offset = index1
684
+ address0 = _read_regexp_string
685
+ if address0 == FAILURE
686
+ @offset = index1
687
+ end
688
+ end
689
+ end
690
+ end
691
+ @cache[:mongo_literals][index0] = [address0, @offset]
692
+ return address0
693
+ end
694
+
695
+ def _read_mongo_types
696
+ address0, index0 = FAILURE, @offset
697
+ cached = @cache[:mongo_types][index0]
698
+ if cached
699
+ @offset = cached[1]
700
+ return cached[0]
701
+ end
702
+ index1 = @offset
703
+ address0 = _read_object_id
704
+ if address0 == FAILURE
705
+ @offset = index1
706
+ address0 = _read_bin_data
707
+ if address0 == FAILURE
708
+ @offset = index1
709
+ address0 = _read_timestamp
710
+ if address0 == FAILURE
711
+ @offset = index1
712
+ address0 = _read_number_long
713
+ if address0 == FAILURE
714
+ @offset = index1
715
+ address0 = _read_number_decimal
716
+ if address0 == FAILURE
717
+ @offset = index1
718
+ address0 = _read_date
719
+ if address0 == FAILURE
720
+ @offset = index1
721
+ address0 = _read_db_ref_type
722
+ if address0 == FAILURE
723
+ @offset = index1
724
+ end
725
+ end
726
+ end
727
+ end
728
+ end
729
+ end
730
+ end
731
+ @cache[:mongo_types][index0] = [address0, @offset]
732
+ return address0
733
+ end
734
+
735
+ def _read_boolean
736
+ address0, index0 = FAILURE, @offset
737
+ cached = @cache[:boolean][index0]
738
+ if cached
739
+ @offset = cached[1]
740
+ return cached[0]
741
+ end
742
+ index1 = @offset
743
+ address0 = _read_true
744
+ if address0 == FAILURE
745
+ @offset = index1
746
+ address0 = _read_false
747
+ if address0 == FAILURE
748
+ @offset = index1
749
+ end
750
+ end
751
+ @cache[:boolean][index0] = [address0, @offset]
752
+ return address0
753
+ end
754
+
755
+ def _read_true
756
+ address0, index0 = FAILURE, @offset
757
+ cached = @cache[:true][index0]
758
+ if cached
759
+ @offset = cached[1]
760
+ return cached[0]
761
+ end
762
+ chunk0 = nil
763
+ if @offset < @input_size
764
+ chunk0 = @input[@offset...@offset + 4]
765
+ end
766
+ if chunk0 == "true"
767
+ address0 = @actions.make_true(@input, @offset, @offset + 4)
768
+ @offset = @offset + 4
769
+ else
770
+ address0 = FAILURE
771
+ if @offset > @failure
772
+ @failure = @offset
773
+ @expected = []
774
+ end
775
+ if @offset == @failure
776
+ @expected << "\"true\""
777
+ end
778
+ end
779
+ @cache[:true][index0] = [address0, @offset]
780
+ return address0
781
+ end
782
+
783
+ def _read_false
784
+ address0, index0 = FAILURE, @offset
785
+ cached = @cache[:false][index0]
786
+ if cached
787
+ @offset = cached[1]
788
+ return cached[0]
789
+ end
790
+ chunk0 = nil
791
+ if @offset < @input_size
792
+ chunk0 = @input[@offset...@offset + 5]
793
+ end
794
+ if chunk0 == "false"
795
+ address0 = @actions.make_false(@input, @offset, @offset + 5)
796
+ @offset = @offset + 5
797
+ else
798
+ address0 = FAILURE
799
+ if @offset > @failure
800
+ @failure = @offset
801
+ @expected = []
802
+ end
803
+ if @offset == @failure
804
+ @expected << "\"false\""
805
+ end
806
+ end
807
+ @cache[:false][index0] = [address0, @offset]
808
+ return address0
809
+ end
810
+
811
+ def _read_null
812
+ address0, index0 = FAILURE, @offset
813
+ cached = @cache[:null][index0]
814
+ if cached
815
+ @offset = cached[1]
816
+ return cached[0]
817
+ end
818
+ chunk0 = nil
819
+ if @offset < @input_size
820
+ chunk0 = @input[@offset...@offset + 4]
821
+ end
822
+ if chunk0 == "null"
823
+ address0 = @actions.make_null(@input, @offset, @offset + 4)
824
+ @offset = @offset + 4
825
+ else
826
+ address0 = FAILURE
827
+ if @offset > @failure
828
+ @failure = @offset
829
+ @expected = []
830
+ end
831
+ if @offset == @failure
832
+ @expected << "\"null\""
833
+ end
834
+ end
835
+ @cache[:null][index0] = [address0, @offset]
836
+ return address0
837
+ end
838
+
839
+ def _read_string
840
+ address0, index0 = FAILURE, @offset
841
+ cached = @cache[:string][index0]
842
+ if cached
843
+ @offset = cached[1]
844
+ return cached[0]
845
+ end
846
+ index1 = @offset
847
+ address0 = _read_double_quote_string
848
+ if address0 == FAILURE
849
+ @offset = index1
850
+ address0 = _read_single_quote_string
851
+ if address0 == FAILURE
852
+ @offset = index1
853
+ end
854
+ end
855
+ @cache[:string][index0] = [address0, @offset]
856
+ return address0
857
+ end
858
+
859
+ def _read_double_quote_string
860
+ address0, index0 = FAILURE, @offset
861
+ cached = @cache[:double_quote_string][index0]
862
+ if cached
863
+ @offset = cached[1]
864
+ return cached[0]
865
+ end
866
+ index1, elements0 = @offset, []
867
+ address1 = FAILURE
868
+ address1 = _read_double_quote
869
+ unless address1 == FAILURE
870
+ address2 = FAILURE
871
+ remaining0, index2, elements1, address3 = 0, @offset, [], true
872
+ until address3 == FAILURE
873
+ index3 = @offset
874
+ index4, elements2 = @offset, []
875
+ address4 = FAILURE
876
+ chunk0 = nil
877
+ if @offset < @input_size
878
+ chunk0 = @input[@offset...@offset + 1]
879
+ end
880
+ if chunk0 == "\\"
881
+ address4 = TreeNode.new(@input[@offset...@offset + 1], @offset)
882
+ @offset = @offset + 1
883
+ else
884
+ address4 = FAILURE
885
+ if @offset > @failure
886
+ @failure = @offset
887
+ @expected = []
888
+ end
889
+ if @offset == @failure
890
+ @expected << "\"\\\\\""
891
+ end
892
+ end
893
+ unless address4 == FAILURE
894
+ elements2 << address4
895
+ address5 = FAILURE
896
+ if @offset < @input_size
897
+ address5 = TreeNode.new(@input[@offset...@offset + 1], @offset)
898
+ @offset = @offset + 1
899
+ else
900
+ address5 = FAILURE
901
+ if @offset > @failure
902
+ @failure = @offset
903
+ @expected = []
904
+ end
905
+ if @offset == @failure
906
+ @expected << "<any char>"
907
+ end
908
+ end
909
+ unless address5 == FAILURE
910
+ elements2 << address5
911
+ else
912
+ elements2 = nil
913
+ @offset = index4
914
+ end
915
+ else
916
+ elements2 = nil
917
+ @offset = index4
918
+ end
919
+ if elements2.nil?
920
+ address3 = FAILURE
921
+ else
922
+ address3 = TreeNode.new(@input[index4...@offset], index4, elements2)
923
+ @offset = @offset
924
+ end
925
+ if address3 == FAILURE
926
+ @offset = index3
927
+ chunk1 = nil
928
+ if @offset < @input_size
929
+ chunk1 = @input[@offset...@offset + 1]
930
+ end
931
+ if chunk1 =~ /\A[^"]/
932
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
933
+ @offset = @offset + 1
934
+ else
935
+ address3 = FAILURE
936
+ if @offset > @failure
937
+ @failure = @offset
938
+ @expected = []
939
+ end
940
+ if @offset == @failure
941
+ @expected << "[^\"]"
942
+ end
943
+ end
944
+ if address3 == FAILURE
945
+ @offset = index3
946
+ end
947
+ end
948
+ unless address3 == FAILURE
949
+ elements1 << address3
950
+ remaining0 -= 1
951
+ end
952
+ end
953
+ if remaining0 <= 0
954
+ address2 = TreeNode.new(@input[index2...@offset], index2, elements1)
955
+ @offset = @offset
956
+ else
957
+ address2 = FAILURE
958
+ end
959
+ unless address2 == FAILURE
960
+ elements0 << address2
961
+ address6 = FAILURE
962
+ address6 = _read_double_quote
963
+ unless address6 == FAILURE
964
+ else
965
+ elements0 = nil
966
+ @offset = index1
967
+ end
968
+ else
969
+ elements0 = nil
970
+ @offset = index1
971
+ end
972
+ else
973
+ elements0 = nil
974
+ @offset = index1
975
+ end
976
+ if elements0.nil?
977
+ address0 = FAILURE
978
+ else
979
+ address0 = @actions.make_string(@input, index1, @offset, elements0)
980
+ @offset = @offset
981
+ end
982
+ @cache[:double_quote_string][index0] = [address0, @offset]
983
+ return address0
984
+ end
985
+
986
+ def _read_single_quote_string
987
+ address0, index0 = FAILURE, @offset
988
+ cached = @cache[:single_quote_string][index0]
989
+ if cached
990
+ @offset = cached[1]
991
+ return cached[0]
992
+ end
993
+ index1, elements0 = @offset, []
994
+ address1 = FAILURE
995
+ address1 = _read_single_quote
996
+ unless address1 == FAILURE
997
+ address2 = FAILURE
998
+ remaining0, index2, elements1, address3 = 0, @offset, [], true
999
+ until address3 == FAILURE
1000
+ index3 = @offset
1001
+ index4, elements2 = @offset, []
1002
+ address4 = FAILURE
1003
+ chunk0 = nil
1004
+ if @offset < @input_size
1005
+ chunk0 = @input[@offset...@offset + 1]
1006
+ end
1007
+ if chunk0 == "\\"
1008
+ address4 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1009
+ @offset = @offset + 1
1010
+ else
1011
+ address4 = FAILURE
1012
+ if @offset > @failure
1013
+ @failure = @offset
1014
+ @expected = []
1015
+ end
1016
+ if @offset == @failure
1017
+ @expected << "\"\\\\\""
1018
+ end
1019
+ end
1020
+ unless address4 == FAILURE
1021
+ elements2 << address4
1022
+ address5 = FAILURE
1023
+ if @offset < @input_size
1024
+ address5 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1025
+ @offset = @offset + 1
1026
+ else
1027
+ address5 = FAILURE
1028
+ if @offset > @failure
1029
+ @failure = @offset
1030
+ @expected = []
1031
+ end
1032
+ if @offset == @failure
1033
+ @expected << "<any char>"
1034
+ end
1035
+ end
1036
+ unless address5 == FAILURE
1037
+ elements2 << address5
1038
+ else
1039
+ elements2 = nil
1040
+ @offset = index4
1041
+ end
1042
+ else
1043
+ elements2 = nil
1044
+ @offset = index4
1045
+ end
1046
+ if elements2.nil?
1047
+ address3 = FAILURE
1048
+ else
1049
+ address3 = TreeNode.new(@input[index4...@offset], index4, elements2)
1050
+ @offset = @offset
1051
+ end
1052
+ if address3 == FAILURE
1053
+ @offset = index3
1054
+ chunk1 = nil
1055
+ if @offset < @input_size
1056
+ chunk1 = @input[@offset...@offset + 1]
1057
+ end
1058
+ if chunk1 =~ /\A[^']/
1059
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1060
+ @offset = @offset + 1
1061
+ else
1062
+ address3 = FAILURE
1063
+ if @offset > @failure
1064
+ @failure = @offset
1065
+ @expected = []
1066
+ end
1067
+ if @offset == @failure
1068
+ @expected << "[^']"
1069
+ end
1070
+ end
1071
+ if address3 == FAILURE
1072
+ @offset = index3
1073
+ end
1074
+ end
1075
+ unless address3 == FAILURE
1076
+ elements1 << address3
1077
+ remaining0 -= 1
1078
+ end
1079
+ end
1080
+ if remaining0 <= 0
1081
+ address2 = TreeNode.new(@input[index2...@offset], index2, elements1)
1082
+ @offset = @offset
1083
+ else
1084
+ address2 = FAILURE
1085
+ end
1086
+ unless address2 == FAILURE
1087
+ elements0 << address2
1088
+ address6 = FAILURE
1089
+ address6 = _read_single_quote
1090
+ unless address6 == FAILURE
1091
+ else
1092
+ elements0 = nil
1093
+ @offset = index1
1094
+ end
1095
+ else
1096
+ elements0 = nil
1097
+ @offset = index1
1098
+ end
1099
+ else
1100
+ elements0 = nil
1101
+ @offset = index1
1102
+ end
1103
+ if elements0.nil?
1104
+ address0 = FAILURE
1105
+ else
1106
+ address0 = @actions.make_string(@input, index1, @offset, elements0)
1107
+ @offset = @offset
1108
+ end
1109
+ @cache[:single_quote_string][index0] = [address0, @offset]
1110
+ return address0
1111
+ end
1112
+
1113
+ def _read_hex_string
1114
+ address0, index0 = FAILURE, @offset
1115
+ cached = @cache[:hex_string][index0]
1116
+ if cached
1117
+ @offset = cached[1]
1118
+ return cached[0]
1119
+ end
1120
+ index1 = @offset
1121
+ address0 = _read_hex_single_quote
1122
+ if address0 == FAILURE
1123
+ @offset = index1
1124
+ address0 = _read_hex_double_quote
1125
+ if address0 == FAILURE
1126
+ @offset = index1
1127
+ end
1128
+ end
1129
+ @cache[:hex_string][index0] = [address0, @offset]
1130
+ return address0
1131
+ end
1132
+
1133
+ def _read_hex_value
1134
+ address0, index0 = FAILURE, @offset
1135
+ cached = @cache[:hex_value][index0]
1136
+ if cached
1137
+ @offset = cached[1]
1138
+ return cached[0]
1139
+ end
1140
+ remaining0, index1, elements0, address1 = 1, @offset, [], true
1141
+ until address1 == FAILURE
1142
+ chunk0 = nil
1143
+ if @offset < @input_size
1144
+ chunk0 = @input[@offset...@offset + 1]
1145
+ end
1146
+ if chunk0 =~ /\A[a-fA-F0-9]/
1147
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1148
+ @offset = @offset + 1
1149
+ else
1150
+ address1 = FAILURE
1151
+ if @offset > @failure
1152
+ @failure = @offset
1153
+ @expected = []
1154
+ end
1155
+ if @offset == @failure
1156
+ @expected << "[a-fA-F0-9]"
1157
+ end
1158
+ end
1159
+ unless address1 == FAILURE
1160
+ elements0 << address1
1161
+ remaining0 -= 1
1162
+ end
1163
+ end
1164
+ if remaining0 <= 0
1165
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
1166
+ @offset = @offset
1167
+ else
1168
+ address0 = FAILURE
1169
+ end
1170
+ @cache[:hex_value][index0] = [address0, @offset]
1171
+ return address0
1172
+ end
1173
+
1174
+ def _read_hex_single_quote
1175
+ address0, index0 = FAILURE, @offset
1176
+ cached = @cache[:hex_single_quote][index0]
1177
+ if cached
1178
+ @offset = cached[1]
1179
+ return cached[0]
1180
+ end
1181
+ index1, elements0 = @offset, []
1182
+ address1 = FAILURE
1183
+ address1 = _read_single_quote
1184
+ unless address1 == FAILURE
1185
+ address2 = FAILURE
1186
+ address2 = _read_hex_value
1187
+ unless address2 == FAILURE
1188
+ elements0 << address2
1189
+ address3 = FAILURE
1190
+ address3 = _read_single_quote
1191
+ unless address3 == FAILURE
1192
+ else
1193
+ elements0 = nil
1194
+ @offset = index1
1195
+ end
1196
+ else
1197
+ elements0 = nil
1198
+ @offset = index1
1199
+ end
1200
+ else
1201
+ elements0 = nil
1202
+ @offset = index1
1203
+ end
1204
+ if elements0.nil?
1205
+ address0 = FAILURE
1206
+ else
1207
+ address0 = @actions.make_string(@input, index1, @offset, elements0)
1208
+ @offset = @offset
1209
+ end
1210
+ @cache[:hex_single_quote][index0] = [address0, @offset]
1211
+ return address0
1212
+ end
1213
+
1214
+ def _read_hex_double_quote
1215
+ address0, index0 = FAILURE, @offset
1216
+ cached = @cache[:hex_double_quote][index0]
1217
+ if cached
1218
+ @offset = cached[1]
1219
+ return cached[0]
1220
+ end
1221
+ index1, elements0 = @offset, []
1222
+ address1 = FAILURE
1223
+ address1 = _read_double_quote
1224
+ unless address1 == FAILURE
1225
+ address2 = FAILURE
1226
+ address2 = _read_hex_value
1227
+ unless address2 == FAILURE
1228
+ elements0 << address2
1229
+ address3 = FAILURE
1230
+ address3 = _read_double_quote
1231
+ unless address3 == FAILURE
1232
+ else
1233
+ elements0 = nil
1234
+ @offset = index1
1235
+ end
1236
+ else
1237
+ elements0 = nil
1238
+ @offset = index1
1239
+ end
1240
+ else
1241
+ elements0 = nil
1242
+ @offset = index1
1243
+ end
1244
+ if elements0.nil?
1245
+ address0 = FAILURE
1246
+ else
1247
+ address0 = @actions.make_string(@input, index1, @offset, elements0)
1248
+ @offset = @offset
1249
+ end
1250
+ @cache[:hex_double_quote][index0] = [address0, @offset]
1251
+ return address0
1252
+ end
1253
+
1254
+ def _read_integer_string
1255
+ address0, index0 = FAILURE, @offset
1256
+ cached = @cache[:integer_string][index0]
1257
+ if cached
1258
+ @offset = cached[1]
1259
+ return cached[0]
1260
+ end
1261
+ index1 = @offset
1262
+ address0 = _read_integer_string_single
1263
+ if address0 == FAILURE
1264
+ @offset = index1
1265
+ address0 = _read_integer_string_double
1266
+ if address0 == FAILURE
1267
+ @offset = index1
1268
+ end
1269
+ end
1270
+ @cache[:integer_string][index0] = [address0, @offset]
1271
+ return address0
1272
+ end
1273
+
1274
+ def _read_integer_string_single
1275
+ address0, index0 = FAILURE, @offset
1276
+ cached = @cache[:integer_string_single][index0]
1277
+ if cached
1278
+ @offset = cached[1]
1279
+ return cached[0]
1280
+ end
1281
+ index1, elements0 = @offset, []
1282
+ address1 = FAILURE
1283
+ address1 = _read_single_quote
1284
+ unless address1 == FAILURE
1285
+ address2 = FAILURE
1286
+ address2 = _read_integer_number
1287
+ unless address2 == FAILURE
1288
+ elements0 << address2
1289
+ address3 = FAILURE
1290
+ address3 = _read_single_quote
1291
+ unless address3 == FAILURE
1292
+ else
1293
+ elements0 = nil
1294
+ @offset = index1
1295
+ end
1296
+ else
1297
+ elements0 = nil
1298
+ @offset = index1
1299
+ end
1300
+ else
1301
+ elements0 = nil
1302
+ @offset = index1
1303
+ end
1304
+ if elements0.nil?
1305
+ address0 = FAILURE
1306
+ else
1307
+ address0 = @actions.make_numeric_string(@input, index1, @offset, elements0)
1308
+ @offset = @offset
1309
+ end
1310
+ @cache[:integer_string_single][index0] = [address0, @offset]
1311
+ return address0
1312
+ end
1313
+
1314
+ def _read_integer_string_double
1315
+ address0, index0 = FAILURE, @offset
1316
+ cached = @cache[:integer_string_double][index0]
1317
+ if cached
1318
+ @offset = cached[1]
1319
+ return cached[0]
1320
+ end
1321
+ index1, elements0 = @offset, []
1322
+ address1 = FAILURE
1323
+ address1 = _read_double_quote
1324
+ unless address1 == FAILURE
1325
+ address2 = FAILURE
1326
+ address2 = _read_integer_number
1327
+ unless address2 == FAILURE
1328
+ elements0 << address2
1329
+ address3 = FAILURE
1330
+ address3 = _read_double_quote
1331
+ unless address3 == FAILURE
1332
+ else
1333
+ elements0 = nil
1334
+ @offset = index1
1335
+ end
1336
+ else
1337
+ elements0 = nil
1338
+ @offset = index1
1339
+ end
1340
+ else
1341
+ elements0 = nil
1342
+ @offset = index1
1343
+ end
1344
+ if elements0.nil?
1345
+ address0 = FAILURE
1346
+ else
1347
+ address0 = @actions.make_numeric_string(@input, index1, @offset, elements0)
1348
+ @offset = @offset
1349
+ end
1350
+ @cache[:integer_string_double][index0] = [address0, @offset]
1351
+ return address0
1352
+ end
1353
+
1354
+ def _read_number_string
1355
+ address0, index0 = FAILURE, @offset
1356
+ cached = @cache[:number_string][index0]
1357
+ if cached
1358
+ @offset = cached[1]
1359
+ return cached[0]
1360
+ end
1361
+ index1 = @offset
1362
+ address0 = _read_number_string_single
1363
+ if address0 == FAILURE
1364
+ @offset = index1
1365
+ address0 = _read_number_string_double
1366
+ if address0 == FAILURE
1367
+ @offset = index1
1368
+ end
1369
+ end
1370
+ @cache[:number_string][index0] = [address0, @offset]
1371
+ return address0
1372
+ end
1373
+
1374
+ def _read_number_string_single
1375
+ address0, index0 = FAILURE, @offset
1376
+ cached = @cache[:number_string_single][index0]
1377
+ if cached
1378
+ @offset = cached[1]
1379
+ return cached[0]
1380
+ end
1381
+ index1, elements0 = @offset, []
1382
+ address1 = FAILURE
1383
+ address1 = _read_single_quote
1384
+ unless address1 == FAILURE
1385
+ address2 = FAILURE
1386
+ address2 = _read_number
1387
+ unless address2 == FAILURE
1388
+ elements0 << address2
1389
+ address3 = FAILURE
1390
+ address3 = _read_single_quote
1391
+ unless address3 == FAILURE
1392
+ else
1393
+ elements0 = nil
1394
+ @offset = index1
1395
+ end
1396
+ else
1397
+ elements0 = nil
1398
+ @offset = index1
1399
+ end
1400
+ else
1401
+ elements0 = nil
1402
+ @offset = index1
1403
+ end
1404
+ if elements0.nil?
1405
+ address0 = FAILURE
1406
+ else
1407
+ address0 = @actions.make_numeric_string(@input, index1, @offset, elements0)
1408
+ @offset = @offset
1409
+ end
1410
+ @cache[:number_string_single][index0] = [address0, @offset]
1411
+ return address0
1412
+ end
1413
+
1414
+ def _read_number_string_double
1415
+ address0, index0 = FAILURE, @offset
1416
+ cached = @cache[:number_string_double][index0]
1417
+ if cached
1418
+ @offset = cached[1]
1419
+ return cached[0]
1420
+ end
1421
+ index1, elements0 = @offset, []
1422
+ address1 = FAILURE
1423
+ address1 = _read_double_quote
1424
+ unless address1 == FAILURE
1425
+ address2 = FAILURE
1426
+ address2 = _read_number
1427
+ unless address2 == FAILURE
1428
+ elements0 << address2
1429
+ address3 = FAILURE
1430
+ address3 = _read_double_quote
1431
+ unless address3 == FAILURE
1432
+ else
1433
+ elements0 = nil
1434
+ @offset = index1
1435
+ end
1436
+ else
1437
+ elements0 = nil
1438
+ @offset = index1
1439
+ end
1440
+ else
1441
+ elements0 = nil
1442
+ @offset = index1
1443
+ end
1444
+ if elements0.nil?
1445
+ address0 = FAILURE
1446
+ else
1447
+ address0 = @actions.make_numeric_string(@input, index1, @offset, elements0)
1448
+ @offset = @offset
1449
+ end
1450
+ @cache[:number_string_double][index0] = [address0, @offset]
1451
+ return address0
1452
+ end
1453
+
1454
+ def _read_regexp_string
1455
+ address0, index0 = FAILURE, @offset
1456
+ cached = @cache[:regexp_string][index0]
1457
+ if cached
1458
+ @offset = cached[1]
1459
+ return cached[0]
1460
+ end
1461
+ index1, elements0 = @offset, []
1462
+ address1 = FAILURE
1463
+ address1 = _read_slash
1464
+ unless address1 == FAILURE
1465
+ address2 = FAILURE
1466
+ remaining0, index2, elements1, address3 = 0, @offset, [], true
1467
+ until address3 == FAILURE
1468
+ index3 = @offset
1469
+ index4, elements2 = @offset, []
1470
+ address4 = FAILURE
1471
+ chunk0 = nil
1472
+ if @offset < @input_size
1473
+ chunk0 = @input[@offset...@offset + 1]
1474
+ end
1475
+ if chunk0 == "\\"
1476
+ address4 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1477
+ @offset = @offset + 1
1478
+ else
1479
+ address4 = FAILURE
1480
+ if @offset > @failure
1481
+ @failure = @offset
1482
+ @expected = []
1483
+ end
1484
+ if @offset == @failure
1485
+ @expected << "\"\\\\\""
1486
+ end
1487
+ end
1488
+ unless address4 == FAILURE
1489
+ elements2 << address4
1490
+ address5 = FAILURE
1491
+ if @offset < @input_size
1492
+ address5 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1493
+ @offset = @offset + 1
1494
+ else
1495
+ address5 = FAILURE
1496
+ if @offset > @failure
1497
+ @failure = @offset
1498
+ @expected = []
1499
+ end
1500
+ if @offset == @failure
1501
+ @expected << "<any char>"
1502
+ end
1503
+ end
1504
+ unless address5 == FAILURE
1505
+ elements2 << address5
1506
+ else
1507
+ elements2 = nil
1508
+ @offset = index4
1509
+ end
1510
+ else
1511
+ elements2 = nil
1512
+ @offset = index4
1513
+ end
1514
+ if elements2.nil?
1515
+ address3 = FAILURE
1516
+ else
1517
+ address3 = TreeNode.new(@input[index4...@offset], index4, elements2)
1518
+ @offset = @offset
1519
+ end
1520
+ if address3 == FAILURE
1521
+ @offset = index3
1522
+ chunk1 = nil
1523
+ if @offset < @input_size
1524
+ chunk1 = @input[@offset...@offset + 1]
1525
+ end
1526
+ if chunk1 =~ /\A[^\/]/
1527
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1528
+ @offset = @offset + 1
1529
+ else
1530
+ address3 = FAILURE
1531
+ if @offset > @failure
1532
+ @failure = @offset
1533
+ @expected = []
1534
+ end
1535
+ if @offset == @failure
1536
+ @expected << "[^\\/]"
1537
+ end
1538
+ end
1539
+ if address3 == FAILURE
1540
+ @offset = index3
1541
+ end
1542
+ end
1543
+ unless address3 == FAILURE
1544
+ elements1 << address3
1545
+ remaining0 -= 1
1546
+ end
1547
+ end
1548
+ if remaining0 <= 0
1549
+ address2 = TreeNode.new(@input[index2...@offset], index2, elements1)
1550
+ @offset = @offset
1551
+ else
1552
+ address2 = FAILURE
1553
+ end
1554
+ unless address2 == FAILURE
1555
+ elements0 << address2
1556
+ address6 = FAILURE
1557
+ address6 = _read_slash
1558
+ unless address6 == FAILURE
1559
+ address7 = FAILURE
1560
+ index5 = @offset
1561
+ address7 = _read_regexp_options
1562
+ if address7 == FAILURE
1563
+ address7 = TreeNode.new(@input[index5...index5], index5)
1564
+ @offset = index5
1565
+ end
1566
+ unless address7 == FAILURE
1567
+ elements0 << address7
1568
+ else
1569
+ elements0 = nil
1570
+ @offset = index1
1571
+ end
1572
+ else
1573
+ elements0 = nil
1574
+ @offset = index1
1575
+ end
1576
+ else
1577
+ elements0 = nil
1578
+ @offset = index1
1579
+ end
1580
+ else
1581
+ elements0 = nil
1582
+ @offset = index1
1583
+ end
1584
+ if elements0.nil?
1585
+ address0 = FAILURE
1586
+ else
1587
+ address0 = @actions.make_regexp(@input, index1, @offset, elements0)
1588
+ @offset = @offset
1589
+ end
1590
+ @cache[:regexp_string][index0] = [address0, @offset]
1591
+ return address0
1592
+ end
1593
+
1594
+ def _read_regexp_options
1595
+ address0, index0 = FAILURE, @offset
1596
+ cached = @cache[:regexp_options][index0]
1597
+ if cached
1598
+ @offset = cached[1]
1599
+ return cached[0]
1600
+ end
1601
+ remaining0, index1, elements0, address1 = 1, @offset, [], true
1602
+ until address1 == FAILURE
1603
+ chunk0 = nil
1604
+ if @offset < @input_size
1605
+ chunk0 = @input[@offset...@offset + 1]
1606
+ end
1607
+ if chunk0 =~ /\A[gims]/
1608
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1609
+ @offset = @offset + 1
1610
+ else
1611
+ address1 = FAILURE
1612
+ if @offset > @failure
1613
+ @failure = @offset
1614
+ @expected = []
1615
+ end
1616
+ if @offset == @failure
1617
+ @expected << "[gims]"
1618
+ end
1619
+ end
1620
+ unless address1 == FAILURE
1621
+ elements0 << address1
1622
+ remaining0 -= 1
1623
+ end
1624
+ end
1625
+ if remaining0 <= 0
1626
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
1627
+ @offset = @offset
1628
+ else
1629
+ address0 = FAILURE
1630
+ end
1631
+ @cache[:regexp_options][index0] = [address0, @offset]
1632
+ return address0
1633
+ end
1634
+
1635
+ def _read_base64_string
1636
+ address0, index0 = FAILURE, @offset
1637
+ cached = @cache[:base64_string][index0]
1638
+ if cached
1639
+ @offset = cached[1]
1640
+ return cached[0]
1641
+ end
1642
+ index1 = @offset
1643
+ address0 = _read_base64_single_quote
1644
+ if address0 == FAILURE
1645
+ @offset = index1
1646
+ address0 = _read_base64_dobule_quote
1647
+ if address0 == FAILURE
1648
+ @offset = index1
1649
+ end
1650
+ end
1651
+ @cache[:base64_string][index0] = [address0, @offset]
1652
+ return address0
1653
+ end
1654
+
1655
+ def _read_base64_value
1656
+ address0, index0 = FAILURE, @offset
1657
+ cached = @cache[:base64_value][index0]
1658
+ if cached
1659
+ @offset = cached[1]
1660
+ return cached[0]
1661
+ end
1662
+ index1, elements0 = @offset, []
1663
+ address1 = FAILURE
1664
+ remaining0, index2, elements1, address2 = 1, @offset, [], true
1665
+ until address2 == FAILURE
1666
+ chunk0 = nil
1667
+ if @offset < @input_size
1668
+ chunk0 = @input[@offset...@offset + 1]
1669
+ end
1670
+ if chunk0 =~ /\A[a-zA-Z0-9+\/]/
1671
+ address2 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1672
+ @offset = @offset + 1
1673
+ else
1674
+ address2 = FAILURE
1675
+ if @offset > @failure
1676
+ @failure = @offset
1677
+ @expected = []
1678
+ end
1679
+ if @offset == @failure
1680
+ @expected << "[a-zA-Z0-9+\\/]"
1681
+ end
1682
+ end
1683
+ unless address2 == FAILURE
1684
+ elements1 << address2
1685
+ remaining0 -= 1
1686
+ end
1687
+ end
1688
+ if remaining0 <= 0
1689
+ address1 = TreeNode.new(@input[index2...@offset], index2, elements1)
1690
+ @offset = @offset
1691
+ else
1692
+ address1 = FAILURE
1693
+ end
1694
+ unless address1 == FAILURE
1695
+ elements0 << address1
1696
+ address3 = FAILURE
1697
+ index3 = @offset
1698
+ index4 = @offset
1699
+ chunk1 = nil
1700
+ if @offset < @input_size
1701
+ chunk1 = @input[@offset...@offset + 1]
1702
+ end
1703
+ if chunk1 == "="
1704
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1705
+ @offset = @offset + 1
1706
+ else
1707
+ address3 = FAILURE
1708
+ if @offset > @failure
1709
+ @failure = @offset
1710
+ @expected = []
1711
+ end
1712
+ if @offset == @failure
1713
+ @expected << "\"=\""
1714
+ end
1715
+ end
1716
+ if address3 == FAILURE
1717
+ @offset = index4
1718
+ chunk2 = nil
1719
+ if @offset < @input_size
1720
+ chunk2 = @input[@offset...@offset + 2]
1721
+ end
1722
+ if chunk2 == "=="
1723
+ address3 = TreeNode.new(@input[@offset...@offset + 2], @offset)
1724
+ @offset = @offset + 2
1725
+ else
1726
+ address3 = FAILURE
1727
+ if @offset > @failure
1728
+ @failure = @offset
1729
+ @expected = []
1730
+ end
1731
+ if @offset == @failure
1732
+ @expected << "\"==\""
1733
+ end
1734
+ end
1735
+ if address3 == FAILURE
1736
+ @offset = index4
1737
+ end
1738
+ end
1739
+ if address3 == FAILURE
1740
+ address3 = TreeNode.new(@input[index3...index3], index3)
1741
+ @offset = index3
1742
+ end
1743
+ unless address3 == FAILURE
1744
+ elements0 << address3
1745
+ else
1746
+ elements0 = nil
1747
+ @offset = index1
1748
+ end
1749
+ else
1750
+ elements0 = nil
1751
+ @offset = index1
1752
+ end
1753
+ if elements0.nil?
1754
+ address0 = FAILURE
1755
+ else
1756
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
1757
+ @offset = @offset
1758
+ end
1759
+ @cache[:base64_value][index0] = [address0, @offset]
1760
+ return address0
1761
+ end
1762
+
1763
+ def _read_base64_single_quote
1764
+ address0, index0 = FAILURE, @offset
1765
+ cached = @cache[:base64_single_quote][index0]
1766
+ if cached
1767
+ @offset = cached[1]
1768
+ return cached[0]
1769
+ end
1770
+ index1, elements0 = @offset, []
1771
+ address1 = FAILURE
1772
+ address1 = _read_single_quote
1773
+ unless address1 == FAILURE
1774
+ address2 = FAILURE
1775
+ address2 = _read_base64_value
1776
+ unless address2 == FAILURE
1777
+ elements0 << address2
1778
+ address3 = FAILURE
1779
+ address3 = _read_single_quote
1780
+ unless address3 == FAILURE
1781
+ else
1782
+ elements0 = nil
1783
+ @offset = index1
1784
+ end
1785
+ else
1786
+ elements0 = nil
1787
+ @offset = index1
1788
+ end
1789
+ else
1790
+ elements0 = nil
1791
+ @offset = index1
1792
+ end
1793
+ if elements0.nil?
1794
+ address0 = FAILURE
1795
+ else
1796
+ address0 = @actions.make_string(@input, index1, @offset, elements0)
1797
+ @offset = @offset
1798
+ end
1799
+ @cache[:base64_single_quote][index0] = [address0, @offset]
1800
+ return address0
1801
+ end
1802
+
1803
+ def _read_base64_dobule_quote
1804
+ address0, index0 = FAILURE, @offset
1805
+ cached = @cache[:base64_dobule_quote][index0]
1806
+ if cached
1807
+ @offset = cached[1]
1808
+ return cached[0]
1809
+ end
1810
+ index1, elements0 = @offset, []
1811
+ address1 = FAILURE
1812
+ address1 = _read_double_quote
1813
+ unless address1 == FAILURE
1814
+ address2 = FAILURE
1815
+ address2 = _read_base64_value
1816
+ unless address2 == FAILURE
1817
+ elements0 << address2
1818
+ address3 = FAILURE
1819
+ address3 = _read_double_quote
1820
+ unless address3 == FAILURE
1821
+ else
1822
+ elements0 = nil
1823
+ @offset = index1
1824
+ end
1825
+ else
1826
+ elements0 = nil
1827
+ @offset = index1
1828
+ end
1829
+ else
1830
+ elements0 = nil
1831
+ @offset = index1
1832
+ end
1833
+ if elements0.nil?
1834
+ address0 = FAILURE
1835
+ else
1836
+ address0 = @actions.make_string(@input, index1, @offset, elements0)
1837
+ @offset = @offset
1838
+ end
1839
+ @cache[:base64_dobule_quote][index0] = [address0, @offset]
1840
+ return address0
1841
+ end
1842
+
1843
+ def _read_number
1844
+ address0, index0 = FAILURE, @offset
1845
+ cached = @cache[:number][index0]
1846
+ if cached
1847
+ @offset = cached[1]
1848
+ return cached[0]
1849
+ end
1850
+ index1, elements0 = @offset, []
1851
+ address1 = FAILURE
1852
+ index2 = @offset
1853
+ chunk0 = nil
1854
+ if @offset < @input_size
1855
+ chunk0 = @input[@offset...@offset + 1]
1856
+ end
1857
+ if chunk0 == "-"
1858
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1859
+ @offset = @offset + 1
1860
+ else
1861
+ address1 = FAILURE
1862
+ if @offset > @failure
1863
+ @failure = @offset
1864
+ @expected = []
1865
+ end
1866
+ if @offset == @failure
1867
+ @expected << "\"-\""
1868
+ end
1869
+ end
1870
+ if address1 == FAILURE
1871
+ address1 = TreeNode.new(@input[index2...index2], index2)
1872
+ @offset = index2
1873
+ end
1874
+ unless address1 == FAILURE
1875
+ elements0 << address1
1876
+ address2 = FAILURE
1877
+ address2 = _read_integer
1878
+ unless address2 == FAILURE
1879
+ elements0 << address2
1880
+ address3 = FAILURE
1881
+ index3 = @offset
1882
+ address3 = _read_fraction
1883
+ if address3 == FAILURE
1884
+ address3 = TreeNode.new(@input[index3...index3], index3)
1885
+ @offset = index3
1886
+ end
1887
+ unless address3 == FAILURE
1888
+ elements0 << address3
1889
+ address4 = FAILURE
1890
+ index4 = @offset
1891
+ address4 = _read_exponent
1892
+ if address4 == FAILURE
1893
+ address4 = TreeNode.new(@input[index4...index4], index4)
1894
+ @offset = index4
1895
+ end
1896
+ unless address4 == FAILURE
1897
+ elements0 << address4
1898
+ else
1899
+ elements0 = nil
1900
+ @offset = index1
1901
+ end
1902
+ else
1903
+ elements0 = nil
1904
+ @offset = index1
1905
+ end
1906
+ else
1907
+ elements0 = nil
1908
+ @offset = index1
1909
+ end
1910
+ else
1911
+ elements0 = nil
1912
+ @offset = index1
1913
+ end
1914
+ if elements0.nil?
1915
+ address0 = FAILURE
1916
+ else
1917
+ address0 = @actions.make_number(@input, index1, @offset, elements0)
1918
+ @offset = @offset
1919
+ end
1920
+ @cache[:number][index0] = [address0, @offset]
1921
+ return address0
1922
+ end
1923
+
1924
+ def _read_number_as_string
1925
+ address0, index0 = FAILURE, @offset
1926
+ cached = @cache[:number_as_string][index0]
1927
+ if cached
1928
+ @offset = cached[1]
1929
+ return cached[0]
1930
+ end
1931
+ index1, elements0 = @offset, []
1932
+ address1 = FAILURE
1933
+ index2 = @offset
1934
+ chunk0 = nil
1935
+ if @offset < @input_size
1936
+ chunk0 = @input[@offset...@offset + 1]
1937
+ end
1938
+ if chunk0 == "-"
1939
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
1940
+ @offset = @offset + 1
1941
+ else
1942
+ address1 = FAILURE
1943
+ if @offset > @failure
1944
+ @failure = @offset
1945
+ @expected = []
1946
+ end
1947
+ if @offset == @failure
1948
+ @expected << "\"-\""
1949
+ end
1950
+ end
1951
+ if address1 == FAILURE
1952
+ address1 = TreeNode.new(@input[index2...index2], index2)
1953
+ @offset = index2
1954
+ end
1955
+ unless address1 == FAILURE
1956
+ elements0 << address1
1957
+ address2 = FAILURE
1958
+ address2 = _read_integer
1959
+ unless address2 == FAILURE
1960
+ elements0 << address2
1961
+ address3 = FAILURE
1962
+ index3 = @offset
1963
+ address3 = _read_fraction
1964
+ if address3 == FAILURE
1965
+ address3 = TreeNode.new(@input[index3...index3], index3)
1966
+ @offset = index3
1967
+ end
1968
+ unless address3 == FAILURE
1969
+ elements0 << address3
1970
+ address4 = FAILURE
1971
+ index4 = @offset
1972
+ address4 = _read_exponent
1973
+ if address4 == FAILURE
1974
+ address4 = TreeNode.new(@input[index4...index4], index4)
1975
+ @offset = index4
1976
+ end
1977
+ unless address4 == FAILURE
1978
+ elements0 << address4
1979
+ else
1980
+ elements0 = nil
1981
+ @offset = index1
1982
+ end
1983
+ else
1984
+ elements0 = nil
1985
+ @offset = index1
1986
+ end
1987
+ else
1988
+ elements0 = nil
1989
+ @offset = index1
1990
+ end
1991
+ else
1992
+ elements0 = nil
1993
+ @offset = index1
1994
+ end
1995
+ if elements0.nil?
1996
+ address0 = FAILURE
1997
+ else
1998
+ address0 = @actions.make_number_as_string(@input, index1, @offset, elements0)
1999
+ @offset = @offset
2000
+ end
2001
+ @cache[:number_as_string][index0] = [address0, @offset]
2002
+ return address0
2003
+ end
2004
+
2005
+ def _read_integer
2006
+ address0, index0 = FAILURE, @offset
2007
+ cached = @cache[:integer][index0]
2008
+ if cached
2009
+ @offset = cached[1]
2010
+ return cached[0]
2011
+ end
2012
+ index1 = @offset
2013
+ chunk0 = nil
2014
+ if @offset < @input_size
2015
+ chunk0 = @input[@offset...@offset + 1]
2016
+ end
2017
+ if chunk0 == "0"
2018
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2019
+ @offset = @offset + 1
2020
+ else
2021
+ address0 = FAILURE
2022
+ if @offset > @failure
2023
+ @failure = @offset
2024
+ @expected = []
2025
+ end
2026
+ if @offset == @failure
2027
+ @expected << "\"0\""
2028
+ end
2029
+ end
2030
+ if address0 == FAILURE
2031
+ @offset = index1
2032
+ index2, elements0 = @offset, []
2033
+ address1 = FAILURE
2034
+ chunk1 = nil
2035
+ if @offset < @input_size
2036
+ chunk1 = @input[@offset...@offset + 1]
2037
+ end
2038
+ if chunk1 =~ /\A[1-9]/
2039
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2040
+ @offset = @offset + 1
2041
+ else
2042
+ address1 = FAILURE
2043
+ if @offset > @failure
2044
+ @failure = @offset
2045
+ @expected = []
2046
+ end
2047
+ if @offset == @failure
2048
+ @expected << "[1-9]"
2049
+ end
2050
+ end
2051
+ unless address1 == FAILURE
2052
+ elements0 << address1
2053
+ address2 = FAILURE
2054
+ remaining0, index3, elements1, address3 = 0, @offset, [], true
2055
+ until address3 == FAILURE
2056
+ chunk2 = nil
2057
+ if @offset < @input_size
2058
+ chunk2 = @input[@offset...@offset + 1]
2059
+ end
2060
+ if chunk2 =~ /\A[0-9]/
2061
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2062
+ @offset = @offset + 1
2063
+ else
2064
+ address3 = FAILURE
2065
+ if @offset > @failure
2066
+ @failure = @offset
2067
+ @expected = []
2068
+ end
2069
+ if @offset == @failure
2070
+ @expected << "[0-9]"
2071
+ end
2072
+ end
2073
+ unless address3 == FAILURE
2074
+ elements1 << address3
2075
+ remaining0 -= 1
2076
+ end
2077
+ end
2078
+ if remaining0 <= 0
2079
+ address2 = TreeNode.new(@input[index3...@offset], index3, elements1)
2080
+ @offset = @offset
2081
+ else
2082
+ address2 = FAILURE
2083
+ end
2084
+ unless address2 == FAILURE
2085
+ elements0 << address2
2086
+ else
2087
+ elements0 = nil
2088
+ @offset = index2
2089
+ end
2090
+ else
2091
+ elements0 = nil
2092
+ @offset = index2
2093
+ end
2094
+ if elements0.nil?
2095
+ address0 = FAILURE
2096
+ else
2097
+ address0 = TreeNode.new(@input[index2...@offset], index2, elements0)
2098
+ @offset = @offset
2099
+ end
2100
+ if address0 == FAILURE
2101
+ @offset = index1
2102
+ end
2103
+ end
2104
+ @cache[:integer][index0] = [address0, @offset]
2105
+ return address0
2106
+ end
2107
+
2108
+ def _read_fraction
2109
+ address0, index0 = FAILURE, @offset
2110
+ cached = @cache[:fraction][index0]
2111
+ if cached
2112
+ @offset = cached[1]
2113
+ return cached[0]
2114
+ end
2115
+ index1, elements0 = @offset, []
2116
+ address1 = FAILURE
2117
+ chunk0 = nil
2118
+ if @offset < @input_size
2119
+ chunk0 = @input[@offset...@offset + 1]
2120
+ end
2121
+ if chunk0 == "."
2122
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2123
+ @offset = @offset + 1
2124
+ else
2125
+ address1 = FAILURE
2126
+ if @offset > @failure
2127
+ @failure = @offset
2128
+ @expected = []
2129
+ end
2130
+ if @offset == @failure
2131
+ @expected << "\".\""
2132
+ end
2133
+ end
2134
+ unless address1 == FAILURE
2135
+ elements0 << address1
2136
+ address2 = FAILURE
2137
+ remaining0, index2, elements1, address3 = 1, @offset, [], true
2138
+ until address3 == FAILURE
2139
+ chunk1 = nil
2140
+ if @offset < @input_size
2141
+ chunk1 = @input[@offset...@offset + 1]
2142
+ end
2143
+ if chunk1 =~ /\A[0-9]/
2144
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2145
+ @offset = @offset + 1
2146
+ else
2147
+ address3 = FAILURE
2148
+ if @offset > @failure
2149
+ @failure = @offset
2150
+ @expected = []
2151
+ end
2152
+ if @offset == @failure
2153
+ @expected << "[0-9]"
2154
+ end
2155
+ end
2156
+ unless address3 == FAILURE
2157
+ elements1 << address3
2158
+ remaining0 -= 1
2159
+ end
2160
+ end
2161
+ if remaining0 <= 0
2162
+ address2 = TreeNode.new(@input[index2...@offset], index2, elements1)
2163
+ @offset = @offset
2164
+ else
2165
+ address2 = FAILURE
2166
+ end
2167
+ unless address2 == FAILURE
2168
+ elements0 << address2
2169
+ else
2170
+ elements0 = nil
2171
+ @offset = index1
2172
+ end
2173
+ else
2174
+ elements0 = nil
2175
+ @offset = index1
2176
+ end
2177
+ if elements0.nil?
2178
+ address0 = FAILURE
2179
+ else
2180
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
2181
+ @offset = @offset
2182
+ end
2183
+ @cache[:fraction][index0] = [address0, @offset]
2184
+ return address0
2185
+ end
2186
+
2187
+ def _read_exponent
2188
+ address0, index0 = FAILURE, @offset
2189
+ cached = @cache[:exponent][index0]
2190
+ if cached
2191
+ @offset = cached[1]
2192
+ return cached[0]
2193
+ end
2194
+ index1, elements0 = @offset, []
2195
+ address1 = FAILURE
2196
+ index2 = @offset
2197
+ chunk0 = nil
2198
+ if @offset < @input_size
2199
+ chunk0 = @input[@offset...@offset + 1]
2200
+ end
2201
+ if chunk0 == "e"
2202
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2203
+ @offset = @offset + 1
2204
+ else
2205
+ address1 = FAILURE
2206
+ if @offset > @failure
2207
+ @failure = @offset
2208
+ @expected = []
2209
+ end
2210
+ if @offset == @failure
2211
+ @expected << "\"e\""
2212
+ end
2213
+ end
2214
+ if address1 == FAILURE
2215
+ @offset = index2
2216
+ chunk1 = nil
2217
+ if @offset < @input_size
2218
+ chunk1 = @input[@offset...@offset + 1]
2219
+ end
2220
+ if chunk1 == "E"
2221
+ address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2222
+ @offset = @offset + 1
2223
+ else
2224
+ address1 = FAILURE
2225
+ if @offset > @failure
2226
+ @failure = @offset
2227
+ @expected = []
2228
+ end
2229
+ if @offset == @failure
2230
+ @expected << "\"E\""
2231
+ end
2232
+ end
2233
+ if address1 == FAILURE
2234
+ @offset = index2
2235
+ end
2236
+ end
2237
+ unless address1 == FAILURE
2238
+ elements0 << address1
2239
+ address2 = FAILURE
2240
+ index3 = @offset
2241
+ chunk2 = nil
2242
+ if @offset < @input_size
2243
+ chunk2 = @input[@offset...@offset + 1]
2244
+ end
2245
+ if chunk2 == "+"
2246
+ address2 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2247
+ @offset = @offset + 1
2248
+ else
2249
+ address2 = FAILURE
2250
+ if @offset > @failure
2251
+ @failure = @offset
2252
+ @expected = []
2253
+ end
2254
+ if @offset == @failure
2255
+ @expected << "\"+\""
2256
+ end
2257
+ end
2258
+ if address2 == FAILURE
2259
+ @offset = index3
2260
+ chunk3 = nil
2261
+ if @offset < @input_size
2262
+ chunk3 = @input[@offset...@offset + 1]
2263
+ end
2264
+ if chunk3 == "-"
2265
+ address2 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2266
+ @offset = @offset + 1
2267
+ else
2268
+ address2 = FAILURE
2269
+ if @offset > @failure
2270
+ @failure = @offset
2271
+ @expected = []
2272
+ end
2273
+ if @offset == @failure
2274
+ @expected << "\"-\""
2275
+ end
2276
+ end
2277
+ if address2 == FAILURE
2278
+ @offset = index3
2279
+ chunk4 = nil
2280
+ if @offset < @input_size
2281
+ chunk4 = @input[@offset...@offset + 0]
2282
+ end
2283
+ if chunk4 == ""
2284
+ address2 = TreeNode.new(@input[@offset...@offset + 0], @offset)
2285
+ @offset = @offset + 0
2286
+ else
2287
+ address2 = FAILURE
2288
+ if @offset > @failure
2289
+ @failure = @offset
2290
+ @expected = []
2291
+ end
2292
+ if @offset == @failure
2293
+ @expected << "\"\""
2294
+ end
2295
+ end
2296
+ if address2 == FAILURE
2297
+ @offset = index3
2298
+ end
2299
+ end
2300
+ end
2301
+ unless address2 == FAILURE
2302
+ elements0 << address2
2303
+ address3 = FAILURE
2304
+ remaining0, index4, elements1, address4 = 1, @offset, [], true
2305
+ until address4 == FAILURE
2306
+ chunk5 = nil
2307
+ if @offset < @input_size
2308
+ chunk5 = @input[@offset...@offset + 1]
2309
+ end
2310
+ if chunk5 =~ /\A[0-9]/
2311
+ address4 = TreeNode.new(@input[@offset...@offset + 1], @offset)
2312
+ @offset = @offset + 1
2313
+ else
2314
+ address4 = FAILURE
2315
+ if @offset > @failure
2316
+ @failure = @offset
2317
+ @expected = []
2318
+ end
2319
+ if @offset == @failure
2320
+ @expected << "[0-9]"
2321
+ end
2322
+ end
2323
+ unless address4 == FAILURE
2324
+ elements1 << address4
2325
+ remaining0 -= 1
2326
+ end
2327
+ end
2328
+ if remaining0 <= 0
2329
+ address3 = TreeNode.new(@input[index4...@offset], index4, elements1)
2330
+ @offset = @offset
2331
+ else
2332
+ address3 = FAILURE
2333
+ end
2334
+ unless address3 == FAILURE
2335
+ elements0 << address3
2336
+ else
2337
+ elements0 = nil
2338
+ @offset = index1
2339
+ end
2340
+ else
2341
+ elements0 = nil
2342
+ @offset = index1
2343
+ end
2344
+ else
2345
+ elements0 = nil
2346
+ @offset = index1
2347
+ end
2348
+ if elements0.nil?
2349
+ address0 = FAILURE
2350
+ else
2351
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
2352
+ @offset = @offset
2353
+ end
2354
+ @cache[:exponent][index0] = [address0, @offset]
2355
+ return address0
2356
+ end
2357
+
2358
+ def _read_integer_number
2359
+ address0, index0 = FAILURE, @offset
2360
+ cached = @cache[:integer_number][index0]
2361
+ if cached
2362
+ @offset = cached[1]
2363
+ return cached[0]
2364
+ end
2365
+ index1, elements0 = @offset, []
2366
+ address1 = FAILURE
2367
+ address1 = _read_integer
2368
+ unless address1 == FAILURE
2369
+ elements0 << address1
2370
+ address2 = FAILURE
2371
+ chunk0 = nil
2372
+ if @offset < @input_size
2373
+ chunk0 = @input[@offset...@offset + 0]
2374
+ end
2375
+ if chunk0 == ""
2376
+ address2 = TreeNode.new(@input[@offset...@offset + 0], @offset)
2377
+ @offset = @offset + 0
2378
+ else
2379
+ address2 = FAILURE
2380
+ if @offset > @failure
2381
+ @failure = @offset
2382
+ @expected = []
2383
+ end
2384
+ if @offset == @failure
2385
+ @expected << "\"\""
2386
+ end
2387
+ end
2388
+ unless address2 == FAILURE
2389
+ else
2390
+ elements0 = nil
2391
+ @offset = index1
2392
+ end
2393
+ else
2394
+ elements0 = nil
2395
+ @offset = index1
2396
+ end
2397
+ if elements0.nil?
2398
+ address0 = FAILURE
2399
+ else
2400
+ address0 = @actions.make_number(@input, index1, @offset, elements0)
2401
+ @offset = @offset
2402
+ end
2403
+ @cache[:integer_number][index0] = [address0, @offset]
2404
+ return address0
2405
+ end
2406
+
2407
+ def _read_min_key
2408
+ address0, index0 = FAILURE, @offset
2409
+ cached = @cache[:min_key][index0]
2410
+ if cached
2411
+ @offset = cached[1]
2412
+ return cached[0]
2413
+ end
2414
+ chunk0 = nil
2415
+ if @offset < @input_size
2416
+ chunk0 = @input[@offset...@offset + 6]
2417
+ end
2418
+ if chunk0 == "MinKey"
2419
+ address0 = @actions.make_min_key(@input, @offset, @offset + 6)
2420
+ @offset = @offset + 6
2421
+ else
2422
+ address0 = FAILURE
2423
+ if @offset > @failure
2424
+ @failure = @offset
2425
+ @expected = []
2426
+ end
2427
+ if @offset == @failure
2428
+ @expected << "\"MinKey\""
2429
+ end
2430
+ end
2431
+ @cache[:min_key][index0] = [address0, @offset]
2432
+ return address0
2433
+ end
2434
+
2435
+ def _read_max_key
2436
+ address0, index0 = FAILURE, @offset
2437
+ cached = @cache[:max_key][index0]
2438
+ if cached
2439
+ @offset = cached[1]
2440
+ return cached[0]
2441
+ end
2442
+ chunk0 = nil
2443
+ if @offset < @input_size
2444
+ chunk0 = @input[@offset...@offset + 6]
2445
+ end
2446
+ if chunk0 == "MaxKey"
2447
+ address0 = @actions.make_max_key(@input, @offset, @offset + 6)
2448
+ @offset = @offset + 6
2449
+ else
2450
+ address0 = FAILURE
2451
+ if @offset > @failure
2452
+ @failure = @offset
2453
+ @expected = []
2454
+ end
2455
+ if @offset == @failure
2456
+ @expected << "\"MaxKey\""
2457
+ end
2458
+ end
2459
+ @cache[:max_key][index0] = [address0, @offset]
2460
+ return address0
2461
+ end
2462
+
2463
+ def _read_undefined
2464
+ address0, index0 = FAILURE, @offset
2465
+ cached = @cache[:undefined][index0]
2466
+ if cached
2467
+ @offset = cached[1]
2468
+ return cached[0]
2469
+ end
2470
+ chunk0 = nil
2471
+ if @offset < @input_size
2472
+ chunk0 = @input[@offset...@offset + 9]
2473
+ end
2474
+ if chunk0 == "undefined"
2475
+ address0 = @actions.make_undefined(@input, @offset, @offset + 9)
2476
+ @offset = @offset + 9
2477
+ else
2478
+ address0 = FAILURE
2479
+ if @offset > @failure
2480
+ @failure = @offset
2481
+ @expected = []
2482
+ end
2483
+ if @offset == @failure
2484
+ @expected << "\"undefined\""
2485
+ end
2486
+ end
2487
+ @cache[:undefined][index0] = [address0, @offset]
2488
+ return address0
2489
+ end
2490
+
2491
+ def _read_object_id
2492
+ address0, index0 = FAILURE, @offset
2493
+ cached = @cache[:object_id][index0]
2494
+ if cached
2495
+ @offset = cached[1]
2496
+ return cached[0]
2497
+ end
2498
+ index1, elements0 = @offset, []
2499
+ address1 = FAILURE
2500
+ chunk0 = nil
2501
+ if @offset < @input_size
2502
+ chunk0 = @input[@offset...@offset + 8]
2503
+ end
2504
+ if chunk0 == "ObjectId"
2505
+ address1 = TreeNode.new(@input[@offset...@offset + 8], @offset)
2506
+ @offset = @offset + 8
2507
+ else
2508
+ address1 = FAILURE
2509
+ if @offset > @failure
2510
+ @failure = @offset
2511
+ @expected = []
2512
+ end
2513
+ if @offset == @failure
2514
+ @expected << "\"ObjectId\""
2515
+ end
2516
+ end
2517
+ unless address1 == FAILURE
2518
+ address2 = FAILURE
2519
+ address2 = _read_type_open
2520
+ unless address2 == FAILURE
2521
+ address3 = FAILURE
2522
+ address3 = _read_hex_string
2523
+ unless address3 == FAILURE
2524
+ elements0 << address3
2525
+ address4 = FAILURE
2526
+ address4 = _read_type_close
2527
+ unless address4 == FAILURE
2528
+ else
2529
+ elements0 = nil
2530
+ @offset = index1
2531
+ end
2532
+ else
2533
+ elements0 = nil
2534
+ @offset = index1
2535
+ end
2536
+ else
2537
+ elements0 = nil
2538
+ @offset = index1
2539
+ end
2540
+ else
2541
+ elements0 = nil
2542
+ @offset = index1
2543
+ end
2544
+ if elements0.nil?
2545
+ address0 = FAILURE
2546
+ else
2547
+ address0 = @actions.make_object_id(@input, index1, @offset, elements0)
2548
+ @offset = @offset
2549
+ end
2550
+ @cache[:object_id][index0] = [address0, @offset]
2551
+ return address0
2552
+ end
2553
+
2554
+ def _read_bin_data_type
2555
+ address0, index0 = FAILURE, @offset
2556
+ cached = @cache[:bin_data_type][index0]
2557
+ if cached
2558
+ @offset = cached[1]
2559
+ return cached[0]
2560
+ end
2561
+ index1 = @offset
2562
+ address0 = _read_string
2563
+ if address0 == FAILURE
2564
+ @offset = index1
2565
+ address0 = _read_integer_number
2566
+ if address0 == FAILURE
2567
+ @offset = index1
2568
+ end
2569
+ end
2570
+ @cache[:bin_data_type][index0] = [address0, @offset]
2571
+ return address0
2572
+ end
2573
+
2574
+ def _read_bin_data
2575
+ address0, index0 = FAILURE, @offset
2576
+ cached = @cache[:bin_data][index0]
2577
+ if cached
2578
+ @offset = cached[1]
2579
+ return cached[0]
2580
+ end
2581
+ index1, elements0 = @offset, []
2582
+ address1 = FAILURE
2583
+ chunk0 = nil
2584
+ if @offset < @input_size
2585
+ chunk0 = @input[@offset...@offset + 7]
2586
+ end
2587
+ if chunk0 == "BinData"
2588
+ address1 = TreeNode.new(@input[@offset...@offset + 7], @offset)
2589
+ @offset = @offset + 7
2590
+ else
2591
+ address1 = FAILURE
2592
+ if @offset > @failure
2593
+ @failure = @offset
2594
+ @expected = []
2595
+ end
2596
+ if @offset == @failure
2597
+ @expected << "\"BinData\""
2598
+ end
2599
+ end
2600
+ unless address1 == FAILURE
2601
+ address2 = FAILURE
2602
+ address2 = _read_type_open
2603
+ unless address2 == FAILURE
2604
+ address3 = FAILURE
2605
+ address3 = _read_bin_data_type
2606
+ unless address3 == FAILURE
2607
+ elements0 << address3
2608
+ address4 = FAILURE
2609
+ address4 = _read_delimiter
2610
+ unless address4 == FAILURE
2611
+ address5 = FAILURE
2612
+ address5 = _read_base64_string
2613
+ unless address5 == FAILURE
2614
+ elements0 << address5
2615
+ address6 = FAILURE
2616
+ address6 = _read_type_close
2617
+ unless address6 == FAILURE
2618
+ else
2619
+ elements0 = nil
2620
+ @offset = index1
2621
+ end
2622
+ else
2623
+ elements0 = nil
2624
+ @offset = index1
2625
+ end
2626
+ else
2627
+ elements0 = nil
2628
+ @offset = index1
2629
+ end
2630
+ else
2631
+ elements0 = nil
2632
+ @offset = index1
2633
+ end
2634
+ else
2635
+ elements0 = nil
2636
+ @offset = index1
2637
+ end
2638
+ else
2639
+ elements0 = nil
2640
+ @offset = index1
2641
+ end
2642
+ if elements0.nil?
2643
+ address0 = FAILURE
2644
+ else
2645
+ address0 = @actions.make_bin_data(@input, index1, @offset, elements0)
2646
+ @offset = @offset
2647
+ end
2648
+ @cache[:bin_data][index0] = [address0, @offset]
2649
+ return address0
2650
+ end
2651
+
2652
+ def _read_timestamp
2653
+ address0, index0 = FAILURE, @offset
2654
+ cached = @cache[:timestamp][index0]
2655
+ if cached
2656
+ @offset = cached[1]
2657
+ return cached[0]
2658
+ end
2659
+ index1, elements0 = @offset, []
2660
+ address1 = FAILURE
2661
+ chunk0 = nil
2662
+ if @offset < @input_size
2663
+ chunk0 = @input[@offset...@offset + 9]
2664
+ end
2665
+ if chunk0 == "Timestamp"
2666
+ address1 = TreeNode.new(@input[@offset...@offset + 9], @offset)
2667
+ @offset = @offset + 9
2668
+ else
2669
+ address1 = FAILURE
2670
+ if @offset > @failure
2671
+ @failure = @offset
2672
+ @expected = []
2673
+ end
2674
+ if @offset == @failure
2675
+ @expected << "\"Timestamp\""
2676
+ end
2677
+ end
2678
+ unless address1 == FAILURE
2679
+ address2 = FAILURE
2680
+ address2 = _read_type_open
2681
+ unless address2 == FAILURE
2682
+ address3 = FAILURE
2683
+ address3 = _read_integer_number
2684
+ unless address3 == FAILURE
2685
+ elements0 << address3
2686
+ address4 = FAILURE
2687
+ address4 = _read_delimiter
2688
+ unless address4 == FAILURE
2689
+ address5 = FAILURE
2690
+ address5 = _read_integer_number
2691
+ unless address5 == FAILURE
2692
+ elements0 << address5
2693
+ address6 = FAILURE
2694
+ address6 = _read_type_close
2695
+ unless address6 == FAILURE
2696
+ else
2697
+ elements0 = nil
2698
+ @offset = index1
2699
+ end
2700
+ else
2701
+ elements0 = nil
2702
+ @offset = index1
2703
+ end
2704
+ else
2705
+ elements0 = nil
2706
+ @offset = index1
2707
+ end
2708
+ else
2709
+ elements0 = nil
2710
+ @offset = index1
2711
+ end
2712
+ else
2713
+ elements0 = nil
2714
+ @offset = index1
2715
+ end
2716
+ else
2717
+ elements0 = nil
2718
+ @offset = index1
2719
+ end
2720
+ if elements0.nil?
2721
+ address0 = FAILURE
2722
+ else
2723
+ address0 = @actions.make_timestamp(@input, index1, @offset, elements0)
2724
+ @offset = @offset
2725
+ end
2726
+ @cache[:timestamp][index0] = [address0, @offset]
2727
+ return address0
2728
+ end
2729
+
2730
+ def _read_number_long_value
2731
+ address0, index0 = FAILURE, @offset
2732
+ cached = @cache[:number_long_value][index0]
2733
+ if cached
2734
+ @offset = cached[1]
2735
+ return cached[0]
2736
+ end
2737
+ index1 = @offset
2738
+ address0 = _read_integer_number
2739
+ if address0 == FAILURE
2740
+ @offset = index1
2741
+ address0 = _read_integer_string
2742
+ if address0 == FAILURE
2743
+ @offset = index1
2744
+ end
2745
+ end
2746
+ @cache[:number_long_value][index0] = [address0, @offset]
2747
+ return address0
2748
+ end
2749
+
2750
+ def _read_number_long
2751
+ address0, index0 = FAILURE, @offset
2752
+ cached = @cache[:number_long][index0]
2753
+ if cached
2754
+ @offset = cached[1]
2755
+ return cached[0]
2756
+ end
2757
+ index1, elements0 = @offset, []
2758
+ address1 = FAILURE
2759
+ chunk0 = nil
2760
+ if @offset < @input_size
2761
+ chunk0 = @input[@offset...@offset + 10]
2762
+ end
2763
+ if chunk0 == "NumberLong"
2764
+ address1 = TreeNode.new(@input[@offset...@offset + 10], @offset)
2765
+ @offset = @offset + 10
2766
+ else
2767
+ address1 = FAILURE
2768
+ if @offset > @failure
2769
+ @failure = @offset
2770
+ @expected = []
2771
+ end
2772
+ if @offset == @failure
2773
+ @expected << "\"NumberLong\""
2774
+ end
2775
+ end
2776
+ unless address1 == FAILURE
2777
+ address2 = FAILURE
2778
+ address2 = _read_type_open
2779
+ unless address2 == FAILURE
2780
+ address3 = FAILURE
2781
+ address3 = _read_number_long_value
2782
+ unless address3 == FAILURE
2783
+ elements0 << address3
2784
+ address4 = FAILURE
2785
+ address4 = _read_type_close
2786
+ unless address4 == FAILURE
2787
+ else
2788
+ elements0 = nil
2789
+ @offset = index1
2790
+ end
2791
+ else
2792
+ elements0 = nil
2793
+ @offset = index1
2794
+ end
2795
+ else
2796
+ elements0 = nil
2797
+ @offset = index1
2798
+ end
2799
+ else
2800
+ elements0 = nil
2801
+ @offset = index1
2802
+ end
2803
+ if elements0.nil?
2804
+ address0 = FAILURE
2805
+ else
2806
+ address0 = @actions.make_number_long(@input, index1, @offset, elements0)
2807
+ @offset = @offset
2808
+ end
2809
+ @cache[:number_long][index0] = [address0, @offset]
2810
+ return address0
2811
+ end
2812
+
2813
+ def _read_number_decimal_value
2814
+ address0, index0 = FAILURE, @offset
2815
+ cached = @cache[:number_decimal_value][index0]
2816
+ if cached
2817
+ @offset = cached[1]
2818
+ return cached[0]
2819
+ end
2820
+ index1 = @offset
2821
+ address0 = _read_number_as_string
2822
+ if address0 == FAILURE
2823
+ @offset = index1
2824
+ address0 = _read_number_string
2825
+ if address0 == FAILURE
2826
+ @offset = index1
2827
+ end
2828
+ end
2829
+ @cache[:number_decimal_value][index0] = [address0, @offset]
2830
+ return address0
2831
+ end
2832
+
2833
+ def _read_number_decimal
2834
+ address0, index0 = FAILURE, @offset
2835
+ cached = @cache[:number_decimal][index0]
2836
+ if cached
2837
+ @offset = cached[1]
2838
+ return cached[0]
2839
+ end
2840
+ index1, elements0 = @offset, []
2841
+ address1 = FAILURE
2842
+ chunk0 = nil
2843
+ if @offset < @input_size
2844
+ chunk0 = @input[@offset...@offset + 13]
2845
+ end
2846
+ if chunk0 == "NumberDecimal"
2847
+ address1 = TreeNode.new(@input[@offset...@offset + 13], @offset)
2848
+ @offset = @offset + 13
2849
+ else
2850
+ address1 = FAILURE
2851
+ if @offset > @failure
2852
+ @failure = @offset
2853
+ @expected = []
2854
+ end
2855
+ if @offset == @failure
2856
+ @expected << "\"NumberDecimal\""
2857
+ end
2858
+ end
2859
+ unless address1 == FAILURE
2860
+ address2 = FAILURE
2861
+ address2 = _read_type_open
2862
+ unless address2 == FAILURE
2863
+ address3 = FAILURE
2864
+ address3 = _read_number_decimal_value
2865
+ unless address3 == FAILURE
2866
+ elements0 << address3
2867
+ address4 = FAILURE
2868
+ address4 = _read_type_close
2869
+ unless address4 == FAILURE
2870
+ else
2871
+ elements0 = nil
2872
+ @offset = index1
2873
+ end
2874
+ else
2875
+ elements0 = nil
2876
+ @offset = index1
2877
+ end
2878
+ else
2879
+ elements0 = nil
2880
+ @offset = index1
2881
+ end
2882
+ else
2883
+ elements0 = nil
2884
+ @offset = index1
2885
+ end
2886
+ if elements0.nil?
2887
+ address0 = FAILURE
2888
+ else
2889
+ address0 = @actions.make_number_decimal(@input, index1, @offset, elements0)
2890
+ @offset = @offset
2891
+ end
2892
+ @cache[:number_decimal][index0] = [address0, @offset]
2893
+ return address0
2894
+ end
2895
+
2896
+ def _read_date_type
2897
+ address0, index0 = FAILURE, @offset
2898
+ cached = @cache[:date_type][index0]
2899
+ if cached
2900
+ @offset = cached[1]
2901
+ return cached[0]
2902
+ end
2903
+ index1 = @offset
2904
+ index2, elements0 = @offset, []
2905
+ address1 = FAILURE
2906
+ chunk0 = nil
2907
+ if @offset < @input_size
2908
+ chunk0 = @input[@offset...@offset + 3]
2909
+ end
2910
+ if chunk0 == "new"
2911
+ address1 = TreeNode.new(@input[@offset...@offset + 3], @offset)
2912
+ @offset = @offset + 3
2913
+ else
2914
+ address1 = FAILURE
2915
+ if @offset > @failure
2916
+ @failure = @offset
2917
+ @expected = []
2918
+ end
2919
+ if @offset == @failure
2920
+ @expected << "\"new\""
2921
+ end
2922
+ end
2923
+ unless address1 == FAILURE
2924
+ elements0 << address1
2925
+ address2 = FAILURE
2926
+ remaining0, index3, elements1, address3 = 1, @offset, [], true
2927
+ until address3 == FAILURE
2928
+ address3 = _read_space
2929
+ unless address3 == FAILURE
2930
+ elements1 << address3
2931
+ remaining0 -= 1
2932
+ end
2933
+ end
2934
+ if remaining0 <= 0
2935
+ address2 = TreeNode.new(@input[index3...@offset], index3, elements1)
2936
+ @offset = @offset
2937
+ else
2938
+ address2 = FAILURE
2939
+ end
2940
+ unless address2 == FAILURE
2941
+ elements0 << address2
2942
+ address4 = FAILURE
2943
+ chunk1 = nil
2944
+ if @offset < @input_size
2945
+ chunk1 = @input[@offset...@offset + 4]
2946
+ end
2947
+ if chunk1 == "Date"
2948
+ address4 = TreeNode.new(@input[@offset...@offset + 4], @offset)
2949
+ @offset = @offset + 4
2950
+ else
2951
+ address4 = FAILURE
2952
+ if @offset > @failure
2953
+ @failure = @offset
2954
+ @expected = []
2955
+ end
2956
+ if @offset == @failure
2957
+ @expected << "\"Date\""
2958
+ end
2959
+ end
2960
+ unless address4 == FAILURE
2961
+ elements0 << address4
2962
+ else
2963
+ elements0 = nil
2964
+ @offset = index2
2965
+ end
2966
+ else
2967
+ elements0 = nil
2968
+ @offset = index2
2969
+ end
2970
+ else
2971
+ elements0 = nil
2972
+ @offset = index2
2973
+ end
2974
+ if elements0.nil?
2975
+ address0 = FAILURE
2976
+ else
2977
+ address0 = TreeNode.new(@input[index2...@offset], index2, elements0)
2978
+ @offset = @offset
2979
+ end
2980
+ if address0 == FAILURE
2981
+ @offset = index1
2982
+ chunk2 = nil
2983
+ if @offset < @input_size
2984
+ chunk2 = @input[@offset...@offset + 7]
2985
+ end
2986
+ if chunk2 == "ISODate"
2987
+ address0 = TreeNode.new(@input[@offset...@offset + 7], @offset)
2988
+ @offset = @offset + 7
2989
+ else
2990
+ address0 = FAILURE
2991
+ if @offset > @failure
2992
+ @failure = @offset
2993
+ @expected = []
2994
+ end
2995
+ if @offset == @failure
2996
+ @expected << "\"ISODate\""
2997
+ end
2998
+ end
2999
+ if address0 == FAILURE
3000
+ @offset = index1
3001
+ end
3002
+ end
3003
+ @cache[:date_type][index0] = [address0, @offset]
3004
+ return address0
3005
+ end
3006
+
3007
+ def _read_date_value
3008
+ address0, index0 = FAILURE, @offset
3009
+ cached = @cache[:date_value][index0]
3010
+ if cached
3011
+ @offset = cached[1]
3012
+ return cached[0]
3013
+ end
3014
+ index1 = @offset
3015
+ address0 = _read_integer_number
3016
+ if address0 == FAILURE
3017
+ @offset = index1
3018
+ address0 = _read_string
3019
+ if address0 == FAILURE
3020
+ @offset = index1
3021
+ end
3022
+ end
3023
+ @cache[:date_value][index0] = [address0, @offset]
3024
+ return address0
3025
+ end
3026
+
3027
+ def _read_date
3028
+ address0, index0 = FAILURE, @offset
3029
+ cached = @cache[:date][index0]
3030
+ if cached
3031
+ @offset = cached[1]
3032
+ return cached[0]
3033
+ end
3034
+ index1, elements0 = @offset, []
3035
+ address1 = FAILURE
3036
+ address1 = _read_date_type
3037
+ unless address1 == FAILURE
3038
+ address2 = FAILURE
3039
+ address2 = _read_type_open
3040
+ unless address2 == FAILURE
3041
+ address3 = FAILURE
3042
+ address3 = _read_date_value
3043
+ unless address3 == FAILURE
3044
+ elements0 << address3
3045
+ address4 = FAILURE
3046
+ address4 = _read_type_close
3047
+ unless address4 == FAILURE
3048
+ else
3049
+ elements0 = nil
3050
+ @offset = index1
3051
+ end
3052
+ else
3053
+ elements0 = nil
3054
+ @offset = index1
3055
+ end
3056
+ else
3057
+ elements0 = nil
3058
+ @offset = index1
3059
+ end
3060
+ else
3061
+ elements0 = nil
3062
+ @offset = index1
3063
+ end
3064
+ if elements0.nil?
3065
+ address0 = FAILURE
3066
+ else
3067
+ address0 = @actions.make_date(@input, index1, @offset, elements0)
3068
+ @offset = @offset
3069
+ end
3070
+ @cache[:date][index0] = [address0, @offset]
3071
+ return address0
3072
+ end
3073
+
3074
+ def _read_db_ref_type
3075
+ address0, index0 = FAILURE, @offset
3076
+ cached = @cache[:db_ref_type][index0]
3077
+ if cached
3078
+ @offset = cached[1]
3079
+ return cached[0]
3080
+ end
3081
+ index1, elements0 = @offset, []
3082
+ address1 = FAILURE
3083
+ chunk0 = nil
3084
+ if @offset < @input_size
3085
+ chunk0 = @input[@offset...@offset + 5]
3086
+ end
3087
+ if chunk0 == "DBRef"
3088
+ address1 = TreeNode.new(@input[@offset...@offset + 5], @offset)
3089
+ @offset = @offset + 5
3090
+ else
3091
+ address1 = FAILURE
3092
+ if @offset > @failure
3093
+ @failure = @offset
3094
+ @expected = []
3095
+ end
3096
+ if @offset == @failure
3097
+ @expected << "\"DBRef\""
3098
+ end
3099
+ end
3100
+ unless address1 == FAILURE
3101
+ address2 = FAILURE
3102
+ address2 = _read_type_open
3103
+ unless address2 == FAILURE
3104
+ address3 = FAILURE
3105
+ address3 = _read_string
3106
+ unless address3 == FAILURE
3107
+ elements0 << address3
3108
+ address4 = FAILURE
3109
+ address4 = _read_delimiter
3110
+ unless address4 == FAILURE
3111
+ address5 = FAILURE
3112
+ address5 = _read_string
3113
+ unless address5 == FAILURE
3114
+ elements0 << address5
3115
+ address6 = FAILURE
3116
+ address6 = _read_type_close
3117
+ unless address6 == FAILURE
3118
+ else
3119
+ elements0 = nil
3120
+ @offset = index1
3121
+ end
3122
+ else
3123
+ elements0 = nil
3124
+ @offset = index1
3125
+ end
3126
+ else
3127
+ elements0 = nil
3128
+ @offset = index1
3129
+ end
3130
+ else
3131
+ elements0 = nil
3132
+ @offset = index1
3133
+ end
3134
+ else
3135
+ elements0 = nil
3136
+ @offset = index1
3137
+ end
3138
+ else
3139
+ elements0 = nil
3140
+ @offset = index1
3141
+ end
3142
+ if elements0.nil?
3143
+ address0 = FAILURE
3144
+ else
3145
+ address0 = @actions.make_db_ref(@input, index1, @offset, elements0)
3146
+ @offset = @offset
3147
+ end
3148
+ @cache[:db_ref_type][index0] = [address0, @offset]
3149
+ return address0
3150
+ end
3151
+
3152
+ def _read_single_quote
3153
+ address0, index0 = FAILURE, @offset
3154
+ cached = @cache[:single_quote][index0]
3155
+ if cached
3156
+ @offset = cached[1]
3157
+ return cached[0]
3158
+ end
3159
+ chunk0 = nil
3160
+ if @offset < @input_size
3161
+ chunk0 = @input[@offset...@offset + 1]
3162
+ end
3163
+ if chunk0 == "'"
3164
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3165
+ @offset = @offset + 1
3166
+ else
3167
+ address0 = FAILURE
3168
+ if @offset > @failure
3169
+ @failure = @offset
3170
+ @expected = []
3171
+ end
3172
+ if @offset == @failure
3173
+ @expected << "\"'\""
3174
+ end
3175
+ end
3176
+ @cache[:single_quote][index0] = [address0, @offset]
3177
+ return address0
3178
+ end
3179
+
3180
+ def _read_double_quote
3181
+ address0, index0 = FAILURE, @offset
3182
+ cached = @cache[:double_quote][index0]
3183
+ if cached
3184
+ @offset = cached[1]
3185
+ return cached[0]
3186
+ end
3187
+ chunk0 = nil
3188
+ if @offset < @input_size
3189
+ chunk0 = @input[@offset...@offset + 1]
3190
+ end
3191
+ if chunk0 == "\""
3192
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3193
+ @offset = @offset + 1
3194
+ else
3195
+ address0 = FAILURE
3196
+ if @offset > @failure
3197
+ @failure = @offset
3198
+ @expected = []
3199
+ end
3200
+ if @offset == @failure
3201
+ @expected << "'\"'"
3202
+ end
3203
+ end
3204
+ @cache[:double_quote][index0] = [address0, @offset]
3205
+ return address0
3206
+ end
3207
+
3208
+ def _read_left_paren
3209
+ address0, index0 = FAILURE, @offset
3210
+ cached = @cache[:left_paren][index0]
3211
+ if cached
3212
+ @offset = cached[1]
3213
+ return cached[0]
3214
+ end
3215
+ chunk0 = nil
3216
+ if @offset < @input_size
3217
+ chunk0 = @input[@offset...@offset + 1]
3218
+ end
3219
+ if chunk0 == "("
3220
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3221
+ @offset = @offset + 1
3222
+ else
3223
+ address0 = FAILURE
3224
+ if @offset > @failure
3225
+ @failure = @offset
3226
+ @expected = []
3227
+ end
3228
+ if @offset == @failure
3229
+ @expected << "'('"
3230
+ end
3231
+ end
3232
+ @cache[:left_paren][index0] = [address0, @offset]
3233
+ return address0
3234
+ end
3235
+
3236
+ def _read_right_paren
3237
+ address0, index0 = FAILURE, @offset
3238
+ cached = @cache[:right_paren][index0]
3239
+ if cached
3240
+ @offset = cached[1]
3241
+ return cached[0]
3242
+ end
3243
+ chunk0 = nil
3244
+ if @offset < @input_size
3245
+ chunk0 = @input[@offset...@offset + 1]
3246
+ end
3247
+ if chunk0 == ")"
3248
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3249
+ @offset = @offset + 1
3250
+ else
3251
+ address0 = FAILURE
3252
+ if @offset > @failure
3253
+ @failure = @offset
3254
+ @expected = []
3255
+ end
3256
+ if @offset == @failure
3257
+ @expected << "')'"
3258
+ end
3259
+ end
3260
+ @cache[:right_paren][index0] = [address0, @offset]
3261
+ return address0
3262
+ end
3263
+
3264
+ def _read_left_brace
3265
+ address0, index0 = FAILURE, @offset
3266
+ cached = @cache[:left_brace][index0]
3267
+ if cached
3268
+ @offset = cached[1]
3269
+ return cached[0]
3270
+ end
3271
+ chunk0 = nil
3272
+ if @offset < @input_size
3273
+ chunk0 = @input[@offset...@offset + 1]
3274
+ end
3275
+ if chunk0 == "{"
3276
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3277
+ @offset = @offset + 1
3278
+ else
3279
+ address0 = FAILURE
3280
+ if @offset > @failure
3281
+ @failure = @offset
3282
+ @expected = []
3283
+ end
3284
+ if @offset == @failure
3285
+ @expected << "'{'"
3286
+ end
3287
+ end
3288
+ @cache[:left_brace][index0] = [address0, @offset]
3289
+ return address0
3290
+ end
3291
+
3292
+ def _read_right_brace
3293
+ address0, index0 = FAILURE, @offset
3294
+ cached = @cache[:right_brace][index0]
3295
+ if cached
3296
+ @offset = cached[1]
3297
+ return cached[0]
3298
+ end
3299
+ chunk0 = nil
3300
+ if @offset < @input_size
3301
+ chunk0 = @input[@offset...@offset + 1]
3302
+ end
3303
+ if chunk0 == "}"
3304
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3305
+ @offset = @offset + 1
3306
+ else
3307
+ address0 = FAILURE
3308
+ if @offset > @failure
3309
+ @failure = @offset
3310
+ @expected = []
3311
+ end
3312
+ if @offset == @failure
3313
+ @expected << "'}'"
3314
+ end
3315
+ end
3316
+ @cache[:right_brace][index0] = [address0, @offset]
3317
+ return address0
3318
+ end
3319
+
3320
+ def _read_left_bracket
3321
+ address0, index0 = FAILURE, @offset
3322
+ cached = @cache[:left_bracket][index0]
3323
+ if cached
3324
+ @offset = cached[1]
3325
+ return cached[0]
3326
+ end
3327
+ chunk0 = nil
3328
+ if @offset < @input_size
3329
+ chunk0 = @input[@offset...@offset + 1]
3330
+ end
3331
+ if chunk0 == "["
3332
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3333
+ @offset = @offset + 1
3334
+ else
3335
+ address0 = FAILURE
3336
+ if @offset > @failure
3337
+ @failure = @offset
3338
+ @expected = []
3339
+ end
3340
+ if @offset == @failure
3341
+ @expected << "'['"
3342
+ end
3343
+ end
3344
+ @cache[:left_bracket][index0] = [address0, @offset]
3345
+ return address0
3346
+ end
3347
+
3348
+ def _read_right_bracket
3349
+ address0, index0 = FAILURE, @offset
3350
+ cached = @cache[:right_bracket][index0]
3351
+ if cached
3352
+ @offset = cached[1]
3353
+ return cached[0]
3354
+ end
3355
+ chunk0 = nil
3356
+ if @offset < @input_size
3357
+ chunk0 = @input[@offset...@offset + 1]
3358
+ end
3359
+ if chunk0 == "]"
3360
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3361
+ @offset = @offset + 1
3362
+ else
3363
+ address0 = FAILURE
3364
+ if @offset > @failure
3365
+ @failure = @offset
3366
+ @expected = []
3367
+ end
3368
+ if @offset == @failure
3369
+ @expected << "']'"
3370
+ end
3371
+ end
3372
+ @cache[:right_bracket][index0] = [address0, @offset]
3373
+ return address0
3374
+ end
3375
+
3376
+ def _read_comma
3377
+ address0, index0 = FAILURE, @offset
3378
+ cached = @cache[:comma][index0]
3379
+ if cached
3380
+ @offset = cached[1]
3381
+ return cached[0]
3382
+ end
3383
+ chunk0 = nil
3384
+ if @offset < @input_size
3385
+ chunk0 = @input[@offset...@offset + 1]
3386
+ end
3387
+ if chunk0 == ","
3388
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3389
+ @offset = @offset + 1
3390
+ else
3391
+ address0 = FAILURE
3392
+ if @offset > @failure
3393
+ @failure = @offset
3394
+ @expected = []
3395
+ end
3396
+ if @offset == @failure
3397
+ @expected << "','"
3398
+ end
3399
+ end
3400
+ @cache[:comma][index0] = [address0, @offset]
3401
+ return address0
3402
+ end
3403
+
3404
+ def _read_colon
3405
+ address0, index0 = FAILURE, @offset
3406
+ cached = @cache[:colon][index0]
3407
+ if cached
3408
+ @offset = cached[1]
3409
+ return cached[0]
3410
+ end
3411
+ chunk0 = nil
3412
+ if @offset < @input_size
3413
+ chunk0 = @input[@offset...@offset + 1]
3414
+ end
3415
+ if chunk0 == ":"
3416
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3417
+ @offset = @offset + 1
3418
+ else
3419
+ address0 = FAILURE
3420
+ if @offset > @failure
3421
+ @failure = @offset
3422
+ @expected = []
3423
+ end
3424
+ if @offset == @failure
3425
+ @expected << "':'"
3426
+ end
3427
+ end
3428
+ @cache[:colon][index0] = [address0, @offset]
3429
+ return address0
3430
+ end
3431
+
3432
+ def _read_slash
3433
+ address0, index0 = FAILURE, @offset
3434
+ cached = @cache[:slash][index0]
3435
+ if cached
3436
+ @offset = cached[1]
3437
+ return cached[0]
3438
+ end
3439
+ chunk0 = nil
3440
+ if @offset < @input_size
3441
+ chunk0 = @input[@offset...@offset + 1]
3442
+ end
3443
+ if chunk0 == "/"
3444
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3445
+ @offset = @offset + 1
3446
+ else
3447
+ address0 = FAILURE
3448
+ if @offset > @failure
3449
+ @failure = @offset
3450
+ @expected = []
3451
+ end
3452
+ if @offset == @failure
3453
+ @expected << "'/'"
3454
+ end
3455
+ end
3456
+ @cache[:slash][index0] = [address0, @offset]
3457
+ return address0
3458
+ end
3459
+
3460
+ def _read_space
3461
+ address0, index0 = FAILURE, @offset
3462
+ cached = @cache[:space][index0]
3463
+ if cached
3464
+ @offset = cached[1]
3465
+ return cached[0]
3466
+ end
3467
+ chunk0 = nil
3468
+ if @offset < @input_size
3469
+ chunk0 = @input[@offset...@offset + 1]
3470
+ end
3471
+ if chunk0 =~ /\A[\s]/
3472
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3473
+ @offset = @offset + 1
3474
+ else
3475
+ address0 = FAILURE
3476
+ if @offset > @failure
3477
+ @failure = @offset
3478
+ @expected = []
3479
+ end
3480
+ if @offset == @failure
3481
+ @expected << "[\\s]"
3482
+ end
3483
+ end
3484
+ @cache[:space][index0] = [address0, @offset]
3485
+ return address0
3486
+ end
3487
+
3488
+ def _read_new_line
3489
+ address0, index0 = FAILURE, @offset
3490
+ cached = @cache[:new_line][index0]
3491
+ if cached
3492
+ @offset = cached[1]
3493
+ return cached[0]
3494
+ end
3495
+ chunk0 = nil
3496
+ if @offset < @input_size
3497
+ chunk0 = @input[@offset...@offset + 1]
3498
+ end
3499
+ if chunk0 =~ /\A[\n]/
3500
+ address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3501
+ @offset = @offset + 1
3502
+ else
3503
+ address0 = FAILURE
3504
+ if @offset > @failure
3505
+ @failure = @offset
3506
+ @expected = []
3507
+ end
3508
+ if @offset == @failure
3509
+ @expected << "[\\n]"
3510
+ end
3511
+ end
3512
+ @cache[:new_line][index0] = [address0, @offset]
3513
+ return address0
3514
+ end
3515
+
3516
+ def _read_comment
3517
+ address0, index0 = FAILURE, @offset
3518
+ cached = @cache[:comment][index0]
3519
+ if cached
3520
+ @offset = cached[1]
3521
+ return cached[0]
3522
+ end
3523
+ index1, elements0 = @offset, []
3524
+ address1 = FAILURE
3525
+ chunk0 = nil
3526
+ if @offset < @input_size
3527
+ chunk0 = @input[@offset...@offset + 2]
3528
+ end
3529
+ if chunk0 == "//"
3530
+ address1 = TreeNode.new(@input[@offset...@offset + 2], @offset)
3531
+ @offset = @offset + 2
3532
+ else
3533
+ address1 = FAILURE
3534
+ if @offset > @failure
3535
+ @failure = @offset
3536
+ @expected = []
3537
+ end
3538
+ if @offset == @failure
3539
+ @expected << "\"//\""
3540
+ end
3541
+ end
3542
+ unless address1 == FAILURE
3543
+ elements0 << address1
3544
+ address2 = FAILURE
3545
+ remaining0, index2, elements1, address3 = 0, @offset, [], true
3546
+ until address3 == FAILURE
3547
+ chunk1 = nil
3548
+ if @offset < @input_size
3549
+ chunk1 = @input[@offset...@offset + 1]
3550
+ end
3551
+ if chunk1 =~ /\A[^\n]/
3552
+ address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
3553
+ @offset = @offset + 1
3554
+ else
3555
+ address3 = FAILURE
3556
+ if @offset > @failure
3557
+ @failure = @offset
3558
+ @expected = []
3559
+ end
3560
+ if @offset == @failure
3561
+ @expected << "[^\\n]"
3562
+ end
3563
+ end
3564
+ unless address3 == FAILURE
3565
+ elements1 << address3
3566
+ remaining0 -= 1
3567
+ end
3568
+ end
3569
+ if remaining0 <= 0
3570
+ address2 = TreeNode.new(@input[index2...@offset], index2, elements1)
3571
+ @offset = @offset
3572
+ else
3573
+ address2 = FAILURE
3574
+ end
3575
+ unless address2 == FAILURE
3576
+ elements0 << address2
3577
+ else
3578
+ elements0 = nil
3579
+ @offset = index1
3580
+ end
3581
+ else
3582
+ elements0 = nil
3583
+ @offset = index1
3584
+ end
3585
+ if elements0.nil?
3586
+ address0 = FAILURE
3587
+ else
3588
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3589
+ @offset = @offset
3590
+ end
3591
+ @cache[:comment][index0] = [address0, @offset]
3592
+ return address0
3593
+ end
3594
+
3595
+ def _read___
3596
+ address0, index0 = FAILURE, @offset
3597
+ cached = @cache[:__][index0]
3598
+ if cached
3599
+ @offset = cached[1]
3600
+ return cached[0]
3601
+ end
3602
+ remaining0, index1, elements0, address1 = 0, @offset, [], true
3603
+ until address1 == FAILURE
3604
+ index2 = @offset
3605
+ address1 = _read_space
3606
+ if address1 == FAILURE
3607
+ @offset = index2
3608
+ address1 = _read_new_line
3609
+ if address1 == FAILURE
3610
+ @offset = index2
3611
+ address1 = _read_comment
3612
+ if address1 == FAILURE
3613
+ @offset = index2
3614
+ end
3615
+ end
3616
+ end
3617
+ unless address1 == FAILURE
3618
+ elements0 << address1
3619
+ remaining0 -= 1
3620
+ end
3621
+ end
3622
+ if remaining0 <= 0
3623
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3624
+ @offset = @offset
3625
+ else
3626
+ address0 = FAILURE
3627
+ end
3628
+ @cache[:__][index0] = [address0, @offset]
3629
+ return address0
3630
+ end
3631
+
3632
+ def _read_delimiter
3633
+ address0, index0 = FAILURE, @offset
3634
+ cached = @cache[:delimiter][index0]
3635
+ if cached
3636
+ @offset = cached[1]
3637
+ return cached[0]
3638
+ end
3639
+ index1, elements0 = @offset, []
3640
+ address1 = FAILURE
3641
+ address1 = _read___
3642
+ unless address1 == FAILURE
3643
+ address2 = FAILURE
3644
+ address2 = _read_comma
3645
+ unless address2 == FAILURE
3646
+ elements0 << address2
3647
+ address3 = FAILURE
3648
+ address3 = _read___
3649
+ unless address3 == FAILURE
3650
+ else
3651
+ elements0 = nil
3652
+ @offset = index1
3653
+ end
3654
+ else
3655
+ elements0 = nil
3656
+ @offset = index1
3657
+ end
3658
+ else
3659
+ elements0 = nil
3660
+ @offset = index1
3661
+ end
3662
+ if elements0.nil?
3663
+ address0 = FAILURE
3664
+ else
3665
+ address0 = TreeNode24.new(@input[index1...@offset], index1, elements0)
3666
+ @offset = @offset
3667
+ end
3668
+ @cache[:delimiter][index0] = [address0, @offset]
3669
+ return address0
3670
+ end
3671
+
3672
+ def _read_assignment
3673
+ address0, index0 = FAILURE, @offset
3674
+ cached = @cache[:assignment][index0]
3675
+ if cached
3676
+ @offset = cached[1]
3677
+ return cached[0]
3678
+ end
3679
+ index1, elements0 = @offset, []
3680
+ address1 = FAILURE
3681
+ address1 = _read___
3682
+ unless address1 == FAILURE
3683
+ address2 = FAILURE
3684
+ address2 = _read_colon
3685
+ unless address2 == FAILURE
3686
+ address3 = FAILURE
3687
+ address3 = _read___
3688
+ unless address3 == FAILURE
3689
+ else
3690
+ elements0 = nil
3691
+ @offset = index1
3692
+ end
3693
+ else
3694
+ elements0 = nil
3695
+ @offset = index1
3696
+ end
3697
+ else
3698
+ elements0 = nil
3699
+ @offset = index1
3700
+ end
3701
+ if elements0.nil?
3702
+ address0 = FAILURE
3703
+ else
3704
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3705
+ @offset = @offset
3706
+ end
3707
+ @cache[:assignment][index0] = [address0, @offset]
3708
+ return address0
3709
+ end
3710
+
3711
+ def _read_object_open
3712
+ address0, index0 = FAILURE, @offset
3713
+ cached = @cache[:object_open][index0]
3714
+ if cached
3715
+ @offset = cached[1]
3716
+ return cached[0]
3717
+ end
3718
+ index1, elements0 = @offset, []
3719
+ address1 = FAILURE
3720
+ address1 = _read___
3721
+ unless address1 == FAILURE
3722
+ address2 = FAILURE
3723
+ address2 = _read_left_brace
3724
+ unless address2 == FAILURE
3725
+ address3 = FAILURE
3726
+ address3 = _read___
3727
+ unless address3 == FAILURE
3728
+ else
3729
+ elements0 = nil
3730
+ @offset = index1
3731
+ end
3732
+ else
3733
+ elements0 = nil
3734
+ @offset = index1
3735
+ end
3736
+ else
3737
+ elements0 = nil
3738
+ @offset = index1
3739
+ end
3740
+ if elements0.nil?
3741
+ address0 = FAILURE
3742
+ else
3743
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3744
+ @offset = @offset
3745
+ end
3746
+ @cache[:object_open][index0] = [address0, @offset]
3747
+ return address0
3748
+ end
3749
+
3750
+ def _read_object_close
3751
+ address0, index0 = FAILURE, @offset
3752
+ cached = @cache[:object_close][index0]
3753
+ if cached
3754
+ @offset = cached[1]
3755
+ return cached[0]
3756
+ end
3757
+ index1, elements0 = @offset, []
3758
+ address1 = FAILURE
3759
+ address1 = _read___
3760
+ unless address1 == FAILURE
3761
+ address2 = FAILURE
3762
+ address2 = _read_right_brace
3763
+ unless address2 == FAILURE
3764
+ address3 = FAILURE
3765
+ address3 = _read___
3766
+ unless address3 == FAILURE
3767
+ else
3768
+ elements0 = nil
3769
+ @offset = index1
3770
+ end
3771
+ else
3772
+ elements0 = nil
3773
+ @offset = index1
3774
+ end
3775
+ else
3776
+ elements0 = nil
3777
+ @offset = index1
3778
+ end
3779
+ if elements0.nil?
3780
+ address0 = FAILURE
3781
+ else
3782
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3783
+ @offset = @offset
3784
+ end
3785
+ @cache[:object_close][index0] = [address0, @offset]
3786
+ return address0
3787
+ end
3788
+
3789
+ def _read_array_open
3790
+ address0, index0 = FAILURE, @offset
3791
+ cached = @cache[:array_open][index0]
3792
+ if cached
3793
+ @offset = cached[1]
3794
+ return cached[0]
3795
+ end
3796
+ index1, elements0 = @offset, []
3797
+ address1 = FAILURE
3798
+ address1 = _read___
3799
+ unless address1 == FAILURE
3800
+ address2 = FAILURE
3801
+ address2 = _read_left_bracket
3802
+ unless address2 == FAILURE
3803
+ address3 = FAILURE
3804
+ address3 = _read___
3805
+ unless address3 == FAILURE
3806
+ else
3807
+ elements0 = nil
3808
+ @offset = index1
3809
+ end
3810
+ else
3811
+ elements0 = nil
3812
+ @offset = index1
3813
+ end
3814
+ else
3815
+ elements0 = nil
3816
+ @offset = index1
3817
+ end
3818
+ if elements0.nil?
3819
+ address0 = FAILURE
3820
+ else
3821
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3822
+ @offset = @offset
3823
+ end
3824
+ @cache[:array_open][index0] = [address0, @offset]
3825
+ return address0
3826
+ end
3827
+
3828
+ def _read_array_close
3829
+ address0, index0 = FAILURE, @offset
3830
+ cached = @cache[:array_close][index0]
3831
+ if cached
3832
+ @offset = cached[1]
3833
+ return cached[0]
3834
+ end
3835
+ index1, elements0 = @offset, []
3836
+ address1 = FAILURE
3837
+ address1 = _read___
3838
+ unless address1 == FAILURE
3839
+ address2 = FAILURE
3840
+ address2 = _read_right_bracket
3841
+ unless address2 == FAILURE
3842
+ address3 = FAILURE
3843
+ address3 = _read___
3844
+ unless address3 == FAILURE
3845
+ else
3846
+ elements0 = nil
3847
+ @offset = index1
3848
+ end
3849
+ else
3850
+ elements0 = nil
3851
+ @offset = index1
3852
+ end
3853
+ else
3854
+ elements0 = nil
3855
+ @offset = index1
3856
+ end
3857
+ if elements0.nil?
3858
+ address0 = FAILURE
3859
+ else
3860
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3861
+ @offset = @offset
3862
+ end
3863
+ @cache[:array_close][index0] = [address0, @offset]
3864
+ return address0
3865
+ end
3866
+
3867
+ def _read_type_open
3868
+ address0, index0 = FAILURE, @offset
3869
+ cached = @cache[:type_open][index0]
3870
+ if cached
3871
+ @offset = cached[1]
3872
+ return cached[0]
3873
+ end
3874
+ index1, elements0 = @offset, []
3875
+ address1 = FAILURE
3876
+ remaining0, index2, elements1, address2 = 0, @offset, [], true
3877
+ until address2 == FAILURE
3878
+ address2 = _read_space
3879
+ unless address2 == FAILURE
3880
+ elements1 << address2
3881
+ remaining0 -= 1
3882
+ end
3883
+ end
3884
+ if remaining0 <= 0
3885
+ address1 = TreeNode.new(@input[index2...@offset], index2, elements1)
3886
+ @offset = @offset
3887
+ else
3888
+ address1 = FAILURE
3889
+ end
3890
+ unless address1 == FAILURE
3891
+ address3 = FAILURE
3892
+ address3 = _read_left_paren
3893
+ unless address3 == FAILURE
3894
+ address4 = FAILURE
3895
+ remaining1, index3, elements2, address5 = 0, @offset, [], true
3896
+ until address5 == FAILURE
3897
+ address5 = _read_space
3898
+ unless address5 == FAILURE
3899
+ elements2 << address5
3900
+ remaining1 -= 1
3901
+ end
3902
+ end
3903
+ if remaining1 <= 0
3904
+ address4 = TreeNode.new(@input[index3...@offset], index3, elements2)
3905
+ @offset = @offset
3906
+ else
3907
+ address4 = FAILURE
3908
+ end
3909
+ unless address4 == FAILURE
3910
+ else
3911
+ elements0 = nil
3912
+ @offset = index1
3913
+ end
3914
+ else
3915
+ elements0 = nil
3916
+ @offset = index1
3917
+ end
3918
+ else
3919
+ elements0 = nil
3920
+ @offset = index1
3921
+ end
3922
+ if elements0.nil?
3923
+ address0 = FAILURE
3924
+ else
3925
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3926
+ @offset = @offset
3927
+ end
3928
+ @cache[:type_open][index0] = [address0, @offset]
3929
+ return address0
3930
+ end
3931
+
3932
+ def _read_type_close
3933
+ address0, index0 = FAILURE, @offset
3934
+ cached = @cache[:type_close][index0]
3935
+ if cached
3936
+ @offset = cached[1]
3937
+ return cached[0]
3938
+ end
3939
+ index1, elements0 = @offset, []
3940
+ address1 = FAILURE
3941
+ remaining0, index2, elements1, address2 = 0, @offset, [], true
3942
+ until address2 == FAILURE
3943
+ address2 = _read_space
3944
+ unless address2 == FAILURE
3945
+ elements1 << address2
3946
+ remaining0 -= 1
3947
+ end
3948
+ end
3949
+ if remaining0 <= 0
3950
+ address1 = TreeNode.new(@input[index2...@offset], index2, elements1)
3951
+ @offset = @offset
3952
+ else
3953
+ address1 = FAILURE
3954
+ end
3955
+ unless address1 == FAILURE
3956
+ address3 = FAILURE
3957
+ address3 = _read_right_paren
3958
+ unless address3 == FAILURE
3959
+ else
3960
+ elements0 = nil
3961
+ @offset = index1
3962
+ end
3963
+ else
3964
+ elements0 = nil
3965
+ @offset = index1
3966
+ end
3967
+ if elements0.nil?
3968
+ address0 = FAILURE
3969
+ else
3970
+ address0 = TreeNode.new(@input[index1...@offset], index1, elements0)
3971
+ @offset = @offset
3972
+ end
3973
+ @cache[:type_close][index0] = [address0, @offset]
3974
+ return address0
3975
+ end
3976
+ end
3977
+
3978
+ class Parser
3979
+ include Grammar
3980
+
3981
+ def initialize(input, actions, types)
3982
+ @input = input
3983
+ @input_size = input.size
3984
+ @actions = actions
3985
+ @types = types
3986
+ @offset = 0
3987
+ @cache = Hash.new { |h,k| h[k] = {} }
3988
+ @failure = 0
3989
+ @expected = []
3990
+ end
3991
+
3992
+ def parse
3993
+ tree = _read_root
3994
+ if tree != FAILURE and @offset == @input_size
3995
+ return tree
3996
+ end
3997
+ if @expected.empty?
3998
+ @failure = @offset
3999
+ @expected << "<EOF>"
4000
+ end
4001
+ raise ParseError, Parser.format_error(@input, @failure, @expected)
4002
+ end
4003
+
4004
+ def self.format_error(input, offset, expected)
4005
+ lines, line_no, position = input.split(/\n/), 0, 0
4006
+ while position <= offset
4007
+ position += lines[line_no].size + 1
4008
+ line_no += 1
4009
+ end
4010
+ message, line = "Line #{line_no}: expected #{expected * ", "}\n", lines[line_no - 1]
4011
+ message += "#{line}\n"
4012
+ position -= line.size + 1
4013
+ message += " " * (offset - position)
4014
+ return message + "^"
4015
+ end
4016
+ end
4017
+
4018
+ def self.parse(input, options = {})
4019
+ parser = Parser.new(input, options[:actions], options[:types])
4020
+ parser.parse
4021
+ end
4022
+ end