| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/GroupType/NamedCapture.pm |
| Statements | Executed 14 statements in 601µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 35µs | 35µs | PPIx::Regexp::Token::GroupType::NamedCapture::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 29µs | 124µs | PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@48 |
| 1 | 1 | 1 | 16µs | 32µs | PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@37 |
| 1 | 1 | 1 | 10µs | 17µs | PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@38 |
| 1 | 1 | 1 | 10µs | 35µs | PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@44 |
| 1 | 1 | 1 | 10µs | 39µs | PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@42 |
| 1 | 1 | 1 | 9µs | 77µs | PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@40 |
| 1 | 1 | 1 | 2µs | 2µs | PPIx::Regexp::Token::GroupType::NamedCapture::CORE:qr (opcode) |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::NamedCapture::__PPIX_TOKEN__post_make |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::NamedCapture::__make_group_type_matcher |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::NamedCapture::name |
| 0 | 0 | 0 | 0s | 0s | PPIx::Regexp::Token::GroupType::NamedCapture::perl_version_introduced |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | =head1 NAME | ||||
| 2 | |||||
| 3 | PPIx::Regexp::Token::GroupType::NamedCapture - Represent a named capture | ||||
| 4 | |||||
| 5 | =head1 SYNOPSIS | ||||
| 6 | |||||
| 7 | use PPIx::Regexp::Dumper; | ||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{(?<baz>foo)}smx' ) | ||||
| 9 | ->print(); | ||||
| 10 | |||||
| 11 | =head1 INHERITANCE | ||||
| 12 | |||||
| 13 | C<PPIx::Regexp::Token::GroupType::NamedCapture> is a | ||||
| 14 | L<PPIx::Regexp::Token::GroupType|PPIx::Regexp::Token::GroupType>. | ||||
| 15 | |||||
| 16 | C<PPIx::Regexp::Token::GroupType::NamedCapture> has no descendants. | ||||
| 17 | |||||
| 18 | =head1 DESCRIPTION | ||||
| 19 | |||||
| 20 | This class represents a named capture specification. Its content will be | ||||
| 21 | something like one of the following: | ||||
| 22 | |||||
| 23 | ?<NAME> | ||||
| 24 | ?'NAME' | ||||
| 25 | ?P<NAME> | ||||
| 26 | |||||
| 27 | =head1 METHODS | ||||
| 28 | |||||
| 29 | This class provides the following public methods. Methods not documented | ||||
| 30 | here are private, and unsupported in the sense that the author reserves | ||||
| 31 | the right to change or remove them without notice. | ||||
| 32 | |||||
| 33 | =cut | ||||
| 34 | |||||
| 35 | package PPIx::Regexp::Token::GroupType::NamedCapture; | ||||
| 36 | |||||
| 37 | 2 | 33µs | 2 | 48µs | # spent 32µs (16+16) within PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@37 which was called:
# once (16µs+16µs) by PPIx::Regexp::Tokenizer::BEGIN@30 at line 37 # spent 32µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@37
# spent 16µs making 1 call to strict::import |
| 38 | 2 | 33µs | 2 | 23µs | # spent 17µs (10+6) within PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@38 which was called:
# once (10µs+6µs) by PPIx::Regexp::Tokenizer::BEGIN@30 at line 38 # spent 17µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@38
# spent 6µs making 1 call to warnings::import |
| 39 | |||||
| 40 | 2 | 35µs | 2 | 146µs | # spent 77µs (9+68) within PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@40 which was called:
# once (9µs+68µs) by PPIx::Regexp::Tokenizer::BEGIN@30 at line 40 # spent 77µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@40
# spent 68µs making 1 call to base::import |
| 41 | |||||
| 42 | 2 | 35µs | 2 | 69µs | # spent 39µs (10+30) within PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@42 which was called:
# once (10µs+30µs) by PPIx::Regexp::Tokenizer::BEGIN@30 at line 42 # spent 39µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@42
# spent 30µs making 1 call to Exporter::import |
| 43 | |||||
| 44 | 2 | 74µs | 2 | 60µs | # spent 35µs (10+25) within PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@44 which was called:
# once (10µs+25µs) by PPIx::Regexp::Tokenizer::BEGIN@30 at line 44 # spent 35µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@44
# spent 25µs making 1 call to Exporter::import |
| 45 | |||||
| 46 | 1 | 800ns | our $VERSION = '0.036'; | ||
| 47 | |||||
| 48 | # spent 124µs (29+95) within PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@48 which was called:
# once (29µs+95µs) by PPIx::Regexp::Tokenizer::BEGIN@30 at line 50 | ||||
| 49 | 1 | 300ns | qr{ \A \\? \? (?: P? < ( @{[ RE_CAPTURE_NAME ]} ) \\? > | | ||
| 50 | 1 | 389µs | 4 | 220µs | \\? ' ( @{[ RE_CAPTURE_NAME ]} ) \\? ' ) }smxo; # spent 124µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@48
# spent 58µs making 1 call to constant::import
# spent 35µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::CORE:regcomp
# spent 2µs making 1 call to PPIx::Regexp::Token::GroupType::NamedCapture::CORE:qr |
| 51 | |||||
| 52 | # Return true if the token can be quantified, and false otherwise | ||||
| 53 | # sub can_be_quantified { return }; | ||||
| 54 | |||||
| 55 | =head2 name | ||||
| 56 | |||||
| 57 | This method returns the name of the capture. | ||||
| 58 | |||||
| 59 | =cut | ||||
| 60 | |||||
| 61 | sub name { | ||||
| 62 | my ( $self ) = @_; | ||||
| 63 | return $self->{name}; | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | sub perl_version_introduced { | ||||
| 67 | return '5.009005'; | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | sub __PPIX_TOKEN__post_make { | ||||
| 71 | my ( $self, $tokenizer ) = @_; | ||||
| 72 | if ( $tokenizer ) { | ||||
| 73 | foreach my $name ( $tokenizer->capture() ) { | ||||
| 74 | defined $name or next; | ||||
| 75 | $self->{name} = $name; | ||||
| 76 | return; | ||||
| 77 | } | ||||
| 78 | } else { | ||||
| 79 | foreach my $name ( | ||||
| 80 | $self->content() =~ m/ @{[ NAMED_CAPTURE ]} /smxo ) { | ||||
| 81 | defined $name or next; | ||||
| 82 | $self->{name} = $name; | ||||
| 83 | return; | ||||
| 84 | } | ||||
| 85 | } | ||||
| 86 | |||||
| 87 | confess 'Programming error - can not figure out capture name'; | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | =begin comment | ||||
| 91 | |||||
| 92 | sub __PPIX_TOKENIZER__regexp { | ||||
| 93 | my ( $class, $tokenizer, $character ) = @_; | ||||
| 94 | |||||
| 95 | # The optional escapes are because any of the non-open-bracket | ||||
| 96 | # punctuation characters may be the expression delimiter. | ||||
| 97 | if ( my $accept = $tokenizer->find_regexp( NAMED_CAPTURE ) ) { | ||||
| 98 | return $accept; | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | return; | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | =end comment | ||||
| 105 | |||||
| 106 | =cut | ||||
| 107 | |||||
| 108 | sub __make_group_type_matcher { | ||||
| 109 | return { | ||||
| 110 | '' => [ | ||||
| 111 | qr/ \A [?] P? < ( @{[ RE_CAPTURE_NAME ]} ) > /smxo, | ||||
| 112 | qr/ \A [?] ' ( @{[ RE_CAPTURE_NAME ]} ) ' /smxo, | ||||
| 113 | ], | ||||
| 114 | '?' => [ | ||||
| 115 | qr/ \A \\ [?] P? < ( @{[ RE_CAPTURE_NAME ]} ) > /smxo, | ||||
| 116 | qr/ \A \\ [?] ' ( @{[ RE_CAPTURE_NAME ]} ) ' /smxo, | ||||
| 117 | ], | ||||
| 118 | q{'} => [ | ||||
| 119 | qr/ \A [?] P? < ( @{[ RE_CAPTURE_NAME ]} ) > /smxo, | ||||
| 120 | qr/ \A [?] \\ ' ( @{[ RE_CAPTURE_NAME ]} ) \\ ' /smxo, | ||||
| 121 | ], | ||||
| 122 | }; | ||||
| 123 | } | ||||
| 124 | |||||
| 125 | 1 | 3µs | 1; | ||
| 126 | |||||
| 127 | __END__ | ||||
# spent 2µs within PPIx::Regexp::Token::GroupType::NamedCapture::CORE:qr which was called:
# once (2µs+0s) by PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@48 at line 50 | |||||
# spent 35µs within PPIx::Regexp::Token::GroupType::NamedCapture::CORE:regcomp which was called:
# once (35µs+0s) by PPIx::Regexp::Token::GroupType::NamedCapture::BEGIN@48 at line 50 |