Regexp/Token/Unknown.pm

filter: Statementstmt 88.5% 31 / 35 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 76.9% 10 / 13 Podpod 100% 5 / 5 totaltotal 83.0% 49 / 59 CC 4 SCAR 6.9
CC
4
Cov
83%
__new
4.2
is_matcher
2.0
ordinal
2.0
CRAP 2.0
« Regexp/Token/Quantifier.pm ↑ Summary Regexp/Token/GroupType/NamedCapture.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Token::Unknown - Represent an unknown token
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'xyzzy' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Token::Unknown> is a
14 L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15  
16 C<PPIx::Regexp::Token::Unknown> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This token represents something that could not be identified by the
21 tokenizer. Sometimes the lexer can fix these up, but the presence of one
22 of these in a finished parse represents something in the regular
23 expression that was not understood.
24  
25 =head1 METHODS
26  
27 This class provides the following public methods. Methods not documented
28 here are private, and unsupported in the sense that the author reserves
29 the right to change or remove them without notice.
30  
31 =cut
32  
33 package PPIx::Regexp::Token::Unknown;
34  
35 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 9 ▶use base qw{ PPIx::Regexp::Token };
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 9 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
41 9 ▶use PPIx::Regexp::Constant qw{ @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
42 9 ▶use PPIx::Regexp::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 9 our $VERSION = '0.092';
45  
46 38 ▶sub __new {
Subroutine __new: called CC=4 SCAR=14.5
47 38 my ( $class, $content, %arg ) = @_;
48  
49 defined $arg{error}
50 38 ▶ or Carp::confess( 'Programming error - error argument required' );
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{"error"} or Carp::confess("Programming error - error argument required") 38 0 38
51  
52 38 ▶ my $self = $class->SUPER::__new( $content, %arg )
Branch: 1 branch
BranchTrueFalseTotal
my $self = $class->SUPER::__new($content, %arg) or return 38 0 38
53 or return;
54  
55 38 $self->{error} = $arg{error};
56  
57 $self->{explanation} = defined $arg{explanation} ?
58 $arg{explanation} :
59 38 ▶ $arg{error};
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{'explanation'} ? : 0 38 38
60  
61 38 return $self;
62 }
63  
64 # Return true if the token can be quantified, and false otherwise
65 6 ▶sub can_be_quantified { return };
Subroutine can_be_quantified: called CC=1 SCAR=0.0
Pod documented
66  
67 1 ▶sub explain {
Subroutine explain: called CC=1 SCAR=0.0
Pod documented
68 1 my ( $self ) = @_;
69 1 return $self->{explanation};
70 }
71  
72 =head2 is_matcher
73  
74 This method returns C<undef> because, since we could not identify the
75 token, we have no idea whether it matches anything.
76  
77 =cut
78  
79 0 ▶sub is_matcher { return undef; } ## no critic (ProhibitExplicitReturnUndef)
Subroutine is_matcher: not called CC=1 SCAR=6.9
Pod documented
80  
81 =head2 ordinal
82  
83 This method returns the results of the ord built-in on the content
84 (meaning, of course, the first character of the content). No attempt is
85 made to interpret the content, since after all this B<is> the unknown
86 token.
87  
88 =cut
89  
90 0 ▶sub ordinal {
Subroutine ordinal: not called CC=1 SCAR=6.9
Pod documented
91 0 my ( $self ) = @_;
92 0 return ord $self->content();
93 }
94  
95 0 ▶sub width {
Subroutine width: not called CC=1 SCAR=6.9
Pod documented
96 0 return ( undef, undef );
97 }
98  
99 9 *__PPIX_ELEM__post_reblessing = \&PPIx::Regexp::Util::__post_rebless_error;
100  
101 # Since the lexer does not count these on the way in (because it needs
102 # the liberty to rebless them into a known class if it figures out what
103 # is going on) we count them as failures at the finalization step.
104 18 ▶sub __PPIX_LEXER__finalize {
Subroutine __PPIX_LEXER__finalize: called CC=1 SCAR=0.0
105 18 return 1;
106 }
107  
108 9 1;
109  
110 __END__
« Regexp/Token/Quantifier.pm ↑ Summary Regexp/Token/GroupType/NamedCapture.pm »