line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PPI::Token::Data; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PPI::Token::Data - The actual data in the __DATA__ section of a file |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 INHERITANCE |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
PPI::Token::Data |
12
|
|
|
|
|
|
|
isa PPI::Token |
13
|
|
|
|
|
|
|
isa PPI::Element |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
The C class is used to represent the actual data inside |
18
|
|
|
|
|
|
|
a file's C<__DATA__> section. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
One C object is used to represent the entire of the data, |
21
|
|
|
|
|
|
|
primarily so that it can provide a convenient handle directly to the data. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
C provides one method in addition to those provided by |
26
|
|
|
|
|
|
|
our parent L and L classes. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
65
|
|
|
65
|
|
373
|
use strict; |
|
65
|
|
|
|
|
109
|
|
|
65
|
|
|
|
|
1467
|
|
31
|
65
|
|
|
65
|
|
267
|
use PPI::Token (); |
|
65
|
|
|
|
|
96
|
|
|
65
|
|
|
|
|
1385
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# IO::String emulates file handles using in memory strings. Perl can do this |
34
|
|
|
|
|
|
|
# directly on perl 5.8+ |
35
|
65
|
|
|
65
|
|
255
|
use constant USE_IO_STRING => $] < '5.008000'; |
|
65
|
|
|
|
|
99
|
|
|
65
|
|
|
|
|
4247
|
|
36
|
65
|
|
|
65
|
|
1434
|
use if USE_IO_STRING, 'IO::String'; |
|
65
|
|
|
|
|
118
|
|
|
65
|
|
|
|
|
528
|
|
37
|
|
|
|
|
|
|
# code may expect methods to be available on all file handles, so make sure |
38
|
|
|
|
|
|
|
# IO is loaded |
39
|
65
|
|
|
65
|
|
2254
|
use if !USE_IO_STRING, 'IO::File'; |
|
65
|
|
|
|
|
138
|
|
|
65
|
|
|
|
|
187
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $VERSION = '1.276'; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our @ISA = "PPI::Token"; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
##################################################################### |
50
|
|
|
|
|
|
|
# Methods |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 handle |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The C method returns a L handle that allows you |
57
|
|
|
|
|
|
|
to do all the normal handle-y things to the contents of the __DATA__ |
58
|
|
|
|
|
|
|
section of the file. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Unlike in perl itself, this means you can also do things like C |
61
|
|
|
|
|
|
|
new data onto the end of the __DATA__ section, or modify it with |
62
|
|
|
|
|
|
|
any other process that can accept an L as input or output. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns an L object. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub handle { |
69
|
1
|
|
|
1
|
1
|
422
|
my $self = shift; |
70
|
|
|
|
|
|
|
# perl 5.6 compatibility |
71
|
1
|
|
|
|
|
2
|
if (USE_IO_STRING) { |
72
|
|
|
|
|
|
|
return IO::String->new( \$self->{content} ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
1
|
|
|
1
|
|
33
|
open my $fh, '+<', \$self->{content}; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
8
|
|
76
|
1
|
|
|
|
|
705
|
return $fh; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub __TOKENIZER__on_line_start { |
81
|
6
|
|
|
6
|
|
19
|
my ( $self, $t ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Add the line |
84
|
6
|
100
|
|
|
|
21
|
if ( defined $t->{token} ) { |
85
|
3
|
|
|
|
|
153
|
$t->{token}->{content} .= $t->{line}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
3
|
50
|
|
|
|
31
|
defined( $t->{token} = $t->{class}->new( $t->{line} ) ) or return undef; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
6
|
|
|
|
|
16
|
return 0; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=pod |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SUPPORT |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
See the L in the main module. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Copyright 2001 - 2011 Adam Kennedy. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This program is free software; you can redistribute |
111
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The full text of the license can be found in the |
114
|
|
|
|
|
|
|
LICENSE file included with this module. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |