regexp_parser 2.7.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -5
  3. data/LICENSE +1 -1
  4. data/Rakefile +5 -3
  5. data/lib/regexp_parser/error.rb +2 -0
  6. data/lib/regexp_parser/expression/base.rb +2 -7
  7. data/lib/regexp_parser/expression/classes/alternation.rb +3 -1
  8. data/lib/regexp_parser/expression/classes/anchor.rb +2 -0
  9. data/lib/regexp_parser/expression/classes/backreference.rb +7 -26
  10. data/lib/regexp_parser/expression/classes/character_set/intersection.rb +2 -0
  11. data/lib/regexp_parser/expression/classes/character_set/range.rb +4 -7
  12. data/lib/regexp_parser/expression/classes/character_set.rb +6 -8
  13. data/lib/regexp_parser/expression/classes/character_type.rb +2 -0
  14. data/lib/regexp_parser/expression/classes/conditional.rb +4 -28
  15. data/lib/regexp_parser/expression/classes/escape_sequence.rb +29 -96
  16. data/lib/regexp_parser/expression/classes/free_space.rb +5 -1
  17. data/lib/regexp_parser/expression/classes/group.rb +2 -22
  18. data/lib/regexp_parser/expression/classes/keep.rb +3 -1
  19. data/lib/regexp_parser/expression/classes/literal.rb +2 -0
  20. data/lib/regexp_parser/expression/classes/posix_class.rb +7 -5
  21. data/lib/regexp_parser/expression/classes/root.rb +2 -0
  22. data/lib/regexp_parser/expression/classes/unicode_property.rb +13 -11
  23. data/lib/regexp_parser/expression/methods/construct.rb +4 -4
  24. data/lib/regexp_parser/expression/methods/escape_sequence_char.rb +7 -0
  25. data/lib/regexp_parser/expression/methods/escape_sequence_codepoint.rb +76 -0
  26. data/lib/regexp_parser/expression/methods/human_name.rb +2 -0
  27. data/lib/regexp_parser/expression/methods/match.rb +2 -0
  28. data/lib/regexp_parser/expression/methods/match_length.rb +2 -0
  29. data/lib/regexp_parser/expression/methods/negative.rb +22 -0
  30. data/lib/regexp_parser/expression/methods/options.rb +2 -0
  31. data/lib/regexp_parser/expression/methods/parts.rb +25 -0
  32. data/lib/regexp_parser/expression/methods/printing.rb +28 -0
  33. data/lib/regexp_parser/expression/methods/referenced_expressions.rb +30 -0
  34. data/lib/regexp_parser/expression/methods/strfregexp.rb +2 -0
  35. data/lib/regexp_parser/expression/methods/tests.rb +42 -3
  36. data/lib/regexp_parser/expression/methods/traverse.rb +35 -20
  37. data/lib/regexp_parser/expression/quantifier.rb +33 -18
  38. data/lib/regexp_parser/expression/sequence.rb +7 -9
  39. data/lib/regexp_parser/expression/sequence_operation.rb +6 -9
  40. data/lib/regexp_parser/expression/shared.rb +40 -24
  41. data/lib/regexp_parser/expression/subexpression.rb +22 -18
  42. data/lib/regexp_parser/expression.rb +39 -31
  43. data/lib/regexp_parser/lexer.rb +17 -7
  44. data/lib/regexp_parser/parser.rb +101 -95
  45. data/lib/regexp_parser/scanner/errors/premature_end_error.rb +10 -0
  46. data/lib/regexp_parser/scanner/errors/scanner_error.rb +8 -0
  47. data/lib/regexp_parser/scanner/errors/validation_error.rb +65 -0
  48. data/lib/regexp_parser/scanner/properties/long.csv +61 -0
  49. data/lib/regexp_parser/scanner/properties/short.csv +15 -0
  50. data/lib/regexp_parser/scanner/property.rl +1 -1
  51. data/lib/regexp_parser/scanner/scanner.rl +90 -140
  52. data/lib/regexp_parser/scanner.rb +1336 -1450
  53. data/lib/regexp_parser/syntax/any.rb +2 -0
  54. data/lib/regexp_parser/syntax/base.rb +2 -0
  55. data/lib/regexp_parser/syntax/token/anchor.rb +5 -3
  56. data/lib/regexp_parser/syntax/token/assertion.rb +4 -2
  57. data/lib/regexp_parser/syntax/token/backreference.rb +11 -6
  58. data/lib/regexp_parser/syntax/token/character_set.rb +6 -1
  59. data/lib/regexp_parser/syntax/token/character_type.rb +6 -4
  60. data/lib/regexp_parser/syntax/token/conditional.rb +5 -3
  61. data/lib/regexp_parser/syntax/token/escape.rb +12 -8
  62. data/lib/regexp_parser/syntax/token/group.rb +8 -6
  63. data/lib/regexp_parser/syntax/token/keep.rb +3 -1
  64. data/lib/regexp_parser/syntax/token/meta.rb +11 -2
  65. data/lib/regexp_parser/syntax/token/posix_class.rb +4 -2
  66. data/lib/regexp_parser/syntax/token/quantifier.rb +8 -6
  67. data/lib/regexp_parser/syntax/token/unicode_property.rb +164 -70
  68. data/lib/regexp_parser/syntax/token/virtual.rb +13 -0
  69. data/lib/regexp_parser/syntax/token.rb +18 -16
  70. data/lib/regexp_parser/syntax/version_lookup.rb +4 -2
  71. data/lib/regexp_parser/syntax/versions/1.8.6.rb +2 -0
  72. data/lib/regexp_parser/syntax/versions/1.9.1.rb +2 -0
  73. data/lib/regexp_parser/syntax/versions/1.9.3.rb +2 -0
  74. data/lib/regexp_parser/syntax/versions/2.0.0.rb +2 -0
  75. data/lib/regexp_parser/syntax/versions/2.2.0.rb +2 -0
  76. data/lib/regexp_parser/syntax/versions/2.3.0.rb +2 -0
  77. data/lib/regexp_parser/syntax/versions/2.4.0.rb +2 -0
  78. data/lib/regexp_parser/syntax/versions/2.4.1.rb +2 -0
  79. data/lib/regexp_parser/syntax/versions/2.5.0.rb +2 -0
  80. data/lib/regexp_parser/syntax/versions/2.6.0.rb +2 -0
  81. data/lib/regexp_parser/syntax/versions/2.6.2.rb +2 -0
  82. data/lib/regexp_parser/syntax/versions/2.6.3.rb +2 -0
  83. data/lib/regexp_parser/syntax/versions/3.1.0.rb +2 -0
  84. data/lib/regexp_parser/syntax/versions/3.2.0.rb +2 -0
  85. data/lib/regexp_parser/syntax/versions/3.5.0.rb +4 -0
  86. data/lib/regexp_parser/syntax/versions/4.0.0.rb +4 -0
  87. data/lib/regexp_parser/syntax/versions.rb +3 -1
  88. data/lib/regexp_parser/syntax.rb +3 -1
  89. data/lib/regexp_parser/token.rb +2 -0
  90. data/lib/regexp_parser/version.rb +3 -1
  91. data/lib/regexp_parser.rb +8 -6
  92. data/regexp_parser.gemspec +7 -5
  93. metadata +19 -11
  94. data/CHANGELOG.md +0 -632
  95. data/README.md +0 -503
