mutant 0.11.4 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70a7ce19bef24f9e278efb7beee74d9ae0eed625f0e4e4a712d9330ac1907339
4
- data.tar.gz: 814ca08aed382018685010ca642903ea1e4da3226ae4c7c0fb0fae920818be49
3
+ metadata.gz: 528f60da9e74733ccadd735e902e4cbb0110c9bda457eb53e9338196ef668f0d
4
+ data.tar.gz: 440f31b09c0645f17aa9a97e1b0ee3849afa21aa1f294c230fbc1b8b3ee38e65
5
5
  SHA512:
6
- metadata.gz: 3461d1141fdb8ec16d4262aaf9542ec9db4fc00bc31adf97024803ebd71133de3738c55dd08000f080ae59c8a29a6877eb9758001ea42ff54637a7b09d91e1ac
7
- data.tar.gz: e03447c1d1d192fa98641fbee718ef3e6440b69a43d88023741635e348df94fe336cd92e716a1d8a9e638fba230530377a98ea413890f97b6654c0e45e88960e
6
+ metadata.gz: bb351a02f90e45871181af56c4e2288373c39aea7f158d10e19562f10a4d5447d2142a1dff49934fef08ec8e59754959aec560e1ebfa970bfa2ed15686f14982
7
+ data.tar.gz: e060943a2504bad9a542d3eb6b927e6ca7cf86a79244d1179386f7074c78e4fbfb1a97890d371d79a7298138610b84c1ec75e04a0cf9cbeb146a176b8657c6bd
@@ -36,13 +36,52 @@ module Mutant
36
36
  class ASTToExpression < Transformer::ASTToExpression
37
37
  include LookupTable
38
38
 
39
+ # rubocop:disable Metrics/BlockLength
40
+ properties = ::Regexp::Syntax
41
+ .version_class("ruby/#{RUBY_VERSION}")
42
+ .features.fetch(:property)
43
+ .flat_map do |property|
44
+ property_specifier = "\\p{#{property}}"
45
+ non_property_specifier = "\\P{#{property}}"
46
+
47
+ begin
48
+ property_regex = /#{property_specifier}/
49
+ non_property_regex = /#{non_property_specifier}/
50
+ # This is probably a regexp_parser bug, ignoring registration of that property
51
+ # See: https://github.com/ammar/regexp_parser/issues/84
52
+ rescue RegexpError
53
+ next
54
+ end
55
+
56
+ [
57
+ [
58
+ :"regexp_#{property}_property",
59
+ [
60
+ :property,
61
+ property.to_sym,
62
+ property_specifier
63
+ ],
64
+ ::Regexp::Parser.parse(property_regex).expressions.first.class
65
+ ],
66
+ [
67
+ :"regexp_#{property}_nonproperty",
68
+ [
69
+ :nonproperty,
70
+ property.to_sym,
71
+ non_property_specifier
72
+ ],
73
+ ::Regexp::Parser.parse(non_property_regex).expressions.first.class
74
+ ]
75
+ ]
76
+ end.compact
77
+ # rubocop:enable Metrics/BlockLength
78
+
39
79
  # rubocop:disable Layout/LineLength
