| 1 | package Parse::Highlife::Token::Characters; | ||||||||||
| 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 | sub new | ||||||||||
| 7 | 0 | ▶ | { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 8 | 0 | my( $class, @args ) = @_; | |||||||||
| 9 | 0 | my $self = bless Parse::Highlife::Token->new( @args ), $class; | |||||||||
| 10 | 0 | return $self -> _init( @args ); | |||||||||
| 11 | } | ||||||||||
| 12 | |||||||||||
| 13 | sub _init | ||||||||||
| 14 | 0 | ▶ | { | ||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||
| 15 | 0 | my( $self, $characters ) | |||||||||
| 16 | = params( \@_, | ||||||||||
| 17 | -characters => '', | ||||||||||
| 18 | ); | ||||||||||
| 19 | 0 | $self->{'characters'} = $characters; | |||||||||
| 20 | 0 | return $self; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub match | ||||||||||
| 24 | 0 | ▶ | { | ||||||||
|
Subroutine
match: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||
| 25 | 0 | my( $self, $string, $offset ) = @_; | |||||||||
| 26 | 0 | my $c = $offset; | |||||||||
| 27 | 0 | ▶ | while( $c < length $string ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | my $found = 0; | |||||||||
| 29 | 0 | foreach my $char (@{$self->{'characters'}}) { | |||||||||
| 30 | 0 | my $x = substr( $string, $c, 1 ); | |||||||||
| 31 | 0 | ▶ | $found = 1 if $char eq $x; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } | ||||||||||
| 33 | 0 | ▶ | last unless $found; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | $c++; | |||||||||
| 35 | } | ||||||||||
| 36 | 0 | ▶ | if( $c > $offset ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | return | ||||||||||
| 38 | 0 | extend_match( | |||||||||
| 39 | $string, | ||||||||||
| 40 | { | ||||||||||
| 41 | 'token-classname' => ref $self, | ||||||||||
| 42 | 'matched-substring' => substr( $string, $offset, $c - $offset ), | ||||||||||
| 43 | 'first-offset' => $offset, | ||||||||||
| 44 | } | ||||||||||
| 45 | ); | ||||||||||
| 46 | } | ||||||||||
| 47 | 0 | return 0; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||