@@ -1,37 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Regexp::Syntax
2
4
  module Token
3
5
  module UnicodeProperty
4
- all = proc { |name| constants.grep(/#{name}/).flat_map(&method(:const_get)) }
6
+ def self.all(name)
7
+ constants.grep(/#{name}/).flat_map(&method(:const_get)).freeze
8
+ end
9
+ private_class_method :all
5
10
 
6
11
  CharType_V1_9_0 = %i[alnum alpha ascii blank cntrl digit graph
7
- lower print punct space upper word xdigit]
12
+ lower print punct space upper word xdigit].freeze
8
13
 
9
- CharType_V2_5_0 = %i[xposixpunct]
14
+ CharType_V2_5_0 = %i[xposixpunct].freeze
10
15
 
11
- POSIX = %i[any assigned newline]
16
+ POSIX = %i[any assigned newline].freeze
12
17
 
13
18
  module Category
14
19
  Letter = %i[letter uppercase_letter lowercase_letter
15
- titlecase_letter modifier_letter other_letter]
20
+ titlecase_letter modifier_letter other_letter].freeze
16
21
 
17
22
  Mark = %i[mark nonspacing_mark spacing_mark
18
- enclosing_mark]
23
+ enclosing_mark].freeze
19
24
 
20
25
  Number = %i[number decimal_number letter_number
21
- other_number]
26
+ other_number].freeze
22
27
 