40
80
  TABLE = Table.create(
81
+ *properties,
41
82
  [:regexp_alnum_posixclass, [:posixclass, :alnum, '[:alnum:]'], ::Regexp::Expression::PosixClass],
42
83
  [:regexp_alpha_posixclass, [:posixclass, :alpha, '[:alpha:]'], ::Regexp::Expression::PosixClass],
43
- [:regexp_alpha_property, [:property, :alpha, '\p{Alpha}'], ::Regexp::Expression::UnicodeProperty::Alpha],
44
84
  [:regexp_alternation_escape, [:escape, :alternation, '\|'], ::Regexp::Expression::EscapeSequence::Literal],
45
- [:regexp_arabic_property, [:property, :arabic, '\p{Arabic}'], ::Regexp::Expression::UnicodeProperty::Script],
46
85
  [:regexp_ascii_posixclass, [:posixclass, :ascii, '[:ascii:]'], ::Regexp::Expression::PosixClass],
47
86
  [:regexp_backspace_escape, [:escape, :backspace, '\b'], ::Regexp::Expression::EscapeSequence::Backspace],
48
87
  [:regexp_bell_escape, [:escape, :bell, '\a'], ::Regexp::Expression::EscapeSequence::Literal],
@@ -65,16 +104,10 @@ module Mutant
65
104
  [:regexp_graph_posixclass, [:posixclass, :graph, '[:graph:]'], ::Regexp::Expression::PosixClass],
66
105
  [:regexp_group_close_escape, [:escape, :group_close, '\)'], ::Regexp::Expression::EscapeSequence::Literal],
67
106
  [:regexp_group_open_escape, [:escape, :group_open, '\('], ::Regexp::Expression::EscapeSequence::Literal],
68
- [:regexp_han_property, [:property, :han, '\p{Han}'], ::Regexp::Expression::UnicodeProperty::Script],
69
- [:regexp_hangul_property, [:property, :hangul, '\p{Hangul}'], ::Regexp::Expression::UnicodeProperty::Script],
70
107
  [:regexp_hex_type, [:type, :hex, '\h'], ::Regexp::Expression::CharacterType::Hex],
71
- [:regexp_hiragana_property, [:property, :hiragana, '\p{Hiragana}'], ::Regexp::Expression::UnicodeProperty::Script],
72
108
  [:regexp_interval_close_escape, [:escape, :interval_close, '\}'], ::Regexp::Expression::EscapeSequence::Literal],
73
109
  [:regexp_interval_open_escape, [:escape, :interval_open, '\{'], ::Regexp::Expression::EscapeSequence::Literal],
74
- [:regexp_katakana_property, [:property, :katakana, '\p{Katakana}'], ::Regexp::Expression::UnicodeProperty::Script],
75
- [:regexp_letter_property, [:property, :letter, '\p{L}'], ::Regexp::Expression::UnicodeProperty::Letter::Any],
76
110
  [:regexp_linebreak_type, [:type, :linebreak, '\R'], ::Regexp::Expression::CharacterType::Linebreak],
77
- [:regexp_latin_property, [:property, :latin, '\p{Latin}'], ::Regexp::Expression::UnicodeProperty::Script],
78
111
  [:regexp_lower_posixclass, [:posixclass, :lower, '[:lower:]'], ::Regexp::Expression::PosixClass],
79
112
  [:regexp_mark_keep, [:keep, :mark, '\K'], ::Regexp::Expression::Keep::Mark],
80
113
  [:regexp_match_start_anchor, [:anchor, :match_start, '\\G'], ::Regexp::Expression::Anchor::MatchStart],
@@ -86,10 +119,8 @@ module Mutant
86
119
  [:regexp_nonword_type, [:type, :nonword, '\W'], ::Regexp::Expression::CharacterType::NonWord],
87
120
  [:regexp_one_or_more_escape, [:escape, :one_or_more, '\+'], ::Regexp::Expression::EscapeSequence::Literal],
88
121
  [:regexp_print_nonposixclass, [:nonposixclass, :print, '[:^print:]'], ::Regexp::Expression::PosixClass],
89
- [:regexp_print_nonproperty, [:nonproperty, :print, '\P{Print}'], ::Regexp::Expression::UnicodeProperty::Print],
90
122
  [:regexp_print_posixclass, [:posixclass, :print, '[:print:]'], ::Regexp::Expression::PosixClass],
91
123
  [:regexp_print_posixclass, [:posixclass, :print, '[:print:]'], ::Regexp::Expression::PosixClass],
92
- [:regexp_print_property, [:property, :print, '\p{Print}'], ::Regexp::Expression::UnicodeProperty::Print],
93
124
  [:regexp_punct_posixclass, [:posixclass, :punct, '[:punct:]'], ::Regexp::Expression::PosixClass],
94
125
  [:regexp_set_close_escape, [:escape, :set_close, '\]'], ::Regexp::Expression::EscapeSequence::Literal],
95
126
  [:regexp_set_open_escape, [:escape, :set_open, '\['], ::Regexp::Expression::EscapeSequence::Literal],
@@ -110,9 +110,9 @@ module Mutant
110
110
  #
111
111
  # @return [Table]
112
112
  def self.create(*rows)
113
- table = rows.map do |ast_type, token, klass|
113
+ table = rows.to_h do |ast_type, token, klass|
114
114
  [ast_type, Mapping.new(::Regexp::Token.new(*token), klass)]
115
- end.to_h
115
+ end
116
116
 
117
117
  new(table)
118
118
  end