PPI/Lexer.pm

filter: Statementstmt 94.4% 422 / 447 Branchbran 87.5% 254 / 290 Conditioncond 74.1% 115 / 155 MC/DCmcdc 58.5% 55 / 94 Subroutinesub 100% 36 / 36 Podpod 100% 5 / 5 totaltotal 86.3% 887 / 1027 CC 202 SCAR 36.0
CC
202
Cov
89%
_continues
86.9
_statement
37.2
_curly
31.6
CRAP 36.6
« PPI/Token/Whitespace.pm ↑ Summary PPI/Statement/Compound.pm »
1 package PPI::Lexer;
2  
3 =pod
4  
5 =head1 NAME
6  
7 PPI::Lexer - The PPI Lexer
8  
9 =head1 SYNOPSIS
10  
11 use PPI;
12
13 # Create a new Lexer
14 my $Lexer = PPI::Lexer->new;
15
16 # Build a PPI::Document object from a Token stream
17 my $Tokenizer = PPI::Tokenizer->load('My/Module.pm');
18 my $Document = $Lexer->lex_tokenizer($Tokenizer);
19
20 # Build a PPI::Document object for some raw source
21 my $source = "print 'Hello World!'; kill(Humans->all);";
22 $Document = $Lexer->lex_source($source);
23
24 # Build a PPI::Document object for a particular file name
25 $Document = $Lexer->lex_file('My/Module.pm');
26  
27 =head1 DESCRIPTION
28  
29 The is the L<PPI> Lexer. In the larger scheme of things, its job is to take
30 token streams, in a variety of forms, and "lex" them into nested structures.
31  
32 Pretty much everything in this module happens behind the scenes at this
33 point. In fact, at the moment you don't really need to instantiate the lexer
34 at all, the three main methods will auto-instantiate themselves a
35 C<PPI::Lexer> object as needed.
36  
37 All methods do a one-shot "lex this and give me a L<PPI::Document> object".
38  
39 In fact, if you are reading this, what you B<probably> want to do is to
40 just "load a document", in which case you can do this in a much more
41 direct and concise manner with one of the following.
42  
43 use PPI;
44
45 $Document = PPI::Document->load( $filename );
46 $Document = PPI::Document->new( $string );
47  
48 See L<PPI::Document> for more details.
49  
50 For more unusual tasks, by all means forge onwards.
51  
52 =head1 METHODS
53  
54 =cut
55  
56 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 62 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
58 62 ▶use Params::Util qw{_STRING _INSTANCE};
Subroutine BEGIN: called CC=1 SCAR=0.0
59 62 ▶use List::MoreUtils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
60 62 ▶use PPI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
61 62 ▶use PPI::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 62 ▶use vars qw{$VERSION $errstr *_PARENT %ROUND %RESOLVE};
Subroutine BEGIN: called CC=1 SCAR=0.0
64 BEGIN {
65 62 ▶ $VERSION = '1.236';
Subroutine BEGIN: called CC=1 SCAR=0.0
66 62 $errstr = '';
67  
68 # Faster than having another method call just
69 # to set the structure finish token.
70 62 *_PARENT = *PPI::Element::_PARENT;
71  
72 # Keyword -> Structure class maps
73 62 %ROUND = (
74 # Conditions
75 'if' => 'PPI::Structure::Condition',
76 'elsif' => 'PPI::Structure::Condition',
77 'unless' => 'PPI::Structure::Condition',
78 'while' => 'PPI::Structure::Condition',
79 'until' => 'PPI::Structure::Condition',
80  
81 # For(each)
82 'for' => 'PPI::Structure::For',
83 'foreach' => 'PPI::Structure::For',
84 );
85  
86 # Opening brace to refining method
87 62 %RESOLVE = (
88 '(' => '_round',
89 '[' => '_square',
90 '{' => '_curly',
91 );
92  
93 }
94  
95 # Allows for experimental overriding of the tokenizer
96 62 ▶use vars qw{ $X_TOKENIZER };
Subroutine BEGIN: called CC=1 SCAR=0.0
97 BEGIN {
98 62 ▶ $X_TOKENIZER ||= 'PPI::Tokenizer';
Subroutine BEGIN: called CC=2 SCAR=7.6
Condition50%1/2
$PPI::Lexer::X_TOKENIZER ||= "PPI::Tokenizer"
l!l
062
MC/DC0%0/1
$PPI::Lexer::X_TOKENIZER ||= "PPI::Tokenizer"
$PPI::Lexer::X_TOKENIZER
Truth table50%1/2
A
A= $PPI::Lexer::X_TOKENIZER
Aresult
11
00
99 }
100 62 ▶use constant X_TOKENIZER => $X_TOKENIZER;
Subroutine BEGIN: called CC=1 SCAR=0.0
101  
102  
103  
104  
105  
106 #####################################################################
107 # Constructor
108  
109 =pod
110  
111 =head2 new
112  
113 The C<new> constructor creates a new C<PPI::Lexer> object. The object itself
114 is merely used to hold various buffers and state data during the lexing
115 process, and holds no significant data between -E<gt>lex_xxxxx calls.
116  
117 Returns a new C<PPI::Lexer> object
118  
119 =cut
120  
121 sub new {
122 15660 ▶ my $class = shift->_clear;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
123 15660 bless {
124 Tokenizer => undef, # Where we store the tokenizer for a run
125 buffer => [], # The input token buffer
126 delayed => [], # The "delayed insignificant tokens" buffer
127 }, $class;
128 }
129  
130  
131  
132  
133  
134 #####################################################################
135 # Main Lexing Methods
136  
137 =pod
138  
139 =head2 lex_file $filename
140  
141 The C<lex_file> method takes a filename as argument. It then loads the file,
142 creates a L<PPI::Tokenizer> for the content and lexes the token stream
143 produced by the tokenizer. Basically, a sort of all-in-one method for
144 getting a L<PPI::Document> object from a file name.
145  
146 Returns a L<PPI::Document> object, or C<undef> on error.
147  
148 =cut
149  
150 sub lex_file {
151 469 ▶ my $self = ref $_[0] ? shift : shift->new;
Subroutine lex_file: called CC=5 SCAR=16.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 1 468 469
152 469 my $file = _STRING(shift);
153 469 ▶ unless ( defined $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 1 468 469
154 1 return $self->_error("Did not pass a filename to PPI::Lexer::lex_file");
155 }
156  
157 # Create the Tokenizer
158 468 my $Tokenizer = eval {
159 468 X_TOKENIZER->new($file);
160 };
161 468 ▶ if ( _INSTANCE($@, 'PPI::Exception') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&_INSTANCE($@, 'PPI::Exception')) { } 0 468 468
elsif ($@) { } 0 468 468
162 0 return $self->_error( $@->message );
163 } elsif ( $@ ) {
164 0 return $self->_error( $errstr );
165 }
166  
167 468 $self->lex_tokenizer( $Tokenizer );
168 }
169  
170 =pod
171  
172 =head2 lex_source $string
173  
174 The C<lex_source> method takes a normal scalar string as argument. It
175 creates a L<PPI::Tokenizer> object for the string, and then lexes the
176 resulting token stream.
177  
178 Returns a L<PPI::Document> object, or C<undef> on error.
179  
180 =cut
181  
182 sub lex_source {
183 15191 ▶ my $self = ref $_[0] ? shift : shift->new;
Subroutine lex_source: called CC=6 SCAR=21.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 15191 15191
184 15191 my $source = shift;
185 15191 ▶ unless ( defined $source and not ref $source ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source and not ref $source) 0 15191 15191
Condition33%1/3
defined $source and not ref $source
!ll&&!rl&&r
0015191
MC/DC0%0/2
defined $source and not ref $source
defined $source not ref $source
Truth table33%1/3
A and not(B)
A= defined $sourceB= not ref $source
ABresult
0X0
100
111
186 0 return $self->_error("Did not pass a string to PPI::Lexer::lex_source");
187 }
188  
189 # Create the Tokenizer and hand off to the next method
190 15191 my $Tokenizer = eval {
191 15191 X_TOKENIZER->new(\$source);
192 };
193 15191 ▶ if ( _INSTANCE($@, 'PPI::Exception') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&_INSTANCE($@, 'PPI::Exception')) { } 0 15191 15191
elsif ($@) { } 0 15191 15191
194 0 return $self->_error( $@->message );
195 } elsif ( $@ ) {
196 0 return $self->_error( $errstr );
197 }
198  
199 15191 $self->lex_tokenizer( $Tokenizer );
200 }
201  
202 =pod
203  
204 =head2 lex_tokenizer $Tokenizer
205  
206 The C<lex_tokenizer> takes as argument a L<PPI::Tokenizer> object. It
207 lexes the token stream from the tokenizer into a L<PPI::Document> object.
208  
209 Returns a L<PPI::Document> object, or C<undef> on error.
210  
211 =cut
212  
213 sub lex_tokenizer {
214 15659 ▶ my $self = ref $_[0] ? shift : shift->new;
Subroutine lex_tokenizer: called CC=5 SCAR=16.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 15659 0 15659
215 15659 my $Tokenizer = _INSTANCE(shift, 'PPI::Tokenizer');
216 15659 ▶ return $self->_error(
Branch: 1 branch
BranchTrueFalseTotal
unless $Tokenizer 0 15659 15659
217 "Did not pass a PPI::Tokenizer object to PPI::Lexer::lex_tokenizer"
218 ) unless $Tokenizer;
219  
220 # Create the empty document
221 15659 my $Document = PPI::Document->new;
222  
223 # Lex the token stream into the document
224 15659 $self->{Tokenizer} = $Tokenizer;
225 15659 ▶ if ( !eval { $self->_lex_document($Document); 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $self->_lex_document($Document); 1 } }) 1 15658 15659
226 # If an error occurs DESTROY the partially built document.
227 1 undef $Document;
228 1 ▶ if ( _INSTANCE($@, 'PPI::Exception') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_INSTANCE($@, 'PPI::Exception')) { } 1 0 1
229 1 return $self->_error( $@->message );
230 } else {
231 0 return $self->_error( $errstr );
232 }
233 }
234  
235 15658 return $Document;
236 }
237  
238  
239  
240  
241  
242 #####################################################################
243 # Lex Methods - Document Object
244  
245 sub _lex_document {
246 15659 ▶ my ($self, $Document) = @_;
Subroutine _lex_document: called CC=13 SCAR=26.6
247 # my $self = shift;
248 # my $Document = _INSTANCE(shift, 'PPI::Document') or return undef;
249  
250 # Start the processing loop
251 15659 my $Token;
252 15659 ▶ while ( ref($Token = $self->_get_token) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Token = $self->_get_token)) 47809 15658 63467
253 # Add insignificant tokens directly beneath us
254 47809 ▶ unless ( $Token->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Token->significant) 18424 29385 47809
255 18424 $self->_add_element( $Document, $Token );
256 18424 next;
257 }
258  
259 29385 ▶ if ( $Token->content eq ';' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->content eq ";") 273 29112 29385
260 # It's a semi-colon on it's own.
261 # We call this a null statement.
262 273 $self->_add_element(
263 $Document,
264 PPI::Statement::Null->new($Token),
265 );
266 273 next;
267 }
268  
269 # Handle anything other than a structural element
270 29112 ▶ unless ( ref $Token eq 'PPI::Token::Structure' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $Token eq "PPI::Token::Structure") 26507 2605 29112
271 # Determine the class for the Statement, and create it
272 26507 my $Statement = $self->_statement($Document, $Token)->new($Token);
273  
274 # Move the lexing down into the statement
275 26507 $self->_add_delayed( $Document );
276 26507 $self->_add_element( $Document, $Statement );
277 26507 $self->_lex_statement( $Statement );
278  
279 26507 next;
280 }
281  
282 # Is this the opening of a structure?
283 2605 ▶ if ( $Token->__LEXER__opens ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->__LEXER__opens) 955 1650 2605
284 # This should actually have a Statement instead
285 955 $self->_rollback( $Token );
286 955 my $Statement = PPI::Statement->new;
287 955 $self->_add_element( $Document, $Statement );
288 955 $self->_lex_statement( $Statement );
289 955 next;
290 }
291  
292 # Is this the close of a structure.
293 1650 ▶ if ( $Token->__LEXER__closes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->__LEXER__closes) 1650 0 1650
294 # Because we are at the top of the tree, this is an error.
295 # This means either a mis-parsing, or a mistake in the code.
296 # To handle this, we create a "Naked Close" statement
297 1650 $self->_add_element( $Document,
298 PPI::Statement::UnmatchedBrace->new($Token)
299 );
300 1650 next;
301 }
302  
303 # Shouldn't be able to get here
304 0 PPI::Exception->throw('Lexer reached an illegal state');
305 }
306  
307 # Did we leave the main loop because of a Tokenizer error?
308 15658 ▶ unless ( defined $Token ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Token) 0 15658 15658
309 0 ▶ my $errstr = $self->{Tokenizer} ? $self->{Tokenizer}->errstr : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'Tokenizer'} ? : 0 0 0
310 0 ▶ $errstr ||= 'Unknown Tokenizer Error';
Condition0%0/2
$errstr ||= "Unknown Tokenizer Error"
l!l
00
MC/DC0%0/1
$errstr ||= "Unknown Tokenizer Error"
$errstr
Truth table0%0/2
A
A= $errstr
Aresult
11
00
311 0 PPI::Exception->throw($errstr);
312 }
313  
314 # No error, it's just the end of file.
315 # Add any insignificant trailing tokens.
316 15658 $self->_add_delayed( $Document );
317  
318 # If the Tokenizer has any v6 blocks to attach, do so now.
319 # Checking once at the end is faster than adding a special
320 # case check for every statement parsed.
321 15658 my $perl6 = $self->{Tokenizer}->{'perl6'};
322 15658 ▶ if ( @$perl6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$perl6) 2 15656 15658
323 2 my $includes = $Document->find( 'PPI::Statement::Include::Perl6' );
324 2 foreach my $include ( @$includes ) {
325 2 ▶ unless ( @$perl6 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$perl6) 0 2 2
326 0 PPI::Exception->throw('Failed to find a perl6 section');
327 }
328 2 $include->{perl6} = shift @$perl6;
329 }
330 }
331  
332 15658 return 1;
333 }
334  
335  
336  
337  
338  
339 #####################################################################
340 # Lex Methods - Statement Object
341  
342 62 ▶use vars qw{%STATEMENT_CLASSES};
Subroutine BEGIN: called CC=1 SCAR=0.0
343 BEGIN {
344 # Keyword -> Statement Subclass
345 62 ▶ %STATEMENT_CLASSES = (
Subroutine BEGIN: called CC=1 SCAR=0.0
346 # Things that affect the timing of execution
347 'BEGIN' => 'PPI::Statement::Scheduled',
348 'CHECK' => 'PPI::Statement::Scheduled',
349 'UNITCHECK' => 'PPI::Statement::Scheduled',
350 'INIT' => 'PPI::Statement::Scheduled',
351 'END' => 'PPI::Statement::Scheduled',
352  
353 # Special subroutines for which 'sub' is optional
354 'AUTOLOAD' => 'PPI::Statement::Sub',
355 'DESTROY' => 'PPI::Statement::Sub',
356  
357 # Loading and context statement
358 'package' => 'PPI::Statement::Package',
359 # 'use' => 'PPI::Statement::Include',
360 'no' => 'PPI::Statement::Include',
361 'require' => 'PPI::Statement::Include',
362  
363 # Various declarations
364 'my' => 'PPI::Statement::Variable',
365 'local' => 'PPI::Statement::Variable',
366 'our' => 'PPI::Statement::Variable',
367 'state' => 'PPI::Statement::Variable',
368 # Statements starting with 'sub' could be any one of...
369 # 'sub' => 'PPI::Statement::Sub',
370 # 'sub' => 'PPI::Statement::Scheduled',
371 # 'sub' => 'PPI::Statement',
372  
373 # Compound statement
374 'if' => 'PPI::Statement::Compound',
375 'unless' => 'PPI::Statement::Compound',
376 'for' => 'PPI::Statement::Compound',
377 'foreach' => 'PPI::Statement::Compound',
378 'while' => 'PPI::Statement::Compound',
379 'until' => 'PPI::Statement::Compound',
380  
381 # Switch statement
382 'given' => 'PPI::Statement::Given',
383 'when' => 'PPI::Statement::When',
384 'default' => 'PPI::Statement::When',
385  
386 # Various ways of breaking out of scope
387 'redo' => 'PPI::Statement::Break',
388 'next' => 'PPI::Statement::Break',
389 'last' => 'PPI::Statement::Break',
390 'return' => 'PPI::Statement::Break',
391 'goto' => 'PPI::Statement::Break',
392  
393 # Special sections of the file
394 '__DATA__' => 'PPI::Statement::Data',
395 '__END__' => 'PPI::Statement::End',
396 );
397 }
398  
399 sub _statement {
400 51139 ▶ my ($self, $Parent, $Token) = @_;
Subroutine _statement: called CC=37 SCAR=36.2
401 # my $self = shift;
402 # my $Parent = _INSTANCE(shift, 'PPI::Node') or die "Bad param 1";
403 # my $Token = _INSTANCE(shift, 'PPI::Token') or die "Bad param 2";
404  
405 # Check for things like ( parent => ... )
406 51139 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Structure::List") or $Parent->isa("PPI::Structure::Constructor")) 7268 43871 51139
Condition100%3/3
$Parent->isa("PPI::Structure::List") or $Parent->isa("PPI::Structure::Constructor")
l!l&&r!l&&!r
5153211543871
MC/DC100%2/2
$Parent->isa("PPI::Structure::List") or $Parent->isa("PPI::Structure::Constructor")
$Parent->isa("PPI::Structure::List") $Parent->isa("PPI::Structure::Constructor")
Truth table100%3/3
A or B
A= $Parent->isa("PPI::Structure::List")B= $Parent->isa("PPI::Structure::Constructor")
ABresult
1X1
011
000
407 $Parent->isa('PPI::Structure::List')
408 or
409 $Parent->isa('PPI::Structure::Constructor')
410 ) {
411 7268 ▶ if ( $Token->isa('PPI::Token::Word') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->isa("PPI::Token::Word")) 1648 5620 7268
412 # Is the next significant token a =>
413 # Read ahead to the next significant token
414 1648 my $Next;
415 1648 ▶ while ( $Next = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next = $self->_get_token) 2218 47 2265
416 2218 ▶ unless ( $Next->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Next->significant) 617 1601 2218
417 617 push @{$self->{delayed}}, $Next;
418 # $self->_delay_element( $Next );
419 617 next;
420 }
421  
422 # Got the next token
423 1601 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Next->isa('PPI::Token::Operator') and $Next->content eq '=>') { } 849 752 1601
Condition100%3/3
$Next->isa("PPI::Token::Operator") and $Next->content eq "=>"
!ll&&!rl&&r
511241849
MC/DC100%2/2
$Next->isa("PPI::Token::Operator") and $Next->content eq "=>"
$Next->isa("PPI::Token::Operator") $Next->content eq "=>"
Truth table100%3/3
A and B
A= $Next->isa("PPI::Token::Operator")B= $Next->content eq "=>"
ABresult
0X0
100
111
424 $Next->isa('PPI::Token::Operator')
425 and
426 $Next->content eq '=>'
427 ) {
428 # Is an ordinary expression
429 849 $self->_rollback( $Next );
430 849 return 'PPI::Statement::Expression';
431 } else {
432 752 last;
433 }
434 }
435  
436 # Rollback and continue
437 799 $self->_rollback( $Next );
438 }
439 }
440  
441 # Is it a token in our known classes list
442 50290 my $class = $STATEMENT_CLASSES{$Token->content};
443 50290 ▶ if ( $class ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class) 9142 41148 50290
444 # Is the next significant token a =>
445 # Read ahead to the next significant token
446 9142 my $Next;
447 9142 ▶ while ( $Next = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next = $self->_get_token) 17930 47 17977
448 17930 ▶ if ( !$Next->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Next->significant) 8835 9095 17930
449 8835 push @{$self->{delayed}}, $Next;
450 8835 next;
451 }
452  
453 last if
454 9095 ▶ !$Next->isa( 'PPI::Token::Operator' ) or $Next->content ne '=>';
Branch: 1 branch
BranchTrueFalseTotal
if not $Next->isa("PPI::Token::Operator") or $Next->content ne "=>" 9074 21 9095
Condition100%3/3
not $Next->isa("PPI::Token::Operator") or $Next->content ne "=>"
l!l&&r!l&&!r
90571721
MC/DC100%2/2
not $Next->isa("PPI::Token::Operator") or $Next->content ne "=>"
not $Next->isa("PPI::Token::Operator") $Next->content ne "=>"
Truth table100%3/3
not(A) or B
A= not $Next->isa("PPI::Token::Operator")B= $Next->content ne "=>"
ABresult
1X1
011
000
455  
456 # Got the next token
457 # Is an ordinary expression
458 21 $self->_rollback( $Next );
459 21 return 'PPI::Statement';
460 }
461  
462 # Rollback and continue
463 9121 $self->_rollback( $Next );
464 }
465  
466 # Handle potential barewords for subscripts
467 50269 ▶ if ( $Parent->isa('PPI::Structure::Subscript') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Structure::Subscript")) 3660 46609 50269
468 # Fast obvious case, just an expression
469 3660 ▶ unless ( $class and $class->isa('PPI::Statement::Expression') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class and $class->isa("PPI::Statement::Expression")) 3537 123 3660
Condition100%3/3
$class and $class->isa("PPI::Statement::Expression")
!ll&&!rl&&r
350730123
MC/DC100%2/2
$class and $class->isa("PPI::Statement::Expression")
$class $class->isa("PPI::Statement::Expression")
Truth table100%3/3
A and B
A= $classB= $class->isa("PPI::Statement::Expression")
ABresult
0X0
100
111
470 3537 return 'PPI::Statement::Expression';
471 }
472  
473 # This is something like "my" or "our" etc... more subtle.
474 # Check if the next token is a closing curly brace.
475 # This means we are something like $h{my}
476 123 my $Next;
477 123 ▶ while ( $Next = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next = $self->_get_token) 119 4 123
478 119 ▶ unless ( $Next->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Next->significant) 0 119 119
479 0 push @{$self->{delayed}}, $Next;
480 # $self->_delay_element( $Next );
481 0 next;
482 }
483  
484 # Found the next significant token.
485 # Is it a closing curly brace?
486 119 ▶ if ( $Next->content eq '}' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next->content eq '}') { } 119 0 119
487 119 $self->_rollback( $Next );
488 119 return 'PPI::Statement::Expression';
489 } else {
490 0 $self->_rollback( $Next );
491 0 return $class;
492 }
493 }
494  
495 # End of file... this means it is something like $h{our
496 # which is probably going to be $h{our} ... I think
497 4 $self->_rollback( $Next );
498 4 return 'PPI::Statement::Expression';
499 }
500  
501 # If it's a token in our list, use that class
502 46609 ▶ return $class if $class;
Branch: 1 branch
BranchTrueFalseTotal
if $class 8968 37641 46609
503  
504 # Handle the more in-depth sub detection
505 37641 ▶ if ( $Token->content eq 'sub' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->content eq "sub") 3271 34370 37641
506 # Read ahead to the next significant token
507 3271 my $Next;
508 3271 ▶ while ( $Next = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next = $self->_get_token) 6483 24 6507
509 6483 ▶ unless ( $Next->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Next->significant) 3236 3247 6483
510 3236 push @{$self->{delayed}}, $Next;
511 # $self->_delay_element( $Next );
512 3236 next;
513 }
514  
515 # Got the next significant token
516 3247 my $sclass = $STATEMENT_CLASSES{$Next->content};
517 3247 ▶ if ( $sclass and $sclass eq 'PPI::Statement::Scheduled' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sclass and $sclass eq "PPI::Statement::Scheduled") 28 3219 3247
Condition100%3/3
$sclass and $sclass eq "PPI::Statement::Scheduled"
!ll&&!rl&&r
300921028
MC/DC100%2/2
$sclass and $sclass eq "PPI::Statement::Scheduled"
$sclass $sclass eq "PPI::Statement::Scheduled"
Truth table100%3/3
A and B
A= $sclassB= $sclass eq "PPI::Statement::Scheduled"
ABresult
0X0
100
111
518 28 $self->_rollback( $Next );
519 28 return 'PPI::Statement::Scheduled';
520 }
521 3219 ▶ if ( $Next->isa('PPI::Token::Word') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next->isa("PPI::Token::Word")) 3090 129 3219
522 3090 $self->_rollback( $Next );
523 3090 return 'PPI::Statement::Sub';
524 }
525  
526 ### Comment out these two, as they would return PPI::Statement anyway
527 # if ( $content eq '{' ) {
528 # Anonymous sub at start of statement
529 # return 'PPI::Statement';
530 # }
531 #
532 # if ( $Next->isa('PPI::Token::Prototype') ) {
533 # Anonymous sub at start of statement
534 # return 'PPI::Statement';
535 # }
536  
537 # PPI::Statement is the safest fall-through
538 129 $self->_rollback( $Next );
539 129 return 'PPI::Statement';
540 }
541  
542 # End of file... PPI::Statement::Sub is the most likely
543 24 $self->_rollback( $Next );
544 24 return 'PPI::Statement::Sub';
545 }
546  
547 34370 ▶ if ( $Token->content eq 'use' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->content eq "use") 2344 32026 34370
548 # Add a special case for "use v6" lines.
549 2344 my $Next;
550 2344 ▶ while ( $Next = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next = $self->_get_token) 4683 2 4685
551 4683 ▶ unless ( $Next->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Next->significant) 2341 2342 4683
552 2341 push @{$self->{delayed}}, $Next;
553 # $self->_delay_element( $Next );
554 2341 next;
555 }
556  
557 # Found the next significant token.
558 2342 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($Next->isa('PPI::Token::Operator') and $Next->content eq '=>') { } 1 2341 2342
elsif ($Next->content eq 'v6') { } 2 2339 2341
Condition66%2/3
$Next->isa("PPI::Token::Operator") and $Next->content eq "=>"
!ll&&!rl&&r
234101
MC/DC50%1/2
$Next->isa("PPI::Token::Operator") and $Next->content eq "=>"
$Next->isa("PPI::Token::Operator") $Next->content eq "=>"
Truth table66%2/3
A and B
A= $Next->isa("PPI::Token::Operator")B= $Next->content eq "=>"
ABresult
0X0
100
111
559 $Next->isa('PPI::Token::Operator')
560 and
561 $Next->content eq '=>'
562 ) {
563 # Is an ordinary expression
564 1 $self->_rollback( $Next );
565 1 return 'PPI::Statement';
566 # Is it a v6 use?
567 } elsif ( $Next->content eq 'v6' ) {
568 2 $self->_rollback( $Next );
569 2 return 'PPI::Statement::Include::Perl6';
570 } else {
571 2339 $self->_rollback( $Next );
572 2339 return 'PPI::Statement::Include';
573 }
574 }
575  
576 # End of file... this means it is an incomplete use
577 # line, just treat it as a normal include.
578 2 $self->_rollback( $Next );
579 2 return 'PPI::Statement::Include';
580 }
581  
582 # If our parent is a Condition, we are an Expression
583 32026 ▶ if ( $Parent->isa('PPI::Structure::Condition') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Structure::Condition")) 1164 30862 32026
584 1164 return 'PPI::Statement::Expression';
585 }
586  
587 # If our parent is a List, we are also an expression
588 30862 ▶ if ( $Parent->isa('PPI::Structure::List') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Structure::List")) 4829 26033 30862
589 4829 return 'PPI::Statement::Expression';
590 }
591  
592 # Switch statements use expressions, as well.
593 26033 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Structure::Given") or $Parent->isa("PPI::Structure::When")) 6 26027 26033
Condition100%3/3
$Parent->isa("PPI::Structure::Given") or $Parent->isa("PPI::Structure::When")
l!l&&r!l&&!r
3326027
MC/DC100%2/2
$Parent->isa("PPI::Structure::Given") or $Parent->isa("PPI::Structure::When")
$Parent->isa("PPI::Structure::Given") $Parent->isa("PPI::Structure::When")
Truth table100%3/3
A or B
A= $Parent->isa("PPI::Structure::Given")B= $Parent->isa("PPI::Structure::When")
ABresult
1X1
011
000
594 $Parent->isa('PPI::Structure::Given')
595 or
596 $Parent->isa('PPI::Structure::When')
597 ) {
598 6 return 'PPI::Statement::Expression';
599 }
600  
601 26027 ▶ if ( _INSTANCE($Token, 'PPI::Token::Label') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_INSTANCE($Token, "PPI::Token::Label")) 340 25687 26027
602 340 return 'PPI::Statement::Compound';
603 }
604  
605 # Beyond that, I have no idea for the moment.
606 # Just keep adding more conditions above this.
607 25687 return 'PPI::Statement';
608 }
609  
610 sub _lex_statement {
611 52536 ▶ my ($self, $Statement) = @_;
Subroutine _lex_statement: called CC=11 SCAR=24.0
612 # my $self = shift;
613 # my $Statement = _INSTANCE(shift, 'PPI::Statement') or die "Bad param 1";
614  
615 # Handle some special statements
616 52536 ▶ if ( $Statement->isa('PPI::Statement::End') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Statement->isa("PPI::Statement::End")) 8 52528 52536
617 8 return $self->_lex_end( $Statement );
618 }
619  
620 # Begin processing tokens
621 52528 my $Token;
622 52528 ▶ while ( ref( $Token = $self->_get_token ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Token = $self->_get_token)) 232864 10119 242983
623 # Delay whitespace and comment tokens
624 232864 ▶ unless ( $Token->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Token->significant) 84143 148721 232864
625 84143 push @{$self->{delayed}}, $Token;
626 # $self->_delay_element( $Token );
627 84143 next;
628 }
629  
630 # Structual closes, and __DATA__ and __END__ tags implicitly
631 # end every type of statement
632 148721 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->__LEXER__closes or $Token->isa("PPI::Token::Separator")) 16492 132229 148721
Condition66%2/3
$Token->__LEXER__closes or $Token->isa("PPI::Token::Separator")
l!l&&r!l&&!r
164920132229
MC/DC50%1/2
$Token->__LEXER__closes or $Token->isa("PPI::Token::Separator")
$Token->__LEXER__closes $Token->isa("PPI::Token::Separator")
Truth table66%2/3
A or B
A= $Token->__LEXER__closesB= $Token->isa("PPI::Token::Separator")
ABresult
1X1
011
000
633 $Token->__LEXER__closes
634 or
635 $Token->isa('PPI::Token::Separator')
636 ) {
637 # Rollback and end the statement
638 16492 return $self->_rollback( $Token );
639 }
640  
641 # Normal statements never implicitly end
642 132229 ▶ unless ( $Statement->__LEXER__normal ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Statement->__LEXER__normal) 24618 107611 132229
643 # Have we hit an implicit end to the statement
644 24618 ▶ unless ( $self->_continues( $Statement, $Token ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_continues($Statement, $Token)) 4456 20162 24618
645 # Rollback and finish the statement
646 4456 return $self->_rollback( $Token );
647 }
648 }
649  
650 # Any normal character just gets added
651 127773 ▶ unless ( $Token->isa('PPI::Token::Structure') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Token->isa("PPI::Token::Structure")) 85231 42542 127773
652 85231 $self->_add_element( $Statement, $Token );
653 85231 next;
654 }
655  
656 # Handle normal statement terminators
657 42542 ▶ if ( $Token->content eq ';' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->content eq ";") 21461 21081 42542
658 21461 $self->_add_element( $Statement, $Token );
659 21461 return 1;
660 }
661  
662 # Which leaves us with a new structure
663  
664 # Determine the class for the structure and create it
665 21081 my $method = $RESOLVE{$Token->content};
666 21081 my $Structure = $self->$method($Statement)->new($Token);
667  
668 # Move the lexing down into the Structure
669 21081 $self->_add_delayed( $Statement );
670 21081 $self->_add_element( $Statement, $Structure );
671 21081 $self->_lex_structure( $Structure );
672 }
673  
674 # Was it an error in the tokenizer?
675 10119 ▶ unless ( defined $Token ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Token) 0 10119 10119
676 0 PPI::Exception->throw;
677 }
678  
679 # No, it's just the end of the file...
680 # Roll back any insignificant tokens, they'll get added at the Document level
681 10119 $self->_rollback;
682 }
683  
684 sub _lex_end {
685 8 ▶ my ($self, $Statement) = @_;
Subroutine _lex_end: called CC=3 SCAR=11.1
686 # my $self = shift;
687 # my $Statement = _INSTANCE(shift, 'PPI::Statement::End') or die "Bad param 1";
688  
689 # End of the file, EVERYTHING is ours
690 8 my $Token;
691 8 ▶ while ( $Token = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token = $self->_get_token) 15 8 23
692 # Inlined $Statement->__add_element($Token);
693 Scalar::Util::weaken(
694 15 $_PARENT{Scalar::Util::refaddr $Token} = $Statement
695 );
696 15 push @{$Statement->{children}}, $Token;
697 }
698  
699 # Was it an error in the tokenizer?
700 8 ▶ unless ( defined $Token ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Token) 0 8 8
701 0 PPI::Exception->throw;
702 }
703  
704 # No, it's just the end of the file...
705 # Roll back any insignificant tokens, they get added at the Document level
706 8 $self->_rollback;
707 }
708  
709 # For many statements, it can be difficult to determine the end-point.
710 # This method takes a statement and the next significant token, and attempts
711 # to determine if the there is a statement boundary between the two, or if
712 # the statement can continue with the token.
713 sub _continues {
714 24618 ▶ my ($self, $Statement, $Token) = @_;
Subroutine _continues: called CC=64 SCAR=44.7
715 # my $self = shift;
716 # my $Statement = _INSTANCE(shift, 'PPI::Statement') or die "Bad param 1";
717 # my $Token = _INSTANCE(shift, 'PPI::Token') or die "Bad param 2";
718  
719 # Handle the simple block case
720 # { print 1; }
721 24618 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Statement->schildren == 1 and $Statement->schild(0)->isa("PPI::Structure::Block")) 53 24565 24618
Condition100%3/3
$Statement->schildren == 1 and $Statement->schild(0)->isa("PPI::Structure::Block")
!ll&&!rl&&r
16835773053
MC/DC100%2/2
$Statement->schildren == 1 and $Statement->schild(0)->isa("PPI::Structure::Block")
$Statement->schildren == 1 $Statement->schild(0)->isa("PPI::Structure::Block")
Truth table100%3/3
A and B
A= $Statement->schildren == 1B= $Statement->schild(0)->isa("PPI::Structure::Block")
ABresult
0X0
100
111
722 $Statement->schildren == 1
723 and
724 $Statement->schild(0)->isa('PPI::Structure::Block')
725 ) {
726 53 return '';
727 }
728  
729 # Alrighty then, there are six implied-end statement types:
730 # ::Scheduled blocks, ::Sub declarations, ::Compound, ::Given, ::When,
731 # and ::Package statements.
732 24565 ▶ return 1
Branch: 1 branch
BranchTrueFalseTotal
if ref !($Statement =~ /\b(?:Scheduled|Sub|Compound|Given|When|Package)$/) 0 24565 24565
733 if ref $Statement !~ /\b(?:Scheduled|Sub|Compound|Given|When|Package)$/;
734  
735 # Of these six, ::Scheduled, ::Sub, ::Given, and ::When follow the same
736 # simple rule and can be handled first. The block form of ::Package
737 # follows the rule, too. (The non-block form of ::Package
738 # requires a statement terminator, and thus doesn't need to have
739 # an implied end detected.)
740 24565 my @part = $Statement->schildren;
741 24565 my $LastChild = $part[-1];
742 # If the last significant element of the statement is a block,
743 # then an implied-end statement is done, no questions asked.
744 24565 ▶ return !$LastChild->isa('PPI::Structure::Block')
Branch: 1 branch
BranchTrueFalseTotal
unless $Statement->isa("PPI::Statement::Compound") 19361 5204 24565
745 if !$Statement->isa('PPI::Statement::Compound');
746  
747 # Now we get to compound statements, which kind of suck (to lex).
748 # However, of them all, the 'if' type, which includes unless, are
749 # relatively easy to handle compared to the others.
750 5204 my $type = $Statement->type;
751 5204 ▶ if ( $type eq 'if' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "if") 3231 1973 5204
752 # This should be one of the following
753 # if (EXPR) BLOCK
754 # if (EXPR) BLOCK else BLOCK
755 # if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
756  
757 # We only implicitly end on a block
758 3231 ▶ unless ( $LastChild->isa('PPI::Structure::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($LastChild->isa("PPI::Structure::Block")) 2225 1006 3231
759 # if (EXPR) ...
760 # if (EXPR) BLOCK else ...
761 # if (EXPR) BLOCK elsif (EXPR) BLOCK ...
762 2225 return 1;
763 }
764  
765 # If the token before the block is an 'else',
766 # it's over, no matter what.
767 1006 my $NextLast = $Statement->schild(-2);
768 1006 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($NextLast and $NextLast->isa("PPI::Token") and $NextLast->isa("PPI::Token::Word") and $NextLast->content eq "else") 75 931 1006
Condition66%6/9
$NextLast and $NextLast->isa("PPI::Token") and $NextLast->isa("PPI::Token::Word") and $NextLast->content eq "else"
!ll&&!rl&&r
931075
$NextLast and $NextLast->isa("PPI::Token") and $NextLast->isa("PPI::Token::Word")
!ll&&!rl&&r
931075
$NextLast and $NextLast->isa("PPI::Token")
!ll&&!rl&&r
093175
MC/DC25%1/4
$NextLast and $NextLast->isa("PPI::Token") and $NextLast->isa("PPI::Token::Word") and $NextLast->content eq "else"
$NextLast $NextLast->isa("PPI::Token") $NextLast->isa("PPI::Token::Word") $NextLast->content eq "else"
Truth table40%2/5
A and B and C and D
A= $NextLastB= $NextLast->isa("PPI::Token")C= $NextLast->isa("PPI::Token::Word")D= $NextLast->content eq "else"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
769 $NextLast
770 and
771 $NextLast->isa('PPI::Token')
772 and
773 $NextLast->isa('PPI::Token::Word')
774 and
775 $NextLast->content eq 'else'
776 ) {
777 75 return '';
778 }
779  
780 # Otherwise, we continue for 'elsif' or 'else' only.
781 931 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->isa("PPI::Token::Word") and $Token->content eq "else" || $Token->content eq "elsif") 291 640 931
Condition100%6/6
$Token->isa("PPI::Token::Word") and $Token->content eq "else" || $Token->content eq "elsif"
!ll&&!rl&&r
196537198
$Token->content eq "else" or $Token->content eq "elsif"
l!l&&r!l&&!r
145146444
MC/DC66%2/3
$Token->isa("PPI::Token::Word") and $Token->content eq "else" || $Token->content eq "elsif"
$Token->isa("PPI::Token::Word") $Token->content eq "else" $Token->content eq "elsif"
Truth table75%3/4
A and B or C
A= $Token->isa("PPI::Token::Word")B= $Token->content eq "else"C= $Token->content eq "elsif"
ABCresult
0XX0
1000
11X1
1011
782 $Token->isa('PPI::Token::Word')
783 and (
784 $Token->content eq 'else'
785 or
786 $Token->content eq 'elsif'
787 )
788 ) {
789 291 return 1;
790 }
791  
792 640 return '';
793 }
794  
795 1973 ▶ if ( $type eq 'label' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "label") 317 1656 1973
796 # We only have the label so far, could be any of
797 # LABEL while (EXPR) BLOCK
798 # LABEL while (EXPR) BLOCK continue BLOCK
799 # LABEL for (EXPR; EXPR; EXPR) BLOCK
800 # LABEL foreach VAR (LIST) BLOCK
801 # LABEL foreach VAR (LIST) BLOCK continue BLOCK
802 # LABEL BLOCK continue BLOCK
803  
804 # Handle cases with a word after the label
805 317 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->isa("PPI::Token::Word") and $Token->content =~ /^(?:while|until|for|foreach)$/) 38 279 317
Condition100%3/3
$Token->isa("PPI::Token::Word") and $Token->content =~ /^(?:while|until|for|foreach)$/
!ll&&!rl&&r
2691038
MC/DC100%2/2
$Token->isa("PPI::Token::Word") and $Token->content =~ /^(?:while|until|for|foreach)$/
$Token->isa("PPI::Token::Word") $Token->content =~ /^(?:while|until|for|foreach)$/
Truth table100%3/3
A and B
A= $Token->isa("PPI::Token::Word")B= $Token->content =~ /^(?:while|until|for|foreach)$/
ABresult
0X0
100
111
806 $Token->isa('PPI::Token::Word')
807 and
808 $Token->content =~ /^(?:while|until|for|foreach)$/
809 ) {
810 38 return 1;
811 }
812  
813 # Handle labelled blocks
814 279 ▶ if ( $Token->isa('PPI::Token::Structure') && $Token->content eq '{' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->isa("PPI::Token::Structure") and $Token->content eq "{") 201 78 279
Condition100%3/3
$Token->isa("PPI::Token::Structure") and $Token->content eq "{"
!ll&&!rl&&r
753201
MC/DC100%2/2
$Token->isa("PPI::Token::Structure") and $Token->content eq "{"
$Token->isa("PPI::Token::Structure") $Token->content eq "{"
Truth table100%3/3
A and B
A= $Token->isa("PPI::Token::Structure")B= $Token->content eq "{"
ABresult
0X0
100
111
815 201 return 1;
816 }
817  
818 78 return '';
819 }
820  
821 # Handle the common "after round braces" case
822 1656 ▶ if ( $LastChild->isa('PPI::Structure') and $LastChild->braces eq '()' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Structure") and $LastChild->braces eq "()") 371 1285 1656
Condition100%3/3
$LastChild->isa("PPI::Structure") and $LastChild->braces eq "()"
!ll&&!rl&&r
854431371
MC/DC100%2/2
$LastChild->isa("PPI::Structure") and $LastChild->braces eq "()"
$LastChild->isa("PPI::Structure") $LastChild->braces eq "()"
Truth table100%3/3
A and B
A= $LastChild->isa("PPI::Structure")B= $LastChild->braces eq "()"
ABresult
0X0
100
111
823 # LABEL while (EXPR) ...
824 # LABEL while (EXPR) ...
825 # LABEL for (EXPR; EXPR; EXPR) ...
826 # LABEL for VAR (LIST) ...
827 # LABEL foreach VAR (LIST) ...
828 # Only a block will do
829 371 ▶ return $Token->isa('PPI::Token::Structure') && $Token->content eq '{';
Condition33%1/3
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
!ll&&!rl&&r
00371
MC/DC0%0/2
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
$Token->isa('PPI::Token::Structure') $Token->content eq '{'
Truth table33%1/3
A && B
A= $Token->isa('PPI::Token::Structure')B= $Token->content eq '{'
ABresult
0X0
100
111
830 }
831  
832 1285 ▶ if ( $type eq 'for' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "for") 124 1161 1285
833 # LABEL for (EXPR; EXPR; EXPR) BLOCK
834 124 ▶ if (
Branch: 3 branches
BranchTrueFalseTotal
if ($LastChild->isa('PPI::Token::Word') and $LastChild->content =~ /^for(?:each)?\z/) { } 111 13 124
elsif ($LastChild->isa('PPI::Structure::Block')) { } 13 0 13
elsif ($LastChild->isa('PPI::Token::QuoteLike::Words')) { } 0 0 0
Condition66%2/3
$LastChild->isa("PPI::Token::Word") and $LastChild->content =~ /^for(?:each)?\z/
!ll&&!rl&&r
130111
MC/DC50%1/2
$LastChild->isa("PPI::Token::Word") and $LastChild->content =~ /^for(?:each)?\z/
$LastChild->isa("PPI::Token::Word") $LastChild->content =~ /^for(?:each)?\z/
Truth table66%2/3
A and B
A= $LastChild->isa("PPI::Token::Word")B= $LastChild->content =~ /^for(?:each)?\z/
ABresult
0X0
100
111
835 $LastChild->isa('PPI::Token::Word')
836 and
837 $LastChild->content =~ /^for(?:each)?\z/
838 ) {
839 # LABEL for ...
840 111 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->isa("PPI::Token::Structure") and $Token->content eq "(" or $Token->isa("PPI::Token::QuoteLike::Words")) 17 94 111
Condition83%5/6
$Token->isa("PPI::Token::Structure") and $Token->content eq "(" or $Token->isa("PPI::Token::QuoteLike::Words")
l!l&&r!l&&!r
14394
$Token->isa("PPI::Token::Structure") and $Token->content eq "("
!ll&&!rl&&r
97014
MC/DC66%2/3
$Token->isa("PPI::Token::Structure") and $Token->content eq "(" or $Token->isa("PPI::Token::QuoteLike::Words")
$Token->isa("PPI::Token::Structure") $Token->content eq "(" $Token->isa("PPI::Token::QuoteLike::Words")
Truth table60%3/5
A and B or C
A= $Token->isa("PPI::Token::Structure")B= $Token->content eq "("C= $Token->isa("PPI::Token::QuoteLike::Words")
ABCresult
11X1
0X11
1011
0X00
1000
841 (
842 $Token->isa('PPI::Token::Structure')
843 and
844 $Token->content eq '('
845 )
846 or
847 $Token->isa('PPI::Token::QuoteLike::Words')
848 ) {
849 17 return 1;
850 }
851  
852 94 ▶ if ( $LastChild->isa('PPI::Token::QuoteLike::Words') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Token::QuoteLike::Words")) 0 94 94
853 # LABEL for VAR QW{} ...
854 # LABEL foreach VAR QW{} ...
855 # Only a block will do
856 0 ▶ return $Token->isa('PPI::Token::Structure') && $Token->content eq '{';
Condition0%0/3
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
!ll&&!rl&&r
000
MC/DC0%0/2
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
$Token->isa('PPI::Token::Structure') $Token->content eq '{'
Truth table0%0/3
A && B
A= $Token->isa('PPI::Token::Structure')B= $Token->content eq '{'
ABresult
0X0
100
111
857 }
858  
859 # In this case, we can also behave like a foreach
860 94 $type = 'foreach';
861  
862 } elsif ( $LastChild->isa('PPI::Structure::Block') ) {
863 # LABEL for (EXPR; EXPR; EXPR) BLOCK
864 # That's it, nothing can continue
865 13 return '';
866  
867 } elsif ( $LastChild->isa('PPI::Token::QuoteLike::Words') ) {
868 # LABEL for VAR QW{} ...
869 # LABEL foreach VAR QW{} ...
870 # Only a block will do
871 0 ▶ return $Token->isa('PPI::Token::Structure') && $Token->content eq '{';
Condition0%0/3
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
!ll&&!rl&&r
000
MC/DC0%0/2
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
$Token->isa('PPI::Token::Structure') $Token->content eq '{'
Truth table0%0/3
A && B
A= $Token->isa('PPI::Token::Structure')B= $Token->content eq '{'
ABresult
0X0
100
111
872 }
873 }
874  
875 # Handle the common continue case
876 1255 ▶ if ( $LastChild->isa('PPI::Token::Word') and $LastChild->content eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Token::Word") and $LastChild->content eq "continue") 6 1249 1255
Condition100%3/3
$LastChild->isa("PPI::Token::Word") and $LastChild->content eq "continue"
!ll&&!rl&&r
6406096
MC/DC100%2/2
$LastChild->isa("PPI::Token::Word") and $LastChild->content eq "continue"
$LastChild->isa("PPI::Token::Word") $LastChild->content eq "continue"
Truth table100%3/3
A and B
A= $LastChild->isa("PPI::Token::Word")B= $LastChild->content eq "continue"
ABresult
0X0
100
111
877 # LABEL while (EXPR) BLOCK continue ...
878 # LABEL foreach VAR (LIST) BLOCK continue ...
879 # LABEL BLOCK continue ...
880 # Only a block will do
881 6 ▶ return $Token->isa('PPI::Token::Structure') && $Token->content eq '{';
Condition33%1/3
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
!ll&&!rl&&r
006
MC/DC0%0/2
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
$Token->isa('PPI::Token::Structure') $Token->content eq '{'
Truth table33%1/3
A && B
A= $Token->isa('PPI::Token::Structure')B= $Token->content eq '{'
ABresult
0X0
100
111
882 }
883  
884 # Handle the common continuable block case
885 1249 ▶ if ( $LastChild->isa('PPI::Structure::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Structure::Block")) 418 831 1249
886 # LABEL while (EXPR) BLOCK
887 # LABEL while (EXPR) BLOCK ...
888 # LABEL for (EXPR; EXPR; EXPR) BLOCK
889 # LABEL foreach VAR (LIST) BLOCK
890 # LABEL foreach VAR (LIST) BLOCK ...
891 # LABEL BLOCK ...
892 # Is this the block for a continue?
893 418 ▶ if ( _INSTANCE($part[-2], 'PPI::Token::Word') and $part[-2]->content eq 'continue' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_INSTANCE($part[-2], "PPI::Token::Word") and $part[-2]->content eq "continue") 6 412 418
Condition66%2/3
&_INSTANCE($part[-2], "PPI::Token::Word") and $part[-2]->content eq "continue"
!ll&&!rl&&r
41206
MC/DC50%1/2
&_INSTANCE($part[-2], "PPI::Token::Word") and $part[-2]->content eq "continue"
&_INSTANCE($part[-2], "PPI::Token::Word") $part[-2]->content eq "continue"
Truth table66%2/3
A and B
A= &_INSTANCE($part[-2], "PPI::Token::Word")B= $part[-2]->content eq "continue"
ABresult
0X0
100
111
894 # LABEL while (EXPR) BLOCK continue BLOCK
895 # LABEL foreach VAR (LIST) BLOCK continue BLOCK
896 # LABEL BLOCK continue BLOCK
897 # That's it, nothing can continue this
898 6 return '';
899 }
900  
901 # Only a continue will do
902 412 ▶ return $Token->isa('PPI::Token::Word') && $Token->content eq 'continue';
Condition100%3/3
$Token->isa('PPI::Token::Word') && $Token->content eq 'continue'
!ll&&!rl&&r
2022046
MC/DC100%2/2
$Token->isa('PPI::Token::Word') && $Token->content eq 'continue'
$Token->isa('PPI::Token::Word') $Token->content eq 'continue'
Truth table100%3/3
A && B
A= $Token->isa('PPI::Token::Word')B= $Token->content eq 'continue'
ABresult
0X0
100
111
903 }
904  
905 831 ▶ if ( $type eq 'block' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "block") 0 831 831
906 # LABEL BLOCK continue BLOCK
907 # Every possible case is covered in the common cases above
908 }
909  
910 831 ▶ if ( $type eq 'while' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "while") 149 682 831
911 # LABEL while (EXPR) BLOCK
912 # LABEL while (EXPR) BLOCK continue BLOCK
913 # LABEL until (EXPR) BLOCK
914 # LABEL until (EXPR) BLOCK continue BLOCK
915 # The only case not covered is the while ...
916 149 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Token::Word") and $LastChild->content eq "while" || $LastChild->content eq "until") 149 0 149
Condition66%4/6
$LastChild->isa("PPI::Token::Word") and $LastChild->content eq "while" || $LastChild->content eq "until"
!ll&&!rl&&r
033116
$LastChild->content eq "while" or $LastChild->content eq "until"
l!l&&r!l&&!r
14180
MC/DC0%0/3
$LastChild->isa("PPI::Token::Word") and $LastChild->content eq "while" || $LastChild->content eq "until"
$LastChild->isa("PPI::Token::Word") $LastChild->content eq "while" $LastChild->content eq "until"
Truth table25%1/4
A and B or C
A= $LastChild->isa("PPI::Token::Word")B= $LastChild->content eq "while"C= $LastChild->content eq "until"
ABCresult
0XX0
1000
11X1
1011
917 $LastChild->isa('PPI::Token::Word')
918 and (
919 $LastChild->content eq 'while'
920 or
921 $LastChild->content eq 'until'
922 )
923 ) {
924 # LABEL while ...
925 # LABEL until ...
926 # Only a condition structure will do
927 149 ▶ return $Token->isa('PPI::Token::Structure') && $Token->content eq '(';
Condition33%1/3
$Token->isa('PPI::Token::Structure') && $Token->content eq '('
!ll&&!rl&&r
00149
MC/DC0%0/2
$Token->isa('PPI::Token::Structure') && $Token->content eq '('
$Token->isa('PPI::Token::Structure') $Token->content eq '('
Truth table33%1/3
A && B
A= $Token->isa('PPI::Token::Structure')B= $Token->content eq '('
ABresult
0X0
100
111
928 }
929 }
930  
931 682 ▶ if ( $type eq 'foreach' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "foreach") 682 0 682
932 # LABEL foreach VAR (LIST) BLOCK
933 # LABEL foreach VAR (LIST) BLOCK continue BLOCK
934 # The only two cases that have not been covered already are
935 # 'foreach ...' and 'foreach VAR ...'
936  
937 682 ▶ if ( $LastChild->isa('PPI::Token::Symbol') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Token::Symbol")) 197 485 682
938 # LABEL foreach my $scalar ...
939 # Open round brace, or a quotewords
940 197 ▶ return 1 if $Token->isa('PPI::Token::Structure') && $Token->content eq '(';
Branch: 1 branch
BranchTrueFalseTotal
if $Token->isa("PPI::Token::Structure") and $Token->content eq "(" 181 16 197
Condition66%2/3
$Token->isa("PPI::Token::Structure") and $Token->content eq "("
!ll&&!rl&&r
160181
MC/DC50%1/2
$Token->isa("PPI::Token::Structure") and $Token->content eq "("
$Token->isa("PPI::Token::Structure") $Token->content eq "("
Truth table66%2/3
A and B
A= $Token->isa("PPI::Token::Structure")B= $Token->content eq "("
ABresult
0X0
100
111
941 16 ▶ return 1 if $Token->isa('PPI::Token::QuoteLike::Words');
Branch: 1 branch
BranchTrueFalseTotal
if $Token->isa("PPI::Token::QuoteLike::Words") 16 0 16
942 0 return '';
943 }
944  
945 485 ▶ if ( $LastChild->content eq 'foreach' or $LastChild->content eq 'for' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->content eq "foreach" or $LastChild->content eq "for") 281 204 485
Condition100%3/3
$LastChild->content eq "foreach" or $LastChild->content eq "for"
l!l&&r!l&&!r
18794204
MC/DC100%2/2
$LastChild->content eq "foreach" or $LastChild->content eq "for"
$LastChild->content eq "foreach" $LastChild->content eq "for"
Truth table100%3/3
A or B
A= $LastChild->content eq "foreach"B= $LastChild->content eq "for"
ABresult
1X1
011
000
946 # There are three possibilities here
947 281 ▶ if (
Branch: 4 branches
BranchTrueFalseTotal
if ($Token->isa('PPI::Token::Word') and ($PPI::Lexer::STATEMENT_CLASSES{$Token->content} || '') eq 'PPI::Statement::Variable') { } 183 98 281
elsif ($Token->content =~ /^\$/) { } 34 64 98
elsif ($Token->isa('PPI::Token::Structure') and $Token->content eq '(') { } 55 9 64
elsif ($Token->isa('PPI::Token::QuoteLike::Words')) { } 6 3 9
Condition100%5/5
$Token->isa("PPI::Token::Word") and ($PPI::Lexer::STATEMENT_CLASSES{$Token->content} || "") eq "PPI::Statement::Variable"
!ll&&!rl&&r
962183
$PPI::Lexer::STATEMENT_CLASSES{$Token->content} || ''
l!l
1832
MC/DC100%2/2
$Token->isa("PPI::Token::Word") and ($PPI::Lexer::STATEMENT_CLASSES{$Token->content} || "") eq "PPI::Statement::Variable"
$Token->isa("PPI::Token::Word") $PPI::Lexer::STATEMENT_CLASSES{$Token->content}
Truth table100%3/3
A and B
A= $Token->isa("PPI::Token::Word")B= $PPI::Lexer::STATEMENT_CLASSES{$Token->content}
ABresult
0X0
100
111
948 $Token->isa('PPI::Token::Word')
949 and (
950 ($STATEMENT_CLASSES{ $Token->content } || '')
951 eq
952 'PPI::Statement::Variable'
953 )
954 ) {
955 # VAR == 'my ...'
956 183 return 1;
957 } elsif ( $Token->content =~ /^\$/ ) {
958 # VAR == '$scalar'
959 34 return 1;
960 ▶ } elsif ( $Token->isa('PPI::Token::Structure') and $Token->content eq '(' ) {
Condition66%2/3
$Token->isa("PPI::Token::Structure") and $Token->content eq "("
!ll&&!rl&&r
9055
MC/DC50%1/2
$Token->isa("PPI::Token::Structure") and $Token->content eq "("
$Token->isa("PPI::Token::Structure") $Token->content eq "("
Truth table66%2/3
A and B
A= $Token->isa("PPI::Token::Structure")B= $Token->content eq "("
ABresult
0X0
100
111
961 55 return 1;
962 } elsif ( $Token->isa('PPI::Token::QuoteLike::Words') ) {
963 6 return 1;
964 } else {
965 3 return '';
966 }
967 }
968  
969 204 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (($PPI::Lexer::STATEMENT_CLASSES{$LastChild->content} || "") eq "PPI::Statement::Variable") 179 25 204
Condition100%2/2
$PPI::Lexer::STATEMENT_CLASSES{$LastChild->content} || ''
l!l
17925
MC/DC100%1/1
$PPI::Lexer::STATEMENT_CLASSES{$LastChild->content} || ''
$PPI::Lexer::STATEMENT_CLASSES{$LastChild->content}
Truth table100%2/2
A
A= $PPI::Lexer::STATEMENT_CLASSES{$LastChild->content}
Aresult
11
00
970 ($STATEMENT_CLASSES{ $LastChild->content } || '')
971 eq
972 'PPI::Statement::Variable'
973 ) {
974 # LABEL foreach my ...
975 # Only a scalar will do
976 179 return $Token->content =~ /^\$/;
977 }
978  
979 # Handle the rare for my $foo qw{bar} ... case
980 25 ▶ if ( $LastChild->isa('PPI::Token::QuoteLike::Words') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LastChild->isa("PPI::Token::QuoteLike::Words")) 25 0 25
981 # LABEL for VAR QW ...
982 # LABEL foreach VAR QW ...
983 # Only a block will do
984 25 ▶ return $Token->isa('PPI::Token::Structure') && $Token->content eq '{';
Condition33%1/3
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
!ll&&!rl&&r
0025
MC/DC0%0/2
$Token->isa('PPI::Token::Structure') && $Token->content eq '{'
$Token->isa('PPI::Token::Structure') $Token->content eq '{'
Truth table33%1/3
A && B
A= $Token->isa('PPI::Token::Structure')B= $Token->content eq '{'
ABresult
0X0
100
111
985 }
986 }
987  
988 # Something we don't know about... what could it be
989 0 PPI::Exception->throw("Illegal state in '$type' compound statement");
990 }
991  
992  
993  
994  
995  
996 #####################################################################
997 # Lex Methods - Structure Object
998  
999 # Given a parent element, and a ( token to open a structure, determine
1000 # the class that the structure should be.
1001 sub _round {
1002 7551 ▶ my ($self, $Parent) = @_;
Subroutine _round: called CC=9 SCAR=22.0
1003 # my $self = shift;
1004 # my $Parent = _INSTANCE(shift, 'PPI::Node') or die "Bad param 1";
1005  
1006 # Get the last significant element in the parent
1007 7551 my $Element = $Parent->schild(-1);
1008 7551 ▶ if ( _INSTANCE($Element, 'PPI::Token::Word') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_INSTANCE($Element, "PPI::Token::Word")) 6071 1480 7551
1009 # Can it be determined because it is a keyword?
1010 6071 my $rclass = $ROUND{$Element->content};
1011 6071 ▶ return $rclass if $rclass;
Branch: 1 branch
BranchTrueFalseTotal
if $rclass 1264 4807 6071
1012 }
1013  
1014 # If we are part of a for or foreach statement, we are a ForLoop
1015 6287 ▶ if ( $Parent->isa('PPI::Statement::Compound') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($Parent->isa('PPI::Statement::Compound')) { } 181 6106 6287
elsif ($Parent->isa('PPI::Statement::Given')) { } 3 6103 6106
elsif ($Parent->isa('PPI::Statement::When')) { } 3 6100 6103
1016 181 ▶ if ( $Parent->type =~ /^for(?:each)?$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->type =~ /^for(?:each)?$/) 181 0 181
1017 181 return 'PPI::Structure::For';
1018 }
1019 } elsif ( $Parent->isa('PPI::Statement::Given') ) {
1020 3 return 'PPI::Structure::Given';
1021 } elsif ( $Parent->isa('PPI::Statement::When') ) {
1022 3 return 'PPI::Structure::When';
1023 }
1024  
1025 # Otherwise, it must be a list
1026  
1027 # If the previous element is -> then we mark it as a dereference
1028 6100 ▶ if ( _INSTANCE($Element, 'PPI::Token::Operator') and $Element->content eq '->' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_INSTANCE($Element, "PPI::Token::Operator") and $Element->content eq "->") 6 6094 6100
Condition100%3/3
&_INSTANCE($Element, "PPI::Token::Operator") and $Element->content eq "->"
!ll&&!rl&&r
55085866
MC/DC100%2/2
&_INSTANCE($Element, "PPI::Token::Operator") and $Element->content eq "->"
&_INSTANCE($Element, "PPI::Token::Operator") $Element->content eq "->"
Truth table100%3/3
A and B
A= &_INSTANCE($Element, "PPI::Token::Operator")B= $Element->content eq "->"
ABresult
0X0
100
111
1029 6 $Element->{_dereference} = 1;
1030 }
1031  
1032 'PPI::Structure::List'
1033 6100 }
1034  
1035 # Given a parent element, and a [ token to open a structure, determine
1036 # the class that the structure should be.
1037 sub _square {
1038 2798 ▶ my ($self, $Parent) = @_;
Subroutine _square: called CC=7 SCAR=19.5
1039 # my $self = shift;
1040 # my $Parent = _INSTANCE(shift, 'PPI::Node') or die "Bad param 1";
1041  
1042 # Get the last significant element in the parent
1043 2798 my $Element = $Parent->schild(-1);
1044  
1045 # Is this a subscript, like $foo[1] or $foo{expr}
1046
1047 2798 ▶ if ( $Element ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element) 2530 268 2798
1048 2530 ▶ if ( $Element->isa('PPI::Token::Operator') and $Element->content eq '->' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element->isa("PPI::Token::Operator") and $Element->content eq "->") 368 2162 2530
Condition100%3/3
$Element->isa("PPI::Token::Operator") and $Element->content eq "->"
!ll&&!rl&&r
11591003368
MC/DC100%2/2
$Element->isa("PPI::Token::Operator") and $Element->content eq "->"
$Element->isa("PPI::Token::Operator") $Element->content eq "->"
Truth table100%3/3
A and B
A= $Element->isa("PPI::Token::Operator")B= $Element->content eq "->"
ABresult
0X0
100
111
1049 # $foo->[]
1050 368 $Element->{_dereference} = 1;
1051 368 return 'PPI::Structure::Subscript';
1052 }
1053 2162 ▶ if ( $Element->isa('PPI::Structure::Subscript') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element->isa("PPI::Structure::Subscript")) 1 2161 2162
1054 # $foo{}[]
1055 1 return 'PPI::Structure::Subscript';
1056 }
1057 2161 ▶ if ( $Element->isa('PPI::Token::Symbol') and $Element->content =~ /^(?:\$|\@)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element->isa("PPI::Token::Symbol") and $Element->content =~ /^(?:\$|\@)/) 795 1366 2161
Condition100%3/3
$Element->isa("PPI::Token::Symbol") and $Element->content =~ /^(?:\$|\@)/
!ll&&!rl&&r
134125795
MC/DC100%2/2
$Element->isa("PPI::Token::Symbol") and $Element->content =~ /^(?:\$|\@)/
$Element->isa("PPI::Token::Symbol") $Element->content =~ /^(?:\$|\@)/
Truth table100%3/3
A and B
A= $Element->isa("PPI::Token::Symbol")B= $Element->content =~ /^(?:\$|\@)/
ABresult
0X0
100
111
1058 # $foo[], @foo[]
1059 795 return 'PPI::Structure::Subscript';
1060 }
1061 # FIXME - More cases to catch
1062 }
1063  
1064 # Otherwise, we assume that it's an anonymous arrayref constructor
1065 1634 'PPI::Structure::Constructor';
1066 }
1067  
1068 62 ▶use vars qw{%CURLY_CLASSES @CURLY_LOOKAHEAD_CLASSES};
Subroutine BEGIN: called CC=1 SCAR=0.0
1069 BEGIN {
1070 # Keyword -> Structure class maps
1071 62 ▶ %CURLY_CLASSES = (
Subroutine BEGIN: called CC=1 SCAR=0.0
1072 # Blocks
1073 'sub' => 'PPI::Structure::Block',
1074 'grep' => 'PPI::Structure::Block',
1075 'map' => 'PPI::Structure::Block',
1076 'sort' => 'PPI::Structure::Block',
1077 'do' => 'PPI::Structure::Block',
1078 # rely on 'continue' + block being handled elsewhere
1079 # rely on 'eval' + block being handled elsewhere
1080  
1081 # Hash constructors
1082 'scalar' => 'PPI::Structure::Constructor',
1083 '=' => 'PPI::Structure::Constructor',
1084 '||=' => 'PPI::Structure::Constructor',
1085 '&&=' => 'PPI::Structure::Constructor',
1086 '//=' => 'PPI::Structure::Constructor',
1087 '||' => 'PPI::Structure::Constructor',
1088 '&&' => 'PPI::Structure::Constructor',
1089 '//' => 'PPI::Structure::Constructor',
1090 '?' => 'PPI::Structure::Constructor',
1091 ':' => 'PPI::Structure::Constructor',
1092 ',' => 'PPI::Structure::Constructor',
1093 '=>' => 'PPI::Structure::Constructor',
1094 '+' => 'PPI::Structure::Constructor', # per perlref
1095 'return' => 'PPI::Structure::Constructor', # per perlref
1096 'bless' => 'PPI::Structure::Constructor', # pragmatic --
1097 # perlfunc says first arg is a reference, and
1098 # bless {; ... } fails to compile.
1099 );
1100  
1101 62 @CURLY_LOOKAHEAD_CLASSES = (
1102 {}, # not used
1103 {
1104 ';' => 'PPI::Structure::Block', # per perlref
1105 '}' => 'PPI::Structure::Constructor',
1106 },
1107 {
1108 '=>' => 'PPI::Structure::Constructor',
1109 },
1110 );
1111 }
1112  
1113  
1114 # Given a parent element, and a { token to open a structure, determine
1115 # the class that the structure should be.
1116 sub _curly {
1117 10732 ▶ my ($self, $Parent) = @_;
Subroutine _curly: called CC=31 SCAR=34.5
1118 # my $self = shift;
1119 # my $Parent = _INSTANCE(shift, 'PPI::Node') or die "Bad param 1";
1120  
1121 # Get the last significant element in the parent
1122 10732 my $Element = $Parent->schild(-1);
1123 10732 ▶ my $content = $Element ? $Element->content : '';
Branch: 1 branch
BranchTrueFalseTotal
$Element ? : 10122 610 10732
1124  
1125 # Is this a subscript, like $foo[1] or $foo{expr}
1126 10732 ▶ if ( $Element ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element) 10122 610 10732
1127 10122 ▶ if ( $content eq '->' and $Element->isa('PPI::Token::Operator') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content eq "->" and $Element->isa("PPI::Token::Operator")) 1951 8171 10122
Condition66%2/3
$content eq "->" and $Element->isa("PPI::Token::Operator")
!ll&&!rl&&r
817101951
MC/DC50%1/2
$content eq "->" and $Element->isa("PPI::Token::Operator")
$content eq "->" $Element->isa("PPI::Token::Operator")
Truth table66%2/3
A and B
A= $content eq "->"B= $Element->isa("PPI::Token::Operator")
ABresult
0X0
100
111
1128 # $foo->{}
1129 1951 $Element->{_dereference} = 1;
1130 1951 return 'PPI::Structure::Subscript';
1131 }
1132 8171 ▶ if ( $Element->isa('PPI::Structure::Subscript') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element->isa("PPI::Structure::Subscript")) 42 8129 8171
1133 # $foo[]{}
1134 42 return 'PPI::Structure::Subscript';
1135 }
1136 8129 ▶ if ( $content =~ /^(?:\$|\@)/ and $Element->isa('PPI::Token::Symbol') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ /^(?:\$|\@)/ and $Element->isa("PPI::Token::Symbol")) 511 7618 8129
Condition100%3/3
$content =~ /^(?:\$|\@)/ and $Element->isa("PPI::Token::Symbol")
!ll&&!rl&&r
7322296511
MC/DC100%2/2
$content =~ /^(?:\$|\@)/ and $Element->isa("PPI::Token::Symbol")
$content =~ /^(?:\$|\@)/ $Element->isa("PPI::Token::Symbol")
Truth table100%3/3
A and B
A= $content =~ /^(?:\$|\@)/B= $Element->isa("PPI::Token::Symbol")
ABresult
0X0
100
111
1137 # $foo{}, @foo{}
1138 511 return 'PPI::Structure::Subscript';
1139 }
1140 7618 ▶ if ( $Element->isa('PPI::Structure::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Element->isa("PPI::Structure::Block")) 3 7615 7618
1141 # deference - ${$hash_ref}{foo}
1142 # or even ${burfle}{foo}
1143 # hash slice - @{$hash_ref}{'foo', 'bar'}
1144 3 ▶ if ( my $prior = $Parent->schild(-2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $prior = $Parent->schild(-2)) 3 0 3
1145 3 my $prior_content = $prior->content();
1146 3 ▶ $prior->isa( 'PPI::Token::Cast' )
Branch: 1 branch
BranchTrueFalseTotal
$prior->isa("PPI::Token::Cast") and $prior_content eq "\@" || $prior_content eq "\$" and return "PPI::Structure::Subscript" 2 1 3
Condition66%4/6
$prior->isa("PPI::Token::Cast") and $prior_content eq "\@" || $prior_content eq "\$"
!ll&&!rl&&r
102
$prior_content eq "\@" or $prior_content eq "\$"
l!l&&r!l&&!r
110
MC/DC33%1/3
$prior->isa("PPI::Token::Cast") and $prior_content eq "\@" || $prior_content eq "\$"
$prior->isa("PPI::Token::Cast") $prior_content eq "\@" $prior_content eq "\$"
Truth table50%2/4
A and B or C
A= $prior->isa("PPI::Token::Cast")B= $prior_content eq "\@"C= $prior_content eq "\$"
ABCresult
0XX0
1000
11X1
1011
1147 and ( $prior_content eq '@' ||
1148 $prior_content eq '$' )
1149 and return 'PPI::Structure::Subscript';
1150 }
1151 }
1152  
1153 # Are we the last argument of sub?
1154 # E.g.: 'sub foo {}', 'sub foo ($) {}'
1155 7616 ▶ return 'PPI::Structure::Block' if $Parent->isa('PPI::Statement::Sub');
Branch: 1 branch
BranchTrueFalseTotal
if $Parent->isa("PPI::Statement::Sub") 2466 5150 7616
1156  
1157 # Are we the second or third argument of package?
1158 # E.g.: 'package Foo {}' or 'package Foo v1.2.3 {}'
1159 5150 ▶ return 'PPI::Structure::Block'
Branch: 1 branch
BranchTrueFalseTotal
if $Parent->isa("PPI::Statement::Package") 1293 3857 5150
1160 if $Parent->isa('PPI::Statement::Package');
1161  
1162 3857 ▶ if ( $CURLY_CLASSES{$content} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PPI::Lexer::CURLY_CLASSES{$content}) 783 3074 3857
1163 # Known type
1164 783 return $CURLY_CLASSES{$content};
1165 }
1166 }
1167  
1168 # Are we in a compound statement
1169 3684 ▶ if ( $Parent->isa('PPI::Statement::Compound') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Statement::Compound")) 1788 1896 3684
1170 # We will only encounter blocks in compound statements
1171 1788 return 'PPI::Structure::Block';
1172 }
1173  
1174 # Are we the second or third argument of use
1175 1896 ▶ if ( $Parent->isa('PPI::Statement::Include') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Statement::Include")) 53 1843 1896
1176 53 ▶ if ( $Parent->schildren == 2 ||
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->schildren == 2 or $Parent->schildren == 3 and $Parent->schild(2)->isa("PPI::Token::Number")) 53 0 53
Condition50%3/6
$Parent->schildren == 2 or $Parent->schildren == 3 and $Parent->schild(2)->isa("PPI::Token::Number")
l!l&&r!l&&!r
5210
$Parent->schildren == 3 and $Parent->schild(2)->isa("PPI::Token::Number")
!ll&&!rl&&r
001
MC/DC0%0/3
$Parent->schildren == 2 or $Parent->schildren == 3 and $Parent->schild(2)->isa("PPI::Token::Number")
$Parent->schildren == 2 $Parent->schildren == 3 $Parent->schild(2)->isa("PPI::Token::Number")
Truth table50%2/4
A or B and C
A= $Parent->schildren == 2B= $Parent->schildren == 3C= $Parent->schild(2)->isa("PPI::Token::Number")
ABCresult
1XX1
0111
00X0
0100
1177 $Parent->schildren == 3 &&
1178 $Parent->schild(2)->isa('PPI::Token::Number')
1179 ) {
1180 # This is something like use constant { ... };
1181 53 return 'PPI::Structure::Constructor';
1182 }
1183 }
1184  
1185 # Unless we are at the start of the statement, everything else should be a block
1186 ### FIXME This is possibly a bad choice, but will have to do for now.
1187 1843 ▶ return 'PPI::Structure::Block' if $Element;
Branch: 1 branch
BranchTrueFalseTotal
if $Element 1233 610 1843
1188  
1189 # Special case: Are we the param of a core function
1190 # i.e. map({ $_ => 1 } @foo)
1191 610 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($Parent->isa("PPI::Statement") and &_INSTANCE(scalar $Parent->parent, "PPI::Structure::List")) 145 465 610
Condition66%2/3
$Parent->isa("PPI::Statement") and &_INSTANCE(scalar $Parent->parent, "PPI::Structure::List")
!ll&&!rl&&r
0465145
MC/DC50%1/2
$Parent->isa("PPI::Statement") and &_INSTANCE(scalar $Parent->parent, "PPI::Structure::List")
$Parent->isa("PPI::Statement") &_INSTANCE(scalar $Parent->parent, "PPI::Structure::List")
Truth table66%2/3
A and B
A= $Parent->isa("PPI::Statement")B= &_INSTANCE(scalar $Parent->parent, "PPI::Structure::List")
ABresult
0X0
100
111
1192 $Parent->isa('PPI::Statement')
1193 and
1194 _INSTANCE($Parent->parent, 'PPI::Structure::List')
1195 ) {
1196 145 my $function = $Parent->parent->parent->schild(-2);
1197 145 ▶ if ( $function and $function->content =~ /^(?:map|grep|sort)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($function and $function->content =~ /^(?:map|grep|sort)$/) 63 82 145
Condition100%3/3
$function and $function->content =~ /^(?:map|grep|sort)$/
!ll&&!rl&&r
156763
MC/DC100%2/2
$function and $function->content =~ /^(?:map|grep|sort)$/
$function $function->content =~ /^(?:map|grep|sort)$/
Truth table100%3/3
A and B
A= $functionB= $function->content =~ /^(?:map|grep|sort)$/
ABresult
0X0
100
111
1198 63 return 'PPI::Structure::Block';
1199 }
1200 }
1201  
1202 # We need to scan ahead.
1203 547 my $Next;
1204 547 my $position = 0;
1205 547 my @delayed;
1206 547 ▶ while ( $Next = $self->_get_token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Next = $self->_get_token) 1323 103 1426
1207 1323 ▶ unless ( $Next->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Next->significant) 219 1104 1323
1208 219 push @delayed, $Next;
1209 219 next;
1210 }
1211  
1212 # If we are off the end of the lookahead array,
1213 1104 ▶ if ( ++$position >= @CURLY_LOOKAHEAD_CLASSES ) {
Branch: 2 branches
BranchTrueFalseTotal
if (++$position >= @PPI::Lexer::CURLY_LOOKAHEAD_CLASSES) { } 146 958 1104
elsif (my $class = $PPI::Lexer::CURLY_LOOKAHEAD_CLASSES[$position]{$Next->content}) { } 298 660 958
1214 # default to block.
1215 146 $self->_buffer( splice(@delayed), $Next );
1216 146 last;
1217 # If the content at this position is known
1218 } elsif ( my $class = $CURLY_LOOKAHEAD_CLASSES[$position]
1219 {$Next->content} ) {
1220 # return the associated class.
1221 298 $self->_buffer( splice(@delayed), $Next );
1222 298 return $class;
1223 }
1224  
1225 # Delay and continue
1226 660 push @delayed, $Next;
1227 }
1228  
1229 # Hit the end of the document, or bailed out, go with block
1230 249 $self->_buffer( splice(@delayed) );
1231 249 ▶ if ( ref $Parent eq 'PPI::Statement' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $Parent eq "PPI::Statement") 249 0 249
1232 249 bless $Parent, 'PPI::Statement::Compound';
1233 }
1234 249 return 'PPI::Structure::Block';
1235 }
1236  
1237  
1238 sub _lex_structure {
1239 21081 ▶ my ($self, $Structure) = @_;
Subroutine _lex_structure: called CC=10 SCAR=23.0
1240 # my $self = shift;
1241 # my $Structure = _INSTANCE(shift, 'PPI::Structure') or die "Bad param 1";
1242  
1243 # Start the processing loop
1244 21081 my $Token;
1245 21081 ▶ while ( ref($Token = $self->_get_token) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($Token = $self->_get_token)) 85996 1575 87571
1246 # Is this a direct type token
1247 85996 ▶ unless ( $Token->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Token->significant) 41369 44627 85996
1248 41369 push @{$self->{delayed}}, $Token;
1249 # $self->_delay_element( $Token );
1250 41369 next;
1251 }
1252  
1253 # Anything other than a Structure starts a Statement
1254 44627 ▶ unless ( $Token->isa('PPI::Token::Structure') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Token->isa("PPI::Token::Structure")) 24632 19995 44627
1255 # Because _statement may well delay and rollback itself,
1256 # we need to add the delayed tokens early
1257 24632 $self->_add_delayed( $Structure );
1258  
1259 # Determine the class for the Statement and create it
1260 24632 my $Statement = $self->_statement($Structure, $Token)->new($Token);
1261  
1262 # Move the lexing down into the Statement
1263 24632 $self->_add_element( $Structure, $Statement );
1264 24632 $self->_lex_statement( $Statement );
1265  
1266 24632 next;
1267 }
1268  
1269 # Is this the opening of another structure directly inside us?
1270 19995 ▶ if ( $Token->__LEXER__opens ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->__LEXER__opens) 442 19553 19995
1271 # Rollback the Token, and recurse into the statement
1272 442 $self->_rollback( $Token );
1273 442 my $Statement = PPI::Statement->new;
1274 442 $self->_add_element( $Structure, $Statement );
1275 442 $self->_lex_statement( $Statement );
1276 442 next;
1277 }
1278  
1279 # Is this the close of a structure ( which would be an error )
1280 19553 ▶ if ( $Token->__LEXER__closes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->__LEXER__closes) 19506 47 19553
1281 # Is this OUR closing structure
1282 19506 ▶ if ( $Token->content eq $Structure->start->__LEXER__opposite ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Token->content eq $Structure->start->__LEXER__opposite) 18952 554 19506
1283 # Add any delayed tokens, and the finishing token (the ugly way)
1284 18952 $self->_add_delayed( $Structure );
1285 18952 $Structure->{finish} = $Token;
1286 Scalar::Util::weaken(
1287 18952 $_PARENT{Scalar::Util::refaddr $Token} = $Structure
1288 );
1289  
1290 # Confirm that ForLoop structures are actually so, and
1291 # aren't really a list.
1292 18952 ▶ if ( $Structure->isa('PPI::Structure::For') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Structure->isa("PPI::Structure::For")) 228 18724 18952
1293 228 ▶ if ( 2 > scalar grep {
Branch: 1 branch
BranchTrueFalseTotal
if (2 > scalar grep({$_->isa("PPI::Statement");} $Structure->children)) 211 17 228
1294 594 $_->isa('PPI::Statement')
1295 } $Structure->children ) {
1296 211 bless($Structure, 'PPI::Structure::List');
1297 }
1298 }
1299 18952 return 1;
1300 }
1301  
1302 # Unmatched closing brace.
1303 # Either they typed the wrong thing, or haven't put
1304 # one at all. Either way it's an error we need to
1305 # somehow handle gracefully. For now, we'll treat it
1306 # as implicitly ending the structure. This causes the
1307 # least damage across the various reasons why this
1308 # might have happened.
1309 554 return $self->_rollback( $Token );
1310 }
1311  
1312 # It's a semi-colon on it's own, just inside the block.
1313 # This is a null statement.
1314 $self->_add_element(
1315 47 $Structure,
1316 PPI::Statement::Null->new($Token),
1317 );
1318 }
1319  
1320 # Is this an error
1321 1575 ▶ unless ( defined $Token ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Token) 0 1575 1575
1322 0 PPI::Exception->throw;
1323 }
1324  
1325 # No, it's just the end of file.
1326 # Add any insignificant trailing tokens.
1327 1575 $self->_add_delayed( $Structure );
1328 }
1329  
1330  
1331  
1332  
1333  
1334 #####################################################################
1335 # Support Methods
1336  
1337 # Get the next token for processing, handling buffering
1338 sub _get_token {
1339 427028 ▶ shift(@{$_[0]->{buffer}}) or $_[0]->{Tokenizer}->get_token;
Subroutine _get_token: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
shift @{$_[0]{"buffer"};} or $_[0]{"Tokenizer"}->get_token 351567 75461 427028
1340 }
1341  
1342 # Old long version of the above
1343 # my $self = shift;
1344 # # First from the buffer
1345 # if ( @{$self->{buffer}} ) {
1346 # return shift @{$self->{buffer}};
1347 # }
1348 #
1349 # # Then from the Tokenizer
1350 # $self->{Tokenizer}->get_token;
1351 # }
1352  
1353 # Delay the addition of insignificant elements.
1354 # This ended up being inlined.
1355 # sub _delay_element {
1356 # my $self = shift;
1357 # my $Element = _INSTANCE(shift, 'PPI::Element') or die "Bad param 1";
1358 # push @{ $_[0]->{delayed} }, $_[1];
1359 # }
1360  
1361 # Add an Element to a Node, including any delayed Elements
1362 sub _add_element {
1363 200703 ▶ my ($self, $Parent, $Element) = @_;
Subroutine _add_element: called CC=7 SCAR=20.9
1364 # my $self = shift;
1365 # my $Parent = _INSTANCE(shift, 'PPI::Node') or die "Bad param 1";
1366 # my $Element = _INSTANCE(shift, 'PPI::Element') or die "Bad param 2";
1367  
1368 # Handle a special case, where a statement is not fully resolved
1369 200703 ▶ if ( ref $Parent eq 'PPI::Statement'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $Parent eq "PPI::Statement" and my $first = $Parent->schild(0)) 55426 145277 200703
Condition100%3/3
ref $Parent eq "PPI::Statement" and my $first = $Parent->schild(0)
!ll&&!rl&&r
144129114855426
MC/DC100%2/2
ref $Parent eq "PPI::Statement" and my $first = $Parent->schild(0)
ref $Parent eq "PPI::Statement" my $first = $Parent->schild(0)
Truth table100%3/3
A and B
A= ref $Parent eq "PPI::Statement"B= my $first = $Parent->schild(0)
ABresult
0X0
100
111
1370 and my $first = $Parent->schild(0) ) {
1371 55426 ▶ if ( $first->isa('PPI::Token::Label')
Branch: 1 branch
BranchTrueFalseTotal
if ($first->isa("PPI::Token::Label") and not my $second = $Parent->schild(1)) 0 55426 55426
Condition33%1/3
$first->isa("PPI::Token::Label") and not my $second = $Parent->schild(1)
!ll&&!rl&&r
5542600
MC/DC0%0/2
$first->isa("PPI::Token::Label") and not my $second = $Parent->schild(1)
$first->isa("PPI::Token::Label") not my $second = $Parent->schild(1)
Truth table33%1/3
A and not(B)
A= $first->isa("PPI::Token::Label")B= not my $second = $Parent->schild(1)
ABresult
0X0
100
111
1372 and !(my $second = $Parent->schild(1)) ) {
1373 0 my $new_class = $STATEMENT_CLASSES{$second->content};
1374 # It's a labelled statement
1375 0 ▶ bless $Parent, $new_class if $new_class;
Branch: 1 branch
BranchTrueFalseTotal
if $new_class 0 0 0
1376 }
1377 }
1378  
1379 # Add first the delayed, from the front, then the passed element
1380 200703 foreach my $el ( @{$self->{delayed}} ) {
1381 Scalar::Util::weaken(
1382 53783 $_PARENT{Scalar::Util::refaddr $el} = $Parent
1383 );
1384 # Inlined $Parent->__add_element($el);
1385 }
1386 Scalar::Util::weaken(
1387 200703 $_PARENT{Scalar::Util::refaddr $Element} = $Parent
1388 );
1389 200703 push @{$Parent->{children}}, @{$self->{delayed}}, $Element;
1390  
1391 # Clear the delayed elements
1392 200703 $self->{delayed} = [];
1393 }
1394  
1395 # Specifically just add any delayed tokens, if any.
1396 sub _add_delayed {
1397 108405 ▶ my ($self, $Parent) = @_;
Subroutine _add_delayed: called CC=2 SCAR=6.9
1398 # my $self = shift;
1399 # my $Parent = _INSTANCE(shift, 'PPI::Node') or die "Bad param 1";
1400  
1401 # Add any delayed
1402 108405 foreach my $el ( @{$self->{delayed}} ) {
1403 Scalar::Util::weaken(
1404 51923 $_PARENT{Scalar::Util::refaddr $el} = $Parent
1405 );
1406 # Inlined $Parent->__add_element($el);
1407 }
1408 108405 push @{$Parent->{children}}, @{$self->{delayed}};
1409  
1410 # Clear the delayed elements
1411 108405 $self->{delayed} = [];
1412 }
1413  
1414 # Rollback the delayed tokens, plus any passed. Once all the tokens
1415 # have been moved back on to the buffer, the order should be.
1416 # <--- @{$self->{delayed}}, @_, @{$self->{buffer}} <----
1417 sub _rollback {
1418 49554 ▶ my $self = shift;
Subroutine _rollback: called CC=3 SCAR=11.0
1419  
1420 # First, put any passed objects back
1421 49554 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 39427 10127 49554
1422 39427 unshift @{$self->{buffer}}, splice @_;
1423 }
1424  
1425 # Then, put back anything delayed
1426 49554 ▶ if ( @{$self->{delayed}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"delayed"};}) 27613 21941 49554
1427 27613 unshift @{$self->{buffer}}, splice @{$self->{delayed}};
1428 }
1429  
1430 49554 1;
1431 }
1432  
1433 # Partial rollback, just return a single list to the buffer
1434 sub _buffer {
1435 693 ▶ my $self = shift;
Subroutine _buffer: called CC=2 SCAR=6.9
1436  
1437 # Put any passed objects back
1438 693 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 530 163 693
1439 530 unshift @{$self->{buffer}}, splice @_;
1440 }
1441  
1442 693 1;
1443 }
1444  
1445  
1446  
1447  
1448  
1449 #####################################################################
1450 # Error Handling
1451  
1452 # Set the error message
1453 sub _error {
1454 2 ▶ $errstr = $_[1];
Subroutine _error: called CC=1 SCAR=0.0
1455 2 undef;
1456 }
1457  
1458 # Clear the error message.
1459 # Returns the object as a convenience.
1460 sub _clear {
1461 15661 ▶ $errstr = '';
Subroutine _clear: called CC=1 SCAR=0.0
1462 15661 $_[0];
1463 }
1464  
1465 =pod
1466  
1467 =head2 errstr
1468  
1469 For any error that occurs, you can use the C<errstr>, as either
1470 a static or object method, to access the error message.
1471  
1472 If no error occurs for any particular action, C<errstr> will return false.
1473  
1474 =cut
1475  
1476 sub errstr {
1477 2 ▶ $errstr;
Subroutine errstr: called CC=1 SCAR=0.0
Pod documented
1478 }
1479  
1480  
1481  
1482  
1483  
1484 #####################################################################
1485 # PDOM Extensions
1486 #
1487 # This is something of a future expansion... ignore it for now :)
1488 #
1489 # use PPI::Statement::Sub ();
1490 #
1491 # sub PPI::Statement::Sub::__LEXER__normal { '' }
1492  
1493 62 1;
1494  
1495 =pod
1496  
1497 =head1 TO DO
1498  
1499 - Add optional support for some of the more common source filters
1500  
1501 - Some additional checks for blessing things into various Statement
1502 and Structure subclasses.
1503  
1504 =head1 SUPPORT
1505  
1506 See the L<support section|PPI/SUPPORT> in the main module.
1507  
1508 =head1 AUTHOR
1509  
1510 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
1511  
1512 =head1 COPYRIGHT
1513  
1514 Copyright 2001 - 2011 Adam Kennedy.
1515  
1516 This program is free software; you can redistribute
1517 it and/or modify it under the same terms as Perl itself.
1518  
1519 The full text of the license can be found in the
1520 LICENSE file included with this module.
1521  
1522 =cut
« PPI/Token/Whitespace.pm ↑ Summary PPI/Statement/Compound.pm »