23
28
  Punctuation = %i[punctuation connector_punctuation dash_punctuation
24
29
  open_punctuation close_punctuation initial_punctuation
25
- final_punctuation other_punctuation]
30
+ final_punctuation other_punctuation].freeze
26
31
 
27
32
  Symbol = %i[symbol math_symbol currency_symbol
28
- modifier_symbol other_symbol]
33
+ modifier_symbol other_symbol].freeze
29
34
 
30
35
  Separator = %i[separator space_separator line_separator
31
- paragraph_separator]
36
+ paragraph_separator].freeze
32
37
 
33
38
  Codepoint = %i[other control format
34
- surrogate private_use unassigned]
39
+ surrogate private_use unassigned].freeze
35
40
 
36
41
  All = Letter + Mark + Number + Punctuation +
37
42
  Symbol + Separator + Codepoint
@@ -39,29 +44,33 @@ module Regexp::Syntax
39
44
 
40
45
  Age_V1_9_3 = %i[age=1.1 age=2.0 age=2.1 age=3.0 age=3.1
41
46
  age=3.2 age=4.0 age=4.1 age=5.0 age=5.1
42
- age=5.2 age=6.0]
47
+ age=5.2 age=6.0].freeze
48
+
49
+ Age_V2_0_0 = %i[age=6.1].freeze
43
50
 
44
- Age_V2_0_0 = %i[age=6.1]
51
+ Age_V2_2_0 = %i[age=6.2 age=6.3 age=7.0].freeze
45
52
 
46
- Age_V2_2_0 = %i[age=6.2 age=6.3 age=7.0]
53
+ Age_V2_3_0 = %i[age=8.0].freeze
47
54
 
48
- Age_V2_3_0 = %i[age=8.0]
55
+ Age_V2_4_0 = %i[age=9.0].freeze
49
56
 
50
- Age_V2_4_0 = %i[age=9.0]
57
+ Age_V2_5_0 = %i[age=10.0].freeze
51
58
 
52
- Age_V2_5_0 = %i[age=10.0]
59
+ Age_V2_6_0 = %i[age=11.0].freeze
53
60
 
54
- Age_V2_6_0 = %i[age=11.0]
61
+ Age_V2_6_2 = %i[age=12.0].freeze
55
62
 
56
- Age_V2_6_2 = %i[age=12.0]
63
+ Age_V2_6_3 = %i[age=12.1].freeze
57
64
 
58
- Age_V2_6_3 = %i[age=12.1]
65
+ Age_V3_1_0 = %i[age=13.0].freeze
59
66
 
60
- Age_V3_1_0 = %i[age=13.0]
67
+ Age_V3_2_0 = %i[age=14.0 age=15.0].freeze
61
68
 
62
- Age_V3_2_0 = %i[age=14.0]
69
+ Age_V3_5_0 = %i[age=15.1].freeze
63
70
 
64
- Age = all[:Age_V]
71
+ Age_V4_0_0 = %i[age=16.0 age=17.0].freeze
72
+
73
+ Age = all(:Age_V)
65
74
 
