Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/CharClass/POSIX.pm |
Statements | Executed 12 statements in 254µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 18µs | 23µs | BEGIN@40 | PPIx::Regexp::Token::CharClass::POSIX::
1 | 1 | 1 | 13µs | 25µs | BEGIN@39 | PPIx::Regexp::Token::CharClass::POSIX::
1 | 1 | 1 | 9µs | 39µs | BEGIN@44 | PPIx::Regexp::Token::CharClass::POSIX::
1 | 1 | 1 | 8µs | 334µs | BEGIN@42 | PPIx::Regexp::Token::CharClass::POSIX::
0 | 0 | 0 | 0s | 0s | __PPIX_TOKENIZER__regexp | PPIx::Regexp::Token::CharClass::POSIX::
0 | 0 | 0 | 0s | 0s | perl_version_introduced | PPIx::Regexp::Token::CharClass::POSIX::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | =head1 NAME | ||||
2 | |||||
3 | PPIx::Regexp::Token::CharClass::POSIX - Represent a POSIX character class | ||||
4 | |||||
5 | =head1 SYNOPSIS | ||||
6 | |||||
7 | use PPIx::Regexp::Dumper; | ||||
8 | PPIx::Regexp::Dumper->new( 'qr{ [[:alpha:]] }smx' ) | ||||
9 | ->print(); | ||||
10 | |||||
11 | =head1 INHERITANCE | ||||
12 | |||||
13 | C<PPIx::Regexp::Token::CharClass::POSIX> is a | ||||
14 | L<PPIx::Regexp::Token::CharClass|PPIx::Regexp::Token::CharClass>. | ||||
15 | |||||
16 | C<PPIx::Regexp::Token::CharClass::POSIX> is the parent of | ||||
17 | L<PPIx::Regexp::Token::CharClass::POSIX::Unknown|PPIx::Regexp::Token::CharClass::POSIX::Unknown>. | ||||
18 | |||||
19 | =head1 DESCRIPTION | ||||
20 | |||||
21 | This class represents a POSIX character class. It will only be | ||||
22 | recognized within a character class. | ||||
23 | |||||
24 | Note that collating symbols (e.g. C<[.ch.]>) and equivalence classes | ||||
25 | (e.g. C<[=a=]>) are valid in the POSIX standard, but are not valid in | ||||
26 | Perl regular expressions. These end up being represented by | ||||
27 | L<PPIx::Regexp::Token::CharClass::POSIX::Unknown|PPIx::Regexp::Token::CharClass::POSIX::Unknown>, | ||||
28 | and are considered a parse failure. | ||||
29 | |||||
30 | =head1 METHODS | ||||
31 | |||||
32 | This class provides the following public methods beyond those provided | ||||
33 | by its superclass. | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | package PPIx::Regexp::Token::CharClass::POSIX; | ||||
38 | |||||
39 | 2 | 30µs | 2 | 37µs | # spent 25µs (13+12) within PPIx::Regexp::Token::CharClass::POSIX::BEGIN@39 which was called:
# once (13µs+12µs) by PPIx::Regexp::Tokenizer::BEGIN@17 at line 39 # spent 25µs making 1 call to PPIx::Regexp::Token::CharClass::POSIX::BEGIN@39
# spent 12µs making 1 call to strict::import |
40 | 2 | 24µs | 2 | 28µs | # spent 23µs (18+5) within PPIx::Regexp::Token::CharClass::POSIX::BEGIN@40 which was called:
# once (18µs+5µs) by PPIx::Regexp::Tokenizer::BEGIN@17 at line 40 # spent 23µs making 1 call to PPIx::Regexp::Token::CharClass::POSIX::BEGIN@40
# spent 5µs making 1 call to warnings::import |
41 | |||||
42 | 2 | 27µs | 2 | 660µs | # spent 334µs (8+326) within PPIx::Regexp::Token::CharClass::POSIX::BEGIN@42 which was called:
# once (8µs+326µs) by PPIx::Regexp::Tokenizer::BEGIN@17 at line 42 # spent 334µs making 1 call to PPIx::Regexp::Token::CharClass::POSIX::BEGIN@42
# spent 326µs making 1 call to base::import |
43 | |||||
44 | 2 | 167µs | 2 | 69µs | # spent 39µs (9+30) within PPIx::Regexp::Token::CharClass::POSIX::BEGIN@44 which was called:
# once (9µs+30µs) by PPIx::Regexp::Tokenizer::BEGIN@17 at line 44 # spent 39µs making 1 call to PPIx::Regexp::Token::CharClass::POSIX::BEGIN@44
# spent 30µs making 1 call to Exporter::import |
45 | |||||
46 | 1 | 700ns | 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 | ##=head2 is_case_sensitive | ||||
52 | ## | ||||
53 | ##This override of the superclass method of the same name returns true if | ||||
54 | ##the character class is C<[:lower:]> or C<[:upper:]>, and false (but | ||||
55 | ##defined) for all other POSIX character classes. | ||||
56 | ## | ||||
57 | ##=cut | ||||
58 | ## | ||||
59 | ##{ | ||||
60 | ## my %case_sensitive = map { $_ => 1 } qw{ [:lower:] [:upper:] }; | ||||
61 | ## | ||||
62 | ## sub is_case_sensitive { | ||||
63 | ## my ( $self ) = @_; | ||||
64 | ## return $case_sensitive{ $self->content() } || 0; | ||||
65 | ## } | ||||
66 | ##} | ||||
67 | |||||
68 | sub perl_version_introduced { | ||||
69 | # my ( $self ) = @_; | ||||
70 | return '5.006'; | ||||
71 | } | ||||
72 | |||||
73 | { | ||||
74 | |||||
75 | 2 | 2µs | my %class = ( | ||
76 | ':' => __PACKAGE__, | ||||
77 | ); | ||||
78 | |||||
79 | sub __PPIX_TOKENIZER__regexp { | ||||
80 | my ( $class, $tokenizer, $character ) = @_; | ||||
81 | |||||
82 | $tokenizer->cookie( COOKIE_CLASS ) | ||||
83 | or $tokenizer->cookie( COOKIE_REGEX_SET ) | ||||
84 | or return; | ||||
85 | |||||
86 | if ( my $accept = $tokenizer->find_regexp( | ||||
87 | qr{ \A [[] ( [.=:] ) \^? .*? \1 []] }smx ) ) { | ||||
88 | my ( $punc ) = $tokenizer->capture(); | ||||
89 | return $tokenizer->make_token( $accept, | ||||
90 | $class{$punc} || __PACKAGE__ . '::Unknown' ); | ||||
91 | } | ||||
92 | |||||
93 | return; | ||||
94 | |||||
95 | } | ||||
96 | |||||
97 | } | ||||
98 | |||||
99 | 1 | 3µs | 1; | ||
100 | |||||
101 | __END__ |