Module: ExaltedMath::Maths

Includes:
Treetop::Runtime
Included in:
MathsParser
Defined in:
lib/exalted_math/math.rb

Defined Under Namespace

Modules: Additive0, Additive1, Additive2, Additive3, List0, List1, List2, Max0, Max1, Max2, Min0, Min1, Min2, Multitive0, Multitive1, Multitive2, Multitive3, Number0, Number1, Primary0, Primary1, Spec0, Spec1, Stat0, Stat1

Instance Method Summary collapse

Instance Method Details

#_nt_additiveObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
# File 'lib/exalted_math/math.rb', line 52

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

  i0 = index
  i1, s1 = index, []
  r2 = _nt_multitive
  s1 << r2
  if r2
    if has_terminal?('+', false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure('+')
      r3 = nil
    end
    s1 << r3
    if r3
      r4 = _nt_space
      s1 << r4
      if r4
        r5 = _nt_additive
        s1 << r5
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Additive0)
    r1.extend(Additive1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i6, s6 = index, []
    r7 = _nt_multitive
    s6 << r7
    if r7
      if has_terminal?('-', false, index)
        r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('-')
        r8 = nil
      end
      s6 << r8
      if r8
        r9 = _nt_space
        s6 << r9
        if r9
          r10 = _nt_additive
          s6 << r10
        end
      end
    end
    if s6.last
      r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
      r6.extend(Additive2)
      r6.extend(Additive3)
    else
      @index = i6
      r6 = nil
    end
    if r6
      r0 = r6
    else
      r11 = _nt_multitive
      if r11
        r0 = r11
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:additive][start_index] = r0

  r0
end

#_nt_listObject



828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
# File 'lib/exalted_math/math.rb', line 828

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

  i0, s0 = index, []
  r1 = _nt_space
  s0 << r1
  if r1
    i2 = index
    r3 = _nt_number
    if r3
      r2 = r3
    else
      r4 = _nt_stat
      if r4
        r2 = r4
      else
        @index = i2
        r2 = nil
      end
    end
    s0 << r2
    if r2
      s5, i5 = [], index
      loop do
        i6, s6 = index, []
        if has_terminal?(',', false, index)
          r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(',')
          r7 = nil
        end
        s6 << r7
        if r7
          r8 = _nt_space
          s6 << r8
          if r8
            i9 = index
            r10 = _nt_number
            if r10
              r9 = r10
            else
              r11 = _nt_stat
              if r11
                r9 = r11
              else
                @index = i9
                r9 = nil
              end
            end
            s6 << r9
          end
        end
        if s6.last
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          r6.extend(List0)
        else
          @index = i6
          r6 = nil
        end
        if r6
          s5 << r6
        else
          break
        end
      end
      r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
      s0 << r5
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(List1)
    r0.extend(List2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:list][start_index] = r0

  r0
end

#_nt_maxObject



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
570
571
572
573
574
575
576
577
578
579
580
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
651
# File 'lib/exalted_math/math.rb', line 539

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

  i0, s0 = index, []
  i1 = index
  if has_terminal?('max', false, index)
    r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
    @index += 3
  else
    terminal_parse_failure('max')
    r2 = nil
  end
  if r2
    r1 = r2
  else
    if has_terminal?('highest', false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 7))
      @index += 7
    else
      terminal_parse_failure('highest')
      r3 = nil
    end
    if r3
      r1 = r3
    else
      @index = i1
      r1 = nil
    end
  end
  s0 << r1
  if r1
    i5, s5 = index, []
    if has_terminal?('[', false, index)
      r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure('[')
      r6 = nil
    end
    s5 << r6
    if r6
      r7 = _nt_number
      s5 << r7
      if r7
        if has_terminal?(']', false, index)
          r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(']')
          r8 = nil
        end
        s5 << r8
      end
    end
    if s5.last
      r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
      r5.extend(Max0)
    else
      @index = i5
      r5 = nil
    end
    if r5
      r4 = r5
    else
      r4 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r4
    if r4
      if has_terminal?('(', false, index)
        r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('(')
        r9 = nil
      end
      s0 << r9
      if r9
        r10 = _nt_list
        s0 << r10
        if r10
          if has_terminal?(')', false, index)
            r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(')')
            r11 = nil
          end
          s0 << r11
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Max1)
    r0.extend(Max2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:max][start_index] = r0

  r0