66
75
  Derived_V1_9_0 = %i[
67
76
  ascii_hex_digit
@@ -115,22 +124,32 @@ module Regexp::Syntax
115
124
  white_space
116
125
  xid_start
117
126
  xid_continue
118
- ]
127
+ ].freeze
119
128
 
120
129
  Derived_V2_0_0 = %i[
121
130
  cased_letter
122
131
  combining_mark
123
- ]
132
+ ].freeze
124
133
 
125
134
  Derived_V2_4_0 = %i[
126
135
  prepended_concatenation_mark
127
- ]
136
+ ].freeze
128
137
 
129
138
  Derived_V2_5_0 = %i[
130
139
  regional_indicator
140
+ ].freeze
141
+
142
+ Derived_V3_5_0 = %i[
143
+ id_compat_math_continue
144
+ id_compat_math_start
145
+ ids_unary_operator
146
+ ].freeze
147
+
148
+ Derived_V4_0_0 = %i[
149
+ modifier_combining_mark
131
150
  ]
132
151
 
133
- Derived = all[:Derived_V]
152
+ Derived = all(:Derived_V)
134
153
 
135
154
  Script_V1_9_0 = %i[
136
155
  arabic
@@ -226,13 +245,13 @@ module Regexp::Syntax
226
245
  inherited
227
246
  common
228
247
  unknown
229
- ]
248
+ ].freeze
230
249
 
231
250
  Script_V1_9_3 = %i[
232
251
  brahmi
233
252
  batak
234
253
  mandaic
235
- ]
254
+ ].freeze
236
255
 
237
256
  Script_V2_0_0 = %i[
238
257
  chakma
@@ -242,7 +261,7 @@ module Regexp::Syntax
242
261
  sharada
243
262
  sora_sompeng
244
263
  takri
245
- ]
264
+ ].freeze
246
265
 
247
266
  Script_V2_2_0 = %i[
248
267
  caucasian_albanian
@@ -268,7 +287,7 @@ module Regexp::Syntax
268
287
  khudawadi
269
288
  tirhuta
270
289
  warang_citi
271
- ]
290
+ ].freeze
272
291
 
273
292
  Script_V2_3_0 = %i[
274
293
  ahom
@@ -277,7 +296,7 @@ module Regexp::Syntax
277
296
  multani
278
297
  old_hungarian
279
298
  signwriting
280
- ]
299
+ ].freeze
281
300
 
282
301
  Script_V2_4_0 = %i[
283
302
  adlam
@@ -286,14 +305,14 @@ module Regexp::Syntax
286
305
  newa
287
306
  osage
288
307
  tangut
289
- ]
308
+ ].freeze
290
309
 
291
310
  Script_V2_5_0 = %i[
292
311
  masaram_gondi
293
312
  nushu
294
313
  soyombo
295
314
  zanabazar_square
296
- ]
315
+ ].freeze
297
316
 
298
317
  Script_V2_6_0 = %i[
299
318
  dogra
@@ -303,31 +322,47 @@ module Regexp::Syntax
303
322
  medefaidrin
304
323
  old_sogdian
305
324
  sogdian
306
- ]
325
+ ].freeze
307
326
 
308
327
  Script_V2_6_2 = %i[
309
328
  elymaic
310
329
  nandinagari
311
330
  nyiakeng_puachue_hmong
312
331
  wancho
313
- ]
332
+ ].freeze
314
333
 
315
334
  Script_V3_1_0 = %i[
316
335
  chorasmian
317
336
  dives_akuru
318
337
  khitan_small_script
319
338
  yezidi
320
- ]
339
+ ].freeze
321
340
 
322
341
  Script_V3_2_0 = %i[
323
342
  cypro_minoan
343
+ kawi
344
+ nag_mundari
324
345
  old_uyghur
325
346
  tangsa
326
347
  toto
327
348
  vithkuqi
328
- ]
329
-
330
- Script = all[:Script_V]
349
+ ].freeze
350
+
351
+ Script_V4_0_0 = %i[
352
+ beria_erfe
353
+ garay
354
+ gurung_khema
355
+ kirat_rai
356
+ ol_onal
357
+ sidetic
358
+ sunuwar
359
+ tai_yo
360
+ todhri
361
+ tolong_siki
362
+ tulu_tigalari
363
+ ].freeze
364
+
365
+ Script = all(:Script_V)
331
366
 
