| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/GroupType/Code.pm |
| Statements | Executed 14 statements in 305µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 16µs | 32µs | PPIx::Regexp::Token::GroupType::Code::BEGIN@39 |
| 1 | 1 | 1 | 10µs | 37µs | PPIx::Regexp::Token::GroupType::Code::BEGIN@44 |
| 1 | 1 | 1 | 10µs | 16µs | PPIx::Regexp::Token::GroupType::Code::BEGIN@40 |
| 1 | 1 | 1 | 9µs | 81µs | PPIx::Regexp::Token::GroupType::Code::BEGIN@42 |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::Code::__defining_string |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::Code::__match_setup |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::Code::perl_version_introduced |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::Code::perl_version_removed |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | =head1 NAME | ||||
| 2 | |||||
| 3 | PPIx::Regexp::Token::GroupType::Code - Represent one of the embedded code indicators | ||||
| 4 | |||||
| 5 | =head1 SYNOPSIS | ||||
| 6 | |||||
| 7 | use PPIx::Regexp::Dumper; | ||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{(?{print "hello world!\n")}smx' ) | ||||
| 9 | ->print(); | ||||
| 10 | |||||
| 11 | =head1 INHERITANCE | ||||
| 12 | |||||
| 13 | C<PPIx::Regexp::Token::GroupType::Code> is a | ||||
| 14 | L<PPIx::Regexp::Token::GroupType|PPIx::Regexp::Token::GroupType>. | ||||
| 15 | |||||
| 16 | C<PPIx::Regexp::Token::GroupType::Code> has no descendants. | ||||
| 17 | |||||
| 18 | =head1 DESCRIPTION | ||||
| 19 | |||||
| 20 | This method represents one of the embedded code indicators, either '?' | ||||
| 21 | or '??', in the zero-width assertion | ||||
| 22 | |||||
| 23 | (?{ print "Hello, world!\n" }) | ||||
| 24 | |||||
| 25 | or the old-style deferred expression syntax | ||||
| 26 | |||||
| 27 | my $foo; | ||||
| 28 | $foo = qr{ foo (??{ $foo }) }smx; | ||||
| 29 | |||||
| 30 | =head1 METHODS | ||||
| 31 | |||||
| 32 | This class provides no public methods beyond those provided by its | ||||
| 33 | superclass. | ||||
| 34 | |||||
| 35 | =cut | ||||
| 36 | |||||
| 37 | package PPIx::Regexp::Token::GroupType::Code; | ||||
| 38 | |||||
| 39 | 2 | 27µs | 2 | 48µs | # spent 32µs (16+16) within PPIx::Regexp::Token::GroupType::Code::BEGIN@39 which was called:
# once (16µs+16µs) by PPIx::Regexp::Tokenizer::BEGIN@28 at line 39 # spent 32µs making 1 call to PPIx::Regexp::Token::GroupType::Code::BEGIN@39
# spent 16µs making 1 call to strict::import |
| 40 | 2 | 27µs | 2 | 22µs | # spent 16µs (10+6) within PPIx::Regexp::Token::GroupType::Code::BEGIN@40 which was called:
# once (10µs+6µs) by PPIx::Regexp::Tokenizer::BEGIN@28 at line 40 # spent 16µs making 1 call to PPIx::Regexp::Token::GroupType::Code::BEGIN@40
# spent 6µs making 1 call to warnings::import |
| 41 | |||||
| 42 | 2 | 35µs | 2 | 153µs | # spent 81µs (9+72) within PPIx::Regexp::Token::GroupType::Code::BEGIN@42 which was called:
# once (9µs+72µs) by PPIx::Regexp::Tokenizer::BEGIN@28 at line 42 # spent 81µs making 1 call to PPIx::Regexp::Token::GroupType::Code::BEGIN@42
# spent 72µs making 1 call to base::import |
| 43 | |||||
| 44 | 2 | 206µs | 2 | 65µs | # spent 37µs (10+27) within PPIx::Regexp::Token::GroupType::Code::BEGIN@44 which was called:
# once (10µs+27µs) by PPIx::Regexp::Tokenizer::BEGIN@28 at line 44 # spent 37µs making 1 call to PPIx::Regexp::Token::GroupType::Code::BEGIN@44
# spent 27µs making 1 call to Exporter::import |
| 45 | |||||
| 46 | 1 | 800ns | our $VERSION = '0.036'; | ||
| 47 | |||||
| 48 | # Return true if the token can be quantified, and false otherwise | ||||
| 49 | # sub can_be_quantified { return }; | ||||
| 50 | |||||
| 51 | { | ||||
| 52 | 2 | 4µs | my %perl_version_introduced = ( | ||
| 53 | '?' => '5.005', | ||||
| 54 | '?p' => '5.005', # Presumed. I can find no documentation. | ||||
| 55 | '??' => '5.006', | ||||
| 56 | ); | ||||
| 57 | |||||
| 58 | sub perl_version_introduced { | ||||
| 59 | my ( $self ) = @_; | ||||
| 60 | return $perl_version_introduced{ $self->unescaped_content() } || | ||||
| 61 | '5.005'; | ||||
| 62 | } | ||||
| 63 | |||||
| 64 | } | ||||
| 65 | |||||
| 66 | { | ||||
| 67 | |||||
| 68 | 2 | 1µs | my %perl_version_removed = ( | ||
| 69 | '?p' => '5.009005', | ||||
| 70 | ); | ||||
| 71 | |||||
| 72 | sub perl_version_removed { | ||||
| 73 | my ( $self ) = @_; | ||||
| 74 | return $perl_version_removed{ $self->content() }; | ||||
| 75 | } | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | =begin comment | ||||
| 79 | |||||
| 80 | sub __PPIX_TOKENIZER__regexp { | ||||
| 81 | my ( $class, $tokenizer, $character ) = @_; | ||||
| 82 | |||||
| 83 | # Recognize '?{', '??{', or '?p{', the latter deprecated in Perl | ||||
| 84 | # 5.6, and removed in 5.10. The extra escapes are because the | ||||
| 85 | # non-open-bracket characters may appear as delimiters to the | ||||
| 86 | # expression. | ||||
| 87 | if ( my $accept = $tokenizer->find_regexp( | ||||
| 88 | qr{ \A \\? \? \\? [?p]? \{ }smx ) ) { | ||||
| 89 | |||||
| 90 | --$accept; # Don't want the curly bracket. | ||||
| 91 | |||||
| 92 | # Code token comes after. | ||||
| 93 | $tokenizer->expect( 'PPIx::Regexp::Token::Code' ); | ||||
| 94 | |||||
| 95 | return $accept; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | return; | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | =end comment | ||||
| 102 | |||||
| 103 | =cut | ||||
| 104 | |||||
| 105 | sub __defining_string { | ||||
| 106 | return ( | ||||
| 107 | { suffix => '{' }, | ||||
| 108 | '?', | ||||
| 109 | '??', | ||||
| 110 | '?p', | ||||
| 111 | ); | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | sub __match_setup { | ||||
| 115 | my ( $class, $tokenizer ) = @_; | ||||
| 116 | $tokenizer->expect( qw{ PPIx::Regexp::Token::Code } ); | ||||
| 117 | return; | ||||
| 118 | } | ||||
| 119 | |||||
| 120 | 1 | 5µs | 1; | ||
| 121 | |||||
| 122 | __END__ |