Module: HGRAMMAR

Includes:
Treetop::Runtime
Included in:
HGRAMMARParser
Defined in:
lib/cbor-diagnostic-app/hgrammar.rb

Defined Under Namespace

Modules: AppStringH0, AppStringH1, AppStringH2, AppStringH3, AppStringH4, AppStringH5, AppStringH6, Comment0, Comment1, Ellipsis0, S0, S1

Instance Method Summary collapse

Instance Method Details

#_nt_app_string_hObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 91

def _nt_app_string_h
  start_index = index
  if node_cache[:app_string_h].has_key?(index)
    cached = node_cache[:app_string_h][index]
    if cached
      node_cache[:app_string_h][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  r1 = _nt_S
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      i3 = index
      i4, s4 = index, []
      r5 = _nt_HEXDIG
      s4 << r5
      if r5
        r6 = _nt_S
        s4 << r6
        if r6
          r7 = _nt_HEXDIG
          s4 << r7
          if r7
            r8 = _nt_S
            s4 << r8
          end
        end
      end
      if s4.last
        r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
        r4.extend(AppStringH0)
        r4.extend(AppStringH1)
      else
        @index = i4
        r4 = nil
      end
      if r4
        r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
        r3 = r4
      else
        i9, s9 = index, []
        r10 = _nt_ellipsis
        s9 << r10
        if r10
          r11 = _nt_S
          s9 << r11
        end
        if s9.last
          r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
          r9.extend(AppStringH2)
          r9.extend(AppStringH3)
        else
          @index = i9
          r9 = nil
        end
        if r9
          r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
          r3 = r9
        else
          @index = i3
          r3 = nil
        end
      end
      if r3
        s2 << r3
      else
        break
      end
    end
    r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    s0 << r2
    if r2
      i13, s13 = index, []
      if (match_len = has_terminal?("#", false, index))
        r14 = true
        @index += match_len
      else
        terminal_parse_failure('"#"')
        r14 = nil
      end
      s13 << r14
      if r14
        s15, i15 = [], index
        loop do
          r16 = _nt_non_lf
          if r16
            s15 << r16
          else
            break
          end
        end
        r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
        s13 << r15
      end
      if s13.last
        r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
        r13.extend(AppStringH4)
      else
        @index = i13
        r13 = nil
      end
      if r13
        r12 = r13
      else
        r12 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r12
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(AppStringH5)
    r0.extend(AppStringH6)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:app_string_h][start_index] = r0

  r0
end

#_nt_blankObject



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 385