332
367
  UnicodeBlock_V1_9_0 = %i[
333
368
  in_alphabetic_presentation_forms
@@ -426,7 +461,7 @@ module Regexp::Syntax
426
461
  in_yi_radicals
427
462
  in_yi_syllables
428
463
  in_yijing_hexagram_symbols
429
- ]
464
+ ].freeze
430
465
 
431
466
  UnicodeBlock_V2_0_0 = %i[
432
467
  in_aegean_numbers
@@ -554,7 +589,7 @@ module Regexp::Syntax
554
589
  in_variation_selectors_supplement
555
590
  in_vedic_extensions
556
591
  in_vertical_forms
557
- ]
592
+ ].freeze
558
593
 
559
594
  UnicodeBlock_V2_2_0 = %i[
560
595
  in_bassa_vah
@@ -589,7 +624,7 @@ module Regexp::Syntax
589
624
  in_supplemental_arrows_c
590
625
  in_tirhuta
591
626
  in_warang_citi
592
- ]
627
+ ].freeze
593
628
 
594
629
  UnicodeBlock_V2_3_0 = %i[
595
630
  in_ahom
@@ -602,7 +637,7 @@ module Regexp::Syntax
602
637
  in_old_hungarian
603
638
  in_supplemental_symbols_and_pictographs
604
639
  in_sutton_signwriting
605
- ]
640
+ ].freeze
606
641
 
607
642
  UnicodeBlock_V2_4_0 = %i[
608
643
  in_adlam
@@ -616,7 +651,7 @@ module Regexp::Syntax
616
651
  in_osage
617
652
  in_tangut
618
653
  in_tangut_components
619
- ]
654
+ ].freeze
620
655
 
621
656
  UnicodeBlock_V2_5_0 = %i[
622
657
  in_cjk_unified_ideographs_extension_f
@@ -626,7 +661,7 @@ module Regexp::Syntax
626
661
  in_soyombo
627
662
  in_syriac_supplement
628
663
  in_zanabazar_square
629
- ]
664
+ ].freeze
630
665
 
631
666
  UnicodeBlock_V2_6_0 = %i[
632
667
  in_chess_symbols
@@ -640,7 +675,7 @@ module Regexp::Syntax
640
675
  in_medefaidrin
641
676
  in_old_sogdian
642
677
  in_sogdian
643
- ]
678
+ ].freeze
644
679
 
645
680
  UnicodeBlock_V2_6_2 = %i[
646
681
  in_egyptian_hieroglyph_format_controls
@@ -652,7 +687,7 @@ module Regexp::Syntax
652
687
  in_symbols_and_pictographs_extended_a
653
688
  in_tamil_supplement
654
689
  in_wancho
655
- ]
690
+ ].freeze
656
691
 
657
692
  UnicodeBlock_V3_1_0 = %i[
658
693
  in_chorasmian
@@ -663,24 +698,56 @@ module Regexp::Syntax
663
698
  in_symbols_for_legacy_computing
664
699
  in_tangut_supplement
665
700
  in_yezidi
666
- ]
701
+ ].freeze
667
702
 
