Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/Condition.pm |
Statements | Executed 11 statements in 349µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 31µs | 31µs | CORE:regcomp (opcode) | PPIx::Regexp::Token::Condition::
1 | 1 | 1 | 12µs | 24µs | BEGIN@33 | PPIx::Regexp::Token::Condition::
1 | 1 | 1 | 7µs | 12µs | BEGIN@34 | PPIx::Regexp::Token::Condition::
1 | 1 | 1 | 7µs | 26µs | BEGIN@38 | PPIx::Regexp::Token::Condition::
1 | 1 | 1 | 6µs | 60µs | BEGIN@36 | PPIx::Regexp::Token::Condition::
4 | 1 | 1 | 5µs | 5µs | CORE:qr (opcode) | PPIx::Regexp::Token::Condition::
0 | 0 | 0 | 0s | 0s | __PPIX_TOKENIZER__regexp | PPIx::Regexp::Token::Condition::
0 | 0 | 0 | 0s | 0s | __PPIX_TOKEN__recognize | PPIx::Regexp::Token::Condition::
0 | 0 | 0 | 0s | 0s | perl_version_introduced | PPIx::Regexp::Token::Condition::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | =head1 NAME | ||||
2 | |||||
3 | PPIx::Regexp::Token::Condition - Represent the condition of a switch | ||||
4 | |||||
5 | =head1 SYNOPSIS | ||||
6 | |||||
7 | use PPIx::Regexp::Dumper; | ||||
8 | PPIx::Regexp::Dumper->new( 'qr{(?(1)foo|bar)}smx' ) | ||||
9 | ->print(); | ||||
10 | |||||
11 | =head1 INHERITANCE | ||||
12 | |||||
13 | C<PPIx::Regexp::Token::Condition> is a | ||||
14 | L<PPIx::Regexp::Token::Reference|PPIx::Regexp::Token::Reference>. | ||||
15 | |||||
16 | C<PPIx::Regexp::Token::Condition> has no descendants. | ||||
17 | |||||
18 | =head1 DESCRIPTION | ||||
19 | |||||
20 | This class represents the condition portion of a switch or conditional | ||||
21 | expression, provided that condition is reasonably represented as a | ||||
22 | token. | ||||
23 | |||||
24 | =head1 METHODS | ||||
25 | |||||
26 | This class provides no public methods beyond those provided by its | ||||
27 | superclass. | ||||
28 | |||||
29 | =cut | ||||
30 | |||||
31 | package PPIx::Regexp::Token::Condition; | ||||
32 | |||||
33 | 2 | 20µs | 2 | 35µs | # spent 24µs (12+12) within PPIx::Regexp::Token::Condition::BEGIN@33 which was called:
# once (12µs+12µs) by PPIx::Regexp::Tokenizer::BEGIN@22 at line 33 # spent 24µs making 1 call to PPIx::Regexp::Token::Condition::BEGIN@33
# spent 12µs making 1 call to strict::import |
34 | 2 | 21µs | 2 | 16µs | # spent 12µs (7+5) within PPIx::Regexp::Token::Condition::BEGIN@34 which was called:
# once (7µs+5µs) by PPIx::Regexp::Tokenizer::BEGIN@22 at line 34 # spent 12µs making 1 call to PPIx::Regexp::Token::Condition::BEGIN@34
# spent 5µs making 1 call to warnings::import |
35 | |||||
36 | 2 | 25µs | 2 | 113µs | # spent 60µs (6+54) within PPIx::Regexp::Token::Condition::BEGIN@36 which was called:
# once (6µs+54µs) by PPIx::Regexp::Tokenizer::BEGIN@22 at line 36 # spent 60µs making 1 call to PPIx::Regexp::Token::Condition::BEGIN@36
# spent 54µs making 1 call to base::import |
37 | |||||
38 | 2 | 220µs | 2 | 46µs | # spent 26µs (7+19) within PPIx::Regexp::Token::Condition::BEGIN@38 which was called:
# once (7µs+19µs) by PPIx::Regexp::Tokenizer::BEGIN@22 at line 38 # spent 26µs making 1 call to PPIx::Regexp::Token::Condition::BEGIN@38
# spent 19µs making 1 call to Exporter::import |
39 | |||||
40 | 1 | 600ns | our $VERSION = '0.036'; | ||
41 | |||||
42 | sub perl_version_introduced { | ||||
43 | my ( $self ) = @_; | ||||
44 | $self->content() =~ m/ \A [(] \d+ [)] \z /smx | ||||
45 | and return '5.005'; | ||||
46 | return '5.009005'; | ||||
47 | } | ||||
48 | |||||
49 | my @recognize = ( | ||||
50 | [ qr{ \A \( (?: ( \d+ ) | R (\d+) ) \) }smx, | ||||
51 | { is_named => 0 } ], | ||||
52 | [ qr{ \A \( R \) }smx, | ||||
53 | { is_named => 0, capture => '0' } ], | ||||
54 | 1 | 58µs | 5 | 36µs | [ qr{ \A \( (?: < ( @{[ RE_CAPTURE_NAME ]} ) > | # spent 31µs making 1 call to PPIx::Regexp::Token::Condition::CORE:regcomp
# spent 5µs making 4 calls to PPIx::Regexp::Token::Condition::CORE:qr, avg 1µs/call |
55 | ' ( @{[ RE_CAPTURE_NAME ]} ) ' | | ||||
56 | R & ( @{[ RE_CAPTURE_NAME ]} ) ) \) }smxo, | ||||
57 | { is_named => 1} ], | ||||
58 | [ qr{ \A \( DEFINE \) }smx, | ||||
59 | { is_named => 0, capture => '0' } ], | ||||
60 | ); | ||||
61 | |||||
62 | # This must be implemented by tokens which do not recognize themselves. | ||||
63 | # The return is a list of list references. Each list reference must | ||||
64 | # contain a regular expression that recognizes the token, and optionally | ||||
65 | # a reference to a hash to pass to make_token as the class-specific | ||||
66 | # arguments. The regular expression MUST be anchored to the beginning of | ||||
67 | # the string. | ||||
68 | sub __PPIX_TOKEN__recognize { | ||||
69 | return @recognize; | ||||
70 | } | ||||
71 | |||||
72 | |||||
73 | # Return true if the token can be quantified, and false otherwise | ||||
74 | # sub can_be_quantified { return }; | ||||
75 | |||||
76 | sub __PPIX_TOKENIZER__regexp { | ||||
77 | my ( $class, $tokenizer, $character ) = @_; | ||||
78 | |||||
79 | foreach ( @recognize ) { | ||||
80 | my ( $re, $arg ) = @{ $_ }; | ||||
81 | my $accept = $tokenizer->find_regexp( $re ) or next; | ||||
82 | return $tokenizer->make_token( $accept, __PACKAGE__, $arg ); | ||||
83 | } | ||||
84 | |||||
85 | return; | ||||
86 | } | ||||
87 | |||||
88 | 1 | 6µs | 1; | ||
89 | |||||
90 | __END__ | ||||
# spent 5µs within PPIx::Regexp::Token::Condition::CORE:qr which was called 4 times, avg 1µs/call:
# 4 times (5µs+0s) by PPIx::Regexp::Tokenizer::BEGIN@22 at line 54, avg 1µs/call | |||||
# spent 31µs within PPIx::Regexp::Token::Condition::CORE:regcomp which was called:
# once (31µs+0s) by PPIx::Regexp::Tokenizer::BEGIN@22 at line 54 |