Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/Greediness.pm |
Statements | Executed 11 statements in 289µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 17µs | 34µs | BEGIN@33 | PPIx::Regexp::Token::Greediness::
1 | 1 | 1 | 11µs | 17µs | BEGIN@34 | PPIx::Regexp::Token::Greediness::
1 | 1 | 1 | 10µs | 37µs | BEGIN@38 | PPIx::Regexp::Token::Greediness::
1 | 1 | 1 | 9µs | 77µs | BEGIN@36 | PPIx::Regexp::Token::Greediness::
0 | 0 | 0 | 0s | 0s | __PPIX_TOKENIZER__regexp | PPIx::Regexp::Token::Greediness::
0 | 0 | 0 | 0s | 0s | can_be_quantified | PPIx::Regexp::Token::Greediness::
0 | 0 | 0 | 0s | 0s | could_be_greediness | PPIx::Regexp::Token::Greediness::
0 | 0 | 0 | 0s | 0s | perl_version_introduced | PPIx::Regexp::Token::Greediness::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | =head1 NAME | ||||
2 | |||||
3 | PPIx::Regexp::Token::Greediness - Represent a greediness qualifier. | ||||
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 | |||||
13 | C<PPIx::Regexp::Token::Greediness> is a | ||||
14 | L<PPIx::Regexp::Token|PPIx::Regexp::Token>. | ||||
15 | |||||
16 | C<PPIx::Regexp::Token::Greediness> has no descendants. | ||||
17 | |||||
18 | =head1 DESCRIPTION | ||||
19 | |||||
20 | This class represents a greediness qualifier for the preceding | ||||
21 | quantifier. | ||||
22 | |||||
23 | =head1 METHODS | ||||
24 | |||||
25 | This class provides the following public methods. Methods not documented | ||||
26 | here are private, and unsupported in the sense that the author reserves | ||||
27 | the right to change or remove them without notice. | ||||
28 | |||||
29 | =cut | ||||
30 | |||||
31 | package PPIx::Regexp::Token::Greediness; | ||||
32 | |||||
33 | 2 | 29µs | 2 | 51µs | # spent 34µs (17+17) within PPIx::Regexp::Token::Greediness::BEGIN@33 which was called:
# once (17µs+17µs) by PPIx::Regexp::Tokenizer::BEGIN@25 at line 33 # spent 34µs making 1 call to PPIx::Regexp::Token::Greediness::BEGIN@33
# spent 17µs making 1 call to strict::import |
34 | 2 | 29µs | 2 | 23µs | # spent 17µs (11+6) within PPIx::Regexp::Token::Greediness::BEGIN@34 which was called:
# once (11µs+6µs) by PPIx::Regexp::Tokenizer::BEGIN@25 at line 34 # spent 17µs making 1 call to PPIx::Regexp::Token::Greediness::BEGIN@34
# spent 6µs making 1 call to warnings::import |
35 | |||||
36 | 2 | 30µs | 2 | 146µs | # spent 77µs (9+68) within PPIx::Regexp::Token::Greediness::BEGIN@36 which was called:
# once (9µs+68µs) by PPIx::Regexp::Tokenizer::BEGIN@25 at line 36 # spent 77µs making 1 call to PPIx::Regexp::Token::Greediness::BEGIN@36
# spent 68µs making 1 call to base::import |
37 | |||||
38 | 2 | 194µs | 2 | 65µs | # spent 37µs (10+28) within PPIx::Regexp::Token::Greediness::BEGIN@38 which was called:
# once (10µs+28µs) by PPIx::Regexp::Tokenizer::BEGIN@25 at line 38 # spent 37µs making 1 call to PPIx::Regexp::Token::Greediness::BEGIN@38
# spent 28µs making 1 call to Exporter::import |
39 | |||||
40 | 1 | 800ns | our $VERSION = '0.036'; | ||
41 | |||||
42 | # Return true if the token can be quantified, and false otherwise | ||||
43 | sub can_be_quantified { return }; | ||||
44 | |||||
45 | 1 | 2µs | my %greediness = ( | ||
46 | '?' => MINIMUM_PERL, | ||||
47 | '+' => '5.009005', | ||||
48 | ); | ||||
49 | |||||
50 | =head2 could_be_greediness | ||||
51 | |||||
52 | PPIx::Regexp::Token::Greediness->could_be_greediness( '?' ); | ||||
53 | |||||
54 | This method returns true if the given string could be a greediness | ||||
55 | indicator; that is, if it is '+' or '?'. | ||||
56 | |||||
57 | =cut | ||||
58 | |||||
59 | sub could_be_greediness { | ||||
60 | my ( $class, $string ) = @_; | ||||
61 | return $greediness{$string}; | ||||
62 | } | ||||
63 | |||||
64 | sub perl_version_introduced { | ||||
65 | my ( $self ) = @_; | ||||
66 | return $greediness{ $self->content() } || MINIMUM_PERL; | ||||
67 | } | ||||
68 | |||||
69 | sub __PPIX_TOKENIZER__regexp { | ||||
70 | my ( $class, $tokenizer, $character, $char_type ) = @_; | ||||
71 | |||||
72 | $tokenizer->prior( 'is_quantifier' ) or return; | ||||
73 | |||||
74 | $greediness{$character} or return; | ||||
75 | |||||
76 | return length $character; | ||||
77 | } | ||||
78 | |||||
79 | 1 | 4µs | 1; | ||
80 | |||||
81 | __END__ |