biodiversity19 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,7 +56,7 @@ module ScientificNameDirty
56
56
  if node_cache[:root].has_key?(index)
57
57
  cached = node_cache[:root][index]
58
58
  if cached
59
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
59
+ node_cache[:root][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
60
60
  @index = cached.interval.end
61
61
  end
62
62
  return cached
@@ -120,7 +120,7 @@ module ScientificNameDirty
120
120
  if node_cache[:scientific_name_5].has_key?(index)
121
121
  cached = node_cache[:scientific_name_5][index]
122
122
  if cached
123
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
123
+ node_cache[:scientific_name_5][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
124
124
  @index = cached.interval.end
125
125
  end
126
126
  return cached
@@ -143,10 +143,12 @@ module ScientificNameDirty
143
143
  r1 = nil
144
144
  end
145
145
  if r1
146
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
146
147
  r0 = r1
147
148
  else
148
149
  r4 = super
149
150
  if r4
151
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
150
152
  r0 = r4
151
153
  else
152
154
  @index = i0
@@ -236,7 +238,7 @@ module ScientificNameDirty
236
238
  if node_cache[:infraspecies].has_key?(index)
237
239
  cached = node_cache[:infraspecies][index]
238
240
  if cached
239
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
241
+ node_cache[:infraspecies][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
240
242
  @index = cached.interval.end
241
243
  end
242
244
  return cached
@@ -263,6 +265,7 @@ module ScientificNameDirty
263
265
  r1 = nil
264
266
  end
265
267
  if r1
268
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
266
269
  r0 = r1
267
270
  else
268
271
  i5, s5 = index, []
@@ -293,10 +296,12 @@ module ScientificNameDirty
293
296
  r5 = nil
294
297
  end
295
298
  if r5
299
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
296
300
  r0 = r5
297
301
  else
298
302
  r11 = super
299
303
  if r11
304
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
300
305
  r0 = r11
301
306
  else
302
307
  @index = i0
@@ -347,7 +352,7 @@ module ScientificNameDirty
347
352
  if node_cache[:species].has_key?(index)
348
353
  cached = node_cache[:species][index]
349
354
  if cached
350
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
355
+ node_cache[:species][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
351
356
  @index = cached.interval.end
352
357
  end
353
358
  return cached
@@ -374,10 +379,12 @@ module ScientificNameDirty
374
379
  r1 = nil
375
380
  end
376
381
  if r1
382
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
377
383
  r0 = r1
378
384
  else
379
385
  r5 = super
380
386
  if r5
387
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
381
388
  r0 = r5
382
389
  else
383
390
  @index = i0
@@ -418,17 +425,18 @@ module ScientificNameDirty
418
425
  if node_cache[:latin_word].has_key?(index)
419
426
  cached = node_cache[:latin_word][index]
420
427
  if cached
421
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
428
+ node_cache[:latin_word][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
422
429
  @index = cached.interval.end
423
430
  end
424
431
  return cached
425
432
  end
426
433
 
427
434
  i0, s0 = index, []
428
- if has_terminal?('\G[a-z\\-æœàâåãäáçčëéèíìïňññóòôøõöúùüŕřŗššşž]', true, index)
435
+ if has_terminal?(@regexps[gr = '\A[a-z\\-æœàâåãäáçčëéèíìïňññóòôøõöúùüŕřŗššşž]'] ||= Regexp.new(gr), :regexp, index)
429
436
  r1 = true
430
437
  @index += 1
431
438
  else
439
+ terminal_parse_failure('[a-z\\-æœàâåãäáçčëéèíìïňññóòôøõöúùüŕřŗššşž]')
432
440
  r1 = nil
433
441
  end
434
442
  s0 << r1
@@ -469,7 +477,7 @@ module ScientificNameDirty
469
477
  if node_cache[:valid_name_letters].has_key?(index)
470
478
  cached = node_cache[:valid_name_letters][index]
471
479
  if cached
472
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
480
+ node_cache[:valid_name_letters][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
473
481
  @index = cached.interval.end
474
482
  end
475
483
  return cached
@@ -477,10 +485,11 @@ module ScientificNameDirty
477
485
 
478
486
  s0, i0 = [], index
479
487
  loop do
480
- if has_terminal?('\G[a-z\\-æœàâåãäáçčëéèíìïňññóòôøõöúùüŕřŗššşž]', true, index)
488
+ if has_terminal?(@regexps[gr = '\A[a-z\\-æœàâåãäáçčëéèíìïňññóòôøõöúùüŕřŗššşž]'] ||= Regexp.new(gr), :regexp, index)
481
489
  r1 = true
482
490
  @index += 1
483
491
  else
492
+ terminal_parse_failure('[a-z\\-æœàâåãäáçčëéèíìïňññóòôøõöúùüŕřŗššşž]')
484
493
  r1 = nil
485
494
  end
486
495
  if r1
@@ -514,7 +523,7 @@ module ScientificNameDirty
514
523
  if node_cache[:right_paren].has_key?(index)
515
524
  cached = node_cache[:right_paren][index]
516
525
  if cached
517
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
526
+ node_cache[:right_paren][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
518
527
  @index = cached.interval.end
519
528
  end
520
529
  return cached
@@ -522,9 +531,9 @@ module ScientificNameDirty
522
531
 
523
532
  i0 = index
524
533
  i1, s1 = index, []
525
- if has_terminal?(")", false, index)
526
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
527
- @index += 1
534
+ if (match_len = has_terminal?(")", false, index))
535
+ r2 = true
536
+ @index += match_len
528
537
  else
529
538
  terminal_parse_failure(")")
530
539
  r2 = nil
@@ -534,9 +543,9 @@ module ScientificNameDirty
534
543
  r3 = _nt_space
535
544
  s1 << r3
536
545
  if r3
537
- if has_terminal?(")", false, index)
538
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
539
- @index += 1
546
+ if (match_len = has_terminal?(")", false, index))
547
+ r4 = true
548
+ @index += match_len
540
549
  else
541
550
  terminal_parse_failure(")")
542
551
  r4 = nil
@@ -552,10 +561,12 @@ module ScientificNameDirty
552
561
  r1 = nil
553
562
  end
554
563
  if r1
564
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
555
565
  r0 = r1
556
566
  else
557
567
  r5 = super
558
568
  if r5
569
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
559
570
  r0 = r5
560
571
  else
561
572
  @index = i0
@@ -580,7 +591,7 @@ module ScientificNameDirty
580
591
  if node_cache[:left_paren].has_key?(index)
581
592
  cached = node_cache[:left_paren][index]
582
593
  if cached
583
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
594
+ node_cache[:left_paren][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
584
595
  @index = cached.interval.end
585
596
  end
586
597
  return cached
@@ -588,9 +599,9 @@ module ScientificNameDirty
588
599
 
589
600
  i0 = index
590
601
  i1, s1 = index, []
591
- if has_terminal?("(", false, index)
592
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
593
- @index += 1
602
+ if (match_len = has_terminal?("(", false, index))
603
+ r2 = true
604
+ @index += match_len
594
605
  else
595
606
  terminal_parse_failure("(")
596
607
  r2 = nil
@@ -600,9 +611,9 @@ module ScientificNameDirty
600
611
  r3 = _nt_space
601
612
  s1 << r3
602
613
  if r3
603
- if has_terminal?("(", false, index)
604
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
605
- @index += 1
614
+ if (match_len = has_terminal?("(", false, index))
615
+ r4 = true
616
+ @index += match_len
606
617
  else
607
618
  terminal_parse_failure("(")
608
619
  r4 = nil
@@ -618,10 +629,12 @@ module ScientificNameDirty
618
629
  r1 = nil
619
630
  end
620
631
  if r1
632
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
621
633
  r0 = r1
622
634
  else
623
635
  r5 = super
624
636
  if r5
637
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
625
638
  r0 = r5
626
639
  else
627
640
  @index = i0
@@ -695,7 +708,7 @@ module ScientificNameDirty
695
708
  if node_cache[:year].has_key?(index)
696
709
  cached = node_cache[:year][index]
697
710
  if cached
698
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
711
+ node_cache[:year][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
699
712
  @index = cached.interval.end
700
713
  end
701
714
  return cached
@@ -722,6 +735,7 @@ module ScientificNameDirty
722
735
  r1 = nil
723
736
  end
724
737
  if r1
738
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
725
739
  r0 = r1
726
740
  else
727
741
  i5, s5 = index, []
@@ -744,22 +758,27 @@ module ScientificNameDirty
744
758
  r5 = nil
745
759
  end
746
760
  if r5
761
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
747
762
  r0 = r5
748
763
  else
749
764
  r9 = _nt_year_number_with_punctuation
750
765
  if r9
766
+ r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
751
767
  r0 = r9
752
768
  else
753
769
  r10 = _nt_approximate_year
754
770
  if r10
771
+ r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
755
772
  r0 = r10
756
773
  else
757
774
  r11 = _nt_double_year
758
775
  if r11
776
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
759
777
  r0 = r11
760
778
  else
761
779
  r12 = super
762
780
  if r12
781
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
763
782
  r0 = r12
764
783
  else
765
784
  @index = i0
@@ -810,16 +829,16 @@ module ScientificNameDirty
810
829
  if node_cache[:approximate_year].has_key?(index)
811
830
  cached = node_cache[:approximate_year][index]
812
831
  if cached
813
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
832
+ node_cache[:approximate_year][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
814
833
  @index = cached.interval.end
815
834
  end
816
835
  return cached
817
836
  end
818
837
 
819
838
  i0, s0 = index, []
820
- if has_terminal?("[", false, index)
821
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
822
- @index += 1
839
+ if (match_len = has_terminal?("[", false, index))
840
+ r1 = true
841
+ @index += match_len
823
842
  else
824
843
  terminal_parse_failure("[")
825
844
  r1 = nil
@@ -837,9 +856,9 @@ module ScientificNameDirty
837
856
  if r4
838
857
  s5, i5 = [], index
839
858
  loop do
840
- if has_terminal?("]", false, index)
841
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
842
- @index += 1
859
+ if (match_len = has_terminal?("]", false, index))
860
+ r6 = true
861
+ @index += match_len
843
862
  else
844
863
  terminal_parse_failure("]")
845
864
  r6 = nil
@@ -901,7 +920,7 @@ module ScientificNameDirty
901
920
  if node_cache[:double_year].has_key?(index)
902
921
  cached = node_cache[:double_year][index]
903
922
  if cached
904
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
923
+ node_cache[:double_year][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
905
924
  @index = cached.interval.end
906
925
  end
907
926
  return cached
@@ -911,9 +930,9 @@ module ScientificNameDirty
911
930
  r1 = _nt_year_number
912
931
  s0 << r1
913
932
  if r1
914
- if has_terminal?("-", false, index)
915
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
916
- @index += 1
933
+ if (match_len = has_terminal?("-", false, index))
934
+ r2 = true
935
+ @index += match_len
917
936
  else
918
937
  terminal_parse_failure("-")
919
938
  r2 = nil
@@ -922,10 +941,11 @@ module ScientificNameDirty
922
941
  if r2
923
942
  s3, i3 = [], index
924
943
  loop do
925
- if has_terminal?('\G[0-9]', true, index)
944
+ if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
926
945
  r4 = true
927
946
  @index += 1
928
947
  else
948
+ terminal_parse_failure('[0-9]')
929
949
  r4 = nil
930
950
  end
931
951
  if r4
@@ -942,10 +962,11 @@ module ScientificNameDirty
942
962
  end
943
963
  s0 << r3
944
964
  if r3
945
- if has_terminal?('\G[A-Za-z]', true, index)
965
+ if has_terminal?(@regexps[gr = '\A[A-Za-z]'] ||= Regexp.new(gr), :regexp, index)
946
966
  r6 = true
947
967
  @index += 1
948
968
  else
969
+ terminal_parse_failure('[A-Za-z]')
949
970
  r6 = nil
950
971
  end
951
972
  if r6
@@ -955,10 +976,11 @@ module ScientificNameDirty
955
976
  end
956
977
  s0 << r5
957
978
  if r5
958
- if has_terminal?('\G[\\?]', true, index)
979
+ if has_terminal?(@regexps[gr = '\A[\\?]'] ||= Regexp.new(gr), :regexp, index)
959
980
  r8 = true
960
981
  @index += 1
961
982
  else
983
+ terminal_parse_failure('[\\?]')
962
984
  r8 = nil
963
985
  end
964
986
  if r8
@@ -1011,7 +1033,7 @@ module ScientificNameDirty
1011
1033
  if node_cache[:year_number_with_punctuation].has_key?(index)
1012
1034
  cached = node_cache[:year_number_with_punctuation][index]
1013
1035
  if cached
1014
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1036
+ node_cache[:year_number_with_punctuation][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1015
1037
  @index = cached.interval.end
1016
1038
  end
1017
1039
  return cached
@@ -1021,9 +1043,9 @@ module ScientificNameDirty
1021
1043
  r1 = _nt_year_number
1022
1044
  s0 << r1
1023
1045
  if r1
1024
- if has_terminal?(".", false, index)
1025
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
1026
- @index += 1
1046
+ if (match_len = has_terminal?(".", false, index))
1047
+ r2 = true
1048
+ @index += match_len
1027
1049
  else
1028
1050
  terminal_parse_failure(".")
1029
1051
  r2 = nil
@@ -1061,16 +1083,16 @@ module ScientificNameDirty
1061
1083
  if node_cache[:page_number].has_key?(index)
1062
1084
  cached = node_cache[:page_number][index]
1063
1085
  if cached
1064
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1086
+ node_cache[:page_number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1065
1087
  @index = cached.interval.end
1066
1088
  end
1067
1089
  return cached
1068
1090
  end
1069
1091
 
1070
1092
  i0, s0 = index, []
1071
- if has_terminal?(":", false, index)
1072
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1073
- @index += 1
1093
+ if (match_len = has_terminal?(":", false, index))
1094
+ r1 = true
1095
+ @index += match_len
1074
1096
  else
1075
1097
  terminal_parse_failure(":")
1076
1098
  r1 = nil
@@ -1082,10 +1104,11 @@ module ScientificNameDirty
1082
1104
  if r2
1083
1105
  s3, i3 = [], index
1084
1106
  loop do
1085
- if has_terminal?('\G[\\d]', true, index)
1107
+ if has_terminal?(@regexps[gr = '\A[\\d]'] ||= Regexp.new(gr), :regexp, index)
1086
1108
  r4 = true
1087
1109
  @index += 1
1088
1110
  else
1111
+ terminal_parse_failure('[\\d]')
1089
1112
  r4 = nil
1090
1113
  end
1091
1114
  if r4
@@ -1122,15 +1145,15 @@ module ScientificNameDirty
1122
1145
  if node_cache[:string_authorship_inconsistencies].has_key?(index)
1123
1146
  cached = node_cache[:string_authorship_inconsistencies][index]
1124
1147
  if cached
1125
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1148
+ node_cache[:string_authorship_inconsistencies][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1126
1149
  @index = cached.interval.end
1127
1150
  end
1128
1151
  return cached
1129
1152
  end
1130
1153
 
1131
- if has_terminal?("corrig.", false, index)
1132
- r0 = instantiate_node(SyntaxNode,input, index...(index + 7))
1133
- @index += 7
1154
+ if (match_len = has_terminal?("corrig.", false, index))
1155
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1156
+ @index += match_len
1134
1157
  else
1135
1158
  terminal_parse_failure("corrig.")
1136
1159
  r0 = nil
@@ -1164,7 +1187,7 @@ module ScientificNameDirty
1164
1187
  if node_cache[:garbage].has_key?(index)
1165
1188
  cached = node_cache[:garbage][index]
1166
1189
  if cached
1167
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1190
+ node_cache[:garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1168
1191
  @index = cached.interval.end
1169
1192
  end
1170
1193
  return cached
@@ -1175,10 +1198,11 @@ module ScientificNameDirty
1175
1198
  r2 = _nt_space
1176
1199
  s1 << r2
1177
1200
  if r2
1178
- if has_terminal?('\G["\',]', true, index)
1201
+ if has_terminal?(@regexps[gr = '\A["\',]'] ||= Regexp.new(gr), :regexp, index)
1179
1202
  r3 = true
1180
1203
  @index += 1
1181
1204
  else
1205
+ terminal_parse_failure('["\',]')
1182
1206
  r3 = nil
1183
1207
  end
1184
1208
  s1 << r3
@@ -1188,10 +1212,11 @@ module ScientificNameDirty
1188
1212
  if r4
1189
1213
  s5, i5 = [], index
1190
1214
  loop do
1191
- if has_terminal?('\G[^щ]', true, index)
1215
+ if has_terminal?(@regexps[gr = '\A[^щ]'] ||= Regexp.new(gr), :regexp, index)
1192
1216
  r6 = true
1193
1217
  @index += 1
1194
1218
  else
1219
+ terminal_parse_failure('[^щ]')
1195
1220
  r6 = nil
1196
1221
  end
1197
1222
  if r6
@@ -1213,6 +1238,7 @@ module ScientificNameDirty
1213
1238
  r1 = nil
1214
1239
  end
1215
1240
  if r1
1241
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1216
1242
  r0 = r1
1217
1243
  else
1218
1244
  i7, s7 = index, []
@@ -1221,10 +1247,11 @@ module ScientificNameDirty
1221
1247
  if r8
1222
1248
  s9, i9 = [], index
1223
1249
  loop do
1224
- if has_terminal?('\G[^ш]', true, index)
1250
+ if has_terminal?(@regexps[gr = '\A[^ш]'] ||= Regexp.new(gr), :regexp, index)
1225
1251
  r10 = true
1226
1252
  @index += 1
1227
1253
  else
1254
+ terminal_parse_failure('[^ш]')
1228
1255
  r10 = nil
1229
1256
  end
1230
1257
  if r10
@@ -1249,6 +1276,7 @@ module ScientificNameDirty
1249
1276
  r7 = nil
1250
1277
  end
1251
1278
  if r7
1279
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
1252
1280
  r0 = r7
1253
1281
  else
1254
1282
  @index = i0