siren 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,86 @@
1
+ module Siren
2
+ grammar Json
3
+ rule value
4
+ space data:(object / array / string / number / true / false / null) space {
5
+ def value
6
+ data.value
7
+ end
8
+ }
9
+ end
10
+
11
+ rule object
12
+ "{" space list:( first:(key_value_pair) others:("," key_value_pair)* )? "}" {
13
+ def value
14
+ pairs = [list.first] + list.others.elements.map { |e| e.key_value_pair }
15
+ pairs.inject({}) do |hash, pair|
16
+ hash[pair.string.value] = pair.value.value
17
+ hash
18
+ end
19
+ rescue
20
+ {}
21
+ end
22
+ }
23
+ end
24
+
25
+ rule key_value_pair
26
+ space string space ":" value
27
+ end
28
+
29
+ rule array
30
+ "[" space list:( first:(value) others:("," value)* )? "]" {
31
+ def value
32
+ [list.first.value] + list.others.elements.map { |v| v.value.value }
33
+ rescue
34
+ []
35
+ end
36
+ }
37
+ end
38
+
39
+ rule string
40
+ '"' ('\\' ('"' / '\\' / '/' / 'b' / 'f' / 'n' / 'r' / 't' / 'u' hex hex hex hex) / [^\"\\])* '"' {
41
+ def value
42
+ eval(text_value)
43
+ end
44
+ }
45
+ end
46
+
47
+ rule number
48
+ "-"? ("0" / [1-9] digit*) ("." digit+)? ([eE] [+-]? digit+)? {
49
+ def value
50
+ eval(text_value)
51
+ end
52
+ }
53
+ end
54
+
55
+ rule digit
56
+ [0-9]
57
+ end
58
+
59
+ rule hex
60
+ [a-f] / digit
61
+ end
62
+
63
+ rule true
64
+ "true" {
65
+ def value; true; end
66
+ }
67
+ end
68
+
69
+ rule false
70
+ "false" {
71
+ def value; false; end
72
+ }
73
+ end
74
+
75
+ rule null
76
+ "null" {
77
+ def value; nil; end
78
+ }
79
+ end
80
+
81
+ rule space
82
+ [\s\n\t]*
83
+ end
84
+ end
85
+ end
86
+
@@ -0,0 +1,2414 @@
1
+ module Siren
2
+ module JsonQuery
3
+ include Treetop::Runtime
4
+
5
+ def root
6
+ @root || :expression
7
+ end
8
+
9
+ def _nt_expression
10
+ start_index = index
11
+ if node_cache[:expression].has_key?(index)
12
+ cached = node_cache[:expression][index]
13
+ @index = cached.interval.end if cached
14
+ return cached
15
+ end
16
+
17
+ i0 = index
18
+ r1 = _nt_sum
19
+ if r1
20
+ r0 = r1
21
+ else
22
+ r2 = _nt_product
23
+ if r2
24
+ r0 = r2
25
+ else
26
+ r3 = _nt_divmod
27
+ if r3
28
+ r0 = r3
29
+ else
30
+ r4 = _nt_atom
31
+ if r4
32
+ r0 = r4
33
+ else
34
+ self.index = i0
35
+ r0 = nil
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ node_cache[:expression][start_index] = r0
42
+
43
+ return r0
44
+ end
45
+
46
+ def _nt_boolean_expression
47
+ start_index = index
48
+ if node_cache[:boolean_expression].has_key?(index)
49
+ cached = node_cache[:boolean_expression][index]
50
+ @index = cached.interval.end if cached
51
+ return cached
52
+ end
53
+
54
+ i0 = index
55
+ r1 = _nt_or_expression
56
+ if r1
57
+ r0 = r1
58
+ else
59
+ r2 = _nt_and_expression
60
+ if r2
61
+ r0 = r2
62
+ else
63
+ r3 = _nt_comparison
64
+ if r3
65
+ r0 = r3
66
+ else
67
+ r4 = _nt_boolean_atom
68
+ if r4
69
+ r0 = r4
70
+ else
71
+ self.index = i0
72
+ r0 = nil
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ node_cache[:boolean_expression][start_index] = r0
79
+
80
+ return r0
81
+ end
82
+
83
+ module OrExpression0
84
+ def first
85
+ elements[0]
86
+ end
87
+
88
+ def second
89
+ elements[2]
90
+ end
91
+ end
92
+
93
+ def _nt_or_expression
94
+ start_index = index
95
+ if node_cache[:or_expression].has_key?(index)
96
+ cached = node_cache[:or_expression][index]
97
+ @index = cached.interval.end if cached
98
+ return cached
99
+ end
100
+
101
+ i0 = index
102
+ i1, s1 = index, []
103
+ r2 = _nt_and_expression
104
+ s1 << r2
105
+ if r2
106
+ if input.index("|", index) == index
107
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
108
+ @index += 1
109
+ else
110
+ terminal_parse_failure("|")
111
+ r3 = nil
112
+ end
113
+ s1 << r3
114
+ if r3
115
+ r4 = _nt_or_expression
116
+ s1 << r4
117
+ end
118
+ end
119
+ if s1.last
120
+ r1 = instantiate_node(Or,input, i1...index, s1)
121
+ r1.extend(OrExpression0)
122
+ else
123
+ self.index = i1
124
+ r1 = nil
125
+ end
126
+ if r1
127
+ r0 = r1
128
+ else
129
+ r5 = _nt_and_expression
130
+ if r5
131
+ r0 = r5
132
+ else
133
+ self.index = i0
134
+ r0 = nil
135
+ end
136
+ end
137
+
138
+ node_cache[:or_expression][start_index] = r0
139
+
140
+ return r0
141
+ end
142
+
143
+ module AndExpression0
144
+ def first
145
+ elements[0]
146
+ end
147
+
148
+ def second
149
+ elements[2]
150
+ end
151
+ end
152
+
153
+ def _nt_and_expression
154
+ start_index = index
155
+ if node_cache[:and_expression].has_key?(index)
156
+ cached = node_cache[:and_expression][index]
157
+ @index = cached.interval.end if cached
158
+ return cached
159
+ end
160
+
161
+ i0 = index
162
+ i1, s1 = index, []
163
+ r2 = _nt_comparison
164
+ s1 << r2
165
+ if r2
166
+ if input.index("&", index) == index
167
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
168
+ @index += 1
169
+ else
170
+ terminal_parse_failure("&")
171
+ r3 = nil
172
+ end
173
+ s1 << r3
174
+ if r3
175
+ r4 = _nt_and_expression
176
+ s1 << r4
177
+ end
178
+ end
179
+ if s1.last
180
+ r1 = instantiate_node(And,input, i1...index, s1)
181
+ r1.extend(AndExpression0)
182
+ else
183
+ self.index = i1
184
+ r1 = nil
185
+ end
186
+ if r1
187
+ r0 = r1
188
+ else
189
+ r5 = _nt_comparison
190
+ if r5
191
+ r0 = r5
192
+ else
193
+ self.index = i0
194
+ r0 = nil
195
+ end
196
+ end
197
+
198
+ node_cache[:and_expression][start_index] = r0
199
+
200
+ return r0
201
+ end
202
+
203
+ module Comparison0
204
+ def first
205
+ elements[0]
206
+ end
207
+
208
+ def comparator
209
+ elements[1]
210
+ end
211
+
212
+ def second
213
+ elements[2]
214
+ end
215
+ end
216
+
217
+ def _nt_comparison
218
+ start_index = index
219
+ if node_cache[:comparison].has_key?(index)
220
+ cached = node_cache[:comparison][index]
221
+ @index = cached.interval.end if cached
222
+ return cached
223
+ end
224
+
225
+ i0 = index
226
+ i1, s1 = index, []
227
+ r2 = _nt_expression
228
+ s1 << r2
229
+ if r2
230
+ r3 = _nt_comparator
231
+ s1 << r3
232
+ if r3
233
+ r4 = _nt_expression
234
+ s1 << r4
235
+ end
236
+ end
237
+ if s1.last
238
+ r1 = instantiate_node(Comparison,input, i1...index, s1)
239
+ r1.extend(Comparison0)
240
+ else
241
+ self.index = i1
242
+ r1 = nil
243
+ end
244
+ if r1
245
+ r0 = r1
246
+ else
247
+ r5 = _nt_boolean_atom
248
+ if r5
249
+ r0 = r5
250
+ else
251
+ self.index = i0
252
+ r0 = nil
253
+ end
254
+ end
255
+
256
+ node_cache[:comparison][start_index] = r0
257
+
258
+ return r0
259
+ end
260
+
261
+ module BooleanAtom0
262
+ def boolean_expression
263
+ elements[1]
264
+ end
265
+
266
+ end
267
+
268
+ module BooleanAtom1
269
+ def space
270
+ elements[0]
271
+ end
272
+
273
+ def space
274
+ elements[2]
275
+ end
276
+ end
277
+
278
+ def _nt_boolean_atom
279
+ start_index = index
280
+ if node_cache[:boolean_atom].has_key?(index)
281
+ cached = node_cache[:boolean_atom][index]
282
+ @index = cached.interval.end if cached
283
+ return cached
284
+ end
285
+
286
+ i0, s0 = index, []
287
+ r1 = _nt_space
288
+ s0 << r1
289
+ if r1
290
+ i2 = index
291
+ i3, s3 = index, []
292
+ if input.index("(", index) == index
293
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
294
+ @index += 1
295
+ else
296
+ terminal_parse_failure("(")
297
+ r4 = nil
298
+ end
299
+ s3 << r4
300
+ if r4
301
+ r5 = _nt_boolean_expression
302
+ s3 << r5
303
+ if r5
304
+ if input.index(")", index) == index
305
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
306
+ @index += 1
307
+ else
308
+ terminal_parse_failure(")")
309
+ r6 = nil
310
+ end
311
+ s3 << r6
312
+ end
313
+ end
314
+ if s3.last
315
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
316
+ r3.extend(BooleanAtom0)
317
+ else
318
+ self.index = i3
319
+ r3 = nil
320
+ end
321
+ if r3
322
+ r2 = r3
323
+ else
324
+ r7 = _nt_boolean
325
+ if r7
326
+ r2 = r7
327
+ else
328
+ self.index = i2
329
+ r2 = nil
330
+ end
331
+ end
332
+ s0 << r2
333
+ if r2
334
+ r8 = _nt_space
335
+ s0 << r8
336
+ end
337
+ end
338
+ if s0.last
339
+ r0 = instantiate_node(BooleanAtom,input, i0...index, s0)
340
+ r0.extend(BooleanAtom1)
341
+ else
342
+ self.index = i0
343
+ r0 = nil
344
+ end
345
+
346
+ node_cache[:boolean_atom][start_index] = r0
347
+
348
+ return r0
349
+ end
350
+
351
+ module Sum0
352
+ def first
353
+ elements[0]
354
+ end
355
+
356
+ def operator
357
+ elements[1]
358
+ end
359
+
360
+ def second
361
+ elements[2]
362
+ end
363
+ end
364
+
365
+ def _nt_sum
366
+ start_index = index
367
+ if node_cache[:sum].has_key?(index)
368
+ cached = node_cache[:sum][index]
369
+ @index = cached.interval.end if cached
370
+ return cached
371
+ end
372
+
373
+ i0 = index
374
+ i1, s1 = index, []
375
+ r2 = _nt_product
376
+ s1 << r2
377
+ if r2
378
+ i3 = index
379
+ r4 = _nt_add
380
+ if r4
381
+ r3 = r4
382
+ else
383
+ r5 = _nt_subtract
384
+ if r5
385
+ r3 = r5
386
+ else
387
+ self.index = i3
388
+ r3 = nil
389
+ end
390
+ end
391
+ s1 << r3
392
+ if r3
393
+ r6 = _nt_sum
394
+ s1 << r6
395
+ end
396
+ end
397
+ if s1.last
398
+ r1 = instantiate_node(Sum,input, i1...index, s1)
399
+ r1.extend(Sum0)
400
+ else
401
+ self.index = i1
402
+ r1 = nil
403
+ end
404
+ if r1
405
+ r0 = r1
406
+ else
407
+ r7 = _nt_product
408
+ if r7
409
+ r0 = r7
410
+ else
411
+ self.index = i0
412
+ r0 = nil
413
+ end
414
+ end
415
+
416
+ node_cache[:sum][start_index] = r0
417
+
418
+ return r0
419
+ end
420
+
421
+ module Product0
422
+ def first
423
+ elements[0]
424
+ end
425
+
426
+ def operator
427
+ elements[1]
428
+ end
429
+
430
+ def second
431
+ elements[2]
432
+ end
433
+ end
434
+
435
+ def _nt_product
436
+ start_index = index
437
+ if node_cache[:product].has_key?(index)
438
+ cached = node_cache[:product][index]
439
+ @index = cached.interval.end if cached
440
+ return cached
441
+ end
442
+
443
+ i0 = index
444
+ i1, s1 = index, []
445
+ r2 = _nt_divmod
446
+ s1 << r2
447
+ if r2
448
+ i3 = index
449
+ r4 = _nt_times
450
+ if r4
451
+ r3 = r4
452
+ else
453
+ r5 = _nt_divide
454
+ if r5
455
+ r3 = r5
456
+ else
457
+ self.index = i3
458
+ r3 = nil
459
+ end
460
+ end
461
+ s1 << r3
462
+ if r3
463
+ r6 = _nt_product
464
+ s1 << r6
465
+ end
466
+ end
467
+ if s1.last
468
+ r1 = instantiate_node(Product,input, i1...index, s1)
469
+ r1.extend(Product0)
470
+ else
471
+ self.index = i1
472
+ r1 = nil
473
+ end
474
+ if r1
475
+ r0 = r1
476
+ else
477
+ r7 = _nt_divmod
478
+ if r7
479
+ r0 = r7
480
+ else
481
+ self.index = i0
482
+ r0 = nil
483
+ end
484
+ end
485
+
486
+ node_cache[:product][start_index] = r0
487
+
488
+ return r0
489
+ end
490
+
491
+ module Divmod0
492
+ def first
493
+ elements[0]
494
+ end
495
+
496
+ def second
497
+ elements[2]
498
+ end
499
+ end
500
+
501
+ def _nt_divmod
502
+ start_index = index
503
+ if node_cache[:divmod].has_key?(index)
504
+ cached = node_cache[:divmod][index]
505
+ @index = cached.interval.end if cached
506
+ return cached
507
+ end
508
+
509
+ i0 = index
510
+ i1, s1 = index, []
511
+ r2 = _nt_atom
512
+ s1 << r2
513
+ if r2
514
+ if input.index('%', index) == index
515
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
516
+ @index += 1
517
+ else
518
+ terminal_parse_failure('%')
519
+ r3 = nil
520
+ end
521
+ s1 << r3
522
+ if r3
523
+ r4 = _nt_divmod
524
+ s1 << r4
525
+ end
526
+ end
527
+ if s1.last
528
+ r1 = instantiate_node(Divmod,input, i1...index, s1)
529
+ r1.extend(Divmod0)
530
+ else
531
+ self.index = i1
532
+ r1 = nil
533
+ end
534
+ if r1
535
+ r0 = r1
536
+ else
537
+ r5 = _nt_atom
538
+ if r5
539
+ r0 = r5
540
+ else
541
+ self.index = i0
542
+ r0 = nil
543
+ end
544
+ end
545
+
546
+ node_cache[:divmod][start_index] = r0
547
+
548
+ return r0
549
+ end
550
+
551
+ module Atom0
552
+ def expression
553
+ elements[1]
554
+ end
555
+
556
+ end
557
+
558
+ module Atom1
559
+ def space
560
+ elements[0]
561
+ end
562
+
563
+ def space
564
+ elements[2]
565
+ end
566
+ end
567
+
568
+ def _nt_atom
569
+ start_index = index
570
+ if node_cache[:atom].has_key?(index)
571
+ cached = node_cache[:atom][index]
572
+ @index = cached.interval.end if cached
573
+ return cached
574
+ end
575
+
576
+ i0, s0 = index, []
577
+ r1 = _nt_space
578
+ s0 << r1
579
+ if r1
580
+ i2 = index
581
+ i3, s3 = index, []
582
+ if input.index("(", index) == index
583
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
584
+ @index += 1
585
+ else
586
+ terminal_parse_failure("(")
587
+ r4 = nil
588
+ end
589
+ s3 << r4
590
+ if r4
591
+ r5 = _nt_expression
592
+ s3 << r5
593
+ if r5
594
+ if input.index(")", index) == index
595
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
596
+ @index += 1
597
+ else
598
+ terminal_parse_failure(")")
599
+ r6 = nil
600
+ end
601
+ s3 << r6
602
+ end
603
+ end
604
+ if s3.last
605
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
606
+ r3.extend(Atom0)
607
+ else
608
+ self.index = i3
609
+ r3 = nil
610
+ end
611
+ if r3
612
+ r2 = r3
613
+ else
614
+ r7 = _nt_query
615
+ if r7
616
+ r2 = r7
617
+ else
618
+ r8 = _nt_number
619
+ if r8
620
+ r2 = r8
621
+ else
622
+ r9 = _nt_string
623
+ if r9
624
+ r2 = r9
625
+ else
626
+ r10 = _nt_boolean
627
+ if r10
628
+ r2 = r10
629
+ else
630
+ r11 = _nt_null
631
+ if r11
632
+ r2 = r11
633
+ else
634
+ self.index = i2
635
+ r2 = nil
636
+ end
637
+ end
638
+ end
639
+ end
640
+ end
641
+ end
642
+ s0 << r2
643
+ if r2
644
+ r12 = _nt_space
645
+ s0 << r12
646
+ end
647
+ end
648
+ if s0.last
649
+ r0 = instantiate_node(Atom,input, i0...index, s0)
650
+ r0.extend(Atom1)
651
+ else
652
+ self.index = i0
653
+ r0 = nil
654
+ end
655
+
656
+ node_cache[:atom][start_index] = r0
657
+
658
+ return r0
659
+ end
660
+
661
+ def _nt_times
662
+ start_index = index
663
+ if node_cache[:times].has_key?(index)
664
+ cached = node_cache[:times][index]
665
+ @index = cached.interval.end if cached
666
+ return cached
667
+ end
668
+
669
+ if input.index("*", index) == index
670
+ r0 = instantiate_node(Multiplication,input, index...(index + 1))
671
+ @index += 1
672
+ else
673
+ terminal_parse_failure("*")
674
+ r0 = nil
675
+ end
676
+
677
+ node_cache[:times][start_index] = r0
678
+
679
+ return r0
680
+ end
681
+
682
+ def _nt_divide
683
+ start_index = index
684
+ if node_cache[:divide].has_key?(index)
685
+ cached = node_cache[:divide][index]
686
+ @index = cached.interval.end if cached
687
+ return cached
688
+ end
689
+
690
+ if input.index("/", index) == index
691
+ r0 = instantiate_node(Division,input, index...(index + 1))
692
+ @index += 1
693
+ else
694
+ terminal_parse_failure("/")
695
+ r0 = nil
696
+ end
697
+
698
+ node_cache[:divide][start_index] = r0
699
+
700
+ return r0
701
+ end
702
+
703
+ def _nt_add
704
+ start_index = index
705
+ if node_cache[:add].has_key?(index)
706
+ cached = node_cache[:add][index]
707
+ @index = cached.interval.end if cached
708
+ return cached
709
+ end
710
+
711
+ if input.index("+", index) == index
712
+ r0 = instantiate_node(Addition,input, index...(index + 1))
713
+ @index += 1
714
+ else
715
+ terminal_parse_failure("+")
716
+ r0 = nil
717
+ end
718
+
719
+ node_cache[:add][start_index] = r0
720
+
721
+ return r0
722
+ end
723
+
724
+ def _nt_subtract
725
+ start_index = index
726
+ if node_cache[:subtract].has_key?(index)
727
+ cached = node_cache[:subtract][index]
728
+ @index = cached.interval.end if cached
729
+ return cached
730
+ end
731
+
732
+ if input.index("-", index) == index
733
+ r0 = instantiate_node(Subtraction,input, index...(index + 1))
734
+ @index += 1
735
+ else
736
+ terminal_parse_failure("-")
737
+ r0 = nil
738
+ end
739
+
740
+ node_cache[:subtract][start_index] = r0
741
+
742
+ return r0
743
+ end
744
+
745
+ def _nt_comparator
746
+ start_index = index
747
+ if node_cache[:comparator].has_key?(index)
748
+ cached = node_cache[:comparator][index]
749
+ @index = cached.interval.end if cached
750
+ return cached
751
+ end
752
+
753
+ i0 = index
754
+ r1 = _nt_not_equal
755
+ if r1
756
+ r0 = r1
757
+ r0.extend(Comparator)
758
+ else
759
+ r2 = _nt_lte
760
+ if r2
761
+ r0 = r2
762
+ r0.extend(Comparator)
763
+ else
764
+ r3 = _nt_gte
765
+ if r3
766
+ r0 = r3
767
+ r0.extend(Comparator)
768
+ else
769
+ r4 = _nt_equal
770
+ if r4
771
+ r0 = r4
772
+ r0.extend(Comparator)
773
+ else
774
+ r5 = _nt_match
775
+ if r5
776
+ r0 = r5
777
+ r0.extend(Comparator)
778
+ else
779
+ r6 = _nt_lt
780
+ if r6
781
+ r0 = r6
782
+ r0.extend(Comparator)
783
+ else
784
+ r7 = _nt_gt
785
+ if r7
786
+ r0 = r7
787
+ r0.extend(Comparator)
788
+ else
789
+ self.index = i0
790
+ r0 = nil
791
+ end
792
+ end
793
+ end
794
+ end
795
+ end
796
+ end
797
+ end
798
+
799
+ node_cache[:comparator][start_index] = r0
800
+
801
+ return r0
802
+ end
803
+
804
+ def _nt_equal
805
+ start_index = index
806
+ if node_cache[:equal].has_key?(index)
807
+ cached = node_cache[:equal][index]
808
+ @index = cached.interval.end if cached
809
+ return cached
810
+ end
811
+
812
+ if input.index("=", index) == index
813
+ r0 = instantiate_node(Equal,input, index...(index + 1))
814
+ @index += 1
815
+ else
816
+ terminal_parse_failure("=")
817
+ r0 = nil
818
+ end
819
+
820
+ node_cache[:equal][start_index] = r0
821
+
822
+ return r0
823
+ end
824
+
825
+ def _nt_match
826
+ start_index = index
827
+ if node_cache[:match].has_key?(index)
828
+ cached = node_cache[:match][index]
829
+ @index = cached.interval.end if cached
830
+ return cached
831
+ end
832
+
833
+ if input.index("~", index) == index
834
+ r0 = instantiate_node(Match,input, index...(index + 1))
835
+ @index += 1
836
+ else
837
+ terminal_parse_failure("~")
838
+ r0 = nil
839
+ end
840
+
841
+ node_cache[:match][start_index] = r0
842
+
843
+ return r0
844
+ end
845
+
846
+ def _nt_not_equal
847
+ start_index = index
848
+ if node_cache[:not_equal].has_key?(index)
849
+ cached = node_cache[:not_equal][index]
850
+ @index = cached.interval.end if cached
851
+ return cached
852
+ end
853
+
854
+ if input.index("!=", index) == index
855
+ r0 = instantiate_node(NotEqual,input, index...(index + 2))
856
+ @index += 2
857
+ else
858
+ terminal_parse_failure("!=")
859
+ r0 = nil
860
+ end
861
+
862
+ node_cache[:not_equal][start_index] = r0
863
+
864
+ return r0
865
+ end
866
+
867
+ def _nt_lt
868
+ start_index = index
869
+ if node_cache[:lt].has_key?(index)
870
+ cached = node_cache[:lt][index]
871
+ @index = cached.interval.end if cached
872
+ return cached
873
+ end
874
+
875
+ if input.index("<", index) == index
876
+ r0 = instantiate_node(LessThan,input, index...(index + 1))
877
+ @index += 1
878
+ else
879
+ terminal_parse_failure("<")
880
+ r0 = nil
881
+ end
882
+
883
+ node_cache[:lt][start_index] = r0
884
+
885
+ return r0
886
+ end
887
+
888
+ def _nt_lte
889
+ start_index = index
890
+ if node_cache[:lte].has_key?(index)
891
+ cached = node_cache[:lte][index]
892
+ @index = cached.interval.end if cached
893
+ return cached
894
+ end
895
+
896
+ if input.index("<=", index) == index
897
+ r0 = instantiate_node(LessThanOrEqual,input, index...(index + 2))
898
+ @index += 2
899
+ else
900
+ terminal_parse_failure("<=")
901
+ r0 = nil
902
+ end
903
+
904
+ node_cache[:lte][start_index] = r0
905
+
906
+ return r0
907
+ end
908
+
909
+ def _nt_gt
910
+ start_index = index
911
+ if node_cache[:gt].has_key?(index)
912
+ cached = node_cache[:gt][index]
913
+ @index = cached.interval.end if cached
914
+ return cached
915
+ end
916
+
917
+ if input.index(">", index) == index
918
+ r0 = instantiate_node(GreaterThan,input, index...(index + 1))
919
+ @index += 1
920
+ else
921
+ terminal_parse_failure(">")
922
+ r0 = nil
923
+ end
924
+
925
+ node_cache[:gt][start_index] = r0
926
+
927
+ return r0
928
+ end
929
+
930
+ def _nt_gte
931
+ start_index = index
932
+ if node_cache[:gte].has_key?(index)
933
+ cached = node_cache[:gte][index]
934
+ @index = cached.interval.end if cached
935
+ return cached
936
+ end
937
+
938
+ if input.index(">=", index) == index
939
+ r0 = instantiate_node(GreaterThanOrEqual,input, index...(index + 2))
940
+ @index += 2
941
+ else
942
+ terminal_parse_failure(">=")
943
+ r0 = nil
944
+ end
945
+
946
+ node_cache[:gte][start_index] = r0
947
+
948
+ return r0
949
+ end
950
+
951
+ module String0
952
+ def hex
953
+ elements[1]
954
+ end
955
+
956
+ def hex
957
+ elements[2]
958
+ end
959
+
960
+ def hex
961
+ elements[3]
962
+ end
963
+
964
+ def hex
965
+ elements[4]
966
+ end
967
+ end
968
+
969
+ module String1
970
+ end
971
+
972
+ module String2
973
+ end
974
+
975
+ def _nt_string
976
+ start_index = index
977
+ if node_cache[:string].has_key?(index)
978
+ cached = node_cache[:string][index]
979
+ @index = cached.interval.end if cached
980
+ return cached
981
+ end
982
+
983
+ i0, s0 = index, []
984
+ if input.index("'", index) == index
985
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
986
+ @index += 1
987
+ else
988
+ terminal_parse_failure("'")
989
+ r1 = nil
990
+ end
991
+ s0 << r1
992
+ if r1
993
+ s2, i2 = [], index
994
+ loop do
995
+ i3 = index
996
+ i4, s4 = index, []
997
+ if input.index('\\', index) == index
998
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
999
+ @index += 1
1000
+ else
1001
+ terminal_parse_failure('\\')
1002
+ r5 = nil
1003
+ end
1004
+ s4 << r5
1005
+ if r5
1006
+ i6 = index
1007
+ if input.index("'", index) == index
1008
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
1009
+ @index += 1
1010
+ else
1011
+ terminal_parse_failure("'")
1012
+ r7 = nil
1013
+ end
1014
+ if r7
1015
+ r6 = r7
1016
+ else
1017
+ if input.index('\\', index) == index
1018
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
1019
+ @index += 1
1020
+ else
1021
+ terminal_parse_failure('\\')
1022
+ r8 = nil
1023
+ end
1024
+ if r8
1025
+ r6 = r8
1026
+ else
1027
+ if input.index('/', index) == index
1028
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
1029
+ @index += 1
1030
+ else
1031
+ terminal_parse_failure('/')
1032
+ r9 = nil
1033
+ end
1034
+ if r9
1035
+ r6 = r9
1036
+ else
1037
+ if input.index('b', index) == index
1038
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
1039
+ @index += 1
1040
+ else
1041
+ terminal_parse_failure('b')
1042
+ r10 = nil
1043
+ end
1044
+ if r10
1045
+ r6 = r10
1046
+ else
1047
+ if input.index('f', index) == index
1048
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
1049
+ @index += 1
1050
+ else
1051
+ terminal_parse_failure('f')
1052
+ r11 = nil
1053
+ end
1054
+ if r11
1055
+ r6 = r11
1056
+ else
1057
+ if input.index('n', index) == index
1058
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
1059
+ @index += 1
1060
+ else
1061
+ terminal_parse_failure('n')
1062
+ r12 = nil
1063
+ end
1064
+ if r12
1065
+ r6 = r12
1066
+ else
1067
+ if input.index('r', index) == index
1068
+ r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
1069
+ @index += 1
1070
+ else
1071
+ terminal_parse_failure('r')
1072
+ r13 = nil
1073
+ end
1074
+ if r13
1075
+ r6 = r13
1076
+ else
1077
+ if input.index('t', index) == index
1078
+ r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
1079
+ @index += 1
1080
+ else
1081
+ terminal_parse_failure('t')
1082
+ r14 = nil
1083
+ end
1084
+ if r14
1085
+ r6 = r14
1086
+ else
1087
+ i15, s15 = index, []
1088
+ if input.index('u', index) == index
1089
+ r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
1090
+ @index += 1
1091
+ else
1092
+ terminal_parse_failure('u')
1093
+ r16 = nil
1094
+ end
1095
+ s15 << r16
1096
+ if r16
1097
+ r17 = _nt_hex
1098
+ s15 << r17
1099
+ if r17
1100
+ r18 = _nt_hex
1101
+ s15 << r18
1102
+ if r18
1103
+ r19 = _nt_hex
1104
+ s15 << r19
1105
+ if r19
1106
+ r20 = _nt_hex
1107
+ s15 << r20
1108
+ end
1109
+ end
1110
+ end
1111
+ end
1112
+ if s15.last
1113
+ r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
1114
+ r15.extend(String0)
1115
+ else
1116
+ self.index = i15
1117
+ r15 = nil
1118
+ end
1119
+ if r15
1120
+ r6 = r15
1121
+ else
1122
+ self.index = i6
1123
+ r6 = nil
1124
+ end
1125
+ end
1126
+ end
1127
+ end
1128
+ end
1129
+ end
1130
+ end
1131
+ end
1132
+ end
1133
+ s4 << r6
1134
+ end
1135
+ if s4.last
1136
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1137
+ r4.extend(String1)
1138
+ else
1139
+ self.index = i4
1140
+ r4 = nil
1141
+ end
1142
+ if r4
1143
+ r3 = r4
1144
+ else
1145
+ if input.index(Regexp.new('[^\\\'\\\\]'), index) == index
1146
+ r21 = instantiate_node(SyntaxNode,input, index...(index + 1))
1147
+ @index += 1
1148
+ else
1149
+ r21 = nil
1150
+ end
1151
+ if r21
1152
+ r3 = r21
1153
+ else
1154
+ self.index = i3
1155
+ r3 = nil
1156
+ end
1157
+ end
1158
+ if r3
1159
+ s2 << r3
1160
+ else
1161
+ break
1162
+ end
1163
+ end
1164
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1165
+ s0 << r2
1166
+ if r2
1167
+ if input.index("'", index) == index
1168
+ r22 = instantiate_node(SyntaxNode,input, index...(index + 1))
1169
+ @index += 1
1170
+ else
1171
+ terminal_parse_failure("'")
1172
+ r22 = nil
1173
+ end
1174
+ s0 << r22
1175
+ end
1176
+ end
1177
+ if s0.last
1178
+ r0 = instantiate_node(String,input, i0...index, s0)
1179
+ r0.extend(String2)
1180
+ else
1181
+ self.index = i0
1182
+ r0 = nil
1183
+ end
1184
+
1185
+ node_cache[:string][start_index] = r0
1186
+
1187
+ return r0
1188
+ end
1189
+
1190
+ module Number0
1191
+ end
1192
+
1193
+ module Number1
1194
+ end
1195
+
1196
+ module Number2
1197
+ end
1198
+
1199
+ module Number3
1200
+ end
1201
+
1202
+ def _nt_number
1203
+ start_index = index
1204
+ if node_cache[:number].has_key?(index)
1205
+ cached = node_cache[:number][index]
1206
+ @index = cached.interval.end if cached
1207
+ return cached
1208
+ end
1209
+
1210
+ i0, s0 = index, []
1211
+ if input.index("-", index) == index
1212
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
1213
+ @index += 1
1214
+ else
1215
+ terminal_parse_failure("-")
1216
+ r2 = nil
1217
+ end
1218
+ if r2
1219
+ r1 = r2
1220
+ else
1221
+ r1 = instantiate_node(SyntaxNode,input, index...index)
1222
+ end
1223
+ s0 << r1
1224
+ if r1
1225
+ i3 = index
1226
+ if input.index("0", index) == index
1227
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
1228
+ @index += 1
1229
+ else
1230
+ terminal_parse_failure("0")
1231
+ r4 = nil
1232
+ end
1233
+ if r4
1234
+ r3 = r4
1235
+ else
1236
+ i5, s5 = index, []
1237
+ if input.index(Regexp.new('[1-9]'), index) == index
1238
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
1239
+ @index += 1
1240
+ else
1241
+ r6 = nil
1242
+ end
1243
+ s5 << r6
1244
+ if r6
1245
+ s7, i7 = [], index
1246
+ loop do
1247
+ r8 = _nt_digit
1248
+ if r8
1249
+ s7 << r8
1250
+ else
1251
+ break
1252
+ end
1253
+ end
1254
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1255
+ s5 << r7
1256
+ end
1257
+ if s5.last
1258
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1259
+ r5.extend(Number0)
1260
+ else
1261
+ self.index = i5
1262
+ r5 = nil
1263
+ end
1264
+ if r5
1265
+ r3 = r5
1266
+ else
1267
+ self.index = i3
1268
+ r3 = nil
1269
+ end
1270
+ end
1271
+ s0 << r3
1272
+ if r3
1273
+ i10, s10 = index, []
1274
+ if input.index(".", index) == index
1275
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
1276
+ @index += 1
1277
+ else
1278
+ terminal_parse_failure(".")
1279
+ r11 = nil
1280
+ end
1281
+ s10 << r11
1282
+ if r11
1283
+ s12, i12 = [], index
1284
+ loop do
1285
+ r13 = _nt_digit
1286
+ if r13
1287
+ s12 << r13
1288
+ else
1289
+ break
1290
+ end
1291
+ end
1292
+ if s12.empty?
1293
+ self.index = i12
1294
+ r12 = nil
1295
+ else
1296
+ r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1297
+ end
1298
+ s10 << r12
1299
+ end
1300
+ if s10.last
1301
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
1302
+ r10.extend(Number1)
1303
+ else
1304
+ self.index = i10
1305
+ r10 = nil
1306
+ end
1307
+ if r10
1308
+ r9 = r10
1309
+ else
1310
+ r9 = instantiate_node(SyntaxNode,input, index...index)
1311
+ end
1312
+ s0 << r9
1313
+ if r9
1314
+ i15, s15 = index, []
1315
+ if input.index(Regexp.new('[eE]'), index) == index
1316
+ r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
1317
+ @index += 1
1318
+ else
1319
+ r16 = nil
1320
+ end
1321
+ s15 << r16
1322
+ if r16
1323
+ if input.index(Regexp.new('[+-]'), index) == index
1324
+ r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
1325
+ @index += 1
1326
+ else
1327
+ r18 = nil
1328
+ end
1329
+ if r18
1330
+ r17 = r18
1331
+ else
1332
+ r17 = instantiate_node(SyntaxNode,input, index...index)
1333
+ end
1334
+ s15 << r17
1335
+ if r17
1336
+ s19, i19 = [], index
1337
+ loop do
1338
+ r20 = _nt_digit
1339
+ if r20
1340
+ s19 << r20
1341
+ else
1342
+ break
1343
+ end
1344
+ end
1345
+ if s19.empty?
1346
+ self.index = i19
1347
+ r19 = nil
1348
+ else
1349
+ r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
1350
+ end
1351
+ s15 << r19
1352
+ end
1353
+ end
1354
+ if s15.last
1355
+ r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
1356
+ r15.extend(Number2)
1357
+ else
1358
+ self.index = i15
1359
+ r15 = nil
1360
+ end
1361
+ if r15
1362
+ r14 = r15
1363
+ else
1364
+ r14 = instantiate_node(SyntaxNode,input, index...index)
1365
+ end
1366
+ s0 << r14
1367
+ end
1368
+ end
1369
+ end
1370
+ if s0.last
1371
+ r0 = instantiate_node(Number,input, i0...index, s0)
1372
+ r0.extend(Number3)
1373
+ else
1374
+ self.index = i0
1375
+ r0 = nil
1376
+ end
1377
+
1378
+ node_cache[:number][start_index] = r0
1379
+
1380
+ return r0
1381
+ end
1382
+
1383
+ def _nt_digit
1384
+ start_index = index
1385
+ if node_cache[:digit].has_key?(index)
1386
+ cached = node_cache[:digit][index]
1387
+ @index = cached.interval.end if cached
1388
+ return cached
1389
+ end
1390
+
1391
+ if input.index(Regexp.new('[0-9]'), index) == index
1392
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1393
+ @index += 1
1394
+ else
1395
+ r0 = nil
1396
+ end
1397
+
1398
+ node_cache[:digit][start_index] = r0
1399
+
1400
+ return r0
1401
+ end
1402
+
1403
+ def _nt_boolean
1404
+ start_index = index
1405
+ if node_cache[:boolean].has_key?(index)
1406
+ cached = node_cache[:boolean][index]
1407
+ @index = cached.interval.end if cached
1408
+ return cached
1409
+ end
1410
+
1411
+ i0 = index
1412
+ r1 = _nt_true
1413
+ if r1
1414
+ r0 = r1
1415
+ r0.extend(Boolean)
1416
+ else
1417
+ r2 = _nt_false
1418
+ if r2
1419
+ r0 = r2
1420
+ r0.extend(Boolean)
1421
+ else
1422
+ self.index = i0
1423
+ r0 = nil
1424
+ end
1425
+ end
1426
+
1427
+ node_cache[:boolean][start_index] = r0
1428
+
1429
+ return r0
1430
+ end
1431
+
1432
+ def _nt_true
1433
+ start_index = index
1434
+ if node_cache[:true].has_key?(index)
1435
+ cached = node_cache[:true][index]
1436
+ @index = cached.interval.end if cached
1437
+ return cached
1438
+ end
1439
+
1440
+ if input.index("true", index) == index
1441
+ r0 = instantiate_node(True,input, index...(index + 4))
1442
+ @index += 4
1443
+ else
1444
+ terminal_parse_failure("true")
1445
+ r0 = nil
1446
+ end
1447
+
1448
+ node_cache[:true][start_index] = r0
1449
+
1450
+ return r0
1451
+ end
1452
+
1453
+ def _nt_false
1454
+ start_index = index
1455
+ if node_cache[:false].has_key?(index)
1456
+ cached = node_cache[:false][index]
1457
+ @index = cached.interval.end if cached
1458
+ return cached
1459
+ end
1460
+
1461
+ if input.index("false", index) == index
1462
+ r0 = instantiate_node(False,input, index...(index + 5))
1463
+ @index += 5
1464
+ else
1465
+ terminal_parse_failure("false")
1466
+ r0 = nil
1467
+ end
1468
+
1469
+ node_cache[:false][start_index] = r0
1470
+
1471
+ return r0
1472
+ end
1473
+
1474
+ def _nt_null
1475
+ start_index = index
1476
+ if node_cache[:null].has_key?(index)
1477
+ cached = node_cache[:null][index]
1478
+ @index = cached.interval.end if cached
1479
+ return cached
1480
+ end
1481
+
1482
+ if input.index("null", index) == index
1483
+ r0 = instantiate_node(Null,input, index...(index + 4))
1484
+ @index += 4
1485
+ else
1486
+ terminal_parse_failure("null")
1487
+ r0 = nil
1488
+ end
1489
+
1490
+ node_cache[:null][start_index] = r0
1491
+
1492
+ return r0
1493
+ end
1494
+
1495
+ def _nt_space
1496
+ start_index = index
1497
+ if node_cache[:space].has_key?(index)
1498
+ cached = node_cache[:space][index]
1499
+ @index = cached.interval.end if cached
1500
+ return cached
1501
+ end
1502
+
1503
+ s0, i0 = [], index
1504
+ loop do
1505
+ if input.index(" ", index) == index
1506
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1507
+ @index += 1
1508
+ else
1509
+ terminal_parse_failure(" ")
1510
+ r1 = nil
1511
+ end
1512
+ if r1
1513
+ s0 << r1
1514
+ else
1515
+ break
1516
+ end
1517
+ end
1518
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1519
+
1520
+ node_cache[:space][start_index] = r0
1521
+
1522
+ return r0
1523
+ end
1524
+
1525
+ module Query0
1526
+ def identifier
1527
+ elements[0]
1528
+ end
1529
+
1530
+ end
1531
+
1532
+ def _nt_query
1533
+ start_index = index
1534
+ if node_cache[:query].has_key?(index)
1535
+ cached = node_cache[:query][index]
1536
+ @index = cached.interval.end if cached
1537
+ return cached
1538
+ end
1539
+
1540
+ i0, s0 = index, []
1541
+ r1 = _nt_identifier
1542
+ s0 << r1
1543
+ if r1
1544
+ s2, i2 = [], index
1545
+ loop do
1546
+ r3 = _nt_filter
1547
+ if r3
1548
+ s2 << r3
1549
+ else
1550
+ break
1551
+ end
1552
+ end
1553
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1554
+ s0 << r2
1555
+ end
1556
+ if s0.last
1557
+ r0 = instantiate_node(Query,input, i0...index, s0)
1558
+ r0.extend(Query0)
1559
+ else
1560
+ self.index = i0
1561
+ r0 = nil
1562
+ end
1563
+
1564
+ node_cache[:query][start_index] = r0
1565
+
1566
+ return r0
1567
+ end
1568
+
1569
+ def _nt_identifier
1570
+ start_index = index
1571
+ if node_cache[:identifier].has_key?(index)
1572
+ cached = node_cache[:identifier][index]
1573
+ @index = cached.interval.end if cached
1574
+ return cached
1575
+ end
1576
+
1577
+ i0 = index
1578
+ r1 = _nt_root
1579
+ if r1
1580
+ r0 = r1
1581
+ r0.extend(Identifier)
1582
+ else
1583
+ r2 = _nt_current
1584
+ if r2
1585
+ r0 = r2
1586
+ r0.extend(Identifier)
1587
+ else
1588
+ r3 = _nt_symbol
1589
+ if r3
1590
+ r0 = r3
1591
+ r0.extend(Identifier)
1592
+ else
1593
+ self.index = i0
1594
+ r0 = nil
1595
+ end
1596
+ end
1597
+ end
1598
+
1599
+ node_cache[:identifier][start_index] = r0
1600
+
1601
+ return r0
1602
+ end
1603
+
1604
+ def _nt_root
1605
+ start_index = index
1606
+ if node_cache[:root].has_key?(index)
1607
+ cached = node_cache[:root][index]
1608
+ @index = cached.interval.end if cached
1609
+ return cached
1610
+ end
1611
+
1612
+ if input.index("$", index) == index
1613
+ r0 = instantiate_node(Root,input, index...(index + 1))
1614
+ @index += 1
1615
+ else
1616
+ terminal_parse_failure("$")
1617
+ r0 = nil
1618
+ end
1619
+
1620
+ node_cache[:root][start_index] = r0
1621
+
1622
+ return r0
1623
+ end
1624
+
1625
+ def _nt_current
1626
+ start_index = index
1627
+ if node_cache[:current].has_key?(index)
1628
+ cached = node_cache[:current][index]
1629
+ @index = cached.interval.end if cached
1630
+ return cached
1631
+ end
1632
+
1633
+ if input.index("@", index) == index
1634
+ r0 = instantiate_node(Current,input, index...(index + 1))
1635
+ @index += 1
1636
+ else
1637
+ terminal_parse_failure("@")
1638
+ r0 = nil
1639
+ end
1640
+
1641
+ node_cache[:current][start_index] = r0
1642
+
1643
+ return r0
1644
+ end
1645
+
1646
+ module Symbol0
1647
+ end
1648
+
1649
+ def _nt_symbol
1650
+ start_index = index
1651
+ if node_cache[:symbol].has_key?(index)
1652
+ cached = node_cache[:symbol][index]
1653
+ @index = cached.interval.end if cached
1654
+ return cached
1655
+ end
1656
+
1657
+ i0, s0 = index, []
1658
+ if input.index(Regexp.new('[A-Za-z$_]'), index) == index
1659
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1660
+ @index += 1
1661
+ else
1662
+ r1 = nil
1663
+ end
1664
+ s0 << r1
1665
+ if r1
1666
+ s2, i2 = [], index
1667
+ loop do
1668
+ if input.index(Regexp.new('[A-Za-z0-9$_]'), index) == index
1669
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
1670
+ @index += 1
1671
+ else
1672
+ r3 = nil
1673
+ end
1674
+ if r3
1675
+ s2 << r3
1676
+ else
1677
+ break
1678
+ end
1679
+ end
1680
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1681
+ s0 << r2
1682
+ end
1683
+ if s0.last
1684
+ r0 = instantiate_node(Symbol,input, i0...index, s0)
1685
+ r0.extend(Symbol0)
1686
+ else
1687
+ self.index = i0
1688
+ r0 = nil
1689
+ end
1690
+
1691
+ node_cache[:symbol][start_index] = r0
1692
+
1693
+ return r0
1694
+ end
1695
+
1696
+ def _nt_filter
1697
+ start_index = index
1698
+ if node_cache[:filter].has_key?(index)
1699
+ cached = node_cache[:filter][index]
1700
+ @index = cached.interval.end if cached
1701
+ return cached
1702
+ end
1703
+
1704
+ i0 = index
1705
+ r1 = _nt_slice_access
1706
+ if r1
1707
+ r0 = r1
1708
+ r0.extend(Filter)
1709
+ else
1710
+ r2 = _nt_recursive_access
1711
+ if r2
1712
+ r0 = r2
1713
+ r0.extend(Filter)
1714
+ else
1715
+ r3 = _nt_field_access
1716
+ if r3
1717
+ r0 = r3
1718
+ r0.extend(Filter)
1719
+ else
1720
+ r4 = _nt_boolean_filter
1721
+ if r4
1722
+ r0 = r4
1723
+ r0.extend(Filter)
1724
+ else
1725
+ r5 = _nt_map_filter
1726
+ if r5
1727
+ r0 = r5
1728
+ r0.extend(Filter)
1729
+ else
1730
+ r6 = _nt_sort_filter
1731
+ if r6
1732
+ r0 = r6
1733
+ r0.extend(Filter)
1734
+ else
1735
+ self.index = i0
1736
+ r0 = nil
1737
+ end
1738
+ end
1739
+ end
1740
+ end
1741
+ end
1742
+ end
1743
+
1744
+ node_cache[:filter][start_index] = r0
1745
+
1746
+ return r0
1747
+ end
1748
+
1749
+ module SliceAccess0
1750
+ def number
1751
+ elements[1]
1752
+ end
1753
+ end
1754
+
1755
+ module SliceAccess1
1756
+ def head
1757
+ elements[1]
1758
+ end
1759
+
1760
+ def tail
1761
+ elements[3]
1762
+ end
1763
+
1764
+ def step
1765
+ elements[4]
1766
+ end
1767
+
1768
+ end
1769
+
1770
+ def _nt_slice_access
1771
+ start_index = index
1772
+ if node_cache[:slice_access].has_key?(index)
1773
+ cached = node_cache[:slice_access][index]
1774
+ @index = cached.interval.end if cached
1775
+ return cached
1776
+ end
1777
+
1778
+ i0, s0 = index, []
1779
+ if input.index("[", index) == index
1780
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1781
+ @index += 1
1782
+ else
1783
+ terminal_parse_failure("[")
1784
+ r1 = nil
1785
+ end
1786
+ s0 << r1
1787
+ if r1
1788
+ r2 = _nt_number
1789
+ s0 << r2
1790
+ if r2
1791
+ if input.index(":", index) == index
1792
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
1793
+ @index += 1
1794
+ else
1795
+ terminal_parse_failure(":")
1796
+ r3 = nil
1797
+ end
1798
+ s0 << r3
1799
+ if r3
1800
+ r4 = _nt_number
1801
+ s0 << r4
1802
+ if r4
1803
+ i6, s6 = index, []
1804
+ if input.index(":", index) == index
1805
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
1806
+ @index += 1
1807
+ else
1808
+ terminal_parse_failure(":")
1809
+ r7 = nil
1810
+ end
1811
+ s6 << r7
1812
+ if r7
1813
+ r8 = _nt_number
1814
+ s6 << r8
1815
+ end
1816
+ if s6.last
1817
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
1818
+ r6.extend(SliceAccess0)
1819
+ else
1820
+ self.index = i6
1821
+ r6 = nil
1822
+ end
1823
+ if r6
1824
+ r5 = r6
1825
+ else
1826
+ r5 = instantiate_node(SyntaxNode,input, index...index)
1827
+ end
1828
+ s0 << r5
1829
+ if r5
1830
+ if input.index("]", index) == index
1831
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
1832
+ @index += 1
1833
+ else
1834
+ terminal_parse_failure("]")
1835
+ r9 = nil
1836
+ end
1837
+ s0 << r9
1838
+ end
1839
+ end
1840
+ end
1841
+ end
1842
+ end
1843
+ if s0.last
1844
+ r0 = instantiate_node(SliceAccess,input, i0...index, s0)
1845
+ r0.extend(SliceAccess1)
1846
+ else
1847
+ self.index = i0
1848
+ r0 = nil
1849
+ end
1850
+
1851
+ node_cache[:slice_access][start_index] = r0
1852
+
1853
+ return r0
1854
+ end
1855
+
1856
+ module RecursiveAccess0
1857
+ def symbol
1858
+ elements[1]
1859
+ end
1860
+ end
1861
+
1862
+ def _nt_recursive_access
1863
+ start_index = index
1864
+ if node_cache[:recursive_access].has_key?(index)
1865
+ cached = node_cache[:recursive_access][index]
1866
+ @index = cached.interval.end if cached
1867
+ return cached
1868
+ end
1869
+
1870
+ i0, s0 = index, []
1871
+ if input.index("..", index) == index
1872
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
1873
+ @index += 2
1874
+ else
1875
+ terminal_parse_failure("..")
1876
+ r1 = nil
1877
+ end
1878
+ s0 << r1
1879
+ if r1
1880
+ r2 = _nt_symbol
1881
+ s0 << r2
1882
+ end
1883
+ if s0.last
1884
+ r0 = instantiate_node(RecursiveAccess,input, i0...index, s0)
1885
+ r0.extend(RecursiveAccess0)
1886
+ else
1887
+ self.index = i0
1888
+ r0 = nil
1889
+ end
1890
+
1891
+ node_cache[:recursive_access][start_index] = r0
1892
+
1893
+ return r0
1894
+ end
1895
+
1896
+ module FieldAccess0
1897
+ end
1898
+
1899
+ module FieldAccess1
1900
+ end
1901
+
1902
+ def _nt_field_access
1903
+ start_index = index
1904
+ if node_cache[:field_access].has_key?(index)
1905
+ cached = node_cache[:field_access][index]
1906
+ @index = cached.interval.end if cached
1907
+ return cached
1908
+ end
1909
+
1910
+ i0 = index
1911
+ i1, s1 = index, []
1912
+ if input.index(".", index) == index
1913
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
1914
+ @index += 1
1915
+ else
1916
+ terminal_parse_failure(".")
1917
+ r2 = nil
1918
+ end
1919
+ s1 << r2
1920
+ if r2
1921
+ i3 = index
1922
+ r4 = _nt_symbol
1923
+ if r4
1924
+ r3 = r4
1925
+ else
1926
+ r5 = _nt_all
1927
+ if r5
1928
+ r3 = r5
1929
+ else
1930
+ self.index = i3
1931
+ r3 = nil
1932
+ end
1933
+ end
1934
+ s1 << r3
1935
+ end
1936
+ if s1.last
1937
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1938
+ r1.extend(FieldAccess0)
1939
+ else
1940
+ self.index = i1
1941
+ r1 = nil
1942
+ end
1943
+ if r1
1944
+ r0 = r1
1945
+ r0.extend(FieldAccess)
1946
+ else
1947
+ i6, s6 = index, []
1948
+ if input.index("[", index) == index
1949
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
1950
+ @index += 1
1951
+ else
1952
+ terminal_parse_failure("[")
1953
+ r7 = nil
1954
+ end
1955
+ s6 << r7
1956
+ if r7
1957
+ i8 = index
1958
+ r9 = _nt_field_access_expression
1959
+ if r9
1960
+ r8 = r9
1961
+ else
1962
+ r10 = _nt_all
1963
+ if r10
1964
+ r8 = r10
1965
+ else
1966
+ self.index = i8
1967
+ r8 = nil
1968
+ end
1969
+ end
1970
+ s6 << r8
1971
+ if r8
1972
+ if input.index("]", index) == index
1973
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
1974
+ @index += 1
1975
+ else
1976
+ terminal_parse_failure("]")
1977
+ r11 = nil
1978
+ end
1979
+ s6 << r11
1980
+ end
1981
+ end
1982
+ if s6.last
1983
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
1984
+ r6.extend(FieldAccess1)
1985
+ else
1986
+ self.index = i6
1987
+ r6 = nil
1988
+ end
1989
+ if r6
1990
+ r0 = r6
1991
+ r0.extend(FieldAccess)
1992
+ else
1993
+ self.index = i0
1994
+ r0 = nil
1995
+ end
1996
+ end
1997
+
1998
+ node_cache[:field_access][start_index] = r0
1999
+
2000
+ return r0
2001
+ end
2002
+
2003
+ module FieldAccessExpression0
2004
+ def expression
2005
+ elements[1]
2006
+ end
2007
+ end
2008
+
2009
+ module FieldAccessExpression1
2010
+ def first
2011
+ elements[0]
2012
+ end
2013
+
2014
+ def others
2015
+ elements[1]
2016
+ end
2017
+ end
2018
+
2019
+ def _nt_field_access_expression
2020
+ start_index = index
2021
+ if node_cache[:field_access_expression].has_key?(index)
2022
+ cached = node_cache[:field_access_expression][index]
2023
+ @index = cached.interval.end if cached
2024
+ return cached
2025
+ end
2026
+
2027
+ i0, s0 = index, []
2028
+ r1 = _nt_expression
2029
+ s0 << r1
2030
+ if r1
2031
+ s2, i2 = [], index
2032
+ loop do
2033
+ i3, s3 = index, []
2034
+ if input.index(",", index) == index
2035
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2036
+ @index += 1
2037
+ else
2038
+ terminal_parse_failure(",")
2039
+ r4 = nil
2040
+ end
2041
+ s3 << r4
2042
+ if r4
2043
+ r5 = _nt_expression
2044
+ s3 << r5
2045
+ end
2046
+ if s3.last
2047
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2048
+ r3.extend(FieldAccessExpression0)
2049
+ else
2050
+ self.index = i3
2051
+ r3 = nil
2052
+ end
2053
+ if r3
2054
+ s2 << r3
2055
+ else
2056
+ break
2057
+ end
2058
+ end
2059
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2060
+ s0 << r2
2061
+ end
2062
+ if s0.last
2063
+ r0 = instantiate_node(FieldAccessExpression,input, i0...index, s0)
2064
+ r0.extend(FieldAccessExpression1)
2065
+ else
2066
+ self.index = i0
2067
+ r0 = nil
2068
+ end
2069
+
2070
+ node_cache[:field_access_expression][start_index] = r0
2071
+
2072
+ return r0
2073
+ end
2074
+
2075
+ def _nt_all
2076
+ start_index = index
2077
+ if node_cache[:all].has_key?(index)
2078
+ cached = node_cache[:all][index]
2079
+ @index = cached.interval.end if cached
2080
+ return cached
2081
+ end
2082
+
2083
+ if input.index("*", index) == index
2084
+ r0 = instantiate_node(AllFilter,input, index...(index + 1))
2085
+ @index += 1
2086
+ else
2087
+ terminal_parse_failure("*")
2088
+ r0 = nil
2089
+ end
2090
+
2091
+ node_cache[:all][start_index] = r0
2092
+
2093
+ return r0
2094
+ end
2095
+
2096
+ module BooleanFilter0
2097
+ def recursive
2098
+ elements[0]
2099
+ end
2100
+
2101
+ def boolean_expression
2102
+ elements[2]
2103
+ end
2104
+
2105
+ end
2106
+
2107
+ def _nt_boolean_filter
2108
+ start_index = index
2109
+ if node_cache[:boolean_filter].has_key?(index)
2110
+ cached = node_cache[:boolean_filter][index]
2111
+ @index = cached.interval.end if cached
2112
+ return cached
2113
+ end
2114
+
2115
+ i0, s0 = index, []
2116
+ if input.index("..", index) == index
2117
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 2))
2118
+ @index += 2
2119
+ else
2120
+ terminal_parse_failure("..")
2121
+ r2 = nil
2122
+ end
2123
+ if r2
2124
+ r1 = r2
2125
+ else
2126
+ r1 = instantiate_node(SyntaxNode,input, index...index)
2127
+ end
2128
+ s0 << r1
2129
+ if r1
2130
+ if input.index("[?", index) == index
2131
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
2132
+ @index += 2
2133
+ else
2134
+ terminal_parse_failure("[?")
2135
+ r3 = nil
2136
+ end
2137
+ s0 << r3
2138
+ if r3
2139
+ r4 = _nt_boolean_expression
2140
+ s0 << r4
2141
+ if r4
2142
+ if input.index("]", index) == index
2143
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2144
+ @index += 1
2145
+ else
2146
+ terminal_parse_failure("]")
2147
+ r5 = nil
2148
+ end
2149
+ s0 << r5
2150
+ end
2151
+ end
2152
+ end
2153
+ if s0.last
2154
+ r0 = instantiate_node(BooleanFilter,input, i0...index, s0)
2155
+ r0.extend(BooleanFilter0)
2156
+ else
2157
+ self.index = i0
2158
+ r0 = nil
2159
+ end
2160
+
2161
+ node_cache[:boolean_filter][start_index] = r0
2162
+
2163
+ return r0
2164
+ end
2165
+
2166
+ module MapFilter0
2167
+ def expression
2168
+ elements[1]
2169
+ end
2170
+
2171
+ end
2172
+
2173
+ def _nt_map_filter
2174
+ start_index = index
2175
+ if node_cache[:map_filter].has_key?(index)
2176
+ cached = node_cache[:map_filter][index]
2177
+ @index = cached.interval.end if cached
2178
+ return cached
2179
+ end
2180
+
2181
+ i0, s0 = index, []
2182
+ if input.index("[=", index) == index
2183
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
2184
+ @index += 2
2185
+ else
2186
+ terminal_parse_failure("[=")
2187
+ r1 = nil
2188
+ end
2189
+ s0 << r1
2190
+ if r1
2191
+ r2 = _nt_expression
2192
+ s0 << r2
2193
+ if r2
2194
+ if input.index("]", index) == index
2195
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
2196
+ @index += 1
2197
+ else
2198
+ terminal_parse_failure("]")
2199
+ r3 = nil
2200
+ end
2201
+ s0 << r3
2202
+ end
2203
+ end
2204
+ if s0.last
2205
+ r0 = instantiate_node(MapFilter,input, i0...index, s0)
2206
+ r0.extend(MapFilter0)
2207
+ else
2208
+ self.index = i0
2209
+ r0 = nil
2210
+ end
2211
+
2212
+ node_cache[:map_filter][start_index] = r0
2213
+
2214
+ return r0
2215
+ end
2216
+
2217
+ module SortFilter0
2218
+ def sorter
2219
+ elements[0]
2220
+ end
2221
+
2222
+ def expression
2223
+ elements[1]
2224
+ end
2225
+ end
2226
+
2227
+ module SortFilter1
2228
+ def sorter
2229
+ elements[1]
2230
+ end
2231
+
2232
+ def expression
2233
+ elements[2]
2234
+ end
2235
+ end
2236
+
2237
+ module SortFilter2
2238
+ def first
2239
+ elements[1]
2240
+ end
2241
+
2242
+ def others
2243
+ elements[2]
2244
+ end
2245
+
2246
+ end
2247
+
2248
+ def _nt_sort_filter
2249
+ start_index = index
2250
+ if node_cache[:sort_filter].has_key?(index)
2251
+ cached = node_cache[:sort_filter][index]
2252
+ @index = cached.interval.end if cached
2253
+ return cached
2254
+ end
2255
+
2256
+ i0, s0 = index, []
2257
+ if input.index("[", index) == index
2258
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2259
+ @index += 1
2260
+ else
2261
+ terminal_parse_failure("[")
2262
+ r1 = nil
2263
+ end
2264
+ s0 << r1
2265
+ if r1
2266
+ i2, s2 = index, []
2267
+ r3 = _nt_sorter
2268
+ s2 << r3
2269
+ if r3
2270
+ r4 = _nt_expression
2271
+ s2 << r4
2272
+ end
2273
+ if s2.last
2274
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2275
+ r2.extend(SortFilter0)
2276
+ else
2277
+ self.index = i2
2278
+ r2 = nil
2279
+ end
2280
+ s0 << r2
2281
+ if r2
2282
+ s5, i5 = [], index
2283
+ loop do
2284
+ i6, s6 = index, []
2285
+ if input.index(",", index) == index
2286
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2287
+ @index += 1
2288
+ else
2289
+ terminal_parse_failure(",")
2290
+ r7 = nil
2291
+ end
2292
+ s6 << r7
2293
+ if r7
2294
+ r8 = _nt_sorter
2295
+ s6 << r8
2296
+ if r8
2297
+ r9 = _nt_expression
2298
+ s6 << r9
2299
+ end
2300
+ end
2301
+ if s6.last
2302
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
2303
+ r6.extend(SortFilter1)
2304
+ else
2305
+ self.index = i6
2306
+ r6 = nil
2307
+ end
2308
+ if r6
2309
+ s5 << r6
2310
+ else
2311
+ break
2312
+ end
2313
+ end
2314
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2315
+ s0 << r5
2316
+ if r5
2317
+ if input.index("]", index) == index
2318
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
2319
+ @index += 1
2320
+ else
2321
+ terminal_parse_failure("]")
2322
+ r10 = nil
2323
+ end
2324
+ s0 << r10
2325
+ end
2326
+ end
2327
+ end
2328
+ if s0.last
2329
+ r0 = instantiate_node(SortFilter,input, i0...index, s0)
2330
+ r0.extend(SortFilter2)
2331
+ else
2332
+ self.index = i0
2333
+ r0 = nil
2334
+ end
2335
+
2336
+ node_cache[:sort_filter][start_index] = r0
2337
+
2338
+ return r0
2339
+ end
2340
+
2341
+ module Sorter0
2342
+ def space
2343
+ elements[0]
2344
+ end
2345
+
2346
+ def space
2347
+ elements[2]
2348
+ end
2349
+ end
2350
+
2351
+ def _nt_sorter
2352
+ start_index = index
2353
+ if node_cache[:sorter].has_key?(index)
2354
+ cached = node_cache[:sorter][index]
2355
+ @index = cached.interval.end if cached
2356
+ return cached
2357
+ end
2358
+
2359
+ i0, s0 = index, []
2360
+ r1 = _nt_space
2361
+ s0 << r1
2362
+ if r1
2363
+ i2 = index
2364
+ if input.index("/", index) == index
2365
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
2366
+ @index += 1
2367
+ else
2368
+ terminal_parse_failure("/")
2369
+ r3 = nil
2370
+ end
2371
+ if r3
2372
+ r2 = r3
2373
+ else
2374
+ if input.index("\\", index) == index
2375
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2376
+ @index += 1
2377
+ else
2378
+ terminal_parse_failure("\\")
2379
+ r4 = nil
2380
+ end
2381
+ if r4
2382
+ r2 = r4
2383
+ else
2384
+ self.index = i2
2385
+ r2 = nil
2386
+ end
2387
+ end
2388
+ s0 << r2
2389
+ if r2
2390
+ r5 = _nt_space
2391
+ s0 << r5
2392
+ end
2393
+ end
2394
+ if s0.last
2395
+ r0 = instantiate_node(Sorter,input, i0...index, s0)
2396
+ r0.extend(Sorter0)
2397
+ else
2398
+ self.index = i0
2399
+ r0 = nil
2400
+ end
2401
+
2402
+ node_cache[:sorter][start_index] = r0
2403
+
2404
+ return r0
2405
+ end
2406
+
2407
+ end
2408
+
2409
+ class JsonQueryParser < Treetop::Runtime::CompiledParser
2410
+ include JsonQuery
2411
+ end
2412
+
2413
+ end
2414
+