end

#_nt_minObject



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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
# File 'lib/exalted_math/math.rb', line 684

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

  i0, s0 = index, []
  i1 = index
  if has_terminal?('min', false, index)
    r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
    @index += 3
  else
    terminal_parse_failure('min')
    r2 = nil
  end
  if r2
    r1 = r2
  else
    if has_terminal?('lowest', false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 6))
      @index += 6
    else
      terminal_parse_failure('lowest')
      r3 = nil
    end
    if r3
      r1 = r3
    else
      @index = i1
      r1 = nil
    end
  end
  s0 << r1
  if r1
    i5, s5 = index, []
    if has_terminal?('[', false, index)
      r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure('[')
      r6 = nil
    end
    s5 << r6
    if r6
      r7 = _nt_number
      s5 << r7
      if r7
        if has_terminal?(']', false, index)
          r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(']')
          r8 = nil
        end
        s5 << r8
      end
    end
    if s5.last
      r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
      r5.extend(Min0)
    else
      @index = i5
      r5 = nil
    end
    if r5
      r4 = r5
    else
      r4 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r4
    if r4
      if has_terminal?('(', false, index)
        r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('(')
        r9 = nil
      end
      s0 << r9
      if r9
        r10 = _nt_list
        s0 << r10
        if r10
          if has_terminal?(')', false, index)
            r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(')')
            r11 = nil
          end
          s0 << r11
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Min1)
    r0.extend(Min2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:min][start_index] = r0

  r0
end

#_nt_multitiveObject



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
218
219
220
221
222
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
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/exalted_math/math.rb', line 183

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

  i0 = index
  i1, s1 = index, []
  r2 = _nt_primary
  s1 << r2
  if r2
    if has_terminal?('*', false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure('*')
      r3 = nil
    end
    s1 << r3
    if r3
      r4 = _nt_space
      s1 << r4
      if r4
        r5 = _nt_multitive
        s1 << r5
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Multitive0)
    r1.extend(Multitive1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i6, s6 = index, []
    r7 = _nt_primary
    s6 << r7
    if r7
      if has_terminal?('/', false, index)
        r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('/')
        r8 = nil
      end
      s6 << r8
      if r8
        r9 = _nt_space
        s6 << r9
        if r9
          r10 = _nt_multitive
          s6 << r10
        end
      end
    end
    if s6.last
      r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
      r6.extend(Multitive2)
      r6.extend(Multitive3)
    else
      @index = i6
      r6 = nil
    end
    if r6
      r0 = r6
    else
      r11 = _nt_primary
      if r11
        r0 = r11
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:multitive][start_index] = r0

  r0
end

#_nt_numberObject



972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
# File 'lib/exalted_math/math.rb', line 972

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

  i0, s0 = index, []
  if has_terminal?('-', false, index)
    r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('-')
    r2 = nil
  end
  if r2
    r1 = r2
  else
    r1 = instantiate_node(SyntaxNode,input, index...index)
  end
  s0 << r1
  if r1
    if has_terminal?('\G[1-9]', true, index)
      r3 = true
      @index += 1
    else
      r3 = nil
    end
    s0 << r3
    if r3
      s4, i4 = [], index
      loop do
        if has_terminal?('\G[0-9]', true, index)
          r5 = true
          @index += 1
        else
          r5 = nil
        end
        if r5
          s4 << r5
        else
          break
        end
      end
      r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
      s0 << r4
      if r4
        r6 = _nt_space
        s0 << r6
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Number0)
    r0.extend(Number1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:number][start_index] = r0

  r0