668
703
  UnicodeBlock_V3_2_0 = %i[
669
704
  in_arabic_extended_b
705
+ in_arabic_extended_c
706
+ in_cjk_unified_ideographs_extension_h
670
707
  in_cypro_minoan
708
+ in_cyrillic_extended_d
709
+ in_devanagari_extended_a
671
710
  in_ethiopic_extended_b
711
+ in_kaktovik_numerals
672
712
  in_kana_extended_b
713
+ in_kawi
673
714
  in_latin_extended_f
674
715
  in_latin_extended_g
716
+ in_nag_mundari
675
717
  in_old_uyghur
676
718
  in_tangsa
677
719
  in_toto
678
720
  in_unified_canadian_aboriginal_syllabics_extended_a
679
721
  in_vithkuqi
680
722
  in_znamenny_musical_notation
681
- ]
682
-
683
- UnicodeBlock = all[:UnicodeBlock_V]
723
+ ].freeze
724
+
725
+ UnicodeBlock_V3_5_0 = %i[
726
+ in_cjk_unified_ideographs_extension_i
727
+ ].freeze
728
+
729
+ UnicodeBlock_V4_0_0 = %i[
730
+ in_beria_erfe
731
+ in_cjk_unified_ideographs_extension_j
732
+ in_egyptian_hieroglyphs_extended_a
733
+ in_garay
734
+ in_gurung_khema
735
+ in_kirat_rai
736
+ in_miscellaneous_symbols_supplement
737
+ in_myanmar_extended_c
738
+ in_ol_onal
739
+ in_sharada_supplement
740
+ in_sidetic
741
+ in_sunuwar
742
+ in_symbols_for_legacy_computing_supplement
743
+ in_tai_yo
744
+ in_tangut_components_supplement
745
+ in_todhri
746
+ in_tolong_siki
747
+ in_tulu_tigalari
748
+ ].freeze
749
+
750
+ UnicodeBlock = all(:UnicodeBlock_V)
684
751
 
685
752
  Emoji_V2_5_0 = %i[
686
753
  emoji
@@ -688,24 +755,48 @@ module Regexp::Syntax
688
755
  emoji_modifier
689
756
  emoji_modifier_base
690
757
  emoji_presentation
691
- ]
692
-
693
- Emoji = all[:Emoji_V]
694
-
695
- V1_9_0 = Category::All + POSIX + all[:V1_9_0]
696
- V1_9_3 = all[:V1_9_3]
697
- V2_0_0 = all[:V2_0_0]
698
- V2_2_0 = all[:V2_2_0]
699
- V2_3_0 = all[:V2_3_0]
700
- V2_4_0 = all[:V2_4_0]
701
- V2_5_0 = all[:V2_5_0]
702
- V2_6_0 = all[:V2_6_0]
703
- V2_6_2 = all[:V2_6_2]
704
- V2_6_3 = all[:V2_6_3]
705
- V3_1_0 = all[:V3_1_0]
706
- V3_2_0 = all[:V3_2_0]
707
-
708
- All = all[/^V\d+_\d+_\d+$/]
758
+ ].freeze
759
+
760
+ Emoji_V2_6_0 = %i[
761
+ extended_pictographic
762
+ ].freeze
763
+
764
+ Enumerated_V2_4_0 = %i[
765
+ grapheme_cluster_break=control
766
+ grapheme_cluster_break=cr
767
+ grapheme_cluster_break=extend
768
+ grapheme_cluster_break=l
769
+ grapheme_cluster_break=lf
770
+ grapheme_cluster_break=lv
771
+ grapheme_cluster_break=lvt
772
+ grapheme_cluster_break=prepend
773
+ grapheme_cluster_break=regional_indicator
774
+ grapheme_cluster_break=spacingmark
775
+ grapheme_cluster_break=t
776
+ grapheme_cluster_break=v
777
+ grapheme_cluster_break=zwj
778
+ ].freeze
779
+
780
+ Enumerated = all(:Enumerated_V)
781
+
782
+ Emoji = all(:Emoji_V)
783
+
784
+ V1_9_0 = Category::All + POSIX + all(:V1_9_0)
785
+ V1_9_3 = all(:V1_9_3)
786
+ V2_0_0 = all(:V2_0_0)
787
+ V2_2_0 = all(:V2_2_0)
788
+ V2_3_0 = all(:V2_3_0)
789
+ V2_4_0 = all(:V2_4_0)
790
+ V2_5_0 = all(:V2_5_0)
791
+ V2_6_0 = all(:V2_6_0)
792
+ V2_6_2 = all(:V2_6_2)
793
+ V2_6_3 = all(:V2_6_3)
794
+ V3_1_0 = all(:V3_1_0)
795
+ V3_2_0 = all(:V3_2_0)
796
+ V3_5_0 = all(:V3_5_0)
797
+ V4_0_0 = all(:V4_0_0)
798
+
799
+ All = all(/^V\d+_\d+_\d+$/)
709
800
 
