line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Statistics::R::IO::ParserState; |
2
|
|
|
|
|
|
|
# ABSTRACT: Current state of the IO parser |
3
|
|
|
|
|
|
|
$Statistics::R::IO::ParserState::VERSION = '1.0002'; |
4
|
15
|
|
|
15
|
|
49974
|
use 5.010; |
|
15
|
|
|
|
|
49
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
2315
|
use Class::Tiny::Antlers; |
|
15
|
|
|
|
|
25898
|
|
|
15
|
|
|
|
|
91
|
|
7
|
15
|
|
|
15
|
|
5964
|
use namespace::clean; |
|
15
|
|
|
|
|
148959
|
|
|
15
|
|
|
|
|
87
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has data => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
default => sub { [] }, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has position => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
default => sub { 0 }, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has singletons => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
default => sub { [] }, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub BUILDARGS { |
26
|
284186
|
|
|
284186
|
0
|
3424183
|
my $class = shift; |
27
|
284186
|
|
|
|
|
406050
|
my $attributes = {}; |
28
|
|
|
|
|
|
|
|
29
|
284186
|
50
|
|
|
|
650696
|
if ( scalar @_ == 1) { |
|
|
50
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
0
|
if ( ref $_[0] eq 'HASH' ) { |
31
|
0
|
|
|
|
|
0
|
$attributes = $_[0] |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
0
|
|
|
|
|
0
|
$attributes->{name} = $_[0] |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( @_ % 2 ) { |
38
|
0
|
|
|
|
|
0
|
die "The new() method for $class expects a hash reference or a key/value list." |
39
|
|
|
|
|
|
|
. " You passed an odd number of arguments\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
284186
|
|
|
|
|
701570
|
$attributes = { @_ }; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# split strings into a list of individual characters |
46
|
284186
|
100
|
66
|
|
|
1008479
|
if (defined $attributes->{data} && !ref($attributes->{data})) { |
47
|
981
|
|
|
|
|
70711
|
$attributes->{data} = [split //, $attributes->{data}]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$attributes |
51
|
284186
|
|
|
|
|
567177
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub BUILD { |
54
|
284186
|
|
|
284186
|
0
|
5389039
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
284186
|
50
|
|
|
|
4550342
|
die 'foo' unless ref($self->data) eq 'ARRAY' |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub at { |
60
|
281234
|
|
|
281234
|
1
|
393769
|
my $self = shift; |
61
|
281234
|
|
|
|
|
3924986
|
$self->data->[$self->position] |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub next { |
65
|
281262
|
|
|
281262
|
1
|
5713713
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
ref($self)->new(data => $self->data, |
68
|
|
|
|
|
|
|
position => $self->position+1, |
69
|
281262
|
|
|
|
|
3950934
|
singletons => [ @{$self->singletons} ]) |
|
281262
|
|
|
|
|
8945957
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub add_singleton { |
73
|
1937
|
|
|
1937
|
1
|
5145
|
my ($self, $singleton) = (shift, shift); |
74
|
|
|
|
|
|
|
|
75
|
1937
|
|
|
|
|
3478
|
my @new_singletons = @{$self->singletons}; |
|
1937
|
|
|
|
|
30644
|
|
76
|
1937
|
|
|
|
|
12159
|
push @new_singletons, $singleton; |
77
|
1937
|
|
|
|
|
29602
|
ref($self)->new(data => $self->data, |
78
|
|
|
|
|
|
|
position => $self->position, |
79
|
|
|
|
|
|
|
singletons => [ @new_singletons ]) |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub get_singleton { |
83
|
1633
|
|
|
1633
|
1
|
4325
|
my ($self, $singleton_id) = (shift, shift); |
84
|
1633
|
|
|
|
|
30271
|
$self->singletons->[$singleton_id] |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub eof { |
88
|
279805
|
|
|
279805
|
1
|
406289
|
my $self = shift; |
89
|
279805
|
|
|
|
|
4549615
|
$self->position >= scalar @{$self->data}; |
|
279805
|
|
|
|
|
4815411
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |