← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:13 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Structure/Regexp.pm
StatementsExecuted 8 statements in 207µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11115µs26µsPPIx::Regexp::Structure::Regexp::::BEGIN@34PPIx::Regexp::Structure::Regexp::BEGIN@34
1118µs12µsPPIx::Regexp::Structure::Regexp::::BEGIN@35PPIx::Regexp::Structure::Regexp::BEGIN@35
1116µs55µsPPIx::Regexp::Structure::Regexp::::BEGIN@37PPIx::Regexp::Structure::Regexp::BEGIN@37
0000s0sPPIx::Regexp::Structure::Regexp::::__PPIX_LEXER__finalizePPIx::Regexp::Structure::Regexp::__PPIX_LEXER__finalize
0000s0sPPIx::Regexp::Structure::Regexp::::can_be_quantifiedPPIx::Regexp::Structure::Regexp::can_be_quantified
0000s0sPPIx::Regexp::Structure::Regexp::::capture_namesPPIx::Regexp::Structure::Regexp::capture_names
0000s0sPPIx::Regexp::Structure::Regexp::::max_capture_numberPPIx::Regexp::Structure::Regexp::max_capture_number
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1=head1 NAME
2
3PPIx::Regexp::Structure::Regexp - Represent the top-level regular expression
4
5=head1 SYNOPSIS
6
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{foo}smx' )
9 ->print();
10
11=head1 INHERITANCE
12
13C<PPIx::Regexp::Structure::Regexp> is a
14L<PPIx::Regexp::Structure::Main|PPIx::Regexp::Structure::Main>.
15
16C<PPIx::Regexp::Structure::Regexp> has no descendants.
17
18=head1 DESCRIPTION
19
20This class represents the top-level regular expression. In the example
21given in the L</SYNOPSIS>, the C<{foo}> will be represented by this
22class.
23
24=head1 METHODS
25
26This class provides the following public methods. Methods not documented
27here are private, and unsupported in the sense that the author reserves
28the right to change or remove them without notice.
29
30=cut
31
32package PPIx::Regexp::Structure::Regexp;
33
34220µs238µs
# spent 26µs (15+11) within PPIx::Regexp::Structure::Regexp::BEGIN@34 which was called: # once (15µs+11µs) by PPIx::Regexp::Lexer::BEGIN@55 at line 34
use strict;
# spent 26µs making 1 call to PPIx::Regexp::Structure::Regexp::BEGIN@34 # spent 11µs making 1 call to strict::import
35223µs216µs
# spent 12µs (8+4) within PPIx::Regexp::Structure::Regexp::BEGIN@35 which was called: # once (8µs+4µs) by PPIx::Regexp::Lexer::BEGIN@55 at line 35
use warnings;
# spent 12µs making 1 call to PPIx::Regexp::Structure::Regexp::BEGIN@35 # spent 4µs making 1 call to warnings::import
36
372161µs2103µs
# spent 55µs (6+48) within PPIx::Regexp::Structure::Regexp::BEGIN@37 which was called: # once (6µs+48µs) by PPIx::Regexp::Lexer::BEGIN@55 at line 37
use base qw{ PPIx::Regexp::Structure::Main };
# spent 55µs making 1 call to PPIx::Regexp::Structure::Regexp::BEGIN@37 # spent 48µs making 1 call to base::import
38
391500nsour $VERSION = '0.036';
40
41sub can_be_quantified { return; }
42
43=head2 capture_names
44
45 foreach my $name ( $re->capture_names() ) {
46 print "Capture name '$name'\n";
47 }
48
49This method returns the capture names found in the regular expression.
50
51=cut
52
53sub capture_names {
54 my ( $self ) = @_;
55 my %name;
56 my $captures = $self->find(
57 'PPIx::Regexp::Structure::NamedCapture')
58 or return;
59 foreach my $grab ( @{ $captures } ) {
60 $name{$grab->name()}++;
61 }
62 return ( sort keys %name );
63}
64
65=head2 max_capture_number
66
67 print "Highest used capture number ",
68 $re->max_capture_number(), "\n";
69
70This method returns the highest capture number used by the regular
71expression. If there are no captures, the return will be 0.
72
73=cut
74
75sub max_capture_number {
76 my ( $self ) = @_;
77 return $self->{max_capture_number};
78}
79
80# Called by the lexer once it has done its worst to all the tokens.
81# Called as a method with no arguments. The return is the number of
82# parse failures discovered when finalizing.
83sub __PPIX_LEXER__finalize {
84 my ( $self ) = @_;
85 my $rslt = 0;
86 foreach my $elem ( $self->elements() ) {
87 $rslt += $elem->__PPIX_LEXER__finalize();
88 }
89
90 # Calculate the maximum capture group, and number all the other
91 # capture groups along the way.
92 $self->{max_capture_number} =
93 $self->__PPIX_LEXER__record_capture_number( 1 ) - 1;
94
95 return $rslt;
96}
97
9812µs1;
99
100__END__