710
801
  Type = :property
711
802
  NonType = :nonproperty
@@ -713,5 +804,8 @@ module Regexp::Syntax
713
804
 
714
805
  Map[UnicodeProperty::Type] = UnicodeProperty::All
715
806
  Map[UnicodeProperty::NonType] = UnicodeProperty::All
807
+
808
+ # alias for symmetry between token symbol and Token module name
809
+ Property = UnicodeProperty
716
810
  end
717
811
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Regexp::Syntax
4
+ module Token
5
+ module Virtual
6
+ Root = %i[root].freeze
7
+ Sequence = %i[sequence].freeze
8
+
9
+ All = %i[root sequence].freeze
10
+ Type = :expression
11
+ end
12
+ end
13
+ end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Define the base module and the simplest of tokens.
2
4
  module Regexp::Syntax
3
5
  module Token
4
- Map = {}
6
+ Map = Hash.new
5
7
 
6
8
  module Literal
7
- All = %i[literal]
9
+ All = %i[literal].freeze
8
10
  Type = :literal
9
11
  end
10
12
 
11
13
  module FreeSpace
12
- All = %i[comment whitespace]
14
+ All = %i[comment whitespace].freeze
13
15
  Type = :free_space
14
16
  end
15
17
 
@@ -20,19 +22,19 @@ end
20
22
 
21
23
 
22
24
  # Load all the token files, they will populate the Map constant.
23
- require 'regexp_parser/syntax/token/anchor'
24
- require 'regexp_parser/syntax/token/assertion'
25
- require 'regexp_parser/syntax/token/backreference'
26
- require 'regexp_parser/syntax/token/posix_class'
27
- require 'regexp_parser/syntax/token/character_set'
28
- require 'regexp_parser/syntax/token/character_type'
29
- require 'regexp_parser/syntax/token/conditional'
30
- require 'regexp_parser/syntax/token/escape'
31
- require 'regexp_parser/syntax/token/group'
32
- require 'regexp_parser/syntax/token/keep'
33
- require 'regexp_parser/syntax/token/meta'
34
- require 'regexp_parser/syntax/token/quantifier'
35
- require 'regexp_parser/syntax/token/unicode_property'
25
+ require_relative 'token/anchor'
26
+ require_relative 'token/assertion'
27
+ require_relative 'token/backreference'
28
+ require_relative 'token/posix_class'
29
+ require_relative 'token/character_set'
30
+ require_relative 'token/character_type'
31
+ require_relative 'token/conditional'
32
+ require_relative 'token/escape'
33
+ require_relative 'token/group'
34
+ require_relative 'token/keep'
35
+ require_relative 'token/meta'
36
+ require_relative 'token/quantifier'
37
+ require_relative 'token/unicode_property'
36
38
 
37
39
 
38
40
  # After loading all the tokens the map is full. Extract all tokens and types
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Regexp::Syntax
2
4
  VERSION_FORMAT = '\Aruby/\d+\.\d+(\.\d+)?\z'
3
- VERSION_REGEXP = /#{VERSION_FORMAT}/
4
- VERSION_CONST_REGEXP = /\AV\d+_\d+(?:_\d+)?\z/
5
+ VERSION_REGEXP = /#{VERSION_FORMAT}/.freeze
6
+ VERSION_CONST_REGEXP = /\AV\d+_\d+(?:_\d+)?\z/.freeze
5
7
 
6
8
  class InvalidVersionNameError < Regexp::Syntax::SyntaxError
7
9
  def initialize(name)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V1_8_6 < Regexp::Syntax::Base
2
4
  implements :anchor, Anchor::All
