line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Util; |
2
|
|
|
|
|
|
|
|
3
|
89
|
|
|
89
|
|
623
|
use strict; |
|
89
|
|
|
|
|
193
|
|
|
89
|
|
|
|
|
2442
|
|
4
|
89
|
|
|
89
|
|
434
|
use warnings; |
|
89
|
|
|
|
|
179
|
|
|
89
|
|
|
|
|
2626
|
|
5
|
89
|
|
|
89
|
|
477
|
use Exporter 5.57 qw/import/; |
|
89
|
|
|
|
|
1522
|
|
|
89
|
|
|
|
|
7061
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our %FLAGS; BEGIN { |
8
|
89
|
|
|
89
|
|
359
|
my $i = 0; |
9
|
89
|
|
|
|
|
264
|
%FLAGS = map {$_ => 1 << $i++} qw/ |
|
890
|
|
|
|
|
5188
|
|
10
|
|
|
|
|
|
|
F_KEEP_TOKENS |
11
|
|
|
|
|
|
|
F_EVAL |
12
|
|
|
|
|
|
|
F_STRING_EVAL |
13
|
|
|
|
|
|
|
F_EXPECTS_BRACKET |
14
|
|
|
|
|
|
|
F_CONDITIONAL |
15
|
|
|
|
|
|
|
F_SIDEFF |
16
|
|
|
|
|
|
|
F_SCOPE_END |
17
|
|
|
|
|
|
|
F_STATEMENT_END |
18
|
|
|
|
|
|
|
F_EXPR_END |
19
|
|
|
|
|
|
|
F_EXPR |
20
|
|
|
|
|
|
|
/; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
89
|
|
|
89
|
|
610
|
use constant \%FLAGS; |
|
89
|
|
|
|
|
248
|
|
|
89
|
|
|
|
|
19940
|
|
24
|
|
|
|
|
|
|
use constant { |
25
|
89
|
|
|
|
|
63115
|
MASK_KEEP_TOKENS => ~(F_KEEP_TOKENS), |
26
|
|
|
|
|
|
|
MASK_EXPR_END => ~(F_EXPR_END|F_EXPR), |
27
|
|
|
|
|
|
|
MASK_STATEMENT_END => ~(F_KEEP_TOKENS|F_STATEMENT_END|F_EXPR|F_EXPR_END|F_SIDEFF), |
28
|
|
|
|
|
|
|
MASK_EVAL => ~(F_EVAL), |
29
|
|
|
|
|
|
|
MASK_SIDEFF => ~(F_SIDEFF), |
30
|
|
|
|
|
|
|
F_RESCAN => (F_KEEP_TOKENS|F_EVAL|F_STRING_EVAL|F_CONDITIONAL), |
31
|
89
|
|
|
89
|
|
678
|
}; |
|
89
|
|
|
|
|
233
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our @EXPORT = ((keys %FLAGS), qw/ |
34
|
|
|
|
|
|
|
is_module_name |
35
|
|
|
|
|
|
|
is_version |
36
|
|
|
|
|
|
|
convert_string_tokens |
37
|
|
|
|
|
|
|
convert_string_token_list |
38
|
|
|
|
|
|
|
MASK_KEEP_TOKENS |
39
|
|
|
|
|
|
|
MASK_EXPR_END |
40
|
|
|
|
|
|
|
MASK_STATEMENT_END |
41
|
|
|
|
|
|
|
MASK_EVAL |
42
|
|
|
|
|
|
|
MASK_SIDEFF |
43
|
|
|
|
|
|
|
F_RESCAN |
44
|
|
|
|
|
|
|
/); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub is_module_name { |
47
|
2621
|
100
|
|
2621
|
1
|
6159
|
my $name = shift or return; |
48
|
2619
|
100
|
|
|
|
15895
|
return 1 if $name =~ /^[A-Za-z_][A-Za-z0-9_]*(?:(?:::|')[A-Za-z0-9_]+)*$/; |
49
|
96
|
|
|
|
|
494
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub is_version { |
53
|
437
|
|
|
437
|
1
|
811
|
my $version = shift; |
54
|
437
|
100
|
|
|
|
1050
|
return unless defined $version; |
55
|
436
|
100
|
|
|
|
2420
|
return 1 if $version =~ /\A |
56
|
|
|
|
|
|
|
( |
57
|
|
|
|
|
|
|
[0-9]+(?:\.[0-9]+)? |
58
|
|
|
|
|
|
|
| |
59
|
|
|
|
|
|
|
v[0-9]+(?:\.[0-9]+)* |
60
|
|
|
|
|
|
|
| |
61
|
|
|
|
|
|
|
[0-9]+(?:\.[0-9]+){2,} |
62
|
|
|
|
|
|
|
) (?:_[0-9]+)? |
63
|
|
|
|
|
|
|
\z/x; |
64
|
252
|
|
|
|
|
848
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub convert_string_tokens { |
68
|
442
|
|
|
442
|
0
|
902
|
my $org_tokens = shift; |
69
|
442
|
|
|
|
|
776
|
my @tokens; |
70
|
442
|
|
|
|
|
1083
|
my @copied_tokens = @$org_tokens; |
71
|
442
|
|
|
|
|
844
|
my $prev = ''; |
72
|
442
|
|
|
|
|
1409
|
while(my $copied_token = shift @copied_tokens) { |
73
|
1787
|
|
|
|
|
3707
|
my ($token, $desc) = @$copied_token; |
74
|
1787
|
100
|
100
|
|
|
6173
|
if ($desc and $desc eq '()' and $prev ne 'WORD') { |
|
|
|
100
|
|
|
|
|
75
|
61
|
|
|
|
|
174
|
unshift @copied_tokens, @$token; |
76
|
61
|
|
|
|
|
179
|
next; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1726
|
100
|
100
|
|
|
6799
|
if (!$desc) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
80
|
7
|
|
|
|
|
18
|
push @tokens, $copied_token; |
81
|
|
|
|
|
|
|
} elsif ($desc eq 'VERSION_STRING' or $desc eq 'NUMBER') { |
82
|
94
|
|
|
|
|
200
|
push @tokens, $token; |
83
|
|
|
|
|
|
|
} elsif ($desc eq 'STRING') { |
84
|
282
|
|
|
|
|
711
|
push @tokens, $token->[0]; |
85
|
|
|
|
|
|
|
} elsif ($desc eq 'QUOTED_WORD_LIST') { |
86
|
25
|
50
|
|
|
|
159
|
push @tokens, grep {defined $_ and $_ ne ''} split /\s/, $token->[0]; |
|
53
|
|
|
|
|
270
|
|
87
|
|
|
|
|
|
|
} else { |
88
|
1318
|
|
|
|
|
2442
|
push @tokens, $copied_token; |
89
|
|
|
|
|
|
|
} |
90
|
1726
|
|
|
|
|
4252
|
$prev = $desc; |
91
|
|
|
|
|
|
|
} |
92
|
442
|
|
|
|
|
1484
|
\@tokens; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub convert_string_token_list { |
96
|
11
|
|
|
11
|
0
|
19
|
my $org_tokens = shift; |
97
|
11
|
|
|
|
|
25
|
my @list; |
98
|
|
|
|
|
|
|
my @tokens; |
99
|
11
|
|
|
|
|
28
|
my @copied_tokens = @$org_tokens; |
100
|
11
|
|
|
|
|
20
|
my $prev = ''; |
101
|
11
|
|
|
|
|
41
|
while(my $copied_token = shift @copied_tokens) { |
102
|
40
|
|
|
|
|
71
|
my ($token, $desc) = @$copied_token; |
103
|
40
|
50
|
33
|
|
|
129
|
if ($desc and $desc eq '()' and $prev ne 'WORD') { |
|
|
|
33
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
unshift @copied_tokens, @$token; |
105
|
0
|
|
|
|
|
0
|
next; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
40
|
50
|
66
|
|
|
227
|
if (!$desc) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
109
|
0
|
|
|
|
|
0
|
push @tokens, $copied_token; |
110
|
|
|
|
|
|
|
} elsif ($desc eq 'VERSION_STRING' or $desc eq 'NUMBER') { |
111
|
1
|
|
|
|
|
2
|
push @tokens, $token; |
112
|
|
|
|
|
|
|
} elsif ($desc eq 'STRING') { |
113
|
9
|
|
|
|
|
18
|
push @tokens, $token->[0]; |
114
|
|
|
|
|
|
|
} elsif ($desc eq 'QUOTED_WORD_LIST') { |
115
|
1
|
50
|
|
|
|
6
|
push @list, grep {defined $_ and $_ ne ''} split /\s/, $token->[0]; |
|
7
|
|
|
|
|
19
|
|
116
|
|
|
|
|
|
|
} elsif ($token eq ',' or $token eq '=>') { |
117
|
13
|
50
|
|
|
|
32
|
push @list, @tokens == 1 ? $tokens[0] : \@tokens; |
118
|
13
|
|
|
|
|
23
|
@tokens = (); |
119
|
13
|
|
|
|
|
22
|
$prev = ''; |
120
|
|
|
|
|
|
|
} elsif ($desc eq ';') { |
121
|
6
|
|
|
|
|
11
|
last; |
122
|
|
|
|
|
|
|
} else { |
123
|
10
|
|
|
|
|
17
|
push @tokens, $copied_token; |
124
|
|
|
|
|
|
|
} |
125
|
34
|
|
|
|
|
78
|
$prev = $desc; |
126
|
|
|
|
|
|
|
} |
127
|
11
|
100
|
|
|
|
25
|
if (@tokens) { |
128
|
7
|
50
|
|
|
|
32
|
push @list, @tokens == 1 ? $tokens[0] : \@tokens; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
11
|
|
|
|
|
38
|
\@list; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |