Highlife/Token/Regex.pm

filter: Statementstmt 43.4% 10 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 2 totaltotal 39.3% 13 / 33 CC 2 SCAR 10.0
CC
2
Cov
40%
match
6.0
new
2.0
_init
2.0
CRAP 2.7
« Highlife/Compiler.pm ↑ Summary Highlife/Rule/Optional.pm »
1 package Parse::Highlife::Token::Regex;
2  
3 1 ▶use base qw(Parse::Highlife::Token);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Parse::Highlife::Utils qw(params extend_match);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Data::Dump qw(dump);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new
9 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
10 0 my( $class, @args ) = @_;
11 0 my $self = bless Parse::Highlife::Token->new( @args ), $class;
12 0 return $self -> _init( @args );
13 }
14  
15 sub _init
16 0 ▶{
Subroutine _init: not called CC=1 SCAR=6.9
17 0 my( $self, $regex )
18 = params( \@_,
19 -regex => '',
20 );
21 0 $self->{'regex'} = $regex;
22 0 return $self;
23 }
24  
25 sub match
26 0 ▶{
Subroutine match: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my( $self, $string, $offset ) = @_;
28 0 my $tail = substr $string, $offset;
29 0 my $regex = '^('.$self->{'regex'}.')';
30 0 ▶ if( $tail =~ /$regex/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tail =~ /$regex/) 0 0 0
31 0 my ($match) = $tail =~ /$regex/;
32 return
33 0 extend_match(
34 $string,
35 {
36 'token-classname' => ref $self,
37 'matched-substring' => $match,
38 'first-offset' => $offset,
39 }
40 );
41 }
42 0 return 0;
43 }
44  
45 1 1;
« Highlife/Compiler.pm ↑ Summary Highlife/Rule/Optional.pm »