3
5
  implements :assertion, Assertion::Lookahead
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V1_9_1 < Regexp::Syntax::V1_8_6
2
4
  implements :assertion, Assertion::Lookbehind
3
5
  implements :backref, Backreference::V1_9_1 + SubexpressionCall::All
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V1_9_3 < Regexp::Syntax::V1_9_1
2
4
  implements :property, UnicodeProperty::V1_9_3
3
5
  implements :nonproperty, UnicodeProperty::V1_9_3
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_0_0 < Regexp::Syntax::V1_9_3
2
4
  implements :keep, Keep::All
3
5
  implements :conditional, Conditional::All
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_2_0 < Regexp::Syntax::V2_0_0
2
4
  implements :property, UnicodeProperty::V2_2_0
3
5
  implements :nonproperty, UnicodeProperty::V2_2_0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_3_0 < Regexp::Syntax::V2_2_0
2
4
  implements :property, UnicodeProperty::V2_3_0
3
5
  implements :nonproperty, UnicodeProperty::V2_3_0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_4_0 < Regexp::Syntax::V2_3_0
2
4
  implements :property, UnicodeProperty::V2_4_0
3
5
  implements :nonproperty, UnicodeProperty::V2_4_0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_4_1 < Regexp::Syntax::V2_4_0
2
4
  implements :group, Group::V2_4_1
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_5_0 < Regexp::Syntax::V2_4_1
2
4
  implements :property, UnicodeProperty::V2_5_0
3
5
  implements :nonproperty, UnicodeProperty::V2_5_0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_6_0 < Regexp::Syntax::V2_5_0
2
4
  implements :property, UnicodeProperty::V2_6_0
3
5
  implements :nonproperty, UnicodeProperty::V2_6_0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_6_2 < Regexp::Syntax::V2_6_0
2
4
  implements :property, UnicodeProperty::V2_6_2
3
5
  implements :nonproperty, UnicodeProperty::V2_6_2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V2_6_3 < Regexp::Syntax::V2_6_2
2
4
  implements :property, UnicodeProperty::V2_6_3
3
5
  implements :nonproperty, UnicodeProperty::V2_6_3
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V3_1_0 < Regexp::Syntax::V2_6_3
2
4
  implements :property, UnicodeProperty::V3_1_0
3
5
  implements :nonproperty, UnicodeProperty::V3_1_0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp::Syntax::V3_2_0 < Regexp::Syntax::V3_1_0
2
4
  implements :property, UnicodeProperty::V3_2_0
3
5
  implements :nonproperty, UnicodeProperty::V3_2_0
@@ -0,0 +1,4 @@
1
+ class Regexp::Syntax::V3_5_0 < Regexp::Syntax::V3_2_0
2
+ implements :property, UnicodeProperty::V3_5_0
3
+ implements :nonproperty, UnicodeProperty::V3_5_0
4
+ end
@@ -0,0 +1,4 @@
1
+ class Regexp::Syntax::V4_0_0 < Regexp::Syntax::V3_5_0
2
+ implements :property, UnicodeProperty::V4_0_0
3
+ implements :nonproperty, UnicodeProperty::V4_0_0
4
+ end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Ruby 1.x is no longer a supported runtime,
2
4
  # but its regex features are still recognized.
3
5
  #
4
6
  # Aliases for the latest patch version are provided as 'ruby/n.n',
5
7
  # e.g. 'ruby/1.9' refers to Ruby v1.9.3.
6
- Dir[File.expand_path('../versions/*.rb', __FILE__)].sort.each { |f| require f }
8
+ Dir[File.expand_path('../versions/*.rb', __FILE__)].sort.each { |f| require_relative f }
7
9
 
8
10
  Regexp::Syntax::CURRENT = Regexp::Syntax.for("ruby/#{RUBY_VERSION}")
@@ -1,4 +1,6 @@
1
- require 'regexp_parser/error'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'error'
2
4
 
3
5
  module Regexp::Syntax
4
6
  class SyntaxError < Regexp::Parser::Error; end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Regexp
2
4
  TOKEN_KEYS = %i[
3
5
  type