line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
34
|
use strict; use warnings; |
|
5
|
|
|
5
|
|
9
|
|
|
5
|
|
|
|
|
141
|
|
|
5
|
|
|
|
|
28
|
|
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
178
|
|
2
|
|
|
|
|
|
|
package assign::Struct; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
24
|
use XXX; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
24
|
|
|
24
|
0
|
50
|
my $class = shift; |
8
|
24
|
|
|
|
|
145
|
bless { |
9
|
|
|
|
|
|
|
elems => [], |
10
|
|
|
|
|
|
|
@_, |
11
|
|
|
|
|
|
|
}, $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
15
|
24
|
|
|
24
|
0
|
55
|
my ($self) = @_; |
16
|
|
|
|
|
|
|
|
17
|
24
|
|
|
|
|
91
|
my $node = $self->{node}; |
18
|
24
|
|
|
|
|
37
|
my $statement; |
19
|
24
|
|
|
|
|
84
|
for my $child ($node->children) { |
20
|
54
|
|
|
|
|
199
|
my $type = ref($child); |
21
|
54
|
100
|
|
|
|
114
|
if ($type eq 'PPI::Token::Whitespace') { |
22
|
30
|
|
|
|
|
69
|
next; |
23
|
|
|
|
|
|
|
} |
24
|
24
|
50
|
|
|
|
58
|
if ($type eq 'PPI::Statement') { |
25
|
24
|
50
|
|
|
|
45
|
XXX $node, "more than one statement" |
26
|
|
|
|
|
|
|
if $statement; |
27
|
24
|
|
|
|
|
43
|
$statement = $child; |
28
|
24
|
|
|
|
|
44
|
next; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
0
|
XXX $node, "unexpected node"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
24
|
50
|
|
|
|
84
|
XXX $node, "no statement in array" |
34
|
|
|
|
|
|
|
unless $statement; |
35
|
|
|
|
|
|
|
|
36
|
24
|
|
|
|
|
178
|
$self->{in} = [ $statement->children ]; |
37
|
|
|
|
|
|
|
|
38
|
24
|
|
|
|
|
161
|
while (1) { |
39
|
75
|
100
|
|
|
|
171
|
$self->parse_elem or last; |
40
|
73
|
100
|
|
|
|
152
|
$self->parse_comma or last; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
24
|
|
|
|
|
77
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub parse_comma { |
47
|
73
|
|
|
73
|
0
|
116
|
my ($self) = @_; |
48
|
73
|
|
|
|
|
120
|
my $in = $self->{in}; |
49
|
73
|
|
|
|
|
142
|
while (@$in) { |
50
|
51
|
|
|
|
|
76
|
my $tok = shift(@$in); |
51
|
51
|
|
|
|
|
83
|
my $type = ref($tok); |
52
|
51
|
50
|
|
|
|
94
|
next if $type eq 'PPI::Token::Whitespace'; |
53
|
|
|
|
|
|
|
|
54
|
51
|
50
|
33
|
|
|
135
|
if ($type eq 'PPI::Token::Operator' and |
55
|
|
|
|
|
|
|
$tok->content eq ',' |
56
|
|
|
|
|
|
|
) { |
57
|
51
|
|
|
|
|
308
|
return 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
0
|
|
|
|
|
0
|
XXX $tok, $in, "comma expected"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
22
|
|
|
|
|
50
|
return 0; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_var { |
67
|
59
|
|
|
59
|
0
|
114
|
my ($self, $var) = @_; |
68
|
59
|
|
|
|
|
69
|
my $def; |
69
|
59
|
|
|
|
|
112
|
my $in = $self->{in}; |
70
|
59
|
100
|
66
|
|
|
258
|
if (@$in > 1 and |
|
|
|
100
|
|
|
|
|
71
|
|
|
|
|
|
|
ref($in->[0]) eq 'PPI::Token::Operator' and |
72
|
|
|
|
|
|
|
$in->[0]->content eq '=' |
73
|
|
|
|
|
|
|
) { |
74
|
4
|
|
|
|
|
18
|
shift @$in; |
75
|
4
|
|
|
|
|
8
|
my $d = shift @$in; |
76
|
4
|
50
|
|
|
|
19
|
XXX $d, "Invalid token for variable default" |
77
|
|
|
|
|
|
|
unless ref($d) =~ |
78
|
|
|
|
|
|
|
/^PPI::Token::(Number|Symbol|Quote::(Single|Double))$/; |
79
|
4
|
|
|
|
|
9
|
$def = $d->content; |
80
|
4
|
50
|
66
|
|
|
22
|
XXX $d, "Invalid token for variable default" |
81
|
|
|
|
|
|
|
if ref($d) eq 'PPI::Token::Symbol' and |
82
|
|
|
|
|
|
|
$def !~ /^\$\w+$/; |
83
|
|
|
|
|
|
|
} |
84
|
59
|
|
|
|
|
274
|
assign::var->new($var, $def); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |