File Coverage

blib/lib/PPI/Token/End.pm
Criterion Covered Total %
statement 15 15 100.0
branch 5 6 83.3
condition n/a
subroutine 3 3 100.0
pod n/a
total 23 24 95.8


line stmt bran cond sub pod time code
1             package PPI::Token::End;
2              
3             =pod
4              
5             =head1 NAME
6              
7             PPI::Token::End - Completely useless content after the __END__ tag
8              
9             =head1 INHERITANCE
10              
11             PPI::Token::End
12             isa PPI::Token
13             isa PPI::Element
14              
15             =head1 DESCRIPTION
16              
17             If you've read L, you should understand by now
18             the concept of documents "floating in a sea of PPI::Token::Whitespace".
19              
20             Well it doesn't after the __END__ tag.
21              
22             Once you __END__, it's all over. Anything after that tag isn't even fit
23             to be called whitespace. It just simply doesn't exist as far as perl
24             (the interpreter) is concerned.
25              
26             That's not to say there isn't useful content. Most often people use
27             the __END__ tag to hide POD content, so that perl never has to see it,
28             and presumably providing some small speed up.
29              
30             That's fine. PPI likes POD. Any POD after the __END__ tag is parsed
31             into valid L tags as normal. B class, on the
32             other hand, is for "what's after __END__ when it isn't POD".
33              
34             Basically, the completely worthless bits of the file :)
35              
36             =head1 METHODS
37              
38             This class has no method beyond what is provided by its L and
39             L parent classes.
40              
41             =cut
42              
43 65     65   386 use strict;
  65         110  
  65         1525  
44 65     65   277 use PPI::Token ();
  65         139  
  65         12944  
45              
46             our $VERSION = '1.276';
47              
48             our @ISA = "PPI::Token";
49              
50              
51              
52              
53              
54             #####################################################################
55             # Tokenizer Methods
56              
57             ### XS -> PPI/XS.xs:_PPI_Token_End__significant 0.900+
58             sub significant() { '' }
59              
60             sub __TOKENIZER__on_char() { 1 }
61              
62             sub __TOKENIZER__on_line_start {
63 13     13   20 my $t = $_[1];
64              
65             # Can we classify the entire line in one go
66 13 100       220 if ( $t->{line} =~ /^=(\w+)/ ) {
67             # A Pod tag... change to pod mode
68 2         26 $t->_new_token( 'Pod', $t->{line} );
69 2 50       18 unless ( $1 eq 'cut' ) {
70             # Normal start to pod
71 2         5 $t->{class} = 'PPI::Token::Pod';
72             }
73              
74             # This is an error, but one we'll ignore
75             # Don't go into Pod mode, since =cut normally
76             # signals the end of Pod mode
77             } else {
78 11 100       24 if ( defined $t->{token} ) {
79             # Add to existing token
80 6         51 $t->{token}->{content} .= $t->{line};
81             } else {
82 5         11 $t->_new_token( 'End', $t->{line} );
83             }
84             }
85              
86 13         137 0;
87             }
88              
89             1;
90              
91             =pod
92              
93             =head1 SUPPORT
94              
95             See the L in the main module.
96              
97             =head1 AUTHOR
98              
99             Adam Kennedy Eadamk@cpan.orgE
100              
101             =head1 COPYRIGHT
102              
103             Copyright 2001 - 2011 Adam Kennedy.
104              
105             This program is free software; you can redistribute
106             it and/or modify it under the same terms as Perl itself.
107              
108             The full text of the license can be found in the
109             LICENSE file included with this module.
110              
111             =cut