line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FLAT::Regex::WithExtraOps; |
2
|
6
|
|
|
6
|
|
34
|
use parent 'FLAT::Regex'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
31
|
|
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
309
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
96
|
|
5
|
6
|
|
|
6
|
|
24
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1194
|
|
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
|
3018
|
|
|
3018
|
|
23286
|
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
|
|
40
|
use parent "FLAT::Regex::Op"; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
40
|
|
33
|
6
|
|
|
6
|
|
341
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1766
|
|
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
6
|
|
17
|
sub parse_spec {"'~' %s";} |
36
|
6
|
|
|
6
|
|
15
|
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
|
|
40
|
use parent 'FLAT::Regex::Op'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
30
|
|
71
|
6
|
|
|
6
|
|
296
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
2062
|
|
72
|
|
|
|
|
|
|
|
73
|
6
|
|
|
6
|
|
35
|
sub parse_spec {"%s(2.. /[&]/)"} |
74
|
6
|
|
|
6
|
|
15
|
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
|
1359
|
|
|
1359
|
|
291985
|
my ($pkg, @item) = @_; |
89
|
1359
|
|
|
|
|
3388
|
$pkg->new(@{$item[1]}); |
|
1359
|
|
|
|
|
6151
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub as_pfa { |
93
|
48
|
|
|
48
|
|
108
|
my $self = shift; |
94
|
48
|
|
|
|
|
201
|
my @parts = map {$_->as_pfa} $self->members; |
|
100
|
|
|
|
|
429
|
|
95
|
48
|
|
|
|
|
325
|
$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
|
|
|
|
|
|
|
} |