| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/Quantifier.pm |
| Statements | Executed 9 statements in 204µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 14µs | 27µs | PPIx::Regexp::Token::Quantifier::BEGIN@33 |
| 1 | 1 | 1 | 8µs | 14µs | PPIx::Regexp::Token::Quantifier::BEGIN@34 |
| 1 | 1 | 1 | 7µs | 68µs | PPIx::Regexp::Token::Quantifier::BEGIN@36 |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::Quantifier::__PPIX_TOKENIZER__regexp |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::Quantifier::can_be_quantified |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::Quantifier::could_be_quantifier |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::Quantifier::is_quantifier |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | =head1 NAME | ||||
| 2 | |||||
| 3 | PPIx::Regexp::Token::Quantifier - Represent an atomic quantifier. | ||||
| 4 | |||||
| 5 | =head1 SYNOPSIS | ||||
| 6 | |||||
| 7 | use PPIx::Regexp::Dumper; | ||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{\w+}smx' ) | ||||
| 9 | ->print(); | ||||
| 10 | |||||
| 11 | =head1 INHERITANCE | ||||
| 12 | |||||
| 13 | C<PPIx::Regexp::Token::Quantifier> is a | ||||
| 14 | L<PPIx::Regexp::Token|PPIx::Regexp::Token>. | ||||
| 15 | |||||
| 16 | C<PPIx::Regexp::Token::Quantifier> has no descendants. | ||||
| 17 | |||||
| 18 | =head1 DESCRIPTION | ||||
| 19 | |||||
| 20 | This class represents an atomic quantifier; that is, one of the | ||||
| 21 | characters C<*>, C<+>, or C<?>. | ||||
| 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::Quantifier; | ||||
| 32 | |||||
| 33 | 2 | 23µs | 2 | 41µs | # spent 27µs (14+13) within PPIx::Regexp::Token::Quantifier::BEGIN@33 which was called:
# once (14µs+13µs) by PPIx::Regexp::Tokenizer::BEGIN@37 at line 33 # spent 27µs making 1 call to PPIx::Regexp::Token::Quantifier::BEGIN@33
# spent 13µs making 1 call to strict::import |
| 34 | 2 | 28µs | 2 | 19µs | # spent 14µs (8+5) within PPIx::Regexp::Token::Quantifier::BEGIN@34 which was called:
# once (8µs+5µs) by PPIx::Regexp::Tokenizer::BEGIN@37 at line 34 # spent 14µs making 1 call to PPIx::Regexp::Token::Quantifier::BEGIN@34
# spent 5µs making 1 call to warnings::import |
| 35 | |||||
| 36 | 2 | 146µs | 2 | 129µs | # spent 68µs (7+61) within PPIx::Regexp::Token::Quantifier::BEGIN@36 which was called:
# once (7µs+61µs) by PPIx::Regexp::Tokenizer::BEGIN@37 at line 36 # spent 68µs making 1 call to PPIx::Regexp::Token::Quantifier::BEGIN@36
# spent 61µs making 1 call to base::import |
| 37 | |||||
| 38 | 1 | 500ns | our $VERSION = '0.036'; | ||
| 39 | |||||
| 40 | # Return true if the token can be quantified, and false otherwise | ||||
| 41 | sub can_be_quantified { return }; | ||||
| 42 | |||||
| 43 | # Return true if the token is a quantifier. | ||||
| 44 | sub is_quantifier { return 1 }; | ||||
| 45 | |||||
| 46 | 1 | 3µs | my %quantifier = map { $_ => 1 } qw{ * + ? }; | ||
| 47 | |||||
| 48 | =head2 could_be_quantifier | ||||
| 49 | |||||
| 50 | PPIx::Regexp::Token::Quantifier->could_be_quantifier( '*' ); | ||||
| 51 | |||||
| 52 | This method returns true if the given string could be a quantifier; that | ||||
| 53 | is, if it is '*', '+', or '?'. | ||||
| 54 | |||||
| 55 | =cut | ||||
| 56 | |||||
| 57 | sub could_be_quantifier { | ||||
| 58 | my ( $class, $string ) = @_; | ||||
| 59 | return $quantifier{$string}; | ||||
| 60 | } | ||||
| 61 | |||||
| 62 | sub __PPIX_TOKENIZER__regexp { | ||||
| 63 | my ( $class, $tokenizer, $character ) = @_; | ||||
| 64 | |||||
| 65 | $tokenizer->prior( 'can_be_quantified' ) | ||||
| 66 | or return; | ||||
| 67 | |||||
| 68 | return $quantifier{$character}; | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | 1 | 3µs | 1; | ||
| 72 | |||||
| 73 | __END__ |