line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FLAT::Regex::WithExtraOps; |
2
|
6
|
|
|
6
|
|
40
|
use parent 'FLAT::Regex'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
32
|
|
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
340
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
104
|
|
5
|
6
|
|
|
6
|
|
28
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1301
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#### Precedence |
8
|
|
|
|
|
|
|
# 30 ::star |
9
|
|
|
|
|
|
|
# 20 ::concat |
10
|
|
|
|
|
|
|
# 15 ::negate <---<< WithExtraOps |
11
|
|
|
|
|
|
|
# 12 ::shuffle <---<< WithExtraOps |
12
|
|
|
|
|
|
|
# 10 ::alt |
13
|
|
|
|
|
|
|
# 0 ::atomic |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $PARSER = FLAT::Regex::Parser->new(qw[ alt concat star negate shuffle ]); |
16
|
3036
|
|
|
3036
|
|
24546
|
sub _parser {$PARSER} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub negate { |
19
|
0
|
|
|
0
|
0
|
0
|
my $self = $_[0]; |
20
|
0
|
|
|
|
|
0
|
my $op = FLAT::Regex::Op::negate->new(map {$_->as_regex->op} @_); |
|
0
|
|
|
|
|
0
|
|
21
|
0
|
|
|
|
|
0
|
$self->_from_op($op); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
############################### |
25
|
|
|
|
|
|
|
sub shuffle { |
26
|
0
|
|
|
0
|
1
|
0
|
my $self = $_[0]; |
27
|
0
|
|
|
|
|
0
|
my $op = FLAT::Regex::Op::shuffle->new(map {$_->as_regex->op} @_); |
|
0
|
|
|
|
|
0
|
|
28
|
0
|
|
|
|
|
0
|
$self->_from_op($op); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package FLAT::Regex::Op::negate; |
32
|
6
|
|
|
6
|
|
42
|
use parent "FLAT::Regex::Op"; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
25
|
|
33
|
6
|
|
|
6
|
|
380
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1780
|
|
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
6
|
|
23
|
sub parse_spec {"'~' %s";} |
36
|
6
|
|
|
6
|
|
16
|
sub precedence {15} # between concat and alternation |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub as_string { |
39
|
0
|
|
|
0
|
|
0
|
my ($self, $prec) = @_; |
40
|
0
|
|
|
|
|
0
|
my $result = "~" . $self->members->as_string($self->precedence); |
41
|
0
|
0
|
|
|
|
0
|
return $prec > $self->precedence ? "($result)" : $result; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub from_parse { |
45
|
0
|
|
|
0
|
|
0
|
my ($pkg, @item) = @_; |
46
|
0
|
|
|
|
|
0
|
$pkg->new($item[2]); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## note: "reverse" conflicts with perl builtin |
50
|
|
|
|
|
|
|
sub reverse { |
51
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
52
|
0
|
|
|
|
|
0
|
my $op = $self->members->reverse; |
53
|
0
|
|
|
|
|
0
|
__PACKAGE__->new($op); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub is_empty { |
57
|
0
|
|
|
0
|
|
0
|
croak "Not implemented for negated regexes"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub has_nonempty_string { |
61
|
0
|
|
|
0
|
|
0
|
croak "Not implemented for negated regexes"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub is_finite { |
65
|
0
|
|
|
0
|
|
0
|
croak "Not implemented for negated regexes"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################### |
69
|
|
|
|
|
|
|
package FLAT::Regex::Op::shuffle; |
70
|
6
|
|
|
6
|
|
44
|
use parent 'FLAT::Regex::Op'; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
27
|
|
71
|
6
|
|
|
6
|
|
356
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
2183
|
|
72
|
|
|
|
|
|
|
|
73
|
6
|
|
|
6
|
|
47
|
sub parse_spec {"%s(2.. /[&]/)"} |
74
|
6
|
|
|
6
|
|
16
|
sub precedence {12} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub as_string { |
77
|
0
|
|
|
0
|
|
0
|
my ($self, $prec) = @_; |
78
|
0
|
|
|
|
|
0
|
my $result = join "&", map {$_->as_string($self->precedence)} $self->members; |
|
0
|
|
|
|
|
0
|
|
79
|
0
|
0
|
|
|
|
0
|
return $prec > $self->precedence ? "($result)" : $result; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub as_perl_regex { |
83
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
84
|
0
|
|
|
|
|
0
|
croak "Not implemented for shuffled regexes"; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub from_parse { |
88
|
1347
|
|
|
1347
|
|
333585
|
my ($pkg, @item) = @_; |
89
|
1347
|
|
|
|
|
3627
|
$pkg->new(@{$item[1]}); |
|
1347
|
|
|
|
|
7773
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub as_pfa { |
93
|
41
|
|
|
41
|
|
96
|
my $self = shift; |
94
|
41
|
|
|
|
|
199
|
my @parts = map {$_->as_pfa} $self->members; |
|
86
|
|
|
|
|
422
|
|
95
|
41
|
|
|
|
|
313
|
$parts[0]->shuffle(@parts[1 .. $#parts]); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Implement? |
99
|
|
|
|
|
|
|
sub reverse { |
100
|
0
|
|
|
0
|
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
croak "Not implemented for shuffled regexes"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub is_empty { |
105
|
0
|
|
|
0
|
|
|
croak "Not implemented for shuffled regexes"; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub has_nonempty_string { |
109
|
0
|
|
|
0
|
|
|
croak "Not implemented for shuffled regexes"; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub is_finite { |
113
|
0
|
|
|
0
|
|
|
croak "Not implemented for shuffled regexes"; |
114
|
|
|
|
|
|
|
} |