line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Highlife::Token::Characters; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use base qw(Parse::Highlife::Token); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
4
|
1
|
|
|
1
|
|
4
|
use Parse::Highlife::Utils qw(params extend_match); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
279
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new |
7
|
|
|
|
|
|
|
{ |
8
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
{ |
15
|
0
|
|
|
0
|
|
|
my( $self, $characters ) |
16
|
|
|
|
|
|
|
= params( \@_, |
17
|
|
|
|
|
|
|
-characters => '', |
18
|
|
|
|
|
|
|
); |
19
|
0
|
|
|
|
|
|
$self->{'characters'} = $characters; |
20
|
0
|
|
|
|
|
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub match |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
0
|
0
|
|
my( $self, $string, $offset ) = @_; |
26
|
0
|
|
|
|
|
|
my $c = $offset; |
27
|
0
|
|
|
|
|
|
while( $c < length $string ) { |
28
|
0
|
|
|
|
|
|
my $found = 0; |
29
|
0
|
|
|
|
|
|
foreach my $char (@{$self->{'characters'}}) { |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $x = substr( $string, $c, 1 ); |
31
|
0
|
0
|
|
|
|
|
$found = 1 if $char eq $x; |
32
|
|
|
|
|
|
|
} |
33
|
0
|
0
|
|
|
|
|
last unless $found; |
34
|
0
|
|
|
|
|
|
$c++; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
0
|
|
|
|
|
if( $c > $offset ) { |
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; |