← 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:14 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/Operator.pm
StatementsExecuted 13 statements in 275µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114µs28µsPPIx::Regexp::Token::Operator::::BEGIN@33PPIx::Regexp::Token::Operator::BEGIN@33
1118µs14µsPPIx::Regexp::Token::Operator::::BEGIN@34PPIx::Regexp::Token::Operator::BEGIN@34
1118µs31µsPPIx::Regexp::Token::Operator::::BEGIN@38PPIx::Regexp::Token::Operator::BEGIN@38
1118µs30µsPPIx::Regexp::Token::Operator::::BEGIN@39PPIx::Regexp::Token::Operator::BEGIN@39
1118µs74µsPPIx::Regexp::Token::Operator::::BEGIN@36PPIx::Regexp::Token::Operator::BEGIN@36
0000s0sPPIx::Regexp::Token::Operator::::__PPIX_TOKENIZER__regexpPPIx::Regexp::Token::Operator::__PPIX_TOKENIZER__regexp
0000s0sPPIx::Regexp::Token::Operator::::_treat_as_literalPPIx::Regexp::Token::Operator::_treat_as_literal
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::Operator - Represent an operator.
4
5=head1 SYNOPSIS
6
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{foo|bar}smx' )
9 ->print();
10
11=head1 INHERITANCE
12
13C<PPIx::Regexp::Token::Operator> is a
14L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15
16C<PPIx::Regexp::Token::Operator> has no descendants.
17
18=head1 DESCRIPTION
19
20This class represents an operator. In a character class, it represents
21the negation (C<^>) and range (C<->) operators. Outside a character
22class, it represents the alternation (C<|>) operator.
23
24=head1 METHODS
25
26This class provides no public methods beyond those provided by its
27superclass.
28
29=cut
30
31package PPIx::Regexp::Token::Operator;
32
33223µs242µs
# spent 28µs (14+14) within PPIx::Regexp::Token::Operator::BEGIN@33 which was called: # once (14µs+14µs) by PPIx::Regexp::Tokenizer::BEGIN@36 at line 33
use strict;
# spent 28µs making 1 call to PPIx::Regexp::Token::Operator::BEGIN@33 # spent 14µs making 1 call to strict::import
34225µs219µs
# spent 14µs (8+5) within PPIx::Regexp::Token::Operator::BEGIN@34 which was called: # once (8µs+5µs) by PPIx::Regexp::Tokenizer::BEGIN@36 at line 34
use warnings;
# spent 14µs making 1 call to PPIx::Regexp::Token::Operator::BEGIN@34 # spent 5µs making 1 call to warnings::import
35
36226µs2139µs
# spent 74µs (8+66) within PPIx::Regexp::Token::Operator::BEGIN@36 which was called: # once (8µs+66µs) by PPIx::Regexp::Tokenizer::BEGIN@36 at line 36
use base qw{ PPIx::Regexp::Token };
# spent 74µs making 1 call to PPIx::Regexp::Token::Operator::BEGIN@36 # spent 66µs making 1 call to base::import
37
38225µs254µs
# spent 31µs (8+23) within PPIx::Regexp::Token::Operator::BEGIN@38 which was called: # once (8µs+23µs) by PPIx::Regexp::Tokenizer::BEGIN@36 at line 38
use PPIx::Regexp::Constant qw{ TOKEN_LITERAL };
# spent 31µs making 1 call to PPIx::Regexp::Token::Operator::BEGIN@38 # spent 23µs making 1 call to Exporter::import
392168µs253µs
# spent 30µs (8+22) within PPIx::Regexp::Token::Operator::BEGIN@39 which was called: # once (8µs+22µs) by PPIx::Regexp::Tokenizer::BEGIN@36 at line 39
use PPIx::Regexp::Util qw{ __instance };
# spent 30µs making 1 call to PPIx::Regexp::Token::Operator::BEGIN@39 # spent 22µs making 1 call to Exporter::import
40
411600nsour $VERSION = '0.036';
42
43# Return true if the token can be quantified, and false otherwise
44# sub can_be_quantified { return };
45
46# These will be intercepted by PPIx::Regexp::Token::Literal if they are
47# really literals, so here we may process them unconditionally.
48
49# Note that if we receive a '-' we unconditionally make it an operator,
50# relying on the lexer to turn it back into a literal if necessary.
51
5213µsmy %operator = map { $_ => 1 } qw{ | - };
53
54sub _treat_as_literal {
55 my ( $token ) = @_;
56 return __instance( $token, 'PPIx::Regexp::Token::Literal' ) ||
57 __instance( $token, 'PPIx::Regexp::Token::Interpolation' );
58}
59
60sub __PPIX_TOKENIZER__regexp {
61 my ( $class, $tokenizer, $character ) = @_;
62
63 # We only receive the '-' if we are inside a character class. But it
64 # is only an operator if it is preceded and followed by literals. We
65 # can use prior() because there are no insignificant tokens inside a
66 # character class.
67 if ( $character eq '-' ) {
68
69 _treat_as_literal( $tokenizer->prior() )
70 or return $tokenizer->make_token( 1, TOKEN_LITERAL );
71
72 my @tokens = ( $tokenizer->make_token( 1 ) );
73 push @tokens, $tokenizer->get_token();
74
75 _treat_as_literal( $tokens[1] )
76 or bless $tokens[0], TOKEN_LITERAL;
77
78 return ( @tokens );
79 }
80
81 return $operator{$character};
82}
83
8414µs1;
85
86__END__