| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | PPIx::Regexp::Structure::CharClass - Represent a character class | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | use PPIx::Regexp::Dumper; | ||||||||||||||||||||||||||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{[fo]}smx' ) | ||||||||||||||||||||||||||||
| 9 | ->print(); | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 INHERITANCE | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | C<PPIx::Regexp::Structure::CharClass> is a | ||||||||||||||||||||||||||||
| 14 | L<PPIx::Regexp::Structure|PPIx::Regexp::Structure>. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | C<PPIx::Regexp::Structure::CharClass> has no descendants. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | This class represents a square-bracketed character class. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | This class provides the following public methods. Methods not documented | ||||||||||||||||||||||||||||
| 25 | here are private, and unsupported in the sense that the author reserves | ||||||||||||||||||||||||||||
| 26 | the right to change or remove them without notice. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | package PPIx::Regexp::Structure::CharClass; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 9 | ▶ | use base qw{ PPIx::Regexp::Structure }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 9 | ▶ | use PPIx::Regexp::Constant qw{ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | LITERAL_LEFT_CURLY_REMOVED_PHASE_2 | ||||||||||||||||||||||||||||
| 39 | @CARP_NOT | ||||||||||||||||||||||||||||
| 40 | 9 | }; | |||||||||||||||||||||||||||
| 41 | 9 | ▶ | use PPIx::Regexp::Util qw{ :width_one __instance }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 9 | our $VERSION = '0.092'; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 37 | ▶ | sub __new { | ||||||||||||||||||||||||||
|
Subroutine
__new: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 46 | 37 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||
| 47 | 37 | ▶ | ref $class and $class = ref $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 37 | my %brkt; | |||||||||||||||||||||||||||
| 49 | 37 | $brkt{finish} = pop @args; | |||||||||||||||||||||||||||
| 50 | 37 | $brkt{start} = shift @args; | |||||||||||||||||||||||||||
| 51 | __instance( $args[0], 'PPIx::Regexp::Token::Operator' ) | ||||||||||||||||||||||||||||
| 52 | and $args[0]->content() eq '^' | ||||||||||||||||||||||||||||
| 53 | 37 | ▶ | and $brkt{type} = shift @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
__instance($args[0], "PPIx::Regexp::Token::Operator") and $args[0]->content eq "^"
MC/DC50%1/2
__instance($args[0], "PPIx::Regexp::Token::Operator") and $args[0]->content eq "^"
__instance($args[0], "PPIx::Regexp::Token::Operator")
$args[0]->content eq "^"
Truth table66%2/3
A and B
A= __instance($args[0], "PPIx::Regexp::Token::Operator")B= $args[0]->content eq "^"
| |||||||||||||||||||||||||||||
| 54 | 37 | return $class->SUPER::__new( \%brkt, @args ); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub explain { | ||||||||||||||||||||||||||
|
Subroutine
explain: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->negated() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | and return 'Inverted character class'; | ||||||||||||||||||||||||||||
| 61 | 0 | return 'Character class'; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head2 negated | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | $class->negated() and print "Class is negated\n"; | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | This method returns true if the character class is negated -- that is, | ||||||||||||||||||||||||||||
| 69 | if the first token inside the left square bracket is a caret (C<^>). | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub negated { | ||||||||||||||||||||||||||
|
Subroutine
negated: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 75 | 2 | ▶ | return $self->type() ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub __following_literal_left_curly_disallowed_in { | ||||||||||||||||||||||||||
|
Subroutine
__following_literal_left_curly_disallowed_in: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | 1 | return LITERAL_LEFT_CURLY_REMOVED_PHASE_2; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # Called by the lexer to record the capture number. | ||||||||||||||||||||||||||||
| 83 | 36 | ▶ | sub __PPIX_LEXER__record_capture_number { | ||||||||||||||||||||||||||
|
Subroutine
__PPIX_LEXER__record_capture_number: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 84 | 36 | my ( undef, $number ) = @_; # Invocant unused | |||||||||||||||||||||||||||
| 85 | 36 | return $number; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 9 | 1; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | __END__ | ||||||||||||||||||||||||||||