line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Parser::Core; |
2
|
|
|
|
|
|
|
|
3
|
83
|
|
|
83
|
|
1335
|
use strict; |
|
83
|
|
|
|
|
163
|
|
|
83
|
|
|
|
|
2090
|
|
4
|
83
|
|
|
83
|
|
356
|
use warnings; |
|
83
|
|
|
|
|
157
|
|
|
83
|
|
|
|
|
1715
|
|
5
|
83
|
|
|
83
|
|
360
|
use Perl::PrereqScanner::NotQuiteLite::Util; |
|
83
|
|
|
|
|
193
|
|
|
83
|
|
|
|
|
88902
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my %feature_since = ( |
8
|
|
|
|
|
|
|
say => '5.010', |
9
|
|
|
|
|
|
|
state => '5.010', |
10
|
|
|
|
|
|
|
switch => '5.010', |
11
|
|
|
|
|
|
|
unicode_strings => '5.012', |
12
|
|
|
|
|
|
|
current_sub => '5.016', |
13
|
|
|
|
|
|
|
evalbytes => '5.016', |
14
|
|
|
|
|
|
|
fc => '5.016', |
15
|
|
|
|
|
|
|
arybase => '5.016', |
16
|
|
|
|
|
|
|
unicode_eval => '5.016', |
17
|
|
|
|
|
|
|
lexical_subs => '5.018', |
18
|
|
|
|
|
|
|
postderef => '5.020', |
19
|
|
|
|
|
|
|
postderef_qq => '5.020', |
20
|
|
|
|
|
|
|
signatures => '5.020', |
21
|
|
|
|
|
|
|
bitwise => '5.022', |
22
|
|
|
|
|
|
|
refaliasing => '5.022', |
23
|
|
|
|
|
|
|
declared_refs => '5.026', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub register { return { |
27
|
82
|
|
|
82
|
0
|
742
|
use => { |
28
|
|
|
|
|
|
|
if => 'parse_if_args', |
29
|
|
|
|
|
|
|
base => 'parse_base_args', |
30
|
|
|
|
|
|
|
parent => 'parse_parent_args', |
31
|
|
|
|
|
|
|
feature => 'parse_feature_args', |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
keyword => { |
34
|
|
|
|
|
|
|
package => 'parse_package', |
35
|
|
|
|
|
|
|
exit => 'parse_begin_exit', |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
}} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub parse_if_args { |
40
|
9
|
|
|
9
|
0
|
34
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
30
|
while(my $token = shift @$raw_tokens) { |
43
|
20
|
100
|
|
|
|
69
|
last if $token->[1] eq 'COMMA'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
9
|
|
|
|
|
36
|
my $tokens = convert_string_tokens($raw_tokens); |
47
|
9
|
|
|
|
|
19
|
my $module = shift @$tokens; |
48
|
9
|
50
|
66
|
|
|
46
|
if (ref $module and ($module->[1] eq 'WORD' or $module->[1] eq 'KEYWORD')) { |
|
|
|
66
|
|
|
|
|
49
|
4
|
|
|
|
|
8
|
$module = $module->[0]; |
50
|
|
|
|
|
|
|
} |
51
|
9
|
50
|
|
|
|
29
|
if (is_module_name($module)) { |
52
|
9
|
50
|
|
|
|
31
|
if (is_version($tokens->[0])) { |
53
|
0
|
|
|
|
|
0
|
my $version = shift @$tokens; |
54
|
0
|
|
|
|
|
0
|
$c->add_recommendation($module => $version); |
55
|
|
|
|
|
|
|
} else { |
56
|
9
|
|
|
|
|
34
|
$c->add_recommendation($module => 0); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} else { |
59
|
0
|
|
|
|
|
0
|
push @{$c->{errors}}, "use if module not found"; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub parse_base_args { |
64
|
21
|
|
|
21
|
0
|
78
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
65
|
|
|
|
|
|
|
|
66
|
21
|
|
|
|
|
74
|
my $tokens = convert_string_tokens($raw_tokens); |
67
|
21
|
50
|
|
|
|
77
|
if (is_version($tokens->[0])) { |
68
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
69
|
|
|
|
|
|
|
} |
70
|
21
|
|
|
|
|
67
|
while(my $token = shift @$tokens) { |
71
|
51
|
|
|
|
|
749
|
my $module = $token; |
72
|
51
|
100
|
100
|
|
|
238
|
if (ref $module and ($module->[1] || '') eq 'WORD') { |
|
|
|
100
|
|
|
|
|
73
|
|
|
|
|
|
|
# allow bareword, but disallow function() |
74
|
2
|
|
|
|
|
5
|
$module = $module->[0]; |
75
|
2
|
100
|
33
|
|
|
21
|
next if @$tokens and ref $tokens->[0] and ($tokens->[0][1] || '') eq '()'; |
|
|
|
50
|
|
|
|
|
|
|
|
66
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
# bareword in parentheses |
78
|
50
|
100
|
100
|
|
|
164
|
if (ref $module and ref $module->[0]) { |
79
|
3
|
|
|
|
|
7
|
$module = $module->[0][0]; |
80
|
|
|
|
|
|
|
} |
81
|
50
|
100
|
|
|
|
117
|
if (is_module_name($module)) { |
82
|
25
|
|
|
|
|
74
|
$c->add($module => 0); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub parse_parent_args { |
88
|
28
|
|
|
28
|
0
|
60
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
89
|
|
|
|
|
|
|
|
90
|
28
|
|
|
|
|
75
|
my $tokens = convert_string_tokens($raw_tokens); |
91
|
28
|
50
|
|
|
|
74
|
if (is_version($tokens->[0])) { |
92
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
93
|
|
|
|
|
|
|
} |
94
|
28
|
|
|
|
|
70
|
while(my $token = shift @$tokens) { |
95
|
54
|
100
|
|
|
|
676
|
last if $token eq '-norequire'; |
96
|
52
|
|
|
|
|
73
|
my $module = $token; |
97
|
52
|
100
|
|
|
|
104
|
if (ref $token) { |
98
|
31
|
100
|
|
|
|
79
|
last if $token->[0] eq '-norequire'; |
99
|
|
|
|
|
|
|
} |
100
|
47
|
100
|
100
|
|
|
167
|
if (ref $module and ($module->[1] || '') eq 'WORD') { |
|
|
|
100
|
|
|
|
|
101
|
|
|
|
|
|
|
# allow bareword, but disallow function() |
102
|
2
|
|
|
|
|
3
|
$module = $module->[0]; |
103
|
2
|
100
|
33
|
|
|
16
|
next if @$tokens and ref $tokens->[0] and ($tokens->[0][1] || '') eq '()'; |
|
|
|
50
|
|
|
|
|
|
|
|
66
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
# bareword in parentheses |
106
|
46
|
100
|
100
|
|
|
132
|
if (ref $module and ref $module->[0]) { |
107
|
3
|
|
|
|
|
6
|
$module = $module->[0][0]; |
108
|
|
|
|
|
|
|
} |
109
|
46
|
100
|
|
|
|
95
|
$c->add($module => 0) if is_module_name($module); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub parse_feature_args { |
114
|
10
|
|
|
10
|
0
|
21
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
115
|
|
|
|
|
|
|
|
116
|
10
|
|
|
|
|
27
|
$c->add_perl('5.010', 'feature'); |
117
|
10
|
|
|
|
|
24
|
my $tokens = convert_string_tokens($raw_tokens); |
118
|
10
|
50
|
|
|
|
23
|
if (is_version($tokens->[0])) { |
119
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
120
|
|
|
|
|
|
|
} |
121
|
10
|
|
|
|
|
24
|
while(my $token = shift @$tokens) { |
122
|
19
|
100
|
|
|
|
62
|
next if ref $token; |
123
|
9
|
100
|
|
|
|
21
|
if (exists $feature_since{$token}) { |
124
|
5
|
|
|
|
|
17
|
$c->add_perl($feature_since{$token} => "feature $token"); |
125
|
5
|
|
|
|
|
15
|
next; |
126
|
|
|
|
|
|
|
} |
127
|
4
|
50
|
|
|
|
19
|
if ($token =~ /^:5\.([0-9]+)(\.\[0-9]+)?/) { |
128
|
4
|
|
|
|
|
25
|
my $version = sprintf '5.%03d', $1; |
129
|
4
|
|
|
|
|
16
|
$c->add_perl($version, $token); |
130
|
4
|
|
|
|
|
14
|
next; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub parse_begin_exit { |
136
|
8
|
|
|
8
|
0
|
17
|
my ($class, $c, $raw_tokens) = @_; |
137
|
|
|
|
|
|
|
|
138
|
8
|
50
|
|
|
|
13
|
my @stack = @{$c->{stack} || []}; |
|
8
|
|
|
|
|
22
|
|
139
|
8
|
50
|
|
|
|
19
|
if (grep {$_->[0] eq '{' and $_->[2] eq 'BEGIN'} @stack) { |
|
7
|
100
|
|
|
|
58
|
|
140
|
4
|
100
|
|
|
|
9
|
if (grep {$c->token_is_conditional($_->[0])} @$raw_tokens) { |
|
12
|
100
|
|
|
|
24
|
|
141
|
1
|
|
|
|
|
3
|
$c->{force_cond} = 1; |
142
|
4
|
50
|
|
|
|
13
|
} elsif (grep {$_->[0] eq '{' and $c->token_is_conditional($_->[2])} @stack) { |
143
|
1
|
|
|
|
|
4
|
$c->{force_cond} = 1; |
144
|
|
|
|
|
|
|
} else { |
145
|
2
|
|
|
|
|
4
|
$c->{ended} = 1; |
146
|
2
|
|
|
|
|
3
|
@{$c->{stack}} = (); |
|
2
|
|
|
|
|
6
|
|
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub parse_package { |
152
|
32
|
|
|
32
|
0
|
86
|
my ($class, $c, $raw_tokens) = @_; |
153
|
|
|
|
|
|
|
|
154
|
32
|
|
|
|
|
115
|
my $tokens = convert_string_tokens($raw_tokens); |
155
|
32
|
|
|
|
|
63
|
shift @$tokens; # drop "package" |
156
|
32
|
|
|
|
|
77
|
my $token = shift @$tokens; |
157
|
32
|
100
|
33
|
|
|
278
|
if (ref $token && $token->[1] && $token->[1] eq 'WORD') { |
|
|
|
66
|
|
|
|
|
158
|
31
|
|
|
|
|
125
|
$c->add_package($token->[0]); |
159
|
|
|
|
|
|
|
} |
160
|
32
|
50
|
|
|
|
107
|
if (@$tokens) { |
161
|
32
|
|
|
|
|
79
|
$token = shift @$tokens; |
162
|
32
|
100
|
|
|
|
102
|
if (is_version($token)) { |
163
|
5
|
|
|
|
|
13
|
$c->add_perl("5.012", "package PACKAGE VERSION"); |
164
|
5
|
|
|
|
|
11
|
$token = shift @$tokens; |
165
|
|
|
|
|
|
|
} |
166
|
32
|
100
|
33
|
|
|
287
|
if (ref $token && $token->[1] && $token->[1] =~ /^\{/) { |
|
|
|
66
|
|
|
|
|
167
|
6
|
|
|
|
|
15
|
$c->add_perl("5.014", "package PACKAGE (VERSION) {}"); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
__END__ |