def _nt_blank
  start_index = index
  if node_cache[:blank].has_key?(index)
    cached = node_cache[:blank][index]
    if cached
      node_cache[:blank][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  if (match_len = has_terminal?("\t", false, index))
    r1 = true
    @index += match_len
  else
    terminal_parse_failure('"\\t"')
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    if (match_len = has_terminal?("\n", false, index))
      r2 = true
      @index += match_len
    else
      terminal_parse_failure('"\\n"')
      r2 = nil
    end
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      if (match_len = has_terminal?("\r", false, index))
        r3 = true
        @index += match_len
      else
        terminal_parse_failure('"\\r"')
        r3 = nil
      end
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        if (match_len = has_terminal?(" ", false, index))
          r4 = true
          @index += match_len
        else
          terminal_parse_failure('" "')
          r4 = nil
        end
        if r4
          r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end
    end
  end

  node_cache[:blank][start_index] = r0

  r0
end

#_nt_commentObject



658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 658

def _nt_comment
  start_index = index
  if node_cache[:comment].has_key?(index)
    cached = node_cache[:comment][index]
    if cached
      node_cache[:comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  i1, s1 = index, []
  if (match_len = has_terminal?("/", false, index))
    r2 = true
    @index += match_len
  else
    terminal_parse_failure('"/"')
    r2 = nil
  end
  s1 << r2
  if r2
    s3, i3 = [], index
    loop do
      r4 = _nt_non_slash
      if r4
        s3 << r4
      else
        break
      end
    end
    r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
    s1 << r3
    if r3
      if (match_len = has_terminal?("/", false, index))
        r5 = true
        @index += match_len
      else
        terminal_parse_failure('"/"')
        r5 = nil
      end
      s1 << r5
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Comment0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    i6, s6 = index, []
    if (match_len = has_terminal?("#", false, index))
      r7 = true
      @index += match_len
    else
      terminal_parse_failure('"#"')
      r7 = nil
    end
    s6 << r7
    if r7
      s8, i8 = [], index
      loop do
        r9 = _nt_non_lf
        if r9
          s8 << r9
        else
          break
        end
      end
      r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
      s6 << r8
      if r8
        if (match_len = has_terminal?("\n", false, index))
          r10 = true
          @index += match_len
        else
          terminal_parse_failure('"\\n"')
          r10 = nil
        end
        s6 << r10
      end
    end
    if s6.last
      r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
      r6.extend(Comment1)
    else
      @index = i6
      r6 = nil
    end
    if r6
      r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
      r0 = r6
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:comment][start_index] = r0

  r0
end

#_nt_DIGITObject



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 361

def _nt_DIGIT
  start_index = index
  if node_cache[:DIGIT].has_key?(index)
    cached = node_cache[:DIGIT][index]
    if cached
      node_cache[:DIGIT][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('[0-9]')
    r0 = nil
  end

  node_cache[:DIGIT][start_index] = r0

  r0
end

#_nt_ellipsisObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 223

def _nt_ellipsis
  start_index = index
  if node_cache[:ellipsis].has_key?(index)
    cached = node_cache[:ellipsis][index]
    if cached
      node_cache[:ellipsis][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  s0, i0 = [], index
  loop do
    if (match_len = has_terminal?(".", false, index))
      r1 = true
      @index += match_len
    else
      terminal_parse_failure('"."')
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.size < 3
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Ellipsis0)
    r0.extend(Ellipsis0)
  end

  node_cache[:ellipsis][start_index] = r0

  r0
end

#_nt_HEXDIGObject



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 263

def _nt_HEXDIG
  start_index = index
  if node_cache[:HEXDIG].has_key?(index)
    cached = node_cache[:HEXDIG][index]
    if cached
      node_cache[:HEXDIG][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  r1 = _nt_DIGIT
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    if (match_len = has_terminal?("a", :insens, index))
      r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      @index += match_len
    else
      terminal_parse_failure('"A"')
      r2 = nil
    end
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      if (match_len = has_terminal?("b", :insens, index))
        r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"B"')
        r3 = nil
      end
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        if (match_len = has_terminal?("c", :insens, index))
          r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          @index += match_len
        else
          terminal_parse_failure('"C"')
          r4 = nil
        end
        if r4
          r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
          r0 = r4
        else
          if (match_len = has_terminal?("d", :insens, index))
            r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"D"')
            r5 = nil
          end
          if r5
            r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
            r0 = r5
          else
            if (match_len = has_terminal?("e", :insens, index))
              r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('"E"')
              r6 = nil
            end
            if r6
              r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
              r0 = r6
            else
              if (match_len = has_terminal?("f", :insens, index))
                r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                @index += match_len
              else
                terminal_parse_failure('"F"')
                r7 = nil
              end
              if r7
                r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
                r0 = r7
              else
                @index = i0
                r0 = nil
              end
            end
          end
        end
      end
    end
  end

  node_cache[:HEXDIG][start_index] = r0

  r0
end

#_nt_non_lfObject



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 503

def _nt_non_lf
  start_index = index
  if node_cache[:non_lf].has_key?(index)
    cached = node_cache[:non_lf][index]
    if cached
      node_cache[:non_lf][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  if (match_len = has_terminal?("\t", false, index))
    r1 = true
    @index += match_len
  else
    terminal_parse_failure('"\\t"')
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    if (match_len = has_terminal?("\r", false, index))
      r2 = true
      @index += match_len
    else
      terminal_parse_failure('"\\r"')
      r2 = nil
    end
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      if has_terminal?(@regexps[gr = '\A[\\ -퟿]'] ||= Regexp.new(gr), :regexp, index)
        r3 = true
        @index += 1
      else
        terminal_parse_failure('[\\ -퟿]')
        r3 = nil
      end
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        if has_terminal?(@regexps[gr = '\A[-􏿿]'] ||= Regexp.new(gr), :regexp, index)
          r4 = true
          @index += 1
        else
          terminal_parse_failure('[-􏿿]')
          r4 = nil
        end
        if r4
          r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end
    end
  end

  node_cache[:non_lf][start_index] = r0

  r0
end

#_nt_non_slashObject



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 453

def _nt_non_slash
  start_index = index
  if node_cache[:non_slash].has_key?(index)
    cached = node_cache[:non_slash][index]
    if cached
      node_cache[:non_slash][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  r1 = _nt_blank
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    if has_terminal?(@regexps[gr = '\A[!-\\.]'] ||= Regexp.new(gr), :regexp, index)
      r2 = true
      @index += 1
    else
      terminal_parse_failure('[!-\\.]')
      r2 = nil
    end
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      if has_terminal?(@regexps[gr = '\A[0-􏿿]'] ||= Regexp.new(gr), :regexp, index)
        r3 = true
        @index += 1
      else
        terminal_parse_failure('[0-􏿿]')
        r3 = nil
      end
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:non_slash][start_index] = r0

  r0
end

#_nt_SObject



581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 581

def _nt_S
  start_index = index
  if node_cache[:S].has_key?(index)
    cached = node_cache[:S][index]
    if cached
      node_cache[:S][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  s1, i1 = [], index
  loop do
    r2 = _nt_blank
    if r2
      s1 << r2
    else
      break
    end
  end
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
  s0 << r1
  if r1
    s3, i3 = [], index
    loop do
      i4, s4 = index, []
      r5 = _nt_comment
      s4 << r5
      if r5
        s6, i6 = [], index
        loop do
          r7 = _nt_blank
          if r7
            s6 << r7
          else
            break
          end
        end
        r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
        s4 << r6
      end
      if s4.last
        r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
        r4.extend(S0)
      else
        @index = i4
        r4 = nil
      end
      if r4
        s3 << r4
      else
        break
      end
    end
    r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
    s0 << r3
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(S1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:S][start_index] = r0

  r0
end

#rootObject



8
9
10
# File 'lib/cbor-diagnostic-app/hgrammar.rb', line 8

def root
  @root ||= :app_string_h
end