end

#_nt_primaryObject



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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/exalted_math/math.rb', line 294

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

  i0 = index
  i1, s1 = index, []
  if has_terminal?('(', false, index)
    r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('(')
    r2 = nil
  end
  s1 << r2
  if r2
    r3 = _nt_space
    s1 << r3
    if r3
      r4 = _nt_additive
      s1 << r4
      if r4
        if has_terminal?(')', false, index)
          r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(')')
          r5 = nil
        end
        s1 << r5
        if r5
          r6 = _nt_space
          s1 << r6
        end
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Primary0)
    r1.extend(Primary1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    r7 = _nt_number
    if r7
      r0 = r7
    else
      r8 = _nt_spec
      if r8
        r0 = r8
      else
        r9 = _nt_max
        if r9
          r0 = r9
        else
          r10 = _nt_min
          if r10
            r0 = r10
          else
            r11 = _nt_stat
            if r11
              r0 = r11
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end
    end
  end

  node_cache[:primary][start_index] = r0

  r0
end

#_nt_spaceObject



920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
# File 'lib/exalted_math/math.rb', line 920

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

  if has_terminal?(" ", false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure(" ")
    r1 = nil
  end
  if r1
    r0 = r1
  else
    r0 = instantiate_node(SyntaxNode,input, index...index)
  end

  node_cache[:space][start_index] = r0

  r0
end

#_nt_specObject



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
452
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
502
503
504
505
# File 'lib/exalted_math/math.rb', line 402

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

  i0, s0 = index, []
  if has_terminal?('\G[Ss]', true, index)
    r1 = true
    @index += 1
  else
    r1 = nil
  end
  s0 << r1
  if r1
    if has_terminal?('pec', false, index)
      r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
      @index += 3
    else
      terminal_parse_failure('pec')
      r2 = nil
    end
    s0 << r2
    if r2
      if has_terminal?('iality', false, index)
        r4 = instantiate_node(SyntaxNode,input, index...(index + 6))
        @index += 6
      else
        terminal_parse_failure('iality')
        r4 = nil
      end
      if r4
        r3 = r4
      else
        r3 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r3
      if r3
        if has_terminal?(':"', false, index)
          r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
          @index += 2
        else
          terminal_parse_failure(':"')
          r5 = nil
        end
        s0 << r5
        if r5
          s6, i6 = [], index
          loop do
            if has_terminal?('\G[^"]', true, index)
              r7 = true
              @index += 1
            else
              r7 = nil
            end
            if r7
              s6 << r7
            else
              break
            end
          end
          if s6.empty?
            @index = i6
            r6 = nil
          else
            r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          end
          s0 << r6
          if r6
            if has_terminal?('"', false, index)
              r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure('"')
              r8 = nil
            end
            s0 << r8
            if r8
              r9 = _nt_space
              s0 << r9
            end
          end
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Spec0)
    r0.extend(Spec1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:spec][start_index] = r0

  r0
end

#_nt_statObject



1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
# File 'lib/exalted_math/math.rb', line 1061

def _nt_stat
  start_index = index
  if node_cache[:stat].has_key?(index)
    cached = node_cache[:stat][index]
    if cached
      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
    if has_terminal?('\G[A-Za-z]', true, index)
      r2 = true
      @index += 1
    else
      r2 = nil
    end
    if r2
      s1 << r2
    else
      break
    end
  end
  if s1.empty?
    @index = i1
    r1 = nil
  else
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
  end
  s0 << r1
  if r1
    r3 = _nt_space
    s0 << r3
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Stat0)
    r0.extend(Stat1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:stat][start_index] = r0

  r0
end

#rootObject



8
9
10
# File 'lib/exalted_math/math.rb', line 8

def root
  @root ||= :additive
end