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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Number/Exp.pm
StatementsExecuted 9 statements in 311µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11111µs22µsPPI::Token::Number::Exp::::BEGIN@31PPI::Token::Number::Exp::BEGIN@31
11110µs10µsPPI::Token::Number::Exp::::BEGIN@35PPI::Token::Number::Exp::BEGIN@35
1116µs33µsPPI::Token::Number::Exp::::BEGIN@34PPI::Token::Number::Exp::BEGIN@34
1113µs3µsPPI::Token::Number::Exp::::BEGIN@32PPI::Token::Number::Exp::BEGIN@32
0000s0sPPI::Token::Number::Exp::::__TOKENIZER__on_charPPI::Token::Number::Exp::__TOKENIZER__on_char
0000s0sPPI::Token::Number::Exp::::literalPPI::Token::Number::Exp::literal
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Token::Number::Exp;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::Number::Exp - Token class for an exponential notation number
8
9=head1 SYNOPSIS
10
11 $n = 1.0e-2;
12 $n = 1e+2;
13
14=head1 INHERITANCE
15
16 PPI::Token::Number::Exp
17 isa PPI::Token::Number::Float
18 isa PPI::Token::Number
19 isa PPI::Token
20 isa PPI::Element
21
22=head1 DESCRIPTION
23
24The C<PPI::Token::Number::Exp> class is used for tokens that
25represent floating point numbers with exponential notation.
26
27=head1 METHODS
28
29=cut
30
31218µs233µs
# spent 22µs (11+11) within PPI::Token::Number::Exp::BEGIN@31 which was called: # once (11µs+11µs) by PPI::Token::BEGIN@47 at line 31
use strict;
# spent 22µs making 1 call to PPI::Token::Number::Exp::BEGIN@31 # spent 11µs making 1 call to strict::import
32222µs13µs
# spent 3µs within PPI::Token::Number::Exp::BEGIN@32 which was called: # once (3µs+0s) by PPI::Token::BEGIN@47 at line 32
use PPI::Token::Number::Float ();
# spent 3µs making 1 call to PPI::Token::Number::Exp::BEGIN@32
33
34227µs260µs
# spent 33µs (6+27) within PPI::Token::Number::Exp::BEGIN@34 which was called: # once (6µs+27µs) by PPI::Token::BEGIN@47 at line 34
use vars qw{$VERSION @ISA};
# spent 33µs making 1 call to PPI::Token::Number::Exp::BEGIN@34 # spent 27µs making 1 call to vars::import
35
# spent 10µs within PPI::Token::Number::Exp::BEGIN@35 which was called: # once (10µs+0s) by PPI::Token::BEGIN@47 at line 38
BEGIN {
361300ns $VERSION = '1.215';
37110µs @ISA = 'PPI::Token::Number::Float';
381231µs110µs}
# spent 10µs making 1 call to PPI::Token::Number::Exp::BEGIN@35
39
40=pod
41
42=head2 literal
43
44Return the numeric value of this token.
45
46=cut
47
48sub literal {
49 my $self = shift;
50 return if $self->{_error};
51 my ($mantissa, $exponent) = split m/e/i, $self->_literal;
52 my $neg = $mantissa =~ s/^\-//;
53 $mantissa =~ s/^\./0./;
54 $exponent =~ s/^\+//;
55 my $val = $mantissa * 10 ** $exponent;
56 return $neg ? -$val : $val;
57}
58
- -
63#####################################################################
64# Tokenizer Methods
65
66sub __TOKENIZER__on_char {
67 my $class = shift;
68 my $t = shift;
69 my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
70
71 # To get here, the token must have already encountered an 'E'
72
73 # Allow underscores straight through
74 return 1 if $char eq '_';
75
76 # Allow digits
77 return 1 if $char =~ /\d/o;
78
79 # Start of exponent is special
80 if ( $t->{token}->{content} =~ /e$/i ) {
81 # Allow leading +/- in exponent
82 return 1 if $char eq '-' || $char eq '+';
83
84 # Invalid character in exponent. Recover
85 if ( $t->{token}->{content} =~ s/\.(e)$//i ) {
86 my $word = $1;
87 $t->{class} = $t->{token}->set_class('Number');
88 $t->_new_token('Operator', '.');
89 $t->_new_token('Word', $word);
90 return $t->{class}->__TOKENIZER__on_char( $t );
91 }
92 else {
93 $t->{token}->{_error} = "Illegal character in exponent '$char'";
94 }
95 }
96
97 # Doesn't fit a special case, or is after the end of the token
98 # End of token.
99 $t->_finalize_token->__TOKENIZER__on_char( $t );
100}
101
10212µs1;
103
104=pod
105
106=head1 SUPPORT
107
108See the L<support section|PPI/SUPPORT> in the main module.
109
110=head1 AUTHOR
111
112Chris Dolan E<lt>cdolan@cpan.orgE<gt>
113
114=head1 COPYRIGHT
115
116Copyright 2006 Chris Dolan.
117
118This program is free software; you can redistribute
119it and/or modify it under the same terms as Perl itself.
120
121The full text of the license can be found in the
122LICENSE file included with this module.
123
124=cut