line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Taxon::Parse; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2069
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
116
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1920
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.013'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
3
|
|
|
3
|
1
|
4696
|
my $class = shift; |
10
|
3
|
|
|
|
|
12
|
my $self = { |
11
|
|
|
|
|
|
|
patterns => {}, |
12
|
|
|
|
|
|
|
pattern_parts => {}, |
13
|
|
|
|
|
|
|
}; |
14
|
3
|
|
|
|
|
12
|
bless $self,$class; |
15
|
3
|
|
|
|
|
13
|
$self->init(); |
16
|
3
|
|
|
|
|
13
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub pattern { |
20
|
281
|
|
|
281
|
1
|
299
|
my $self = shift; |
21
|
281
|
|
|
|
|
304
|
my $pattern = shift; |
22
|
281
|
100
|
|
|
|
1141
|
return $self->{patterns}->{$pattern} if exists $self->{patterns}->{$pattern}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub pattern_parts { |
26
|
135
|
|
|
135
|
1
|
167
|
my $self = shift; |
27
|
135
|
|
|
|
|
152
|
my $pattern = shift; |
28
|
135
|
50
|
|
|
|
595
|
return $self->{pattern_parts}->{$pattern} if exists $self->{pattern_parts}->{$pattern}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub patterns { |
32
|
3
|
|
|
3
|
0
|
2156
|
my $self = shift; |
33
|
3
|
|
|
|
|
39
|
return $self->{patterns}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub order { |
37
|
2
|
|
|
2
|
0
|
489
|
my $self = shift; |
38
|
2
|
|
|
|
|
4
|
my $pattern = shift; |
39
|
2
|
50
|
|
|
|
11
|
return $self->{order}->{$pattern} if exists $self->{order}->{$pattern}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub match { |
43
|
5
|
|
|
5
|
0
|
12
|
my $self = shift; |
44
|
5
|
|
|
|
|
7
|
my $pattern = shift; |
45
|
5
|
|
|
|
|
7
|
my $string = shift; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
10
|
my $regex = $self->pattern($pattern); |
48
|
5
|
|
|
|
|
38
|
return $string =~ m/$regex/; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub match_parts { |
52
|
132
|
|
|
132
|
0
|
54789
|
my $self = shift; |
53
|
132
|
|
|
|
|
193
|
my $pattern = shift; |
54
|
132
|
|
|
|
|
173
|
my $string = shift; |
55
|
|
|
|
|
|
|
|
56
|
132
|
|
|
|
|
260
|
my $regex = $self->pattern_parts($pattern); |
57
|
132
|
|
|
|
|
3958
|
return $string =~ m/$regex/; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub check_parts { |
61
|
3
|
|
|
3
|
0
|
472
|
my $self = shift; |
62
|
3
|
|
|
|
|
4
|
my $pattern = shift; |
63
|
3
|
|
|
|
|
4
|
my $string = shift; |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
8
|
my $regex = $self->pattern_parts($pattern); |
66
|
3
|
|
|
|
|
71
|
return $string =~ m/^$regex$/; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub check { |
71
|
270
|
|
|
270
|
0
|
215960
|
my $self = shift; |
72
|
270
|
|
|
|
|
402
|
my $pattern = shift; |
73
|
270
|
|
|
|
|
315
|
my $string = shift; |
74
|
|
|
|
|
|
|
|
75
|
270
|
|
|
|
|
624
|
my $regex = $self->pattern($pattern); |
76
|
270
|
|
|
|
|
18686
|
return $string =~ m/^$regex$/; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub pick { |
80
|
3
|
|
|
3
|
0
|
518
|
my $self = shift; |
81
|
3
|
|
|
|
|
4
|
my $pattern = shift; |
82
|
3
|
|
|
|
|
4
|
my $string = shift; |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
6
|
my $regex = $self->pattern($pattern); |
85
|
3
|
|
|
|
|
58
|
my @result = $string =~ m/($regex)/g; |
86
|
3
|
|
|
|
|
203
|
return @result; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub ast { |
90
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
91
|
1
|
|
|
|
|
2
|
my $pattern = shift; |
92
|
1
|
|
|
|
|
1
|
my $string = shift; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
4
|
my $regex = $self->pattern($pattern); |
95
|
1
|
|
|
|
|
3
|
my $order = $self->order($pattern); |
96
|
1
|
|
|
|
|
3
|
my $result = []; |
97
|
|
|
|
|
|
|
{ |
98
|
1
|
50
|
|
|
|
1
|
if ($string =~ m/^$regex$/) { |
|
1
|
|
|
|
|
40
|
|
99
|
1
|
|
|
|
|
169
|
for my $key (@$order) { |
100
|
3
|
50
|
|
3
|
|
2753
|
push @$result,[ $key, $+{$key} ] if ($+{$key}); |
|
3
|
|
|
|
|
1881
|
|
|
3
|
|
|
|
|
476
|
|
|
2
|
|
|
|
|
29
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
} |
104
|
1
|
|
|
|
|
7
|
return $result; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub init { |
108
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
4
|
my $p = $self->{patterns}; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
5
|
$p->{apostrophe} = qr/[\'ยด`]/xms; |
113
|
1
|
|
|
|
|
3
|
$p->{compound_connector} = qr/[-]/xms; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |