← 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/Token/Control.pm
StatementsExecuted 14 statements in 563µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs24µsPPIx::Regexp::Token::Control::::BEGIN@39PPIx::Regexp::Token::Control::BEGIN@39
1117µs35µsPPIx::Regexp::Token::Control::::BEGIN@44PPIx::Regexp::Token::Control::BEGIN@44
1117µs12µsPPIx::Regexp::Token::Control::::BEGIN@40PPIx::Regexp::Token::Control::BEGIN@40
1117µs58µsPPIx::Regexp::Token::Control::::BEGIN@42PPIx::Regexp::Token::Control::BEGIN@42
0000s0sPPIx::Regexp::Token::Control::::__ANON__[:69]PPIx::Regexp::Token::Control::__ANON__[:69]
0000s0sPPIx::Regexp::Token::Control::::__ANON__[:84]PPIx::Regexp::Token::Control::__ANON__[:84]
0000s0sPPIx::Regexp::Token::Control::::__ANON__[:86]PPIx::Regexp::Token::Control::__ANON__[:86]
0000s0sPPIx::Regexp::Token::Control::::__PPIX_TOKENIZER__regexpPPIx::Regexp::Token::Control::__PPIX_TOKENIZER__regexp
0000s0sPPIx::Regexp::Token::Control::::__PPIX_TOKENIZER__replPPIx::Regexp::Token::Control::__PPIX_TOKENIZER__repl
0000s0sPPIx::Regexp::Token::Control::::perl_version_introducedPPIx::Regexp::Token::Control::perl_version_introduced
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::Token::Control - Case and quote control.
4
5=head1 SYNOPSIS
6
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{\Ufoo\E}smx' )
9 ->print();
10
11=head1 INHERITANCE
12
13C<PPIx::Regexp::Token::Control> is a
14L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15
16C<PPIx::Regexp::Token::Control> has no descendants.
17
18=head1 DESCRIPTION
19
20This class represents the case and quote controls. These apply when the
21regular expression is compiled, changing the actual expression
22generated. For example
23
24 print qr{\Ufoo\E}, "\n"
25
26prints
27
28 (?-xism:FOO)
29
30=head1 METHODS
31
32This class provides no public methods beyond those provided by its
33superclass.
34
35=cut
36
37package PPIx::Regexp::Token::Control;
38
39222µs236µs
# spent 24µs (12+12) within PPIx::Regexp::Token::Control::BEGIN@39 which was called: # once (12µs+12µs) by PPIx::Regexp::Tokenizer::BEGIN@23 at line 39
use strict;
# spent 24µs making 1 call to PPIx::Regexp::Token::Control::BEGIN@39 # spent 12µs making 1 call to strict::import
40221µs216µs
# spent 12µs (7+5) within PPIx::Regexp::Token::Control::BEGIN@40 which was called: # once (7µs+5µs) by PPIx::Regexp::Tokenizer::BEGIN@23 at line 40
use warnings;
# spent 12µs making 1 call to PPIx::Regexp::Token::Control::BEGIN@40 # spent 5µs making 1 call to warnings::import
41
42227µs2110µs
# spent 58µs (7+52) within PPIx::Regexp::Token::Control::BEGIN@42 which was called: # once (7µs+52µs) by PPIx::Regexp::Tokenizer::BEGIN@23 at line 42
use base qw{ PPIx::Regexp::Token };
# spent 58µs making 1 call to PPIx::Regexp::Token::Control::BEGIN@42 # spent 52µs making 1 call to base::import
43
441200ns
# spent 35µs (7+28) within PPIx::Regexp::Token::Control::BEGIN@44 which was called: # once (7µs+28µs) by PPIx::Regexp::Tokenizer::BEGIN@23 at line 46
use PPIx::Regexp::Constant qw{
45 COOKIE_QUOTE MINIMUM_PERL TOKEN_LITERAL TOKEN_UNKNOWN
461468µs263µs};
# spent 35µs making 1 call to PPIx::Regexp::Token::Control::BEGIN@44 # spent 28µs making 1 call to Exporter::import
47
4811µsour $VERSION = '0.036';
49
50# Return true if the token can be quantified, and false otherwise
51# sub can_be_quantified { return };
52
53{
5423µs my %version_introduced = (
55 '\\F' => '5.015008',
56 );
57
58 sub perl_version_introduced {
59 my ( $self ) = @_;
60 my $content = $self->content();
61 defined $version_introduced{$content}
62 and return $version_introduced{$content};
63 return MINIMUM_PERL;
64 }
65}
66
6719µsmy %is_control = map { $_ => 1 } qw{ l u L U Q E F };
68my %cookie = (
69 Q => sub { return 1; },
7014µs E => undef,
71);
72
73sub __PPIX_TOKENIZER__regexp {
74 my ( $class, $tokenizer, $character ) = @_;
75
76 # If we are inside a quote sequence, we want to make literals out of
77 # all the characters we reject; otherwise we just want to return
78 # nothing.
79 my $in_quote = $tokenizer->cookie( COOKIE_QUOTE );
80 my $reject = $in_quote ?
81 sub {
82 my ( $size, $class ) = @_;
83 return $tokenizer->make_token( $size, $class || TOKEN_LITERAL );
84 } : sub {
85 return;
86 };
87
88 # We are not interested in anything that is not escaped.
89 $character eq '\\' or return $reject->( 1 );
90
91 # We need to see what the next character is to figure out what to
92 # do. If there is no next character, we do not know what to call the
93 # back slash.
94 my $control = $tokenizer->peek( 1 )
95 or return $reject->( 1, TOKEN_UNKNOWN, {
96 error => 'Trailing back slash'
97 },
98 );
99
100 # We reject any escapes that do not represent controls.
101 $is_control{$control} or return $reject->( 2 );
102
103 # If we are quoting, we reject anything but an end quote.
104 $in_quote and $control ne 'E' and return $reject->( 2 );
105
106 # Anything left gets made into a token now, to avoid its processing
107 # by the cookie we may make.
108 my $token = $tokenizer->make_token( 2 );
109
110 # \Q and \E make and destroy cookies respectively; do those things.
111 exists $cookie{$control}
112 and $tokenizer->cookie( COOKIE_QUOTE, $cookie{$control} );
113
114 # Return our token.
115 return $token;
116}
117
118sub __PPIX_TOKENIZER__repl {
119 my ( $class, $tokenizer, $character ) = @_;
120
121 $tokenizer->interpolates() and goto &__PPIX_TOKENIZER__regexp;
122
123 return;
124}
125
12618µs1;
127
128__END__