line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
21610
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Gentoo::Dependency::AST; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
438
|
$Gentoo::Dependency::AST::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$Gentoo::Dependency::AST::VERSION = '0.001001'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Convert a canonicalized (R|P|)DEPEND into an Abstract Syntax Tree |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _carp { |
18
|
0
|
|
|
0
|
|
0
|
require Carp; |
19
|
0
|
|
|
|
|
0
|
goto &Carp::carp; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub parse_dep_string { |
23
|
1
|
|
|
1
|
1
|
15
|
my ( $class, $string ) = @_; |
24
|
1
|
|
|
|
|
832
|
require Gentoo::Dependency::AST::State; |
25
|
1
|
|
|
|
|
14
|
my $state = Gentoo::Dependency::AST::State->new(); |
26
|
1
|
50
|
|
|
|
102
|
my @tokens = grep { defined and length } split /\s+/msx, $string; |
|
40
|
|
|
|
|
140
|
|
27
|
1
|
|
|
33
|
|
8
|
my $sub_skip_tokens = sub { splice @tokens, 0, $_[0], () }; |
|
33
|
|
|
|
|
77
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
5
|
while (@tokens) { |
30
|
33
|
50
|
|
|
|
65
|
if ( not defined $tokens[0] ) { |
31
|
0
|
|
|
|
|
0
|
_carp('Undefined token!'); |
32
|
0
|
|
|
|
|
0
|
next; |
33
|
|
|
|
|
|
|
} |
34
|
33
|
100
|
100
|
|
|
133
|
if ( defined $tokens[1] and $tokens[1] eq q[(] ) { |
35
|
6
|
100
|
|
|
|
25
|
if ( $tokens[0] =~ /\A!(.*)[?]\z/msx ) { |
36
|
1
|
|
|
|
|
5
|
$state->enter_notuse_group($1); |
37
|
1
|
|
|
|
|
2
|
$sub_skip_tokens->(2); |
38
|
1
|
|
|
|
|
3
|
next; |
39
|
|
|
|
|
|
|
} |
40
|
5
|
50
|
|
|
|
24
|
if ( $tokens[0] =~ /\A([^!].*)[?]\z/msx ) { |
41
|
5
|
|
|
|
|
16
|
$state->enter_use_group($1); |
42
|
5
|
|
|
|
|
11
|
$sub_skip_tokens->(2); |
43
|
5
|
|
|
|
|
14
|
next; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
0
|
|
|
|
0
|
if ( $tokens[0] eq q[||] ) { |
46
|
0
|
|
|
|
|
0
|
$state->enter_or_group(); |
47
|
0
|
|
|
|
|
0
|
$sub_skip_tokens->(2); |
48
|
0
|
|
|
|
|
0
|
next; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
27
|
50
|
|
|
|
54
|
if ( $tokens[0] eq q[(] ) { |
52
|
0
|
|
|
|
|
0
|
$state->enter_and_group($1); |
53
|
0
|
|
|
|
|
0
|
$sub_skip_tokens->(1); |
54
|
0
|
|
|
|
|
0
|
next; |
55
|
|
|
|
|
|
|
} |
56
|
27
|
100
|
|
|
|
45
|
if ( $tokens[0] eq q[)] ) { |
57
|
6
|
|
|
|
|
19
|
$state->exit_group($1); |
58
|
6
|
|
|
|
|
14
|
$sub_skip_tokens->(1); |
59
|
6
|
|
|
|
|
18
|
next; |
60
|
|
|
|
|
|
|
} |
61
|
21
|
|
|
|
|
57
|
$state->add_dep( $tokens[0] ); |
62
|
21
|
|
|
|
|
39
|
$sub_skip_tokens->(1); |
63
|
|
|
|
|
|
|
} |
64
|
1
|
50
|
|
|
|
5
|
if ( not $state->state->isa('Gentoo::Dependency::AST::Node::TopLevel') ) { |
65
|
0
|
|
|
|
|
0
|
_carp(q[Parse was inbalanced]); |
66
|
|
|
|
|
|
|
} |
67
|
1
|
|
|
|
|
23
|
return $state->state; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |