mutant 0.10.21 → 0.10.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mutant.rb +32 -13
- data/lib/mutant/ast/find_metaclass_containing.rb +1 -1
- data/lib/mutant/ast/regexp.rb +54 -0
- data/lib/mutant/ast/regexp/transformer.rb +150 -0
- data/lib/mutant/ast/regexp/transformer/direct.rb +121 -0
- data/lib/mutant/ast/regexp/transformer/named_group.rb +50 -0
- data/lib/mutant/ast/regexp/transformer/options_group.rb +68 -0
- data/lib/mutant/ast/regexp/transformer/quantifier.rb +92 -0
- data/lib/mutant/ast/regexp/transformer/recursive.rb +56 -0
- data/lib/mutant/ast/regexp/transformer/root.rb +28 -0
- data/lib/mutant/ast/regexp/transformer/text.rb +58 -0
- data/lib/mutant/ast/types.rb +115 -2
- data/lib/mutant/bootstrap.rb +1 -1
- data/lib/mutant/cli/command.rb +4 -0
- data/lib/mutant/cli/command/environment.rb +9 -3
- data/lib/mutant/cli/command/environment/subject.rb +0 -4
- data/lib/mutant/cli/command/environment/test.rb +36 -0
- data/lib/mutant/cli/command/root.rb +1 -1
- data/lib/mutant/config.rb +9 -55
- data/lib/mutant/config/coverage_criteria.rb +61 -0
- data/lib/mutant/context.rb +1 -1
- data/lib/mutant/env.rb +2 -2
- data/lib/mutant/expression.rb +0 -12
- data/lib/mutant/expression/method.rb +4 -4
- data/lib/mutant/expression/methods.rb +5 -4
- data/lib/mutant/expression/namespace.rb +1 -1
- data/lib/mutant/integration.rb +8 -2
- data/lib/mutant/isolation/fork.rb +4 -11
- data/lib/mutant/loader.rb +1 -1
- data/lib/mutant/matcher.rb +3 -3
- data/lib/mutant/matcher/config.rb +30 -8
- data/lib/mutant/matcher/method.rb +10 -9
- data/lib/mutant/matcher/method/instance.rb +6 -2
- data/lib/mutant/matcher/method/metaclass.rb +1 -1
- data/lib/mutant/matcher/methods.rb +2 -4
- data/lib/mutant/meta/example.rb +1 -1
- data/lib/mutant/meta/example/dsl.rb +6 -1
- data/lib/mutant/meta/example/verification.rb +1 -1
- data/lib/mutant/mutation.rb +1 -1
- data/lib/mutant/mutator.rb +8 -1
- data/lib/mutant/mutator/node/argument.rb +2 -2
- data/lib/mutant/mutator/node/block.rb +5 -1
- data/lib/mutant/mutator/node/dynamic_literal.rb +1 -1
- data/lib/mutant/mutator/node/kwargs.rb +44 -0
- data/lib/mutant/mutator/node/literal/regex.rb +12 -0
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -3
- data/lib/mutant/mutator/node/regexp.rb +20 -0
- data/lib/mutant/mutator/node/regexp/alternation_meta.rb +20 -0
- data/lib/mutant/mutator/node/regexp/beginning_of_line_anchor.rb +20 -0
- data/lib/mutant/mutator/node/regexp/capture_group.rb +25 -0
- data/lib/mutant/mutator/node/regexp/character_type.rb +31 -0
- data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +20 -0
- data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +20 -0
- data/lib/mutant/mutator/node/regexp/named_group.rb +39 -0
- data/lib/mutant/mutator/node/regexp/zero_or_more.rb +34 -0
- data/lib/mutant/mutator/node/regopt.rb +1 -1
- data/lib/mutant/mutator/node/sclass.rb +1 -1
- data/lib/mutant/mutator/node/send.rb +55 -6
- data/lib/mutant/parallel.rb +2 -2
- data/lib/mutant/parallel/driver.rb +1 -1
- data/lib/mutant/parallel/worker.rb +1 -1
- data/lib/mutant/parser.rb +1 -1
- data/lib/mutant/pipe.rb +1 -1
- data/lib/mutant/procto.rb +23 -0
- data/lib/mutant/reporter/cli/printer.rb +10 -4
- data/lib/mutant/reporter/cli/printer/env.rb +3 -3
- data/lib/mutant/reporter/cli/printer/env_progress.rb +2 -2
- data/lib/mutant/selector.rb +1 -1
- data/lib/mutant/subject.rb +2 -4
- data/lib/mutant/subject/method/instance.rb +6 -45
- data/lib/mutant/timer.rb +2 -2
- data/lib/mutant/transform.rb +25 -0
- data/lib/mutant/variable.rb +322 -0
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/world.rb +2 -3
- metadata +39 -151
- data/lib/mutant/warnings.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b03b60df6a63d9fa7a8b64affcaae0a804a753764b636fee625b1edc597e25
|
4
|
+
data.tar.gz: b61c7b228cdffed5d67cd38ffb3cc55b00d2bace308e56f8f48e828987fa76ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50fbc446b2f03edb5015136920a95e3fa9dbbc55b10a530dcea755ed9bf0bb0fea2e99bc3bdf6503cc564fc4d71ea8b1fbcabe97f6959df9ec800e68c81220cb
|
7
|
+
data.tar.gz: fa841fc57b3422780840b66368bbac984b42bd2cef27aee58d07b783b952cbece2fddb0d821ff489279c808db64802c254df84774fcc4a50b887ec068c455b00
|
data/lib/mutant.rb
CHANGED
@@ -1,27 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'abstract_type'
|
4
|
-
require 'adamantium'
|
5
|
-
require 'anima'
|
6
|
-
require 'concord'
|
7
3
|
require 'diff/lcs'
|
8
4
|
require 'diff/lcs/hunk'
|
9
5
|
require 'digest/sha1'
|
10
|
-
require 'equalizer'
|
11
6
|
require 'etc'
|
12
|
-
require 'ice_nine'
|
13
|
-
require 'mprelude'
|
14
7
|
require 'json'
|
15
8
|
require 'open3'
|
16
9
|
require 'optparse'
|
17
10
|
require 'parser'
|
18
11
|
require 'parser/current'
|
19
12
|
require 'pathname'
|
13
|
+
require 'regexp_parser'
|
20
14
|
require 'set'
|
21
15
|
require 'singleton'
|
22
16
|
require 'stringio'
|
23
17
|
require 'unparser'
|
24
|
-
require 'variable'
|
25
18
|
require 'yaml'
|
26
19
|
|
27
20
|
# This setting is done to make errors within the parallel
|
@@ -32,7 +25,12 @@ Thread.abort_on_exception = true
|
|
32
25
|
#
|
33
26
|
# @api private
|
34
27
|
module Mutant
|
35
|
-
|
28
|
+
AbstractType = Unparser::AbstractType
|
29
|
+
Adamantium = Unparser::Adamantium
|
30
|
+
Anima = Unparser::Anima
|
31
|
+
Concord = Unparser::Concord
|
32
|
+
Either = Unparser::Either
|
33
|
+
Equalizer = Unparser::Equalizer
|
36
34
|
|
37
35
|
EMPTY_STRING = ''
|
38
36
|
EMPTY_ARRAY = [].freeze
|
@@ -40,6 +38,9 @@ module Mutant
|
|
40
38
|
SCOPE_OPERATOR = '::'
|
41
39
|
end # Mutant
|
42
40
|
|
41
|
+
require 'mutant/procto'
|
42
|
+
require 'mutant/transform'
|
43
|
+
require 'mutant/variable'
|
43
44
|
require 'mutant/bootstrap'
|
44
45
|
require 'mutant/version'
|
45
46
|
require 'mutant/env'
|
@@ -53,6 +54,15 @@ require 'mutant/ast/nodes'
|
|
53
54
|
require 'mutant/ast/named_children'
|
54
55
|
require 'mutant/ast/node_predicates'
|
55
56
|
require 'mutant/ast/find_metaclass_containing'
|
57
|
+
require 'mutant/ast/regexp'
|
58
|
+
require 'mutant/ast/regexp/transformer'
|
59
|
+
require 'mutant/ast/regexp/transformer/direct'
|
60
|
+
require 'mutant/ast/regexp/transformer/named_group'
|
61
|
+
require 'mutant/ast/regexp/transformer/options_group'
|
62
|
+
require 'mutant/ast/regexp/transformer/quantifier'
|
63
|
+
require 'mutant/ast/regexp/transformer/recursive'
|
64
|
+
require 'mutant/ast/regexp/transformer/root'
|
65
|
+
require 'mutant/ast/regexp/transformer/text'
|
56
66
|
require 'mutant/ast/meta'
|
57
67
|
require 'mutant/ast/meta/send'
|
58
68
|
require 'mutant/ast/meta/const'
|
@@ -75,6 +85,15 @@ require 'mutant/mutator/util/array'
|
|
75
85
|
require 'mutant/mutator/util/symbol'
|
76
86
|
require 'mutant/mutator/node'
|
77
87
|
require 'mutant/mutator/node/generic'
|
88
|
+
require 'mutant/mutator/node/regexp'
|
89
|
+
require 'mutant/mutator/node/regexp/alternation_meta'
|
90
|
+
require 'mutant/mutator/node/regexp/beginning_of_line_anchor'
|
91
|
+
require 'mutant/mutator/node/regexp/capture_group'
|
92
|
+
require 'mutant/mutator/node/regexp/named_group'
|
93
|
+
require 'mutant/mutator/node/regexp/character_type'
|
94
|
+
require 'mutant/mutator/node/regexp/end_of_line_anchor'
|
95
|
+
require 'mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor'
|
96
|
+
require 'mutant/mutator/node/regexp/zero_or_more'
|
78
97
|
require 'mutant/mutator/node/literal'
|
79
98
|
require 'mutant/mutator/node/literal/boolean'
|
80
99
|
require 'mutant/mutator/node/literal/range'
|
@@ -130,6 +149,7 @@ require 'mutant/mutator/node/rescue'
|
|
130
149
|
require 'mutant/mutator/node/match_current_line'
|
131
150
|
require 'mutant/mutator/node/index'
|
132
151
|
require 'mutant/mutator/node/procarg_zero'
|
152
|
+
require 'mutant/mutator/node/kwargs'
|
133
153
|
require 'mutant/loader'
|
134
154
|
require 'mutant/context'
|
135
155
|
require 'mutant/scope'
|
@@ -158,7 +178,6 @@ require 'mutant/expression/methods'
|
|
158
178
|
require 'mutant/expression/namespace'
|
159
179
|
require 'mutant/test'
|
160
180
|
require 'mutant/timer'
|
161
|
-
require 'mutant/transform'
|
162
181
|
require 'mutant/integration'
|
163
182
|
require 'mutant/integration/null'
|
164
183
|
require 'mutant/selector'
|
@@ -166,6 +185,7 @@ require 'mutant/selector/expression'
|
|
166
185
|
require 'mutant/selector/null'
|
167
186
|
require 'mutant/world'
|
168
187
|
require 'mutant/config'
|
188
|
+
require 'mutant/config/coverage_criteria'
|
169
189
|
require 'mutant/cli'
|
170
190
|
require 'mutant/cli/command'
|
171
191
|
require 'mutant/cli/command/subscription'
|
@@ -173,6 +193,7 @@ require 'mutant/cli/command/environment'
|
|
173
193
|
require 'mutant/cli/command/environment/run'
|
174
194
|
require 'mutant/cli/command/environment/show'
|
175
195
|
require 'mutant/cli/command/environment/subject'
|
196
|
+
require 'mutant/cli/command/environment/test'
|
176
197
|
require 'mutant/cli/command/root'
|
177
198
|
require 'mutant/runner'
|
178
199
|
require 'mutant/runner/sink'
|
@@ -195,7 +216,6 @@ require 'mutant/reporter/cli/format'
|
|
195
216
|
require 'mutant/repository'
|
196
217
|
require 'mutant/repository/diff'
|
197
218
|
require 'mutant/repository/diff/ranges'
|
198
|
-
require 'mutant/warnings'
|
199
219
|
require 'mutant/zombifier'
|
200
220
|
require 'mutant/range'
|
201
221
|
require 'mutant/license'
|
@@ -221,8 +241,7 @@ module Mutant
|
|
221
241
|
stderr: $stderr,
|
222
242
|
stdout: $stdout,
|
223
243
|
thread: Thread,
|
224
|
-
timer: Timer.new(Process)
|
225
|
-
warnings: Warnings.new(Warning)
|
244
|
+
timer: Timer.new(Process)
|
226
245
|
)
|
227
246
|
|
228
247
|
# Reopen class to initialize constant to avoid dep circle
|
@@ -10,7 +10,7 @@ module Mutant
|
|
10
10
|
# Descending into 'begin' nodes is supported because these are generated for
|
11
11
|
# the one-line syntax class << self; def foo; end
|
12
12
|
class FindMetaclassContaining
|
13
|
-
include NodePredicates, Concord.new(:root, :target), Procto
|
13
|
+
include NodePredicates, Concord.new(:root, :target), Procto
|
14
14
|
|
15
15
|
SCLASS_BODY_INDEX = 1
|
16
16
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
module AST
|
5
|
+
# Regexp source mapper
|
6
|
+
module Regexp
|
7
|
+
# Parse regex string into expression
|
8
|
+
#
|
9
|
+
# @param regexp [String]
|
10
|
+
#
|
11
|
+
# @return [Regexp::Expression, nil]
|
12
|
+
def self.parse(regexp)
|
13
|
+
::Regexp::Parser.parse(regexp)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Convert expression into ast node
|
17
|
+
#
|
18
|
+
# @param expression [Regexp::Expression]
|
19
|
+
#
|
20
|
+
# @return [Parser::AST::Node]
|
21
|
+
def self.to_ast(expression)
|
22
|
+
ast_type = :"regexp_#{expression.token}_#{expression.type}"
|
23
|
+
|
24
|
+
Transformer.lookup(ast_type).to_ast(expression)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Convert node into expression
|
28
|
+
#
|
29
|
+
# @param node [Parser::AST::Node]
|
30
|
+
#
|
31
|
+
# @return [Regexp::Expression]
|
32
|
+
def self.to_expression(node)
|
33
|
+
Transformer.lookup(node.type).to_expression(node)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Convert's a `parser` `regexp` node into more fine-grained AST nodes.
|
37
|
+
#
|
38
|
+
# @param node [Parser::AST::Node]
|
39
|
+
#
|
40
|
+
# @return [Parser::AST::Node]
|
41
|
+
def self.expand_regexp_ast(node)
|
42
|
+
*body, _opts = node.children
|
43
|
+
|
44
|
+
# NOTE: We only mutate parts of regexp body if the body is composed of
|
45
|
+
# only strings. Regular expressions with interpolation are skipped
|
46
|
+
return unless body.all? { |child| child.type.equal?(:str) }
|
47
|
+
|
48
|
+
body_expression = parse(body.map(&:children).join)
|
49
|
+
|
50
|
+
to_ast(body_expression)
|
51
|
+
end
|
52
|
+
end # Regexp
|
53
|
+
end # AST
|
54
|
+
end # Mutant
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
module AST
|
5
|
+
module Regexp
|
6
|
+
# Regexp bijective mapper
|
7
|
+
#
|
8
|
+
# Transforms parsed regular expression representation from
|
9
|
+
# `Regexp::Expression` instances (provided by `regexp_parser`) into
|
10
|
+
# equivalent representations using `Parser::AST::Node`
|
11
|
+
class Transformer
|
12
|
+
include AbstractType
|
13
|
+
|
14
|
+
REGISTRY = Registry.new
|
15
|
+
|
16
|
+
# Lookup transformer class for regular expression node type
|
17
|
+
#
|
18
|
+
# @param type [Symbol]
|
19
|
+
#
|
20
|
+
# @return [Class<Transformer>]
|
21
|
+
def self.lookup(type)
|
22
|
+
REGISTRY.lookup(type)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.register(type)
|
26
|
+
REGISTRY.register(type, self)
|
27
|
+
end
|
28
|
+
private_class_method :register
|
29
|
+
|
30
|
+
# Transform expression
|
31
|
+
#
|
32
|
+
# @param expression [Regexp::Expression]
|
33
|
+
#
|
34
|
+
# @return [Parser::AST::Node]
|
35
|
+
def self.to_ast(expression)
|
36
|
+
self::ExpressionToAST.call(expression)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Transform node
|
40
|
+
#
|
41
|
+
# @param node [Parser::AST::Node]
|
42
|
+
#
|
43
|
+
# @return [Regexp::Expression]
|
44
|
+
def self.to_expression(node)
|
45
|
+
self::ASTToExpression.call(node)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Abstract expression transformer
|
49
|
+
class ExpressionToAST
|
50
|
+
PREFIX = :regexp
|
51
|
+
|
52
|
+
include Concord.new(:expression), Procto, AST::Sexp, AbstractType, Adamantium
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def ast(*children)
|
57
|
+
s(type, *children)
|
58
|
+
end
|
59
|
+
|
60
|
+
def quantify(node)
|
61
|
+
return node unless expression.quantified?
|
62
|
+
|
63
|
+
Quantifier.to_ast(expression.quantifier).append(node)
|
64
|
+
end
|
65
|
+
|
66
|
+
def children
|
67
|
+
expression.map(&Regexp.public_method(:to_ast))
|
68
|
+
end
|
69
|
+
|
70
|
+
def type
|
71
|
+
:"#{PREFIX}_#{expression.token}_#{expression.type}"
|
72
|
+
end
|
73
|
+
end # ExpressionToAST
|
74
|
+
|
75
|
+
# Abstract node transformer
|
76
|
+
class ASTToExpression
|
77
|
+
include Concord.new(:node), Procto, AbstractType, Adamantium
|
78
|
+
|
79
|
+
# Call generic transform method and freeze result
|
80
|
+
#
|
81
|
+
# @return [Regexp::Expression]
|
82
|
+
def call
|
83
|
+
transform.freeze
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
abstract_method :transform
|
89
|
+
|
90
|
+
def subexpressions
|
91
|
+
node.children.map(&Regexp.public_method(:to_expression))
|
92
|
+
end
|
93
|
+
end # ASTToExpression
|
94
|
+
|
95
|
+
# Mixin for node transformers
|
96
|
+
#
|
97
|
+
# Helps construct a mapping from Parser::AST::Node domain to
|
98
|
+
# Regexp::Expression domain
|
99
|
+
module LookupTable
|
100
|
+
Mapping = Class.new.include(Concord::Public.new(:token, :regexp_class))
|
101
|
+
|
102
|
+
# Table mapping ast types to object information for regexp domain
|
103
|
+
class Table
|
104
|
+
|
105
|
+
# Coerce array of mapping information into structured table
|
106
|
+
#
|
107
|
+
# @param [Array(Symbol, Array, Class<Regexp::Expression>)]
|
108
|
+
#
|
109
|
+
# @return [Table]
|
110
|
+
def self.create(*rows)
|
111
|
+
table = rows.map do |ast_type, token, klass|
|
112
|
+
[ast_type, Mapping.new(::Regexp::Token.new(*token), klass)]
|
113
|
+
end.to_h
|
114
|
+
|
115
|
+
new(table)
|
116
|
+
end
|
117
|
+
|
118
|
+
include Concord.new(:table), Adamantium
|
119
|
+
|
120
|
+
# Types defined by the table
|
121
|
+
#
|
122
|
+
# @return [Array<Symbol>]
|
123
|
+
def types
|
124
|
+
table.keys
|
125
|
+
end
|
126
|
+
|
127
|
+
# Lookup mapping information given an ast node type
|
128
|
+
#
|
129
|
+
# @param type [Symbol]
|
130
|
+
#
|
131
|
+
# @return [Mapping]
|
132
|
+
def lookup(type)
|
133
|
+
table.fetch(type)
|
134
|
+
end
|
135
|
+
end # Table
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def expression_token
|
140
|
+
self.class::TABLE.lookup(node.type).token
|
141
|
+
end
|
142
|
+
|
143
|
+
def expression_class
|
144
|
+
self.class::TABLE.lookup(node.type).regexp_class
|
145
|
+
end
|
146
|
+
end # LookupTable
|
147
|
+
end # Transformer
|
148
|
+
end # Regexp
|
149
|
+
end # AST
|
150
|
+
end # Mutant
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
module AST
|
5
|
+
module Regexp
|
6
|
+
class Transformer
|
7
|
+
# Transformer for nodes which map directly to other domain
|
8
|
+
#
|
9
|
+
# A node maps "directly" to another domain if the node never
|
10
|
+
# has children or text which needs to be preserved for a mapping
|
11
|
+
#
|
12
|
+
# @example direct mapping
|
13
|
+
#
|
14
|
+
# input = /\d/
|
15
|
+
# expression = Regexp::Parser.parse(input).first
|
16
|
+
# node = Transformer::Direct.to_ast(expression)
|
17
|
+
#
|
18
|
+
# # the digit type always has the same text and no children
|
19
|
+
# expression.text # => "\\d"
|
20
|
+
# expression.terminal? # => true
|
21
|
+
#
|
22
|
+
# # therefore the `Parser::AST::Node` is always the same
|
23
|
+
# node # => s(:regexp_digit_type)
|
24
|
+
class Direct < self
|
25
|
+
# Mapper from `Regexp::Expression` to `Parser::AST::Node`
|
26
|
+
class ExpressionToAST < Transformer::ExpressionToAST
|
27
|
+
# Transform expression into node
|
28
|
+
#
|
29
|
+
# @return [Parser::AST::Node]
|
30
|
+
def call
|
31
|
+
quantify(ast)
|
32
|
+
end
|
33
|
+
end # ExpressionToAST
|
34
|
+
|
35
|
+
# Mapper from `Parser::AST::Node` to `Regexp::Expression`
|
36
|
+
class ASTToExpression < Transformer::ASTToExpression
|
37
|
+
include LookupTable
|
38
|
+
|
39
|
+
# rubocop:disable Layout/LineLength
|
40
|
+
TABLE = Table.create(
|
41
|
+
[:regexp_alnum_posixclass, [:posixclass, :alnum, '[:alnum:]'], ::Regexp::Expression::PosixClass],
|
42
|
+
[:regexp_alpha_posixclass, [:posixclass, :alpha, '[:alpha:]'], ::Regexp::Expression::PosixClass],
|
43
|
+
[:regexp_alpha_property, [:property, :alpha, '\p{Alpha}'], ::Regexp::Expression::UnicodeProperty::Alpha],
|
44
|
+
[:regexp_alternation_escape, [:escape, :alternation, '\|'], ::Regexp::Expression::EscapeSequence::Literal],
|
45
|
+
[:regexp_arabic_property, [:property, :arabic, '\p{Arabic}'], ::Regexp::Expression::UnicodeProperty::Script],
|
46
|
+
[:regexp_ascii_posixclass, [:posixclass, :ascii, '[:ascii:]'], ::Regexp::Expression::PosixClass],
|
47
|
+
[:regexp_backspace_escape, [:escape, :backspace, '\b'], ::Regexp::Expression::EscapeSequence::Backspace],
|
48
|
+
[:regexp_bell_escape, [:escape, :bell, '\a'], ::Regexp::Expression::EscapeSequence::Literal],
|
49
|
+
[:regexp_blank_posixclass, [:posixclass, :blank, '[:blank:]'], ::Regexp::Expression::PosixClass],
|
50
|
+
[:regexp_bol_anchor, [:anchor, :bol, '^'], ::Regexp::Expression::Anchor::BeginningOfLine],
|
51
|
+
[:regexp_bol_escape, [:escape, :bol, '\^'], ::Regexp::Expression::EscapeSequence::Literal],
|
52
|
+
[:regexp_bos_anchor, [:anchor, :bos, '\\A'], ::Regexp::Expression::Anchor::BeginningOfString],
|
53
|
+
[:regexp_carriage_escape, [:escape, :carriage, '\r'], ::Regexp::Expression::EscapeSequence::Literal],
|
54
|
+
[:regexp_cntrl_posixclass, [:posixclass, :cntrl, '[:cntrl:]'], ::Regexp::Expression::PosixClass],
|
55
|
+
[:regexp_digit_posixclass, [:posixclass, :digit, '[:digit:]'], ::Regexp::Expression::PosixClass],
|
56
|
+
[:regexp_digit_type, [:type, :digit, '\d'], ::Regexp::Expression::CharacterType::Digit],
|
57
|
+
[:regexp_dot_escape, [:escape, :dot, '\.'], ::Regexp::Expression::EscapeSequence::Literal],
|
58
|
+
[:regexp_dot_meta, [:meta, :dot, '.'], ::Regexp::Expression::CharacterType::Any],
|
59
|
+
[:regexp_eol_anchor, [:anchor, :eol, '$'], ::Regexp::Expression::Anchor::EndOfLine],
|
60
|
+
[:regexp_eol_escape, [:escape, :eol, '\$'], ::Regexp::Expression::EscapeSequence::Literal],
|
61
|
+
[:regexp_eos_anchor, [:anchor, :eos, '\\z'], ::Regexp::Expression::Anchor::EndOfString],
|
62
|
+
[:regexp_eos_ob_eol_anchor, [:anchor, :eos_ob_eol, '\\Z'], ::Regexp::Expression::Anchor::EndOfStringOrBeforeEndOfLine],
|
63
|
+
[:regexp_escape_escape, [:escape, :escape, '\e'], ::Regexp::Expression::EscapeSequence::AsciiEscape],
|
64
|
+
[:regexp_form_feed_escape, [:escape, :form_feed, '\f'], ::Regexp::Expression::EscapeSequence::FormFeed],
|
65
|
+
[:regexp_graph_posixclass, [:posixclass, :graph, '[:graph:]'], ::Regexp::Expression::PosixClass],
|
66
|
+
[:regexp_group_close_escape, [:escape, :group_close, '\)'], ::Regexp::Expression::EscapeSequence::Literal],
|
67
|
+
[: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
|
+
[:regexp_hex_type, [:type, :hex, '\h'], ::Regexp::Expression::CharacterType::Hex],
|
71
|
+
[:regexp_hiragana_property, [:property, :hiragana, '\p{Hiragana}'], ::Regexp::Expression::UnicodeProperty::Script],
|
72
|
+
[:regexp_interval_close_escape, [:escape, :interval_close, '\}'], ::Regexp::Expression::EscapeSequence::Literal],
|
73
|
+
[: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
|
+
[:regexp_linebreak_type, [:type, :linebreak, '\R'], ::Regexp::Expression::CharacterType::Linebreak],
|
77
|
+
[:regexp_lower_posixclass, [:posixclass, :lower, '[:lower:]'], ::Regexp::Expression::PosixClass],
|
78
|
+
[:regexp_mark_keep, [:keep, :mark, '\K'], ::Regexp::Expression::Keep::Mark],
|
79
|
+
[:regexp_match_start_anchor, [:anchor, :match_start, '\\G'], ::Regexp::Expression::Anchor::MatchStart],
|
80
|
+
[:regexp_newline_escape, [:escape, :newline, '\n'], ::Regexp::Expression::EscapeSequence::Literal],
|
81
|
+
[:regexp_nondigit_type, [:type, :nondigit, '\D'], ::Regexp::Expression::CharacterType::NonDigit],
|
82
|
+
[:regexp_nonhex_type, [:type, :nonhex, '\H'], ::Regexp::Expression::CharacterType::NonHex],
|
83
|
+
[:regexp_nonspace_type, [:type, :nonspace, '\S'], ::Regexp::Expression::CharacterType::NonSpace],
|
84
|
+
[:regexp_nonword_boundary_anchor, [:anchor, :nonword_boundary, '\\B'], ::Regexp::Expression::Anchor::NonWordBoundary],
|
85
|
+
[:regexp_nonword_type, [:type, :nonword, '\W'], ::Regexp::Expression::CharacterType::NonWord],
|
86
|
+
[:regexp_one_or_more_escape, [:escape, :one_or_more, '\+'], ::Regexp::Expression::EscapeSequence::Literal],
|
87
|
+
[:regexp_print_nonposixclass, [:nonposixclass, :print, '[:^print:]'], ::Regexp::Expression::PosixClass],
|
88
|
+
[:regexp_print_nonproperty, [:nonproperty, :print, '\P{Print}'], ::Regexp::Expression::UnicodeProperty::Print],
|
89
|
+
[:regexp_print_posixclass, [:posixclass, :print, '[:print:]'], ::Regexp::Expression::PosixClass],
|
90
|
+
[:regexp_print_posixclass, [:posixclass, :print, '[:print:]'], ::Regexp::Expression::PosixClass],
|
91
|
+
[:regexp_print_property, [:property, :print, '\p{Print}'], ::Regexp::Expression::UnicodeProperty::Print],
|
92
|
+
[:regexp_punct_posixclass, [:posixclass, :punct, '[:punct:]'], ::Regexp::Expression::PosixClass],
|
93
|
+
[:regexp_set_close_escape, [:escape, :set_close, '\]'], ::Regexp::Expression::EscapeSequence::Literal],
|
94
|
+
[:regexp_set_open_escape, [:escape, :set_open, '\['], ::Regexp::Expression::EscapeSequence::Literal],
|
95
|
+
[:regexp_space_posixclass, [:posixclass, :space, '[:space:]'], ::Regexp::Expression::PosixClass],
|
96
|
+
[:regexp_space_type, [:type, :space, '\s'], ::Regexp::Expression::CharacterType::Space],
|
97
|
+
[:regexp_upper_posixclass, [:posixclass, :upper, '[:upper:]'], ::Regexp::Expression::PosixClass],
|
98
|
+
[:regexp_vertical_tab_escape, [:escape, :vertical_tab, '\v'], ::Regexp::Expression::EscapeSequence::VerticalTab],
|
99
|
+
[:regexp_word_boundary_anchor, [:anchor, :word_boundary, '\b'], ::Regexp::Expression::Anchor::WordBoundary],
|
100
|
+
[:regexp_word_posixclass, [:posixclass, :word, '[:word:]'], ::Regexp::Expression::PosixClass],
|
101
|
+
[:regexp_word_type, [:type, :word, '\w'], ::Regexp::Expression::CharacterType::Word],
|
102
|
+
[:regexp_xdigit_posixclass, [:posixclass, :xdigit, '[:xdigit:]'], ::Regexp::Expression::PosixClass],
|
103
|
+
[:regexp_xgrapheme_type, [:type, :xgrapheme, '\X'], ::Regexp::Expression::CharacterType::ExtendedGrapheme],
|
104
|
+
[:regexp_zero_or_more_escape, [:escape, :zero_or_more, '\*'], ::Regexp::Expression::EscapeSequence::Literal],
|
105
|
+
[:regexp_zero_or_one_escape, [:escape, :zero_or_one, '\?'], ::Regexp::Expression::EscapeSequence::Literal]
|
106
|
+
)
|
107
|
+
# rubocop:enable Layout/LineLength
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def transform
|
112
|
+
expression_class.new(expression_token)
|
113
|
+
end
|
114
|
+
end # ASTToExpression
|
115
|
+
|
116
|
+
ASTToExpression::TABLE.types.each(&method(:register))
|
117
|
+
end # Direct
|
118
|
+
end # Transformer
|
119
|
+
end # Regexp
|
120
|
+
end # AST
|
121
|
+
end # Mutant
|